[gtkparasite] window: Add a "Follow" button
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkparasite] window: Add a "Follow" button
- Date: Fri, 15 Mar 2013 22:03:26 +0000 (UTC)
commit d20c5d205e981fe06542ccf59273ef069a2c9992
Author: Benjamin Otte <otte redhat com>
Date: Fri Mar 15 20:24:08 2013 +0100
window: Add a "Follow" button
This will make the displayed widget follow the mouse pointer, so one can
leave the gtkparasite window in the background and see what's happening
below the mouse pointer.
I use it to debug menus.
src/parasite.h | 1 +
src/window.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 62 insertions(+), 1 deletions(-)
---
diff --git a/src/parasite.h b/src/parasite.h
index 906e7b4..90a1899 100644
--- a/src/parasite.h
+++ b/src/parasite.h
@@ -55,6 +55,7 @@ typedef struct
GtkWidget *widget_path_entry;
GtkWidget *style_classes_entry;
guint style_classes_entry_ratelimit_id;
+ guint follow_id;
} ParasiteWindow;
diff --git a/src/window.c b/src/window.c
index dd4f2e2..25701e3 100644
--- a/src/window.c
+++ b/src/window.c
@@ -48,7 +48,8 @@ on_widget_tree_selection_changed(ParasiteWidgetTree *widget_tree,
g_free (path);
/* Flash the widget. */
- gtkparasite_flash_widget(parasite, selected);
+ if (!parasite->follow_id)
+ gtkparasite_flash_widget(parasite, selected);
}
else
{
@@ -200,6 +201,58 @@ on_edit_mode_toggled(GtkWidget *toggle_button,
active);
}
+static gboolean
+on_follow_timeout (gpointer data)
+{
+ ParasiteWindow *parasite = data;
+ GdkDevice *device;
+ GdkWindow *window;
+
+ device = gdk_device_manager_get_client_pointer (gdk_display_get_device_manager (gtk_widget_get_display
(parasite->window)));
+ window = gdk_device_get_window_at_position (device, NULL, NULL);
+
+ if (window != NULL &&
+ gdk_window_get_toplevel (window) != gtk_widget_get_window (parasite->window))
+ {
+ GtkWidget *toplevel = NULL;
+ GtkWidget *widget = NULL;
+
+ gdk_window_get_user_data(gdk_window_get_toplevel(window), (gpointer*)&toplevel);
+ gdk_window_get_user_data(window, (gpointer*)&widget);
+
+ if (toplevel)
+ {
+ parasite_widget_tree_scan(PARASITE_WIDGET_TREE(parasite->widget_tree),
+ toplevel);
+ }
+
+ if (widget)
+ {
+ parasite_widget_tree_select_widget(PARASITE_WIDGET_TREE(parasite->widget_tree),
+ widget);
+ }
+ }
+
+ return TRUE;
+}
+
+static void
+on_follow_toggled(GtkWidget *toggle_button,
+ ParasiteWindow *parasite)
+{
+ if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toggle_button)))
+ {
+ parasite->follow_id = g_timeout_add_seconds (1,
+ on_follow_timeout,
+ parasite);
+ }
+ else
+ {
+ g_source_remove (parasite->follow_id);
+ parasite->follow_id = 0;
+ }
+}
+
static void
on_show_graphic_updates_toggled(GtkWidget *toggle_button,
ParasiteWindow *parasite)
@@ -236,6 +289,13 @@ create_widget_tree(ParasiteWindow *parasite)
gtk_widget_show(button);
gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+ button = gtk_toggle_button_new_with_mnemonic("_Follow");
+ gtk_widget_show(button);
+ gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
+
+ g_signal_connect(G_OBJECT(button), "toggled",
+ G_CALLBACK(on_follow_toggled), parasite);
+
button = gtk_toggle_button_new_with_mnemonic("_Edit Mode");
gtk_widget_show(button);
gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]