Merge branch 'otte/for-master' into 'master'

Otte/for master

See merge request GNOME/gtk!1333
This commit is contained in:
Benjamin Otte 2020-01-21 12:09:26 +00:00
commit 631ea5caac
18 changed files with 29 additions and 429 deletions

View File

@ -262,7 +262,7 @@ draw_menu (GtkWidget *widget,
gint toggle_x, toggle_y, toggle_width, toggle_height;
/* This information is taken from the GtkMenu docs, see "CSS nodes" */
menu_context = get_style (gtk_widget_get_style_context(widget), "menu");
menu_context = get_style (NULL, "menu");
hovermenuitem_context = get_style (menu_context, "menuitem:hover");
hoveredarrowmenuitem_context = get_style (hovermenuitem_context, "arrow.right:dir(ltr)");
menuitem_context = get_style (menu_context, "menuitem");

View File

@ -775,7 +775,6 @@ gtk_container_add
gtk_container_remove
gtk_container_foreach
gtk_container_get_children
gtk_container_get_path_for_child
gtk_container_get_focus_vadjustment
gtk_container_set_focus_vadjustment
gtk_container_get_focus_hadjustment
@ -4412,7 +4411,6 @@ gtk_widget_get_layout_manager
gtk_widget_should_layout
<SUBSECTION>
gtk_widget_get_path
gtk_widget_get_style_context
gtk_widget_reset_style
gtk_widget_class_get_css_name

View File

@ -109,9 +109,6 @@ static void gtk_box_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
static GType gtk_box_child_type (GtkContainer *container);
static GtkWidgetPath * gtk_box_get_path_for_child
(GtkContainer *container,
GtkWidget *child);
G_DEFINE_TYPE_WITH_CODE (GtkBox, gtk_box, GTK_TYPE_CONTAINER,
G_ADD_PRIVATE (GtkBox)
@ -131,7 +128,6 @@ gtk_box_class_init (GtkBoxClass *class)
container_class->remove = gtk_box_remove;
container_class->forall = gtk_box_forall;
container_class->child_type = gtk_box_child_type;
container_class->get_path_for_child = gtk_box_get_path_for_child;
g_object_class_override_property (object_class,
PROP_ORIENTATION,
@ -242,105 +238,6 @@ gtk_box_child_type (GtkContainer *container)
return GTK_TYPE_WIDGET;
}
typedef struct _CountingData CountingData;
struct _CountingData {
GtkWidget *widget;
gboolean found;
guint before;
guint after;
};
static void
count_widget_position (GtkWidget *widget,
gpointer data)
{
CountingData *count = data;
if (!_gtk_widget_get_visible (widget))
return;
if (count->widget == widget)
count->found = TRUE;
else if (count->found)
count->after++;
else
count->before++;
}
static gint
gtk_box_get_visible_position (GtkBox *box,
GtkWidget *child)
{
CountingData count = { child, FALSE, 0, 0 };
GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
/* foreach iterates in visible order */
gtk_container_foreach (GTK_CONTAINER (box),
count_widget_position,
&count);
/* the child wasn't found, it's likely an internal child of some
* subclass, return -1 to indicate that there is no sibling relation
* to the regular box children
*/
if (!count.found)
return -1;
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
return count.after;
else
return count.before;
}
static GtkWidgetPath *
gtk_box_get_path_for_child (GtkContainer *container,
GtkWidget *child)
{
GtkWidgetPath *path, *sibling_path;
GtkBox *box = GTK_BOX (container);
GtkBoxPrivate *priv = gtk_box_get_instance_private (box);
GList *list, *children;
path = _gtk_widget_create_path (GTK_WIDGET (container));
if (_gtk_widget_get_visible (child))
{
gint position;
sibling_path = gtk_widget_path_new ();
/* get_children works in visible order */
children = gtk_container_get_children (container);
if (priv->orientation == GTK_ORIENTATION_HORIZONTAL &&
_gtk_widget_get_direction (GTK_WIDGET (box)) == GTK_TEXT_DIR_RTL)
children = g_list_reverse (children);
for (list = children; list; list = list->next)
{
if (!_gtk_widget_get_visible (list->data))
continue;
gtk_widget_path_append_for_widget (sibling_path, list->data);
}
g_list_free (children);
position = gtk_box_get_visible_position (box, child);
if (position >= 0)
gtk_widget_path_append_with_siblings (path, sibling_path, position);
else
gtk_widget_path_append_for_widget (path, child);
gtk_widget_path_unref (sibling_path);
}
else
gtk_widget_path_append_for_widget (path, child);
return path;
}
static void
gtk_box_init (GtkBox *box)
{

View File

@ -115,9 +115,6 @@ static void gtk_container_children_callback (GtkWidget *widget,
gpointer client_data);
static GtkSizeRequestMode gtk_container_get_request_mode (GtkWidget *widget);
static GtkWidgetPath * gtk_container_real_get_path_for_child (GtkContainer *container,
GtkWidget *child);
/* GtkBuildable */
static void gtk_container_buildable_init (GtkBuildableIface *iface);
static GtkBuildableIface *parent_buildable_iface;
@ -149,7 +146,6 @@ gtk_container_class_init (GtkContainerClass *class)
class->forall = NULL;
class->set_focus_child = gtk_container_real_set_focus_child;
class->child_type = NULL;
class->get_path_for_child = gtk_container_real_get_path_for_child;
container_signals[ADD] =
g_signal_new (I_("add"),
@ -651,18 +647,6 @@ gtk_container_real_set_focus_child (GtkContainer *container,
}
}
static GtkWidgetPath *
gtk_container_real_get_path_for_child (GtkContainer *container,
GtkWidget *child)
{
GtkWidgetPath *path;
path = _gtk_widget_create_path (GTK_WIDGET (container));
gtk_widget_path_append_for_widget (path, child);
return path;
}
static void
gtk_container_children_callback (GtkWidget *widget,
gpointer client_data)
@ -783,35 +767,3 @@ gtk_container_get_focus_hadjustment (GtkContainer *container)
return hadjustment;
}
/**
* gtk_container_get_path_for_child:
* @container: a #GtkContainer
* @child: a child of @container
*
* Returns a newly created widget path representing all the widget hierarchy
* from the toplevel down to and including @child.
*
* Returns: A newly created #GtkWidgetPath
**/
GtkWidgetPath *
gtk_container_get_path_for_child (GtkContainer *container,
GtkWidget *child)
{
GtkWidgetPath *path;
g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL);
g_return_val_if_fail (GTK_IS_WIDGET (child), NULL);
g_return_val_if_fail (container == (GtkContainer *) _gtk_widget_get_parent (child), NULL);
path = GTK_CONTAINER_GET_CLASS (container)->get_path_for_child (container, child);
if (gtk_widget_path_get_object_type (path) != G_OBJECT_TYPE (child))
{
g_critical ("%s %p returned a widget path for type %s, but child is %s",
G_OBJECT_TYPE_NAME (container),
container,
g_type_name (gtk_widget_path_get_object_type (path)),
G_OBJECT_TYPE_NAME (child));
}
return path;
}

View File

@ -62,8 +62,6 @@ struct _GtkContainer
* @child_type: Returns the type of the children supported by the container.
* @set_child_property: Set a property on a child of container.
* @get_child_property: Get a property from a child of container.
* @get_path_for_child: Get path representing entire widget hierarchy
* from the toplevel down to and including @child.
*
* Base class for containers.
*/
@ -83,8 +81,6 @@ struct _GtkContainerClass
void (*set_focus_child) (GtkContainer *container,
GtkWidget *child);
GType (*child_type) (GtkContainer *container);
GtkWidgetPath * (*get_path_for_child) (GtkContainer *container,
GtkWidget *child);
/*< private >*/
@ -132,10 +128,6 @@ void gtk_container_forall (GtkContainer *container,
GtkCallback callback,
gpointer callback_data);
GDK_AVAILABLE_IN_ALL
GtkWidgetPath * gtk_container_get_path_for_child (GtkContainer *container,
GtkWidget *child);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkContainer, g_object_unref)
G_END_DECLS

