33 #define HOTKEY_DIALOG_UI_FILE "hotkey-dialog-gtk3.glade" 35 #define HOTKEY_DIALOG_UI_FILE "hotkey-dialog-gtk2.glade" 48 title = g_strdup_printf(
_(
"Set %s HotKey"),
hotkey);
49 gtk_window_set_title(window, title);
52 instruction = g_strdup_printf(
_(
"Press new HotKey for <b>%s</b>"),
hotkey);
53 gtk_label_set_markup(instruction_label, instruction);
79 GdkModifierType state, consumed;
80 GtkLabel *key_pressed_label;
87 gdk_keymap_translate_keyboard_state(gdk_keymap_get_default(),
88 event->hardware_keycode,
89 state, event->group, &key_val,
90 NULL, NULL, &consumed);
93 state &= gtk_accelerator_get_default_mod_mask();
95 key_text = gtk_accelerator_name(key_val, state);
96 gtk_label_set_text(key_pressed_label, key_text);
114 G_GNUC_UNUSED GdkEventKey *event,
117 gtk_dialog_response(GTK_DIALOG(widget), GTK_RESPONSE_OK);
135 GdkGrabStatus grab_status;
145 device = gtk_get_current_event_device();
146 if (device == NULL) {
147 WARN(
"Couldn't get current device");
153 #if GTK_CHECK_VERSION(3,20,0) 154 grab_status = gdk_seat_grab
155 (gdk_device_get_seat(device),
157 GDK_SEAT_CAPABILITY_KEYBOARD, TRUE,
158 NULL, NULL, NULL, NULL);
160 grab_status = gdk_device_grab
163 GDK_OWNERSHIP_APPLICATION, TRUE,
164 GDK_KEY_PRESS_MASK, NULL, GDK_CURRENT_TIME);
169 grab_status = gdk_keyboard_grab
170 (window, TRUE, GDK_CURRENT_TIME);
173 if (grab_status != GDK_GRAB_SUCCESS) {
183 #if GTK_CHECK_VERSION(3,20,0) 184 gdk_seat_ungrab(gdk_device_get_seat(device));
186 gdk_device_ungrab(device, GDK_CURRENT_TIME);
189 gdk_keyboard_ungrab(GDK_CURRENT_TIME);
193 if (resp != GTK_RESPONSE_OK)
197 return g_strdup(gtk_label_get_text(key_pressed_label));
234 DEBUG(
"Building from ui file '%s'", uifile);
248 gtk_window_set_transient_for(GTK_WINDOW(dialog->
hotkey_dialog), parent);
251 gtk_builder_connect_signals(builder, dialog);
254 g_object_unref(builder);
GtkBuilder * gtk_builder_new_from_file(const gchar *filename)
Internationalization support.
HotkeyDialog * hotkey_dialog_create(GtkWindow *parent, const gchar *hotkey)
static void configure_hotkey_dialog(GtkWindow *window, GtkLabel *instruction_label, const gchar *hotkey)
gchar * hotkey_dialog_run(HotkeyDialog *dialog)
#define HOTKEY_DIALOG_UI_FILE
#define assign_gtk_widget(builder, container, name)
Header for ui-hotkey-dialog.c.
GtkWidget * instruction_label
gchar * get_ui_file(const char *filename)
GtkWidget * hotkey_dialog
void run_error_dialog(const char *fmt,...)
gboolean on_hotkey_dialog_key_press_event(G_GNUC_UNUSED GtkWidget *widget, GdkEventKey *event, HotkeyDialog *dialog)
gboolean on_hotkey_dialog_key_release_event(GtkWidget *widget, G_GNUC_UNUSED GdkEventKey *event, G_GNUC_UNUSED HotkeyDialog *dialog)
void hotkey_dialog_destroy(HotkeyDialog *dialog)
GtkWidget * key_pressed_label