2010-03-12 17:55:54 +00:00
|
|
|
/* GTK - The GIMP Toolkit
|
|
|
|
* Copyright (C) 2010 Carlos Garnacho <carlosg@gnome.org>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
2012-02-27 13:01:10 +00:00
|
|
|
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
2010-03-12 17:55:54 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
#include "gtkwidgetpath.h"
|
|
|
|
|
2010-03-12 17:55:54 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
#include "gtkcssnodedeclarationprivate.h"
|
|
|
|
#include "gtkprivate.h"
|
2011-01-23 23:29:07 +00:00
|
|
|
#include "gtkstylecontextprivate.h"
|
2014-07-21 23:49:11 +00:00
|
|
|
#include "gtktypebuiltins.h"
|
2015-09-12 00:59:38 +00:00
|
|
|
#include "gtkwidget.h"
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* SECTION:gtkwidgetpath
|
|
|
|
* @Short_description: Widget path abstraction
|
|
|
|
* @Title: GtkWidgetPath
|
|
|
|
* @See_also: #GtkStyleContext
|
|
|
|
*
|
2010-11-26 01:48:52 +00:00
|
|
|
* GtkWidgetPath is a boxed type that represents a widget hierarchy from
|
2010-10-19 08:59:46 +00:00
|
|
|
* the topmost widget, typically a toplevel, to any child. This widget
|
|
|
|
* path abstraction is used in #GtkStyleContext on behalf of the real
|
|
|
|
* widget in order to query style information.
|
|
|
|
*
|
2010-11-22 02:50:43 +00:00
|
|
|
* If you are using GTK+ widgets, you probably will not need to use
|
|
|
|
* this API directly, as there is gtk_widget_get_path(), and the style
|
|
|
|
* context returned by gtk_widget_get_style_context() will be automatically
|
|
|
|
* updated on widget hierarchy changes.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* The widget path generation is generally simple:
|
2014-02-04 21:57:57 +00:00
|
|
|
*
|
|
|
|
* ## Defining a button within a window
|
|
|
|
*
|
2014-01-27 19:55:18 +00:00
|
|
|
* |[<!-- language="C" -->
|
2010-10-19 08:59:46 +00:00
|
|
|
* {
|
|
|
|
* GtkWidgetPath *path;
|
|
|
|
*
|
|
|
|
* path = gtk_widget_path_new ();
|
|
|
|
* gtk_widget_path_append_type (path, GTK_TYPE_WINDOW);
|
|
|
|
* gtk_widget_path_append_type (path, GTK_TYPE_BUTTON);
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Although more complex information, such as widget names, or
|
|
|
|
* different classes (property that may be used by other widget
|
|
|
|
* types) and intermediate regions may be included:
|
|
|
|
*
|
2014-02-04 21:57:57 +00:00
|
|
|
* ## Defining the first tab widget in a notebook
|
|
|
|
*
|
2014-01-27 19:55:18 +00:00
|
|
|
* |[<!-- language="C" -->
|
2010-10-19 08:59:46 +00:00
|
|
|
* {
|
|
|
|
* GtkWidgetPath *path;
|
|
|
|
* guint pos;
|
|
|
|
*
|
|
|
|
* path = gtk_widget_path_new ();
|
|
|
|
*
|
|
|
|
* pos = gtk_widget_path_append_type (path, GTK_TYPE_NOTEBOOK);
|
|
|
|
* gtk_widget_path_iter_add_region (path, pos, "tab", GTK_REGION_EVEN | GTK_REGION_FIRST);
|
|
|
|
*
|
|
|
|
* pos = gtk_widget_path_append_type (path, GTK_TYPE_LABEL);
|
|
|
|
* gtk_widget_path_iter_set_name (path, pos, "first tab label");
|
|
|
|
* }
|
2014-01-27 17:12:55 +00:00
|
|
|
* ]|
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* All this information will be used to match the style information
|
|
|
|
* that applies to the described widget.
|
|
|
|
**/
|
|
|
|
|
2010-10-20 17:33:39 +00:00
|
|
|
G_DEFINE_BOXED_TYPE (GtkWidgetPath, gtk_widget_path,
|
2011-05-27 14:37:16 +00:00
|
|
|
gtk_widget_path_ref, gtk_widget_path_unref)
|
2010-10-20 17:33:39 +00:00
|
|
|
|
|
|
|
|
2010-03-12 17:55:54 +00:00
|
|
|
typedef struct GtkPathElement GtkPathElement;
|
|
|
|
|
|
|
|
struct GtkPathElement
|
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
GtkCssNodeDeclaration *decl;
|
2013-09-22 03:37:48 +00:00
|
|
|
guint sibling_index;
|
2011-05-27 16:22:09 +00:00
|
|
|
GtkWidgetPath *siblings;
|
2010-03-12 17:55:54 +00:00
|
|
|
};
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
struct _GtkWidgetPath
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2015-09-11 23:05:19 +00:00
|
|
|
guint ref_count;
|
2011-05-27 14:36:07 +00:00
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
GArray *elems; /* First element contains the described widget */
|
2010-03-12 17:55:54 +00:00
|
|
|
};
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_new:
|
|
|
|
*
|
|
|
|
* Returns an empty widget path.
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): A newly created, empty, #GtkWidgetPath
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-12 17:55:54 +00:00
|
|
|
GtkWidgetPath *
|
|
|
|
gtk_widget_path_new (void)
|
|
|
|
{
|
|
|
|
GtkWidgetPath *path;
|
|
|
|
|
|
|
|
path = g_slice_new0 (GtkWidgetPath);
|
2010-04-20 23:27:46 +00:00
|
|
|
path->elems = g_array_new (FALSE, TRUE, sizeof (GtkPathElement));
|
2011-05-27 14:36:07 +00:00
|
|
|
path->ref_count = 1;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
2011-05-27 15:51:40 +00:00
|
|
|
static void
|
|
|
|
gtk_path_element_copy (GtkPathElement *dest,
|
|
|
|
const GtkPathElement *src)
|
|
|
|
{
|
|
|
|
memset (dest, 0, sizeof (GtkPathElement));
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
dest->decl = gtk_css_node_declaration_ref (src->decl);
|
2011-05-27 16:22:09 +00:00
|
|
|
if (src->siblings)
|
|
|
|
dest->siblings = gtk_widget_path_ref (src->siblings);
|
|
|
|
dest->sibling_index = src->sibling_index;
|
2011-05-27 15:51:40 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_copy:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
*
|
|
|
|
* Returns a copy of @path
|
|
|
|
*
|
|
|
|
* Returns: (transfer full): a copy of @path
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-04-20 23:27:46 +00:00
|
|
|
GtkWidgetPath *
|
|
|
|
gtk_widget_path_copy (const GtkWidgetPath *path)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2010-04-20 23:27:46 +00:00
|
|
|
GtkWidgetPath *new_path;
|
|
|
|
guint i;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
new_path = gtk_widget_path_new ();
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2012-08-07 04:38:48 +00:00
|
|
|
g_array_set_size (new_path->elems, path->elems->len);
|
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
for (i = 0; i < path->elems->len; i++)
|
|
|
|
{
|
2012-08-07 04:38:48 +00:00
|
|
|
GtkPathElement *elem, *dest;
|
2010-04-20 23:27:46 +00:00
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, i);
|
2012-08-07 04:38:48 +00:00
|
|
|
dest = &g_array_index (new_path->elems, GtkPathElement, i);
|
2010-04-20 23:27:46 +00:00
|
|
|
|
2012-08-07 04:38:48 +00:00
|
|
|
gtk_path_element_copy (dest, elem);
|
2010-04-20 23:27:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return new_path;
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
2011-05-27 14:36:07 +00:00
|
|
|
* gtk_widget_path_ref:
|
2010-10-19 08:59:46 +00:00
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
*
|
2011-05-27 14:36:07 +00:00
|
|
|
* Increments the reference count on @path.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
2011-05-27 14:36:07 +00:00
|
|
|
* Returns: @path itself.
|
|
|
|
*
|
|
|
|
* Since: 3.2
|
|
|
|
**/
|
|
|
|
GtkWidgetPath *
|
|
|
|
gtk_widget_path_ref (GtkWidgetPath *path)
|
|
|
|
{
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, path);
|
2011-05-27 14:36:07 +00:00
|
|
|
|
2015-09-11 23:05:19 +00:00
|
|
|
path->ref_count += 1;
|
2011-05-27 14:36:07 +00:00
|
|
|
|
|
|
|
return path;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_widget_path_unref:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
*
|
|
|
|
* Decrements the reference count on @path, freeing the structure
|
|
|
|
* if the reference count reaches 0.
|
|
|
|
*
|
|
|
|
* Since: 3.2
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-03-12 17:55:54 +00:00
|
|
|
void
|
2011-05-27 14:36:07 +00:00
|
|
|
gtk_widget_path_unref (GtkWidgetPath *path)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2010-04-20 23:27:46 +00:00
|
|
|
guint i;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-11 23:05:19 +00:00
|
|
|
path->ref_count -= 1;
|
|
|
|
if (path->ref_count > 0)
|
2011-05-27 14:36:07 +00:00
|
|
|
return;
|
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
for (i = 0; i < path->elems->len; i++)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2010-04-20 23:27:46 +00:00
|
|
|
GtkPathElement *elem;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, i);
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_unref (elem->decl);
|
2015-09-15 23:31:00 +00:00
|
|
|
if (elem->siblings)
|
|
|
|
gtk_widget_path_unref (elem->siblings);
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
2010-04-20 23:27:46 +00:00
|
|
|
|
|
|
|
g_array_free (path->elems, TRUE);
|
|
|
|
g_slice_free (GtkWidgetPath, path);
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
|
|
|
|
2011-05-27 14:36:07 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_free:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
*
|
|
|
|
* Decrements the reference count on @path, freeing the structure
|
|
|
|
* if the reference count reaches 0.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_widget_path_free (GtkWidgetPath *path)
|
|
|
|
{
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
2011-05-27 14:36:07 +00:00
|
|
|
|
|
|
|
gtk_widget_path_unref (path);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_length:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
*
|
|
|
|
* Returns the number of #GtkWidget #GTypes between the represented
|
|
|
|
* widget and its topmost container.
|
|
|
|
*
|
|
|
|
* Returns: the number of elements in the path
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-11-19 17:59:49 +00:00
|
|
|
gint
|
2010-08-05 14:21:12 +00:00
|
|
|
gtk_widget_path_length (const GtkWidgetPath *path)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, 0);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
return path->elems->len;
|
|
|
|
}
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2011-03-26 13:29:32 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_to_string:
|
|
|
|
* @path: the path
|
|
|
|
*
|
|
|
|
* Dumps the widget path into a string representation. It tries to match
|
|
|
|
* the CSS style as closely as possible (Note that there might be paths
|
|
|
|
* that cannot be represented in CSS).
|
2011-03-27 13:43:31 +00:00
|
|
|
*
|
2011-03-26 13:29:32 +00:00
|
|
|
* The main use of this code is for debugging purposes, so that you can
|
|
|
|
* g_print() the path or dump it in a gdb session.
|
|
|
|
*
|
|
|
|
* Returns: A new string describing @path.
|
2011-03-27 13:43:31 +00:00
|
|
|
*
|
|
|
|
* Since: 3.2
|
2011-03-26 13:29:32 +00:00
|
|
|
**/
|
|
|
|
char *
|
|
|
|
gtk_widget_path_to_string (const GtkWidgetPath *path)
|
|
|
|
{
|
|
|
|
GString *string;
|
2015-09-12 00:59:38 +00:00
|
|
|
guint i, j, n;
|
2011-03-26 13:29:32 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
2011-03-26 13:29:32 +00:00
|
|
|
|
|
|
|
string = g_string_new ("");
|
|
|
|
|
|
|
|
for (i = 0; i < path->elems->len; i++)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
2015-09-12 00:59:38 +00:00
|
|
|
GtkStateFlags state;
|
|
|
|
const GQuark *classes;
|
|
|
|
GList *list, *regions;
|
2011-03-26 13:29:32 +00:00
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, i);
|
|
|
|
|
|
|
|
if (i > 0)
|
|
|
|
g_string_append_c (string, ' ');
|
|
|
|
|
2016-01-12 19:34:56 +00:00
|
|
|
if (gtk_css_node_declaration_get_name (elem->decl))
|
|
|
|
g_string_append (string, gtk_css_node_declaration_get_name (elem->decl));
|
|
|
|
else
|
|
|
|
g_string_append (string, g_type_name (gtk_css_node_declaration_get_type (elem->decl)));
|
2011-03-26 13:29:32 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
if (gtk_css_node_declaration_get_id (elem->decl))
|
2011-03-26 13:29:32 +00:00
|
|
|
{
|
|
|
|
g_string_append_c (string, '(');
|
2015-09-12 00:59:38 +00:00
|
|
|
g_string_append (string, gtk_css_node_declaration_get_id (elem->decl));
|
2011-03-26 13:29:32 +00:00
|
|
|
g_string_append_c (string, ')');
|
|
|
|
}
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
state = gtk_css_node_declaration_get_state (elem->decl);
|
|
|
|
if (state)
|
2014-07-21 23:49:11 +00:00
|
|
|
{
|
|
|
|
GFlagsClass *fclass;
|
|
|
|
|
|
|
|
fclass = g_type_class_ref (GTK_TYPE_STATE_FLAGS);
|
2015-05-31 01:30:26 +00:00
|
|
|
for (j = 0; j < fclass->n_values; j++)
|
2014-07-21 23:49:11 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
if (state & fclass->values[j].value)
|
2014-07-21 23:49:11 +00:00
|
|
|
{
|
2014-08-14 01:00:02 +00:00
|
|
|
g_string_append_c (string, ':');
|
2015-05-31 01:30:26 +00:00
|
|
|
g_string_append (string, fclass->values[j].value_nick);
|
2014-07-21 23:49:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
g_type_class_unref (fclass);
|
|
|
|
}
|
2011-06-18 16:36:38 +00:00
|
|
|
|
|
|
|
if (elem->siblings)
|
|
|
|
g_string_append_printf (string, "[%d/%d]",
|
2011-11-23 16:22:30 +00:00
|
|
|
elem->sibling_index + 1,
|
2011-06-18 16:36:38 +00:00
|
|
|
gtk_widget_path_length (elem->siblings));
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
classes = gtk_css_node_declaration_get_classes (elem->decl, &n);
|
|
|
|
for (j = 0; j < n; j++)
|
2011-03-26 13:29:32 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
g_string_append_c (string, '.');
|
|
|
|
g_string_append (string, g_quark_to_string (classes[j]));
|
2011-03-26 13:29:32 +00:00
|
|
|
}
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
regions = gtk_css_node_declaration_list_regions (elem->decl);
|
|
|
|
for (list = regions; list; list = list->next)
|
2011-03-26 13:29:32 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
static const char *flag_names[] = {
|
|
|
|
"even",
|
|
|
|
"odd",
|
|
|
|
"first",
|
|
|
|
"last",
|
|
|
|
"only",
|
|
|
|
"sorted"
|
|
|
|
};
|
|
|
|
GtkRegionFlags flags;
|
|
|
|
GQuark region = GPOINTER_TO_UINT (regions->data);
|
|
|
|
|
|
|
|
gtk_css_node_declaration_has_region (elem->decl, region, &flags);
|
|
|
|
g_string_append_c (string, ' ');
|
|
|
|
g_string_append (string, g_quark_to_string (region));
|
|
|
|
for (j = 0; j < G_N_ELEMENTS(flag_names); j++)
|
2011-03-26 13:29:32 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
if (flags & (1 << j))
|
2011-03-26 13:29:32 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
g_string_append_c (string, ':');
|
|
|
|
g_string_append (string, flag_names[j]);
|
2011-03-26 13:29:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-09-12 00:59:38 +00:00
|
|
|
g_list_free (regions);
|
2011-03-26 13:29:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return g_string_free (string, FALSE);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_prepend_type:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @type: widget type to prepend
|
|
|
|
*
|
|
|
|
* Prepends a widget type to the widget hierachy represented by @path.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-11-19 17:58:19 +00:00
|
|
|
void
|
2010-04-20 23:27:46 +00:00
|
|
|
gtk_widget_path_prepend_type (GtkWidgetPath *path,
|
|
|
|
GType type)
|
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
GtkPathElement new = { NULL };
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
new.decl = gtk_css_node_declaration_new ();
|
|
|
|
gtk_css_node_declaration_set_type (&new.decl, type);
|
|
|
|
|
2010-10-10 22:23:40 +00:00
|
|
|
g_array_prepend_val (path->elems, new);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_append_type:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @type: widget type to append
|
|
|
|
*
|
2011-05-27 16:01:11 +00:00
|
|
|
* Appends a widget type to the widget hierarchy represented by @path.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns: the position where the element was inserted
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-11-19 17:59:49 +00:00
|
|
|
gint
|
2010-10-10 22:23:40 +00:00
|
|
|
gtk_widget_path_append_type (GtkWidgetPath *path,
|
|
|
|
GType type)
|
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
GtkPathElement new = { NULL };
|
2010-10-10 22:23:40 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, 0);
|
2010-10-10 22:23:40 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
new.decl = gtk_css_node_declaration_new ();
|
|
|
|
gtk_css_node_declaration_set_type (&new.decl, type);
|
2010-04-20 23:27:46 +00:00
|
|
|
g_array_append_val (path->elems, new);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
return path->elems->len - 1;
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
|
|
|
|
2011-05-27 16:22:09 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_append_with_siblings:
|
|
|
|
* @path: the widget path to append to
|
|
|
|
* @siblings: a widget path describing a list of siblings. This path
|
|
|
|
* may not contain any siblings itself and it must not be modified
|
|
|
|
* afterwards.
|
|
|
|
* @sibling_index: index into @siblings for where the added element is
|
|
|
|
* positioned.
|
|
|
|
*
|
|
|
|
* Appends a widget type with all its siblings to the widget hierarchy
|
|
|
|
* represented by @path. Using this function instead of
|
|
|
|
* gtk_widget_path_append_type() will allow the CSS theming to use
|
|
|
|
* sibling matches in selectors and apply :nth-child() pseudo classes.
|
|
|
|
* In turn, it requires a lot more care in widget implementations as
|
|
|
|
* widgets need to make sure to call gtk_widget_reset_style() on all
|
|
|
|
* involved widgets when the @siblings path changes.
|
|
|
|
*
|
|
|
|
* Returns: the position where the element was inserted.
|
|
|
|
*
|
|
|
|
* Since: 3.2
|
|
|
|
**/
|
|
|
|
gint
|
|
|
|
gtk_widget_path_append_with_siblings (GtkWidgetPath *path,
|
|
|
|
GtkWidgetPath *siblings,
|
|
|
|
guint sibling_index)
|
|
|
|
{
|
|
|
|
GtkPathElement new;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, 0);
|
|
|
|
gtk_internal_return_val_if_fail (siblings != NULL, 0);
|
|
|
|
gtk_internal_return_val_if_fail (sibling_index < gtk_widget_path_length (siblings), 0);
|
2011-05-27 16:22:09 +00:00
|
|
|
|
|
|
|
gtk_path_element_copy (&new, &g_array_index (siblings->elems, GtkPathElement, sibling_index));
|
|
|
|
new.siblings = gtk_widget_path_ref (siblings);
|
|
|
|
new.sibling_index = sibling_index;
|
|
|
|
g_array_append_val (path->elems, new);
|
|
|
|
|
|
|
|
return path->elems->len - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_get_siblings:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @pos: position to get the siblings for, -1 for the path head
|
|
|
|
*
|
|
|
|
* Returns the list of siblings for the element at @pos. If the element
|
|
|
|
* was not added with siblings, %NULL is returned.
|
|
|
|
*
|
|
|
|
* Returns: %NULL or the list of siblings for the element at @pos.
|
|
|
|
**/
|
|
|
|
const GtkWidgetPath *
|
|
|
|
gtk_widget_path_iter_get_siblings (const GtkWidgetPath *path,
|
|
|
|
gint pos)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, NULL);
|
2011-05-27 16:22:09 +00:00
|
|
|
|
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
return elem->siblings;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_get_sibling_index:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @pos: position to get the sibling index for, -1 for the path head
|
|
|
|
*
|
|
|
|
* Returns the index into the list of siblings for the element at @pos as
|
|
|
|
* returned by gtk_widget_path_iter_get_siblings(). If that function would
|
|
|
|
* return %NULL because the element at @pos has no siblings, this function
|
|
|
|
* will return 0.
|
|
|
|
*
|
|
|
|
* Returns: 0 or the index into the list of siblings for the element at @pos.
|
|
|
|
**/
|
|
|
|
guint
|
|
|
|
gtk_widget_path_iter_get_sibling_index (const GtkWidgetPath *path,
|
|
|
|
gint pos)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, G_TYPE_INVALID);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, G_TYPE_INVALID);
|
2011-05-27 16:22:09 +00:00
|
|
|
|
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
return elem->sibling_index;
|
|
|
|
}
|
|
|
|
|
2015-10-27 00:26:20 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_get_object_name:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @pos: position to get the object name for, -1 for the path head
|
|
|
|
*
|
|
|
|
* Returns the object name that is at position @pos in the widget
|
|
|
|
* hierarchy defined in @path.
|
|
|
|
*
|
|
|
|
* Returns: the name or %NULL
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
**/
|
|
|
|
const char *
|
|
|
|
gtk_widget_path_iter_get_object_name (const GtkWidgetPath *path,
|
|
|
|
gint pos)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, NULL);
|
|
|
|
|
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
return gtk_css_node_declaration_get_name (elem->decl);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_set_object_name:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @pos: position to modify, -1 for the path head
|
|
|
|
* @name: (allow-none): object name to set or %NULL to unset
|
|
|
|
*
|
|
|
|
* Sets the object name for a given position in the widget hierarchy
|
|
|
|
* defined by @path.
|
|
|
|
*
|
|
|
|
* When set, the object name overrides the object type when matching
|
|
|
|
* CSS.
|
|
|
|
*
|
|
|
|
* Since: 3.20
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_widget_path_iter_set_object_name (GtkWidgetPath *path,
|
|
|
|
gint pos,
|
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
|
|
|
|
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
gtk_css_node_declaration_set_name (&elem->decl, g_intern_string (name));
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
2010-12-13 16:54:02 +00:00
|
|
|
* gtk_widget_path_iter_get_object_type:
|
2010-10-19 08:59:46 +00:00
|
|
|
* @path: a #GtkWidgetPath
|
2010-12-13 16:54:02 +00:00
|
|
|
* @pos: position to get the object type for, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
2010-12-13 16:54:02 +00:00
|
|
|
* Returns the object #GType that is at position @pos in the widget
|
2010-10-19 08:59:46 +00:00
|
|
|
* hierarchy defined in @path.
|
|
|
|
*
|
|
|
|
* Returns: a widget type
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-04-20 23:27:46 +00:00
|
|
|
GType
|
2010-12-13 16:54:02 +00:00
|
|
|
gtk_widget_path_iter_get_object_type (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2010-04-20 23:27:46 +00:00
|
|
|
GtkPathElement *elem;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, G_TYPE_INVALID);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, G_TYPE_INVALID);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_get_type (elem->decl);
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
2010-12-13 16:54:02 +00:00
|
|
|
* gtk_widget_path_iter_set_object_type:
|
2010-10-19 08:59:46 +00:00
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-12-13 16:54:02 +00:00
|
|
|
* @type: object type to set
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
2010-12-13 16:54:02 +00:00
|
|
|
* Sets the object type for a given position in the widget hierarchy
|
|
|
|
* defined by @path.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-04-20 23:27:46 +00:00
|
|
|
void
|
2010-12-13 16:54:02 +00:00
|
|
|
gtk_widget_path_iter_set_object_type (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-04 10:50:37 +00:00
|
|
|
GType type)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2010-04-20 23:27:46 +00:00
|
|
|
GtkPathElement *elem;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_set_type (&elem->decl, type);
|
2010-04-20 23:27:46 +00:00
|
|
|
}
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2014-07-18 18:07:27 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_get_state:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @pos: position to get the state for, -1 for the path head
|
|
|
|
*
|
|
|
|
* Returns the state flags corresponding to the widget found at
|
|
|
|
* the position @pos in the widget hierarchy defined by
|
|
|
|
* @path
|
|
|
|
*
|
|
|
|
* Returns: The state flags
|
|
|
|
*
|
|
|
|
* Since: 3.14
|
|
|
|
**/
|
|
|
|
GtkStateFlags
|
|
|
|
gtk_widget_path_iter_get_state (const GtkWidgetPath *path,
|
|
|
|
gint pos)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, 0);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, 0);
|
2014-07-18 18:07:27 +00:00
|
|
|
|
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_get_state (elem->decl);
|
2014-07-18 18:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_set_state:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @pos: position to modify, -1 for the path head
|
|
|
|
* @state: state flags
|
|
|
|
*
|
|
|
|
* Sets the widget name for the widget found at position @pos
|
|
|
|
* in the widget hierarchy defined by @path.
|
|
|
|
*
|
|
|
|
* If you want to update just a single state flag, you need to do
|
|
|
|
* this manually, as this function updates all state flags.
|
|
|
|
*
|
|
|
|
* ## Setting a flag
|
|
|
|
*
|
|
|
|
* |[<!-- language="C" -->
|
|
|
|
* gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) | flag);
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
* ## Unsetting a flag
|
|
|
|
*
|
|
|
|
* |[<!-- language="C" -->
|
|
|
|
* gtk_widget_path_iter_set_state (path, pos, gtk_widget_path_iter_get_state (path, pos) & ~flag);
|
|
|
|
* ]|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Since: 3.14
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gtk_widget_path_iter_set_state (GtkWidgetPath *path,
|
|
|
|
gint pos,
|
|
|
|
GtkStateFlags state)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
2014-07-18 18:07:27 +00:00
|
|
|
|
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_set_state (&elem->decl, state);
|
2014-07-18 18:07:27 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_get_name:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to get the widget name for, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns the name corresponding to the widget found at
|
|
|
|
* the position @pos in the widget hierarchy defined by
|
|
|
|
* @path
|
|
|
|
*
|
|
|
|
* Returns: The widget name, or %NULL if none was set.
|
|
|
|
**/
|
2011-06-06 18:13:44 +00:00
|
|
|
const gchar *
|
2010-08-04 10:50:37 +00:00
|
|
|
gtk_widget_path_iter_get_name (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos)
|
2010-04-20 23:27:46 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, NULL);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_get_id (elem->decl);
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_set_name:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: widget name
|
|
|
|
*
|
|
|
|
* Sets the widget name for the widget found at position @pos
|
|
|
|
* in the widget hierarchy defined by @path.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-03-12 17:55:54 +00:00
|
|
|
void
|
2010-08-04 10:50:37 +00:00
|
|
|
gtk_widget_path_iter_set_name (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-04 10:50:37 +00:00
|
|
|
const gchar *name)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
2010-04-20 23:27:46 +00:00
|
|
|
GtkPathElement *elem;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
|
|
|
gtk_internal_return_if_fail (name != NULL);
|
2010-04-20 23:27:46 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_set_id (&elem->decl, g_intern_string (name));
|
2010-08-04 11:11:50 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_has_qname:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @qname: widget name as a #GQuark
|
|
|
|
*
|
|
|
|
* See gtk_widget_path_iter_has_name(). This is a version
|
2014-02-09 22:24:06 +00:00
|
|
|
* that operates on #GQuarks.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the widget at @pos has this name
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-04 11:11:50 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_iter_has_qname (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-04 11:11:50 +00:00
|
|
|
GQuark qname)
|
|
|
|
{
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (qname != 0, FALSE);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_widget_path_iter_has_name (path, pos, g_quark_to_string (qname));
|
2010-08-04 11:11:50 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_has_name:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: a widget name
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the widget at position @pos has the name @name,
|
|
|
|
* %FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the widget at @pos has this name
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-04 11:11:50 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_iter_has_name (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-04 11:11:50 +00:00
|
|
|
const gchar *name)
|
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
GtkPathElement *elem;
|
2010-08-04 11:11:50 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, FALSE);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-08-04 11:11:50 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
name = g_intern_string (name);
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2010-04-20 23:27:46 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_get_id (elem->decl) == name;
|
2010-04-20 23:27:46 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_add_class:
|
|
|
|
* @path: a #GtkWidget
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: a class name
|
|
|
|
*
|
|
|
|
* Adds the class @name to the widget at position @pos in
|
|
|
|
* the hierarchy defined in @path. See
|
2010-10-20 17:02:41 +00:00
|
|
|
* gtk_style_context_add_class().
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-06 09:59:35 +00:00
|
|
|
void
|
|
|
|
gtk_widget_path_iter_add_class (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-06 09:59:35 +00:00
|
|
|
const gchar *name)
|
|
|
|
{
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
|
|
|
gtk_internal_return_if_fail (name != NULL);
|
2010-08-06 09:59:35 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2015-09-11 15:49:59 +00:00
|
|
|
gtk_widget_path_iter_add_qclass (path, pos, g_quark_from_string (name));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gtk_widget_path_iter_add_qclass (GtkWidgetPath *path,
|
|
|
|
gint pos,
|
|
|
|
GQuark qname)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2010-08-06 09:59:35 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_add_class (&elem->decl, qname);
|
2010-08-06 09:59:35 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_remove_class:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: class name
|
|
|
|
*
|
|
|
|
* Removes the class @name from the widget at position @pos in
|
|
|
|
* the hierarchy defined in @path.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-06 09:59:35 +00:00
|
|
|
void
|
|
|
|
gtk_widget_path_iter_remove_class (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-06 09:59:35 +00:00
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
GQuark qname;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
|
|
|
gtk_internal_return_if_fail (name != NULL);
|
2010-08-06 09:59:35 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2010-08-06 09:59:35 +00:00
|
|
|
qname = g_quark_try_string (name);
|
|
|
|
if (qname == 0)
|
|
|
|
return;
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_remove_class (&elem->decl, qname);
|
2010-08-06 09:59:35 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_clear_classes:
|
|
|
|
* @path: a #GtkWidget
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Removes all classes from the widget at position @pos in the
|
|
|
|
* hierarchy defined in @path.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-06 09:59:35 +00:00
|
|
|
void
|
|
|
|
gtk_widget_path_iter_clear_classes (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos)
|
2010-08-06 09:59:35 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-08-06 09:59:35 +00:00
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_clear_classes (&elem->decl);
|
2010-08-06 09:59:35 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_list_classes:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns a list with all the class names defined for the widget
|
|
|
|
* at position @pos in the hierarchy defined in @path.
|
|
|
|
*
|
2011-01-18 09:14:33 +00:00
|
|
|
* Returns: (transfer container) (element-type utf8): The list of
|
|
|
|
* classes, This is a list of strings, the #GSList contents
|
|
|
|
* are owned by GTK+, but you should use g_slist_free() to
|
2010-10-19 08:59:46 +00:00
|
|
|
* free the list itself.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-06 09:59:35 +00:00
|
|
|
GSList *
|
|
|
|
gtk_widget_path_iter_list_classes (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos)
|
2010-08-06 09:59:35 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
GSList *list = NULL;
|
2015-09-12 00:59:38 +00:00
|
|
|
const GQuark *classes;
|
|
|
|
guint i, n;
|
2010-08-06 09:59:35 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, NULL);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-08-06 09:59:35 +00:00
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2015-09-12 00:59:38 +00:00
|
|
|
classes = gtk_css_node_declaration_get_classes (elem->decl, &n);
|
2010-08-06 09:59:35 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
for (i = 0; i < n; i++)
|
2010-08-06 09:59:35 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
list = g_slist_prepend (list, (gchar *) g_quark_to_string (classes[i]));
|
2010-08-06 09:59:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return g_slist_reverse (list);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_has_qclass:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @qname: class name as a #GQuark
|
|
|
|
*
|
|
|
|
* See gtk_widget_path_iter_has_class(). This is a version that operates
|
2014-02-09 22:24:06 +00:00
|
|
|
* with GQuarks.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the widget at @pos has the class defined.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-06 09:59:35 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_iter_has_qclass (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-06 09:59:35 +00:00
|
|
|
GQuark qname)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (qname != 0, FALSE);
|
2010-08-06 09:59:35 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-08-06 09:59:35 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_has_class (elem->decl, qname);
|
2010-08-06 09:59:35 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_has_class:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: class name
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the widget at position @pos has the class @name
|
|
|
|
* defined, %FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the class @name is defined for the widget at @pos
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-08-06 09:59:35 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_iter_has_class (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-06 09:59:35 +00:00
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GQuark qname;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (name != NULL, FALSE);
|
2010-08-06 09:59:35 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-08-06 09:59:35 +00:00
|
|
|
qname = g_quark_try_string (name);
|
|
|
|
|
|
|
|
if (qname == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
return gtk_widget_path_iter_has_qclass (path, pos, qname);
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_add_region:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: region name
|
|
|
|
* @flags: flags affecting the region
|
|
|
|
*
|
|
|
|
* Adds the region @name to the widget at position @pos in
|
|
|
|
* the hierarchy defined in @path. See
|
2010-10-20 17:02:41 +00:00
|
|
|
* gtk_style_context_add_region().
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
2014-02-02 06:22:14 +00:00
|
|
|
* Region names must only contain lowercase letters
|
2014-02-07 19:03:49 +00:00
|
|
|
* and “-”, starting always with a lowercase letter.
|
2011-01-19 03:12:08 +00:00
|
|
|
*
|
2010-10-19 08:59:46 +00:00
|
|
|
* Since: 3.0
|
2014-06-21 13:38:38 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.14: The use of regions is deprecated.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-04-20 23:35:54 +00:00
|
|
|
void
|
2010-08-05 09:08:51 +00:00
|
|
|
gtk_widget_path_iter_add_region (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-05 09:08:51 +00:00
|
|
|
const gchar *name,
|
|
|
|
GtkRegionFlags flags)
|
2010-04-20 23:35:54 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
2010-08-04 10:19:23 +00:00
|
|
|
GQuark qname;
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
|
|
|
gtk_internal_return_if_fail (name != NULL);
|
|
|
|
gtk_internal_return_if_fail (_gtk_style_context_check_region_name (name));
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-04-20 23:35:54 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2010-08-04 10:19:23 +00:00
|
|
|
qname = g_quark_from_string (name);
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_add_region (&elem->decl, qname, flags);
|
2010-04-20 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_remove_region:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: region name
|
|
|
|
*
|
|
|
|
* Removes the region @name from the widget at position @pos in
|
|
|
|
* the hierarchy defined in @path.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2014-06-21 13:38:38 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.14: The use of regions is deprecated.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-04-20 23:35:54 +00:00
|
|
|
void
|
|
|
|
gtk_widget_path_iter_remove_region (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-04-20 23:35:54 +00:00
|
|
|
const gchar *name)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
2010-08-04 10:19:23 +00:00
|
|
|
GQuark qname;
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
|
|
|
gtk_internal_return_if_fail (name != NULL);
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
2010-08-04 10:19:23 +00:00
|
|
|
qname = g_quark_try_string (name);
|
|
|
|
if (qname == 0)
|
|
|
|
return;
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_remove_region (&elem->decl, qname);
|
2010-04-20 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_clear_regions:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to modify, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Removes all regions from the widget at position @pos in the
|
|
|
|
* hierarchy defined in @path.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2014-06-21 13:38:38 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.14: The use of regions is deprecated.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-04-20 23:35:54 +00:00
|
|
|
void
|
|
|
|
gtk_widget_path_iter_clear_regions (GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos)
|
2010-04-20 23:35:54 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_if_fail (path != NULL);
|
|
|
|
gtk_internal_return_if_fail (path->elems->len != 0);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-04-20 23:35:54 +00:00
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
gtk_css_node_declaration_clear_regions (&elem->decl);
|
2010-04-20 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_list_regions:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns a list with all the region names defined for the widget
|
|
|
|
* at position @pos in the hierarchy defined in @path.
|
|
|
|
*
|
2011-01-18 09:14:33 +00:00
|
|
|
* Returns: (transfer container) (element-type utf8): The list of
|
|
|
|
* regions, This is a list of strings, the #GSList contents
|
|
|
|
* are owned by GTK+, but you should use g_slist_free() to
|
2010-10-19 08:59:46 +00:00
|
|
|
* free the list itself.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2014-06-21 13:38:38 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.14: The use of regions is deprecated.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-04-20 23:35:54 +00:00
|
|
|
GSList *
|
2010-08-05 14:21:12 +00:00
|
|
|
gtk_widget_path_iter_list_regions (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos)
|
2010-04-20 23:35:54 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
GSList *list = NULL;
|
2015-09-12 00:59:38 +00:00
|
|
|
GList *l, *wrong_list;
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, NULL);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, NULL);
|
2010-11-19 17:59:49 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
2010-04-20 23:35:54 +00:00
|
|
|
|
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
wrong_list = gtk_css_node_declaration_list_regions (elem->decl);
|
|
|
|
for (l = wrong_list; l; l = l->next)
|
2010-08-04 10:19:23 +00:00
|
|
|
{
|
2015-09-12 00:59:38 +00:00
|
|
|
list = g_slist_prepend (list, (char *) g_quark_to_string (GPOINTER_TO_UINT (l->data)));
|
2010-08-04 10:19:23 +00:00
|
|
|
}
|
2015-09-12 00:59:38 +00:00
|
|
|
g_list_free (wrong_list);
|
2010-04-20 23:35:54 +00:00
|
|
|
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_has_qregion:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @qname: region name as a #GQuark
|
|
|
|
* @flags: (out): return location for the region flags
|
|
|
|
*
|
|
|
|
* See gtk_widget_path_iter_has_region(). This is a version that operates
|
2014-02-09 22:24:06 +00:00
|
|
|
* with GQuarks.
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Returns: %TRUE if the widget at @pos has the region defined.
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2014-06-21 13:38:38 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.14: The use of regions is deprecated.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-04-20 23:35:54 +00:00
|
|
|
gboolean
|
2010-08-04 10:19:23 +00:00
|
|
|
gtk_widget_path_iter_has_qregion (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-04 10:19:23 +00:00
|
|
|
GQuark qname,
|
2010-08-05 09:08:51 +00:00
|
|
|
GtkRegionFlags *flags)
|
2010-04-20 23:35:54 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (qname != 0, FALSE);
|
2010-04-20 23:35:54 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-04-20 23:35:54 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, pos);
|
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_has_region (elem->decl, qname, flags);
|
2010-04-20 23:35:54 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_iter_has_region:
|
|
|
|
* @path: a #GtkWidgetPath
|
2010-11-19 17:59:49 +00:00
|
|
|
* @pos: position to query, -1 for the path head
|
2010-10-19 08:59:46 +00:00
|
|
|
* @name: region name
|
|
|
|
* @flags: (out): return location for the region flags
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the widget at position @pos has the class @name
|
|
|
|
* defined, %FALSE otherwise.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the class @name is defined for the widget at @pos
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
2014-06-21 13:38:38 +00:00
|
|
|
*
|
|
|
|
* Deprecated: 3.14: The use of regions is deprecated.
|
2010-10-19 08:59:46 +00:00
|
|
|
**/
|
2010-08-04 10:19:23 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_iter_has_region (const GtkWidgetPath *path,
|
2010-11-19 17:59:49 +00:00
|
|
|
gint pos,
|
2010-08-04 10:19:23 +00:00
|
|
|
const gchar *name,
|
2010-08-05 09:08:51 +00:00
|
|
|
GtkRegionFlags *flags)
|
2010-08-04 10:19:23 +00:00
|
|
|
{
|
|
|
|
GQuark qname;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (path->elems->len != 0, FALSE);
|
|
|
|
gtk_internal_return_val_if_fail (name != NULL, FALSE);
|
2010-08-04 10:19:23 +00:00
|
|
|
|
2011-03-26 13:44:12 +00:00
|
|
|
if (pos < 0 || pos >= path->elems->len)
|
2010-11-19 17:59:49 +00:00
|
|
|
pos = path->elems->len - 1;
|
|
|
|
|
2010-08-04 10:19:23 +00:00
|
|
|
qname = g_quark_try_string (name);
|
|
|
|
|
|
|
|
if (qname == 0)
|
|
|
|
return FALSE;
|
|
|
|
|
2014-06-21 13:38:38 +00:00
|
|
|
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
|
2010-08-04 10:19:23 +00:00
|
|
|
return gtk_widget_path_iter_has_qregion (path, pos, qname, flags);
|
2014-06-21 13:38:38 +00:00
|
|
|
G_GNUC_END_IGNORE_DEPRECATIONS
|
2010-08-04 10:19:23 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
2010-12-13 16:54:02 +00:00
|
|
|
* gtk_widget_path_get_object_type:
|
2010-10-19 08:59:46 +00:00
|
|
|
* @path: a #GtkWidget
|
|
|
|
*
|
2010-12-13 16:54:02 +00:00
|
|
|
* Returns the topmost object type, that is, the object type this path
|
2010-10-19 08:59:46 +00:00
|
|
|
* is representing.
|
|
|
|
*
|
2010-12-13 16:54:02 +00:00
|
|
|
* Returns: The object type
|
2010-10-19 08:59:46 +00:00
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-06-18 14:59:14 +00:00
|
|
|
GType
|
2010-12-13 16:54:02 +00:00
|
|
|
gtk_widget_path_get_object_type (const GtkWidgetPath *path)
|
2010-06-18 14:59:14 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, G_TYPE_INVALID);
|
2010-06-18 14:59:14 +00:00
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement,
|
|
|
|
path->elems->len - 1);
|
2015-09-12 00:59:38 +00:00
|
|
|
return gtk_css_node_declaration_get_type (elem->decl);
|
2010-06-18 14:59:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_is_type:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @type: widget type to match
|
|
|
|
*
|
|
|
|
* Returns %TRUE if the widget type represented by this path
|
|
|
|
* is @type, or a subtype of it.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if the widget represented by @path is of type @type
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-06-18 14:59:14 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_is_type (const GtkWidgetPath *path,
|
|
|
|
GType type)
|
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
2010-06-18 14:59:14 +00:00
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement,
|
|
|
|
path->elems->len - 1);
|
2010-06-18 14:59:14 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
return g_type_is_a (gtk_css_node_declaration_get_type (elem->decl), type);
|
2010-06-18 14:59:14 +00:00
|
|
|
}
|
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
/**
|
|
|
|
* gtk_widget_path_has_parent:
|
|
|
|
* @path: a #GtkWidgetPath
|
|
|
|
* @type: widget type to check in parents
|
|
|
|
*
|
|
|
|
* Returns %TRUE if any of the parents of the widget represented
|
|
|
|
* in @path is of type @type, or any subtype of it.
|
|
|
|
*
|
|
|
|
* Returns: %TRUE if any parent is of type @type
|
|
|
|
*
|
|
|
|
* Since: 3.0
|
|
|
|
**/
|
2010-04-20 23:27:46 +00:00
|
|
|
gboolean
|
|
|
|
gtk_widget_path_has_parent (const GtkWidgetPath *path,
|
|
|
|
GType type)
|
|
|
|
{
|
|
|
|
guint i;
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-08 12:07:05 +00:00
|
|
|
gtk_internal_return_val_if_fail (path != NULL, FALSE);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2010-10-19 08:59:46 +00:00
|
|
|
for (i = 0; i < path->elems->len - 1; i++)
|
2010-03-12 17:55:54 +00:00
|
|
|
{
|
|
|
|
GtkPathElement *elem;
|
|
|
|
|
2010-04-20 23:27:46 +00:00
|
|
|
elem = &g_array_index (path->elems, GtkPathElement, i);
|
2010-03-12 17:55:54 +00:00
|
|
|
|
2015-09-12 00:59:38 +00:00
|
|
|
if (g_type_is_a (gtk_css_node_declaration_get_type (elem->decl), type))
|
2010-04-20 23:27:46 +00:00
|
|
|
return TRUE;
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|
2010-04-20 23:27:46 +00:00
|
|
|
|
|
|
|
return FALSE;
|
2010-03-12 17:55:54 +00:00
|
|
|
}
|