]> spindle.queued.net Git - midori/commitdiff
Add button to open addon in text editor
authorPaweł Forysiuk <tuxator@o2.pl>
Sun, 29 Aug 2010 22:59:57 +0000 (00:59 +0200)
committerChristian Dywan <christian@twotoasts.de>
Sun, 29 Aug 2010 22:59:57 +0000 (00:59 +0200)
extensions/addons.c

index 7f5d68a1301119319d0c4286f97183afaefbd7c9..263c893d87554369534249718cc5e771aef8105b 100644 (file)
@@ -277,6 +277,39 @@ midori_addons_button_delete_clicked_cb (GtkWidget* toolitem,
         }
     }
 }
+static void
+midori_addons_open_in_editor_clicked_cb (GtkWidget* toolitem,
+                                         Addons*    addons)
+{
+    GtkTreeModel* model;
+    GtkTreeIter iter;
+
+    if (katze_tree_view_get_selected_iter (GTK_TREE_VIEW (addons->treeview),
+                                                          &model, &iter))
+    {
+        struct AddonElement* element;
+        MidoriWebSettings* settings;
+        MidoriBrowser* browser;
+        gchar* text_editor;
+        gchar* element_uri;
+
+        browser = midori_browser_get_for_widget (GTK_WIDGET (addons->treeview));
+        settings = katze_object_get_object (browser, "settings");
+
+        gtk_tree_model_get (model, &iter, 0, &element, -1);
+        element_uri = g_filename_to_uri (element->fullpath, NULL, NULL);
+
+        g_object_get (settings, "text-editor", &text_editor, NULL);
+        if (text_editor && *text_editor)
+            sokoke_spawn_program (text_editor, element_uri, TRUE);
+        else
+            sokoke_show_uri (NULL, element_uri,
+                             gtk_get_current_event_time (), NULL);
+
+        g_free (element_uri);
+        g_free (text_editor);
+    }
+}
 
 GtkWidget*
 addons_get_toolbar (MidoriViewable* viewable)
@@ -311,6 +344,14 @@ addons_get_toolbar (MidoriViewable* viewable)
         gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
         gtk_widget_show (GTK_WIDGET (toolitem));
 
+        /* Text editor button */
+        toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_EDIT);
+        gtk_tool_item_set_is_important (toolitem, TRUE);
+        g_signal_connect (toolitem, "clicked",
+            G_CALLBACK (midori_addons_open_in_editor_clicked_cb), viewable);
+        gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
+        gtk_widget_show (GTK_WIDGET (toolitem));
+
         /* Delete button */
         toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
         gtk_tool_item_set_is_important (toolitem, TRUE);