Re: GtkTreeView: how to get the cell with current focus?
I do this all the time in Python with: def key_tree_tab(self, treeview, event): keyname = Gdk.keyval_name(event.keyval) path, col = treeview.get_cursor() # only visible columns!! columns = [c for c in treeview.get_columns() if c.get_visible()] colnum = columns.index(col) if keyname=="Tab" : if colnum + 1 < len(columns): next_column = columns[colnum + 1] else: tmodel = treeview.get_model() titer = tmodel.iter_next(tmodel.get_iter(path)) if titer is None: titer = tmodel.get_iter_first() path = tmodel.get_path(titer) next_column = columns[0] GLib.timeout_add(10, treeview.set_cursor, path, next_column, True) Hope it helps! On 07/12/2018 01:36 PM, Lars Paulsen wrote: Hi All, I did some further tests and the addresses returned in focus_column are the same as the columns I created with "gtk_tree_view_column_new();". Well, it's quite obvious but somehow I expected that there is some API function which returns an index for a column. Anyway, I will continue by comparing the addresses to find out which column I am in. I need this to find out which column "is next". I want to set the focus to the next cell/column if the user presses tab. If anyone knows a better solution to determine the column/next column please let me know. Cheers, Lars Am 12.07.2018 um 18:11 schrieb Lars Paulsen: Hello All, I got a little problem with a GtkTreeView and with getting the cell which actually has got the focus: From the API documentation it seems like gtk_tree_view_get_cursor(GTK_TREE_VIEW(tree), , _column); is doing the job. I can handle the path, it gives me the row which has the focus. But how do I get the index of the cell from focus_column (alias GtkTreeViewColumn)? A web search revealed some old forum entries which seem to state that it is not supported. Do I have to check the column name or compare the addresses of my columns? Thanks for any help in advance. Best Regards, Lars ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: GtkTreeView: how to get the cell with current focus?
Hi All, I did some further tests and the addresses returned in focus_column are the same as the columns I created with "gtk_tree_view_column_new();". Well, it's quite obvious but somehow I expected that there is some API function which returns an index for a column. Anyway, I will continue by comparing the addresses to find out which column I am in. I need this to find out which column "is next". I want to set the focus to the next cell/column if the user presses tab. If anyone knows a better solution to determine the column/next column please let me know. Cheers, Lars Am 12.07.2018 um 18:11 schrieb Lars Paulsen: Hello All, I got a little problem with a GtkTreeView and with getting the cell which actually has got the focus: From the API documentation it seems like gtk_tree_view_get_cursor(GTK_TREE_VIEW(tree), , _column); is doing the job. I can handle the path, it gives me the row which has the focus. But how do I get the index of the cell from focus_column (alias GtkTreeViewColumn)? A web search revealed some old forum entries which seem to state that it is not supported. Do I have to check the column name or compare the addresses of my columns? Thanks for any help in advance. Best Regards, Lars ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GtkTreeView: how to get the cell with current focus?
Hello All, I got a little problem with a GtkTreeView and with getting the cell which actually has got the focus: From the API documentation it seems like gtk_tree_view_get_cursor(GTK_TREE_VIEW(tree), , _column); is doing the job. I can handle the path, it gives me the row which has the focus. But how do I get the index of the cell from focus_column (alias GtkTreeViewColumn)? A web search revealed some old forum entries which seem to state that it is not supported. Do I have to check the column name or compare the addresses of my columns? Thanks for any help in advance. Best Regards, Lars ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Get GtkWindow focus from XI Event
Thanks for your reply. Let me send the question to gtk-devel-l...@gnome.org again. On 05/11/17 21:19, Emmanuele Bassi-san wrote: You likely want to ask on gtk-devel-l...@gnome.org and/or on the #gtk+ IRC channel on irc.gnome.org. Ciao, Emmanuele. On 11 May 2017 at 13:15, Takao Fujiwara <tfuji...@redhat.com> wrote: On 05/11/17 20:55, Takao Fujiwara-san wrote: I have a focus problem with the attached program. 1. When press Ctrl-Alt-v, my window is launched with the keyboard focus. 2. Click [x] button and close the window. 3. When press Ctrl-Alt-v again, my window is launched but the focus status is different by desktop. XFCE4 desktop can get the keyboard focus correctly. But MATE or Plasma desktop cannot get the keyboard focus in the second Ctrl-Alt-v. I also observe this problem in GNOME desktop. How should I investigate it? The current workaround is to close the second window and launch the third window by the program but not XI shortcut key. Thanks, Fujiwara - // gcc -o a a.c `pkg-config --cflags --libs gtk+-3.0 x11 xi` #include #include #include #include guint shortcut_keysym = 0; guint shortcut_modifiers = 0; static void loop_quit (GtkWindow *window, gpointer data) { GMainLoop *loop = data; g_return_if_fail (loop != NULL); gtk_widget_hide (GTK_WIDGET (window)); while (gtk_events_pending ()) { gtk_main_iteration (); } g_main_loop_quit (loop); } GtkWidget * my_window_new (GMainLoop *loop) { GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect(window, "destroy", G_CALLBACK(loop_quit), loop); GtkWidget *entry = gtk_entry_new (); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), entry, 0, 0, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); return window; } static XIGrabModifiers * get_grab_modifiers (guint modifiers, int *result_length) { XIGrabModifiers *ximodifiers = g_new0 (XIGrabModifiers, 1); XIGrabModifiers ximodifier = { 0, }; memset (, 0, sizeof (XIGrabModifiers)); ximodifier.modifiers = modifiers; ximodifier.status = 0; ximodifiers[0] = ximodifier; if (result_length) *result_length = 1; return ximodifiers; } static void grab_keycode (guint keysym, guint modifiers) { GdkDisplay *display = gdk_display_get_default (); Display *xdisplay = gdk_x11_display_get_xdisplay (display); guint keycode = 0; XIEventMask evmask = { 0, }; int length = 0; XIGrabModifiers *ximodifiers; keycode = XKeysymToKeycode (xdisplay, keysym); memset (, 0, sizeof (XIEventMask)); evmask.deviceid = XIAllMasterDevices; evmask.mask = g_new0 (guchar, (XI_LASTEVENT + 7) / 8); evmask.mask_len = (XI_LASTEVENT + 7) / 8; XISetMask (evmask.mask, XI_KeyPress); XISetMask (evmask.mask, XI_KeyRelease); ximodifiers = get_grab_modifiers (modifiers, ); XIGrabKeycode (xdisplay, XIAllMasterDevices, keycode, DefaultRootWindow (xdisplay), GrabModeAsync, GrabModeAsync, TRUE, , length, ximodifiers); g_free (ximodifiers); } static void ungrab_keycode (guint keysym, guint modifiers) { GdkDisplay *display = gdk_display_get_default (); Display *xdisplay = gdk_x11_display_get_xdisplay (display); guint keycode = 0; int length = 0; XIGrabModifiers *ximodifiers; keycode = XKeysymToKeycode (xdisplay, keysym); ximodifiers = get_grab_modifiers (modifiers, ); XIUngrabKeycode (xdisplay, XIAllMasterDevices, keycode, DefaultRootWindow (xdisplay), length, ximodifiers); g_free (ximodifiers); } static void run_window () { GtkWidget *window; GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); window = my_window_new (loop); gtk_widget_show_all(window); g_main_loop_run (loop); } static void event_handler (GdkEvent *event, gpointer data) { static int times = 0; if (((GdkEventAny*)event)->window == gdk_get_default_root_window() && event->type == GDK_KEY_PRESS) { guint keyval = ((GdkEventKey*)event)->keyval; guint modifiers = ((GdkEventKey*)event)->state; if (keyval >= GDK_KEY_A && keyval <= GDK_KEY_Z && (modifiers & GDK_SHIFT_MASK) != 0) { keyval = keyval - GDK_KEY_A + GDK_KEY_a; } if (keyval == shortcut_keysym && modifiers == shortcut_modifiers) { run_window (); times++;
Re: Get GtkWindow focus from XI Event
You likely want to ask on gtk-devel-l...@gnome.org and/or on the #gtk+ IRC channel on irc.gnome.org. Ciao, Emmanuele. On 11 May 2017 at 13:15, Takao Fujiwara <tfuji...@redhat.com> wrote: > On 05/11/17 20:55, Takao Fujiwara-san wrote: >> >> I have a focus problem with the attached program. >> 1. When press Ctrl-Alt-v, my window is launched with the keyboard focus. >> 2. Click [x] button and close the window. >> 3. When press Ctrl-Alt-v again, my window is launched but the focus status >> is different by desktop. >> >> XFCE4 desktop can get the keyboard focus correctly. >> But MATE or Plasma desktop cannot get the keyboard focus in the second >> Ctrl-Alt-v. > > > I also observe this problem in GNOME desktop. > > >> >> How should I investigate it? >> The current workaround is to close the second window and launch the third >> window by the program but not XI shortcut key. >> >> Thanks, >> Fujiwara >> >> - >> // gcc -o a a.c `pkg-config --cflags --libs gtk+-3.0 x11 xi` >> #include >> #include >> #include >> #include >> >> guint shortcut_keysym = 0; >> guint shortcut_modifiers = 0; >> >> static void >> loop_quit (GtkWindow *window, >>gpointer data) >> { >> GMainLoop *loop = data; >> g_return_if_fail (loop != NULL); >> gtk_widget_hide (GTK_WIDGET (window)); >> while (gtk_events_pending ()) { >> gtk_main_iteration (); >> } >> g_main_loop_quit (loop); >> } >> >> GtkWidget * >> my_window_new (GMainLoop *loop) { >> GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL); >> gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); >> gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); >> g_signal_connect(window, "destroy", G_CALLBACK(loop_quit), loop); >> >> GtkWidget *entry = gtk_entry_new (); >> >> GtkWidget *grid=gtk_grid_new(); >> gtk_grid_attach(GTK_GRID(grid), entry, 0, 0, 1, 1); >> >> gtk_container_add(GTK_CONTAINER(window), grid); >> >> return window; >> } >> >> static XIGrabModifiers * >> get_grab_modifiers (guint modifiers, >> int *result_length) >> { >> XIGrabModifiers *ximodifiers = g_new0 (XIGrabModifiers, 1); >> XIGrabModifiers ximodifier = { 0, }; >> memset (, 0, sizeof (XIGrabModifiers)); >> ximodifier.modifiers = modifiers; >> ximodifier.status = 0; >> ximodifiers[0] = ximodifier; >> if (result_length) >> *result_length = 1; >> return ximodifiers; >> } >> >> static void >> grab_keycode (guint keysym, >> guint modifiers) >> { >> GdkDisplay *display = gdk_display_get_default (); >> Display *xdisplay = gdk_x11_display_get_xdisplay (display); >> guint keycode = 0; >> XIEventMask evmask = { 0, }; >> int length = 0; >> XIGrabModifiers *ximodifiers; >> >> keycode = XKeysymToKeycode (xdisplay, keysym); >> memset (, 0, sizeof (XIEventMask)); >> evmask.deviceid = XIAllMasterDevices; >> evmask.mask = g_new0 (guchar, (XI_LASTEVENT + 7) / 8); >> evmask.mask_len = (XI_LASTEVENT + 7) / 8; >> XISetMask (evmask.mask, XI_KeyPress); >> XISetMask (evmask.mask, XI_KeyRelease); >> ximodifiers = get_grab_modifiers (modifiers, ); >> XIGrabKeycode (xdisplay, >>XIAllMasterDevices, >>keycode, >>DefaultRootWindow (xdisplay), >>GrabModeAsync, >>GrabModeAsync, >>TRUE, >>, >>length, >>ximodifiers); >> g_free (ximodifiers); >> } >> >> static void >> ungrab_keycode (guint keysym, >> guint modifiers) >> { >> GdkDisplay *display = gdk_display_get_default (); >> Display *xdisplay = gdk_x11_display_get_xdisplay (display); >> guint keycode = 0; >> int length = 0; >> XIGrabModifiers *ximodifiers; >> >> keycode = XKeysymToKeycode (xdisplay, keysym); >> ximodifiers = get_grab_modifiers (modifiers, ); >> XIUngrabKeycode (xdisplay, >> XIAllMasterDevices, >> keycode, >> DefaultRootWindow (xdisplay), >> length, >>
Re: Get GtkWindow focus from XI Event
On 05/11/17 20:55, Takao Fujiwara-san wrote: I have a focus problem with the attached program. 1. When press Ctrl-Alt-v, my window is launched with the keyboard focus. 2. Click [x] button and close the window. 3. When press Ctrl-Alt-v again, my window is launched but the focus status is different by desktop. XFCE4 desktop can get the keyboard focus correctly. But MATE or Plasma desktop cannot get the keyboard focus in the second Ctrl-Alt-v. I also observe this problem in GNOME desktop. How should I investigate it? The current workaround is to close the second window and launch the third window by the program but not XI shortcut key. Thanks, Fujiwara - // gcc -o a a.c `pkg-config --cflags --libs gtk+-3.0 x11 xi` #include #include #include #include guint shortcut_keysym = 0; guint shortcut_modifiers = 0; static void loop_quit (GtkWindow *window, gpointer data) { GMainLoop *loop = data; g_return_if_fail (loop != NULL); gtk_widget_hide (GTK_WIDGET (window)); while (gtk_events_pending ()) { gtk_main_iteration (); } g_main_loop_quit (loop); } GtkWidget * my_window_new (GMainLoop *loop) { GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect(window, "destroy", G_CALLBACK(loop_quit), loop); GtkWidget *entry = gtk_entry_new (); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), entry, 0, 0, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); return window; } static XIGrabModifiers * get_grab_modifiers (guint modifiers, int *result_length) { XIGrabModifiers *ximodifiers = g_new0 (XIGrabModifiers, 1); XIGrabModifiers ximodifier = { 0, }; memset (, 0, sizeof (XIGrabModifiers)); ximodifier.modifiers = modifiers; ximodifier.status = 0; ximodifiers[0] = ximodifier; if (result_length) *result_length = 1; return ximodifiers; } static void grab_keycode (guint keysym, guint modifiers) { GdkDisplay *display = gdk_display_get_default (); Display *xdisplay = gdk_x11_display_get_xdisplay (display); guint keycode = 0; XIEventMask evmask = { 0, }; int length = 0; XIGrabModifiers *ximodifiers; keycode = XKeysymToKeycode (xdisplay, keysym); memset (, 0, sizeof (XIEventMask)); evmask.deviceid = XIAllMasterDevices; evmask.mask = g_new0 (guchar, (XI_LASTEVENT + 7) / 8); evmask.mask_len = (XI_LASTEVENT + 7) / 8; XISetMask (evmask.mask, XI_KeyPress); XISetMask (evmask.mask, XI_KeyRelease); ximodifiers = get_grab_modifiers (modifiers, ); XIGrabKeycode (xdisplay, XIAllMasterDevices, keycode, DefaultRootWindow (xdisplay), GrabModeAsync, GrabModeAsync, TRUE, , length, ximodifiers); g_free (ximodifiers); } static void ungrab_keycode (guint keysym, guint modifiers) { GdkDisplay *display = gdk_display_get_default (); Display *xdisplay = gdk_x11_display_get_xdisplay (display); guint keycode = 0; int length = 0; XIGrabModifiers *ximodifiers; keycode = XKeysymToKeycode (xdisplay, keysym); ximodifiers = get_grab_modifiers (modifiers, ); XIUngrabKeycode (xdisplay, XIAllMasterDevices, keycode, DefaultRootWindow (xdisplay), length, ximodifiers); g_free (ximodifiers); } static void run_window () { GtkWidget *window; GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); window = my_window_new (loop); gtk_widget_show_all(window); g_main_loop_run (loop); } static void event_handler (GdkEvent *event, gpointer data) { static int times = 0; if (((GdkEventAny*)event)->window == gdk_get_default_root_window() && event->type == GDK_KEY_PRESS) { guint keyval = ((GdkEventKey*)event)->keyval; guint modifiers = ((GdkEventKey*)event)->state; if (keyval >= GDK_KEY_A && keyval <= GDK_KEY_Z && (modifiers & GDK_SHIFT_MASK) != 0) { keyval = keyval - GDK_KEY_A + GDK_KEY_a; } if (keyval == shortcut_keysym && modifiers == shortcut_modifiers) { run_window (); times++; if (times > 1) { ungrab_keycode (keyval, modifiers); gtk_main_quit(); } } } gtk_main_do_event (event); } int main (int argc, char *argv[]) { GtkWidget *window; GMainLoop *loop; gtk_init (, ); gdk_event_handler_set (event_handler, NULL, NULL);
Get GtkWindow focus from XI Event
I have a focus problem with the attached program. 1. When press Ctrl-Alt-v, my window is launched with the keyboard focus. 2. Click [x] button and close the window. 3. When press Ctrl-Alt-v again, my window is launched but the focus status is different by desktop. XFCE4 desktop can get the keyboard focus correctly. But MATE or Plasma desktop cannot get the keyboard focus in the second Ctrl-Alt-v. How should I investigate it? The current workaround is to close the second window and launch the third window by the program but not XI shortcut key. Thanks, Fujiwara - // gcc -o a a.c `pkg-config --cflags --libs gtk+-3.0 x11 xi` #include #include #include #include guint shortcut_keysym = 0; guint shortcut_modifiers = 0; static void loop_quit (GtkWindow *window, gpointer data) { GMainLoop *loop = data; g_return_if_fail (loop != NULL); gtk_widget_hide (GTK_WIDGET (window)); while (gtk_events_pending ()) { gtk_main_iteration (); } g_main_loop_quit (loop); } GtkWidget * my_window_new (GMainLoop *loop) { GtkWidget *window=gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_default_size(GTK_WINDOW(window), 200, 200); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); g_signal_connect(window, "destroy", G_CALLBACK(loop_quit), loop); GtkWidget *entry = gtk_entry_new (); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), entry, 0, 0, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); return window; } static XIGrabModifiers * get_grab_modifiers (guint modifiers, int *result_length) { XIGrabModifiers *ximodifiers = g_new0 (XIGrabModifiers, 1); XIGrabModifiers ximodifier = { 0, }; memset (, 0, sizeof (XIGrabModifiers)); ximodifier.modifiers = modifiers; ximodifier.status = 0; ximodifiers[0] = ximodifier; if (result_length) *result_length = 1; return ximodifiers; } static void grab_keycode (guint keysym, guint modifiers) { GdkDisplay *display = gdk_display_get_default (); Display *xdisplay = gdk_x11_display_get_xdisplay (display); guint keycode = 0; XIEventMask evmask = { 0, }; int length = 0; XIGrabModifiers *ximodifiers; keycode = XKeysymToKeycode (xdisplay, keysym); memset (, 0, sizeof (XIEventMask)); evmask.deviceid = XIAllMasterDevices; evmask.mask = g_new0 (guchar, (XI_LASTEVENT + 7) / 8); evmask.mask_len = (XI_LASTEVENT + 7) / 8; XISetMask (evmask.mask, XI_KeyPress); XISetMask (evmask.mask, XI_KeyRelease); ximodifiers = get_grab_modifiers (modifiers, ); XIGrabKeycode (xdisplay, XIAllMasterDevices, keycode, DefaultRootWindow (xdisplay), GrabModeAsync, GrabModeAsync, TRUE, , length, ximodifiers); g_free (ximodifiers); } static void ungrab_keycode (guint keysym, guint modifiers) { GdkDisplay *display = gdk_display_get_default (); Display *xdisplay = gdk_x11_display_get_xdisplay (display); guint keycode = 0; int length = 0; XIGrabModifiers *ximodifiers; keycode = XKeysymToKeycode (xdisplay, keysym); ximodifiers = get_grab_modifiers (modifiers, ); XIUngrabKeycode (xdisplay, XIAllMasterDevices, keycode, DefaultRootWindow (xdisplay), length, ximodifiers); g_free (ximodifiers); } static void run_window () { GtkWidget *window; GMainLoop *loop; loop = g_main_loop_new (NULL, FALSE); window = my_window_new (loop); gtk_widget_show_all(window); g_main_loop_run (loop); } static void event_handler (GdkEvent *event, gpointer data) { static int times = 0; if (((GdkEventAny*)event)->window == gdk_get_default_root_window() && event->type == GDK_KEY_PRESS) { guint keyval = ((GdkEventKey*)event)->keyval; guint modifiers = ((GdkEventKey*)event)->state; if (keyval >= GDK_KEY_A && keyval <= GDK_KEY_Z && (modifiers & GDK_SHIFT_MASK) != 0) { keyval = keyval - GDK_KEY_A + GDK_KEY_a; } if (keyval == shortcut_keysym && modifiers == shortcut_modifiers) { run_window (); times++; if (times > 1) { ungrab_keycode (keyval, modifiers); gtk_main_quit(); } } } gtk_main_do_event (event); } int main (int argc, char *argv[]) { GtkWidget *window; GMainLoop *loop; gtk_init (, ); gdk_event_handler_set (event_handler, NULL, NULL); gtk_accelerator_parse ("v", _keysym, _modi
Re: Combobox focus event
Works fine :-))) Thanks Eric. Regards Thomas Den 04/08/2017 kl. 07:30 PM skrev cecas...@aol.com: > > Another thing to give a try is just to set a boolean in the > "set-focus-child" callback. Not sure if this will always work. I think > that it should. > > I don't know the best workaround for the "focus-in-event" in a combo > box. It isn't obvious how to connect that signal for the combobox. > > Eric > > > gboolean combo_focus=FALSE; > g_signal_connect(combo, "set-focus-child", > G_CALLBACK(focus_combo_container), _focus); > ... > static void focus_combo_container(GtkContainer *container, GtkWidget > *widget, gboolean *combo_focus) > { > if(*combo_focus) > { > g_print("Combo Container Focus Out\n"); > *combo_focus=FALSE; > } > else > { > g_print("Combo Container Focus In\n"); > *combo_focus=TRUE; > } > } > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Another thing to give a try is just to set a boolean in the "set-focus-child" callback. Not sure if this will always work. I think that it should. I don't know the best workaround for the "focus-in-event" in a combo box. It isn't obvious how to connect that signal for the combobox. Eric gboolean combo_focus=FALSE; g_signal_connect(combo, "set-focus-child", G_CALLBACK(focus_combo_container), _focus); ... static void focus_combo_container(GtkContainer *container, GtkWidget *widget, gboolean *combo_focus) { if(*combo_focus) { g_print("Combo Container Focus Out\n"); *combo_focus=FALSE; } else { g_print("Combo Container Focus In\n"); *combo_focus=TRUE; } } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Thanks :-)) I'l try that. Thomas On 07-04-2017 23:10, cecas...@aol.com wrote: Hi Nicola, The "set-focus-child" on the container fires for the "focus-in-event" and "focus-out-event". I forgot about those container functions though. You can get the toggle button pointer from the container and set up your "focus-in-event". That way there is no ugly business of using a private structure. Eric /* gcc -Wall combo_focus2.c -o combo_focus2 `pkg-config gtk+-3.0 --cflags --libs` Tested on Ubuntu16.04, GTK3.18. https://bugzilla.gnome.org/show_bug.cgi?id=599076 Bugzilla Bug 599076 - GtkComboBox missing focus events */ #include static void find_toggle_button(GtkWidget *widget, GtkWidget **toggle_button); static gboolean focus_button1(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean focus_button2(GtkWidget *widget, GdkEvent *event, gpointer user_data); static void focus_combo_container(GtkContainer *container, GtkWidget *widget, gpointer user_data); int main(int argc, char *argv[]) { gtk_init(, ); GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Combo Focus"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); GtkWidget *button1=gtk_button_new_with_label("Button1"); gtk_widget_set_hexpand(button1, TRUE); gtk_widget_set_vexpand(button1, TRUE); g_signal_connect(button1, "focus-in-event", G_CALLBACK(focus_button1), NULL); GtkWidget *combo=gtk_combo_box_text_new(); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 0, "1", "Turtle"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 1, "2", "Koala"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 2, "3", "Cheetah"); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_widget_set_hexpand(combo, TRUE); GtkWidget *toggle_button=NULL; gtk_container_forall(GTK_CONTAINER(combo), (GtkCallback)find_toggle_button, _button); g_signal_connect(toggle_button, "focus-in-event", G_CALLBACK(focus_combo), NULL); g_signal_connect(combo, "set-focus-child", G_CALLBACK(focus_combo_container), NULL); GtkWidget *button2=gtk_button_new_with_label("Button2"); gtk_widget_set_hexpand(button2, TRUE); gtk_widget_set_vexpand(button2, TRUE); g_signal_connect(button2, "focus-in-event", G_CALLBACK(focus_button2), NULL); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), button1, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid), combo, 0, 1, 1, 1); gtk_grid_attach(GTK_GRID(grid), button2, 0, 2, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); gtk_widget_show_all(window); gtk_main(); return 0; } static void find_toggle_button(GtkWidget *widget, GtkWidget **toggle_button) { if(g_strcmp0(gtk_widget_get_name(widget), "GtkToggleButton")==0) { g_print("Found Toggle Button in Combo\n"); *toggle_button=widget; } } static gboolean focus_button1(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Button1 Focus\n"); return FALSE; } static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Combo Focus In\n"); return FALSE; } static gboolean focus_button2(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Button2 Focus\n"); return FALSE; } static void focus_combo_container(GtkContainer *container, GtkWidget *widget, gpointer user_data) { g_print("Combo Container Focus\n"); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Hi Nicola, The "set-focus-child" on the container fires for the "focus-in-event" and "focus-out-event". I forgot about those container functions though. You can get the toggle button pointer from the container and set up your "focus-in-event". That way there is no ugly business of using a private structure. Eric /* gcc -Wall combo_focus2.c -o combo_focus2 `pkg-config gtk+-3.0 --cflags --libs` Tested on Ubuntu16.04, GTK3.18. https://bugzilla.gnome.org/show_bug.cgi?id=599076 Bugzilla Bug 599076 - GtkComboBox missing focus events */ #include static void find_toggle_button(GtkWidget *widget, GtkWidget **toggle_button); static gboolean focus_button1(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean focus_button2(GtkWidget *widget, GdkEvent *event, gpointer user_data); static void focus_combo_container(GtkContainer *container, GtkWidget *widget, gpointer user_data); int main(int argc, char *argv[]) { gtk_init(, ); GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Combo Focus"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); GtkWidget *button1=gtk_button_new_with_label("Button1"); gtk_widget_set_hexpand(button1, TRUE); gtk_widget_set_vexpand(button1, TRUE); g_signal_connect(button1, "focus-in-event", G_CALLBACK(focus_button1), NULL); GtkWidget *combo=gtk_combo_box_text_new(); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 0, "1", "Turtle"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 1, "2", "Koala"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 2, "3", "Cheetah"); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_widget_set_hexpand(combo, TRUE); GtkWidget *toggle_button=NULL; gtk_container_forall(GTK_CONTAINER(combo), (GtkCallback)find_toggle_button, _button); g_signal_connect(toggle_button, "focus-in-event", G_CALLBACK(focus_combo), NULL); g_signal_connect(combo, "set-focus-child", G_CALLBACK(focus_combo_container), NULL); GtkWidget *button2=gtk_button_new_with_label("Button2"); gtk_widget_set_hexpand(button2, TRUE); gtk_widget_set_vexpand(button2, TRUE); g_signal_connect(button2, "focus-in-event", G_CALLBACK(focus_button2), NULL); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), button1, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid), combo, 0, 1, 1, 1); gtk_grid_attach(GTK_GRID(grid), button2, 0, 2, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); gtk_widget_show_all(window); gtk_main(); return 0; } static void find_toggle_button(GtkWidget *widget, GtkWidget **toggle_button) { if(g_strcmp0(gtk_widget_get_name(widget), "GtkToggleButton")==0) { g_print("Found Toggle Button in Combo\n"); *toggle_button=widget; } } static gboolean focus_button1(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Button1 Focus\n"); return FALSE; } static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Combo Focus In\n"); return FALSE; } static gboolean focus_button2(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Button2 Focus\n"); return FALSE; } static void focus_combo_container(GtkContainer *container, GtkWidget *widget, gpointer user_data) { g_print("Combo Container Focus\n"); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Il Fri, 7 Apr 2017 13:52:57 -0400 Eric Cashon via gtk-app-devel-list <gtk-app-devel-list@gnome.org> scrisse: > Thomas, > > Your original question looked easy. Connect the "focus-in-event" to the combo > box and everything will work fine. > ... Hi, GtkComboBox is a GtkContainer, so I would try to connect the callback to the set-focus-child signal instead: https://developer.gnome.org/gtk3/stable/GtkContainer.html#GtkContainer-set-focus-child Ciao. -- Nicola ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Thomas, Your original question looked easy. Connect the "focus-in-event" to the combo box and everything will work fine. The "focus-in-event" works with other widgets. So I tried it out. Couldn't get it to work. Tried changing some combo box functions around and still couldn't get it to work. So I looked at the GTK source code for the combo box to see if I could understand the problem a little better. I saw a toggle button in the private structure so I gave that a try. That is as far as I got. Don't use private variables in your application code. They are private for a reason. The toggle button needs to work a certain way for the combo box to work. If there is a possible bug that you need to get a better look at, then you need to start digging into the private structure to figure out what is going on and why something isn't working as expected. Also look at previous bug reports. If you get everything figured out and it is a bug then file a bug report. As part of the discussion, if someone knows an easy way to connect the "focus-in-event" with the combo box, say so. Eric ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Hi Eric, Thanks a lot, looks good. I will try it. If I want the same feature with other widgets, then I can find the structs in the sources from GTK ? Thomas On 04/06/2017 10:43 PM, cecas...@aol.com wrote: Hi Thomas, You can try getting the private toggle button in the combo box. This isn't a solution using the given GTK api but if you want to inspect the how to get the "focus-in-event" to work with a combo box, this might be helpful. You are working in C right? Eric /* gcc -Wall combo_focus1.c -o combo_focus1 `pkg-config gtk+-3.0 --cflags --libs` Tested on Ubuntu16.04, GTK3.18. */ #include //From gtkcombobox.c struct _GtkComboBoxPrivate { GtkTreeModel *model; GtkCellArea *area; gint col_column; gint row_column; gint wrap_width; gint active; /* Only temporary */ GtkTreeRowReference *active_row; GtkWidget *tree_view; GtkWidget *cell_view; GtkWidget *box; GtkWidget *button; GtkWidget *arrow; GtkWidget *popup_widget; GtkWidget *popup_window; GtkWidget *scrolled_window; //GtkCssGadget *gadget; gulong inserted_id; gulong deleted_id; gulong reordered_id; gulong changed_id; guint popup_idle_id; guint activate_button; guint32 activate_time; guint scroll_timer; guint resize_idle_id; /* For "has-entry" specific behavior we track * an automated cell renderer and text column */ gint text_column; GtkCellRenderer *text_renderer; gint id_column; guint popup_in_progress : 1; guint popup_shown : 1; guint add_tearoffs : 1; guint has_frame : 1; guint is_cell_renderer : 1; guint editing_canceled : 1; guint auto_scroll : 1; guint button_sensitivity : 2; guint has_entry : 1; guint popup_fixed_width : 1; GtkTreeViewRowSeparatorFunc row_separator_func; gpointerrow_separator_data; GDestroyNotify row_separator_destroy; GdkDevice *grab_pointer; gchar *tearoff_title; }; static gboolean focus_button(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data); int main(int argc, char *argv[]) { gtk_init(, ); GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Rooster Icon"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); GtkWidget *button=gtk_button_new_with_label("Button"); gtk_widget_set_hexpand(button, TRUE); gtk_widget_set_vexpand(button, TRUE); g_signal_connect(button, "focus-in-event", G_CALLBACK(focus_button), NULL); GtkWidget *combo=gtk_combo_box_text_new(); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 0, "1", "Turtle"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 1, "2", "Koala"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 2, "3", "Cheetah"); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_widget_set_hexpand(combo, TRUE); GtkComboBoxPrivate *priv=G_TYPE_INSTANCE_GET_PRIVATE((combo), GTK_TYPE_COMBO_BOX, GtkComboBoxPrivate); g_signal_connect(priv->button, "focus-in-event", G_CALLBACK(focus_combo), NULL); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), button, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid), combo, 0, 1, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); gtk_widget_show_all(window); gtk_main(); return 0; } static gboolean focus_button(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Button Focus\n"); return FALSE; } static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Combo Focus\n"); return FALSE; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Combobox focus event
Hi Thomas, You can try getting the private toggle button in the combo box. This isn't a solution using the given GTK api but if you want to inspect the how to get the "focus-in-event" to work with a combo box, this might be helpful. You are working in C right? Eric /* gcc -Wall combo_focus1.c -o combo_focus1 `pkg-config gtk+-3.0 --cflags --libs` Tested on Ubuntu16.04, GTK3.18. */ #include //From gtkcombobox.c struct _GtkComboBoxPrivate { GtkTreeModel *model; GtkCellArea *area; gint col_column; gint row_column; gint wrap_width; gint active; /* Only temporary */ GtkTreeRowReference *active_row; GtkWidget *tree_view; GtkWidget *cell_view; GtkWidget *box; GtkWidget *button; GtkWidget *arrow; GtkWidget *popup_widget; GtkWidget *popup_window; GtkWidget *scrolled_window; //GtkCssGadget *gadget; gulong inserted_id; gulong deleted_id; gulong reordered_id; gulong changed_id; guint popup_idle_id; guint activate_button; guint32 activate_time; guint scroll_timer; guint resize_idle_id; /* For "has-entry" specific behavior we track * an automated cell renderer and text column */ gint text_column; GtkCellRenderer *text_renderer; gint id_column; guint popup_in_progress : 1; guint popup_shown : 1; guint add_tearoffs : 1; guint has_frame : 1; guint is_cell_renderer : 1; guint editing_canceled : 1; guint auto_scroll : 1; guint button_sensitivity : 2; guint has_entry : 1; guint popup_fixed_width : 1; GtkTreeViewRowSeparatorFunc row_separator_func; gpointerrow_separator_data; GDestroyNotify row_separator_destroy; GdkDevice *grab_pointer; gchar *tearoff_title; }; static gboolean focus_button(GtkWidget *widget, GdkEvent *event, gpointer user_data); static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data); int main(int argc, char *argv[]) { gtk_init(, ); GtkWidget *window=gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_title(GTK_WINDOW(window), "Rooster Icon"); gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); gtk_container_set_border_width(GTK_CONTAINER(window), 10); gtk_window_set_default_size(GTK_WINDOW(window), 200, 100); g_signal_connect(window, "destroy", G_CALLBACK(gtk_main_quit), NULL); GtkWidget *button=gtk_button_new_with_label("Button"); gtk_widget_set_hexpand(button, TRUE); gtk_widget_set_vexpand(button, TRUE); g_signal_connect(button, "focus-in-event", G_CALLBACK(focus_button), NULL); GtkWidget *combo=gtk_combo_box_text_new(); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 0, "1", "Turtle"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 1, "2", "Koala"); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo), 2, "3", "Cheetah"); gtk_combo_box_set_active(GTK_COMBO_BOX(combo), 0); gtk_widget_set_hexpand(combo, TRUE); GtkComboBoxPrivate *priv=G_TYPE_INSTANCE_GET_PRIVATE((combo), GTK_TYPE_COMBO_BOX, GtkComboBoxPrivate); g_signal_connect(priv->button, "focus-in-event", G_CALLBACK(focus_combo), NULL); GtkWidget *grid=gtk_grid_new(); gtk_grid_attach(GTK_GRID(grid), button, 0, 0, 1, 1); gtk_grid_attach(GTK_GRID(grid), combo, 0, 1, 1, 1); gtk_container_add(GTK_CONTAINER(window), grid); gtk_widget_show_all(window); gtk_main(); return 0; } static gboolean focus_button(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Button Focus\n"); return FALSE; } static gboolean focus_combo(GtkWidget *widget, GdkEvent *event, gpointer user_data) { g_print("Combo Focus\n"); return FALSE; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Combobox focus event
Hi, I can't get focus-in-event to work for a combobox. It seems others have the same problem, when I google. Is there a way to get an event when clicking on a combobox ? Either with the mouse or with TAB. Regards Thomas ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Get tty device for the application that lost focus
I am not sure whether this is possible, but here goes... I am writing a Gtk3 application whilst learning the API and I am pushing it by trying to achieve some edgy things! My application, which is suitably privileged, can inject some arbitrary text into the tty of another application. It does this like so (Ruby example): tty = '/dev/pts/5' # need to determine this! File.open(tty, File::WRONLY|File::NONBLOCK) do |f| content.split('').each { |c| f.ioctl(0x5412,c) } end It works if I hard-code the device (the '/dev/pts/5' exemplified above) but I would like to be able to ascertain this from within my application: I want to find the tty for the application that lost the input focus to my application. My application receives the focus at the expense of the application window that it should inject input to. My application can receive focus either by a mouse click or through a global keybinding applied using the keybinder[1] api. Is there a way for a Gtk3+ application to discover the tty device of the application that lost focus to it ? Although my example is in Ruby, any pointers in C, Ruby or Python would be helpful - I can work out the bindings if I know how it is done in C. [1] https://lazka.github.io/pgi-docs/#Keybinder-3.0 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
hide window when the application loses focus
How can I hide a window when the application loses focus? I'm working in Linux (X11). Is there a window hint for doing it? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Help with keyboard event capture and focus in/out
My application needs to capture keyboard events: when my windows is focused, I want all keystrokes routed to my app, and not to the WM. For example pressing Super key on Ubutntu Unity, should not open the dash, but activate a function in my application. So I used gdk_device_grab() to capture keyboard events. But when gdk_device_grab() is in effect, I no longer receive "focus-out-event" signal, so my application can never release the grab. How can I fix it ? Attached is a full working example which exposes the problem, I'm using Ubuntu 16.04 (GTK 3.18). Compile it with gcc `pkg-config --cflags gtk+-3.0` -o testkbgrab \ testkbgrab.c `pkg-config --libs gtk+-3.0` Thank you for your help. Giovanni ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to reactivate (focus?) the main window,
Hi If your application should get being accepted you should consider ATK https://developer.gnome.org/atk/ else forget the focus handling cheers, Joël Krähemann On Mon, Sep 5, 2016 at 3:25 PM, Joël Krähemann <jkraehem...@gmail.com> wrote: > Hi > > you might want to look at: > > * gtk_widget_set_can_focus ()¨ > * gtk_widget_set_events() > > > g_object_set(window, >"can-focus\0", TRUE, >NULL); > gtk_widget_set_events((GtkWidget *) window, > GDK_CONTROL_MASK > | GDK_KEY_PRESS_MASK > | GDK_KEY_RELEASE_MASK) > > ... > > g_signal_connect_after(G_OBJECT(window), "focus_in_event\0", > > G_CALLBACK(your_window_box_focus_in_callback), (gpointer) window); > > g_signal_connect_after(G_OBJECT(window), "focus_out_event\0", > > G_CALLBACK(your_window_box_focus_out_callback), (gpointer) window); > > ... > > gtk_widget_set_state((GtkWidget *) window, > GTK_STATE_ACTIVE); > > That's it. > > bests, > Joël > > On Mon, Sep 5, 2016 at 2:57 PM, Paulo Silva <pa...@sistemasolar.com.br> wrote: >> I don't now if I understood correctly your problem. >> Maybe this: >> >> gtk_window_present( GTK_WINDOW(ptr_to_your_window) ); >> >> José Paulo >> >> >> 2016-09-04 13:58 GMT-03:00 dmg <d...@uvic.ca>: >> >>> On Sun, Sep 4, 2016 at 9:57 AM, dmg <d...@uvic.ca> wrote: >>> >>> > >>> > I have tried using gtk_window_set_focus(winMain); but this does not >>> work. >>> > >>> >>> My mistake. I have used: >>> >>> gtk_widget_grab_focus(winMain); >>> >>> and it does not work. >>> >>> >>> >>> >>> -- >>> --dmg >>> >>> --- >>> Daniel M. German >>> http://turingmachine.org >>> ___ >>> gtk-app-devel-list mailing list >>> gtk-app-devel-list@gnome.org >>> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list >>> >> ___ >> gtk-app-devel-list mailing list >> gtk-app-devel-list@gnome.org >> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Preventing fade on loss of focus?
On Tue, Sep 6, 2016 at 3:54 PM, Mark Farver <mfar...@mindbent.org> wrote: > I launch gstreamer as if it was an embedded video, but the output > plugin supplied by the graphics vendor (imxeglvivsink) still causes > the GTK main window to lose focus even when handed a parent window id. I never found a way to make gstreamer render on my window so I wouldn't lose focus, but a workaround was to load a stylesheet that overrides the default behavior and keeps the same font color for labels whether the window is active or inactive: ---my-app.css GtkLabel { color: black; } GtkLabel:active { color: black; } GtkLabel:inactive { color: black; } --- ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Preventing fade on loss of focus?
On Tue, Sep 6, 2016 at 3:26 PM, Gergely Polonkai <gerg...@polonkai.eu> wrote: > how exactly do you play the video? Do you open a separate video player like > Totem, or you embed it somehow to your main window? I launch gstreamer as if it was an embedded video, but the output plugin supplied by the graphics vendor (imxeglvivsink) still causes the GTK main window to lose focus even when handed a parent window id. /* Initialize GStreamer */ gst_init (NULL, NULL); data.playbin = gst_element_factory_make ("playbin", "playbin"); /* Create the IMX EGL Sink */ data.sink = gst_element_factory_make ("imxeglvivsink", "videosink"); g_object_set (GST_OBJECT (data.sink), "parent", gtk_widget_get_window (mainwindow), NULL); g_object_set (GST_OBJECT (data.sink), "borderless-window", TRUE, NULL); //w = 400; h = 300; /* Create the IMX EGL Sink */ g_object_set (GST_OBJECT (data.sink), "window-width", w, NULL); g_object_set (GST_OBJECT (data.sink), "window-height", h, NULL); g_object_set (GST_OBJECT (data.sink), "window-x-coord", x, NULL); g_object_set (GST_OBJECT (data.sink), "window-y-coord", y, NULL); snprintf(cmd, sizeof(cmd), "file://%s", filename); g_object_set (data.playbin, "uri", cmd, NULL); g_object_set (GST_OBJECT (data.playbin), "video-sink", data.sink, NULL); /* Start playing */ gst_element_set_state (data.playbin, GST_STATE_PLAYING); Mark ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Preventing fade on loss of focus?
Hello, how exactly do you play the video? Do you open a separate video player like Totem, or you embed it somehow to your main window? Best, Gergely On Tue, Sep 6, 2016, 21:00 Mark Farver <mfar...@mindbent.org> wrote: > I am using GTK3 with Weston/Wayland and when I play a video using > gstreamer my main window loses focus and all the labels dim. This is > not the behavior I want since the video is part of the window. This > is an ATM like kiosk, so there is no user interface issues related to > the loss of focus. > > Is there a way to modify the window system to disable the dimming > feature, or set the focus/unfocused styles the same? > > Thank you > Mark Farver > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Preventing fade on loss of focus?
I am using GTK3 with Weston/Wayland and when I play a video using gstreamer my main window loses focus and all the labels dim. This is not the behavior I want since the video is part of the window. This is an ATM like kiosk, so there is no user interface issues related to the loss of focus. Is there a way to modify the window system to disable the dimming feature, or set the focus/unfocused styles the same? Thank you Mark Farver ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to reactivate (focus?) the main window,
Hi you might want to look at: * gtk_widget_set_can_focus ()¨ * gtk_widget_set_events() g_object_set(window, "can-focus\0", TRUE, NULL); gtk_widget_set_events((GtkWidget *) window, GDK_CONTROL_MASK | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK) ... g_signal_connect_after(G_OBJECT(window), "focus_in_event\0", G_CALLBACK(your_window_box_focus_in_callback), (gpointer) window); g_signal_connect_after(G_OBJECT(window), "focus_out_event\0", G_CALLBACK(your_window_box_focus_out_callback), (gpointer) window); ... gtk_widget_set_state((GtkWidget *) window, GTK_STATE_ACTIVE); That's it. bests, Joël On Mon, Sep 5, 2016 at 2:57 PM, Paulo Silva <pa...@sistemasolar.com.br> wrote: > I don't now if I understood correctly your problem. > Maybe this: > > gtk_window_present( GTK_WINDOW(ptr_to_your_window) ); > > José Paulo > > > 2016-09-04 13:58 GMT-03:00 dmg <d...@uvic.ca>: > >> On Sun, Sep 4, 2016 at 9:57 AM, dmg <d...@uvic.ca> wrote: >> >> > >> > I have tried using gtk_window_set_focus(winMain); but this does not >> work. >> > >> >> My mistake. I have used: >> >> gtk_widget_grab_focus(winMain); >> >> and it does not work. >> >> >> >> >> -- >> --dmg >> >> --- >> Daniel M. German >> http://turingmachine.org >> ___ >> gtk-app-devel-list mailing list >> gtk-app-devel-list@gnome.org >> https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list >> > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to reactivate (focus?) the main window,
I don't now if I understood correctly your problem. Maybe this: gtk_window_present( GTK_WINDOW(ptr_to_your_window) ); José Paulo 2016-09-04 13:58 GMT-03:00 dmg: > On Sun, Sep 4, 2016 at 9:57 AM, dmg wrote: > > > > > I have tried using gtk_window_set_focus(winMain); but this does not > work. > > > > My mistake. I have used: > > gtk_widget_grab_focus(winMain); > > and it does not work. > > > > > -- > --dmg > > --- > Daniel M. German > http://turingmachine.org > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: How to reactivate (focus?) the main window,
On Sun, Sep 4, 2016 at 9:57 AM, dmgwrote: > > I have tried using gtk_window_set_focus(winMain); but this does not work. > My mistake. I have used: gtk_widget_grab_focus(winMain); and it does not work. -- --dmg --- Daniel M. German http://turingmachine.org ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
How to reactivate (focus?) the main window,
hi everybody, i help maintain xournal. We use gtk+2. One feature we support is making a screenshot. This is done by activating the root window. Things work as expected. But... the problem is, how do I activate the main window? The focus remains in the root one. I have tried using gtk_window_set_focus(winMain); but this does not work. thank you, --daniel --- Daniel M. German http://turingmachine.org ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
That's my understanding for Wayland as well, I'd be interested in knowing if that's wrong as well since it's been an oft requested feature for terminix. On Thu, Aug 25, 2016 at 6:51 AM, pelzflorian (Florian Pelz)wrote: > I believe shell integration is the only clean way to do a > Wayland-compatible guake. Am I wrong? > ___ > gtk-app-devel-list mailing list > gtk-app-devel-list@gnome.org > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
I believe shell integration is the only clean way to do a Wayland-compatible guake. Am I wrong? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
This is odd! If I change "org.gnome.desktop.wm.preferences.disable-workarounds" to TRUE, everything works fine El 23/08/16 a las 19:11, rastersoft escribió: > Well, it seems that destroying the window and creating it again also > doesn't work. > > It seems that I can't "steal" the focus when it is in other application, > but if my app has the focus in one window, I can pass it to another one > using grab_focus(). > > > El 23/08/16 a las 16:24, rastersoft escribió: >> Hi: >> >>>> It's not a problem of being early: I even tried to put a 1-second timer >>>> to call to grab_focus(), but didn't work. >>>> >>>> In fact, the first time I create the window it works fine, but seems to >>>> fail when I hide it and show it again. >>> So it may be related to the window manager? >> I suspect that. In fact, I think I'm going to just save the internal >> widget and create a new window every time I press the hotkey. >> >> It is a guake clone written in Vala, using Gtk3. I'm using libkeybinder >> to detect a global key. It is the same library used by guake and >> terminator, but they use Gtk2. I also implemented a guake mode in >> terminator, but had to do some tricks to ensure that the window received >> the focus on those same cases when my vala code fails (I use a >> show-hide-show scheme, that seems to guarantee that the window receives >> the focus; but it seems to work only with gtk2, but not gtk3). >> >>> Is it Linux with Gnome3 shell? Gnome 3.20? >> That's right. I'm using debian sid. >> >>> May other programs steal the focus? >> No, AFAIK. >> >>> Do other tools work fine? When you hide and show gedit, will it have >>> the focus? >>> >> Yes, everything works fine. >> -- Nos leemos RASTER(Linux user #228804) ras...@rastersoft.com http://www.rastersoft.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
Well, it seems that destroying the window and creating it again also doesn't work. It seems that I can't "steal" the focus when it is in other application, but if my app has the focus in one window, I can pass it to another one using grab_focus(). El 23/08/16 a las 16:24, rastersoft escribió: > Hi: > >>> It's not a problem of being early: I even tried to put a 1-second timer >>> to call to grab_focus(), but didn't work. >>> >>> In fact, the first time I create the window it works fine, but seems to >>> fail when I hide it and show it again. >> So it may be related to the window manager? > I suspect that. In fact, I think I'm going to just save the internal > widget and create a new window every time I press the hotkey. > > It is a guake clone written in Vala, using Gtk3. I'm using libkeybinder > to detect a global key. It is the same library used by guake and > terminator, but they use Gtk2. I also implemented a guake mode in > terminator, but had to do some tricks to ensure that the window received > the focus on those same cases when my vala code fails (I use a > show-hide-show scheme, that seems to guarantee that the window receives > the focus; but it seems to work only with gtk2, but not gtk3). > >> Is it Linux with Gnome3 shell? Gnome 3.20? > That's right. I'm using debian sid. > >> May other programs steal the focus? > No, AFAIK. > >> Do other tools work fine? When you hide and show gedit, will it have >> the focus? >> > Yes, everything works fine. > -- Nos leemos RASTER(Linux user #228804) ras...@rastersoft.com http://www.rastersoft.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
Hi: >> It's not a problem of being early: I even tried to put a 1-second timer >> to call to grab_focus(), but didn't work. >> >> In fact, the first time I create the window it works fine, but seems to >> fail when I hide it and show it again. > So it may be related to the window manager? I suspect that. In fact, I think I'm going to just save the internal widget and create a new window every time I press the hotkey. It is a guake clone written in Vala, using Gtk3. I'm using libkeybinder to detect a global key. It is the same library used by guake and terminator, but they use Gtk2. I also implemented a guake mode in terminator, but had to do some tricks to ensure that the window received the focus on those same cases when my vala code fails (I use a show-hide-show scheme, that seems to guarantee that the window receives the focus; but it seems to work only with gtk2, but not gtk3). > Is it Linux with Gnome3 shell? Gnome 3.20? That's right. I'm using debian sid. > May other programs steal the focus? No, AFAIK. > Do other tools work fine? When you hide and show gedit, will it have > the focus? > Yes, everything works fine. -- Nos leemos RASTER(Linux user #228804) ras...@rastersoft.com http://www.rastersoft.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
On Tue, 2016-08-23 at 00:38 +0200, rastersoft wrote: > It's not a problem of being early: I even tried to put a 1-second timer > to call to grab_focus(), but didn't work. > > In fact, the first time I create the window it works fine, but seems to > fail when I hide it and show it again. So it may be related to the window manager? Is it Linux with Gnome3 shell? Gnome 3.20? May other programs steal the focus? Do other tools work fine? When you hide and show gedit, will it have the focus? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
It's not a problem of being early: I even tried to put a 1-second timer to call to grab_focus(), but didn't work. In fact, the first time I create the window it works fine, but seems to fail when I hide it and show it again. El 22/08/16 a las 20:42, Stefan Salewski escribió: > On Sun, 2016-08-21 at 21:56 +0200, rastersoft wrote: >> I tried to >> call "grab_focus" on the "map" callback... but doesn't work. > The map signal may be too early. > > Maybe g_signal_connect_after() may work. > > After map signal map_event is emmited, maybe you can use that one. > > Or try the draw signal, I guess it should be emmited after map signal. > > > -- Nos leemos RASTER(Linux user #228804) ras...@rastersoft.com http://www.rastersoft.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting focus
On Sun, 2016-08-21 at 21:56 +0200, rastersoft wrote: > I tried to > call "grab_focus" on the "map" callback... but doesn't work. The map signal may be too early. Maybe g_signal_connect_after() may work. After map signal map_event is emmited, maybe you can use that one. Or try the draw signal, I guess it should be emmited after map signal. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Getting focus
Hi all: I'm creating a guake-like terminal, but I'm having problems to ensure that the window has the focus. The idea is that I have a global shortcut that, when pressed, will show a terminal window. The problem is that, under certain circumstances, I'm unable to ensure that the window will receive the focus. I tried to use "present()". Also a "show/hide/show" trick. I tried to call "grab_focus" on the "map" callback... but doesn't work. If the window had previously the focus before being hiden, then it regains the focus when presented; but if it loses the focus before being hiden, then it doesn't recover the focus until I do a click on the window. I'm working with Vala and Gtk3. -- Nos leemos RASTER(Linux user #228804) ras...@rastersoft.com http://www.rastersoft.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Centering window over window with current focus
(Resending since my message was held for moderation, because I was not subscribed, and the message has apparently not been released yet.) Hi, I work on GnuPG. We have a helper program call pinentry that asks for the user's passphrase. This means that a program like Enigmail doesn't need to handle the user's passphrase and accidentally leak it due to a bug like heart bleed. I have a dual-monitor setup and I've observed the following issue: when pinentry is started, it appears on the monitor that currently has the mouse cursor rather the the monitor that has the window with the focus. This is a bit annoying and occurs quite often for me due to my limited use of the mouse. Is there a way to change this programatically or is this perhaps a theme or window manager policy that I can't override (I'm using XFCE from Debian Stable on this system)? If I can change it, I'd appreciate any pointers to get me started. Thanks! :) Neal ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Setting focus to newly shown window
On 20.01.2016 08:55, Marius Gedminas wrote: > On Tue, Jan 19, 2016 at 10:10:09PM +0100, Johannes Bauer wrote: >> I've done some GTK programming in the ancient past and am just now >> starting again with GTK3, Glade and pygtk. Wow, the project has come a >> long way. It's absolutely amazing and so much simpler than in the past. >> I love it. > > (I think you mean PyGObject, since PyGTK doesn't support GTK+ 3.x.) True! > Isn't info_window.show() doing what you want? Newly-opened windows > appear on top and get keyboard focus. Hm, they didn't in my example, even though I had newer shown it before. > If the window was already visible, and you just want to bring it to > front, try info_window.present(). The window manager (i.e. gnome-shell) > may feel free to ignore your request, on the grounds of focus stealing > prevention -- in that case you'll get a notification about the window > wanting attention. Works perfectly, thanks to you (and Phil and John) for the clarification. Best regards, Johannes ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Setting focus to newly shown window
On Tue, Jan 19, 2016 at 10:10:09PM +0100, Johannes Bauer wrote: > I've done some GTK programming in the ancient past and am just now > starting again with GTK3, Glade and pygtk. Wow, the project has come a > long way. It's absolutely amazing and so much simpler than in the past. > I love it. (I think you mean PyGObject, since PyGTK doesn't support GTK+ 3.x.) > But that aside, I do have a newbie question that I can't seem to figure > out: I have a main application and want to show a different top level > window (let's say it's a "info" window). When the window is opened, I > want it to show and give it the focus (so the user can press enter and > quickly close it down again). But I don't want it modal (it's okay if > the user changes the focus back to the main window and lets the "info" > window open). > > I've tried set_focus() and grab_focus(), but both don't do what I expect > them to do. Surely this is insanely easy, but I couldn't find on the web > how it's done. Can someone give me a hand, please? Isn't info_window.show() doing what you want? Newly-opened windows appear on top and get keyboard focus. If the window was already visible, and you just want to bring it to front, try info_window.present(). The window manager (i.e. gnome-shell) may feel free to ignore your request, on the grounds of focus stealing prevention -- in that case you'll get a notification about the window wanting attention. Regards, Marius Gedminas -- Just a note: quantum gravity discussions are _clearly_ on-topic in c.l.py. -- Peter Hansen on comp.lang.python ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GTK widget focus control
Hi, I'm trying to get a C++ GTK application that works under GTK 2.2 in Ubuntu 10.04 to run under GTK 2.24 in Ubuntu 14.04. I'm having a problem with focus control in the new system. Some screens with edit fields still handle the keyboard Tab key properly by moving focus to the next widget; others do nothing when Tab is pressed. Using Tab to move focus works on all screens in the old system. In the new system, if I click on any edit field, it accepts focus, so it doesn't seem to be a can-focus type problem. Any ideas what to look for, or what has changed in focus handling between these? (Some code has had to change between the two versions, so it's not exactly the same code base and something may have been broken but none of the changes have been related to focus control as far as I know.) I've read the GTK FAQ and a number of online postings related to GTK focus control without finding anything. Regards, John Boncek ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Problems Sending Input/Focus to Plug Window - Solution
Ok, it's already implemented, though using a huge framework like gtk can sometimes make it a tough job to find the right trigger. The plug/socket example could be a bit more detailed, but I guess the gtk Developers are quite busy, like us ;). Anyways, here is the solution: socket-child_focus(Gtk::DIR_TAB_FORWARD); For your convenience, the link to Gtk::DirectionType: https://developer.gnome.org/gtkmm/3.11/group__gtkmmEnums.html#ga6c754c32a8421f746367b43c277e4d7b One little question remains: Is there any way to put the focus to an embedded xterm? It somehow seems, that xterm does not follow the xembed protocoll correctly. Be wild and genius, Benjamin ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Problems Sending Input/Focus to Plug Window
Dear list members, I'm trying to create an unmanaged Gtk window containing one or more embedded windows (for example terminals). I'm having Problems focussing and sending input to these embedded windows. I already tried to embed an xterm and a urxvt window. At least the urxvt works correctly, if no other elements are in the window. However putting a button into the window leads to the terminal loosing its focus with no apparent way to let it regain it. It is however possible to send an XEMBED_FOCUS_IN message to the urxvt window. Whe the urxvt recieves the message, it will at least change the cursor correctly, but yet, no input is send to it. Using an xterm doesn't work, even with normal toplevel windows. Can You help me in solving this problem? Here is a gist containing a more or less minimal example (I'm using the gtkmm C++ interface): https://gist.github.com/anonymous/f179ff891f7c8029faf8 or clone it via: git clone https://gist.github.com/f179ff891f7c8029faf8.git Benjamin For reference, here is the code from the gist: Makefile: sockfoc: sockfoc.cc window_ext.h g++ -ggdb sockfoc.cc -o sockfoc `pkg-config gtkmm-3.0 --cflags --libs` -lX11 sockfoc.cc #include gtkmm.h #include gtkmm/socket.h #include window_ext.h #define XEMBED_FOCUS_IN 4 #define XEMBED_FOCUS_CURRENT 0 class TheWindow : public WindowExt { Gtk::Box* box; Gtk::Socket* socket; Gtk::Button* button_close; public: TheWindow() : WindowExt(Gtk::WINDOW_POPUP) { signal_realize().connect( sigc::mem_fun(*this,TheWindow::add_term) ); button_close = Gtk::manage( new Gtk::Button(Close Window.) ); box = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_VERTICAL) ); box-pack_start( *button_close ); add(*box); button_close-signal_clicked().connect( sigc::mem_fun(*this,Window::hide) ); show_all(); grab_keyboard(this-get_window()); } void add_term() { socket = Gtk::manage( new Gtk::Socket ); box-pack_start( *socket ); int xid = socket-get_id(); char buffer[50]; //sprintf(buffer, xterm -into %d , xid); sprintf(buffer, urxvt -embed %d , xid); system(buffer); box-show_all(); socket-signal_plug_added().connect( sigc::mem_fun(*this, TheWindow::send_focus_in) ); socket-signal_plug_removed().connect( sigc::mem_fun(*this, TheWindow::on_plug_removed) ); } bool on_plug_removed() { hide(); return false; } void send_focus_in() { GdkWindow* plug = socket-get_plug_window()-gobj(); GdkDisplay *display = gdk_window_get_display(plug); XClientMessageEvent xclient; memset(xclient, 0, sizeof (xclient)); xclient.window = GDK_WINDOW_XID(plug); xclient.type = ClientMessage; xclient.message_type = gdk_x11_get_xatom_by_name_for_display(display, _XEMBED); xclient.format = 32; xclient.data.l[0] = gtk_get_current_event_time(); xclient.data.l[1] = XEMBED_FOCUS_IN; xclient.data.l[2] = XEMBED_FOCUS_CURRENT; xclient.data.l[3] = 0; xclient.data.l[4] = 0; XSendEvent( GDK_WINDOW_XDISPLAY(plug), GDK_WINDOW_XID(plug), False, NoEventMask, (XEvent *)xclient ); } }; int main(int argc, char** argv) { Glib::RefPtrGtk::Application app; app = Gtk::Application::create(argc, argv, socket.focustest); TheWindow win; return app-run(win); } window_ext.h: #ifndef WINDOW_EXT_H #define WINDOW_EXT_H #include gtkmm.h #include iostream class Overlay; class WindowExt : public Gtk::Window { private: Cairo::RefPtrCairo::Region shape; public: void grab_keyboard(Glib::RefPtrGdk::Window dest) { Glib::RefPtrGdk::Display display = get_display(); Glib::RefPtrGdk::DeviceManager deviceM = display-get_device_manager(); std::vector Glib::RefPtrGdk::Device devices = deviceM-list_devices( Gdk::DEVICE_TYPE_MASTER ); std::vector Glib::RefPtrGdk::Device ::iterator it; for(it = devices.begin(); it != devices.end(); ++it) { for(int grab = Gdk::GRAB_NOT_VIEWABLE; grab == Gdk::GRAB_NOT_VIEWABLE;) { grab = (*it)-grab( dest, Gdk::OWNERSHIP_NONE, true, Gdk::ALL_EVENTS_MASK, GDK_CURRENT_TIME ); } } } WindowExt(Gtk::WindowType type=Gtk::WINDOW_TOPLEVEL) : Window(type) {} virtual ~WindowExt(){} }; #endif ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Problems Sending Input/Focus to Plug Window
Hi, I've had a similar problem when trying to give focus to a widget within the embedded window (from socket application). It seems that this is not really possible at the present moment. I've created an example with the plug-socket example code [0]. Here [1] is also a patch for a gtk_socket_focus_forward () method that could give focus to the next widget within the embedded window, but I have not yet received any response on this approach. An example of how this could be used (using the plug-socket example) can also be found in the focus_forward branch [2]. The bug report has some more information, also I sent an email to this list a while ago: https://mail.gnome.org/archives/gtk-app-devel-list/2014-May/msg2.html [0] https://github.com/gauteh/plug-socket-grab-focus [1] https://bugzilla.gnome.org/show_bug.cgi?id=729248 [2] https://github.com/gauteh/plug-socket-grab-focus/tree/focus_forward Cheers, Gaute On Tue, Aug 26, 2014 at 10:24 PM, Benjamin Schnitzler benjaminschnitz...@googlemail.com wrote: Dear list members, I'm trying to create an unmanaged Gtk window containing one or more embedded windows (for example terminals). I'm having Problems focussing and sending input to these embedded windows. I already tried to embed an xterm and a urxvt window. At least the urxvt works correctly, if no other elements are in the window. However putting a button into the window leads to the terminal loosing its focus with no apparent way to let it regain it. It is however possible to send an XEMBED_FOCUS_IN message to the urxvt window. Whe the urxvt recieves the message, it will at least change the cursor correctly, but yet, no input is send to it. Using an xterm doesn't work, even with normal toplevel windows. Can You help me in solving this problem? Here is a gist containing a more or less minimal example (I'm using the gtkmm C++ interface): https://gist.github.com/anonymous/f179ff891f7c8029faf8 or clone it via: git clone https://gist.github.com/f179ff891f7c8029faf8.git Benjamin For reference, here is the code from the gist: Makefile: sockfoc: sockfoc.cc window_ext.h g++ -ggdb sockfoc.cc -o sockfoc `pkg-config gtkmm-3.0 --cflags --libs` -lX11 sockfoc.cc #include gtkmm.h #include gtkmm/socket.h #include window_ext.h #define XEMBED_FOCUS_IN 4 #define XEMBED_FOCUS_CURRENT 0 class TheWindow : public WindowExt { Gtk::Box* box; Gtk::Socket* socket; Gtk::Button* button_close; public: TheWindow() : WindowExt(Gtk::WINDOW_POPUP) { signal_realize().connect( sigc::mem_fun(*this,TheWindow::add_term) ); button_close = Gtk::manage( new Gtk::Button(Close Window.) ); box = Gtk::manage( new Gtk::Box(Gtk::ORIENTATION_VERTICAL) ); box-pack_start( *button_close ); add(*box); button_close-signal_clicked().connect( sigc::mem_fun(*this,Window::hide) ); show_all(); grab_keyboard(this-get_window()); } void add_term() { socket = Gtk::manage( new Gtk::Socket ); box-pack_start( *socket ); int xid = socket-get_id(); char buffer[50]; //sprintf(buffer, xterm -into %d , xid); sprintf(buffer, urxvt -embed %d , xid); system(buffer); box-show_all(); socket-signal_plug_added().connect( sigc::mem_fun(*this, TheWindow::send_focus_in) ); socket-signal_plug_removed().connect( sigc::mem_fun(*this, TheWindow::on_plug_removed) ); } bool on_plug_removed() { hide(); return false; } void send_focus_in() { GdkWindow* plug = socket-get_plug_window()-gobj(); GdkDisplay *display = gdk_window_get_display(plug); XClientMessageEvent xclient; memset(xclient, 0, sizeof (xclient)); xclient.window = GDK_WINDOW_XID(plug); xclient.type = ClientMessage; xclient.message_type = gdk_x11_get_xatom_by_name_for_display(display, _XEMBED); xclient.format = 32; xclient.data.l[0] = gtk_get_current_event_time(); xclient.data.l[1] = XEMBED_FOCUS_IN; xclient.data.l[2] = XEMBED_FOCUS_CURRENT; xclient.data.l[3] = 0; xclient.data.l[4] = 0; XSendEvent( GDK_WINDOW_XDISPLAY(plug), GDK_WINDOW_XID(plug), False, NoEventMask, (XEvent *)xclient ); } }; int main(int argc, char** argv) { Glib::RefPtrGtk::Application app; app = Gtk::Application::create(argc, argv, socket.focustest); TheWindow win; return app-run(win); } window_ext.h: #ifndef WINDOW_EXT_H #define WINDOW_EXT_H #include gtkmm.h #include iostream class Overlay; class WindowExt : public Gtk::Window { private: Cairo::RefPtrCairo::Region shape; public: void grab_keyboard(Glib::RefPtrGdk::Window dest) { Glib::RefPtrGdk::Display display = get_display(); Glib::RefPtrGdk::DeviceManager deviceM = display
GtkSocket: focus to embedded child widget or plug widget
Hi, note: this message was already sent to gtk-list, but re-sending here as it might be more appropriate: I am trying to put the keyboard focus on a widget (or similar) inside a embedded window of a GtkSocket, but although I am using grab_focus on the GtkSocket and the plugin seems to be receiving the events (at least the socket-side window is not anymore) the widget or window does not have keyboard focus. E.g. in the case of a simple plug with a GtkEntry, the entry does not have cursor, or if I embed gvim the gvim cursor is not blinking/active. I have submitted a bug here: https://bugzilla.gnome.org/show_bug.cgi?id=729248 I am using Gtk+ git. It turns out it is possible to give focus to the first widget by 'Tab'-ing into the embedded child, but it does not seem to be a way to do this programtically. The specific XEMBED signals that are required to be sent [0] can, as far as I can see, only be sent through the GtkSocket by the tab-handler. grab_focus() sends a XEMBED_FOCUS_IN message but with an XEMBED_FOCUS_CURRENT detail, by replacing ..._CURRENT with _FIRST the embedded child acts as if Tab has been pressed and the first widget gets focus. As you can see from the bug report I created a patch for Gtk where I can send the focus_forward and backward ( _FIRST and _LAST ) signals. When I use it the focus changes as expected. A small example based on gtkmm's socket and plug examples can be found here: https://github.com/gauteh/plug-socket-grab-focus/tree/focus_forward After some discussion on #gtk+ we've also discovered that the testsocket program appears to give focus to the plugin entry field, but the entry does not get any key events before it is clicked. If there is no other way of programatically changing the focus of the embedded plugin I would greatly appreciate either something like the patch I include in the bug report or some other way to control the focus from the socket-side. By the way, thanks for the helpful discussions on #gtk+. Best regards, Gaute [0] http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html#idm139742756373280 ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Set Focus to GtkEntry when GtkNotebook Tab selected
I have the following object: GtkWindow GtkNotebook GtkBox GtkScrolledWindow, GtkTextArea GtkEntry I am trying to have the Entry get focus when I change Tabs When the program starts it does focus on Tab 1's entry but I can not get it to keep focus without clicking the entry area manually. I set gtk_widget_set_can_focus(GTK_WIDGET(entry), 1); notebook g_signal_connect(G_OBJECT(nb), switch-page, G_CALLBACK(ChatNB_switch_page_cb), NULL); G_MODULE_EXPORT void ChatNB_switch_page_cb(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data) { printf(switch-page %d\r\n, page_num);fflush(stdout); if (page_num = 0 page_num 5 entries[page_num] != NULL) { gtk_widget_grab_focus(GTK_WIDGET(entries[page_num])); } } I have looked around and seen that this question is often asked but answers are not clear... i run the program below and click Tab 1 and then Tab 2 tom Full single file example /* Name: Scrolled.c Author : Tom Moulton Version : Copyright : (c) 2013 Thoomas A. Moulton, Public Domain Description : Hello World in GTK+ */ #include gtk/gtk.h #include string.h GtkNotebook *nb; GtkEntry *entries[5]; void Enter_Chat(GtkEntry *entry, GtkTextBuffer *buf) { char line[512]; const gchar *cmd; GtkTextIter endit; cmd = gtk_entry_get_text(entry); strcpy(line, cmd); strcat(line, \r\n); gtk_entry_set_text(entry, ); gtk_text_buffer_get_end_iter(buf, endit); gtk_text_buffer_insert_with_tags(buf, endit, line, -1, NULL, NULL); } gboolean Enter_focus_in_event(GtkEntry *entry, gpointer *buf) { printf(Entry %x focus in event\r\n, (unsigned int)entry);fflush(stdout); //gtk_widget_grab_focus(GTK_WIDGET(entry)); return TRUE; } void Enter_grab_focus(GtkEntry *entry, gpointer *buf) { printf(Entry %x grabbed focus\r\n, (unsigned int)entry);fflush(stdout); } void Chat_scroll_to_end(GtkTextBuffer *buf, GtkTextView *text) { GtkTextMark *mark; mark = gtk_text_buffer_get_mark(buf, eob); gtk_text_view_scroll_mark_onscreen(text, mark); } void ChatNew(gchar *name) { GtkBox *chat; GtkTextBuffer *buf; GtkTextView *text; GtkEntry *entry; GtkScrolledWindow *scroll; GtkTextIter endit; GtkLabel *label; gint pg; text = (GtkTextView *)gtk_text_view_new(); gtk_text_view_set_editable(text, FALSE); gtk_text_view_set_wrap_mode(text, GTK_WRAP_WORD_CHAR); gtk_text_view_set_cursor_visible(text, FALSE); buf = gtk_text_buffer_new(NULL); gtk_text_view_set_buffer(text, buf); scroll = (GtkScrolledWindow *)gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(scroll, GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); gtk_container_add(GTK_CONTAINER(scroll), GTK_WIDGET(text)); entry = (GtkEntry *)gtk_entry_new(); gtk_widget_set_size_request(GTK_WIDGET(entry), -1, 30); gtk_entry_set_has_frame(entry, 0); gtk_widget_set_can_focus(GTK_WIDGET(entry), 1); chat = GTK_BOX(gtk_box_new(GTK_ORIENTATION_VERTICAL, 0)); gtk_box_pack_start(chat, GTK_WIDGET(scroll), TRUE, TRUE, 0); gtk_box_pack_end(chat, (GtkWidget *)entry, FALSE, TRUE, 0); g_signal_connect(G_OBJECT(entry), activate, G_CALLBACK(Enter_Chat), (gpointer)buf); g_signal_connect(G_OBJECT(entry), focus-in-event, G_CALLBACK(Enter_focus_in_event), NULL); g_signal_connect(G_OBJECT(entry), grab-focus, G_CALLBACK(Enter_grab_focus), NULL); gtk_text_buffer_get_end_iter(buf, endit); gtk_text_buffer_create_mark(buf, eob, endit, FALSE); g_signal_connect(G_OBJECT(buf), changed, G_CALLBACK(Chat_scroll_to_end), (gpointer)text); label = (GtkLabel *)gtk_label_new(name); pg = gtk_notebook_append_page(nb, GTK_WIDGET(chat), GTK_WIDGET(label)); if (pg != -1) entries[pg] = entry; } G_MODULE_EXPORT void ChatNB_switch_page_cb(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer user_data) { printf(switch-page %d\r\n, page_num);fflush(stdout); if (page_num = 0 page_num 5 entries[page_num] != NULL) { gtk_widget_grab_focus(GTK_WIDGET(entries[page_num])); } } int main (int argc, char *argv[]) { GtkWidget *window; entries[0] = NULL; entries[1] = NULL; entries[2] = NULL; entries[3] = NULL; entries[4] = NULL; gtk_init (argc, argv); /* create the main, top level, window */ window = gtk_window_new (GTK_WINDOW_TOPLEVEL); /* give it the title */ gtk_window_set_title (GTK_WINDOW (window), Hello World); gtk_window_set_default_size(GTK_WINDOW (window), 800, 600); /* Connect the destroy signal of the window to gtk_main_quit * When the window is about to be destroyed we get a notification and * stop the main GTK+ loop */ g_signal_connect (window, destroy, G_CALLBACK
Re: Focus vs Sensitivity
David: Y O U R O C K ! ! ! Amazing explanation! Now I understand what happens! And excellent workaround too!!! Thanks a lot for putting the effort to explain it, look for the GTK+ warning and providing a way to fix it! Just perfect! Now I have a lot of work to do to change a lot of spinbuttons ;-). Have a great 2013! P.s.: sorry for the late reply but been too busy, crazy times, everyone wants something before the year ends! -- Iván Baldo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus vs Sensitivity
On Fri, Dec 21, 2012 at 07:16:07PM -0200, Ivan Baldo wrote: What happens is that the Tab handler runs before the value-changed handler This is the wrong view what happens. The adjustment value is not updated during user's editing of the entry. If the spin button is not set to numeric its entry can contain any text during the editing (whereas setting numeric ensures the entry contents always parses as a number, making impossible to enter numbers in the scientific format, for instance). The value is updated when editing finishes, for which one possibility is that the entry loses focus. So *first* the focus leaves the entry then *in consequence* the adjustment value is updated. However, this does not seem to be entirely the core of your problem. The CRITICAL errors are printed becuase in gtk_window_real_set_focus() this: if (priv-has_focus) do_focus_change (priv-focus_widget, TRUE); g_object_notify (G_OBJECT (priv-focus_widget), is-focus); assumes that do_focus_change() cannot make priv-focus_widget become NULL. IMO there may be sane use cases when this can occur (like yours) so I would try to report a bug. How to work around it? Instead of connecting to value-changed monitor all changes to the entry text: g_signal_connect(spin_button, changed, G_CALLBACK(spin_entry_changed), spin_button2); ... static void spin_entry_changed(GtkEntry *entry, GtkWidget *target) { gtk_widget_set_sensitive(target, g_strtod(gtk_entry_get_text(entry), NULL) != 0); } This will *also* make the second entry insensitive when the content of the first does not parse as a number at all (which is likely a good thing though perhaps not). Regards, Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Focus vs Sensitivity
/* Given 3 spin buttons, I want the second one to be enabled or disabled based on input from the first one. If in the first one the user puts 0 as value I want that when it presses Tab the focus go to the third spin button. If in the first one the user puts a value different than zero I want that when it presses Tab the focus go to the seconds spin button. What happens is that the Tab handler runs before the value-changed handler so when the value-changed handler sets the sensitivity of the second spin button Gtk+ complains of errors internally or passes the focus to the third spin button instead of the second. I imagine I could solve it by setting the focus by hand in my value-changed handler but I am looking for an easier way because I have a large application with lots of these interactions and also I don't know if that solves the Gtk+ error. I would love that Gtk+ emitted the value-changed signal before it handled the Tab key... If you know another way to solve the problem then please email iba...@adinet.com.uy, thanks!!! Based on http://developer.gnome.org/gnome-devel-demos/unstable/spinbutton.c.html. Compile with: gcc focus_problem.c `pkg-config --cflags --libs gtk+-3.0` -o focus_problem */ #include gtk/gtk.h static void spin_value_changed (GtkSpinButton *spin_button, gpointer user_data) { fprintf (stderr, %s: before set_sensitive\n, __func__); GtkWidget * const spin_button2 = user_data; const gint value = gtk_spin_button_get_value_as_int (spin_button); gtk_widget_set_sensitive (spin_button2, value); fprintf (stderr, %s: after set_sensitive\n, __func__); } static void activate (GtkApplication *app, gpointer user_data) { GtkWidget * const window = gtk_application_window_new (app); gtk_window_set_title (GTK_WINDOW (window), Focus Problem); //gtk_window_set_default_size (GTK_WINDOW (window), 210, 70); gtk_container_set_border_width (GTK_CONTAINER (window), 5); GtkWidget * const label = gtk_label_new ( Enter 1 to enable middle spinbutton, 0 to disable it:); GtkAdjustment * const adjustment = gtk_adjustment_new (1, 0, 100, 1, 10, 0); GtkWidget * const spin_button = gtk_spin_button_new (adjustment, 0, 0); //gtk_widget_set_hexpand (spin_button, TRUE); GtkAdjustment * const adjustment2 = gtk_adjustment_new (0, 0, 100, 1, 10, 0); GtkWidget * const spin_button2 = gtk_spin_button_new (adjustment2, 0, 0); GtkAdjustment * const adjustment3 = gtk_adjustment_new (0, 0, 100, 1, 10, 0); GtkWidget * const spin_button3 = gtk_spin_button_new (adjustment3, 0, 0); g_signal_connect (spin_button, value-changed, G_CALLBACK (spin_value_changed), spin_button2); /* Create a grid and arrange everything accordingly */ GtkWidget * const grid = gtk_grid_new (); gtk_grid_set_column_spacing (GTK_GRID (grid), 5); //gtk_grid_set_column_homogeneous (GTK_GRID (grid), TRUE); gtk_grid_attach (GTK_GRID (grid), label, 0, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), spin_button, 1, 0, 1, 1); gtk_grid_attach (GTK_GRID (grid), spin_button2, 1, 1, 1, 1); gtk_grid_attach (GTK_GRID (grid), spin_button3, 1, 2, 1, 1); gtk_container_add (GTK_CONTAINER (window), grid); gtk_widget_show_all (window); } int main (int argc, char **argv) { GtkApplication *app; int status; app = gtk_application_new (org.gtk.example, G_APPLICATION_FLAGS_NONE); g_signal_connect (app, activate, G_CALLBACK (activate), NULL); status = g_application_run (G_APPLICATION (app), argc, argv); g_object_unref (app); return status; } -- Iván Baldo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Toplevel windows losing active and focus properties
jr...@devio.us (Josh Rickmar) wrote: Hi, I'm doing some development work on xombrero. We recently (last month or so) switched to GTK3 (3.4.4 on my OpenBSD/amd64 system), and have noticed some recurring focus issus. Unfortunately, we haven't found a good way to reproduce them, and that has made it incredibly hard to debug. For whatever reason, we've found that after a while our browser will enter a weird state where many things begin to break. Searching a webpage with the '/' key and pressing enter no longer focuses the WebKitWebView, and keyboard commands no longer work. Our link hinting works correctly in all cases except if we press enter (the hints on the page are never cleared, until a new page is loaded). And, the text cursor in our URL and search bars becomes completely invisible. After some more looking around it seems that our main toplevel GtkWindow no longer has the is-active and has-toplevel-focus properties set to true. We think this is the cause of the invisible cursor (just as how the cursor becomes invisible if you use your window manager to focus a different window), and believe the other bugs are a result of it as well (perhaps not all signal callbacks are being run?). I'm not sure if this is a bug in GTK3, or our fault due to a bad switch to GTK3. Has anyone seen this sort of eratic behavior when switching applications to GTK3? If not, can anyone point me in the right direction about what possible things may be causing this toplevel window from losing those active and focus properies? This bug is driving us nuts and we'd love to get it solved before our next major release. Any help would be greatly appreciated. -- Josh Rickmar http://jrick.devio.us/ So this may cause even more fallout for being so hackish, but I think I found a workaround. I went through the GTK source code and found the _gtk_window_set_is_active function. I manually added a prototype for this function to our code (because it is not declared static) and was able to use it to confirm that it was the is-active property being set to false that was causing all of our issues. As a workaround, I'm now calling this function, setting this property to true, before any GtkEntry is foucsed (to get rid of the invisible cursor), and before any keypress is handled. Can anyone see any potential issues with this workaround, and have a better idea about how to remove this issue in the first place? -- Josh Rickmar http://jrick.devio.us/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Toplevel windows losing active and focus properties
Hi, I'm doing some development work on xombrero. We recently (last month or so) switched to GTK3 (3.4.4 on my OpenBSD/amd64 system), and have noticed some recurring focus issus. Unfortunately, we haven't found a good way to reproduce them, and that has made it incredibly hard to debug. For whatever reason, we've found that after a while our browser will enter a weird state where many things begin to break. Searching a webpage with the '/' key and pressing enter no longer focuses the WebKitWebView, and keyboard commands no longer work. Our link hinting works correctly in all cases except if we press enter (the hints on the page are never cleared, until a new page is loaded). And, the text cursor in our URL and search bars becomes completely invisible. After some more looking around it seems that our main toplevel GtkWindow no longer has the is-active and has-toplevel-focus properties set to true. We think this is the cause of the invisible cursor (just as how the cursor becomes invisible if you use your window manager to focus a different window), and believe the other bugs are a result of it as well (perhaps not all signal callbacks are being run?). I'm not sure if this is a bug in GTK3, or our fault due to a bad switch to GTK3. Has anyone seen this sort of eratic behavior when switching applications to GTK3? If not, can anyone point me in the right direction about what possible things may be causing this toplevel window from losing those active and focus properies? This bug is driving us nuts and we'd love to get it solved before our next major release. Any help would be greatly appreciated. -- Josh Rickmar http://jrick.devio.us/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: [GTK3] GtkEntry, why focus-in-event does not work ?
On 02/23/2012 02:49 PM, Gilles DOFFE wrote: Hello, Below a simple application with a GtkButton and a GtkEntry. Two callbacks associated to this widgets following this rules : 1) When I click on the GtkButton, it should display the GtkEntry pointer value. 2) When I focus on the GtkEntry, it should display the GtkButton pointer value. Case 1) works perfectly but case 2) always give a different value for the GtkButton pointer ?! Did i miss something ? That the signature for focus-in-event isn't the same[1], and that second parameter you use in your printf is a pointer to the GdkEvent, not your user_data (Also, this callback should return a gboolean value). -j [1] http://developer.gnome.org/gtk/stable/GtkWidget.html#GtkWidget-focus-in-event Thanks, Gilles #include gtk/gtk.h void onEntryFocusIn(GtkWidget *entry, gpointer pData) { printf(pData = %p\n, (GtkWidget *)pData); } int main(int argc, char **argv) { GtkWidget *pWindow = NULL; GtkWidget *pButton = NULL; GtkWidget *pEntry = NULL; GtkWidget *pHbx = NULL; gtk_init(NULL, NULL); pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); pButton = gtk_button_new(); pEntry = gtk_entry_new(); pHbx = gtk_hbox_new(FALSE, FALSE); gtk_box_pack_start(GTK_BOX(pHbx), GTK_WIDGET(pButton), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(pHbx), GTK_WIDGET(pEntry), FALSE, FALSE, 0); gtk_container_add(pWindow, pHbx); g_signal_connect(G_OBJECT(pWindow), destroy, (GCallback) gtk_main_quit, NULL); /* THIS WORKS : */ g_signal_connect(G_OBJECT(pButton), clicked, (GCallback) onEntryFocusIn, (gpointer)pEntry); /* THIS DOES NOT WORK : */ g_signal_connect(G_OBJECT(pEntry), focus-in-event, (GCallback) onEntryFocusIn, (gpointer)pButton); gtk_widget_show_all(pWindow); printf(pEntry = %p\n, pEntry); printf(pButton = %p\n, pButton); gtk_main(); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: [GTK3] GtkEntry, why focus-in-event does not work ?
Thanks Jacky ! It was big enough in gtk3 documentation but I missed it anyway... ^^' http://developer.gnome.org/gtk3/3.2/GtkWidget.html#GtkWidget-focus-in-event Solved. 2012/2/23 jjacky i.am.jack.m...@gmail.com On 02/23/2012 02:49 PM, Gilles DOFFE wrote: Hello, Below a simple application with a GtkButton and a GtkEntry. Two callbacks associated to this widgets following this rules : 1) When I click on the GtkButton, it should display the GtkEntry pointer value. 2) When I focus on the GtkEntry, it should display the GtkButton pointer value. Case 1) works perfectly but case 2) always give a different value for the GtkButton pointer ?! Did i miss something ? That the signature for focus-in-event isn't the same[1], and that second parameter you use in your printf is a pointer to the GdkEvent, not your user_data (Also, this callback should return a gboolean value). -j [1] http://developer.gnome.org/gtk/stable/GtkWidget.html#GtkWidget-focus-in-event Thanks, Gilles #include gtk/gtk.h void onEntryFocusIn(GtkWidget *entry, gpointer pData) { printf(pData = %p\n, (GtkWidget *)pData); } int main(int argc, char **argv) { GtkWidget *pWindow = NULL; GtkWidget *pButton = NULL; GtkWidget *pEntry = NULL; GtkWidget *pHbx = NULL; gtk_init(NULL, NULL); pWindow = gtk_window_new(GTK_WINDOW_TOPLEVEL); pButton = gtk_button_new(); pEntry = gtk_entry_new(); pHbx = gtk_hbox_new(FALSE, FALSE); gtk_box_pack_start(GTK_BOX(pHbx), GTK_WIDGET(pButton), FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(pHbx), GTK_WIDGET(pEntry), FALSE, FALSE, 0); gtk_container_add(pWindow, pHbx); g_signal_connect(G_OBJECT(pWindow), destroy, (GCallback) gtk_main_quit, NULL); /* THIS WORKS : */ g_signal_connect(G_OBJECT(pButton), clicked, (GCallback) onEntryFocusIn, (gpointer)pEntry); /* THIS DOES NOT WORK : */ g_signal_connect(G_OBJECT(pEntry), focus-in-event, (GCallback) onEntryFocusIn, (gpointer)pButton); gtk_widget_show_all(pWindow); printf(pEntry = %p\n, pEntry); printf(pButton = %p\n, pButton); gtk_main(); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: focus line pattern around gtk event box
On Tue, Dec 20, 2011 at 11:24:44AM +0530, Guruprasad Bhat wrote: When I set the focus line pattern in rc file, dotted border comes around button widgtes, entry widgets when focus comes on that. But for event box, layout, even though i set Can focus flag TRUE focus in indication is not appearing. How I can get the visual indication of focus in for gtk event box, gtk layout. Early suggestion appreciated. Using gtk_paint_focus() in the draw handler to draw it if the widget has focus. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: focus line pattern around gtk event box
On Tue, 2011-12-20 at 09:25 +0100, David Nečas wrote: Using gtk_paint_focus() in the draw handler... Deprecated now, apparently; refers to http://developer.gnome.org/gtk3/3.3/GtkStyleContext.html#gtk-render-focus instead. AfC Sydney ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: focus line pattern around gtk event box
On Tue, Dec 20, 2011 at 10:43:43PM +1100, Andrew Cowie wrote: On Tue, 2011-12-20 at 09:25 +0100, David Nečas wrote: Using gtk_paint_focus() in the draw handler... Deprecated now, apparently; refers to http://developer.gnome.org/gtk3/3.3/GtkStyleContext.html#gtk-render-focus instead. No, I just mixed up Gtk+ 2 and 3 functions (sorry for that). gtk_paint_focus() is the correct method to draw focus in Gtk+ 2, but you do this in expose-event handler. Use gtk_render_focus() in draw handler if you use Gtk+ 3. Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
focus line pattern around gtk event box
Hi ppl, When I set the focus line pattern in rc file, dotted border comes around button widgtes, entry widgets when focus comes on that. But for event box, layout, even though i set Can focus flag TRUE focus in indication is not appearing. How I can get the visual indication of focus in for gtk event box, gtk layout. Early suggestion appreciated. Regards, ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Focus behaviour on widget derived from a gtkentry
Hi, I've been banging my head against the wall for some time now on this problem: I have a widget that is derived from a GtkEntry. The derived widget basically does some additional validation checks during text entry, nothing more really. If you like to see the complete code, you can browse it here: http://svn.gnucash.org/trac/browser/gnucash/trunk/src/gnome-utils/gnc-amount- edit.c I am now having problems to set the focus on this widget programmatically. In this particular use case, the widget is added to a GtkAssistant, and during the prepare of the page showing this widget, I call a gtk_widget_grab_focus on it. This does nothing. If I do the same with a plain GtkEntry on the same assistant page in the same prepare callback, this entry does get the focus. So I assume my custom widget is not handling things properly. Based on another thread I found on the gtk-list list [1] I then tried adding a callback to the focus-in-event signal in gnc_amount_edit_init like so: g_signal_connect (G_OBJECT (gae), focus-in-event, G_CALLBACK (gnc_amount_edit_focus_in), NULL); And the callback function simply call gtk_widget_grab_focus on the internal GtkEntry widget: static gboolean gnc_amount_edit_focus_in (GNCAmountEdit *gae, GdkEvent *event, gpointer data) { gtk_widget_grab_focus (GTK_WIDGET(gae-entry)); return FALSE; } Stepping through the code in a debugger shows me that the callback is really called, but it still doesn't set the focus. I am sure I'm missing something, but I don't see it. Any hints ? Geert [1] http://www.mail-archive.com/gtk-list@gnome.org/msg02478.html ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus behaviour on widget derived from a gtkentry
On 7 December 2011 09:16, Geert Janssens i...@kobaltwit.be wrote: I am now having problems to set the focus on this widget programmatically. In this particular use case, the widget is added to a GtkAssistant, and during the prepare of the page showing this widget, I call a gtk_widget_grab_focus on it. This does nothing. I remember struggling to get focus working in my widgets too. In my case the problem turned out to be forgetting to set the CAN_FOCUS flag in _init(). Have you tried this? http://developer.gnome.org/gtk/2.24/GtkWidget.html#gtk-widget-set-can-focus Needs to be called at some point for every widget object that can take focus. Though perhaps the parent class should do this for you? Maybe worth a try anyway. John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Committing preedit string on focus out
I have a query regarding preedit strings in editables like gtkentry, gtktextview. When there is a preedit string in one gtkentry and focus is shifted to another gtkentry, the preedit string in the first is lost. Is this expected behaviour? Shouldn't the preedit string be committed on focus out? Also, if commit does not happen on focus-out, shouldn't the preedit string be activated again on regaining focus? Please help. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
how to hint gtk about a useful start of the focus chain
hi, having the focus on the right widget can make apps more productive. I feed that right now either I am missing something or gtk does not a good job at it. For odd reasons gtk prefers to focus toolbar button on new windows (which is strange and not useful imho). When trying to hint gtk+ about what a useful focus behavior I came across gtk_button_get_focus_on_click(). The documentations says Making mouse clicks not grab focus is useful in places like toolbars where you don't want the keyboard focus removed from the main area of the application.. Although this function cannot be used with toolbar buttons as those are toolitems. Then I discovered that gtktoolitem.c seems to actually call this internaly. http://git.gnome.org/browse/gtk+/tree/gtk/gtktoolbutton.c?h=gtk-2-24#n308 Should the docs be changed to mention that for toolbars its helpful for toolitem implementations? Should gtk take that flag into account when determining the widget that gets focus in a new window. Right now it stubbornly focuses on the toolitem. No matter how hard I try (e.g. gtk_widget_grab_focus(other_widget) in window::show signal handler). Any tips? What are you guy using to set a proper focus on new windows/dialogs. Stefan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Question on keyboard focus
Hi, If I connect to the key-pressed-event of the main window GtkWidget of my application, the callback gets called when I type in a GtkEntry or a GtkSpinButton. I would like my callback to be called or have some means to mask out calls depending on whether the application window itself is in focus and some keys are pressed (F5 or PageUp for example) or the user is entering information in a field (pressing PageUp then should increment something but not call the default application reaction). Does anyone have any ideas? solarsd ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
grabbing focus to destination widget after drag-and-drop
Hi list, I'm having troubles in implementing rather simple but convenient behaviour: my widget, which is accepting drag-and-drops from other applications, should receive keyboard focus right after the drops. I'm trying to achieve this using gtk_widget_grab_focus() inside 'drag-data-received' signal handler (as it turns out that this signal is the last in d-n-d procedure which destination widget can receive; connecting to 'drag-end' signal won't work). But the focus doesn't get grabbed, and gtk_widget_has_focus() returns FALSE. How can i beat this? - Regards, max ulidtko ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus of about dialog
On 26 May 2010, at 20:52, Tadej Borovšak wrote: Hello. I've added an about dialog to my gtk application, using GtkAboutDialog. However, when the dialog is displayed, the user can still switch to the main window, which is undesirable. The dialog should steal focus of the whole application. How can I do that ? I have looked at gtk_widget_set_parent_window () but couldn't get it to work. Have a look at gtk_window_set_modal() and gtk_window_set_transient_for() functions. You might also consider why you consider the behaviour to be 'undesirable', though. Modal dialogs sometimes cause users more problems than modeless ones, especially if, from prior experience (e.g. the About dialog in other gtk+ apps), they're expecting a familiar-looking dialog to behave a particular way. Cheeri, Calum. -- CALUM BENSON, Interaction Designer Oracle Corporation, Ireland mailto:calum.ben...@oracle.com Solaris Desktop Team http://blogs.sun.com/calum +353 1 819 9771 Any opinions are personal and not necessarily those of Oracle Corp. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus of about dialog
On 31 May 2010, at 17:16, Calum Benson wrote: You might also consider why you consider the behaviour to be 'undesirable', though. Modal dialogs sometimes cause users more problems than modeless ones, especially if, from prior experience (e.g. the About dialog in other gtk+ apps), they're expecting a familiar-looking dialog to behave a particular way. And therein lies the problem The OP didn't specify which platform he's targeting - but regardless of what other gtk+ apps might do, the general trend is that different OS's tend to exhibit different behaviours for About dialogs. For example I just opened half a dozen Windows apps and all their About dialogs were modal. Then I tried half a dozen OS-X apps and all their About dialogs were modeless. Admittedly though, none of them were gtk+ apps. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Focus of about dialog
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 I've added an about dialog to my gtk application, using GtkAboutDialog. However, when the dialog is displayed, the user can still switch to the main window, which is undesirable. The dialog should steal focus of the whole application. How can I do that ? I have looked at gtk_widget_set_parent_window () but couldn't get it to work. - -- Vikraman -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.15 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iQEcBAEBAgAGBQJL/WPwAAoJEBEjnI2DXTclB6gH/0qpyu00txqzt4MC9u0EK3ao lWGRlF/KjJUmvQQuRIZx0q1ulL6qsNR45xLpIeLYWDMzo85fi8njq1G3K4M7Xxpv J4+Pl6AUbRufUmD5pSyHYPvJDRFKRnJUWhBD/Un4oA8VGzAAevd1oK3CL82FROYr itRIE8PPVL/hEQxSTTfEeeE70g55LVWyp4ImXGkZlMzUiqr/poDPSWpT2UKKlLyu THgfemq8BSGf52/8Vh4XANYW/LqZI+PksyZoYcp8dQv+l6QHmrQ/J8H4k3scO667 9p4axQDEY4ajZ0KtATHRKUWF8PM/ekp4AJLCx86V1vBsuPqU77ZBYyXTk8YEG8o= =cCNo -END PGP SIGNATURE- ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus of about dialog
Hello. I've added an about dialog to my gtk application, using GtkAboutDialog. However, when the dialog is displayed, the user can still switch to the main window, which is undesirable. The dialog should steal focus of the whole application. How can I do that ? I have looked at gtk_widget_set_parent_window () but couldn't get it to work. Have a look at gtk_window_set_modal() and gtk_window_set_transient_for() functions. Tadej -- Tadej Borovšak tadeboro.blogspot.com tadeb...@gmail.com tadej.borov...@gmail.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Enabling return for dialog with focus on gtk_entry
Hi list, I'm not sure whether you can help me here out. I'm looking for a way to directly send GTK_RESPONSE_ACCEPT by hitting return, even on dialogs where a GTK Entry or a ComboBox is having the focus. Do you might have an idea how to do this or some code snippet I can have a look at? Thanks, Frank -- Frank Lanitz fr...@frank.uvena.de ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Display 1 buttons stuck after click until non-button used or other display gets focus
Hello! I've a mid-sized, debian/squeeze (2.18 gtk family) , amd64, multithreaded, gstreamer (webcam in a small window), gdk , two display gtkbuilder 2.0 application that worked well under debian/lenny (stable). Moving to 'squeeze' / testing a very weird effect happens. Display 1 is fullscreen, 0 is in a window. Display 1 has a webcam image and a table of four rows, four columns that holds a number of on/off buttons and simple click buttons. After the change from lenny, any of these buttons will accept one click, send the event signal to the right handler relative to the click, the appropriate of the various handlerer returns after doing the right thing -- but then gtk simply will not accept further clicks (but allows normal mouse movement and will show the focus change on a click attempt) until either: a combo box on display 1 is changed, or the mouse is moved even for a moment off display 1 onto 0, then back on to 1 (without clicking anything on display 0). After either of those things, the toggle buttons will allow one more click, and the cycle repeats. \ In all ways the application is normal after hours of use -- except having to slide the mouse off display 1, on to 0, and back onto 1 before any further button (single or toggle) within the table on display 1 (of 2) will accept a further click. The application responds normally in all other respects. How odd is that? Any ideas? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Display 1 buttons stuck after click until non-button used or other display gets focus
Harry Coin wrote: Hello! I've a mid-sized, debian/squeeze (2.18 gtk family) , amd64, multithreaded, gstreamer (webcam in a small window), gdk , two display gtkbuilder 2.0 application that worked well under debian/lenny (stable). Moving to 'squeeze' / testing a very weird effect happens. Display 1 is fullscreen, 0 is in a window. Display 1 has a webcam image and a table of four rows, four columns that holds a number of on/off buttons and simple click buttons. After the change from lenny, any of these buttons will accept one click, send the event signal to the right handler relative to the click, the appropriate of the various handlerer returns after doing the right thing -- but then gtk simply will not accept further clicks (but allows normal mouse movement and will show the focus change on a click attempt) until either: a combo box on display 1 is changed, or the mouse is moved even for a moment off display 1 onto 0, then back on to 1 (without clicking anything on display 0). After either of those things, the toggle buttons will allow one more click, and the cycle repeats. \ In all ways the application is normal after hours of use -- except having to slide the mouse off display 1, on to 0, and back onto 1 before any further button (single or toggle) within the table on display 1 (of 2) will accept a further click. The application responds normally in all other respects. How odd is that? Any ideas? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list Update: v2.18 When I compile the application that has two top level windows to not move one of them to the other monitor, but instead leave them both on the same monitor it all works normally-- whether launched on monitor 0 or monitor 1.Only when one of the two top level windows is moved to another head/monitor will the button permit only one click then all buttons are locked until the mouse moves off that screen momentarily, or until a combo dropdown box on the 'button locked' screen has content changed. I'm thinking this is related to bug 597386 attempted to be fixed by Alex Larsson on 5 oct 09? ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Need help to set a cursor/focus on treeview row!
On 10/30/2009 05:48 PM, Daniel B. Thurman wrote: I am learning, so please bear with me! I have the following code: def expandHome(self, model, iter=None, defaultHome=None): ''' expand user's home directory ''' if not defaultHome: return ran = model.iter_n_children(iter) for i in range(ran): iter_n_child = model.iter_nth_child(iter, i) path = model.get_path(iter_n_child) pn = model[path][1] idx = defaultHome.find(pn) if idx -1: Dbg.dPrint( + File=%s % pn) StoreTools.append_path(model, iter=iter_n_child) Display.tv.expand_row(path, False) self.expandHome(model, iter_n_child, defaultHome) # Set cursor selection to the homepath here Display.tv.set_cursor(path, focus_column=None, start_editing=False) The treestore is saved into a treeview, and the treeview is saved into a scrolledwindow. The above code expands the treeview on the user's home directory and it works, and the last step is to set the cursor or focus on the user's home directory of which I am not able to do. The code: Display.tv.set_cursor(path, focus_column=None, start_editing=False) is a feeble attempt to do that and it is not working for me. Please advise? I wanted to add a bit of clarification. The goal is that once the user's home directory is expanded, I wanted to bring the expanded tree of /home/some-user into view in the scrolled window, centered, so I may have the wrong method entirely. Thanks! Dan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Need help to set a cursor/focus on treeview row!
On Sat, Oct 31, 2009 at 10:06:12AM -0700, Daniel B. Thurman wrote: I wanted to add a bit of clarification. The goal is that once the user's home directory is expanded, I wanted to bring the expanded tree of /home/some-user into view in the scrolled window, centered, so I may have the wrong method entirely. You are probably looking for this: http://library.gnome.org/devel/gtk/stable/GtkTreeView.html#gtk-tree-view-scroll-to-cell Yeti ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Need help to set a cursor/focus on treeview row!
I am learning, so please bear with me! I have the following code: def expandHome(self, model, iter=None, defaultHome=None): ''' expand user's home directory ''' if not defaultHome: return ran = model.iter_n_children(iter) for i in range(ran): iter_n_child = model.iter_nth_child(iter, i) path = model.get_path(iter_n_child) pn = model[path][1] idx = defaultHome.find(pn) if idx -1: Dbg.dPrint( + File=%s % pn) StoreTools.append_path(model, iter=iter_n_child) Display.tv.expand_row(path, False) self.expandHome(model, iter_n_child, defaultHome) # Set cursor selection to the homepath here Display.tv.set_cursor(path, focus_column=None, start_editing=False) The treestore is saved into a treeview, and the treeview is saved into a scrolledwindow. The above code expands the treeview on the user's home directory and it works, and the last step is to set the cursor or focus on the user's home directory of which I am not able to do. The code: Display.tv.set_cursor(path, focus_column=None, start_editing=False) is a feeble attempt to do that and it is not working for me. Please advise? Thanks! Dan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
GTK Combo Box focus handling
Hello. I need to receive the focus-in-event of a GTK Combo Box but didn't found the way to do that yet after trying various things. I have other widgets (entries, spin buttons, check boxes, radio buttons) and I have no problems with those, only with the combo box. Something similar with a small C example is here: http://www.nabble.com/ComboBox-Events-bug--td2816980.html#a2824165 . Thanks for your help. -- Ivan Baldo - iba...@adinet.com.uy - http://ibaldo.codigolibre.net/ From Montevideo, Uruguay, at the south of South America. Freelance programmer and GNU/Linux system administrator, hire me! Alternatives: iba...@codigolibre.net - http://go.to/ibaldo ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
change the focus ring's color
Hi all I have some problems, and I hope you tell me, thank you. As followed: The button obtains the focus, and there is focus ring, now I want to change the focus ring's color, but I don't do it. Thank you zh ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: change the focus ring's color
On Fri, 2009-01-16 at 17:54 +0800, zhenghe zhang wrote: Hi all I have some problems, and I hope you tell me, thank you. As followed: The button obtains the focus, and there is focus ring, now I want to change the focus ring's color, but I don't do it. Please remember that colours are generally under the control of the user, who may have chosen a particular theme for accessibility reasons (e.g. needing low contrast). What is your motivation here? Liam -- Liam Quin - XML Activity Lead, W3C, http://www.w3.org/People/Quin/ Pictures from old books: http://fromoldbooks.org/ Ankh: irc.sorcery.net irc.gnome.org www.advogato.org ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
how to focus only mouse pointed button in a gtktree row.
Hi, I am able to render buttons on the gtktree cells and able to get the focus on all the buttons when ever mouse pointer moves to particular row, but the problem is if *I want to focus mouse pointed button only in a gtktree row but* it is focusing all the buttons in a row. How to overcome this problem ? Is there any way to do this? please share your thoughts. plz find the code in attachment. Regards Prashanth Kumar ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: [gedit-list] Focus problem
Please have a look at the gedit-view search thingie, it also is a GTK_WINDOW_POPUP type window, but can receive focus by handling some focus stuff manually iirc. Jesse Op maandag 01-12-2008 om 00:47 uur [tijdzone +0100], schreef Perriman: Hi all, I want to create a GTK_WINDOW_POPUP and change the type to GTK_WINDOW_TOPLEVEL. If you have used eclipse, when you are writting you can see a calltip (but the focus is in the editor) and if you press F2, then the calltip window gets the focus and show the decoration. I'm trying for two weeks and I cannot do the same in the example program. If I set GTK_WINDOW_POPUP then I cannot set the focus to the window and, If I use GTK_WINDOW_TOPLEVEL then the window lost the focus. If I show the popup window and set the focus to the main window, it does not work... I'm desperated Can you help me? Thank you again!! El Sun, 30 Nov 2008 23:37:29 +0100 Perriman [EMAIL PROTECTED] escribió: Hi Michael I paste the code: #include gtk/gtk.h #include gdk/gdkkeysyms.h static GtkWidget *window; static GtkWidget *view; static GtkWidget *popup; static GtkWidget *popup_view; static gboolean set_focus = FALSE; static void destroy_cb(GtkObject *object,gpointer user_data) { gtk_main_quit (); } static gboolean focus_window(gpointer win) { g_debug(focus win); gtk_window_present_with_time(GTK_WINDOW(win),GDK_CURRENT_TIME); gtk_window_activate_focus(GTK_WINDOW(win)); gtk_widget_grab_focus(GTK_WIDGET(win)); return FALSE; } static void show_cb(GtkWidget *widget, gpointer user_data) { g_debug(show popup); focus_window(window); } static void realize_cb(GtkWidget *widget, gpointer user_data) { g_debug(realize popup); focus_window(window); } static void focus_in_cb(GtkWidget *widget, gpointer user_data) { g_debug(focus-in); //focus_window(window); } static void focus_out_win_cb(GtkWidget *widget, gpointer user_data) { g_debug(focus-out-win); /* if (!set_focus) focus_window(window); else set_focus = FALSE; */ } static void map_cb(GtkWidget *widget, gpointer user_data) { g_debug(map popup); focus_window(window); } static gboolean key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { if (event-keyval == GDK_F5) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { gtk_widget_hide(popup); } else { gtk_widget_show_all(popup); focus_window(window); //g_timeout_add(2000,focus_window,window); } } else if (event-keyval == GDK_F6) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { g_debug(focus al popup); set_focus = TRUE; focus_window(popup); gtk_widget_grab_focus(popup_view); } } return FALSE; } GtkWidget* create_popup (void) { popup = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_transient_for(GTK_WINDOW(popup),GTK_WINDOW(window)); gtk_window_set_focus_on_map(GTK_WINDOW(popup), FALSE); gtk_window_set_type_hint(GTK_WINDOW(popup), GDK_WINDOW_TYPE_HINT_TOOLTIP); gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); gtk_container_set_border_width(GTK_CONTAINER(popup),2); gtk_window_resize(GTK_WINDOW(popup),200,200); popup_view = gtk_text_view_new(); GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(scroll),popup_view); gtk_container_add(GTK_CONTAINER(popup),scroll); /*g_signal_connect(popup, show, G_CALLBACK(show_cb), NULL); g_signal_connect(popup, realize, G_CALLBACK(realize_cb), NULL); g_signal_connect(popup, map, G_CALLBACK(map_cb), NULL); g_signal_connect(popup, focus-in-event, G_CALLBACK(focus_in_cb), NULL); */ return popup; } GtkWidget* create_window (void) { window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_resize(GTK_WINDOW(window),800,600); view = gtk_text_view_new(); gtk_window_set_default(GTK_WINDOW(window),view); GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(scroll),view); gtk_container_add(GTK_CONTAINER(window),scroll); g_signal_connect(view, key-release-event, G_CALLBACK(key_press), NULL); g_signal_connect(window, destroy, G_CALLBACK(destroy_cb), NULL); g_signal_connect(window, focus-out-event, G_CALLBACK(focus_out_win_cb), NULL); return window; } int main (int argc, char *argv[]) { GtkWidget *window
Re: Focus problem
Hi Larry, Thank a lo for you patch but it don't work for me :( I think the problem is Metacity... Andrea get works without metacity and it works on my xfce but not in my gnome with metacty (ubuntu 8.10)... The code below works fine in metacity using your changes and set_modal (thank Jesse and gedit) but I cannot show the decoration because the popup is a GTK_WINDOW_POPUP :) I'll try some changes to do it work on all environments Regards, Perriman #include gtk/gtk.h #include gdk/gdkkeysyms.h static GtkWidget *window; static GtkWidget *view; static GtkWidget *popup; static GtkWidget *popup_view; static gboolean set_focus = FALSE; static void destroy_cb (GtkObject * object, gpointer user_data) { gtk_main_quit (); } static gboolean focus_window (gpointer win) { g_debug (focus win); gtk_window_present_with_time (GTK_WINDOW (win), GDK_CURRENT_TIME); gtk_window_activate_focus (GTK_WINDOW (win)); gtk_widget_grab_focus (GTK_WIDGET (win)); return FALSE; } static void show_cb (GtkWidget * widget, gpointer user_data) { g_debug (show popup); focus_window (window); } static void realize_cb (GtkWidget * widget, gpointer user_data) { g_debug (realize popup); focus_window (window); } static void focus_in_cb (GtkWidget * widget, gpointer user_data) { g_debug (focus-in); } static void focus_out_win_cb (GtkWidget * widget, gpointer user_data) { g_debug (focus-out-win); } static void map_cb (GtkWidget * widget, gpointer user_data) { g_debug (map popup); focus_window (window); } static gboolean key_press (GtkWidget * widget, GdkEventKey * event, gpointer user_data) { if (event-keyval == GDK_F5) { if (GTK_WIDGET_VISIBLE (GTK_WIDGET (popup))) { gtk_widget_hide (popup); } else { gtk_widget_show_all (popup); focus_window (window); g_debug (unfocus al popup); set_focus = FALSE; gtk_widget_grab_focus (view); gtk_window_set_decorated (GTK_WINDOW (popup), FALSE); } } else if (event-keyval == GDK_F6) { if (GTK_WIDGET_VISIBLE (GTK_WIDGET (popup))) { if (set_focus == FALSE) { g_debug (focus al popup); set_focus = TRUE; gtk_window_set_modal(GTK_WINDOW (popup), TRUE); focus_window (popup); gtk_widget_grab_focus (popup_view); gtk_window_set_decorated (GTK_WINDOW (popup), TRUE); } else { g_debug (unfocus al popup); set_focus = FALSE; gtk_window_set_modal(GTK_WINDOW (popup), FALSE); focus_window (window); gtk_widget_grab_focus (view); gtk_window_set_decorated (GTK_WINDOW (popup), FALSE); } } } return FALSE; } GtkWidget * create_popup (void) { popup = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_transient_for (GTK_WINDOW (popup), GTK_WINDOW (window)); gtk_window_set_focus_on_map (GTK_WINDOW (popup), FALSE); gtk_window_set_type_hint (GTK_WINDOW (popup), GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_decorated (GTK_WINDOW (popup), FALSE); gtk_container_set_border_width (GTK_CONTAINER (popup), 2); gtk_window_resize (GTK_WINDOW (popup), 200, 200); popup_view = gtk_text_view_new (); GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scroll), popup_view); gtk_container_add (GTK_CONTAINER (popup), scroll); g_signal_connect (popup, key-release-event, G_CALLBACK (key_press), NULL); return popup; } GtkWidget * create_window (void) { window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_resize (GTK_WINDOW (window), 800, 600); view = gtk_text_view_new (); gtk_window_set_default (GTK_WINDOW (window), view); GtkWidget *scroll = gtk_scrolled_window_new (NULL, NULL); gtk_container_add (GTK_CONTAINER (scroll), view); gtk_container_add (GTK_CONTAINER (window), scroll); g_signal_connect (view, key-release-event, G_CALLBACK (key_press), NULL); g_signal_connect (window, destroy, G_CALLBACK (destroy_cb), NULL); g_signal_connect (window, focus-out-event, G_CALLBACK (focus_out_win_cb), NULL); return window; } int main (int argc, char *argv[]) { GtkWidget *window; gtk_set_locale (); gtk_init (argc, argv); window = create_window (); popup = create_popup (); gtk_widget_show_all (window); gtk_main (); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus problem
Hmmm... I'm running ubuntu 8.10 also, but with compiz. I just switched to metacity and I see what you're talking about. The code below works for me in both metacity and compiz if I make pop a toplevel window: - popup = gtk_window_new (GTK_WINDOW_POPUP); + popup = gtk_window_new (GTK_WINDOW_TOPLEVEL); Hope this helps, Larry On Sun, 2008-11-30 at 21:02 -0500, Larry Reaves wrote: Hi, I think this patch should do what you want: --- test.orig.c 2008-11-30 20:40:21.0 -0500 +++ test.c2008-11-30 20:49:57.0 -0500 @@ -78,7 +78,11 @@ { gtk_widget_show_all(popup); focus_window(window); - + g_debug(unfocus al popup); + set_focus = FALSE; + focus_window(window); + gtk_widget_grab_focus(view); + gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); //g_timeout_add(2000,focus_window,window); } } @@ -86,10 +90,22 @@ { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { - g_debug(focus al popup); - set_focus = TRUE; - focus_window(popup); - gtk_widget_grab_focus(popup_view); + if (set_focus == FALSE) + { + g_debug(focus al popup); + set_focus = TRUE; + focus_window(popup); + gtk_widget_grab_focus(popup_view); + gtk_window_set_decorated(GTK_WINDOW(popup),TRUE); + } + else + { + g_debug(unfocus al popup); + set_focus = FALSE; + focus_window(window); + gtk_widget_grab_focus(view); + gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); + } } } @@ -103,7 +119,7 @@ gtk_window_set_transient_for(GTK_WINDOW(popup),GTK_WINDOW(window)); gtk_window_set_focus_on_map(GTK_WINDOW(popup), FALSE); gtk_window_set_type_hint(GTK_WINDOW(popup), -GDK_WINDOW_TYPE_HINT_TOOLTIP); +GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); gtk_container_set_border_width(GTK_CONTAINER(popup),2); gtk_window_resize(GTK_WINDOW(popup),200,200); @@ -112,6 +128,8 @@ gtk_container_add(GTK_CONTAINER(scroll),popup_view); gtk_container_add(GTK_CONTAINER(popup),scroll); + g_signal_connect(popup, key-release-event, +G_CALLBACK(key_press), NULL); /*g_signal_connect(popup, show, G_CALLBACK(show_cb), NULL); g_signal_connect(popup, realize, G_CALLBACK(realize_cb), NULL); g_signal_connect(popup, map, G_CALLBACK(map_cb), NULL); Summary of changes: 1. set type hint to be 'normal' instead of 'tooltip' 2. connect up key-release-event to popup also, so when it has focus we can get out of it 3. on f6, only grab focus if we don't have it and add decorations 4. if we do have it, return focus to main window and remove decorations 5. if we hide popup while it has focus, remove decorations and focus So, you open the app and the main window has focus. Pressing F5 will show the popup, but focus will remain with the main window. Pressing F5 again will hide it. If F6 is pressed while the popup is open, it will grab focus and become decorated. While it has focus, it can remove decorations and pass focus back via F6. F5 also returns focus and removes decorations, but also hides the window. If this is not the desired behavior, let me know and I'll see if I can help. P.S. I'm not sure what you're trying to do with gtk_window_set_default, but it isn't doing anything... I get: (test:19164): Gtk-CRITICAL **: gtk_window_set_default: assertion `GTK_WIDGET_CAN_DEFAULT (default_widget)' failed at runtime. devhelp says: Before making a widget the default widget, you must set the GTK_CAN_DEFAULT flag on the widget you'd like to make the default using GTK_WIDGET_SET_FLAGS(). However, I'm not sure you need the call in the first place to achieve your desired behavior. -Larry Reaves [EMAIL PROTECTED] On Mon, 2008-12-01 at 00:47 +0100, Perriman wrote: Hi all, I want to create a GTK_WINDOW_POPUP and change the type to GTK_WINDOW_TOPLEVEL. If you have used eclipse, when you are writting you can see a calltip (but the focus is in the editor) and if you press F2, then the calltip window gets the focus and show the decoration. I'm trying for two weeks and I cannot do the same in the example program. If I set GTK_WINDOW_POPUP then I cannot set the focus to the window and, If I use GTK_WINDOW_TOPLEVEL then the window lost the focus. If I show the popup window and set the focus to the main window, it does not work... I'm desperated Can you help me? Thank you again!! El Sun, 30 Nov 2008 23:37:29 +0100 Perriman [EMAIL PROTECTED] escribió: Hi Michael I paste the code: #include gtk/gtk.h #include gdk/gdkkeysyms.h static GtkWidget *window; static GtkWidget *view
Re: Focus problem
Hi Michael I paste the code: #include gtk/gtk.h #include gdk/gdkkeysyms.h static GtkWidget *window; static GtkWidget *view; static GtkWidget *popup; static GtkWidget *popup_view; static gboolean set_focus = FALSE; static void destroy_cb(GtkObject *object,gpointer user_data) { gtk_main_quit (); } static gboolean focus_window(gpointer win) { g_debug(focus win); gtk_window_present_with_time(GTK_WINDOW(win),GDK_CURRENT_TIME); gtk_window_activate_focus(GTK_WINDOW(win)); gtk_widget_grab_focus(GTK_WIDGET(win)); return FALSE; } static void show_cb(GtkWidget *widget, gpointer user_data) { g_debug(show popup); focus_window(window); } static void realize_cb(GtkWidget *widget, gpointer user_data) { g_debug(realize popup); focus_window(window); } static void focus_in_cb(GtkWidget *widget, gpointer user_data) { g_debug(focus-in); //focus_window(window); } static void focus_out_win_cb(GtkWidget *widget, gpointer user_data) { g_debug(focus-out-win); /* if (!set_focus) focus_window(window); else set_focus = FALSE; */ } static void map_cb(GtkWidget *widget, gpointer user_data) { g_debug(map popup); focus_window(window); } static gboolean key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { if (event-keyval == GDK_F5) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { gtk_widget_hide(popup); } else { gtk_widget_show_all(popup); focus_window(window); //g_timeout_add(2000,focus_window,window); } } else if (event-keyval == GDK_F6) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { g_debug(focus al popup); set_focus = TRUE; focus_window(popup); gtk_widget_grab_focus(popup_view); } } return FALSE; } GtkWidget* create_popup (void) { popup = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_transient_for(GTK_WINDOW(popup),GTK_WINDOW(window)); gtk_window_set_focus_on_map(GTK_WINDOW(popup), FALSE); gtk_window_set_type_hint(GTK_WINDOW(popup), GDK_WINDOW_TYPE_HINT_TOOLTIP); gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); gtk_container_set_border_width(GTK_CONTAINER(popup),2); gtk_window_resize(GTK_WINDOW(popup),200,200); popup_view = gtk_text_view_new(); GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(scroll),popup_view); gtk_container_add(GTK_CONTAINER(popup),scroll); /*g_signal_connect(popup, show, G_CALLBACK(show_cb), NULL); g_signal_connect(popup, realize, G_CALLBACK(realize_cb), NULL); g_signal_connect(popup, map, G_CALLBACK(map_cb), NULL); g_signal_connect(popup, focus-in-event, G_CALLBACK(focus_in_cb), NULL); */ return popup; } GtkWidget* create_window (void) { window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_resize(GTK_WINDOW(window),800,600); view = gtk_text_view_new(); gtk_window_set_default(GTK_WINDOW(window),view); GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(scroll),view); gtk_container_add(GTK_CONTAINER(window),scroll); g_signal_connect(view, key-release-event, G_CALLBACK(key_press), NULL); g_signal_connect(window, destroy, G_CALLBACK(destroy_cb), NULL); g_signal_connect(window, focus-out-event, G_CALLBACK(focus_out_win_cb), NULL); return window; } int main (int argc, char *argv[]) { GtkWidget *window; gtk_set_locale (); gtk_init (argc, argv); window = create_window (); popup = create_popup(); gtk_widget_show_all (window); gtk_main (); return 0; } El Sat, 29 Nov 2008 16:50:09 -0600 Michael Cronenworth [EMAIL PROTECTED] escribió: Perriman wrote: Can you help me?? (I attach the example) Sorry, I don't see the example. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus problem
Hi all, I want to create a GTK_WINDOW_POPUP and change the type to GTK_WINDOW_TOPLEVEL. If you have used eclipse, when you are writting you can see a calltip (but the focus is in the editor) and if you press F2, then the calltip window gets the focus and show the decoration. I'm trying for two weeks and I cannot do the same in the example program. If I set GTK_WINDOW_POPUP then I cannot set the focus to the window and, If I use GTK_WINDOW_TOPLEVEL then the window lost the focus. If I show the popup window and set the focus to the main window, it does not work... I'm desperated Can you help me? Thank you again!! El Sun, 30 Nov 2008 23:37:29 +0100 Perriman [EMAIL PROTECTED] escribió: Hi Michael I paste the code: #include gtk/gtk.h #include gdk/gdkkeysyms.h static GtkWidget *window; static GtkWidget *view; static GtkWidget *popup; static GtkWidget *popup_view; static gboolean set_focus = FALSE; static void destroy_cb(GtkObject *object,gpointer user_data) { gtk_main_quit (); } static gboolean focus_window(gpointer win) { g_debug(focus win); gtk_window_present_with_time(GTK_WINDOW(win),GDK_CURRENT_TIME); gtk_window_activate_focus(GTK_WINDOW(win)); gtk_widget_grab_focus(GTK_WIDGET(win)); return FALSE; } static void show_cb(GtkWidget *widget, gpointer user_data) { g_debug(show popup); focus_window(window); } static void realize_cb(GtkWidget *widget, gpointer user_data) { g_debug(realize popup); focus_window(window); } static void focus_in_cb(GtkWidget *widget, gpointer user_data) { g_debug(focus-in); //focus_window(window); } static void focus_out_win_cb(GtkWidget *widget, gpointer user_data) { g_debug(focus-out-win); /*if (!set_focus) focus_window(window); else set_focus = FALSE; */ } static void map_cb(GtkWidget *widget, gpointer user_data) { g_debug(map popup); focus_window(window); } static gboolean key_press(GtkWidget *widget, GdkEventKey *event, gpointer user_data) { if (event-keyval == GDK_F5) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { gtk_widget_hide(popup); } else { gtk_widget_show_all(popup); focus_window(window); //g_timeout_add(2000,focus_window,window); } } else if (event-keyval == GDK_F6) { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { g_debug(focus al popup); set_focus = TRUE; focus_window(popup); gtk_widget_grab_focus(popup_view); } } return FALSE; } GtkWidget* create_popup (void) { popup = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_transient_for(GTK_WINDOW(popup),GTK_WINDOW(window)); gtk_window_set_focus_on_map(GTK_WINDOW(popup), FALSE); gtk_window_set_type_hint(GTK_WINDOW(popup), GDK_WINDOW_TYPE_HINT_TOOLTIP); gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); gtk_container_set_border_width(GTK_CONTAINER(popup),2); gtk_window_resize(GTK_WINDOW(popup),200,200); popup_view = gtk_text_view_new(); GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(scroll),popup_view); gtk_container_add(GTK_CONTAINER(popup),scroll); /*g_signal_connect(popup, show, G_CALLBACK(show_cb), NULL); g_signal_connect(popup, realize, G_CALLBACK(realize_cb), NULL); g_signal_connect(popup, map, G_CALLBACK(map_cb), NULL); g_signal_connect(popup, focus-in-event, G_CALLBACK(focus_in_cb), NULL); */ return popup; } GtkWidget* create_window (void) { window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_resize(GTK_WINDOW(window),800,600); view = gtk_text_view_new(); gtk_window_set_default(GTK_WINDOW(window),view); GtkWidget *scroll = gtk_scrolled_window_new(NULL,NULL); gtk_container_add(GTK_CONTAINER(scroll),view); gtk_container_add(GTK_CONTAINER(window),scroll); g_signal_connect(view, key-release-event, G_CALLBACK(key_press), NULL); g_signal_connect(window, destroy, G_CALLBACK(destroy_cb), NULL); g_signal_connect(window, focus-out-event, G_CALLBACK(focus_out_win_cb), NULL); return window; } int main (int argc, char *argv[]) { GtkWidget *window; gtk_set_locale (); gtk_init (argc, argv); window = create_window (); popup = create_popup(); gtk_widget_show_all (window); gtk_main (); return 0; } El Sat, 29 Nov 2008 16:50:09 -0600
Re: Focus problem
Hi, I think this patch should do what you want: --- test.orig.c 2008-11-30 20:40:21.0 -0500 +++ test.c 2008-11-30 20:49:57.0 -0500 @@ -78,7 +78,11 @@ { gtk_widget_show_all(popup); focus_window(window); - + g_debug(unfocus al popup); + set_focus = FALSE; + focus_window(window); + gtk_widget_grab_focus(view); + gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); //g_timeout_add(2000,focus_window,window); } } @@ -86,10 +90,22 @@ { if (GTK_WIDGET_VISIBLE(GTK_WIDGET(popup))) { - g_debug(focus al popup); - set_focus = TRUE; - focus_window(popup); - gtk_widget_grab_focus(popup_view); + if (set_focus == FALSE) + { + g_debug(focus al popup); + set_focus = TRUE; + focus_window(popup); + gtk_widget_grab_focus(popup_view); + gtk_window_set_decorated(GTK_WINDOW(popup),TRUE); + } + else + { + g_debug(unfocus al popup); + set_focus = FALSE; + focus_window(window); + gtk_widget_grab_focus(view); + gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); + } } } @@ -103,7 +119,7 @@ gtk_window_set_transient_for(GTK_WINDOW(popup),GTK_WINDOW(window)); gtk_window_set_focus_on_map(GTK_WINDOW(popup), FALSE); gtk_window_set_type_hint(GTK_WINDOW(popup), - GDK_WINDOW_TYPE_HINT_TOOLTIP); + GDK_WINDOW_TYPE_HINT_NORMAL); gtk_window_set_decorated(GTK_WINDOW(popup),FALSE); gtk_container_set_border_width(GTK_CONTAINER(popup),2); gtk_window_resize(GTK_WINDOW(popup),200,200); @@ -112,6 +128,8 @@ gtk_container_add(GTK_CONTAINER(scroll),popup_view); gtk_container_add(GTK_CONTAINER(popup),scroll); + g_signal_connect(popup, key-release-event, + G_CALLBACK(key_press), NULL); /*g_signal_connect(popup, show, G_CALLBACK(show_cb), NULL); g_signal_connect(popup, realize, G_CALLBACK(realize_cb), NULL); g_signal_connect(popup, map, G_CALLBACK(map_cb), NULL); Summary of changes: 1. set type hint to be 'normal' instead of 'tooltip' 2. connect up key-release-event to popup also, so when it has focus we can get out of it 3. on f6, only grab focus if we don't have it and add decorations 4. if we do have it, return focus to main window and remove decorations 5. if we hide popup while it has focus, remove decorations and focus So, you open the app and the main window has focus. Pressing F5 will show the popup, but focus will remain with the main window. Pressing F5 again will hide it. If F6 is pressed while the popup is open, it will grab focus and become decorated. While it has focus, it can remove decorations and pass focus back via F6. F5 also returns focus and removes decorations, but also hides the window. If this is not the desired behavior, let me know and I'll see if I can help. P.S. I'm not sure what you're trying to do with gtk_window_set_default, but it isn't doing anything... I get: (test:19164): Gtk-CRITICAL **: gtk_window_set_default: assertion `GTK_WIDGET_CAN_DEFAULT (default_widget)' failed at runtime. devhelp says: Before making a widget the default widget, you must set the GTK_CAN_DEFAULT flag on the widget you'd like to make the default using GTK_WIDGET_SET_FLAGS(). However, I'm not sure you need the call in the first place to achieve your desired behavior. -Larry Reaves [EMAIL PROTECTED] On Mon, 2008-12-01 at 00:47 +0100, Perriman wrote: Hi all, I want to create a GTK_WINDOW_POPUP and change the type to GTK_WINDOW_TOPLEVEL. If you have used eclipse, when you are writting you can see a calltip (but the focus is in the editor) and if you press F2, then the calltip window gets the focus and show the decoration. I'm trying for two weeks and I cannot do the same in the example program. If I set GTK_WINDOW_POPUP then I cannot set the focus to the window and, If I use GTK_WINDOW_TOPLEVEL then the window lost the focus. If I show the popup window and set the focus to the main window, it does not work... I'm desperated Can you help me? Thank you again!! El Sun, 30 Nov 2008 23:37:29 +0100 Perriman [EMAIL PROTECTED] escribió: Hi Michael I paste the code: #include gtk/gtk.h #include gdk/gdkkeysyms.h static GtkWidget *window; static GtkWidget *view; static GtkWidget *popup; static GtkWidget *popup_view; static gboolean set_focus = FALSE; static void destroy_cb(GtkObject *object,gpointer user_data) { gtk_main_quit (); } static gboolean focus_window(gpointer win) { g_debug(focus win); gtk_window_present_with_time(GTK_WINDOW(win),GDK_CURRENT_TIME); gtk_window_activate_focus(GTK_WINDOW(win)); gtk_widget_grab_focus(GTK_WIDGET(win
Focus problem
Hi all, I have a problem with the window focus. I have a main window and a second window. I want to show the second window always on top but set the focus in the main window. I'm setted this in the second window: gtk_window_set_transient_for(GTK_WINDOW(popup),GTK_WINDOW(window)); gtk_window_set_focus_on_map(GTK_WINDOW(popup), FALSE); But when I show the second window, the focus is losed. The main window has not the focus and the second window neither. If I try to set the focus on the main window with gtk_window_present(GTK_WINDOW(window)); gtk_window_activate_focus(GTK_WINDOW(window)); gtk_widget_grab_focus(GTK_WIDGET(view)); Only works the first time I show the second window. I think it's a gtk bug or a window manager bug... Can you help me?? (I attach the example) I'm using ubuntu 8.10 with gnome. Regards, Perriman___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus problem
Perriman wrote: Can you help me?? (I attach the example) Sorry, I don't see the example. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Focus weirdness
Alright I've finally solved it. I had to pass the focus manually from the GtkDrawingArea to the embedded xterm using XSetInputFocus(). Can somebody suggest a cleaner or a more GTK-ish way of doing this? I've tried with GtkSocket and gtk_socket_steal() but I still had to pass the focus manually. The minimal working example follows. David - FILE: minex.c - // gcc -o minex -Wall `pkg-config --cflags --libs gtk+-2.0` minex.c ./minex #include glib.h #include glib/gprintf.h #include gtk/gtk.h #include gdk/gdkx.h static XID get_child_xid(GtkWidget *widget) { Window win = GDK_WINDOW_XID(gtk_widget_get_window(widget)); Window root_win, parent_win, *children; unsigned int nchildren; XID child; if (!XQueryTree(GDK_DISPLAY(), win, root_win, parent_win, children, nchildren)) return 0; child = (nchildren 0) ? children[0] : 0; XFree((char *) children); return child; } static void destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } static void realize(GtkWidget *xterm_area, gpointer data) { char cmd[256]; g_sprintf(cmd, xterm -into %lu, GDK_WINDOW_XID(gtk_widget_get_window(xterm_area))); g_spawn_command_line_async(cmd, NULL); } static gboolean focus_in_event(GtkWidget *xterm_area, GdkEventFocus *event, gpointer data) { XID child = get_child_xid(xterm_area); if (child) { XSetInputFocus(GDK_DISPLAY(), child, RevertToParent, GDK_CURRENT_TIME); } return TRUE; } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *xterm_area; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), destroy, G_CALLBACK(destroy), NULL); xterm_area = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), xterm_area); gtk_widget_set_size_request(GTK_WIDGET(xterm_area), 484, 316); gtk_widget_show(xterm_area); GTK_WIDGET_SET_FLAGS(xterm_area, GTK_CAN_FOCUS); g_signal_connect(G_OBJECT(xterm_area), realize, G_CALLBACK(realize), NULL); g_signal_connect(G_OBJECT(xterm_area), focus-in-event, G_CALLBACK(focus_in_event), NULL); gtk_widget_show(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Focus weirdness
Hi, I'm having a weird focus problem with an xterm embedded in a GtkDrawingArea. When I put the main application on sleep, the xterm can get the focus. Otherwise, it can't. Could somebody suggest me a way to allow the embedded xterm to get the focus when the GtkDrawingArea gets it? A minimal example follows. Move the focus in and out of the window. The main application will be put on sleep for 3 seconds when the GtkDrawingArea gets the focus. During these 3 seconds, you can type in the embedded xterm. When the main application wakes up, the embedded xterm loses the focus. Thanks in advance for any help! David - FILE: minex.c // gcc -o minex -Wall `pkg-config --cflags --libs gtk+-2.0` minex.c ./minex #include glib.h #include glib/gprintf.h #include gtk/gtk.h #include gdk/gdkx.h static void destroy(GtkWidget *widget, gpointer data) { gtk_main_quit(); } static void realize(GtkWidget *xterm_area, GdkEvent *event, gpointer data) { char cmd[256]; GError *err; g_sprintf(cmd, xterm -into %lu, GDK_WINDOW_XID(gtk_widget_get_window(xterm_area))); g_spawn_command_line_async(cmd, err); } static gboolean focus_in_event(GtkWidget *xterm_area, GdkEventFocus *event, gpointer data) { g_print(focus in\n); g_usleep(3ul * 100ul); return FALSE; } int main(int argc, char *argv[]) { GtkWidget *window; GtkWidget *xterm_area; gtk_init(argc, argv); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); g_signal_connect(G_OBJECT(window), destroy, G_CALLBACK(destroy), NULL); xterm_area = gtk_drawing_area_new(); gtk_container_add(GTK_CONTAINER(window), xterm_area); gtk_widget_set_size_request(GTK_WIDGET(xterm_area), 484, 316); gtk_widget_show(xterm_area); GTK_WIDGET_SET_FLAGS(xterm_area, GTK_CAN_FOCUS); g_signal_connect(G_OBJECT(xterm_area), realize, G_CALLBACK(realize), NULL); g_signal_connect(G_OBJECT(xterm_area), focus-in-event, G_CALLBACK(focus_in_event), NULL); gtk_widget_show(window); gtk_main(); return 0; } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Focus chain ineffectual
I'm trying to set the focus chain. I have 3 widgets that I want to chain, so I specified them as the arguments of the set_focus_chain method on the top-level window. I expect focus to move from one to the next as I hit tab. Instead, focus moves to many widgets not in the chain in addition to some that are in it. It seems as if the set_focus_chain call is not doing anything. can_focus is set on all three widgets. Am I not allowed to call it on the top-level window? Are the widgets required to be immediate descendants (the manual says only that the widgets should be descendants, which these are)? Is there a different explanation? -- Jeffrey Barish ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Redrawing and focus events with GtkSocket
Hey, I'm writing a plugin that uses a GtkSocket to embed gvim (a graphical version of vim). I am making some remote calls to it (via dbus) that change the current cursor position in gvim, however this change is not reflected in gvim until I scroll using the mouse wheel. If I click somewhere with the mouse, the cursor goes to that location, so that itself isn't a viable solution. I have tested using vim's remote calling function that uses X11's ICCCM (by setting/getting window properties), and it refreshes instantly. I had a look at vim's code, and it doesn't do anything special X11 wise, other than get/set the X11 window properties. Is there a way I can get the GtkSocket to redraw without resorting to using the X11 properties? (I require the dbus method for some other things, so I can't redo it all with GDK/X11). Also, can I get the GtkSockets' window focus events in my program? Cheers, Arun Tejasvi Chaganty (vimzard) GNOME GSoC Student Blog: http://arunchaganty.wordpress.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
How to bring an dialog to focus?
Hi How to bring an dialog to focus? sometimes i use gtk_message_dialog_new for some messages, but when i have some big windows on the screen, this message dialog is behind this others. how to bring them to front? Atenciosamente Luiz Rafael Culik Guimaraes Suporte Xharbour www.xharbour.com.br ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
signal for detecting gtk app de-focus
Hello, I am attempting to find a way in my gtk app to get control (via signal or other means) when my application looses focus - that is when another application comes to the front, but my app is still running. I need to cleanup somethings at that point in time, but have not been able to determine how to get control. thanks, steve ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
signal for detecting gtk app de-focus
Hello, I am attempting to find a way in my gtk app to get control (via signal or other means) when my application looses focus - that is when another application comes to the front, but my app is still running. I need to cleanup somethings at that point in time, but have not been able to determine how to get control. thanks, steve ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Dragging a window without focus
Hello, I've been trying on and off for the past few weeks to use the function gdk_window_begin_move_drag on a window in my application. If I call the function in the callback for a button-press-event it works fine. However, if I attempt to call the function in response to a client-event (or anything but a button-press-event) it fails miserably and silently. At first I thought that the problem was the event's timestamp. I tested and found that gdk_window_begin_move_drag works after several repeated client-events, so I've began to doubt that is the problem. It's worth pointing out that the function gtk_menu_popup behaves in the same way. It works fine on a button-press-event but does nothing otherwise. I suspect that the functions are failing because the GdkWindow doesn't have focus, however I'm not sure how to fix that. I've spent a large number of hours trying to solve this myself, and I'm out of ideas. Any help on this would be greatly appreciated. Thanks, Natan ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Keyboard Event Focus
Hello list, i have a mplayer running in my application. Keyboard events are used to navigate and to switch between different video sources. When the player is in a QVGA-mode (just a quarter of the VGA-Screen) the keyboard strokes are registered correctly in the application, but when the video is displayed in VGA (a small border generated by the app is still around and in the foreground) the events are catched from the mplayer and i can´t navigate no more. The same problem exists if i display four QVGA videos arranged in the four quarters of the screen, every seperated by it´s own border. FYI: The app is running on X, but without Window Manager on an ELinOS-System. I think it´s a problem of focus, but i do not know how to get the focus on e.g. the border Is there a possibility to solve this with sth like an event box? Best regards Markus - Gersys GmbH, Hans-Urmiller-Ring 46c, D-82515 Wolfratshausen, Germany Geschaeftsfuehrer: Erwin Sterzer, HRB 137 872 Muenchen, Fon: +49(0)8171 9986-6 Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet. This e-mail may contain confidential and/or privileged information. If you are not the intended recipient or have received this e-mail in error please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Setting focus change/activation bindings
Background: I'm trying to build a GTK+ GUI for a simple embedded system with limited input. Specifically it's an ipod-style wheel with click, so I have three buttons: forward, backward, and select. I'd like to be able to use forward and backward to move focus, the way tab/shift-tab does currently, and then the select button to work like spacebar. I can do this by mapping the buttons to tab, shift-tab, and spacebar, but some widgets need more keys, e.g. you need up and down arrows for a menu, but the right and left arrows to move into/out of sub-menus. Question: How can I insert my own key bindings for GUI events that are normally mouse-driven? Do I need to do this by manually moving focus between items and trapping keypresses? Any ideas would be greatly appreciated. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Telling a widget not to be in the focus chain
--- [EMAIL PROTECTED] wrote: On 10/31/07, Steffen Gutmann [EMAIL PROTECTED] wrote: So, anybody has an idea what the correct way of leaving a widget out of the focus chain is? I use gtk_container_set_focus_chain() to set an exact list of widgets for a section of the focus chain. Thanks for your answer. The word 'section' in your answer gave me the right idea: I placed the widget that I want to be out of the focus chain in its own container widget and called gtk_container_set_focus_chain with NULL as second argument. This gives the desired result. Very simple and quite trivial once you find out... Cheers, Steffen __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Telling a widget not to be in the focus chain
Hi! I would like to tell a widget to not be part of Gtk's focus chain. I know there is gtk_container_set_focus_chain, however, I would like to keep Gtk's default focus chain logic and just would like to have one or two widgets not being part of it. The widget could be a GtkButton, GtkEntry, GtkTreeView or GtkTextView, or any other user interface element. I tried to unset the GTK_CAN_FOCUS flag. This works nicely e.g. for GtkButton (pressing tab jumps over the button) but when doing this on a GtkEntry or GtkTextView it means that the widget also doesn't grab the focus when clicking on it, thus no text input is possible any more. I tried g_signal_connect(widget, focus, G_CALLBACK(noFocus), NULL) where the callback is defined as: static gboolean noFocus(GtkWidget *widget) { g_signal_stop_emission_by_name(widget, focus); return FALSE; } This works well for GtkButtons and GtkEntries but has a small glitch for GtkTextView and GtkTreeView. There is no focus drawn but still the focus is 'somehow on the widget'. Pressing the tab key again then moves on to the next widget. Not perfect. So, anybody has an idea what the correct way of leaving a widget out of the focus chain is? __ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Telling a widget not to be in the focus chain
On 10/31/07, Steffen Gutmann [EMAIL PROTECTED] wrote: So, anybody has an idea what the correct way of leaving a widget out of the focus chain is? I use gtk_container_set_focus_chain() to set an exact list of widgets for a section of the focus chain. GList *focus_chain; focus_chain = NULL; focus_chain = g_list_append( focus_chain, iv-ip ); focus_chain = g_list_append( focus_chain, iv-cv ); focus_chain = g_list_append( focus_chain, iv-pbv ); gtk_container_set_focus_chain( GTK_CONTAINER( vbox ), focus_chain ); John John ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
focus
Is there an explanation of gtk's focus mechanism somewhere? That is, an overview of how focus works, what the various focus-related signals mean etc. I've googled but haven't found anything. Thanks, Dave ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
focus-out-event and GtkEntry
I need to check data a user inputs on one of numerous GtkEntry's on window, and I need to handle the situation when the entry loses focus (by TABing out of the field, or by mouse control. When I encouter bad input, I bring up a dialog box. The problem is I get an GtkWarning and GtkError: the GtkWarning is: Gtk-WARING **: GtkEntry - did not receive focus-out-event. If you connect to a handler to this signal, it must return FALSE so the entry gets the event as well. the Error is a message box: Gtk-ERROR **: file gtkentry.c: line 4886 (blink_cb): assertion failed: (GTK_WIDGET_HAS_FOCUS(entry)) aborting... a sample C program which duplicates the error is below. Is there anyway to bring up a dialog box in a focus-out-event handler that wont trigger this error? I am using GTK version 2.6.4 on Windows XP. Zvi /* test2.c */ #include gtk/gtk.h GtkWidget *frm_main, *entry1, *entry2, *box; void dstry() { gtk_main_quit(); } int activate(GtkWidget *w, void *p) { g_print(in activate()\n); check_data(w); g_print(leaving activate()\n); return FALSE; } int focus_out(GtkWidget *w, void *p) { g_print(in focus_out()\n); check_data(w); g_print(leaving focus_out()\n); return FALSE; } int check_data(GtkWidget *w) { GtkWidget *dialog; int resp; char *data = gtk_entry_get_text(w); g_print(in check_data(), data = \%s\\n, data); if (!strcmp(data, abcd)) { g_print(leaving check_data(1)\n); return 1; } dialog = gtk_message_dialog_new (GTK_WINDOW (frm_main), GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, INVALID DATA); switch (resp = gtk_dialog_run (GTK_DIALOG (dialog))) { case GTK_RESPONSE_OK: default: gtk_widget_destroy (dialog); g_print(leaving check_data(0)\n); return 0; } } int main(int argc, char **argv) { gtk_init(argc, argv); frm_main = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_window_set_position(GTK_WINDOW(frm_main),GTK_WIN_POS_CENTER); gtk_window_set_default_size(GTK_WINDOW(frm_main), 500, 500); g_signal_connect (G_OBJECT(frm_main), destroy, G_CALLBACK (dstry), NULL); box = gtk_hbox_new(TRUE, 10); gtk_container_add(GTK_CONTAINER(frm_main), box); entry1 = gtk_entry_new_with_max_length(20); gtk_container_add(GTK_CONTAINER(box), entry1); g_signal_connect (G_OBJECT (entry1), focus-out-event, G_CALLBACK (focus_out), NULL); g_signal_connect (G_OBJECT (entry1), activate, G_CALLBACK (activate), NULL); entry2 = gtk_entry_new_with_max_length(20); gtk_container_add(GTK_CONTAINER(box), entry2); gtk_widget_show_all(frm_main); gtk_main(); exit (0); } ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list