Revision: 1842 http://geany-plugins.svn.sourceforge.net/geany-plugins/?rev=1842&view=re... Author: colombanw Date: 2011-01-13 21:55:04 +0000 (Thu, 13 Jan 2011)
Log Message: ----------- WebHelper: Add a keybinding to show/hide web view's window (bug #3156262)
This keybinding currently does nothing it the web view is not in a separate window. Maybe it should do something similar when docked, not sure yet.
Modified Paths: -------------- trunk/geany-plugins/webhelper/src/gwh-keybindings.h trunk/geany-plugins/webhelper/src/gwh-plugin.c
Modified: trunk/geany-plugins/webhelper/src/gwh-keybindings.h =================================================================== --- trunk/geany-plugins/webhelper/src/gwh-keybindings.h 2011-01-13 21:54:37 UTC (rev 1841) +++ trunk/geany-plugins/webhelper/src/gwh-keybindings.h 2011-01-13 21:55:04 UTC (rev 1842) @@ -31,6 +31,7 @@
enum { GWH_KB_TOGGLE_INSPECTOR, + GWH_KB_SHOW_HIDE_SEPARATE_WINDOW, GWH_KB_COUNT };
Modified: trunk/geany-plugins/webhelper/src/gwh-plugin.c =================================================================== --- trunk/geany-plugins/webhelper/src/gwh-plugin.c 2011-01-13 21:54:37 UTC (rev 1841) +++ trunk/geany-plugins/webhelper/src/gwh-plugin.c 2011-01-13 21:55:04 UTC (rev 1842) @@ -67,10 +67,33 @@
/* only valid if type == CONTAINER_NOTEBOOK */ gint page_num; + /* only valid if type == CONTAINER_WINDOW */ + gboolean visible; } G_container; static GwhSettings *G_settings = NULL;
+static void +separate_window_set_visible (gboolean visible) +{ + if (visible != G_container.visible) { + gchar *geometry; + + G_container.visible = visible; + if (visible) { + gtk_widget_show (G_container.widget); + g_object_get (G_settings, "browser-separate-window-geometry", &geometry, NULL); + gwh_set_window_geometry (GTK_WINDOW (G_container.widget), geometry, NULL, NULL); + g_free (geometry); + } else { + geometry = gwh_get_window_geometry (GTK_WINDOW (G_container.widget), 0, 0); + g_object_set (G_settings, "browser-separate-window-geometry", geometry, NULL); + g_free (geometry); + gtk_widget_hide (G_container.widget); + } + } +} + static gboolean on_separate_window_delete_event (GtkWidget *widget, GdkEvent *event, @@ -91,12 +114,7 @@ static gboolean on_idle_widget_show (gpointer data) { - gchar *geometry; - - gtk_widget_show (data); - g_object_get (G_settings, "browser-separate-window-geometry", &geometry, NULL); - gwh_set_window_geometry (GTK_WINDOW (data), geometry, NULL, NULL); - g_free (geometry); + separate_window_set_visible (TRUE); /* present back the Geany's window because it is very unlikely the user * expects the focus on our newly created window at this point, since we * either just loaded the plugin or activated a element from Geany's UI */ @@ -160,11 +178,7 @@ detach_browser (void) { if (G_container.type == CONTAINER_WINDOW) { - gchar *geometry; - - geometry = gwh_get_window_geometry (GTK_WINDOW (G_container.widget), 0, 0); - g_object_set (G_settings, "browser-separate-window-geometry", geometry, NULL); - g_free (geometry); + separate_window_set_visible (FALSE); /* saves the geometry */ gtk_widget_destroy (G_container.widget); } else { GtkNotebook *notebook = GTK_NOTEBOOK (G_container.widget); @@ -252,7 +266,15 @@ gwh_browser_toggle_inspector (GWH_BROWSER (G_browser)); }
+static void +on_kb_show_hide_separate_window (guint key_id) +{ + if (G_container.type == CONTAINER_WINDOW) { + separate_window_set_visible (! G_container.visible); + } +}
+ static gchar * get_config_filename (void) { @@ -324,6 +346,11 @@ keybindings_set_item (gwh_keybindings_get_group (), GWH_KB_TOGGLE_INSPECTOR, on_kb_toggle_inspector, GDK_F12, 0, "toggle_inspector", _("Toggle Web Inspector"), NULL); + keybindings_set_item (gwh_keybindings_get_group (), + GWH_KB_SHOW_HIDE_SEPARATE_WINDOW, + on_kb_show_hide_separate_window, 0, 0, + "show_hide_separate_window", + _("Show/Hide Web View's Window"), NULL); }
void
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.