View File

@ -512,18 +512,6 @@ gtk_css_node_real_init_matcher (GtkCssNode *cssnode,
return TRUE;
}
static GtkWidgetPath *
gtk_css_node_real_create_widget_path (GtkCssNode *cssnode)
{
return gtk_widget_path_new ();
}
static const GtkWidgetPath *
gtk_css_node_real_get_widget_path (GtkCssNode *cssnode)
{
return NULL;
}
static GtkStyleProvider *
gtk_css_node_real_get_style_provider (GtkCssNode *cssnode)
{
@ -604,8 +592,6 @@ gtk_css_node_class_init (GtkCssNodeClass *klass)
klass->queue_validate = gtk_css_node_real_queue_validate;
klass->dequeue_validate = gtk_css_node_real_dequeue_validate;
klass->init_matcher = gtk_css_node_real_init_matcher;
klass->create_widget_path = gtk_css_node_real_create_widget_path;
klass->get_widget_path = gtk_css_node_real_get_widget_path;
klass->get_style_provider = gtk_css_node_real_get_style_provider;
klass->get_frame_clock = gtk_css_node_real_get_frame_clock;
@ -1435,18 +1421,6 @@ gtk_css_node_init_matcher (GtkCssNode *cssnode,
return GTK_CSS_NODE_GET_CLASS (cssnode)->init_matcher (cssnode, matcher);
}
GtkWidgetPath *
gtk_css_node_create_widget_path (GtkCssNode *cssnode)
{
return GTK_CSS_NODE_GET_CLASS (cssnode)->create_widget_path (cssnode);
}
const GtkWidgetPath *
gtk_css_node_get_widget_path (GtkCssNode *cssnode)
{
return GTK_CSS_NODE_GET_CLASS (cssnode)->get_widget_path (cssnode);
}
GtkStyleProvider *
gtk_css_node_get_style_provider (GtkCssNode *cssnode)
{

View File

@ -78,8 +78,6 @@ struct _GtkCssNodeClass
gboolean (* init_matcher) (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
GtkWidgetPath * (* create_widget_path) (GtkCssNode *cssnode);
const GtkWidgetPath * (* get_widget_path) (GtkCssNode *cssnode);
/* get style provider to use or NULL to use parent's */
GtkStyleProvider * (* get_style_provider) (GtkCssNode *cssnode);
/* get frame clock or NULL (only relevant for root node) */
@ -157,8 +155,6 @@ void gtk_css_node_validate (GtkCssNode *
gboolean gtk_css_node_init_matcher (GtkCssNode *cssnode,
GtkCssMatcher *matcher);
GtkWidgetPath * gtk_css_node_create_widget_path (GtkCssNode *cssnode);
const GtkWidgetPath * gtk_css_node_get_widget_path (GtkCssNode *cssnode) G_GNUC_PURE;
GtkStyleProvider * gtk_css_node_get_style_provider (GtkCssNode *cssnode) G_GNUC_PURE;
void gtk_css_node_print (GtkCssNode *cssnode,

View File

@ -59,37 +59,6 @@ gtk_css_path_node_real_init_matcher (GtkCssNode *node,
gtk_css_node_get_declaration (node));
}
static GtkWidgetPath *
gtk_css_path_node_real_create_widget_path (GtkCssNode *node)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
GtkWidgetPath *path;
guint length;
if (path_node->path == NULL)
path = gtk_widget_path_new ();
else
path = gtk_widget_path_copy (path_node->path);
length = gtk_widget_path_length (path);
if (length > 0)
{
gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node),
path,
length - 1);
}
return path;
}
static const GtkWidgetPath *
gtk_css_path_node_real_get_widget_path (GtkCssNode *node)
{
GtkCssPathNode *path_node = GTK_CSS_PATH_NODE (node);
return path_node->path;
}
static GtkCssStyle *
gtk_css_path_node_update_style (GtkCssNode *cssnode,
GtkCssChange change,
@ -122,8 +91,6 @@ gtk_css_path_node_class_init (GtkCssPathNodeClass *klass)
node_class->invalidate = gtk_css_path_node_invalidate;
node_class->update_style = gtk_css_path_node_update_style;
node_class->init_matcher = gtk_css_path_node_real_init_matcher;
node_class->create_widget_path = gtk_css_path_node_real_create_widget_path;
node_class->get_widget_path = gtk_css_path_node_real_get_widget_path;
node_class->get_style_provider = gtk_css_path_node_get_style_provider;
}

View File

@ -22,36 +22,6 @@
G_DEFINE_TYPE (GtkCssTransientNode, gtk_css_transient_node, GTK_TYPE_CSS_NODE)
static GtkWidgetPath *
gtk_css_transient_node_create_widget_path (GtkCssNode *node)
{
GtkWidgetPath *result;
GtkCssNode *parent;
parent = gtk_css_node_get_parent (node);
if (parent == NULL)
result = gtk_widget_path_new ();
else
result = gtk_css_node_create_widget_path (parent);
gtk_widget_path_append_type (result, gtk_css_node_get_widget_type (node));
gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node), result, -1);
return result;
}
static const GtkWidgetPath *
gtk_css_transient_node_get_widget_path (GtkCssNode *node)
{
GtkCssNode *parent;
parent = gtk_css_node_get_parent (node);
if (parent == NULL)
return NULL;
return gtk_css_node_get_widget_path (parent);
}
static GtkCssStyle *
gtk_css_transient_node_update_style (GtkCssNode *cssnode,
GtkCssChange change,
@ -67,8 +37,6 @@ gtk_css_transient_node_class_init (GtkCssTransientNodeClass *klass)
{
GtkCssNodeClass *node_class = GTK_CSS_NODE_CLASS (klass);
node_class->create_widget_path = gtk_css_transient_node_create_widget_path;
node_class->get_widget_path = gtk_css_transient_node_get_widget_path;
node_class->update_style = gtk_css_transient_node_update_style;
}

View File

@ -38,20 +38,6 @@ gtk_css_widget_node_finalize (GObject *object)
G_OBJECT_CLASS (gtk_css_widget_node_parent_class)->finalize (object);
}
static void
gtk_css_widget_node_style_changed (GtkCssNode *cssnode,
GtkCssStyleChange *change)
{
GtkCssWidgetNode *node;
node = GTK_CSS_WIDGET_NODE (cssnode);
if (node->widget)
gtk_widget_clear_path (node->widget);
GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->style_changed (cssnode, change);
}
static gboolean
gtk_css_widget_node_queue_callback (GtkWidget *widget,
GdkFrameClock *frame_clock,
@ -133,40 +119,6 @@ gtk_css_widget_node_init_matcher (GtkCssNode *node,
return GTK_CSS_NODE_CLASS (gtk_css_widget_node_parent_class)->init_matcher (node, matcher);
}
static GtkWidgetPath *
gtk_css_widget_node_create_widget_path (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkWidgetPath *path;
guint length;
if (widget_node->widget == NULL)
path = gtk_widget_path_new ();
else
path = _gtk_widget_create_path (widget_node->widget);
length = gtk_widget_path_length (path);
if (length > 0)
{
gtk_css_node_declaration_add_to_widget_path (gtk_css_node_get_declaration (node),
path,
length - 1);
}
return path;
}
static const GtkWidgetPath *
gtk_css_widget_node_get_widget_path (GtkCssNode *node)
{
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
if (widget_node->widget == NULL)
return NULL;
return gtk_widget_get_path (widget_node->widget);
}
static GtkStyleProvider *
gtk_css_widget_node_get_style_provider (GtkCssNode *node)
{
@ -211,11 +163,8 @@ gtk_css_widget_node_class_init (GtkCssWidgetNodeClass *klass)
node_class->queue_validate = gtk_css_widget_node_queue_validate;
node_class->dequeue_validate = gtk_css_widget_node_dequeue_validate;
node_class->init_matcher = gtk_css_widget_node_init_matcher;
node_class->create_widget_path = gtk_css_widget_node_create_widget_path;
node_class->get_widget_path = gtk_css_widget_node_get_widget_path;
node_class->get_style_provider = gtk_css_widget_node_get_style_provider;
node_class->get_frame_clock = gtk_css_widget_node_get_frame_clock;
node_class->style_changed = gtk_css_widget_node_style_changed;
}
static void

View File

@ -924,13 +924,10 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
}
style = gtk_widget_get_style_context (widget);
gtk_style_context_save (style);
gtk_style_context_set_state (style, GTK_STATE_FLAG_NORMAL);
gtk_style_context_get (style,
"font",
&font_desc,
NULL);
gtk_style_context_restore (style);
if (lang[0])
{

View File

@ -234,18 +234,21 @@ gtk_radio_button_class_init (GtkRadioButtonClass *class)
}
static void
gtk_radio_button_init (GtkRadioButton *radio_button)
gtk_radio_button_init (GtkRadioButton *self)
{
GtkRadioButtonPrivate *priv = gtk_radio_button_get_instance_private (radio_button);
GtkRadioButtonPrivate *priv = gtk_radio_button_get_instance_private (self);
GtkWidget *widget = GTK_WIDGET (self);
GtkCssNode *css_node;
gtk_widget_set_receives_default (GTK_WIDGET (radio_button), FALSE);
gtk_widget_set_receives_default (widget, FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (radio_button), TRUE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self), TRUE);
priv->group = g_slist_prepend (NULL, radio_button);
priv->group = g_slist_prepend (NULL, self);
css_node = gtk_check_button_get_indicator_node (GTK_CHECK_BUTTON (radio_button));
css_node = gtk_widget_get_css_node (widget);
gtk_css_node_set_name (css_node, I_("radiobutton"));
css_node = gtk_check_button_get_indicator_node (GTK_CHECK_BUTTON (self));
gtk_css_node_set_name (css_node, I_("radio"));
}

