keyboard: custom shortcut should require name and command
It is possible to press the Add button in the custom shortcut dialog when the name and command fields are empty. Disable the button by default, and only enable it when the name and command is non-empty. https://bugzilla.gnome.org/show_bug.cgi?id=739647
This commit is contained in:
parent
3aa76db195
commit
fe9fe99439
2 changed files with 25 additions and 4 deletions
|
@ -19,7 +19,7 @@
|
|||
<property name="title" translatable="yes">Custom Shortcut</property>
|
||||
<property name="show_close_button">False</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="cancelbutton1">
|
||||
<object class="GtkButton" id="custom-shortcut-cancel-button">
|
||||
<property name="label" translatable="yes">_Cancel</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -36,7 +36,7 @@
|
|||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkButton" id="okbutton1">
|
||||
<object class="GtkButton" id="custom-shortcut-ok-button">
|
||||
<property name="label" translatable="yes">_Add</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
|
@ -45,6 +45,7 @@
|
|||
<property name="use_action_appearance">False</property>
|
||||
<property name="use_underline">True</property>
|
||||
<property name="valign">center</property>
|
||||
<property name="sensitive">False</property>
|
||||
<style>
|
||||
<class name="text-button"/>
|
||||
<class name="suggested-action"/>
|
||||
|
@ -144,8 +145,8 @@
|
|||
</object>
|
||||
</child>
|
||||
<action-widgets>
|
||||
<action-widget response="-6">cancelbutton1</action-widget>
|
||||
<action-widget response="-5">okbutton1</action-widget>
|
||||
<action-widget response="-6">custom-shortcut-cancel-button</action-widget>
|
||||
<action-widget response="-5">custom-shortcut-ok-button</action-widget>
|
||||
</action-widgets>
|
||||
</object>
|
||||
<object class="GtkNotebook" id="keyboard_notebook">
|
||||
|
|
|
@ -92,6 +92,7 @@ static GSettings *binding_settings = NULL;
|
|||
static GtkWidget *custom_shortcut_dialog = NULL;
|
||||
static GtkWidget *custom_shortcut_name_entry = NULL;
|
||||
static GtkWidget *custom_shortcut_command_entry = NULL;
|
||||
static GtkWidget *custom_shortcut_ok_button = NULL;
|
||||
static GHashTable *kb_system_sections = NULL;
|
||||
static GHashTable *kb_apps_sections = NULL;
|
||||
static GHashTable *kb_user_sections = NULL;
|
||||
|
@ -1727,6 +1728,20 @@ add_custom_shortcut (GtkTreeView *tree_view,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
shortcut_entry_changed (GtkEntry *entry,
|
||||
gpointer user_data)
|
||||
{
|
||||
guint16 name_length;
|
||||
guint16 command_length;
|
||||
|
||||
name_length = gtk_entry_get_text_length (custom_shortcut_name_entry);
|
||||
command_length = gtk_entry_get_text_length (custom_shortcut_command_entry);
|
||||
|
||||
gtk_widget_set_sensitive (custom_shortcut_ok_button,
|
||||
name_length > 0 && command_length > 0);
|
||||
}
|
||||
|
||||
static void
|
||||
add_button_clicked (GtkWidget *button,
|
||||
GtkBuilder *builder)
|
||||
|
@ -2051,10 +2066,15 @@ setup_dialog (CcPanel *panel, GtkBuilder *builder)
|
|||
/* setup the custom shortcut dialog */
|
||||
custom_shortcut_dialog = WID (builder,
|
||||
"custom-shortcut-dialog");
|
||||
custom_shortcut_ok_button = WID (builder, "custom-shortcut-ok-button");
|
||||
custom_shortcut_name_entry = WID (builder,
|
||||
"custom-shortcut-name-entry");
|
||||
g_signal_connect (custom_shortcut_name_entry, "changed",
|
||||
G_CALLBACK (shortcut_entry_changed), NULL);
|
||||
custom_shortcut_command_entry = WID (builder,
|
||||
"custom-shortcut-command-entry");
|
||||
g_signal_connect (custom_shortcut_command_entry, "changed",
|
||||
G_CALLBACK (shortcut_entry_changed), NULL);
|
||||
g_signal_connect (WID (builder, "add-toolbutton"),
|
||||
"clicked", G_CALLBACK (add_button_clicked), builder);
|
||||
g_signal_connect (WID (builder, "remove-toolbutton"),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue