diff --git a/extensions/addons.c b/extensions/addons.c index 7f5d68a1..263c893d 100644 --- a/extensions/addons.c +++ b/extensions/addons.c @@ -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);