View File

@ -970,14 +970,26 @@ gtk_style_context_set_path (GtkStyleContext *context,
* gtk_style_context_get_path:
* @context: a #GtkStyleContext
*
* Returns the widget path used for style matching.
* Returns the widget path used for style matching set via
* gtk_style_context_set_path().
*
* Returns: (transfer none): A #GtkWidgetPath
* If no path has been set - in particular if this style context
* was returned from a #GtkWidget - this function returns %NULL.
*
* Returns: (transfer none) (nullable): A #GtkWidgetPath or %NULL
**/
const GtkWidgetPath *
gtk_style_context_get_path (GtkStyleContext *context)
{
return gtk_css_node_get_widget_path (gtk_style_context_get_root (context));
GtkCssNode *root;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
root = gtk_style_context_get_root (context);
if (!GTK_IS_CSS_PATH_NODE (root))
return NULL;
return gtk_css_path_node_get_widget_path (GTK_CSS_PATH_NODE (root));
}
/**

View File

@ -1637,6 +1637,7 @@ gtk_text_view_init (GtkTextView *text_view)
priv->indent = 0;
priv->tabs = NULL;
priv->editable = TRUE;
priv->cursor_alpha = 1.0;
priv->scroll_after_paste = FALSE;

View File

@ -592,7 +592,6 @@ static void gtk_widget_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gtk_widget_constructed (GObject *object);
static void gtk_widget_dispose (GObject *object);
static void gtk_widget_real_destroy (GtkWidget *object);
static void gtk_widget_finalize (GObject *object);
@ -718,7 +717,6 @@ static GQuark quark_mnemonic_labels = 0;
static GQuark quark_tooltip_markup = 0;
static GQuark quark_size_groups = 0;
static GQuark quark_auto_children = 0;
static GQuark quark_widget_path = 0;
static GQuark quark_action_muxer = 0;
static GQuark quark_font_options = 0;
static GQuark quark_font_map = 0;
@ -876,12 +874,10 @@ gtk_widget_class_init (GtkWidgetClass *klass)
quark_tooltip_markup = g_quark_from_static_string ("gtk-tooltip-markup");
quark_size_groups = g_quark_from_static_string ("gtk-widget-size-groups");
quark_auto_children = g_quark_from_static_string ("gtk-widget-auto-children");
quark_widget_path = g_quark_from_static_string ("gtk-widget-path");
quark_action_muxer = g_quark_from_static_string ("gtk-widget-action-muxer");
quark_font_options = g_quark_from_static_string ("gtk-widget-font-options");
quark_font_map = g_quark_from_static_string ("gtk-widget-font-map");
gobject_class->constructed = gtk_widget_constructed;
gobject_class->dispose = gtk_widget_dispose;
gobject_class->finalize = gtk_widget_finalize;
gobject_class->set_property = gtk_widget_set_property;
@ -1910,8 +1906,6 @@ gtk_widget_set_property (GObject *object,
case PROP_CSS_NAME:
if (g_value_get_string (value) != NULL)
gtk_css_node_set_name (priv->cssnode, g_intern_string (g_value_get_string (value)));
else
gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_GET_CLASS (widget)->priv->css_name);
break;
case PROP_LAYOUT_MANAGER:
gtk_widget_set_layout_manager (widget, g_value_dup_object (value));
@ -2445,7 +2439,8 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->cssnode = gtk_css_widget_node_new (widget);
gtk_css_node_set_state (priv->cssnode, priv->state_flags);
gtk_css_node_set_visible (priv->cssnode, priv->visible);
/* need to set correct type here, and only class has the correct type here */
/* need to set correct name here, and only class has the correct type here */
gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_CLASS (g_class)->priv->css_name);
gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
if (g_type_is_a (G_TYPE_FROM_CLASS (g_class), GTK_TYPE_ROOT))
@ -6321,7 +6316,7 @@ reset_style_recurse (GtkWidget *widget, gpointer user_data)
* Updates the style context of @widget and all descendants
* by updating its widget path. #GtkContainers may want
* to use this on a child when reordering it in a way that a different
* style might apply to it. See also gtk_container_get_path_for_child().
* style might apply to it.
*/
void
gtk_widget_reset_style (GtkWidget *widget)
@ -7462,24 +7457,6 @@ gtk_widget_get_default_direction (void)
return gtk_default_direction;
}
static void
gtk_widget_constructed (GObject *object)
{
GtkWidget *widget = GTK_WIDGET (object);
GtkWidgetPath *path;
/* As strange as it may seem, this may happen on object construction.
* init() implementations of parent types may eventually call this function,
* each with its corresponding GType, which could leave a child
* implementation with a wrong widget type in the widget path
*/
path = (GtkWidgetPath*)g_object_get_qdata (object, quark_widget_path);
if (path && G_OBJECT_TYPE (widget) != gtk_widget_path_get_object_type (path))
g_object_set_qdata (object, quark_widget_path, NULL);
G_OBJECT_CLASS (gtk_widget_parent_class)->constructed (object);
}
static void
gtk_widget_dispose (GObject *object)
{
@ -7701,8 +7678,6 @@ gtk_widget_finalize (GObject *object)
g_clear_pointer (&priv->transform, gsk_transform_unref);
g_clear_pointer (&priv->allocated_transform, gsk_transform_unref);
gtk_widget_clear_path (widget);
gtk_css_widget_node_widget_destroyed (GTK_CSS_WIDGET_NODE (priv->cssnode));
g_object_unref (priv->cssnode);
@ -11243,79 +11218,6 @@ gtk_widget_path_append_for_widget (GtkWidgetPath *path,
return pos;
}
GtkWidgetPath *
_gtk_widget_create_path (GtkWidget *widget)
{
GtkWidget *parent = _gtk_widget_get_parent (widget);
if (parent && GTK_IS_CONTAINER (parent))
return gtk_container_get_path_for_child (GTK_CONTAINER (parent), widget);
else if (parent)
{
GtkWidgetPath *path = _gtk_widget_create_path (parent);
gtk_widget_path_append_for_widget (path, widget);
return path;
}
else
{
/* Widget is either toplevel or unparented, treat both
* as toplevels style wise, since there are situations
* where style properties might be retrieved on that
* situation.
*/
GtkWidget *attach_widget = NULL;
GtkWidgetPath *result;
if (GTK_IS_WINDOW (widget))
attach_widget = gtk_window_get_attached_to (GTK_WINDOW (widget));
if (attach_widget != NULL)
result = gtk_widget_path_copy (gtk_widget_get_path (attach_widget));
else
result = gtk_widget_path_new ();
gtk_widget_path_append_for_widget (result, widget);
return result;
}
}
/**
* gtk_widget_get_path:
* @widget: a #GtkWidget
*
* Returns the #GtkWidgetPath representing @widget, if the widget
* is not connected to a toplevel widget, a partial path will be
* created.
*
* Returns: (transfer none): The #GtkWidgetPath representing @widget
**/
GtkWidgetPath *
gtk_widget_get_path (GtkWidget *widget)
{
GtkWidgetPath *path;
g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL);
path = (GtkWidgetPath*)g_object_get_qdata (G_OBJECT (widget), quark_widget_path);
if (!path)
{
path = _gtk_widget_create_path (widget);
g_object_set_qdata_full (G_OBJECT (widget),
quark_widget_path,
path,
(GDestroyNotify)gtk_widget_path_free);
}
return path;
}
void
gtk_widget_clear_path (GtkWidget *widget)
{
g_object_set_qdata (G_OBJECT (widget), quark_widget_path, NULL);
}
/**
* gtk_widget_class_set_css_name:
* @widget_class: class to set the name on

View File

@ -764,9 +764,6 @@ gboolean gtk_widget_in_destruction (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
GtkStyleContext * gtk_widget_get_style_context (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
GtkWidgetPath * gtk_widget_get_path (GtkWidget *widget);
GDK_AVAILABLE_IN_ALL
void gtk_widget_class_set_css_name (GtkWidgetClass *widget_class,
const char *name);

View File

@ -278,8 +278,6 @@ GtkStyleContext * _gtk_widget_peek_style_context (GtkWidget *widget);
gboolean _gtk_widget_captured_event (GtkWidget *widget,
GdkEvent *event);
GtkWidgetPath * _gtk_widget_create_path (GtkWidget *widget);
void gtk_widget_clear_path (GtkWidget *widget);
void _gtk_widget_style_context_invalidated (GtkWidget *widget);
void _gtk_widget_update_parent_muxer (GtkWidget *widget);

View File

@ -566,20 +566,17 @@ create_radio_buttons (GtkWidget *widget)
gtk_container_add (GTK_CONTAINER (box1), box2);
button = gtk_radio_button_new_with_label (NULL, "button4");
gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_radio_button_new_with_label (
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
"button5");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (box2), button);
button = gtk_radio_button_new_with_label (
gtk_radio_button_get_group (GTK_RADIO_BUTTON (button)),
"button6");
gtk_check_button_set_draw_indicator (GTK_CHECK_BUTTON (button), FALSE);
gtk_container_add (GTK_CONTAINER (box2), button);
separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL);