]> Pileus Git - ~andy/gtk/commitdiff
Add a GtkSetting (gtk-entry-select-on-focus) controlling whether the
authorOwen Taylor <otaylor@redhat.com>
Sat, 2 Feb 2002 22:52:22 +0000 (22:52 +0000)
committerOwen Taylor <otaylor@src.gnome.org>
Sat, 2 Feb 2002 22:52:22 +0000 (22:52 +0000)
Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>

* gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
(gtk-entry-select-on-focus) controlling whether the
contents of an entry are selected on focus in.

* gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
(gtk-can-change-accels) controlling whether accelerators can be
changed on the fly or not. (#51902)

* gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
accelerators, now that accelerator changing can be turned
off for those who won't expect it. (#61285)

* gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow
Backspace/Delete/KP_Delete as valid accelerators.

* gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
Delete/Backspace as accelerators by making them toggle
the menu item between empty and the pressed key.
(#58605)

* tests/testgtkrc: Remove the objectionably short cursor blink
time setting.

ChangeLog
ChangeLog.pre-2-0
ChangeLog.pre-2-10
ChangeLog.pre-2-2
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gtk/gtkaccelgroup.c
gtk/gtkentry.c
gtk/gtkmenu.c

index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 7031df09152721a9459b05715c340d2ce9fbc5e1..06f580e27d1e1a56d0ef695100b9bf0b05724e56 100644 (file)
@@ -1,3 +1,28 @@
+Sat Feb  2 17:43:00 2002  Owen Taylor  <otaylor@redhat.com>
+
+       * gtk/gtkentry.c (gtk_entry_grab_focus): Add a GtkSetting
+       (gtk-entry-select-on-focus) controlling whether the
+       contents of an entry are selected on focus in.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Add a GtkSetting
+       (gtk-can-change-accels) controlling whether accelerators can be
+       changed on the fly or not. (#51902)
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow unmodified
+       accelerators, now that accelerator changing can be turned
+       off for those who won't expect it. (#61285)
+
+       * gtk/gtkaccelgroup.c (gtk_accelerator_valid): Allow 
+       Backspace/Delete/KP_Delete as valid accelerators.
+
+       * gtk/gtkmenu.c (gtk_menu_key_press): Allow setting of
+       Delete/Backspace as accelerators by making them toggle
+       the menu item between empty and the pressed key.
+       (#58605)
+
+       * tests/testgtkrc: Remove the objectionably short cursor blink
+       time setting.
+
 Sat Feb  2 16:43:31 2002  Owen Taylor  <otaylor@redhat.com>
 
        * gtk/gtkmenu.c (gtk_menu_popup): To get around the fact
index 0e521676212a4acfaf7e48921a33a951905be49d..70db40aee51e5d9194022e1d35ab4f0a9b9f9bae 100644 (file)
@@ -803,7 +803,6 @@ gtk_accelerator_valid (guint                  keyval,
                       GdkModifierType    modifiers)
 {
   static const guint invalid_accelerator_vals[] = {
-    GDK_BackSpace, GDK_Delete, GDK_KP_Delete,
     GDK_Shift_L, GDK_Shift_R, GDK_Shift_Lock, GDK_Caps_Lock, GDK_ISO_Lock,
     GDK_Control_L, GDK_Control_R, GDK_Meta_L, GDK_Meta_R,
     GDK_Alt_L, GDK_Alt_R, GDK_Super_L, GDK_Super_R, GDK_Hyper_L, GDK_Hyper_R,
index d9bf421f3d5941fe3dd2c864e0cf3e40640f33a4..25cbcc795643363ee3575b982bef5f99b9934f19 100644 (file)
@@ -780,6 +780,12 @@ gtk_entry_class_init (GtkEntryClass *class)
                                "toggle_overwrite", 0);
   gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0,
                                "toggle_overwrite", 0);
+
+  gtk_settings_install_property (g_param_spec_boolean ("gtk-entry-select-on-focus",
+                                                      _("Select on focus"),
+                                                      _("Whether to select the contents of an entry when it is focused."),
+                                                      TRUE,
+                                                      G_PARAM_READWRITE));
 }
 
 static void
@@ -1659,9 +1665,16 @@ gtk_entry_focus_out (GtkWidget     *widget,
 static void
 gtk_entry_grab_focus (GtkWidget        *widget)
 {
-   GTK_WIDGET_CLASS (parent_class)->grab_focus (widget);
+  gboolean select_on_focus;
+  
+  GTK_WIDGET_CLASS (parent_class)->grab_focus (widget);
 
-  if (!GTK_ENTRY (widget)->in_click)
+  g_object_get (G_OBJECT (gtk_settings_get_default ()),
+               "gtk-entry-select-on-focus",
+               &select_on_focus,
+               NULL);
+  
+  if (select_on_focus && !GTK_ENTRY (widget)->in_click)
     gtk_editable_select_region (GTK_EDITABLE (widget), 0, -1);
 }
 
index ede02af4bdc43d0c34814c68d6606c927a8c11c8..785e721b27e42889a6b24c60c22acc52f36d9ad6 100644 (file)
@@ -256,6 +256,12 @@ gtk_menu_class_init (GtkMenuClass *class)
                                "move_current", 1,
                                GTK_TYPE_MENU_DIRECTION_TYPE,
                                GTK_MENU_DIR_CHILD);
+
+  gtk_settings_install_property (g_param_spec_boolean ("gtk-can-change-accels",
+                                                      _("Can change accelerators"),
+                                                      _("Whether menu accelerators can be changed by pressing a key over the menu item."),
+                                                      FALSE,
+                                                      G_PARAM_READWRITE));
 }
 
 
@@ -1700,8 +1706,8 @@ gtk_menu_key_press (GtkWidget     *widget,
 {
   GtkMenuShell *menu_shell;
   GtkMenu *menu;
-  GtkAccelGroup *accel_group;
   gboolean delete = FALSE;
+  gboolean can_change_accels;
   gchar *accel = NULL;
   guint accel_key, accel_mods;
   
@@ -1710,7 +1716,6 @@ gtk_menu_key_press (GtkWidget     *widget,
       
   menu_shell = GTK_MENU_SHELL (widget);
   menu = GTK_MENU (widget);
-  accel_group = gtk_menu_get_accel_group (menu);
   
   gtk_menu_stop_navigating_submenu (menu);
 
@@ -1760,17 +1765,20 @@ gtk_menu_key_press (GtkWidget   *widget,
       break;
     }
 
+  g_object_get (G_OBJECT (gtk_settings_get_default ()),
+               "gtk-can-change-accels",
+               &can_change_accels,
+               NULL);
+  
   accel_key = event->keyval;
   accel_mods = event->state & gtk_accelerator_get_default_mod_mask ();
 
   /* Modify the accelerators */
-  if (menu_shell->active_menu_item &&
+  if (can_change_accels &&
+      menu_shell->active_menu_item &&
       GTK_BIN (menu_shell->active_menu_item)->child &&                 /* no seperators */
       GTK_MENU_ITEM (menu_shell->active_menu_item)->submenu == NULL && /* no submenus */
-      (delete ||
-       (gtk_accelerator_valid (event->keyval, event->state) &&
-       (accel_mods ||
-        (accel_key >= GDK_F1 && accel_key <= GDK_F35)))))
+      (delete || gtk_accelerator_valid (event->keyval, event->state)))
     {
       GtkWidget *menu_item = menu_shell->active_menu_item;
       gboolean replace_accels = TRUE;
@@ -1791,10 +1799,20 @@ gtk_menu_key_press (GtkWidget   *widget,
        {
          gboolean changed;
 
+         /* For the keys that act to delete the current setting, we delete
+          * the current setting if there is one, otherwise, we set the
+          * key as the accelerator.
+          */
          if (delete)
            {
-             accel_key = 0;
-             accel_mods = 0;
+             GtkAccelKey key;
+             
+             if (gtk_accel_map_lookup_entry (path, &key) &&
+                 key.accel_key || key.accel_mods)
+               {
+                 accel_key = 0;
+                 accel_mods = 0;
+               }
            }
          changed = gtk_accel_map_change_entry (path, accel_key, accel_mods, replace_accels);