ec2878f5d46108d32dce7228dcf9fd15f8c58ad8
1 /*
2 * Authors:
3 * Ted Gould <ted@gould.cx>
4 *
5 * Copyright (C) 2005 Authors
6 *
7 * Released under GNU GPL, read the file 'COPYING' for more information
8 */
11 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
15 #include <glibmm/i18n.h>
18 #include "inkscape.h"
19 #include "prefs-utils.h"
20 #include "dialogs/extensions.h"
21 #include "extension/extension.h"
23 #include "error-file.h"
25 /** The name and group of the preference to say whether the error
26 dialog should be shown on startup. */
27 #define PREFERENCE_ID "dialogs.extension-error", "show-on-startup"
29 namespace Inkscape {
30 namespace Extension {
32 /** \brief An initializer which builds the dialog
34 Really a simple function. Basically the message dialog itself gets
35 built with the first initializer. The next step is to add in the
36 message, and attach the filename for the error file. After that
37 the checkbox is built, and has the call back attached to it. Also,
38 it is set based on the preferences setting for show on startup (really,
39 it should always be checked if you can see the dialog, but it is
40 probably good to check anyway).
41 */
42 ErrorFileNotice::ErrorFileNotice (void) :
43 Gtk::MessageDialog::MessageDialog(
44 "", /* message */
45 false, /* use markup */
46 Gtk::MESSAGE_WARNING, /* dialog type */
47 Gtk::BUTTONS_OK, /* buttons */
48 true /* modal */
49 )
51 {
52 /* This is some filler text, needs to change before relase */
53 Glib::ustring dialog_text(_("<span weight=\"bold\" size=\"larger\">One or more extensions failed to load</span>\n\nThe failed extensions have been skipped. Inkscape will continue to run normally but those extensions will be unavailable. For details to troubleshoot this problem, please refer to the error log located at: "));
54 gchar * ext_error_file = profile_path(EXTENSION_ERROR_LOG_FILENAME);
55 dialog_text += ext_error_file;
56 g_free(ext_error_file);
57 set_message(dialog_text, true);
59 Gtk::VBox * vbox = get_vbox();
61 /* This is some filler text, needs to change before relase */
62 checkbutton = Gtk::manage(new Gtk::CheckButton(_("Show dialog on startup")));
63 vbox->pack_start(*checkbutton, true, false, 5);
64 checkbutton->show();
65 checkbutton->set_active(prefs_get_int_attribute(PREFERENCE_ID, 1) == 0 ? false : true);
67 checkbutton->signal_toggled().connect(sigc::mem_fun(this, &ErrorFileNotice::checkbox_toggle));
69 set_resizable(true);
71 Inkscape::UI::Dialogs::ExtensionsPanel* extens = new Inkscape::UI::Dialogs::ExtensionsPanel();
72 extens->set_full(false);
73 vbox->pack_start( *extens, true, true );
74 extens->show();
76 return;
77 }
79 /** \brief Sets the preferences based on the checkbox value */
80 void
81 ErrorFileNotice::checkbox_toggle (void)
82 {
83 // std::cout << "Toggle value" << std::endl;
84 prefs_set_int_attribute(PREFERENCE_ID, checkbutton->get_active() ? 1 : 0);
85 }
87 /** \brief Shows the dialog
89 This function only shows the dialog if the preferences say that the
90 user wants to see the dialog, otherwise it just exits.
91 */
92 int
93 ErrorFileNotice::run (void)
94 {
95 if (prefs_get_int_attribute(PREFERENCE_ID, 1) == 0)
96 return 0;
97 return Gtk::Dialog::run();
98 }
100 }; }; /* namespace Inkscape, Extension */
102 /*
103 Local Variables:
104 mode:c++
105 c-file-style:"stroustrup"
106 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
107 indent-tabs-mode:nil
108 fill-column:99
109 End:
110 */
111 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :