Code

Super duper mega (fun!) commit: replaced encoding=utf-8 with fileencoding=utf-8 in...
[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 #ifdef HAVE_CONFIG_H
12 #include "config.h"
13 #endif
15 #include <glibmm/i18n.h>
18 #include "inkscape.h"
19 #include "preferences.h"
20 #include "ui/dialog/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     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
63     checkbutton = Gtk::manage(new Gtk::CheckButton(_("Show dialog on startup")));
64     vbox->pack_start(*checkbutton, true, false, 5);
65     checkbutton->show();
66     checkbutton->set_active(prefs->getBool(PREFERENCE_ID, true));
68     checkbutton->signal_toggled().connect(sigc::mem_fun(this, &ErrorFileNotice::checkbox_toggle));
70     set_resizable(true);
72     Inkscape::UI::Dialogs::ExtensionsPanel* extens = new Inkscape::UI::Dialogs::ExtensionsPanel();
73     extens->set_full(false);
74     vbox->pack_start( *extens, true, true );
75     extens->show();
77     return;
78 }
80 /** \brief Sets the preferences based on the checkbox value */
81 void
82 ErrorFileNotice::checkbox_toggle (void)
83 {
84     // std::cout << "Toggle value" << std::endl;
85     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
86     prefs->setBool(PREFERENCE_ID, checkbutton->get_active());
87 }
89 /** \brief Shows the dialog
91     This function only shows the dialog if the preferences say that the
92     user wants to see the dialog, otherwise it just exits.
93 */
94 int
95 ErrorFileNotice::run (void)
96 {
97     Inkscape::Preferences *prefs = Inkscape::Preferences::get();
98     if (!prefs->getBool(PREFERENCE_ID, true))
99         return 0;
100     return Gtk::Dialog::run();
103 }; };  /* namespace Inkscape, Extension */
105 /*
106   Local Variables:
107   mode:c++
108   c-file-style:"stroustrup"
109   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
110   indent-tabs-mode:nil
111   fill-column:99
112   End:
113 */
114 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :