Code

moving trunk for module inkscape
[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 = 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     //Gtk::HPaned *splitter = new Gtk::HPaned();
69     Inkscape::UI::Dialogs::ExtensionsPanel* extens = new Inkscape::UI::Dialogs::ExtensionsPanel();
70     extens->set_full(false);
71     vbox->pack_start( *extens, true, true );
72     extens->show();
74     return;
75 }
77 /** \brief Sets the preferences based on the checkbox value */
78 void
79 ErrorFileNotice::checkbox_toggle (void)
80 {
81     // std::cout << "Toggle value" << std::endl;
82     prefs_set_int_attribute(PREFERENCE_ID, checkbutton->get_active() ? 1 : 0);
83 }
85 /** \brief Shows the dialog
87     This function only shows the dialog if the preferences say that the
88     user wants to see the dialog, otherwise it just exits.
89 */
90 int
91 ErrorFileNotice::run (void)
92 {
93     if (prefs_get_int_attribute(PREFERENCE_ID, 1) == 0)
94         return 0;
95     return Gtk::Dialog::run();
96 }
98 }; };  /* namespace Inkscape, Extension */
100 /*
101   Local Variables:
102   mode:c++
103   c-file-style:"stroustrup"
104   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
105   indent-tabs-mode:nil
106   fill-column:99
107   End:
108 */
109 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :