Code

Added preferences for controlling external image editing and reload.
authorjoncruz <joncruz@users.sourceforge.net>
Sun, 18 May 2008 08:20:21 +0000 (08:20 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Sun, 18 May 2008 08:20:21 +0000 (08:20 +0000)
Fixes bug #171824.

src/preferences-skeleton.h
src/ui/context-menu.cpp
src/ui/dialog/inkscape-preferences.cpp
src/ui/dialog/inkscape-preferences.h
src/widgets/desktop-widget.cpp

index 939be9a821c59c6a89d164947957cc0936db06b1..3ac8b0bb8d7033387a864f2fb9ec69cb8f28c893 100644 (file)
@@ -226,6 +226,8 @@ static char const preferences_skeleton[] =
 "    <group id=\"autoscrolldistance\" value=\"-10\"/>\n"
 "    <group id=\"simplifythreshold\" value=\"0.002\"/>\n"
 "    <group id=\"bitmapoversample\" value=\"1\"/>\n"
+"    <group id=\"bitmapeditor\" value=\"0\" choices=\"gimp,krita,gpaint,kolourpaint,mtpaint,cinepaint\"/>\n"
+"    <group id=\"bitmapautoreload\" value=\"1\"/>\n"
 "    <group id=\"dialogtype\" value=\"1\"/>\n"
 "    <group id=\"dock\" "
 "           cancenterdock=\"1\""
index 442eb5ef63593f873715fde04c48438ccd8eea56..e2ce5a2e1b1779eadc9bd9917e183fb215234e7a 100644 (file)
@@ -18,6 +18,7 @@
 #include "desktop.h"
 #include "document.h"
 #include "message-stack.h"
+#include "prefs-utils.h"
 #include "ui/dialog/dialog-manager.h"
 
 static void sp_object_type_menu(GType type, SPObject *object, SPDesktop *desktop, GtkMenu *menu);
@@ -296,7 +297,7 @@ sp_image_menu(SPObject *object, SPDesktop *desktop, GtkMenu *m)
     gtk_widget_show(w);
     gtk_menu_append(GTK_MENU(m), w);
 
-    w = gtk_menu_item_new_with_mnemonic(_("Edit Image..."));
+    w = gtk_menu_item_new_with_mnemonic(_("Edit Externally..."));
     gtk_object_set_data(GTK_OBJECT(w), "desktop", desktop);
     gtk_signal_connect(GTK_OBJECT(w), "activate", GTK_SIGNAL_FUNC(sp_image_image_edit), item);
     gtk_widget_show(w);
@@ -314,8 +315,25 @@ sp_image_image_properties(GtkMenuItem */*menuitem*/, SPAnchor *anchor)
     sp_object_attributes_dialog(SP_OBJECT(anchor), "Image");
 }
 
-#define EDIT_APP "gimp"
-//#define EDIT_APP "krita"
+static gchar* getImageEditorName() {
+    gchar* value = 0;
+    gchar const *choices = prefs_get_string_attribute("options.bitmapeditor", "choices");
+    if ( choices && choices[0] ) {
+        gchar** splits = g_strsplit(choices, ",", 0);
+        gint numIems = g_strv_length(splits);
+
+        int setting = prefs_get_int_attribute_limited("options.bitmapeditor", "value", 0, 0, numIems);
+        value = g_strdup(splits[setting]);
+
+        g_strfreev(splits);
+    }
+
+    if (!value) {
+        value = g_strdup("gimp");
+    }
+    return value;
+}
+
 static void sp_image_image_edit(GtkMenuItem *menuitem, SPAnchor *anchor)
 {
     SPObject* obj = SP_OBJECT(anchor);
@@ -323,7 +341,8 @@ static void sp_image_image_edit(GtkMenuItem *menuitem, SPAnchor *anchor)
     const gchar *href = ir->attribute("xlink:href");
 
     GError* errThing = 0;
-    gchar const* args[] = {EDIT_APP, href, 0};
+    gchar* editorBin = getImageEditorName();
+    gchar const* args[] = {editorBin, href, 0};
     g_spawn_async(0, // working dir
                   const_cast<gchar **>(args),
                   0, //envp
@@ -339,6 +358,7 @@ static void sp_image_image_edit(GtkMenuItem *menuitem, SPAnchor *anchor)
         g_error_free(errThing);
         errThing = 0;
     }
+    g_free(editorBin);
 }
 
 /* SPShape */
