diff options
author | Stig Bjørlykke <stig@bjorlykke.org> | 2013-08-12 12:59:21 +0000 |
---|---|---|
committer | Stig Bjørlykke <stig@bjorlykke.org> | 2013-08-12 12:59:21 +0000 |
commit | 1cf28c375f4ddc19fb4c4880281de2ad64df4fca (patch) | |
tree | b4fd7c1b8e3bb0e90dd67c56af7d5feb4a5dcbbf | |
parent | f76303cd6c6c3f4649f08faf3692cad5ad022807 (diff) |
Double click Lua scripts in About Plugins list to open in an editor.
svn path=/trunk/; revision=51314
-rw-r--r-- | ui/gtk/plugins_dlg.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/ui/gtk/plugins_dlg.c b/ui/gtk/plugins_dlg.c index 6051c0d275..2a9f91d863 100644 --- a/ui/gtk/plugins_dlg.c +++ b/ui/gtk/plugins_dlg.c @@ -32,9 +32,41 @@ #include "ui/gtk/gui_utils.h" #include "ui/gtk/plugins_dlg.h" +#include "webbrowser.h" #if defined(HAVE_PLUGINS) || defined(HAVE_LUA) +static gboolean +about_plugins_callback(GtkWidget *widget, GdkEventButton *event, gint id _U_) +{ + GtkTreeSelection *tree_selection; + GtkTreeModel *model; + GtkTreeIter iter; + gchar *type; + gchar *file; + + tree_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(widget)); + + if (gtk_tree_selection_count_selected_rows (tree_selection) == 0) + return FALSE; + + if (event->type != GDK_2BUTTON_PRESS) + /* not a double click */ + return FALSE; + + if (gtk_tree_selection_get_selected (tree_selection, &model, &iter)) { + gtk_tree_model_get (model, &iter, 2, &type, -1); + if (strcmp (type, "lua script") == 0) { + gtk_tree_model_get (model, &iter, 3, &file, -1); + browser_open_data_file (file); + g_free (file); + } + g_free (type); + } + + return TRUE; +} + /* * Fill the list widget with a list of the plugin modules. * XXX - We might want to combine this with plugins_dump_all(). @@ -112,6 +144,10 @@ about_plugins_page_new(void) plugins_list = simple_list_new(4, titles); plugins_scan(plugins_list); + /* connect a callback so we can spot a double-click */ + g_signal_connect(plugins_list, "button_press_event", + G_CALLBACK(about_plugins_callback), NULL); + gtk_container_add(GTK_CONTAINER(scrolledwindow), plugins_list); return scrolledwindow; |