gtk: Remove accel paths
authorBenjamin Otte <otte@redhat.com>
Fri, 17 Aug 2018 03:07:32 +0000 (05:07 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 26 Mar 2020 03:14:27 +0000 (23:14 -0400)
It's an outdated technology now that everybody is using GActionGroups.

If somebody wanted to support changeable shortcuts, they'd need to
reintroduce it in another way.

docs/reference/gtk/gtk4-sections.txt
gtk/gtkaccelmap.c
gtk/gtkshortcut.h
gtk/gtkwidget.c
gtk/gtkwidget.h
gtk/gtkwidgetprivate.h

index 63da1afc9ef30a93c4a2d2c620170227ea62ef1f..bcdafa64c4a449049fefdd0c04f2a1515d04ae2c 100644 (file)
@@ -4040,7 +4040,6 @@ gtk_widget_class_add_binding
 gtk_widget_class_add_binding_signal
 gtk_widget_add_accelerator
 gtk_widget_remove_accelerator
-gtk_widget_set_accel_path
 gtk_widget_list_accel_closures
 gtk_widget_can_activate_accel
 gtk_widget_activate
index 2c24d78fa8efdfc656c62760ff4aa317b55b6e48..71e021732066944d10c678e3ded41f23a65b4c8f 100644 (file)
@@ -41,7 +41,7 @@
  * SECTION:gtkaccelmap
  * @Short_description: Loadable keyboard accelerator specifications
  * @Title: Accelerator Maps
- * @See_also: #GtkAccelGroup, #GtkAccelKey, gtk_widget_set_accel_path(), gtk_menu_item_set_accel_path()
+ * @See_also: #GtkAccelGroup, #GtkAccelKey
  *
  * Accelerator maps are used to define runtime configurable accelerators.
  * Functions for manipulating them are are usually used by higher level
index a95df8d82d5edb0d981f5a6d2f4af83b7fa68cbc..fa32805ef5eb1f8833168102aa0a934098bba14f 100644 (file)
@@ -74,6 +74,11 @@ gboolean        gtk_shortcut_get_mnemonic_activate              (GtkShortcut
 GDK_AVAILABLE_IN_ALL
 void            gtk_shortcut_set_mnemonic_activate              (GtkShortcut            *self,
                                                                  gboolean                mnemonic_activate);
+GDK_AVAILABLE_IN_ALL
+gboolean        gtk_shortcut_get_activate                       (GtkShortcut            *self);
+GDK_AVAILABLE_IN_ALL
+void            gtk_shortcut_set_activate                       (GtkShortcut            *self,
+                                                                 gboolean                activate);
 
 G_END_DECLS
 
index 8e7a29e2cc31a40981cbea42970d6974b0873173..442330a29294767db679d53ee8ba40629a3b7b08 100644 (file)
@@ -688,7 +688,6 @@ static gpointer         gtk_widget_parent_class = NULL;
 static guint            widget_signals[LAST_SIGNAL] = { 0 };
 GtkTextDirection gtk_default_direction = GTK_TEXT_DIR_LTR;
 
-static GQuark          quark_accel_path = 0;
 static GQuark          quark_accel_closures = 0;
 static GQuark          quark_pango_context = 0;
 static GQuark          quark_mnemonic_labels = 0;
@@ -861,7 +860,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   g_type_class_adjust_private_offset (klass, &GtkWidget_private_offset);
   gtk_widget_parent_class = g_type_class_peek_parent (klass);
 
-  quark_accel_path = g_quark_from_static_string ("gtk-accel-path");
   quark_accel_closures = g_quark_from_static_string ("gtk-accel-closures");
   quark_pango_context = g_quark_from_static_string ("gtk-pango-context");
   quark_mnemonic_labels = g_quark_from_static_string ("gtk-mnemonic-labels");
@@ -4645,9 +4643,7 @@ widget_new_accel_closure (GtkWidget *widget,
  * The @accel_group needs to be added to the widget’s toplevel via
  * gtk_window_add_accel_group(), and the signal must be of type %G_SIGNAL_ACTION.
  * Accelerators added through this function are not user changeable during
- * runtime. If you want to support accelerators that can be changed by the
- * user, use gtk_accel_map_add_entry() and gtk_widget_set_accel_path() or
- * gtk_menu_item_set_accel_path() instead.
+ * runtime.
  */
 void
 gtk_widget_add_accelerator (GtkWidget      *widget,
@@ -4774,99 +4770,6 @@ gtk_widget_list_accel_closures (GtkWidget *widget)
   return clist;
 }
 
-typedef struct {
-  GQuark         path_quark;
-  GtkAccelGroup *accel_group;
-  GClosure      *closure;
-} AccelPath;
-
-static void
-destroy_accel_path (gpointer data)
-{
-  AccelPath *apath = data;
-
-  gtk_accel_group_disconnect (apath->accel_group, apath->closure);
-
-  /* closures_destroy takes care of unrefing the closure */
-  g_object_unref (apath->accel_group);
-
-  g_slice_free (AccelPath, apath);
-}
-
-
-/**
- * gtk_widget_set_accel_path:
- * @widget: a #GtkWidget
- * @accel_path: (allow-none): path used to look up the accelerator
- * @accel_group: (allow-none): a #GtkAccelGroup.
- *
- * Given an accelerator group, @accel_group, and an accelerator path,
- * @accel_path, sets up an accelerator in @accel_group so whenever the
- * key binding that is defined for @accel_path is pressed, @widget
- * will be activated.  This removes any accelerators (for any
- * accelerator group) installed by previous calls to
- * gtk_widget_set_accel_path(). Associating accelerators with
- * paths allows them to be modified by the user and the modifications
- * to be saved for future use. (See gtk_accel_map_save().)
- *
- * This function is a low level function that would most likely
- * be used by a menu creation system.
- *
- * If you only want to
- * set up accelerators on menu items gtk_menu_item_set_accel_path()
- * provides a somewhat more convenient interface.
- *
- * Note that @accel_path string will be stored in a #GQuark. Therefore, if you
- * pass a static string, you can save some memory by interning it first with
- * g_intern_static_string().
- **/
-void
-gtk_widget_set_accel_path (GtkWidget     *widget,
-                          const gchar   *accel_path,
-                          GtkAccelGroup *accel_group)
-{
-  AccelPath *apath;
-
-  g_return_if_fail (GTK_IS_WIDGET (widget));
-  g_return_if_fail (GTK_WIDGET_GET_CLASS (widget)->activate_signal != 0);
-
-  if (accel_path)
-    {
-      g_return_if_fail (GTK_IS_ACCEL_GROUP (accel_group));
-      g_return_if_fail (_gtk_accel_path_is_valid (accel_path));
-
-      gtk_accel_map_add_entry (accel_path, 0, 0);
-      apath = g_slice_new (AccelPath);
-      apath->accel_group = g_object_ref (accel_group);
-      apath->path_quark = g_quark_from_string (accel_path);
-      apath->closure = widget_new_accel_closure (widget, GTK_WIDGET_GET_CLASS (widget)->activate_signal);
-    }
-  else
-    apath = NULL;
-
-  /* also removes possible old settings */
-  g_object_set_qdata_full (G_OBJECT (widget), quark_accel_path, apath, destroy_accel_path);
-
-  if (apath)
-    gtk_accel_group_connect_by_path (apath->accel_group, g_quark_to_string (apath->path_quark), apath->closure);
-
-  g_signal_emit (widget, widget_signals[ACCEL_CLOSURES_CHANGED], 0);
-}
-
-const gchar*
-_gtk_widget_get_accel_path (GtkWidget *widget,
-                           gboolean  *locked)
-{
-  AccelPath *apath;
-
-  g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
-
-  apath = g_object_get_qdata (G_OBJECT (widget), quark_accel_path);
-  if (locked)
-    *locked = apath ? gtk_accel_group_get_is_locked (apath->accel_group) : TRUE;
-  return apath ? g_quark_to_string (apath->path_quark) : NULL;
-}
-
 /**
  * gtk_widget_mnemonic_activate:
  * @widget: a #GtkWidget
@@ -7768,7 +7671,6 @@ gtk_widget_real_destroy (GtkWidget *object)
     }
 
   /* wipe accelerator closures (keep order) */
-  g_object_set_qdata (G_OBJECT (widget), quark_accel_path, NULL);
   g_object_set_qdata (G_OBJECT (widget), quark_accel_closures, NULL);
 
   /* Callers of add_mnemonic_label() should disconnect on ::destroy */
index d9d0a30932069356e702bd703553d34f81ae83ad..4171ff0b98cfb5ef3af2818782be22a7668d2512 100644 (file)
@@ -414,10 +414,6 @@ gboolean   gtk_widget_remove_accelerator  (GtkWidget           *widget,
                                            guint                accel_key,
                                            GdkModifierType      accel_mods);
 GDK_AVAILABLE_IN_ALL
-void       gtk_widget_set_accel_path      (GtkWidget           *widget,
-                                           const gchar         *accel_path,
-                                           GtkAccelGroup       *accel_group);
-GDK_AVAILABLE_IN_ALL
 GList*     gtk_widget_list_accel_closures (GtkWidget           *widget);
 GDK_AVAILABLE_IN_ALL
 gboolean   gtk_widget_can_activate_accel  (GtkWidget           *widget,
index cd150136eed59ba9343212432743802097e92595..efcf1b601fe3ff0de12d92a71b6f2a9390ec34a2 100644 (file)
@@ -248,8 +248,6 @@ void         _gtk_widget_add_attached_window    (GtkWidget    *widget,
 void         _gtk_widget_remove_attached_window (GtkWidget    *widget,
                                                  GtkWindow    *window);
 
-const gchar*      _gtk_widget_get_accel_path               (GtkWidget *widget,
-                                                            gboolean  *locked);
 const GSList *    gtk_widget_class_get_shortcuts           (GtkWidgetClass *widget_class);
 
 AtkObject *       _gtk_widget_peek_accessible              (GtkWidget *widget);