Add button to open addon in text editor
This commit is contained in:
parent
ce56f60ccd
commit
d7b68b9d94
1 changed files with 41 additions and 0 deletions
|
@ -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*
|
GtkWidget*
|
||||||
addons_get_toolbar (MidoriViewable* viewable)
|
addons_get_toolbar (MidoriViewable* viewable)
|
||||||
|
@ -311,6 +344,14 @@ addons_get_toolbar (MidoriViewable* viewable)
|
||||||
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
gtk_toolbar_insert (GTK_TOOLBAR (toolbar), toolitem, -1);
|
||||||
gtk_widget_show (GTK_WIDGET (toolitem));
|
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 */
|
/* Delete button */
|
||||||
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
|
toolitem = gtk_tool_button_new_from_stock (GTK_STOCK_DELETE);
|
||||||
gtk_tool_item_set_is_important (toolitem, TRUE);
|
gtk_tool_item_set_is_important (toolitem, TRUE);
|
||||||
|
|
Loading…
Reference in a new issue