summaryrefslogtreecommitdiff
path: root/gtk/gtkaccellabel.c
diff options
context:
space:
mode:
authorJames Henstridge <james@daa.com.au>2001-07-25 13:36:02 +0000
committerJames Henstridge <jamesh@src.gnome.org>2001-07-25 13:36:02 +0000
commite70939234cf3af180b4d2a695a0076b4538a3889 (patch)
tree5e26f207b4f43cc10ee5445ca8083138fb86b66c /gtk/gtkaccellabel.c
parentafacc246f17fa078fa9a47f7496d570a1b0f97c8 (diff)
downloadgtk+-e70939234cf3af180b4d2a695a0076b4538a3889.tar.gz
commiting patch after comments from Alex on IRC
2001-07-15 James Henstridge <james@daa.com.au> * gtk/gtkwindow.c (gtk_window_add_accel_group): cast to GObject. (gtk_window_remove_accel_group): same here. (gtk_window_key_press_event): same here. * gtk/gtkwidget.c (gtk_widget_add_accelerator): cast to GObject. (gtk_widget_remove_accelerator): same here. (gtk_widget_remove_accelerators): same here. * gtk/gtkplug.c (gtk_plug_accel_entries_changed): same here. * gtk/gtkmenushell.c (gtk_menu_shell_key_press): cast to GObject instead of GtkObject. * gtk/gtkmenu.c (gtk_menu_key_press): update since GtkAccelGroup now takes GObjects. * gtk/gtkitemfactory.c (gtk_item_factory_propagate_accelerator): pass a GObject to gtk_accel_group_entries_from_object. (gtk_item_factory_create_item): s/accel_widget/accel_object/ * gtk/gtk-boxed.defs: remove GtkAccelGroup boxed def. * gtk/gtkaccellabel.c: convert to handle GObject accel objects. * gtk/gtkaccellabel.h: fix header to reflect that arbitrary GObjects can have accelerators set now. Add compatibility defines. * gtk/gtkmarshal.list: add missing marshallers. * gtk/gtkaccelgroup.[ch]: convert to a GObject, and allow setting accelerators on plain GObjects. gtk_accel_group_object_destroy has been converted into a weak reference, and gtk_accel_group_delete_entries is now a destroy notify for that piece of data.
Diffstat (limited to 'gtk/gtkaccellabel.c')
-rw-r--r--gtk/gtkaccellabel.c87
1 files changed, 44 insertions, 43 deletions
diff --git a/gtk/gtkaccellabel.c b/gtk/gtkaccellabel.c
index f9adfc5ef6..36397f3132 100644
--- a/gtk/gtkaccellabel.c
+++ b/gtk/gtkaccellabel.c
@@ -36,7 +36,7 @@
enum {
PROP_0,
- PROP_ACCEL_WIDGET
+ PROP_ACCEL_OBJECT
};
static void gtk_accel_label_class_init (GtkAccelLabelClass *klass);
@@ -110,11 +110,11 @@ gtk_accel_label_class_init (GtkAccelLabelClass *class)
object_class->destroy = gtk_accel_label_destroy;
g_object_class_install_property (G_OBJECT_CLASS(object_class),
- PROP_ACCEL_WIDGET,
- g_param_spec_object ("accel_widget",
- _("Accelerator widget"),
- _("The widget monitored by this accelerator label"),
- GTK_TYPE_WIDGET,
+ PROP_ACCEL_OBJECT,
+ g_param_spec_object ("accel_object",
+ _("Accelerator object"),
+ _("The object monitored by this accelerator label"),
+ G_TYPE_OBJECT,
G_PARAM_READABLE | G_PARAM_WRITABLE));
@@ -143,8 +143,8 @@ gtk_accel_label_set_property (GObject *object,
switch (prop_id)
{
- case PROP_ACCEL_WIDGET:
- gtk_accel_label_set_accel_widget (accel_label, (GtkWidget*) g_value_get_object (value));
+ case PROP_ACCEL_OBJECT:
+ gtk_accel_label_set_accel_object (accel_label, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -163,8 +163,8 @@ static void gtk_accel_label_get_property (GObject *object,
switch (prop_id)
{
- case PROP_ACCEL_WIDGET:
- g_value_set_object (value, G_OBJECT (accel_label->accel_widget));
+ case PROP_ACCEL_OBJECT:
+ g_value_set_object (value, accel_label->accel_object);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -177,7 +177,7 @@ gtk_accel_label_init (GtkAccelLabel *accel_label)
{
accel_label->queue_id = 0;
accel_label->accel_padding = 3;
- accel_label->accel_widget = NULL;
+ accel_label->accel_object = NULL;
accel_label->accel_string = NULL;
gtk_accel_label_refetch (accel_label);
@@ -206,7 +206,7 @@ gtk_accel_label_destroy (GtkObject *object)
accel_label = GTK_ACCEL_LABEL (object);
- gtk_accel_label_set_accel_widget (accel_label, NULL);
+ gtk_accel_label_set_accel_object (accel_label, NULL);
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -226,21 +226,21 @@ gtk_accel_label_finalize (GObject *object)
}
/**
- * gtk_accel_label_get_accel_widget:
+ * gtk_accel_label_get_accel_object:
* @accel_label: a #GtkAccelLabel
*
* Fetches the widget monitored by this accelerator label. See
- * gtk_accel_label_set_accel_widget().
+ * gtk_accel_label_set_accel_object().
*
- * Return value: the widget monitored by the accelerator label,
+ * Return value: the object monitored by the accelerator label,
* or %NULL.
**/
-GtkWidget *
-gtk_accel_label_get_accel_widget (GtkAccelLabel *accel_label)
+GObject *
+gtk_accel_label_get_accel_object (GtkAccelLabel *accel_label)
{
g_return_val_if_fail (GTK_IS_ACCEL_LABEL (accel_label), NULL);
- return accel_label->accel_widget;
+ return accel_label->accel_object;
}
guint
@@ -348,41 +348,42 @@ gtk_accel_label_queue_refetch (GtkAccelLabel *accel_label)
}
void
-gtk_accel_label_set_accel_widget (GtkAccelLabel *accel_label,
- GtkWidget *accel_widget)
+gtk_accel_label_set_accel_object (GtkAccelLabel *accel_label,
+ GObject *accel_object)
{
g_return_if_fail (GTK_IS_ACCEL_LABEL (accel_label));
- if (accel_widget != NULL)
- g_return_if_fail (GTK_IS_WIDGET (accel_widget));
-
- if (accel_widget != accel_label->accel_widget)
+ g_return_if_fail (accel_object == NULL || G_IS_OBJECT (accel_object));
+
+ if (accel_object != accel_label->accel_object)
{
- if (accel_label->accel_widget)
+ if (accel_label->accel_object)
{
- gtk_signal_disconnect_by_func (GTK_OBJECT (accel_label->accel_widget),
- GTK_SIGNAL_FUNC (gtk_accel_label_queue_refetch),
- accel_label);
- gtk_widget_unref (accel_label->accel_widget);
+ g_signal_handlers_disconnect_by_func (accel_label->accel_object,
+ G_CALLBACK (gtk_accel_label_queue_refetch),
+ accel_object);
+ g_object_unref (accel_label->accel_object);
}
if (accel_label->queue_id)
{
gtk_idle_remove (accel_label->queue_id);
accel_label->queue_id = 0;
}
- accel_label->accel_widget = accel_widget;
- if (accel_label->accel_widget)
+ accel_label->accel_object = accel_object;
+ if (accel_label->accel_object)
{
- gtk_widget_ref (accel_label->accel_widget);
- gtk_signal_connect_object_after (GTK_OBJECT (accel_label->accel_widget),
- "add-accelerator",
- GTK_SIGNAL_FUNC (gtk_accel_label_queue_refetch),
- GTK_OBJECT (accel_label));
- gtk_signal_connect_object_after (GTK_OBJECT (accel_label->accel_widget),
- "remove-accelerator",
- GTK_SIGNAL_FUNC (gtk_accel_label_queue_refetch),
- GTK_OBJECT (accel_label));
+ g_object_ref (accel_label->accel_object);
+ g_signal_connect_object (accel_label->accel_object,
+ "add-accelerator",
+ G_CALLBACK (gtk_accel_label_queue_refetch),
+ accel_label,
+ G_CONNECT_AFTER | G_CONNECT_SWAPPED);
+ g_signal_connect_object (accel_label->accel_object,
+ "remove-accelerator",
+ G_CALLBACK (gtk_accel_label_queue_refetch),
+ accel_label,
+ G_CONNECT_AFTER | G_CONNECT_SWAPPED);
}
- g_object_notify (G_OBJECT (accel_label), "accel_widget");
+ g_object_notify (G_OBJECT (accel_label), "accel_object");
}
}
@@ -410,12 +411,12 @@ gtk_accel_label_refetch (GtkAccelLabel *accel_label)
g_free (accel_label->accel_string);
accel_label->accel_string = NULL;
- if (accel_label->accel_widget)
+ if (accel_label->accel_object)
{
GtkAccelEntry *entry = NULL;
GSList *slist;
- slist = gtk_accel_group_entries_from_object (GTK_OBJECT (accel_label->accel_widget));
+ slist = gtk_accel_group_entries_from_object (accel_label->accel_object);
for (; slist; slist = slist->next)
{
entry = slist->data;