index effbeb3280fb6eae5aa53ed4ce55cd970ff1bfab..f8e7b8e08c713831b8bfc3876ac6edd1a9d4d2df 100644 (file)
@@ -901,12 +901,13 @@ void InkscapePreferences::initPageMisc()
 
     _page_misc.add_line( false, _("Simplification threshold:"), _misc_simpl, "",
                            _("How strong is the Simplify command by default. If you invoke this command several times in quick succession, it will act more and more aggressively; invoking it again after a pause restores the default threshold."), false);
-    int const num_items = 5;
-    Glib::ustring labels[num_items] = {_("None"), _("2x2"), _("4x4"), _("8x8"), _("16x16")};
-    int values[num_items] = {0, 1, 2, 3, 4};
-    _misc_overs_bitmap.set_size_request(_sb_width);
-    _misc_overs_bitmap.init("options.bitmapoversample", "value", labels, values, num_items, 1);
-    _page_misc.add_line( false, _("Oversample bitmaps:"), _misc_overs_bitmap, "", "", false);
+    {
+        Glib::ustring labels[] = {_("None"), _("2x2"), _("4x4"), _("8x8"), _("16x16")};
+        int values[] = {0, 1, 2, 3, 4};
+        _misc_overs_bitmap.set_size_request(_sb_width);
+        _misc_overs_bitmap.init("options.bitmapoversample", "value", labels, values, G_N_ELEMENTS(values), 1);
+        _page_misc.add_line( false, _("Oversample bitmaps:"), _misc_overs_bitmap, "", "", false);
+    }
 
 
     // consider moving this to an UI tab:
@@ -931,6 +932,30 @@ void InkscapePreferences::initPageMisc()
                            _("The maximum length of the Open Recent list in the File menu"), false);
     _misc_simpl.init("options.simplifythreshold", "value", 0.0001, 1.0, 0.0001, 0.0010, 0.0010, false, false);
 
+
+    // -----------
+
+    _misc_bitmap_autoreload.init(_("Automatically reload bitmaps"), "options.bitmapautoreload", "value", true);
+    _page_misc.add_line( false, "", _misc_bitmap_autoreload, "",
+                           _("Enbles automatic reload of linked images when changed on disk."));
+    gchar const *choices = prefs_get_string_attribute("options.bitmapeditor", "choices");
+    if ( choices && choices[0] ) {
+        gchar** splits = g_strsplit(choices, ",", 0);
+        gint numIems = g_strv_length(splits);
+
+        Glib::ustring labels[numIems];
+        int values[numIems];
+        for ( gint i = 0; i < numIems; i++) {
+            values[i] = i;
+            labels[i] = splits[i];
+        }
+        _misc_bitmap_editor.init("options.bitmapeditor", "value", labels, values, numIems, 0);
+        _page_misc.add_line( false, _("Bitmap editor:"), _misc_bitmap_editor, "", "", false);
+
+        g_strfreev(splits);
+    }
+
+
     this->AddPage(_page_misc, _("Misc"), PREFS_PAGE_MISC);
 }
 
index a1a577b95710165057b284ed72f9eddad53fa0af..5202e09d3ab5b03db7a96ab8813c4c154edc146d 100644 (file)
@@ -166,6 +166,8 @@ protected:
     PrefCombo       _misc_small_secondary;
     PrefCombo       _misc_small_tools;
     PrefCombo       _misc_overs_bitmap;
+    PrefCombo       _misc_bitmap_editor;
+    PrefCheckButton _misc_bitmap_autoreload;
 
     Gtk::ComboBoxText   _cms_display_profile;
     PrefCheckButton     _cms_from_display;
index 3fd0e529ef54c544b2d13ad0d8166991ec5edea7..c6e36aa8e076b81213efdb8ef5ed91c25342f0ad 100644 (file)
@@ -1439,7 +1439,8 @@ sp_desktop_widget_adjustment_value_changed (GtkAdjustment */*adj*/, SPDesktopWid
 /* we make the desktop window with focus active, signal is connected in interface.c */
 bool SPDesktopWidget::onFocusInEvent(GdkEventFocus*)
 {
-    {
+
+    if (prefs_get_int_attribute_limited("options.bitmapautoreload", "value", 1, 0, 1)) {
         GSList const *imageList = sp_document_get_resource_list(desktop->doc(), "image");
         for (GSList const *p = imageList; p; p = p->next) {
             SPImage* image = SP_IMAGE(p->data);