Skip to content

Commit

Permalink
Gtk3: base dialogs: update signal handler connecting
Browse files Browse the repository at this point in the history
Connect "destroy" signal handlers unlocked, add comments about why the other
signal handles cannot be connected unlocked.


git-svn-id: https://svn.code.sf.net/p/vice-emu/code/trunk@45173 379a1393-f5fb-40a0-bcee-ef074d9b53f7
  • Loading branch information
Compyx committed May 28, 2024
1 parent 3a4de12 commit e424af4
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions vice/src/arch/gtk3/widgets/base/basedialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,10 @@ static GtkWidget *create_dialog(GtkWindow *parent,

/* set up signal handler to destroy the temporary parent window */
if (no_parent) {
g_signal_connect_unlocked(dialog, "destroy", G_CALLBACK(on_dialog_destroy),
(gpointer)parent);
g_signal_connect_unlocked(G_OBJECT(dialog),
"destroy",
G_CALLBACK(on_dialog_destroy),
(gpointer)parent);
}

return dialog;
Expand Down Expand Up @@ -257,6 +259,8 @@ GtkWidget *vice_gtk3_message_confirm(GtkWindow *parent,
} else {
gtk_window_set_position(GTK_WINDOW(dialog), GTK_WIN_POS_CENTER);
}

/* cannot connect unlocked: the user's callback might set a resource */
g_signal_connect(G_OBJECT(dialog),
"response",
G_CALLBACK(on_response_confirm),
Expand Down Expand Up @@ -360,10 +364,10 @@ static gboolean entry_get_int(GtkWidget *entry, int *value)
*/
static gboolean on_integer_key_press_event(GtkEntry *entry,
GdkEvent *event,
gpointer data)
gpointer data)
{
GtkWidget *dialog = data;
GdkEventKey *keyev = (GdkEventKey *)event;
GtkWidget *dialog = data;
GdkEventKey *keyev = (GdkEventKey *)event;

if (keyev->type == GDK_KEY_PRESS && keyev->keyval == GDK_KEY_Return) {
/* got Enter */
Expand Down Expand Up @@ -447,10 +451,17 @@ GtkWidget *vice_gtk3_integer_input_box(
gtk_widget_show_all(grid);
gtk_box_pack_start(GTK_BOX(content), grid, TRUE, TRUE, 8);

g_signal_connect(dialog, "key-press-event",
G_CALLBACK(on_integer_key_press_event), (gpointer)dialog);
g_signal_connect(dialog, "response", G_CALLBACK(on_response_integer),
(gpointer)entry);
/* cannot connect unlocked: this handler emits the "accept" signal of the
* dialog and the callback could set a resource */
g_signal_connect(G_OBJECT(dialog),
"key-press-event",
G_CALLBACK(on_integer_key_press_event),
(gpointer)dialog);
/* cannot connect unlocked either */
g_signal_connect(G_OBJECT(dialog),
"response",
G_CALLBACK(on_response_integer),
(gpointer)entry);
gtk_widget_show(dialog);
return dialog;
}

0 comments on commit e424af4

Please sign in to comment.