summaryrefslogtreecommitdiff
path: root/gtk
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2010-09-24 11:13:30 -0400
committerMatthias Clasen <mclasen@redhat.com>2010-09-24 11:13:30 -0400
commit3c19eea34b192ac4a4a8bf22506cf29360cc0c2f (patch)
tree265670b104fb60861b66502585f9725a87ea3357 /gtk
parentb47b1428b817528b30dc6bb84d96ce85681e8aef (diff)
downloadgtk+-3c19eea34b192ac4a4a8bf22506cf29360cc0c2f.tar.gz
GtkNotebook: replace group by group_name
Dealing with bare pointers is problematic for language bindings, using interned strings is much more straightforward and more than good enough for what is needed here. http://bugzilla.gnome.org/show_bug.cgi?id=630521
Diffstat (limited to 'gtk')
-rw-r--r--gtk/gtk.symbols4
-rw-r--r--gtk/gtknotebook.c87
-rw-r--r--gtk/gtknotebook.h6
3 files changed, 49 insertions, 48 deletions
diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols
index bf535584e0..dd5b1df1ab 100644
--- a/gtk/gtk.symbols
+++ b/gtk/gtk.symbols
@@ -2066,8 +2066,8 @@ gtk_notebook_set_tab_label_text
gtk_notebook_set_tab_pos
gtk_notebook_get_tab_hborder
gtk_notebook_get_tab_vborder
-gtk_notebook_get_group
-gtk_notebook_set_group
+gtk_notebook_get_group_name
+gtk_notebook_set_group_name
gtk_notebook_get_tab_reorderable
gtk_notebook_set_tab_reorderable
gtk_notebook_get_tab_detachable
diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c
index f696906dea..ec62d458f5 100644
--- a/gtk/gtknotebook.c
+++ b/gtk/gtknotebook.c
@@ -94,7 +94,7 @@ struct _GtkNotebookPrivate
gint mouse_y;
gint pressed_button;
- gpointer group;
+ GQuark group;
guint dnd_timer;
guint switch_tab_timer;
@@ -173,7 +173,7 @@ enum {
PROP_SCROLLABLE,
PROP_PAGE,
PROP_ENABLE_POPUP,
- PROP_GROUP,
+ PROP_GROUP_NAME
};
enum {
@@ -639,18 +639,17 @@ gtk_notebook_class_init (GtkNotebookClass *class)
GTK_PARAM_READWRITE));
/**
- * GtkNotebook:group:
- *
- * Group for tabs drag and drop.
+ * GtkNotebook:group-name:
*
- * Since: 2.12
- */
+ * Group name for tab drag and drop.
+ */
g_object_class_install_property (gobject_class,
- PROP_GROUP,
- g_param_spec_pointer ("group",
- P_("Group"),
- P_("Group for tabs drag and drop"),
- GTK_PARAM_READWRITE));
+ PROP_GROUP_NAME,
+ g_param_spec_string ("group-name",
+ P_("Group Name"),
+ P_("Group name for tab drag and drop"),
+ NULL,
+ GTK_PARAM_READWRITE));
gtk_container_class_install_child_property (container_class,
CHILD_PROP_TAB_LABEL,
@@ -1073,7 +1072,7 @@ gtk_notebook_init (GtkNotebook *notebook)
priv->has_after_previous = 0;
priv->has_after_next = 1;
- priv->group = NULL;
+ priv->group = 0;
priv->pressed_button = -1;
priv->dnd_timer = 0;
priv->switch_tab_timer = 0;
@@ -1517,8 +1516,8 @@ gtk_notebook_set_property (GObject *object,
case PROP_TAB_POS:
gtk_notebook_set_tab_pos (notebook, g_value_get_enum (value));
break;
- case PROP_GROUP:
- gtk_notebook_set_group (notebook, g_value_get_pointer (value));
+ case PROP_GROUP_NAME:
+ gtk_notebook_set_group_name (notebook, g_value_get_string (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -1555,8 +1554,8 @@ gtk_notebook_get_property (GObject *object,
case PROP_TAB_POS:
g_value_set_enum (value, priv->tab_pos);
break;
- case PROP_GROUP:
- g_value_set_pointer (value, priv->group);
+ case PROP_GROUP_NAME:
+ g_value_set_string (value, gtk_notebook_get_group_name (notebook));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -3451,19 +3450,19 @@ gtk_notebook_drag_motion (GtkWidget *widget,
if (target == tab_target)
{
- gpointer widget_group, source_widget_group;
- GtkWidget *source_widget;
+ GQuark group, source_group;
+ GtkNotebook *source;
+ GtkWidget *source_child;
- source_widget = gtk_drag_get_source_widget (context);
- g_assert (source_widget);
+ source = GTK_NOTEBOOK (gtk_drag_get_source_widget (context));
+ source_child = source->priv->cur_page->child;
- widget_group = gtk_notebook_get_group (notebook);
- source_widget_group = gtk_notebook_get_group (GTK_NOTEBOOK (source_widget));
+ group = notebook->priv->group;
+ source_group = source->priv->group;
- if (widget_group && source_widget_group &&
- widget_group == source_widget_group &&
- !(widget == GTK_NOTEBOOK (source_widget)->priv->cur_page->child ||
- gtk_widget_is_ancestor (widget, GTK_NOTEBOOK (source_widget)->priv->cur_page->child)))
+ if (group != 0 && group == source_group &&
+ !(widget == source_child ||
+ gtk_widget_is_ancestor (widget, source_child)))
{
gdk_drag_status (context, GDK_ACTION_MOVE, time);
return TRUE;
@@ -7585,51 +7584,53 @@ gtk_notebook_reorder_child (GtkNotebook *notebook,
}
/**
- * gtk_notebook_set_group:
+ * gtk_notebook_set_group_name:
* @notebook: a #GtkNotebook
- * @group: (allow-none): a pointer to identify the notebook group, or %NULL to unset it
+ * @name: (allow-none): the name of the notebook group, or %NULL to unset it
+ *
+ * Sets a group name for @notebook.
*
- * Sets a group identificator pointer for @notebook, notebooks sharing
- * the same group identificator pointer will be able to exchange tabs
- * via drag and drop. A notebook with a %NULL group identificator will
+ * Notebooks with the same name will be able to exchange tabs
+ * via drag and drop. A notebook with a %NULL group name will
* not be able to exchange tabs with any other notebook.
- *
- * Since: 2.12
*/
void
-gtk_notebook_set_group (GtkNotebook *notebook,
- gpointer group)
+gtk_notebook_set_group_name (GtkNotebook *notebook,
+ const gchar *group_name)
{
GtkNotebookPrivate *priv;
+ GQuark *group;
g_return_if_fail (GTK_IS_NOTEBOOK (notebook));
priv = notebook->priv;
+ group = g_quark_from_string (group_name);
+
if (priv->group != group)
{
priv->group = group;
- g_object_notify (G_OBJECT (notebook), "group");
+ g_object_notify (G_OBJECT (notebook), "group-name");
}
}
/**
- * gtk_notebook_get_group:
+ * gtk_notebook_get_group_name:
* @notebook: a #GtkNotebook
*
- * Gets the current group identificator pointer for @notebook.
+ * Gets the current group name for @notebook.
*
- * Return Value: (transfer none): the group identificator,
+ * Return Value: (transfer none): the group name,
* or %NULL if none is set.
*
* Since: 2.12
**/
-gpointer
-gtk_notebook_get_group (GtkNotebook *notebook)
+const gchar *
+gtk_notebook_get_group_name (GtkNotebook *notebook)
{
g_return_val_if_fail (GTK_IS_NOTEBOOK (notebook), NULL);
- return notebook->priv->group;
+ return g_quark_to_string (notebook->priv->group);
}
/**
diff --git a/gtk/gtknotebook.h b/gtk/gtknotebook.h
index efbb6274db..553a4840d9 100644
--- a/gtk/gtknotebook.h
+++ b/gtk/gtknotebook.h
@@ -136,9 +136,9 @@ void gtk_notebook_remove_page (GtkNotebook *notebook,
* Tabs drag and drop *
***********************************************************/
-void gtk_notebook_set_group (GtkNotebook *notebook,
- gpointer group);
-gpointer gtk_notebook_get_group (GtkNotebook *notebook);
+void gtk_notebook_set_group_name (GtkNotebook *notebook,
+ const gchar *group_name);
+const gchar *gtk_notebook_get_group_name (GtkNotebook *notebook);