Code

r11463@tres: ted | 2006-04-19 08:28:18 -0700
[inkscape.git] / src / extension / error-file.cpp
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 // #include <glibmm/ustring.h>
12 #include <glibmm/i18n.h>
15 #include "inkscape.h"
16 #include "prefs-utils.h"
17 #include "dialogs/extensions.h"
18 #include "extension/extension.h"
20 #include "error-file.h"
22 /** The name and group of the preference to say whether the error
23     dialog should be shown on startup. */
24 #define PREFERENCE_ID  "dialogs.extension-error", "show-on-startup"
26 namespace Inkscape {
27 namespace Extension {
29 /** \brief  An initializer which builds the dialog
31     Really a simple function.  Basically the message dialog itself gets
32     built with the first initializer.  The next step is to add in the
33     message, and attach the filename for the error file.  After that
34     the checkbox is built, and has the call back attached to it.  Also,
35     it is set based on the preferences setting for show on startup (really,
36     it should always be checked if you can see the dialog, but it is
37     probably good to check anyway).
38 */
39 ErrorFileNotice::ErrorFileNotice (void) :
40     Gtk::MessageDialog::MessageDialog(
41             "",                    /* message */
42             false,                 /* use markup */
43             Gtk::MESSAGE_WARNING,  /* dialog type */
44             Gtk::BUTTONS_OK,       /* buttons */
45             true                   /* modal */
46         )
48 {
49     /* This is some filler text, needs to change before relase */
50     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: "));
51     gchar * ext_error_file = profile_path(EXTENSION_ERROR_LOG_FILENAME);
52     dialog_text += ext_error_file;
53     g_free(ext_error_file);
54     set_message(dialog_text, true);
56     Gtk::VBox * vbox = get_vbox();
58     /* This is some filler text, needs to change before relase */
59     checkbutton = Gtk::manage(new Gtk::CheckButton(_("Show dialog on startup")));
60     vbox->pack_start(*checkbutton, true, false, 5);
61     checkbutton->show();
62     checkbutton->set_active(prefs_get_int_attribute(PREFERENCE_ID, 1) == 0 ? false : true);
64     checkbutton->signal_toggled().connect(sigc::mem_fun(this, &ErrorFileNotice::checkbox_toggle));
66     set_resizable(true);
68     Inkscape::UI::Dialogs::ExtensionsPanel* extens = new Inkscape::UI::Dialogs::ExtensionsPanel();
69     extens->set_full(false);
70     vbox->pack_start( *extens, true, true );
71     extens->show();
73     return;
74 }
76 /** \brief Sets the preferences based on the checkbox value */
77 void
78 ErrorFileNotice::checkbox_toggle (void)
79 {
80     // std::cout << "Toggle value" << std::endl;
81     prefs_set_int_attribute(PREFERENCE_ID, checkbutton->get_active() ? 1 : 0);
82 }
84 /** \brief Shows the dialog
86     This function only shows the dialog if the preferences say that the
87     user wants to see the dialog, otherwise it just exits.
88 */
89 int
90 ErrorFileNotice::run (void)
91 {
92     if (prefs_get_int_attribute(PREFERENCE_ID, 1) == 0)
93         return 0;
94     return Gtk::Dialog::run();
95 }
97 }; };  /* namespace Inkscape, Extension */
99 /*
100   Local Variables:
101   mode:c++
102   c-file-style:"stroustrup"
103   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
104   indent-tabs-mode:nil
105   fill-column:99
106   End:
107 */
108 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :