From 5d928407022afa0fd9e1c6798f4c93ba54418b4e Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Thu, 23 Mar 2017 12:30:48 +0100 Subject: keybindings: Allow to select an installed application through a dialog --- capplets/keybindings/mate-keybinding-properties.c | 31 +++++++++ capplets/keybindings/mate-keybinding-properties.ui | 74 ++++++++++++++++++---- 2 files changed, 93 insertions(+), 12 deletions(-) (limited to 'capplets') diff --git a/capplets/keybindings/mate-keybinding-properties.c b/capplets/keybindings/mate-keybinding-properties.c index 9d548569..78900537 100644 --- a/capplets/keybindings/mate-keybinding-properties.c +++ b/capplets/keybindings/mate-keybinding-properties.c @@ -1827,6 +1827,30 @@ selection_changed (GtkTreeSelection *selection, gpointer data) gtk_widget_set_sensitive (button, can_remove); } +static void +cb_app_dialog_response (GtkWidget *dialog, gint response_id, gpointer data) +{ + if (response_id == GTK_RESPONSE_OK) + { + GAppInfo *info; + const gchar *custom_name; + + info = gtk_app_chooser_get_app_info (GTK_APP_CHOOSER (dialog)); + + gtk_entry_set_text (custom_shortcut_command_entry, + g_app_info_get_executable (info)); + /* if name isn't set yet, use the associated one */ + custom_name = gtk_entry_get_text (GTK_ENTRY (custom_shortcut_name_entry)); + if (! custom_name || custom_name[0] == '\0') + gtk_entry_set_text (custom_shortcut_name_entry, + g_app_info_get_display_name (info)); + + g_object_unref (info); + } + + gtk_widget_hide (dialog); +} + static void setup_dialog (GtkBuilder *builder, GSettings *marco_settings) { @@ -1835,6 +1859,7 @@ setup_dialog (GtkBuilder *builder, GSettings *marco_settings) GtkWidget *widget; GtkTreeView *treeview; GtkTreeSelection *selection; + GtkWidget *button; treeview = GTK_TREE_VIEW (gtk_builder_get_object (builder, "shortcut_treeview")); @@ -1916,6 +1941,12 @@ setup_dialog (GtkBuilder *builder, GSettings *marco_settings) GTK_RESPONSE_OK); gtk_window_set_transient_for (GTK_WINDOW (custom_shortcut_dialog), GTK_WINDOW (widget)); + button = _gtk_builder_get_widget (builder, "custom-shortcut-command-button"); + widget = _gtk_builder_get_widget (builder, "custom-shortcut-application-dialog"); + g_signal_connect_swapped (button, "clicked", G_CALLBACK (gtk_dialog_run), widget); + g_signal_connect (widget, "response", G_CALLBACK (cb_app_dialog_response), NULL); + widget = gtk_app_chooser_dialog_get_widget (GTK_APP_CHOOSER_DIALOG (widget)); + gtk_app_chooser_widget_set_show_all (GTK_APP_CHOOSER_WIDGET (widget), TRUE); } static void diff --git a/capplets/keybindings/mate-keybinding-properties.ui b/capplets/keybindings/mate-keybinding-properties.ui index 2eae2c1d..65ed5059 100644 --- a/capplets/keybindings/mate-keybinding-properties.ui +++ b/capplets/keybindings/mate-keybinding-properties.ui @@ -100,29 +100,53 @@ - + True - True - True - - True + False + start + C_ommand: + True - 1 + 0 1 - + True False - start - C_ommand: - True - custom-shortcut-command-entry + 6 + + + True + True + True + + True + + + True + True + 0 + + + + + Browse applications... + True + True + True + + + False + True + 1 + + - 0 + 1 1 @@ -147,6 +171,32 @@ okbutton1 + + False + True + True + dialog + custom-shortcut-dialog + */* + + + False + vertical + 2 + + + False + end + + + False + False + 0 + + + + + mate-keybinding-dialog False -- cgit v1.2.1