Compare commits

..

22 Commits

Author SHA1 Message Date
Alexander Larsson 0542d5461f css: Make test pass
The new css tree may change the order of selectors (keeping the
same semantics). This affects how the selectors are printed later,
which causes some css parsing tests to not match the references.

Fortunately the order is consistent between runs given the same
css, so we just have to switch around the order in some of the
.ref.css files.
2012-11-30 14:18:39 +01:00
Alexander Larsson 28033a25dd css: Allocate the css tree in a single chunk
This gives us several advantages:

* Smaller struct on 64bit (32bit indexes vs 64bit pointers)
* Less overhead for allocation
* Less fragmentation
2012-11-29 22:21:23 +01:00
Alexander Larsson 536e38aef6 css: Fix leak of lists while building tree 2012-11-29 22:21:23 +01:00
Alexander Larsson 867f70586c css: Add accessor functions for traversing css tree
This will let us later change how the tree is stored
2012-11-29 22:21:23 +01:00
Alexander Larsson 8e461c2ecd css: Add const to _gtk_css_selector_tree_match_all arg 2012-11-29 22:21:23 +01:00
Alexander Larsson e3930f2342 css: Don't keep around linear selectors
Now we use the selector tree everywhere, so there is no need to
keep around the linear selectors unless we're using them to
verify the tree correctness, so free them.
2012-11-29 22:21:23 +01:00
Alexander Larsson 24f5412b3d css: Remove gtk_css_ruleset_matches
This is only not needed anymore, and only the VERIFY_TREE code
should access ->selector.
2012-11-29 22:21:23 +01:00
Alexander Larsson 36200036db css: Use tree for gtk_css_provider_get_style_property 2012-11-29 22:21:23 +01:00
Alexander Larsson 67c62fff13 css: Implement ruleset_get_change() with the tree
We traverse the tree on the matches instead of using
the linear selectors.
2012-11-29 22:21:23 +01:00
Alexander Larsson 55f8bb5279 css: Ensure the tree built is always the same
We add some "artificial" ordering to the otherwise unordered
tree nodes. This means the tree will be the same every time for the
same input. This is good because e.g. tree order affects the
reordering of the simple selectors, which may affect how
css providers are printed, which need to be consistent for
the css tests to work.
2012-11-29 22:21:23 +01:00
Alexander Larsson 736d1bccf6 css: Use the tree to print css selectors 2012-11-29 22:21:23 +01:00
Alexander Larsson ef1dbc7c36 css: Track the tree selector matches 2012-11-29 22:21:23 +01:00
Alexander Larsson f11013e80a css: Fix type of GtkCssSelectorRuleSetInfo match
The old type was a leftover from a previous version.
2012-11-29 22:21:23 +01:00
Alexander Larsson d40d532067 css: Track parent in the css tree nodes
This way we can reconstruct matched css rules
2012-11-29 22:21:22 +01:00
Alexander Larsson 64d8034164 css: Better tree match verification 2012-11-29 22:21:22 +01:00
Alexander Larsson d9357402ed css: Fix up position with region tree matching
This was using the wrong result in case of a match (results from
the position, not the region. Also, the descendant checks were
wrong.
2012-11-29 22:21:22 +01:00
Alexander Larsson 6702974e32 css: Don't reorder some selectors when building selector tree
When building the tree we generally reorder the selectors inside
the same simple selector in order to pick a good first selector
to balance the tree better. However, some kinds of selectors
can't really be reordered, even thought they are simple.

This is since the matching code for some types handle
the existance of a directly preceeding selector differently:

 REGION and ANY selectors look for a DESCENDANT previous
 POSITION selector look for a REGION previous
2012-11-29 22:21:22 +01:00
Alexander Larsson 18536fc044 css: Fixed typo in PRINT_TREE debug code 2012-11-28 12:13:09 +01:00
Alexander Larsson fa2f5eee64 css: Create and use a tree for css selector matching 2012-11-28 11:21:06 +01:00
Alexander Larsson b70bac8b76 css: Add GtkCssSelectorTree creation and matching
From a set of GtkCssSelectors and the rulesets they match to
we create a large decision tree that lets us efficitently match
against all the rules and return the set of matched rulesets.

The tree is created such that at each level we pick the initial rule[1]
in all the considered selectors for that level and use put the
one that is in most selectors in the node. All selectors matching that
are put in the previous part of the tree.
2012-11-28 11:15:53 +01:00
Alexander Larsson b786ccc6d9 css: Add _gtk_css_matcher_matches_any()
This returns true if the matcher matches *anything*. We need
to check this later, because such matchers are dangerous in loops
that iterate over all parents/siblings since such loops would not
terminate.
2012-11-28 11:07:52 +01:00
Alexander Larsson af7c38c60c css: Track which selectors are "simple" 2012-11-27 10:50:59 +01:00
173 changed files with 4725 additions and 6568 deletions
-71
View File
@@ -1,74 +1,3 @@
Overview of Changes in GTK+ 3.7.4
=================================
* GtkBuilder now lets you refer to external objects from a ui
file if the objects have been exported with the new function
gtk_builder_expose_object()
* Font handling has been improved:
- The default font is no longer handled like a custom style sheet
that overrides everything, but as the initial value. This is the
same behavior as in web browsers.
- It is now possible to set font-family and font-size like other
CSS properties, and relative font sizes are supported. Font
sizes in CSS can be specified as numbers or with keywords
like xx-small, medium, smaller, larger,...
* GTK+ now uses proper Unicode ellipses in strings.
* The releases includes several noticable performance improvements:
- Size allocation has been optimized, by avoiding excessive
resizing in various situations.
- The performance of size groups has been improved.
- Text rendering in GtkLabel and other widgets has been optimized
to avoid excessive recreation of Pango layouts.
- Icon loading overhead was reduced by caching of GtkIconInfo.
- The CSS is now keeping a tree of selectors to speed up matchinh.
* Deprecations and removals:
- Custom CSS properties have been deprecated
- Support for color schemes has been removed
- gtk_style_provider_get_style, gtk_style_provider_get_icon_factory
- GtkGradient and GtkSymbolicColor
- All the padding style properties in menus
* Bugs closed:
132333 Can't add a palette to the dialog of a color button
371034 Doc for gtk_file_chooser_get_filename: Is the resulting path...
447972 Add a way to specify user_data sent to signals
548793 funny pattern for iterating GtkTreeModel
595615 Use proper ellipses
626499 GtkClipboard unnotified on change of OS X pasteboard owner
668239 texts disappear when notebook switch page at zh_CN locate!
677339 GTK+ 3 documentation wrong about GtkWidget scroll-event signal
680065 treemodelfilter: Make the constructor binding friendly
687065 InstallableOptions is not filtered in cups backend
687816 GtkTreeView does not draw correctly since commit aaedc7b6
688710 [PATCH] Splash screens shouldn't stay on top of all applicat...
688744 Don't use gtk_style_context_set_background() to render icon/...
688884 Typo in gtk_tree_view_set_tooltip_column documentation
689012 "Copy file's location" menu item in file chooser dialog uses...
689047 Obtain the recent files max age setting from xsettings
689081 No caching of icons
689168 Deprecate some menu style properties
689401 xi2: Abort early if we don't have a proper GDK window
689584 Add summary and description to "show-hidden" key
689847 Add fast repeated typename -> GType resolver
689923 Missing null-check in GtkEntryAccessible
690099 GtkScrolledWindow with NEVER policy don't resize with children
690266 Freeze with F10/Shift-F10 on submenus
* Translation updates:
Assamese
British English
Dutch
German
Hebrew
Polish
Slovenian
Spanish
Overview of Changes in GTK+ 3.7.2
=================================
+3 -3
View File
@@ -10,7 +10,7 @@
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [7])
m4_define([gtk_micro_version], [4])
m4_define([gtk_micro_version], [3])
m4_define([gtk_interface_age], [0])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
@@ -39,8 +39,8 @@ AC_CONFIG_AUX_DIR([build-aux])
m4_define([gtk_binary_version], [3.0.0])
# required versions of other packages
m4_define([glib_required_version], [2.35.3])
m4_define([pango_required_version], [1.32.4])
m4_define([glib_required_version], [2.35.0])
m4_define([pango_required_version], [1.30.0])
m4_define([atk_required_version], [2.5.3])
m4_define([cairo_required_version], [1.10.0])
m4_define([gdk_pixbuf_required_version], [2.26.0])
-4
View File
@@ -406,10 +406,6 @@
<title>Index of new symbols in 3.6</title>
<xi:include href="xml/api-index-3.6.xml"><xi:fallback /></xi:include>
</index>
<index id="api-index-3-8" role="3.8">
<title>Index of new symbols in 3.8</title>
<xi:include href="xml/api-index-3.8.xml"><xi:fallback /></xi:include>
</index>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback /></xi:include>
-1
View File
@@ -536,7 +536,6 @@ gtk_builder_add_objects_from_string
gtk_builder_add_objects_from_resource
gtk_builder_get_object
gtk_builder_get_objects
gtk_builder_expose_object
gtk_builder_connect_signals
gtk_builder_connect_signals_full
gtk_builder_set_translation_domain
+2 -2
View File
@@ -1060,7 +1060,7 @@ _gdk_broadway_display_open (const gchar *display_name)
{
GdkDisplay *display;
GdkBroadwayDisplay *broadway_display;
GError *error = NULL;
GError *error;
int port;
display = g_object_new (GDK_TYPE_BROADWAY_DISPLAY, NULL);
@@ -1104,7 +1104,7 @@ _gdk_broadway_display_open (const gchar *display_name)
G_OBJECT (display),
&error))
{
g_printerr ("Unable to listen to port %d: %s\n", port, error->message);
g_printerr ("Unable to listen to port %d: %s\n", 8080, error->message);
g_error_free (error);
return NULL;
}
+2 -2
View File
@@ -6549,8 +6549,8 @@ gdk_window_set_background (GdkWindow *window,
* See also gdk_window_set_background_pattern().
**/
void
gdk_window_set_background_rgba (GdkWindow *window,
const GdkRGBA *rgba)
gdk_window_set_background_rgba (GdkWindow *window,
GdkRGBA *rgba)
{
cairo_pattern_t *pattern;
+2 -2
View File
@@ -659,8 +659,8 @@ void gdk_window_set_transient_for (GdkWindow *window,
GDK_DEPRECATED_IN_3_4_FOR(gdk_window_set_background_rgba)
void gdk_window_set_background (GdkWindow *window,
const GdkColor *color);
void gdk_window_set_background_rgba (GdkWindow *window,
const GdkRGBA *rgba);
void gdk_window_set_background_rgba (GdkWindow *window,
GdkRGBA *rgba);
void gdk_window_set_background_pattern (GdkWindow *window,
cairo_pattern_t *pattern);
cairo_pattern_t *gdk_window_get_background_pattern (GdkWindow *window);
+3 -8
View File
@@ -28,14 +28,9 @@ GdkWindow *_gdk_root = NULL;
GdkOSXVersion
gdk_quartz_osx_version (void)
{
static gint32 minor = GDK_OSX_UNSUPPORTED;
if (minor == GDK_OSX_UNSUPPORTED)
{
OSErr err = Gestalt (gestaltSystemVersionMinor, (SInt32*)&minor);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
}
gint minor;
OSErr err = Gestalt (gestaltSystemVersionMinor, &minor);
g_return_val_if_fail (err == noErr, GDK_OSX_UNSUPPORTED);
if (minor < GDK_OSX_MIN)
return GDK_OSX_UNSUPPORTED;
+1 -2
View File
@@ -48,8 +48,7 @@ typedef enum
GDK_OSX_LEOPARD = 5,
GDK_OSX_SNOW_LEOPARD = 6,
GDK_OSX_LION = 7,
GDK_OSX_MOUNTAIN_LION = 8,
GDK_OSX_CURRENT = 8,
GDK_OSX_CURRENT = 7,
GDK_OSX_NEW = 99
} GdkOSXVersion;
+2 -3
View File
@@ -27,7 +27,6 @@
#include "config.h"
#include <stdlib.h>
#include <windows.h>
#include "gdk.h"
#include "gdkwindowimpl.h"
@@ -1534,7 +1533,7 @@ gdk_win32_window_set_urgency_hint (GdkWindow *window,
gboolean urgent)
{
FLASHWINFO flashwinfo;
typedef BOOL (WINAPI *PFN_FlashWindowEx) (FLASHWINFO*);
typedef BOOL (*PFN_FlashWindowEx) (FLASHWINFO*);
PFN_FlashWindowEx flashWindowEx = NULL;
g_return_if_fail (GDK_IS_WINDOW (window));
@@ -3265,7 +3264,7 @@ gdk_win32_window_set_opacity (GdkWindow *window,
gdouble opacity)
{
LONG exstyle;
typedef BOOL (WINAPI *PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
typedef BOOL (*PFN_SetLayeredWindowAttributes) (HWND, COLORREF, BYTE, DWORD);
PFN_SetLayeredWindowAttributes setLayeredWindowAttributes = NULL;
g_return_if_fail (GDK_IS_WINDOW (window));
+5 -18
View File
@@ -917,14 +917,12 @@ is_parent_of (GdkWindow *parent,
return FALSE;
}
static gboolean
static GdkWindow *
get_event_window (GdkEventTranslator *translator,
XIEvent *ev,
GdkWindow **window_p)
XIEvent *ev)
{
GdkDisplay *display;
GdkWindow *window = NULL;
gboolean should_have_window = TRUE;
display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (translator));
@@ -978,17 +976,9 @@ get_event_window (GdkEventTranslator *translator,
window = gdk_x11_window_lookup_for_display (display, xev->event);
}
break;
default:
should_have_window = FALSE;
break;
}
*window_p = window;
if (should_have_window && !window)
return FALSE;
return TRUE;
return window;
}
static gboolean
@@ -1132,8 +1122,7 @@ gdk_x11_device_manager_xi2_translate_event (GdkEventTranslator *translator,
if (!ev)
return FALSE;
if (!get_event_window (translator, ev, &window))
return FALSE;
window = get_event_window (translator, ev);
if (window && GDK_WINDOW_DESTROYED (window))
return FALSE;
@@ -1661,7 +1650,6 @@ gdk_x11_device_manager_xi2_get_window (GdkEventTranslator *translator,
{
GdkX11DeviceManagerXI2 *device_manager;
XIEvent *ev;
GdkWindow *window = NULL;
device_manager = (GdkX11DeviceManagerXI2 *) translator;
@@ -1671,8 +1659,7 @@ gdk_x11_device_manager_xi2_get_window (GdkEventTranslator *translator,
ev = (XIEvent *) xevent->xcookie.data;
get_event_window (translator, ev, &window);
return window;
return get_event_window (translator, ev);
}
GdkDevice *
+2 -4
View File
@@ -82,8 +82,7 @@ static const char gdk_settings_names[] =
"Gtk/VisibleFocus\0" "gtk-visible-focus\0"
"Gtk/ShellShowsAppMenu\0" "gtk-shell-shows-app-menu\0"
"Gtk/ShellShowsMenubar\0" "gtk-shell-shows-menubar\0"
"Gtk/EnablePrimaryPaste\0" "gtk-enable-primary-paste\0"
"Gtk/RecentFilesMaxAge\0" "gtk-recent-files-max-age\0";
"Gtk/EnablePrimaryPaste\0" "gtk-enable-primary-paste\0";
@@ -141,6 +140,5 @@ static const struct
{ 1767, 1784 },
{ 1802, 1824 },
{ 1849, 1871 },
{ 1895, 1918 },
{ 1943, 1965 }
{ 1895, 1918 }
};
-3
View File
@@ -287,13 +287,10 @@ gtk_cell_accessible_action_do_action (AtkAction *action,
{
case 0:
_gtk_cell_accessible_parent_expand_collapse (parent, cell);
break;
case 1:
_gtk_cell_accessible_parent_edit (parent, cell);
break;
case 2:
_gtk_cell_accessible_parent_activate (parent, cell);
break;
default:
return FALSE;
}
+2 -4
View File
@@ -549,8 +549,7 @@ gtk_entry_accessible_notify_gtk (GObject *obj,
const gchar *name;
name = gtk_entry_get_icon_name (gtk_entry,
GTK_ENTRY_ICON_PRIMARY);
if (name)
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_PRIMARY], name);
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_PRIMARY], name);
}
}
else if (g_strcmp0 (pspec->name, "secondary-icon-name") == 0)
@@ -560,8 +559,7 @@ gtk_entry_accessible_notify_gtk (GObject *obj,
const gchar *name;
name = gtk_entry_get_icon_name (gtk_entry,
GTK_ENTRY_ICON_SECONDARY);
if (name)
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_SECONDARY], name);
atk_object_set_name (priv->icons[GTK_ENTRY_ICON_SECONDARY], name);
}
}
else if (g_strcmp0 (pspec->name, "primary-icon-tooltip-text") == 0)
+1 -1
View File
@@ -708,7 +708,7 @@ gtk_icon_view_item_accessible_is_showing (GtkIconViewItemAccessible *item)
if (icon_view->priv->hadjustment)
visible_rect.x += gtk_adjustment_get_value (icon_view->priv->hadjustment);
visible_rect.y = 0;
if (icon_view->priv->vadjustment)
if (icon_view->priv->hadjustment)
visible_rect.y += gtk_adjustment_get_value (icon_view->priv->vadjustment);
visible_rect.width = allocation.width;
visible_rect.height = allocation.height;
-6
View File
@@ -23,7 +23,6 @@
struct _GtkMenuItemAccessiblePrivate
{
gchar *text;
gboolean selected;
};
#define KEYBINDING_SEPARATOR ";"
@@ -148,10 +147,6 @@ gtk_menu_item_accessible_ref_state_set (AtkObject *obj)
state_set = ATK_OBJECT_CLASS (_gtk_menu_item_accessible_parent_class)->ref_state_set (obj);
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
if (GTK_MENU_ITEM_ACCESSIBLE (obj)->priv->selected)
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
menu_item = atk_object_get_parent (obj);
if (menu_item)
@@ -625,7 +620,6 @@ menu_item_selection (GtkMenuItem *item,
gint i;
obj = gtk_widget_get_accessible (GTK_WIDGET (item));
GTK_MENU_ITEM_ACCESSIBLE (obj)->priv->selected = selected;
atk_object_notify_state_change (obj, ATK_STATE_SELECTED, selected);
for (i = 0; i < atk_object_get_n_accessible_children (obj); i++)
-9
View File
@@ -140,21 +140,12 @@ gtk_notebook_page_accessible_ref_child (AtkObject *accessible,
static AtkStateSet *
gtk_notebook_page_accessible_ref_state_set (AtkObject *accessible)
{
GtkNotebookPageAccessible *page = GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible);
AtkStateSet *state_set, *label_state_set, *merged_state_set;
AtkObject *atk_label;
GtkWidget *label;
AtkObject *selected;
state_set = ATK_OBJECT_CLASS (_gtk_notebook_page_accessible_parent_class)->ref_state_set (accessible);
atk_state_set_add_state (state_set, ATK_STATE_SELECTABLE);
selected = atk_selection_ref_selection (ATK_SELECTION (page->priv->notebook), 0);
if (selected == accessible)
atk_state_set_add_state (state_set, ATK_STATE_SELECTED);
g_object_unref (selected);
label = get_label_from_notebook_page (GTK_NOTEBOOK_PAGE_ACCESSIBLE (accessible));
if (label)
{
+5 -7
View File
@@ -474,12 +474,6 @@ gtk_widget_accessible_notify_gtk (GObject *obj,
* focus changes so we ignore this.
*/
return;
else if (g_strcmp0 (pspec->name, "tooltip-text") == 0)
{
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj),
widget);
return;
}
else if (g_strcmp0 (pspec->name, "visible") == 0)
{
state = ATK_STATE_VISIBLE;
@@ -500,7 +494,11 @@ gtk_widget_accessible_notify_gtk (GObject *obj,
state = ATK_STATE_HORIZONTAL;
value = (gtk_orientable_get_orientation (orientable) == GTK_ORIENTATION_HORIZONTAL);
}
else
else if (g_strcmp0 (pspec->name, "tooltip-text") == 0)
{
gtk_widget_accessible_update_tooltip (GTK_WIDGET_ACCESSIBLE (atk_obj),
widget);
}
return;
atk_object_notify_state_change (atk_obj, state, value);
-1
View File
@@ -338,7 +338,6 @@ gtk_builder_connect_signals
gtk_builder_connect_signals_full
gtk_builder_error_get_type
gtk_builder_error_quark
gtk_builder_expose_object
gtk_builder_get_object
gtk_builder_get_objects
gtk_builder_get_translation_domain
+12 -9
View File
@@ -2095,9 +2095,11 @@ text_view_new (GtkAboutDialog *about,
GdkColor color;
GdkColor link_color;
GdkColor visited_link_color;
gint size;
PangoFontDescription *font_desc;
GtkAboutDialogPrivate *priv = about->priv;
GtkTextIter start_iter, end_iter;
GtkTextTag *tag;
GtkStyleContext *context;
GtkStateFlags state;
gtk_widget_style_get (GTK_WIDGET (about),
"link-color", &style_link_color,
@@ -2126,11 +2128,14 @@ text_view_new (GtkAboutDialog *about,
gtk_text_view_set_editable (text_view, FALSE);
gtk_text_view_set_wrap_mode (text_view, wrap_mode);
gtk_text_buffer_get_start_iter (buffer, &start_iter);
gtk_text_buffer_get_start_iter (buffer, &end_iter);
tag = gtk_text_tag_new (NULL);
g_object_set (tag, "font-scale", PANGO_SCALE_SMALL, NULL);
gtk_text_buffer_apply_tag (buffer, tag, &start_iter, &end_iter);
context = gtk_widget_get_style_context (view);
state = gtk_widget_get_state_flags (view);
size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
font_desc = pango_font_description_new ();
pango_font_description_set_size (font_desc, size * PANGO_SCALE_SMALL);
gtk_widget_override_font (view, font_desc);
pango_font_description_free (font_desc);
gtk_text_view_set_left_margin (text_view, 8);
gtk_text_view_set_right_margin (text_view, 8);
@@ -2390,8 +2395,6 @@ create_credits_page (GtkAboutDialog *about)
gtk_widget_set_valign (grid, GTK_ALIGN_START);
gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), grid);
row = 0;
if (priv->authors != NULL)
add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors);
+1 -1
View File
@@ -189,7 +189,7 @@ gtk_action_helper_action_removed (GtkActionHelper *helper)
if (helper->active)
{
helper->active = FALSE;
helper->enabled = FALSE;
gtk_action_helper_report_change (helper, PROP_ACTIVE);
}
+24 -64
View File
@@ -123,14 +123,12 @@
* (can be specified by their name, nick or integer value), flags (can be
* specified by their name, nick, integer value, optionally combined with "|",
* e.g. "GTK_VISIBLE|GTK_REALIZED") and colors (in a format understood by
* gdk_color_parse()). Pixbufs can be specified as a filename of an image file to load.
* Objects can be referred to by their name and by default refer to objects declared
* in the local xml fragment and objects exposed via gtk_builder_expose_object().
*
* In general, GtkBuilder allows forward references to objects &mdash declared
* in the local xml; an object doesn't have to be constructed before it can be referred to.
* The exception to this rule is that an object has to be constructed before
* it can be used as the value of a construct-only property.
* gdk_color_parse()). Objects can be referred to by their name. Pixbufs can be
* specified as a filename of an image file to load. In general, GtkBuilder
* allows forward references to objects &mdash; an object doesn't have to be
* constructed before it can be referred to. The exception to this rule is that
* an object has to be constructed before it can be used as the value of a
* construct-only property.
*
* Signal handlers are set up with the &lt;signal&gt; element. The "name"
* attribute specifies the name of the signal, and the "handler" attribute
@@ -576,24 +574,6 @@ gtk_builder_get_internal_child (GtkBuilder *builder,
return obj;
}
static inline void
object_set_name (GObject *object, const gchar *name)
{
if (GTK_IS_BUILDABLE (object))
gtk_buildable_set_name (GTK_BUILDABLE (object), name);
else
g_object_set_data_full (object, "gtk-builder-name", g_strdup (name), g_free);
}
void
_gtk_builder_add_object (GtkBuilder *builder,
const gchar *id,
GObject *object)
{
object_set_name (object, id);
g_hash_table_insert (builder->priv->objects, g_strdup (id), g_object_ref (object));
}
GObject *
_gtk_builder_construct (GtkBuilder *builder,
ObjectInfo *info,
@@ -723,16 +703,29 @@ _gtk_builder_construct (GtkBuilder *builder,
g_value_unset (&param->value);
}
g_array_free (parameters, TRUE);
/* put it in the hash table. */
_gtk_builder_add_object (builder, info->id, obj);
/* we already own a reference to obj. */
g_object_unref (obj);
if (GTK_IS_BUILDABLE (obj))
gtk_buildable_set_name (buildable, info->id);
else
g_object_set_data_full (obj,
"gtk-builder-name",
g_strdup (info->id),
g_free);
/* we already own a reference to obj. put it in the hash table. */
g_hash_table_insert (builder->priv->objects, g_strdup (info->id), obj);
return obj;
}
void
_gtk_builder_add_object (GtkBuilder *builder,
const gchar *id,
GObject *object)
{
g_hash_table_insert (builder->priv->objects, g_strdup (id), g_object_ref (object));
}
void
_gtk_builder_add (GtkBuilder *builder,
ChildInfo *child_info)
@@ -1347,39 +1340,6 @@ gtk_builder_get_translation_domain (GtkBuilder *builder)
return builder->priv->domain;
}
/**
* gtk_builder_expose_object:
* @builder: a #GtkBuilder
* @name: the name of the object exposed to the builder
* @object: the object to expose
*
* Add @object to the @builder object pool so it can be referenced just like any
* other object built by builder.
*
* To make this function even more useful a new special entry point element
* &lt;external-object&gt; is defined. It is similar to &lt;object&gt; but has
* to reference an external object exposed with this function.
* This way you can change properties and even add children to an
* external object using builder, not just reference it.
*
* Since: 3.8
**/
void
gtk_builder_expose_object (GtkBuilder *builder,
const gchar *name,
GObject *object)
{
g_return_if_fail (GTK_IS_BUILDER (builder));
g_return_if_fail (name && name[0]);
g_return_if_fail (gtk_builder_get_object (builder, name) == NULL);
object_set_name (object, name);
g_hash_table_insert (builder->priv->objects,
g_strdup (name),
g_object_ref (object));
}
typedef struct {
GModule *module;
gpointer data;
-4
View File
@@ -141,10 +141,6 @@ guint gtk_builder_add_objects_from_string (GtkBuilder *builder,
GObject* gtk_builder_get_object (GtkBuilder *builder,
const gchar *name);
GSList* gtk_builder_get_objects (GtkBuilder *builder);
GDK_AVAILABLE_IN_3_8
void gtk_builder_expose_object (GtkBuilder *builder,
const gchar *name,
GObject *object);
void gtk_builder_connect_signals (GtkBuilder *builder,
gpointer user_data);
void gtk_builder_connect_signals_full (GtkBuilder *builder,
+7 -3
View File
@@ -1768,7 +1768,7 @@ get_size (GtkCellRenderer *cell,
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get (style_context, state, "font", &font_desc, NULL);
font_desc = pango_font_description_copy_static (gtk_style_context_get_font (style_context, state));
pango_font_description_merge_static (font_desc, priv->font, TRUE);
if (priv->scale_set)
@@ -2128,6 +2128,8 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
{
GtkCellRendererTextPrivate *priv;
GtkCellRendererText *celltext;
GtkStyleContext *style_context;
const PangoFontDescription *font_desc;
PangoLayout *layout;
PangoContext *context;
PangoFontMetrics *metrics;
@@ -2147,6 +2149,8 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
celltext = GTK_CELL_RENDERER_TEXT (cell);
priv = celltext->priv;
style_context = gtk_widget_get_style_context (widget);
gtk_cell_renderer_get_padding (cell, &xpad, NULL);
layout = get_layout (celltext, widget, NULL, 0);
@@ -2158,8 +2162,8 @@ gtk_cell_renderer_text_get_preferred_width (GtkCellRenderer *cell,
/* Fetch the average size of a charachter */
context = pango_layout_get_context (layout);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
font_desc = gtk_style_context_get_font (style_context, 0);
metrics = pango_context_get_metrics (context, font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
+37 -74
View File
@@ -31,30 +31,20 @@
#include "gtktextbuffer.h"
#include "gtkselectionprivate.h"
#include "gtkquartz.h"
#include "../gdk/quartz/gdkquartz.h"
enum {
OWNER_CHANGE,
LAST_SIGNAL
};
@interface GtkClipboardOwner : NSObject {
GtkClipboard *clipboard;
@public
gboolean setting_same_owner;
}
@end
typedef struct _GtkClipboardClass GtkClipboardClass;
struct _GtkClipboard
struct _GtkClipboard
{
GObject parent_instance;
NSPasteboard *pasteboard;
GtkClipboardOwner *owner;
NSInteger change_count;
GdkAtom selection;
@@ -86,15 +76,16 @@ struct _GtkClipboardClass
GdkEventOwnerChange *event);
};
static void gtk_clipboard_class_init (GtkClipboardClass *class);
static void gtk_clipboard_finalize (GObject *object);
static void gtk_clipboard_owner_change (GtkClipboard *clipboard,
GdkEventOwnerChange *event);
@interface GtkClipboardOwner : NSObject {
GtkClipboard *clipboard;
static void clipboard_unset (GtkClipboard *clipboard);
static GtkClipboard *clipboard_peek (GdkDisplay *display,
GdkAtom selection,
gboolean only_if_exists);
GtkClipboardGetFunc get_func;
GtkClipboardClearFunc clear_func;
gpointer user_data;
}
@end
@implementation GtkClipboardOwner
-(void)pasteboard:(NSPasteboard *)sender provideDataForType:(NSString *)type
@@ -126,16 +117,12 @@ static GtkClipboard *clipboard_peek (GdkDisplay *display,
}
}
/* pasteboardChangedOwner is not called immediately, and it's not called
* reliably. It is somehow documented in the apple api docs, but the docs
* suck and don't really give clear instructions. Therefore we track
* changeCount in several places below and clear the clipboard if it
* changed.
*/
- (void)pasteboardChangedOwner:(NSPasteboard *)sender
{
if (! setting_same_owner)
clipboard_unset (clipboard);
if (clear_func)
clear_func (clipboard, user_data);
[self release];
}
- (id)initWithClipboard:(GtkClipboard *)aClipboard
@@ -145,7 +132,6 @@ static GtkClipboard *clipboard_peek (GdkDisplay *display,
if (self)
{
clipboard = aClipboard;
setting_same_owner = FALSE;
}
return self;
@@ -153,6 +139,15 @@ static GtkClipboard *clipboard_peek (GdkDisplay *display,
@end
static void gtk_clipboard_class_init (GtkClipboardClass *class);
static void gtk_clipboard_finalize (GObject *object);
static void gtk_clipboard_owner_change (GtkClipboard *clipboard,
GdkEventOwnerChange *event);
static void clipboard_unset (GtkClipboard *clipboard);
static GtkClipboard *clipboard_peek (GdkDisplay *display,
GdkAtom selection,
gboolean only_if_exists);
static const gchar clipboards_owned_key[] = "gtk-clipboards-owned";
static GQuark clipboards_owned_key_id = 0;
@@ -336,6 +331,10 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
NSSet *types;
NSAutoreleasePool *pool;
pool = [[NSAutoreleasePool alloc] init];
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
if (!(clipboard->have_owner && have_owner) ||
clipboard->user_data != user_data)
{
@@ -350,44 +349,17 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
clipboard->user_data != user_data)
{
(*clear_func) (clipboard, user_data);
[pool release];
return FALSE;
}
else
{
[pool release];
return TRUE;
}
}
}
pool = [[NSAutoreleasePool alloc] init];
types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
/* call declareTypes before setting the clipboard members because
* declareTypes might clear the clipboard
*/
if (user_data && user_data == clipboard->user_data)
{
owner = [clipboard->owner retain];
owner->setting_same_owner = TRUE;
clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
owner: owner];
owner->setting_same_owner = FALSE;
}
else
{
owner = [[GtkClipboardOwner alloc] initWithClipboard:clipboard];
clipboard->change_count = [clipboard->pasteboard declareTypes: [types allObjects]
owner: owner];
}
[owner release];
[types release];
[pool release];
clipboard->owner = owner;
clipboard->user_data = user_data;
clipboard->have_owner = have_owner;
if (have_owner)
@@ -399,6 +371,12 @@ gtk_clipboard_set_contents (GtkClipboard *clipboard,
gtk_target_list_unref (clipboard->target_list);
clipboard->target_list = gtk_target_list_new (targets, n_targets);
types = _gtk_quartz_target_entries_to_pasteboard_types (targets, n_targets);
[clipboard->pasteboard declareTypes:[types allObjects] owner:owner];
[types release];
[pool release];
return TRUE;
}
@@ -442,12 +420,6 @@ gtk_clipboard_get_owner (GtkClipboard *clipboard)
{
g_return_val_if_fail (clipboard != NULL, NULL);
if (clipboard->change_count < [clipboard->pasteboard changeCount])
{
clipboard_unset (clipboard);
clipboard->change_count = [clipboard->pasteboard changeCount];
}
if (clipboard->have_owner)
return clipboard->user_data;
else
@@ -476,8 +448,7 @@ clipboard_unset (GtkClipboard *clipboard)
clipboard->n_storable_targets = -1;
g_free (clipboard->storable_targets);
clipboard->storable_targets = NULL;
clipboard->owner = NULL;
clipboard->get_func = NULL;
clipboard->clear_func = NULL;
clipboard->user_data = NULL;
@@ -502,8 +473,6 @@ clipboard_unset (GtkClipboard *clipboard)
void
gtk_clipboard_clear (GtkClipboard *clipboard)
{
clipboard_unset (clipboard);
[clipboard->pasteboard declareTypes:nil owner:nil];
}
@@ -687,12 +656,6 @@ gtk_clipboard_wait_for_contents (GtkClipboard *clipboard,
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
GtkSelectionData *selection_data = NULL;
if (clipboard->change_count < [clipboard->pasteboard changeCount])
{
clipboard_unset (clipboard);
clipboard->change_count = [clipboard->pasteboard changeCount];
}
if (target == gdk_atom_intern_static_string ("TARGETS"))
{
NSArray *types = [clipboard->pasteboard types];
+26 -33
View File
@@ -584,42 +584,36 @@ dialog_response (GtkDialog *dialog,
}
}
/* Create the dialog and connects its buttons */
static void
ensure_dialog (GtkColorButton *button)
{
GtkWidget *parent, *dialog;
if (button->priv->cs_dialog != NULL)
return;
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
gtk_window_set_modal (GTK_WINDOW (dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
g_signal_connect (dialog, "response",
G_CALLBACK (dialog_response), button);
g_signal_connect (dialog, "destroy",
G_CALLBACK (dialog_destroy), button);
}
static void
gtk_color_button_clicked (GtkButton *b)
{
GtkColorButton *button = GTK_COLOR_BUTTON (b);
GtkWidget *dialog;
/* if dialog already exists, make sure it's shown and raised */
ensure_dialog (button);
if (!button->priv->cs_dialog)
{
/* Create the dialog and connects its buttons */
GtkWidget *parent;
parent = gtk_widget_get_toplevel (GTK_WIDGET (button));
button->priv->cs_dialog = dialog = gtk_color_chooser_dialog_new (button->priv->title, NULL);
if (gtk_widget_is_toplevel (parent) && GTK_IS_WINDOW (parent))
{
if (GTK_WINDOW (parent) != gtk_window_get_transient_for (GTK_WINDOW (dialog)))
gtk_window_set_transient_for (GTK_WINDOW (dialog), GTK_WINDOW (parent));
gtk_window_set_modal (GTK_WINDOW (dialog),
gtk_window_get_modal (GTK_WINDOW (parent)));
}
g_signal_connect (dialog, "response",
G_CALLBACK (dialog_response), button);
g_signal_connect (dialog, "destroy",
G_CALLBACK (dialog_destroy), button);
}
gtk_color_chooser_set_use_alpha (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
button->priv->use_alpha);
@@ -968,9 +962,8 @@ gtk_color_button_add_palette (GtkColorChooser *chooser,
{
GtkColorButton *button = GTK_COLOR_BUTTON (chooser);
ensure_dialog (button);
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
if (button->priv->cs_dialog)
gtk_color_chooser_add_palette (GTK_COLOR_CHOOSER (button->priv->cs_dialog),
orientation, colors_per_line, n_colors, colors);
}
+8 -2
View File
@@ -5446,9 +5446,12 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
gint font_size, arrow_size;
PangoContext *context;
PangoFontMetrics *metrics;
const PangoFontDescription *font_desc;
GtkWidget *child;
gint minimum_width = 0, natural_width = 0;
gint child_min, child_nat;
GtkStyleContext *style_context;
GtkStateFlags state;
GtkBorder padding;
gfloat arrow_scaling;
@@ -5462,11 +5465,14 @@ gtk_combo_box_get_preferred_width (GtkWidget *widget,
"arrow-scaling", &arrow_scaling,
NULL);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
get_widget_padding_and_border (widget, &padding);
font_desc = gtk_style_context_get_font (style_context, state);
context = gtk_widget_get_pango_context (GTK_WIDGET (widget));
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
metrics = pango_context_get_metrics (context, font_desc,
pango_context_get_language (context));
font_size = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
pango_font_metrics_get_descent (metrics));
+13 -18
View File
@@ -51,33 +51,28 @@ gtk_css_value_array_compute (GtkCssValue *value,
GtkCssDependencies *dependencies)
{
GtkCssValue *result;
GtkCssValue *i_value;
guint i, j;
gboolean changed = FALSE;
guint i;
GtkCssDependencies child_deps;
result = NULL;
if (value->n_values == 0)
return _gtk_css_value_ref (value);
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
for (i = 0; i < value->n_values; i++)
{
i_value = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
result->values[i] = _gtk_css_value_compute (value->values[i], property_id, provider, values, parent_values, &child_deps);
*dependencies = _gtk_css_dependencies_union (*dependencies, child_deps);
if (result == NULL &&
i_value != value->values[i])
{
result = _gtk_css_array_value_new_from_array (value->values, value->n_values);
for (j = 0; j < i; j++)
_gtk_css_value_ref (result->values[j]);
}
if (result != NULL)
result->values[i] = i_value;
else
_gtk_css_value_unref (i_value);
changed |= (result->values[i] != value->values[i]);
}
if (result == NULL)
return _gtk_css_value_ref (value);
if (!changed)
{
_gtk_css_value_unref (result);
return _gtk_css_value_ref (value);
}
return result;
}
+1 -1
View File
@@ -74,7 +74,7 @@ gtk_css_value_bg_size_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
return value1->cover == value2->cover &&
value1->contain == value2->contain &&
value2->contain == value2->contain &&
(value1->x == value2->x ||
(value1->x != NULL && value2->x != NULL &&
_gtk_css_value_equal (value1->x, value2->x))) &&
+15 -17
View File
@@ -19,7 +19,6 @@
#include "config.h"
#include "gtkprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssanimationprivate.h"
@@ -121,9 +120,9 @@ _gtk_css_computed_values_compute_value (GtkCssComputedValues *values,
GtkCssDependencies dependencies;
GtkCssValue *value;
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
gtk_internal_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values));
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider));
g_return_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values));
/* http://www.w3.org/TR/css3-cascade/#cascade
* Then, for every element, the value for each property can be found
@@ -155,8 +154,8 @@ _gtk_css_computed_values_set_animated_value (GtkCssComputedValues *values,
guint id,
GtkCssValue *value)
{
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
gtk_internal_return_if_fail (value != NULL);
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (value != NULL);
if (values->animated_values == NULL)
values->animated_values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
@@ -176,11 +175,10 @@ _gtk_css_computed_values_set_value (GtkCssComputedValues *values,
GtkCssDependencies dependencies,
GtkCssSection *section)
{
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
if (values->values == NULL)
values->values = g_ptr_array_new_full (_gtk_css_style_property_get_n_properties (),
(GDestroyNotify)_gtk_css_value_unref);
values->values = g_ptr_array_new_with_free_func ((GDestroyNotify)_gtk_css_value_unref);
if (id >= values->values->len)
g_ptr_array_set_size (values->values, id + 1);
@@ -218,7 +216,7 @@ GtkCssValue *
_gtk_css_computed_values_get_value (GtkCssComputedValues *values,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->animated_values &&
id < values->animated_values->len &&
@@ -232,7 +230,7 @@ GtkCssValue *
_gtk_css_computed_values_get_intrinsic_value (GtkCssComputedValues *values,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->values == NULL ||
id >= values->values->len)
@@ -245,7 +243,7 @@ GtkCssSection *
_gtk_css_computed_values_get_section (GtkCssComputedValues *values,
guint id)
{
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
if (values->sections == NULL ||
id >= values->sections->len)
@@ -530,8 +528,8 @@ _gtk_css_computed_values_advance (GtkCssComputedValues *values,
GSList *list;
guint i;
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (timestamp >= values->current_time, NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (timestamp >= values->current_time, NULL);
values->current_time = timestamp;
old_computed_values = values->animated_values;
@@ -580,7 +578,7 @@ _gtk_css_computed_values_is_static (GtkCssComputedValues *values)
{
GSList *list;
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), TRUE);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), TRUE);
for (list = values->animations; list; list = list->next)
{
@@ -594,7 +592,7 @@ _gtk_css_computed_values_is_static (GtkCssComputedValues *values)
void
_gtk_css_computed_values_cancel_animations (GtkCssComputedValues *values)
{
gtk_internal_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
g_return_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values));
if (values->animated_values)
{
@@ -612,7 +610,7 @@ _gtk_css_computed_values_compute_dependencies (GtkCssComputedValues *values,
{
GtkBitmask *changes;
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), _gtk_bitmask_new ());
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), _gtk_bitmask_new ());
changes = _gtk_bitmask_copy (parent_changes);
changes = _gtk_bitmask_intersect (changes, values->depends_on_parent);
-7
View File
@@ -211,8 +211,6 @@ gtk_css_custom_property_create_initial_value (GParamSpec *pspec)
* </note>
*
* Since: 3.0
*
* Deprecated: 3.8: Code should use the default properties provided by CSS.
**/
void
gtk_theming_engine_register_property (const gchar *name_space,
@@ -262,8 +260,6 @@ gtk_theming_engine_register_property (const gchar *name_space,
* a theming engine, you want to use that function instead.
*
* Since: 3.0
*
* Deprecated: 3.8: Code should use the default properties provided by CSS.
**/
void
gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
@@ -307,9 +303,6 @@ gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
* Returns: %TRUE if the property is registered, %FALSE otherwise
*
* Since: 3.0
*
* Deprecated: 3.8: This code could only look up custom properties and
* those are deprecated.
**/
gboolean
gtk_style_properties_lookup_property (const gchar *property_name,
+1 -148
View File
@@ -19,9 +19,7 @@
#include "gtkcssenumvalueprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkstyleproviderprivate.h"
#include "gtkstylepropertyprivate.h"
/* repeated API */
@@ -126,151 +124,6 @@ _gtk_css_border_style_value_get (const GtkCssValue *value)
return value->value;
}
/* GtkCssFontSize */
/* XXX: Kinda bad to have that machinery here, nobody expects vital font
* size code to appear in gtkcssvalueenum.c.
*/
#define DEFAULT_FONT_SIZE 10
double
_gtk_css_font_size_get_default (GtkStyleProviderPrivate *provider)
{
GtkSettings *settings;
PangoFontDescription *description;
char *font_name;
double font_size;
settings = _gtk_style_provider_private_get_settings (provider);
if (settings == NULL)
return DEFAULT_FONT_SIZE;
g_object_get (settings, "gtk-font-name", &font_name, NULL);
description = pango_font_description_from_string (font_name);
g_free (font_name);
if (description == NULL)
return DEFAULT_FONT_SIZE;
if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_SIZE)
font_size = (double) pango_font_description_get_size (description) / PANGO_SCALE;
else
font_size = DEFAULT_FONT_SIZE;
pango_font_description_free (description);
return font_size;
}
static GtkCssValue *
gtk_css_value_font_size_compute (GtkCssValue *value,
guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
{
double font_size;
switch (value->value)
{
case GTK_CSS_FONT_SIZE_XX_SMALL:
font_size = _gtk_css_font_size_get_default (provider) * 3. / 5;
break;
case GTK_CSS_FONT_SIZE_X_SMALL:
font_size = _gtk_css_font_size_get_default (provider) * 3. / 4;
break;
case GTK_CSS_FONT_SIZE_SMALL:
font_size = _gtk_css_font_size_get_default (provider) * 8. / 9;
break;
default:
g_assert_not_reached ();
/* fall thru */
case GTK_CSS_FONT_SIZE_MEDIUM:
font_size = _gtk_css_font_size_get_default (provider);
break;
case GTK_CSS_FONT_SIZE_LARGE:
font_size = _gtk_css_font_size_get_default (provider) * 6. / 5;
break;
case GTK_CSS_FONT_SIZE_X_LARGE:
font_size = _gtk_css_font_size_get_default (provider) * 3. / 2;
break;
case GTK_CSS_FONT_SIZE_XX_LARGE:
font_size = _gtk_css_font_size_get_default (provider) * 2;
break;
case GTK_CSS_FONT_SIZE_SMALLER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
font_size = _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
font_size = _gtk_css_font_size_get_default (provider);
/* XXX: This is what WebKit does... */
font_size /= 1.2;
break;
case GTK_CSS_FONT_SIZE_LARGER:
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
font_size = _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
font_size = _gtk_css_font_size_get_default (provider);
/* XXX: This is what WebKit does... */
font_size *= 1.2;
break;
}
return _gtk_css_number_value_new (font_size, GTK_CSS_PX);
}
static const GtkCssValueClass GTK_CSS_VALUE_FONT_SIZE = {
gtk_css_value_enum_free,
gtk_css_value_font_size_compute,
gtk_css_value_enum_equal,
gtk_css_value_enum_transition,
gtk_css_value_enum_print
};
static GtkCssValue font_size_values[] = {
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_SMALLER, "smaller" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_LARGER, "larger" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_XX_SMALL, "xx-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_X_SMALL, "x-small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_SMALL, "small" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_MEDIUM, "medium" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_LARGE, "large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_X_LARGE, "x-large" },
{ &GTK_CSS_VALUE_FONT_SIZE, 1, GTK_CSS_FONT_SIZE_XX_LARGE, "xx-large" }
};
GtkCssValue *
_gtk_css_font_size_value_new (GtkCssFontSize font_size)
{
g_return_val_if_fail (font_size < G_N_ELEMENTS (font_size_values), NULL);
return _gtk_css_value_ref (&font_size_values[font_size]);
}
GtkCssValue *
_gtk_css_font_size_value_try_parse (GtkCssParser *parser)
{
guint i;
g_return_val_if_fail (parser != NULL, NULL);
for (i = 0; i < G_N_ELEMENTS (font_size_values); i++)
{
if (_gtk_css_parser_try (parser, font_size_values[i].name, TRUE))
return _gtk_css_value_ref (&font_size_values[i]);
}
return NULL;
}
GtkCssFontSize
_gtk_css_font_size_value_get (const GtkCssValue *value)
{
g_return_val_if_fail (value->class == &GTK_CSS_VALUE_FONT_SIZE, GTK_CSS_FONT_SIZE_MEDIUM);
return value->value;
}
/* PangoStyle */
static const GtkCssValueClass GTK_CSS_VALUE_FONT_STYLE = {
-5
View File
@@ -31,11 +31,6 @@ GtkCssValue * _gtk_css_border_style_value_new (GtkBorderStyle border
GtkCssValue * _gtk_css_border_style_value_try_parse (GtkCssParser *parser);
GtkBorderStyle _gtk_css_border_style_value_get (const GtkCssValue *value);
GtkCssValue * _gtk_css_font_size_value_new (GtkCssFontSize size);
GtkCssValue * _gtk_css_font_size_value_try_parse (GtkCssParser *parser);
GtkCssFontSize _gtk_css_font_size_value_get (const GtkCssValue *value);
double _gtk_css_font_size_get_default (GtkStyleProviderPrivate *provider);
GtkCssValue * _gtk_css_font_style_value_new (PangoStyle style);
GtkCssValue * _gtk_css_font_style_value_try_parse (GtkCssParser *parser);
PangoStyle _gtk_css_font_style_value_get (const GtkCssValue *value);
-37
View File
@@ -19,11 +19,7 @@
#include "gtkcssinitialvalueprivate.h"
#include "gtkcssarrayvalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssstringvalueprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkstyleproviderprivate.h"
struct _GtkCssValue {
GTK_CSS_VALUE_BASE
@@ -44,39 +40,6 @@ gtk_css_value_initial_compute (GtkCssValue *value,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
{
GtkSettings *settings;
switch (property_id)
{
case GTK_CSS_PROPERTY_FONT_FAMILY:
settings = _gtk_style_provider_private_get_settings (provider);
if (settings)
{
PangoFontDescription *description;
char *font_name;
GtkCssValue *value;
g_object_get (settings, "gtk-font-name", &font_name, NULL);
description = pango_font_description_from_string (font_name);
g_free (font_name);
if (description == NULL)
break;
if (pango_font_description_get_set_fields (description) & PANGO_FONT_MASK_FAMILY)
{
value = _gtk_css_array_value_new (_gtk_css_string_value_new (pango_font_description_get_family (description)));
pango_font_description_free (description);
return value;
}
pango_font_description_free (description);
}
break;
default:
break;
}
return _gtk_css_value_compute (_gtk_css_style_property_get_initial_value (_gtk_css_style_property_lookup_by_id (property_id)),
property_id,
provider,
+13 -11
View File
@@ -62,11 +62,13 @@ gtk_css_matcher_widget_path_get_state (const GtkCssMatcher *matcher)
}
static gboolean
gtk_css_matcher_widget_path_has_type (const GtkCssMatcher *matcher,
GType type)
gtk_css_matcher_widget_path_has_name (const GtkCssMatcher *matcher,
const char *name)
{
const GtkWidgetPath *siblings;
GType type;
type = g_type_from_name (name);
siblings = gtk_widget_path_iter_get_siblings (matcher->path.path, matcher->path.index);
if (siblings && matcher->path.sibling_index != gtk_widget_path_iter_get_sibling_index (matcher->path.path, matcher->path.index))
return g_type_is_a (gtk_widget_path_iter_get_object_type (siblings, matcher->path.sibling_index), type);
@@ -177,7 +179,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
gtk_css_matcher_widget_path_get_parent,
gtk_css_matcher_widget_path_get_previous,
gtk_css_matcher_widget_path_get_state,
gtk_css_matcher_widget_path_has_type,
gtk_css_matcher_widget_path_has_name,
gtk_css_matcher_widget_path_has_class,
gtk_css_matcher_widget_path_has_id,
gtk_css_matcher_widget_path_has_regions,
@@ -234,8 +236,8 @@ gtk_css_matcher_any_get_state (const GtkCssMatcher *matcher)
}
static gboolean
gtk_css_matcher_any_has_type (const GtkCssMatcher *matcher,
GType type)
gtk_css_matcher_any_has_name (const GtkCssMatcher *matcher,
const char *name)
{
return TRUE;
}
@@ -281,7 +283,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
gtk_css_matcher_any_get_parent,
gtk_css_matcher_any_get_previous,
gtk_css_matcher_any_get_state,
gtk_css_matcher_any_has_type,
gtk_css_matcher_any_has_name,
gtk_css_matcher_any_has_class,
gtk_css_matcher_any_has_id,
gtk_css_matcher_any_has_regions,
@@ -330,11 +332,11 @@ gtk_css_matcher_superset_get_state (const GtkCssMatcher *matcher)
}
static gboolean
gtk_css_matcher_superset_has_type (const GtkCssMatcher *matcher,
GType type)
gtk_css_matcher_superset_has_name (const GtkCssMatcher *matcher,
const char *name)
{
if (matcher->superset.relevant & GTK_CSS_CHANGE_NAME)
return _gtk_css_matcher_has_type (matcher->superset.subset, type);
return _gtk_css_matcher_has_name (matcher->superset.subset, name);
else
return TRUE;
}
@@ -400,7 +402,7 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
gtk_css_matcher_superset_get_parent,
gtk_css_matcher_superset_get_previous,
gtk_css_matcher_superset_get_state,
gtk_css_matcher_superset_has_type,
gtk_css_matcher_superset_has_name,
gtk_css_matcher_superset_has_class,
gtk_css_matcher_superset_has_id,
gtk_css_matcher_superset_has_regions,
+5 -5
View File
@@ -36,8 +36,8 @@ struct _GtkCssMatcherClass {
const GtkCssMatcher *next);
GtkStateFlags (* get_state) (const GtkCssMatcher *matcher);
gboolean (* has_type) (const GtkCssMatcher *matcher,
GType type);
gboolean (* has_name) (const GtkCssMatcher *matcher,
const char *name);
gboolean (* has_class) (const GtkCssMatcher *matcher,
GQuark class_name);
gboolean (* has_id) (const GtkCssMatcher *matcher,
@@ -103,10 +103,10 @@ _gtk_css_matcher_get_state (const GtkCssMatcher *matcher)
}
static inline gboolean
_gtk_css_matcher_has_type (const GtkCssMatcher *matcher,
GType type)
_gtk_css_matcher_has_name (const GtkCssMatcher *matcher,
const char *name)
{
return matcher->klass->has_type (matcher, type);
return matcher->klass->has_name (matcher, name);
}
static inline gboolean
+4 -28
View File
@@ -20,7 +20,6 @@
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssenumvalueprivate.h"
#include "gtkcssinitialvalueprivate.h"
#include "gtkstylepropertyprivate.h"
struct _GtkCssValue {
@@ -35,26 +34,6 @@ gtk_css_value_number_free (GtkCssValue *value)
g_slice_free (GtkCssValue, value);
}
static double
get_base_font_size (guint property_id,
GtkStyleProviderPrivate *provider,
GtkCssComputedValues *values,
GtkCssComputedValues *parent_values,
GtkCssDependencies *dependencies)
{
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
{
*dependencies = GTK_CSS_DEPENDS_ON_PARENT;
if (parent_values)
return _gtk_css_number_value_get (_gtk_css_computed_values_get_value (parent_values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
else
return _gtk_css_font_size_get_default (provider);
}
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100);
}
static GtkCssValue *
gtk_css_value_number_compute (GtkCssValue *number,
guint property_id,
@@ -69,11 +48,6 @@ gtk_css_value_number_compute (GtkCssValue *number,
g_assert_not_reached();
/* fall through */
case GTK_CSS_PERCENT:
/* percentages for font sizes are computed, other percentages aren't */
if (property_id == GTK_CSS_PROPERTY_FONT_SIZE)
return _gtk_css_number_value_new (number->value / 100.0 *
get_base_font_size (property_id, provider, values, parent_values, dependencies),
GTK_CSS_PX);
case GTK_CSS_NUMBER:
case GTK_CSS_PX:
case GTK_CSS_DEG:
@@ -99,14 +73,16 @@ gtk_css_value_number_compute (GtkCssValue *number,
GTK_CSS_PX);
break;
case GTK_CSS_EM:
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_new (number->value *
get_base_font_size (property_id, provider, values, parent_values, dependencies),
_gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100),
GTK_CSS_PX);
break;
case GTK_CSS_EX:
/* for now we pretend ex is half of em */
*dependencies = GTK_CSS_DEPENDS_ON_FONT_SIZE;
return _gtk_css_number_value_new (number->value * 0.5 *
get_base_font_size (property_id, provider, values, parent_values, dependencies),
_gtk_css_number_value_get (_gtk_css_computed_values_get_value (values, GTK_CSS_PROPERTY_FONT_SIZE), 100),
GTK_CSS_PX);
case GTK_CSS_RAD:
return _gtk_css_number_value_new (number->value * 360.0 / (2 * G_PI),
+1 -1
View File
@@ -257,7 +257,7 @@ gtk_css_parser_skip_comment (GtkCssParser *parser)
parser->data++;
if (len > 0 && parser->data[-2] == '*')
if (parser->data[-2] == '*')
return TRUE;
if (parser->data[0] == '*')
_gtk_css_parser_error (parser, "'/*' in comment block");
+24 -46
View File
@@ -1273,6 +1273,12 @@ gtk_css_ruleset_add (GtkCssRuleset *ruleset,
ruleset->styles[i].section = NULL;
}
static GtkCssChange
gtk_css_ruleset_get_change (GtkCssRuleset *ruleset)
{
return _gtk_css_selector_tree_match_get_change (ruleset->selector_match);
}
static void
gtk_css_scanner_destroy (GtkCssScanner *scanner)
{
@@ -1435,49 +1441,6 @@ verify_tree_match_results (GtkCssProvider *provider,
#endif
}
static void
verify_tree_get_change_results (GtkCssProvider *provider,
const GtkCssMatcher *matcher,
GtkCssChange change)
{
#ifdef VERIFY_TREE
{
GtkCssChange verify_change = 0;
GPtrArray *tree_rules;
int i;
tree_rules = _gtk_css_selector_tree_match_all (provider->priv->tree, matcher);
verify_tree_match_results (provider, matcher, tree_rules);
for (i = tree_rules->len - 1; i >= 0; i--)
{
GtkCssRuleset *ruleset;
ruleset = tree_rules->pdata[i];
verify_change |= _gtk_css_selector_tree_match_get_change (ruleset->selector_match);
}
if (change != verify_change)
{
GString *s;
s = g_string_new ("");
g_string_append_printf (s, "expected change 0x%x, but it was 0x%x", verify_change, change);
if ((change & ~verify_change) != 0)
g_string_append_printf (s, ", unexpectedly set: 0x%x", change & ~verify_change);
if ((~change & verify_change) != 0)
g_string_append_printf (s, ", unexpectedly no set: 0x%x", ~change & verify_change);
g_warning (s->str);
g_string_free (s, TRUE);
}
g_ptr_array_free (tree_rules, TRUE);
}
#endif
}
static gboolean
gtk_css_provider_get_style_property (GtkStyleProvider *provider,
GtkWidgetPath *path,
@@ -1622,14 +1585,29 @@ gtk_css_style_provider_get_change (GtkStyleProviderPrivate *provider,
{
GtkCssProvider *css_provider;
GtkCssProviderPrivate *priv;
GtkCssChange change;
GtkCssChange change = 0;
GPtrArray *tree_rules;
int i;
css_provider = GTK_CSS_PROVIDER (provider);
priv = css_provider->priv;
change = _gtk_css_selector_tree_get_change_all (priv->tree, matcher);
tree_rules = _gtk_css_selector_tree_match_all (priv->tree, matcher);
verify_tree_match_results (css_provider, matcher, tree_rules);
verify_tree_get_change_results (css_provider, matcher, change);
for (i = tree_rules->len - 1; i >= 0; i--)
{
GtkCssRuleset *ruleset;
ruleset = tree_rules->pdata[i];
if (ruleset->styles == NULL)
continue;
change |= gtk_css_ruleset_get_change (ruleset);
}
g_ptr_array_free (tree_rules, TRUE);
return change;
}
+139 -537
View File
File diff suppressed because it is too large Load Diff
-2
View File
@@ -42,8 +42,6 @@ int _gtk_css_selector_compare (const GtkCssSelector *a,
void _gtk_css_selector_tree_free (GtkCssSelectorTree *tree);
GPtrArray * _gtk_css_selector_tree_match_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher);
GtkCssChange _gtk_css_selector_tree_get_change_all (const GtkCssSelectorTree *tree,
const GtkCssMatcher *matcher);
void _gtk_css_selector_tree_match_print (const GtkCssSelectorTree *tree,
GString *str);
GtkCssChange _gtk_css_selector_tree_match_get_change (const GtkCssSelectorTree *tree);
+3 -3
View File
@@ -565,8 +565,8 @@ parse_background (GtkCssShorthandProperty *shorthand,
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
return FALSE;
}
return FALSE;
}
for (i = 0; i < 6; i++)
@@ -668,8 +668,8 @@ parse_transition (GtkCssShorthandProperty *shorthand,
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
return FALSE;
}
return FALSE;
}
for (i = 0; i < 4; i++)
@@ -784,8 +784,8 @@ parse_animation (GtkCssShorthandProperty *shorthand,
{
g_ptr_array_set_free_func (arrays[i], (GDestroyNotify) _gtk_css_value_unref);
g_ptr_array_unref (arrays[i]);
return FALSE;
}
return FALSE;
}
for (i = 0; i < 6; i++)
+14 -100
View File
@@ -38,8 +38,6 @@
enum {
PROP_0,
PROP_ANIMATED,
PROP_AFFECTS_SIZE,
PROP_AFFECTS_FONT,
PROP_ID,
PROP_INHERIT,
PROP_INITIAL
@@ -47,11 +45,6 @@ enum {
G_DEFINE_TYPE (GtkCssStyleProperty, _gtk_css_style_property, GTK_TYPE_STYLE_PROPERTY)
static GtkBitmask *_properties_affecting_size = NULL;
static GtkBitmask *_properties_affecting_font = NULL;
static GtkCssStylePropertyClass *gtk_css_style_property_class = NULL;
static void
gtk_css_style_property_constructed (GObject *object)
{
@@ -61,12 +54,6 @@ gtk_css_style_property_constructed (GObject *object)
property->id = klass->style_properties->len;
g_ptr_array_add (klass->style_properties, property);
if (property->affects_size)
_properties_affecting_size = _gtk_bitmask_set (_properties_affecting_size, property->id, TRUE);
if (property->affects_font)
_properties_affecting_font = _gtk_bitmask_set (_properties_affecting_font, property->id, TRUE);
G_OBJECT_CLASS (_gtk_css_style_property_parent_class)->constructed (object);
}
@@ -83,12 +70,6 @@ gtk_css_style_property_set_property (GObject *object,
case PROP_ANIMATED:
property->animated = g_value_get_boolean (value);
break;
case PROP_AFFECTS_SIZE:
property->affects_size = g_value_get_boolean (value);
break;
case PROP_AFFECTS_FONT:
property->affects_font = g_value_get_boolean (value);
break;
case PROP_INHERIT:
property->inherit = g_value_get_boolean (value);
break;
@@ -115,12 +96,6 @@ gtk_css_style_property_get_property (GObject *object,
case PROP_ANIMATED:
g_value_set_boolean (value, property->animated);
break;
case PROP_AFFECTS_SIZE:
g_value_set_boolean (value, property->affects_size);
break;
case PROP_AFFECTS_FONT:
g_value_set_boolean (value, property->affects_font);
break;
case PROP_ID:
g_value_set_boolean (value, property->id);
break;
@@ -276,20 +251,6 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
P_("Set if the value can be animated"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_AFFECTS_SIZE,
g_param_spec_boolean ("affects-size",
P_("Affects size"),
P_("Set if the value affects the sizing of elements"),
TRUE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_AFFECTS_FONT,
g_param_spec_boolean ("affects-font",
P_("Affects font"),
P_("Set if the value affects the font"),
FALSE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_class,
PROP_ID,
g_param_spec_uint ("id",
@@ -317,11 +278,6 @@ _gtk_css_style_property_class_init (GtkCssStylePropertyClass *klass)
property_class->parse_value = gtk_css_style_property_parse_value;
klass->style_properties = g_ptr_array_new ();
_properties_affecting_size = _gtk_bitmask_new ();
_properties_affecting_font = _gtk_bitmask_new ();
gtk_css_style_property_class = klass;
}
static GtkCssValue *
@@ -349,13 +305,17 @@ _gtk_css_style_property_init (GtkCssStyleProperty *property)
guint
_gtk_css_style_property_get_n_properties (void)
{
if (G_UNLIKELY (gtk_css_style_property_class == NULL))
GtkCssStylePropertyClass *klass;
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
if (G_UNLIKELY (klass == NULL))
{
_gtk_style_property_init_properties ();
g_assert (gtk_css_style_property_class);
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
g_assert (klass);
}
return gtk_css_style_property_class->style_properties->len;
return klass->style_properties->len;
}
/**
@@ -371,16 +331,18 @@ _gtk_css_style_property_get_n_properties (void)
GtkCssStyleProperty *
_gtk_css_style_property_lookup_by_id (guint id)
{
GtkCssStylePropertyClass *klass;
if (G_UNLIKELY (gtk_css_style_property_class == NULL))
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
if (G_UNLIKELY (klass == NULL))
{
_gtk_style_property_init_properties ();
g_assert (gtk_css_style_property_class);
klass = g_type_class_peek (GTK_TYPE_CSS_STYLE_PROPERTY);
g_assert (klass);
}
g_return_val_if_fail (id < klass->style_properties->len, NULL);
g_return_val_if_fail (id < gtk_css_style_property_class->style_properties->len, NULL);
return g_ptr_array_index (gtk_css_style_property_class->style_properties, id);
return g_ptr_array_index (klass->style_properties, id);
}
/**
@@ -419,42 +381,6 @@ _gtk_css_style_property_is_animated (GtkCssStyleProperty *property)
return property->animated;
}
/**
* _gtk_css_style_property_affects_size:
* @property: the property
*
* Queries if the given @property affects the size of elements. This is
* used for optimizations inside GTK, where a gtk_widget_queue_resize()
* can be avoided if the property does not affect size.
*
* Returns: %TRUE if the property affects sizing of elements.
**/
gboolean
_gtk_css_style_property_affects_size (GtkCssStyleProperty *property)
{
g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
return property->affects_size;
}
/**
* _gtk_css_style_property_affects_font:
* @property: the property
*
* Queries if the given @property affects the default font. This is
* used for optimizations inside GTK, where clearing pango
* layouts can be avoided if the font doesn't change.
*
* Returns: %TRUE if the property affects the font.
**/
gboolean
_gtk_css_style_property_affects_font (GtkCssStyleProperty *property)
{
g_return_val_if_fail (GTK_IS_CSS_STYLE_PROPERTY (property), FALSE);
return property->affects_font;
}
/**
* _gtk_css_style_property_get_id:
* @property: the property
@@ -489,15 +415,3 @@ _gtk_css_style_property_get_initial_value (GtkCssStyleProperty *property)
return property->initial_value;
}
gboolean
_gtk_css_style_property_changes_affect_size (const GtkBitmask *changes)
{
return _gtk_bitmask_intersects (changes, _properties_affecting_size);
}
gboolean
_gtk_css_style_property_changes_affect_font (const GtkBitmask *changes)
{
return _gtk_bitmask_intersects (changes, _properties_affecting_font);
}
+59 -64
View File
@@ -65,9 +65,7 @@
typedef enum {
GTK_STYLE_PROPERTY_INHERIT = (1 << 0),
GTK_STYLE_PROPERTY_ANIMATED = (1 << 1),
GTK_STYLE_PROPERTY_NO_RESIZE = (1 << 2),
GTK_STYLE_PROPERTY_AFFECTS_FONT = (1 << 3)
GTK_STYLE_PROPERTY_ANIMATED = (1 << 1)
} GtkStylePropertyFlags;
static void
@@ -89,8 +87,6 @@ gtk_css_style_property_register (const char * name,
node = g_object_new (GTK_TYPE_CSS_STYLE_PROPERTY,
"value-type", value_type,
"affects-size", (flags & GTK_STYLE_PROPERTY_NO_RESIZE) ? FALSE : TRUE,
"affects-font", (flags & GTK_STYLE_PROPERTY_AFFECTS_FONT) ? TRUE : FALSE,
"animated", (flags & GTK_STYLE_PROPERTY_ANIMATED) ? TRUE : FALSE,
"inherit", (flags & GTK_STYLE_PROPERTY_INHERIT) ? TRUE : FALSE,
"initial-value", initial_value,
@@ -650,17 +646,15 @@ static GtkCssValue *
font_size_parse (GtkCssStyleProperty *property,
GtkCssParser *parser)
{
GtkCssValue *value;
gdouble d;
value = _gtk_css_font_size_value_try_parse (parser);
if (value)
return value;
if (!_gtk_css_parser_try_double (parser, &d))
{
_gtk_css_parser_error (parser, "Expected a number");
return NULL;
}
return _gtk_css_number_value_parse (parser,
GTK_CSS_PARSE_LENGTH
| GTK_CSS_PARSE_PERCENT
| GTK_CSS_POSITIVE_ONLY
| GTK_CSS_NUMBER_AS_PIXELS);
return _gtk_css_number_value_new (d, GTK_CSS_PX);
}
static GtkCssValue *
@@ -870,7 +864,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("color",
GTK_CSS_PROPERTY_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -878,18 +872,19 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-size",
GTK_CSS_PROPERTY_FONT_SIZE,
G_TYPE_DOUBLE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_AFFECTS_FONT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
font_size_parse,
query_length_as_double,
assign_length_from_double,
_gtk_css_font_size_value_new (GTK_CSS_FONT_SIZE_MEDIUM));
/* XXX: This should be 'normal' */
_gtk_css_number_value_new (10.0, GTK_CSS_PX));
/* properties that aren't referenced when computing values
* start here */
gtk_css_style_property_register ("background-color",
GTK_CSS_PROPERTY_BACKGROUND_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -898,7 +893,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-family",
GTK_CSS_PROPERTY_FONT_FAMILY,
G_TYPE_STRV,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
GTK_STYLE_PROPERTY_INHERIT,
font_family_parse,
font_family_query,
font_family_assign,
@@ -906,7 +901,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-style",
GTK_CSS_PROPERTY_FONT_STYLE,
PANGO_TYPE_STYLE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
GTK_STYLE_PROPERTY_INHERIT,
parse_pango_style,
query_pango_style,
assign_pango_style,
@@ -914,7 +909,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-variant",
GTK_CSS_PROPERTY_FONT_VARIANT,
PANGO_TYPE_VARIANT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
GTK_STYLE_PROPERTY_INHERIT,
parse_pango_variant,
query_pango_variant,
assign_pango_variant,
@@ -922,7 +917,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("font-weight",
GTK_CSS_PROPERTY_FONT_WEIGHT,
PANGO_TYPE_WEIGHT,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_AFFECTS_FONT,
GTK_STYLE_PROPERTY_INHERIT,
parse_pango_weight,
query_pango_weight,
assign_pango_weight,
@@ -931,7 +926,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("text-shadow",
GTK_CSS_PROPERTY_TEXT_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
shadow_value_parse,
NULL,
NULL,
@@ -940,7 +935,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("icon-shadow",
GTK_CSS_PROPERTY_ICON_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_INHERIT | GTK_STYLE_PROPERTY_ANIMATED,
shadow_value_parse,
NULL,
NULL,
@@ -949,7 +944,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("box-shadow",
GTK_CSS_PROPERTY_BOX_SHADOW,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
shadow_value_parse,
NULL,
NULL,
@@ -1025,7 +1020,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-style",
GTK_CSS_PROPERTY_BORDER_TOP_STYLE,
GTK_TYPE_BORDER_STYLE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1041,7 +1036,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-left-style",
GTK_CSS_PROPERTY_BORDER_LEFT_STYLE,
GTK_TYPE_BORDER_STYLE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1057,7 +1052,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-style",
GTK_CSS_PROPERTY_BORDER_BOTTOM_STYLE,
GTK_TYPE_BORDER_STYLE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1073,7 +1068,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-right-style",
GTK_CSS_PROPERTY_BORDER_RIGHT_STYLE,
GTK_TYPE_BORDER_STYLE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1090,7 +1085,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-left-radius",
GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1099,7 +1094,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-right-radius",
GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1108,7 +1103,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-right-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1117,7 +1112,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-left-radius",
GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
border_corner_radius_value_parse,
NULL,
NULL,
@@ -1127,7 +1122,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("outline-style",
GTK_CSS_PROPERTY_OUTLINE_STYLE,
GTK_TYPE_BORDER_STYLE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_border_style,
query_border_style,
assign_border_style,
@@ -1143,7 +1138,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("outline-offset",
GTK_CSS_PROPERTY_OUTLINE_OFFSET,
G_TYPE_INT,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
outline_parse,
query_length_as_int,
assign_length_from_int,
@@ -1152,7 +1147,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-clip",
GTK_CSS_PROPERTY_BACKGROUND_CLIP,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_css_area,
NULL,
NULL,
@@ -1160,7 +1155,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-origin",
GTK_CSS_PROPERTY_BACKGROUND_ORIGIN,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_css_area,
NULL,
NULL,
@@ -1168,7 +1163,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-size",
GTK_CSS_PROPERTY_BACKGROUND_SIZE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
background_size_parse,
NULL,
NULL,
@@ -1176,7 +1171,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-position",
GTK_CSS_PROPERTY_BACKGROUND_POSITION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
background_position_parse,
NULL,
NULL,
@@ -1186,7 +1181,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-top-color",
GTK_CSS_PROPERTY_BORDER_TOP_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -1194,7 +1189,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-right-color",
GTK_CSS_PROPERTY_BORDER_RIGHT_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -1202,7 +1197,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-bottom-color",
GTK_CSS_PROPERTY_BORDER_BOTTOM_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -1210,7 +1205,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-left-color",
GTK_CSS_PROPERTY_BORDER_LEFT_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -1218,7 +1213,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("outline-color",
GTK_CSS_PROPERTY_OUTLINE_COLOR,
GDK_TYPE_RGBA,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
color_parse,
color_query,
color_assign,
@@ -1227,7 +1222,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-repeat",
GTK_CSS_PROPERTY_BACKGROUND_REPEAT,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
background_repeat_value_parse,
NULL,
NULL,
@@ -1236,7 +1231,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("background-image",
GTK_CSS_PROPERTY_BACKGROUND_IMAGE,
CAIRO_GOBJECT_TYPE_PATTERN,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
background_image_value_parse,
background_image_value_query,
background_image_value_assign,
@@ -1245,7 +1240,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-source",
GTK_CSS_PROPERTY_BORDER_IMAGE_SOURCE,
CAIRO_GOBJECT_TYPE_PATTERN,
GTK_STYLE_PROPERTY_ANIMATED | GTK_STYLE_PROPERTY_NO_RESIZE,
GTK_STYLE_PROPERTY_ANIMATED,
css_image_value_parse,
css_image_value_query,
css_image_value_assign,
@@ -1253,7 +1248,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-repeat",
GTK_CSS_PROPERTY_BORDER_IMAGE_REPEAT,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
border_image_repeat_parse,
NULL,
NULL,
@@ -1263,7 +1258,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-slice",
GTK_CSS_PROPERTY_BORDER_IMAGE_SLICE,
GTK_TYPE_BORDER,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
border_image_slice_parse,
query_border,
assign_border,
@@ -1274,7 +1269,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("border-image-width",
GTK_CSS_PROPERTY_BORDER_IMAGE_WIDTH,
GTK_TYPE_BORDER,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
border_image_width_parse,
query_border,
assign_border,
@@ -1286,7 +1281,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-property",
GTK_CSS_PROPERTY_TRANSITION_PROPERTY,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_property_parse,
NULL,
NULL,
@@ -1294,7 +1289,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-duration",
GTK_CSS_PROPERTY_TRANSITION_DURATION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_time_parse,
NULL,
NULL,
@@ -1302,7 +1297,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-timing-function",
GTK_CSS_PROPERTY_TRANSITION_TIMING_FUNCTION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_timing_function_parse,
NULL,
NULL,
@@ -1311,7 +1306,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("transition-delay",
GTK_CSS_PROPERTY_TRANSITION_DELAY,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_time_parse,
NULL,
NULL,
@@ -1320,7 +1315,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-name",
GTK_CSS_PROPERTY_ANIMATION_NAME,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_property_parse,
NULL,
NULL,
@@ -1328,7 +1323,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-duration",
GTK_CSS_PROPERTY_ANIMATION_DURATION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_time_parse,
NULL,
NULL,
@@ -1336,7 +1331,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-timing-function",
GTK_CSS_PROPERTY_ANIMATION_TIMING_FUNCTION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_timing_function_parse,
NULL,
NULL,
@@ -1345,7 +1340,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-iteration-count",
GTK_CSS_PROPERTY_ANIMATION_ITERATION_COUNT,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
iteration_count_parse,
NULL,
NULL,
@@ -1353,7 +1348,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-direction",
GTK_CSS_PROPERTY_ANIMATION_DIRECTION,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_css_direction,
NULL,
NULL,
@@ -1361,7 +1356,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-play-state",
GTK_CSS_PROPERTY_ANIMATION_PLAY_STATE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_css_play_state,
NULL,
NULL,
@@ -1369,7 +1364,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-delay",
GTK_CSS_PROPERTY_ANIMATION_DELAY,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
transition_time_parse,
NULL,
NULL,
@@ -1377,7 +1372,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("animation-fill-mode",
GTK_CSS_PROPERTY_ANIMATION_FILL_MODE,
G_TYPE_NONE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
parse_css_fill_mode,
NULL,
NULL,
@@ -1386,7 +1381,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("engine",
GTK_CSS_PROPERTY_ENGINE,
GTK_TYPE_THEMING_ENGINE,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
engine_parse,
engine_query,
engine_assign,
@@ -1396,7 +1391,7 @@ _gtk_css_style_property_init_properties (void)
gtk_css_style_property_register ("gtk-key-bindings",
GTK_CSS_PROPERTY_GTK_KEY_BINDINGS,
G_TYPE_PTR_ARRAY,
GTK_STYLE_PROPERTY_NO_RESIZE,
0,
bindings_value_parse,
bindings_value_query,
bindings_value_assign,
+1 -9
View File
@@ -49,8 +49,6 @@ struct _GtkCssStyleProperty
guint id;
guint inherit :1;
guint animated :1;
guint affects_size :1;
guint affects_font :1;
GtkCssStylePropertyParseFunc parse_value;
GtkCssStylePropertyQueryFunc query_value;
@@ -73,8 +71,6 @@ GtkCssStyleProperty * _gtk_css_style_property_lookup_by_id (guint
gboolean _gtk_css_style_property_is_inherit (GtkCssStyleProperty *property);
gboolean _gtk_css_style_property_is_animated (GtkCssStyleProperty *property);
gboolean _gtk_css_style_property_affects_size (GtkCssStyleProperty *property);
gboolean _gtk_css_style_property_affects_font (GtkCssStyleProperty *property);
guint _gtk_css_style_property_get_id (GtkCssStyleProperty *property);
GtkCssValue * _gtk_css_style_property_get_initial_value
(GtkCssStyleProperty *property);
@@ -82,11 +78,7 @@ GtkCssValue * _gtk_css_style_property_get_initial_value
void _gtk_css_style_property_print_value (GtkCssStyleProperty *property,
GtkCssValue *value,
GString *string);
gboolean _gtk_css_style_property_changes_affect_size
(const GtkBitmask *changes);
gboolean _gtk_css_style_property_changes_affect_font
(const GtkBitmask *changes);
G_END_DECLS
+1 -17
View File
@@ -50,9 +50,7 @@ typedef enum { /*< skip >*/
/* add more */
GTK_CSS_CHANGE_SOURCE = (1 << 16),
GTK_CSS_CHANGE_ANIMATE = (1 << 17),
GTK_CSS_CHANGE_FORCE_INVALIDATE = (1 << 18),
GTK_CSS_CHANGE_RESERVED_BIT = (1 << 31) /* Used internally in gtkcssselector.c */
GTK_CSS_CHANGE_FORCE_INVALIDATE = (1 << 18)
} GtkCssChange;
#define GTK_CSS_CHANGE_ANY ((1 << 19) - 1)
@@ -163,20 +161,6 @@ typedef enum /*< skip >*/ {
GTK_CSS_FILL_BOTH
} GtkCssFillMode;
typedef enum /*< skip >*/ {
/* relative font sizes */
GTK_CSS_FONT_SIZE_SMALLER,
GTK_CSS_FONT_SIZE_LARGER,
/* absolute font sizes */
GTK_CSS_FONT_SIZE_XX_SMALL,
GTK_CSS_FONT_SIZE_X_SMALL,
GTK_CSS_FONT_SIZE_SMALL,
GTK_CSS_FONT_SIZE_MEDIUM,
GTK_CSS_FONT_SIZE_LARGE,
GTK_CSS_FONT_SIZE_X_LARGE,
GTK_CSS_FONT_SIZE_XX_LARGE
} GtkCssFontSize;
/* for the order in arrays */
typedef enum /*< skip >*/ {
GTK_CSS_TOP,
+12 -13
View File
@@ -17,7 +17,6 @@
#include "config.h"
#include "gtkprivate.h"
#include "gtkcssvalueprivate.h"
#include "gtkcsscomputedvaluesprivate.h"
@@ -46,7 +45,7 @@ _gtk_css_value_alloc (const GtkCssValueClass *klass,
GtkCssValue *
_gtk_css_value_ref (GtkCssValue *value)
{
gtk_internal_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (value != NULL, NULL);
g_atomic_int_add (&value->ref_count, 1);
@@ -94,10 +93,10 @@ _gtk_css_value_compute (GtkCssValue *value,
{
GtkCssDependencies fallback;
gtk_internal_return_val_if_fail (value != NULL, NULL);
gtk_internal_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
gtk_internal_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
gtk_internal_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
g_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
g_return_val_if_fail (GTK_IS_CSS_COMPUTED_VALUES (values), NULL);
g_return_val_if_fail (parent_values == NULL || GTK_IS_CSS_COMPUTED_VALUES (parent_values), NULL);
if (dependencies == NULL)
dependencies = &fallback;
@@ -110,8 +109,8 @@ gboolean
_gtk_css_value_equal (const GtkCssValue *value1,
const GtkCssValue *value2)
{
gtk_internal_return_val_if_fail (value1 != NULL, FALSE);
gtk_internal_return_val_if_fail (value2 != NULL, FALSE);
g_return_val_if_fail (value1 != NULL, FALSE);
g_return_val_if_fail (value2 != NULL, FALSE);
if (value1 == value2)
return TRUE;
@@ -142,8 +141,8 @@ _gtk_css_value_transition (GtkCssValue *start,
guint property_id,
double progress)
{
gtk_internal_return_val_if_fail (start != NULL, FALSE);
gtk_internal_return_val_if_fail (end != NULL, FALSE);
g_return_val_if_fail (start != NULL, FALSE);
g_return_val_if_fail (end != NULL, FALSE);
if (start->class != end->class)
return NULL;
@@ -156,7 +155,7 @@ _gtk_css_value_to_string (const GtkCssValue *value)
{
GString *string;
gtk_internal_return_val_if_fail (value != NULL, NULL);
g_return_val_if_fail (value != NULL, NULL);
string = g_string_new (NULL);
_gtk_css_value_print (value, string);
@@ -176,8 +175,8 @@ void
_gtk_css_value_print (const GtkCssValue *value,
GString *string)
{
gtk_internal_return_if_fail (value != NULL);
gtk_internal_return_if_fail (string != NULL);
g_return_if_fail (value != NULL);
g_return_if_fail (string != NULL);
value->class->print (value, string);
}
-1
View File
@@ -41,7 +41,6 @@
#include "gtkquartz.h"
#include "gdk/quartz/gdkquartz.h"
#include "gtkselectionprivate.h"
#include "gtksettings.h"
typedef struct _GtkDragSourceSite GtkDragSourceSite;
typedef struct _GtkDragSourceInfo GtkDragSourceInfo;
+19 -3
View File
@@ -3216,14 +3216,19 @@ gtk_entry_get_preferred_width (GtkWidget *widget,
PangoFontMetrics *metrics;
GtkBorder borders;
PangoContext *context;
GtkStyleContext *style_context;
GtkStateFlags state;
gint icon_widths = 0;
gint icon_width, i;
gint width;
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
_gtk_entry_get_borders (entry, &borders);
@@ -3264,6 +3269,8 @@ gtk_entry_get_preferred_height (GtkWidget *widget,
GtkEntryPrivate *priv = entry->priv;
PangoFontMetrics *metrics;
GtkBorder borders;
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
gint height;
PangoLayout *layout;
@@ -3271,8 +3278,11 @@ gtk_entry_get_preferred_height (GtkWidget *widget,
layout = gtk_entry_ensure_layout (entry, TRUE);
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
priv->ascent = pango_font_metrics_get_ascent (metrics);
@@ -4865,6 +4875,8 @@ gtk_entry_style_updated (GtkWidget *widget)
gtk_entry_update_cached_style_values (entry);
gtk_entry_recompute (entry);
icon_theme_changed (entry);
}
@@ -6562,6 +6574,8 @@ gtk_entry_move_adjustments (GtkEntry *entry)
GtkAdjustment *adjustment;
PangoContext *context;
PangoFontMetrics *metrics;
GtkStyleContext *style_context;
GtkStateFlags state;
GtkBorder borders;
gint x, layout_x;
gint char_width;
@@ -6580,9 +6594,11 @@ gtk_entry_move_adjustments (GtkEntry *entry)
/* Approximate width of a char, so user can see what is ahead/behind */
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics) / PANGO_SCALE;
+2 -4
View File
@@ -1251,7 +1251,6 @@ get_next_site (GtkExpander *expander,
case GTK_DIR_RIGHT:
return FOCUS_WIDGET;
}
break;
case FOCUS_WIDGET:
switch (direction)
{
@@ -1265,8 +1264,8 @@ get_next_site (GtkExpander *expander,
return FOCUS_LABEL;
case GTK_DIR_RIGHT:
return ltr ? FOCUS_LABEL : FOCUS_NONE;
break;
}
break;
case FOCUS_LABEL:
switch (direction)
{
@@ -1280,8 +1279,8 @@ get_next_site (GtkExpander *expander,
return FOCUS_CHILD;
case GTK_DIR_RIGHT:
return ltr ? FOCUS_CHILD : FOCUS_WIDGET;
break;
}
break;
case FOCUS_CHILD:
switch (direction)
{
@@ -1294,7 +1293,6 @@ get_next_site (GtkExpander *expander,
case GTK_DIR_RIGHT:
return FOCUS_NONE;
}
break;
}
g_assert_not_reached ();
+6 -6
View File
@@ -3865,7 +3865,7 @@ copy_file_clear_cb (GtkClipboard *clipboard,
g_slist_free (selected_files);
}
/* Callback used when the "Copy files location" menu item is activated */
/* Callback used when the "Copy file's location" menu item is activated */
static void
copy_file_location_cb (GtkMenuItem *item,
GtkFileChooserDefault *impl)
@@ -4107,7 +4107,7 @@ file_list_drag_motion_cb (GtkWidget *widget,
return TRUE;
}
/* Sensitizes the "Copy files location" context menu item if there is actually
/* Sensitizes the "Copy file's location" context menu item if there is actually
* a selection active.
*/
static void
@@ -4176,7 +4176,7 @@ file_list_build_popup_menu (GtkFileChooserDefault *impl)
impl->browse_files_popup_menu_visit_file_item = file_list_add_image_menu_item (impl, GTK_STOCK_DIRECTORY, _("_Visit this file"),
G_CALLBACK (visit_file_cb));
impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy files location"),
impl->browse_files_popup_menu_copy_file_location_item = file_list_add_image_menu_item (impl, GTK_STOCK_COPY, _("_Copy file's location"),
G_CALLBACK (copy_file_location_cb));
impl->browse_files_popup_menu_add_shortcut_item = file_list_add_image_menu_item (impl, GTK_STOCK_ADD, _("_Add to Bookmarks"),
@@ -8187,7 +8187,7 @@ find_good_size_from_style (GtkWidget *widget,
{
GtkStyleContext *context;
GtkStateFlags state;
double font_size;
int font_size;
GdkScreen *screen;
double resolution;
@@ -8204,8 +8204,8 @@ find_good_size_from_style (GtkWidget *widget,
else
resolution = 96.0; /* wheeee */
gtk_style_context_get (context, state, "font-size", &font_size, NULL);
font_size = font_size * resolution / 72.0 + 0.5;
font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
font_size = PANGO_PIXELS (font_size) * resolution / 72.0;
*width = font_size * NUM_CHARS;
*height = font_size * NUM_LINES;
+1 -4
View File
@@ -325,10 +325,7 @@ _gtk_icon_helper_ensure_pixbuf (GtkIconHelper *self,
case GTK_IMAGE_STOCK:
icon_set = gtk_style_context_lookup_icon_set (context, self->priv->stock_id);
if (icon_set != NULL)
ensure_pixbuf_for_icon_set (self, context, icon_set);
else
pixbuf = NULL;
ensure_pixbuf_for_icon_set (self, context, icon_set);
break;
case GTK_IMAGE_ICON_SET:
+100 -501
View File
@@ -24,7 +24,6 @@
#endif
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <glib.h>
#include <glib/gstdio.h>
@@ -161,18 +160,9 @@ typedef enum
HAS_ICON_FILE = 1 << 3
} IconSuffix;
#define INFO_CACHE_LRU_SIZE 32
#if 0
#define DEBUG_CACHE(args) g_print args
#else
#define DEBUG_CACHE(args)
#endif
struct _GtkIconThemePrivate
{
GHashTable *info_cache;
GList *info_cache_lru;
gchar *current_theme;
gchar *fallback_theme;
gchar **search_path;
@@ -207,31 +197,10 @@ struct _GtkIconThemePrivate
gulong reset_styles_idle;
};
typedef struct {
gchar **icon_names;
gint size;
GtkIconLookupFlags flags;
} IconInfoKey;
typedef struct _SymbolicPixbufCache SymbolicPixbufCache;
struct _SymbolicPixbufCache {
GdkPixbuf *pixbuf;
GdkPixbuf *proxy_pixbuf;
GdkRGBA fg;
GdkRGBA success_color;
GdkRGBA warning_color;
GdkRGBA error_color;
SymbolicPixbufCache *next;
};
struct _GtkIconInfo
{
/* Information about the source
*/
IconInfoKey key;
GtkIconTheme *in_cache;
gchar *filename;
GFile *icon_file;
GLoadableIcon *loadable;
@@ -262,12 +231,9 @@ struct _GtkIconInfo
* the icon.
*/
GdkPixbuf *pixbuf;
GdkPixbuf *proxy_pixbuf;
GError *load_error;
gdouble scale;
SymbolicPixbufCache *symbolic_pixbuf_cache;
GtkRequisition *symbolic_pixbuf_size;
};
@@ -364,8 +330,6 @@ static BuiltinIcon *find_builtin_icon (const gchar *icon_name,
gint size,
gint *min_difference_p,
gboolean *has_larger_p);
static void remove_from_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info);
static guint signal_changed = 0;
@@ -375,46 +339,6 @@ static GHashTable *icon_theme_builtin_icons;
GtkIconCache *_builtin_cache = NULL;
static GList *builtin_dirs = NULL;
static guint
icon_info_key_hash (gconstpointer _key)
{
const IconInfoKey *key = _key;
guint h = 0;
int i;
for (i = 0; key->icon_names[i] != NULL; i++)
h ^= g_str_hash (key->icon_names[i]);
h ^= key->size * 0x10001;
h ^= key->flags * 0x1000010;
return h;
}
static gboolean
icon_info_key_equal (gconstpointer _a,
gconstpointer _b)
{
const IconInfoKey *a = _a;
const IconInfoKey *b = _b;
int i;
if (a->size != b->size)
return FALSE;
if (a->flags != b->flags)
return FALSE;
for (i = 0;
a->icon_names[i] != NULL &&
b->icon_names[i] != NULL; i++)
{
if (strcmp (a->icon_names[i], b->icon_names[i]) != 0)
return FALSE;
}
return a->icon_names[i] == NULL && b->icon_names[i] == NULL;
}
G_DEFINE_TYPE (GtkIconTheme, gtk_icon_theme, G_TYPE_OBJECT)
/**
@@ -717,25 +641,6 @@ pixbuf_supports_svg (void)
return found_svg;
}
/* The icon info was removed from the icon_info_hash hash table */
static void
icon_info_uncached (GtkIconInfo *icon_info)
{
GtkIconTheme *icon_theme = icon_info->in_cache;
DEBUG_CACHE (("removing %p (%s %d 0x%x) from cache (icon_them: %p) (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
icon_theme,
icon_theme != NULL ? g_hash_table_size (icon_theme->priv->info_cache) : 0));
icon_info->in_cache = NULL;
if (icon_theme != NULL)
remove_from_lru_cache (icon_theme, icon_info);
}
static void
gtk_icon_theme_init (GtkIconTheme *icon_theme)
{
@@ -748,9 +653,6 @@ gtk_icon_theme_init (GtkIconTheme *icon_theme)
GtkIconThemePrivate);
icon_theme->priv = priv;
priv->info_cache = g_hash_table_new_full (icon_info_key_hash, icon_info_key_equal, NULL,
(GDestroyNotify)icon_info_uncached);
priv->custom_theme = FALSE;
xdg_data_dirs = g_get_system_data_dirs ();
@@ -810,8 +712,6 @@ do_theme_change (GtkIconTheme *icon_theme)
{
GtkIconThemePrivate *priv = icon_theme->priv;
g_hash_table_remove_all (priv->info_cache);
if (!priv->themes_valid)
return;
@@ -855,9 +755,6 @@ gtk_icon_theme_finalize (GObject *object)
icon_theme = GTK_ICON_THEME (object);
priv = icon_theme->priv;
g_hash_table_destroy (priv->info_cache);
g_assert (priv->info_cache_lru == NULL);
if (priv->reset_styles_idle)
{
g_source_remove (priv->reset_styles_idle);
@@ -1409,173 +1306,6 @@ ensure_valid_themes (GtkIconTheme *icon_theme)
priv->loading_themes = FALSE;
}
/* The LRU cache is a short list of IconInfos that are kept
alive even though their IconInfo would otherwise have
been freed, so that we can avoid reloading these
constantly.
We put infos on the lru list when nothing otherwise
references the info. So, when we get a cache hit
we remove it from the list, and when the proxy
pixmap is released we put it on the list.
*/
static void
ensure_lru_cache_space (GtkIconTheme *icon_theme)
{
GtkIconThemePrivate *priv = icon_theme->priv;
GList *l;
/* Remove last item if LRU full */
l = g_list_nth (priv->info_cache_lru, INFO_CACHE_LRU_SIZE - 1);
if (l)
{
GtkIconInfo *icon_info = l->data;
DEBUG_CACHE (("removing (due to out of space) %p (%s %d 0x%x) from LRU cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_list_length (priv->info_cache_lru)));
priv->info_cache_lru = g_list_delete_link (priv->info_cache_lru, l);
gtk_icon_info_free (icon_info);
}
}
static void
add_to_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info)
{
GtkIconThemePrivate *priv = icon_theme->priv;
DEBUG_CACHE (("adding %p (%s %d 0x%x) to LRU cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_list_length (priv->info_cache_lru)));
g_assert (g_list_find (priv->info_cache_lru, icon_info) == NULL);
ensure_lru_cache_space (icon_theme);
/* prepend new info to LRU */
priv->info_cache_lru = g_list_prepend (priv->info_cache_lru,
gtk_icon_info_copy (icon_info));
}
static void
ensure_in_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info)
{
GtkIconThemePrivate *priv = icon_theme->priv;
GList *l;
l = g_list_find (priv->info_cache_lru, icon_info);
if (l)
{
/* Move to front of LRU if already in it */
priv->info_cache_lru = g_list_remove_link (priv->info_cache_lru, l);
priv->info_cache_lru = g_list_concat (l, priv->info_cache_lru);
}
else
add_to_lru_cache (icon_theme, icon_info);
}
static void
remove_from_lru_cache (GtkIconTheme *icon_theme,
GtkIconInfo *icon_info)
{
GtkIconThemePrivate *priv = icon_theme->priv;
if (g_list_find (priv->info_cache_lru, icon_info))
{
DEBUG_CACHE (("removing %p (%s %d 0x%x) from LRU cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_list_length (priv->info_cache_lru)));
priv->info_cache_lru = g_list_remove (priv->info_cache_lru, icon_info);
gtk_icon_info_free (icon_info);
}
}
static SymbolicPixbufCache *
symbolic_pixbuf_cache_new (GdkPixbuf *pixbuf,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color,
SymbolicPixbufCache *next)
{
SymbolicPixbufCache *cache;
cache = g_new0 (SymbolicPixbufCache, 1);
cache->pixbuf = g_object_ref (pixbuf);
if (fg)
cache->fg = *fg;
if (success_color)
cache->success_color = *success_color;
if (warning_color)
cache->warning_color = *warning_color;
if (error_color)
cache->error_color = *error_color;
cache->next = next;
return cache;
}
static gboolean
rgba_matches (const GdkRGBA *a, const GdkRGBA *b)
{
GdkRGBA transparent = { 0 };
/* For matching we treat unset colors as transparent rather
than default, which works as well, because transparent
will never be used for real symbolic icon colors */
if (a == NULL)
a = &transparent;
return
fabs(a->red - b->red) < 0.0001 &&
fabs(a->green - b->green) < 0.0001 &&
fabs(a->blue - b->blue) < 0.0001 &&
fabs(a->alpha - b->alpha) < 0.0001;
}
static SymbolicPixbufCache *
symbolic_pixbuf_cache_matches (SymbolicPixbufCache *cache,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color)
{
while (cache != NULL)
{
if (rgba_matches (fg, &cache->fg) &&
rgba_matches (success_color, &cache->success_color) &&
rgba_matches (warning_color, &cache->warning_color) &&
rgba_matches (error_color, &cache->error_color))
return cache;
cache = cache->next;
}
return NULL;
}
static void
symbolic_pixbuf_cache_free (SymbolicPixbufCache *cache)
{
SymbolicPixbufCache *next;
while (cache != NULL)
{
next = cache->next;
g_object_unref (cache->pixbuf);
g_free (cache);
cache = next;
}
}
static GtkIconInfo *
choose_icon (GtkIconTheme *icon_theme,
const gchar *icon_names[],
@@ -1589,31 +1319,9 @@ choose_icon (GtkIconTheme *icon_theme,
gboolean allow_svg;
gboolean use_builtin;
gint i;
IconInfoKey key;
priv = icon_theme->priv;
ensure_valid_themes (icon_theme);
key.icon_names = (char **)icon_names;
key.size = size;
key.flags = flags;
icon_info = g_hash_table_lookup (priv->info_cache, &key);
if (icon_info != NULL)
{
DEBUG_CACHE (("cache hit %p (%s %d 0x%x) (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_hash_table_size (priv->info_cache)));
icon_info = gtk_icon_info_copy (icon_info);
remove_from_lru_cache (icon_theme, icon_info);
return icon_info;
}
if (flags & GTK_ICON_LOOKUP_NO_SVG)
allow_svg = FALSE;
else if (flags & GTK_ICON_LOOKUP_FORCE_SVG)
@@ -1622,6 +1330,8 @@ choose_icon (GtkIconTheme *icon_theme,
allow_svg = priv->pixbuf_supports_svg;
use_builtin = flags & GTK_ICON_LOOKUP_USE_BUILTIN;
ensure_valid_themes (icon_theme);
/* for symbolic icons, do a search in all registered themes first;
* a theme that inherits them from a parent theme might provide
@@ -1707,21 +1417,10 @@ choose_icon (GtkIconTheme *icon_theme,
}
out:
if (icon_info)
if (icon_info)
{
icon_info->desired_size = size;
icon_info->forced_size = (flags & GTK_ICON_LOOKUP_FORCE_SIZE) != 0;
icon_info->key.icon_names = g_strdupv ((char **)icon_names);
icon_info->key.size = size;
icon_info->key.flags = flags;
icon_info->in_cache = icon_theme;
DEBUG_CACHE (("adding %p (%s %d 0x%x) to cache (cache size %d)\n",
icon_info,
g_strjoinv (",", icon_info->key.icon_names),
icon_info->key.size, icon_info->key.flags,
g_hash_table_size (priv->info_cache)));
g_hash_table_insert (priv->info_cache, &icon_info->key, icon_info);
}
else
{
@@ -3036,12 +2735,7 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
icon_info->ref_count--;
if (icon_info->ref_count > 0)
return;
if (icon_info->in_cache)
g_hash_table_remove (icon_info->in_cache->priv->info_cache, &icon_info->key);
g_strfreev (icon_info->key.icon_names);
g_free (icon_info->filename);
g_clear_object (&icon_info->icon_file);
@@ -3055,8 +2749,6 @@ gtk_icon_info_free (GtkIconInfo *icon_info)
if (icon_info->symbolic_pixbuf_size)
gtk_requisition_free (icon_info->symbolic_pixbuf_size);
symbolic_pixbuf_cache_free (icon_info->symbolic_pixbuf_cache);
g_slice_free (GtkIconInfo, icon_info);
}
@@ -3403,22 +3095,6 @@ icon_info_ensure_scale_and_pixbuf (GtkIconInfo *icon_info,
return TRUE;
}
static void
proxy_pixbuf_destroy (guchar *pixels, gpointer data)
{
GtkIconInfo *icon_info = data;
GtkIconTheme *icon_theme = icon_info->in_cache;
g_assert (icon_info->proxy_pixbuf != NULL);
icon_info->proxy_pixbuf = NULL;
/* Keep it alive a bit longer */
if (icon_theme != NULL)
ensure_in_lru_cache (icon_theme, icon_info);
gtk_icon_info_free (icon_info);
}
/**
* gtk_icon_info_load_icon:
* @icon_info: a #GtkIconInfo structure from gtk_icon_theme_lookup_icon()
@@ -3464,28 +3140,7 @@ gtk_icon_info_load_icon (GtkIconInfo *icon_info,
return NULL;
}
/* Instead of returning the pixbuf directly we
return a proxy to it that we don't own (but that
shares the data with the one we own). This way
we can know when it is freed and ensure the
IconInfo is alive (and thus cached) while
the pixbuf is still alive. */
if (icon_info->proxy_pixbuf != NULL)
return g_object_ref (icon_info->proxy_pixbuf);
icon_info->proxy_pixbuf =
gdk_pixbuf_new_from_data (gdk_pixbuf_get_pixels (icon_info->pixbuf),
gdk_pixbuf_get_colorspace (icon_info->pixbuf),
gdk_pixbuf_get_has_alpha (icon_info->pixbuf),
gdk_pixbuf_get_bits_per_sample (icon_info->pixbuf),
gdk_pixbuf_get_width (icon_info->pixbuf),
gdk_pixbuf_get_height (icon_info->pixbuf),
gdk_pixbuf_get_rowstride (icon_info->pixbuf),
proxy_pixbuf_destroy,
gtk_icon_info_copy (icon_info));
return icon_info->proxy_pixbuf;
return g_object_ref (icon_info->pixbuf);
}
static gchar *
@@ -3507,109 +3162,40 @@ gdk_rgba_to_css (const GdkRGBA *color)
(gint)(color->blue * 255));
}
static void
proxy_symbolic_pixbuf_destroy (guchar *pixels, gpointer data)
{
GtkIconInfo *icon_info = data;
GtkIconTheme *icon_theme = icon_info->in_cache;
SymbolicPixbufCache *symbolic_cache;
for (symbolic_cache = icon_info->symbolic_pixbuf_cache;
symbolic_cache != NULL;
symbolic_cache = symbolic_cache->next)
{
if (symbolic_cache->proxy_pixbuf != NULL &&
gdk_pixbuf_get_pixels (symbolic_cache->proxy_pixbuf) == pixels)
break;
}
g_assert (symbolic_cache != NULL);
g_assert (symbolic_cache->proxy_pixbuf != NULL);
symbolic_cache->proxy_pixbuf = NULL;
/* Keep it alive a bit longer */
if (icon_theme != NULL)
ensure_in_lru_cache (icon_theme, icon_info);
gtk_icon_info_free (icon_info);
}
static GdkPixbuf *
symbolic_cache_get_proxy (SymbolicPixbufCache *symbolic_cache,
GtkIconInfo *icon_info)
{
if (symbolic_cache->proxy_pixbuf)
return g_object_ref (symbolic_cache->proxy_pixbuf);
symbolic_cache->proxy_pixbuf =
gdk_pixbuf_new_from_data (gdk_pixbuf_get_pixels (symbolic_cache->pixbuf),
gdk_pixbuf_get_colorspace (symbolic_cache->pixbuf),
gdk_pixbuf_get_has_alpha (symbolic_cache->pixbuf),
gdk_pixbuf_get_bits_per_sample (symbolic_cache->pixbuf),
gdk_pixbuf_get_width (symbolic_cache->pixbuf),
gdk_pixbuf_get_height (symbolic_cache->pixbuf),
gdk_pixbuf_get_rowstride (symbolic_cache->pixbuf),
proxy_symbolic_pixbuf_destroy,
gtk_icon_info_copy (icon_info));
return symbolic_cache->proxy_pixbuf;
}
static GdkPixbuf *
_gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
const GdkRGBA *fg,
const GdkRGBA *success_color,
const GdkRGBA *warning_color,
const GdkRGBA *error_color,
const gchar *css_fg,
const gchar *css_success,
const gchar *css_warning,
const gchar *css_error,
GError **error)
{
GInputStream *stream;
GdkPixbuf *pixbuf;
gchar *css_fg;
gchar *css_success;
gchar *css_warning;
gchar *css_error;
gchar *data;
gchar *success, *warning, *err;
gchar *width, *height, *uri;
SymbolicPixbufCache *symbolic_cache;
symbolic_cache = symbolic_pixbuf_cache_matches (icon_info->symbolic_pixbuf_cache,
fg, success_color, warning_color, error_color);
if (symbolic_cache)
return symbolic_cache_get_proxy (symbolic_cache, icon_info);
/* css_fg can't possibly have failed, otherwise
* that would mean we have a broken style */
g_return_val_if_fail (fg != NULL, NULL);
g_return_val_if_fail (css_fg != NULL, NULL);
css_fg = gdk_rgba_to_css (fg);
css_success = css_warning = css_error = NULL;
if (warning_color)
css_warning = gdk_rgba_to_css (warning_color);
if (error_color)
css_error = gdk_rgba_to_css (error_color);
if (success_color)
css_success = gdk_rgba_to_css (success_color);
success = warning = err = NULL;
if (!css_success)
{
GdkColor success_default_color = { 0, 0x4e00, 0x9a00, 0x0600 };
css_success = gdk_color_to_css (&success_default_color);
success = gdk_color_to_css (&success_default_color);
}
if (!css_warning)
{
GdkColor warning_default_color = { 0, 0xf500, 0x7900, 0x3e00 };
css_warning = gdk_color_to_css (&warning_default_color);
warning = gdk_color_to_css (&warning_default_color);
}
if (!css_error)
{
GdkColor error_default_color = { 0, 0xcc00, 0x0000, 0x0000 };
css_error = gdk_color_to_css (&error_default_color);
err = gdk_color_to_css (&error_default_color);
}
if (!icon_info->symbolic_pixbuf_size)
@@ -3647,22 +3233,21 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
" fill: ", css_fg," !important;\n"
" }\n"
" .warning {\n"
" fill: ", css_warning, " !important;\n"
" fill: ", css_warning ? css_warning : warning," !important;\n"
" }\n"
" .error {\n"
" fill: ", css_error ," !important;\n"
" fill: ", css_error ? css_error : err," !important;\n"
" }\n"
" .success {\n"
" fill: ", css_success, " !important;\n"
" fill: ", css_success ? css_success : success," !important;\n"
" }\n"
" </style>\n"
" <xi:include href=\"", uri, "\"/>\n"
"</svg>",
NULL);
g_free (css_fg);
g_free (css_warning);
g_free (css_error);
g_free (css_success);
g_free (warning);
g_free (err);
g_free (success);
g_free (width);
g_free (height);
g_free (uri);
@@ -3676,16 +3261,7 @@ _gtk_icon_info_load_symbolic_internal (GtkIconInfo *icon_info,
error);
g_object_unref (stream);
if (pixbuf != NULL)
{
icon_info->symbolic_pixbuf_cache =
symbolic_pixbuf_cache_new (pixbuf, fg, success_color, warning_color, error_color,
icon_info->symbolic_pixbuf_cache);
return symbolic_cache_get_proxy (icon_info->symbolic_pixbuf_cache, icon_info);
}
return NULL;
return pixbuf;
}
/**
@@ -3734,6 +3310,11 @@ gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
GdkPixbuf *pixbuf;
gchar *css_fg;
gchar *css_success;
gchar *css_warning;
gchar *css_error;
gchar *icon_uri;
gboolean is_symbolic;
@@ -3753,10 +3334,29 @@ gtk_icon_info_load_symbolic (GtkIconInfo *icon_info,
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
return _gtk_icon_info_load_symbolic_internal (icon_info,
fg, success_color,
warning_color, error_color,
error);
css_fg = gdk_rgba_to_css (fg);
css_success = css_warning = css_error = NULL;
if (warning_color)
css_warning = gdk_rgba_to_css (warning_color);
if (error_color)
css_error = gdk_rgba_to_css (error_color);
if (success_color)
css_success = gdk_rgba_to_css (success_color);
pixbuf = _gtk_icon_info_load_symbolic_internal (icon_info,
css_fg, css_success,
css_warning, css_error,
error);
g_free (css_fg);
g_free (css_warning);
g_free (css_success);
g_free (css_error);
return pixbuf;
}
/**
@@ -3790,15 +3390,11 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
GdkPixbuf *pixbuf;
GdkRGBA *color = NULL;
GdkRGBA fg;
GdkRGBA *fgp;
GdkRGBA success_color;
GdkRGBA *success_colorp;
GdkRGBA warning_color;
GdkRGBA *warning_colorp;
GdkRGBA error_color;
GdkRGBA *error_colorp;
GdkRGBA rgba;
gchar *css_fg = NULL, *css_success;
gchar *css_warning, *css_error;
GtkStateFlags state;
gchar *icon_uri;
gboolean is_symbolic;
@@ -3819,40 +3415,36 @@ gtk_icon_info_load_symbolic_for_context (GtkIconInfo *icon_info,
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
fgp = success_colorp = warning_colorp = error_colorp = NULL;
state = gtk_style_context_get_state (context);
gtk_style_context_get (context, state, "color", &color, NULL);
if (color)
{
fg = *color;
fgp = &fg;
css_fg = gdk_rgba_to_css (color);
gdk_rgba_free (color);
}
if (gtk_style_context_lookup_color (context, "success_color", &success_color))
success_colorp = &success_color;
css_success = css_warning = css_error = NULL;
if (gtk_style_context_lookup_color (context, "warning_color", &warning_color))
warning_colorp = &warning_color;
if (gtk_style_context_lookup_color (context, "success_color", &rgba))
css_success = gdk_rgba_to_css (&rgba);
if (gtk_style_context_lookup_color (context, "error_color", &error_color))
error_colorp = &error_color;
if (gtk_style_context_lookup_color (context, "warning_color", &rgba))
css_warning = gdk_rgba_to_css (&rgba);
return _gtk_icon_info_load_symbolic_internal (icon_info,
fgp, success_colorp,
warning_colorp, error_colorp,
error);
}
if (gtk_style_context_lookup_color (context, "error_color", &rgba))
css_error = gdk_rgba_to_css (&rgba);
static GdkRGBA *
color_to_rgba (GdkColor *color, GdkRGBA *rgba)
{
rgba->red = color->red / 65535.0;
rgba->green = color->green / 65535.0;
rgba->blue = color->blue / 65535.0;
rgba->alpha = 1.0;
return rgba;
pixbuf = _gtk_icon_info_load_symbolic_internal (icon_info,
css_fg, css_success,
css_warning, css_error,
error);
g_free (css_fg);
g_free (css_success);
g_free (css_warning);
g_free (css_error);
return pixbuf;
}
/**
@@ -3887,14 +3479,13 @@ gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
gboolean *was_symbolic,
GError **error)
{
GdkColor color;
GdkRGBA fg;
GdkRGBA success_color;
GdkRGBA *success_colorp;
GdkRGBA warning_color;
GdkRGBA *warning_colorp;
GdkRGBA error_color;
GdkRGBA *error_colorp;
GdkPixbuf *pixbuf;
GdkColor success_color;
GdkColor warning_color;
GdkColor error_color;
GdkColor *fg;
gchar *css_fg, *css_success;
gchar *css_warning, *css_error;
gchar *icon_uri;
gboolean is_symbolic;
@@ -3914,23 +3505,31 @@ gtk_icon_info_load_symbolic_for_style (GtkIconInfo *icon_info,
if (!is_symbolic)
return gtk_icon_info_load_icon (icon_info, error);
color_to_rgba (&style->fg[state], &fg);
fg = &style->fg[state];
css_fg = gdk_color_to_css (fg);
success_colorp = warning_colorp = error_colorp = NULL;
css_success = css_warning = css_error = NULL;
if (gtk_style_lookup_color (style, "success_color", &color))
success_colorp = color_to_rgba (&color, &success_color);
if (gtk_style_lookup_color (style, "success_color", &success_color))
css_success = gdk_color_to_css (&success_color);
if (gtk_style_lookup_color (style, "warning_color", &color))
warning_colorp = color_to_rgba (&color, &warning_color);
if (gtk_style_lookup_color (style, "warning_color", &warning_color))
css_warning = gdk_color_to_css (&warning_color);
if (gtk_style_lookup_color (style, "error_color", &color))
error_colorp = color_to_rgba (&color, &error_color);
if (gtk_style_lookup_color (style, "error_color", &error_color))
css_error = gdk_color_to_css (&error_color);
return _gtk_icon_info_load_symbolic_internal (icon_info,
&fg, success_colorp,
warning_colorp, error_colorp,
error);
pixbuf = _gtk_icon_info_load_symbolic_internal (icon_info,
css_fg, css_success,
css_warning, css_error,
error);
g_free (css_fg);
g_free (css_success);
g_free (css_warning);
g_free (css_error);
return pixbuf;
}
/**
+12 -38
View File
@@ -371,52 +371,26 @@ check_quartz_special_cases (GtkIMContextSimple *context_simple,
gint n_compose)
{
GtkIMContextSimplePrivate *priv = context_simple->priv;
guint value = 0;
if (n_compose == 2)
if (n_compose == 2 &&
priv->compose_buffer[1] == GDK_KEY_space)
{
gunichar value = 0;
switch (priv->compose_buffer[0])
{
case GDK_KEY_dead_doubleacute:
switch (priv->compose_buffer[1])
{
case GDK_KEY_dead_doubleacute:
case GDK_KEY_space:
value = GDK_KEY_quotedbl; break;
case 'a': value = GDK_KEY_adiaeresis; break;
case 'A': value = GDK_KEY_Adiaeresis; break;
case 'e': value = GDK_KEY_ediaeresis; break;
case 'E': value = GDK_KEY_Ediaeresis; break;
case 'i': value = GDK_KEY_idiaeresis; break;
case 'I': value = GDK_KEY_Idiaeresis; break;
case 'o': value = GDK_KEY_odiaeresis; break;
case 'O': value = GDK_KEY_Odiaeresis; break;
case 'u': value = GDK_KEY_udiaeresis; break;
case 'U': value = GDK_KEY_Udiaeresis; break;
case 'y': value = GDK_KEY_ydiaeresis; break;
case 'Y': value = GDK_KEY_Ydiaeresis; break;
}
break;
case GDK_KEY_dead_acute:
switch (priv->compose_buffer[1])
{
case 'c': value = GDK_KEY_ccedilla; break;
case 'C': value = GDK_KEY_Ccedilla; break;
}
break;
value = '"'; break;
}
}
if (value > 0)
{
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple),
gdk_keyval_to_unicode (value));
priv->compose_buffer[0] = 0;
if (value > 0)
{
gtk_im_context_simple_commit_char (GTK_IM_CONTEXT (context_simple), value);
priv->compose_buffer[0] = 0;
GTK_NOTE (MISC, g_print ("quartz: U+%04X\n", value));
return TRUE;
GTK_NOTE (MISC, g_print ("quartz: U+%04X\n", value));
return TRUE;
}
}
return FALSE;
+51 -7
View File
@@ -384,6 +384,9 @@ static void gtk_label_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void gtk_label_state_flags_changed (GtkWidget *widget,
GtkStateFlags prev_state);
static void gtk_label_style_updated (GtkWidget *widget);
static void gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir);
static gint gtk_label_draw (GtkWidget *widget,
cairo_t *cr);
static gboolean gtk_label_focus (GtkWidget *widget,
@@ -563,7 +566,9 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->destroy = gtk_label_destroy;
widget_class->size_allocate = gtk_label_size_allocate;
widget_class->state_flags_changed = gtk_label_state_flags_changed;
widget_class->style_updated = gtk_label_style_updated;
widget_class->query_tooltip = gtk_label_query_tooltip;
widget_class->direction_changed = gtk_label_direction_changed;
widget_class->draw = gtk_label_draw;
widget_class->realize = gtk_label_realize;
widget_class->unrealize = gtk_label_unrealize;
@@ -1847,9 +1852,6 @@ gtk_label_screen_changed (GtkWidget *widget,
GtkSettings *settings;
gboolean shortcuts_connected;
/* The PangoContext is replaced when the screen changes, so clear the layouts */
gtk_label_clear_layout (GTK_LABEL (widget));
if (!gtk_widget_has_screen (widget))
return;
@@ -3134,6 +3136,23 @@ gtk_label_clear_layout (GtkLabel *label)
}
}
static PangoFontMetrics *
get_font_metrics (PangoContext *context, GtkWidget *widget)
{
GtkStyleContext *style_context;
const PangoFontDescription *font;
PangoFontMetrics *retval;
style_context = gtk_widget_get_style_context (widget);
font = gtk_style_context_get_font (style_context, GTK_STATE_FLAG_NORMAL);
retval = pango_context_get_metrics (context,
font,
pango_context_get_language (context));
return retval;
}
/**
* gtk_label_get_measuring_layout:
* @label: the label
@@ -3365,7 +3384,7 @@ gtk_label_ensure_layout (GtkLabel *label)
pango_attr_list_insert (attrs, attribute);
}
}
else if (priv->markup_attrs || priv->attrs)
else if (priv->markup_attrs && priv->markup_attrs)
attrs = pango_attr_list_new ();
else
attrs = NULL;
@@ -3466,9 +3485,7 @@ get_char_pixels (GtkWidget *label,
gint char_width, digit_width;
context = pango_layout_get_context (layout);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
metrics = get_font_metrics (context, GTK_WIDGET (label));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
digit_width = pango_font_metrics_get_approximate_digit_width (metrics);
pango_font_metrics_unref (metrics);
@@ -3809,10 +3826,37 @@ gtk_label_state_flags_changed (GtkWidget *widget,
gtk_label_update_cursor (label);
}
/* We have to clear the layout, fonts etc. may have changed */
gtk_label_clear_layout (label);
if (GTK_WIDGET_CLASS (gtk_label_parent_class)->state_flags_changed)
GTK_WIDGET_CLASS (gtk_label_parent_class)->state_flags_changed (widget, prev_state);
}
static void
gtk_label_style_updated (GtkWidget *widget)
{
GtkLabel *label = GTK_LABEL (widget);
GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget);
/* We have to clear the layout, fonts etc. may have changed */
gtk_label_clear_layout (label);
}
static void
gtk_label_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir)
{
GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = label->priv;
if (priv->layout)
pango_layout_context_changed (priv->layout);
GTK_WIDGET_CLASS (gtk_label_parent_class)->direction_changed (widget, previous_dir);
}
static void
get_layout_location (GtkLabel *label,
gint *xp,
+4 -6
View File
@@ -2437,12 +2437,10 @@ list_store_start_element (GMarkupParseContext *context,
else if (strcmp (element_name, "row") == 0)
;
else if (strcmp (element_name, "column") == 0)
{
for (i = 0; names[i]; i++)
if (strcmp (names[i], "type") == 0)
data->column_type_names = g_slist_prepend (data->column_type_names,
g_strdup (values[i]));
}
for (i = 0; names[i]; i++)
if (strcmp (names[i], "type") == 0)
data->column_type_names = g_slist_prepend (data->column_type_names,
g_strdup (values[i]));
else if (strcmp (element_name, "columns") == 0)
;
else if (strcmp (element_name, "data") == 0)
+1 -1
View File
@@ -1555,7 +1555,7 @@ gtk_main_do_event (GdkEvent *event)
* This is the key to implementing modality.
*/
if (!grab_widget ||
((gtk_widget_is_sensitive (event_widget) || event->type == GDK_SCROLL) &&
(gtk_widget_is_sensitive (event_widget) &&
gtk_widget_is_ancestor (event_widget, grab_widget)))
grab_widget = event_widget;
+83 -56
View File
@@ -641,6 +641,15 @@ gtk_menu_class_init (GtkMenuClass *class)
-1, G_MAXINT, -1,
GTK_PARAM_READWRITE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-padding",
P_("Vertical Padding"),
P_("Extra space at the top and bottom of the menu"),
0,
G_MAXINT,
1,
GTK_PARAM_READABLE));
/**
* GtkMenu:reserve-toggle-size:
*
@@ -662,15 +671,6 @@ gtk_menu_class_init (GtkMenuClass *class)
TRUE,
GTK_PARAM_READWRITE));
/**
* GtkMenu:horizontal-padding:
*
* Extra space at the left and right edges of the menu.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
P_("Horizontal Padding"),
@@ -678,27 +678,7 @@ gtk_menu_class_init (GtkMenuClass *class)
0,
G_MAXINT,
0,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
/**
* GtkMenu:vertical-padding:
*
* Extra space at the top and bottom of the menu.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-padding",
P_("Vertical Padding"),
P_("Extra space at the top and bottom of the menu"),
0,
G_MAXINT,
1,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("vertical-offset",
@@ -2530,6 +2510,8 @@ gtk_menu_realize (GtkWidget *widget)
gint border_width;
GtkWidget *child;
GList *children;
guint vertical_padding;
guint horizontal_padding;
GtkBorder arrow_border, padding;
g_return_if_fail (GTK_IS_MENU (widget));
@@ -2560,14 +2542,19 @@ gtk_menu_realize (GtkWidget *widget)
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
context = gtk_widget_get_style_context (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
gtk_widget_get_allocation (widget, &allocation);
attributes.x = border_width + padding.left;
attributes.y = border_width + padding.top;
attributes.x = border_width + padding.left + horizontal_padding;
attributes.y = border_width + padding.top + vertical_padding;
attributes.width = allocation.width -
(2 * border_width) - padding.left - padding.right;
(2 * (border_width + horizontal_padding)) - padding.left - padding.right;
attributes.height = allocation.height -
(2 * border_width) - padding.top - padding.bottom;
(2 * (border_width + vertical_padding)) - padding.top - padding.bottom;
get_arrows_border (menu, &arrow_border);
attributes.y += arrow_border.top;
@@ -2585,9 +2572,9 @@ gtk_menu_realize (GtkWidget *widget)
attributes.x = 0;
attributes.y = 0;
attributes.width = allocation.width + (2 * border_width) +
attributes.width = allocation.width + (2 * (border_width + horizontal_padding)) +
padding.left + padding.right;
attributes.height = priv->requested_height - (2 * border_width) +
attributes.height = priv->requested_height - (2 * (border_width + vertical_padding)) +
padding.top + padding.bottom;
attributes.width = MAX (1, attributes.width);
@@ -2703,6 +2690,7 @@ calculate_line_heights (GtkMenu *menu,
GtkMenuShell *menu_shell;
GtkWidget *child, *widget;
GList *children;
guint horizontal_padding;
guint border_width;
guint n_columns;
gint n_heights;
@@ -2720,10 +2708,13 @@ calculate_line_heights (GtkMenu *menu,
n_columns = gtk_menu_get_n_columns (menu);
avail_width = for_width - (2 * priv->toggle_size + priv->accel_size) * n_columns;
gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
avail_width -= (border_width) * 2 + padding.left + padding.right;
avail_width -= (border_width + horizontal_padding) * 2 + padding.left + padding.right;
for (children = menu_shell->priv->children; children; children = children->next)
{
@@ -2779,6 +2770,8 @@ gtk_menu_size_allocate (GtkWidget *widget,
gint x, y, i;
gint width, height;
guint border_width;
guint vertical_padding;
guint horizontal_padding;
GtkBorder padding;
g_return_if_fail (GTK_IS_MENU (widget));
@@ -2790,6 +2783,11 @@ gtk_menu_size_allocate (GtkWidget *widget,
gtk_widget_set_allocation (widget, allocation);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
@@ -2800,15 +2798,16 @@ gtk_menu_size_allocate (GtkWidget *widget,
NULL);
/* refresh our cached height request */
priv->requested_height = (2 * border_width) + padding.top + padding.bottom;
priv->requested_height = (2 * (border_width + vertical_padding)) +
padding.top + padding.bottom;
for (i = 0; i < priv->heights_length; i++)
priv->requested_height += priv->heights[i];
x = border_width + padding.left;
y = border_width + padding.top;
width = allocation->width - (2 * border_width) -
x = border_width + padding.left + horizontal_padding;
y = border_width + padding.top + vertical_padding;
width = allocation->width - (2 * (border_width + horizontal_padding)) -
padding.left - padding.right;
height = allocation->height - (2 * border_width) -
height = allocation->height - (2 * (border_width + vertical_padding)) -
padding.top - padding.bottom;
if (menu_shell->priv->active)
@@ -2938,18 +2937,22 @@ get_arrows_visible_area (GtkMenu *menu,
GtkArrowPlacement arrow_placement;
GtkWidget *widget = GTK_WIDGET (menu);
guint border_width;
guint vertical_padding;
guint horizontal_padding;
gint scroll_arrow_height;
GtkBorder menu_padding;
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
get_menu_padding (widget, &menu_padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
border->x = border_width + menu_padding.left;
border->y = border_width + menu_padding.top;
border->x = border_width + menu_padding.left + horizontal_padding;
border->y = border_width + menu_padding.top + vertical_padding;
border->width = gdk_window_get_width (gtk_widget_get_window (widget));
border->height = gdk_window_get_height (gtk_widget_get_window (widget));
@@ -3134,6 +3137,7 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
GList *children;
guint max_toggle_size;
guint max_accel_width;
guint horizontal_padding;
guint border_width;
gint child_min, child_nat;
gint min_width, nat_width;
@@ -3222,10 +3226,16 @@ gtk_menu_get_preferred_width (GtkWidget *widget,
nat_width += 2 * max_toggle_size + max_accel_width;
nat_width *= gtk_menu_get_n_columns (menu);
gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
min_width += (2 * border_width) + padding.left + padding.right;
nat_width += (2 * border_width) + padding.left + padding.right;
min_width += (2 * (border_width + horizontal_padding)) +
padding.left + padding.right;
nat_width += (2 * (border_width + horizontal_padding)) +
padding.left + padding.right;
priv->toggle_size = max_toggle_size;
priv->accel_size = max_accel_width;
@@ -3267,14 +3277,16 @@ gtk_menu_get_preferred_height_for_width (GtkWidget *widget,
GtkMenu *menu = GTK_MENU (widget);
GtkMenuPrivate *priv = menu->priv;
guint *min_heights, *nat_heights;
guint border_width;
guint vertical_padding, border_width;
gint n_heights, i;
gint min_height, nat_height;
gtk_widget_style_get (widget, "vertical-padding", &vertical_padding, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
get_menu_padding (widget, &padding);
min_height = nat_height = (2 * border_width) + padding.top + padding.bottom;
min_height = nat_height = (border_width + vertical_padding) * 2 +
padding.top + padding.bottom;
n_heights =
calculate_line_heights (menu, for_size, &min_heights, &nat_heights);
@@ -3856,6 +3868,7 @@ get_arrows_sensitive_area (GtkMenu *menu,
GdkWindow *window;
gint width, height;
guint border;
guint vertical_padding;
gint win_x, win_y;
gint scroll_arrow_height;
GtkBorder padding;
@@ -3865,11 +3878,12 @@ get_arrows_sensitive_area (GtkMenu *menu,
height = gdk_window_get_height (window);
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
"scroll-arrow-vlength", &scroll_arrow_height,
"arrow-placement", &arrow_placement,
NULL);
border = gtk_container_get_border_width (GTK_CONTAINER (menu));
border = gtk_container_get_border_width (GTK_CONTAINER (menu)) + vertical_padding;
get_menu_padding (widget, &padding);
gdk_window_get_position (window, &win_x, &win_y);
@@ -4831,6 +4845,8 @@ gtk_menu_scroll_to (GtkMenu *menu,
gint view_width, view_height;
gint border_width;
gint menu_height;
guint vertical_padding;
guint horizontal_padding;
gboolean double_arrows;
widget = GTK_WIDGET (menu);
@@ -4842,17 +4858,23 @@ gtk_menu_scroll_to (GtkMenu *menu,
view_width = gtk_widget_get_allocated_width (widget);
view_height = gtk_widget_get_allocated_height (widget);
gtk_widget_style_get (GTK_WIDGET (menu),
"vertical-padding", &vertical_padding,
"horizontal-padding", &horizontal_padding,
NULL);
get_menu_padding (widget, &padding);
double_arrows = get_double_arrows (menu);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu));
view_width -= (2 * border_width) + padding.left + padding.right;
view_height -= (2 * border_width) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * border_width) - padding.top - padding.bottom;
view_width -= (2 * (border_width + horizontal_padding)) + padding.left + padding.right;
view_height -= (2 * (border_width + vertical_padding)) + padding.top + padding.bottom;
menu_height = priv->requested_height - (2 * (border_width + vertical_padding)) -
padding.top - padding.bottom;
x = border_width + padding.left;
y = border_width + padding.top;
x = border_width + padding.left + horizontal_padding;
y = border_width + padding.top + vertical_padding;
if (double_arrows && !priv->tearoff_active)
{
@@ -5049,18 +5071,23 @@ gtk_menu_scroll_item_visible (GtkMenuShell *menu_shell,
if (compute_child_offset (menu, menu_item,
&child_offset, &child_height, &last_child))
{
guint vertical_padding;
gboolean double_arrows;
GtkBorder padding;
y = priv->scroll_offset;
height = gdk_window_get_height (gtk_widget_get_window (widget));
gtk_widget_style_get (widget,
"vertical-padding", &vertical_padding,
NULL);
double_arrows = get_double_arrows (menu);
get_menu_padding (widget, &padding);
height -= 2 * gtk_container_get_border_width (GTK_CONTAINER (menu)) +
padding.top + padding.bottom;
padding.top + padding.bottom +
2 * vertical_padding;
if (child_offset < y)
{
/* Ignore the enter event we might get if the pointer
+33 -48
View File
@@ -51,6 +51,9 @@
#include "gtkprivate.h"
#include "gtktypebuiltins.h"
#define BORDER_SPACING 0
#define DEFAULT_IPADDING 1
/* Properties */
enum {
PROP_0,
@@ -216,24 +219,14 @@ gtk_menu_bar_class_init (GtkMenuBarClass *class)
GTK_SHADOW_OUT,
GTK_PARAM_READABLE));
/**
* GtkMenuBar:internal-padding:
*
* Amount of border space between the menubar shadow and the menu items
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("internal-padding",
P_("Internal padding"),
P_("Amount of border space between the menubar shadow and the menu items"),
0,
G_MAXINT,
0,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
DEFAULT_IPADDING,
GTK_PARAM_READABLE));
g_type_class_add_private (gobject_class, sizeof (GtkMenuBarPrivate));
}
@@ -339,12 +332,10 @@ gtk_menu_bar_size_request (GtkWidget *widget,
GtkMenuShell *menu_shell;
GtkWidget *child;
GList *children;
gint ipadding;
guint border_width;
gboolean use_toggle_size, use_maximize;
gint child_minimum, child_natural;
GtkStyleContext *context;
GtkBorder border;
GtkStateFlags flags;
*minimum = 0;
*natural = 0;
@@ -400,28 +391,19 @@ gtk_menu_bar_size_request (GtkWidget *widget,
}
}
context = gtk_widget_get_style_context (widget);
flags = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, flags, &border);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
*minimum += border.left + border.right;
*natural += border.left + border.right;
}
else
{
*minimum += border.top + border.bottom;
*natural += border.top + border.bottom;
}
gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
*minimum += border_width * 2;
*natural += border_width * 2;
*minimum += (border_width + ipadding + BORDER_SPACING) * 2;
*natural += (border_width + ipadding + BORDER_SPACING) * 2;
if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
{
gtk_style_context_get_border (context, flags, &border);
GtkStyleContext *context;
GtkBorder border;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget),
&border);
if (orientation == GTK_ORIENTATION_HORIZONTAL)
{
@@ -480,6 +462,7 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
GtkWidget *child;
GList *children;
GtkAllocation remaining_space;
gint ipadding;
guint border_width;
GArray *requested_sizes;
gint toggle_size;
@@ -501,26 +484,28 @@ gtk_menu_bar_size_allocate (GtkWidget *widget,
if (menu_shell->priv->children)
{
GtkStyleContext *context;
GtkStateFlags flags;
GtkBorder border;
context = gtk_widget_get_style_context (widget);
flags = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, flags, &border);
gtk_widget_style_get (widget, "internal-padding", &ipadding, NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (menu_bar));
remaining_space.x = (border_width + border.left);
remaining_space.y = (border_width + border.top);
remaining_space.x = (border_width +
ipadding +
BORDER_SPACING);
remaining_space.y = (border_width +
ipadding +
BORDER_SPACING);
remaining_space.width = allocation->width -
2 * (border_width) - border.left - border.right;
2 * (border_width + ipadding + BORDER_SPACING);
remaining_space.height = allocation->height -
2 * (border_width) - border.top - border.bottom;
2 * (border_width + ipadding + BORDER_SPACING);
if (get_shadow_type (menu_bar) != GTK_SHADOW_NONE)
{
gtk_style_context_get_border (context, flags, &border);
GtkStyleContext *context;
GtkBorder border;
context = gtk_widget_get_style_context (widget);
gtk_style_context_get_border (context, gtk_widget_get_state_flags (widget),
&border);
remaining_space.x += border.left;
remaining_space.y += border.top;
+104 -22
View File
@@ -464,24 +464,14 @@ gtk_menu_item_class_init (GtkMenuItemClass *klass)
GTK_PARAM_READABLE),
gtk_rc_property_parse_enum);
/**
* GtkMenuItem:horizontal-padding:
*
* Padding to left and right of the menu item.
*
* Deprecated: 3.8: use the standard padding CSS property (through objects
* like #GtkStyleContext and #GtkCssProvider); the value of this style
* property is ignored.
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("horizontal-padding",
"Horizontal Padding",
"Padding to left and right of the menu item",
0,
G_MAXINT,
0,
GTK_PARAM_READABLE |
G_PARAM_DEPRECATED));
3,
GTK_PARAM_READABLE));
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("toggle-spacing",
@@ -758,6 +748,8 @@ get_arrow_size (GtkWidget *widget,
gint *size,
gint *spacing)
{
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
PangoFontMetrics *metrics;
gfloat arrow_scaling;
@@ -774,9 +766,11 @@ get_arrow_size (GtkWidget *widget,
*spacing = arrow_spacing;
context = gtk_widget_get_pango_context (child);
style_context = gtk_widget_get_style_context (child);
state = gtk_widget_get_state_flags (child);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
*size = (PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) +
@@ -810,15 +804,19 @@ gtk_menu_item_accel_width_foreach (GtkWidget *widget,
static gint
get_minimum_width (GtkWidget *widget)
{
GtkStyleContext *style_context;
GtkStateFlags state;
PangoContext *context;
PangoFontMetrics *metrics;
gint width;
gint width_chars;
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
gtk_style_context_get_font (style_context, state),
pango_context_get_language (context));
width = pango_font_metrics_get_approximate_char_width (metrics);
@@ -841,16 +839,35 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
GtkWidget *child;
GtkWidget *parent;
guint accel_width;
guint horizontal_padding;
guint border_width;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
gint min_width, nat_width;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
min_width = nat_width = 0;
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
bin = GTK_BIN (widget);
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
{
pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
context = gtk_widget_get_style_context (widget);
@@ -858,8 +875,13 @@ gtk_menu_item_get_preferred_width (GtkWidget *widget,
gtk_style_context_get_padding (context, state, &padding);
min_width = (border_width * 2) + padding.left + padding.right;
nat_width = min_width;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
min_width += 2 * horizontal_padding;
nat_width = min_width;
child = gtk_bin_get_child (bin);
if (child != NULL && gtk_widget_get_visible (child))
@@ -914,7 +936,10 @@ gtk_menu_item_real_get_height (GtkWidget *widget,
GtkWidget *child;
GtkWidget *parent;
guint accel_width;
guint horizontal_padding;
guint border_width;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
gint min_height, nat_height;
gint avail_size = 0;
@@ -924,16 +949,39 @@ gtk_menu_item_real_get_height (GtkWidget *widget,
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
bin = GTK_BIN (widget);
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
{
pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
min_height = (border_width * 2) + padding.top + padding.bottom;
if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
min_height += 2 * horizontal_padding;
if (for_size != -1)
{
avail_size = for_size;
avail_size -= (border_width * 2) + padding.left + padding.right;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
avail_size -= 2 * horizontal_padding;
}
nat_height = min_height;
@@ -1444,6 +1492,7 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkBin *bin;
GtkAllocation child_allocation;
GtkTextDirection direction;
GtkPackDirection pack_dir;
GtkPackDirection child_pack_dir;
GtkWidget *child;
GtkWidget *parent;
@@ -1458,10 +1507,12 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
parent = gtk_widget_get_parent (widget);
if (GTK_IS_MENU_BAR (parent))
{
pack_dir = gtk_menu_bar_get_pack_direction (GTK_MENU_BAR (parent));
child_pack_dir = gtk_menu_bar_get_child_pack_direction (GTK_MENU_BAR (parent));
}
else
{
pack_dir = GTK_PACK_DIRECTION_LTR;
child_pack_dir = GTK_PACK_DIRECTION_LTR;
}
@@ -1473,12 +1524,17 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
guint horizontal_padding;
guint border_width;
context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
gtk_style_context_get_padding (context, state, &padding);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
border_width = gtk_container_get_border_width (GTK_CONTAINER (widget));
child_allocation.x = border_width + padding.left;
child_allocation.y = border_width + padding.top;
@@ -1488,6 +1544,19 @@ gtk_menu_item_size_allocate (GtkWidget *widget,
child_allocation.height = allocation->height - (border_width * 2) -
padding.top - padding.bottom;
if ((pack_dir == GTK_PACK_DIRECTION_LTR || pack_dir == GTK_PACK_DIRECTION_RTL) &&
(child_pack_dir == GTK_PACK_DIRECTION_LTR || child_pack_dir == GTK_PACK_DIRECTION_RTL))
{
child_allocation.x += horizontal_padding;
child_allocation.width -= 2 * horizontal_padding;
}
else if ((pack_dir == GTK_PACK_DIRECTION_TTB || pack_dir == GTK_PACK_DIRECTION_BTT) &&
(child_pack_dir == GTK_PACK_DIRECTION_TTB || child_pack_dir == GTK_PACK_DIRECTION_BTT))
{
child_allocation.y += horizontal_padding;
child_allocation.height -= 2 * horizontal_padding;
}
if (child_pack_dir == GTK_PACK_DIRECTION_LTR ||
child_pack_dir == GTK_PACK_DIRECTION_RTL)
{
@@ -1657,20 +1726,26 @@ gtk_menu_item_draw (GtkWidget *widget,
{
gint arrow_x, arrow_y;
gint arrow_size;
guint horizontal_padding;
GtkTextDirection direction;
gdouble angle;
direction = gtk_widget_get_direction (widget);
gtk_widget_style_get (widget,
"horizontal-padding", &horizontal_padding,
NULL);
get_arrow_size (widget, child, &arrow_size, NULL);
if (direction == GTK_TEXT_DIR_LTR)
{
arrow_x = x + w - arrow_size;
arrow_x = x + w - horizontal_padding - arrow_size;
angle = G_PI / 2;
}
else
{
arrow_x = x;
arrow_x = x + horizontal_padding;
angle = (3 * G_PI) / 2;
}
@@ -1682,22 +1757,24 @@ gtk_menu_item_draw (GtkWidget *widget,
{
gboolean wide_separators;
gint separator_height;
guint horizontal_padding;
gtk_widget_style_get (widget,
"wide-separators", &wide_separators,
"separator-height", &separator_height,
"horizontal-padding", &horizontal_padding,
NULL);
if (wide_separators)
gtk_render_frame (context, cr,
x + padding.left,
x + horizontal_padding + padding.left,
y + padding.top,
w - padding.left - padding.right,
w - (2 * horizontal_padding) - padding.left - padding.right,
separator_height);
else
gtk_render_line (context, cr,
x + padding.left,
x + horizontal_padding + padding.left,
y + padding.top,
x + w - padding.right - 1,
x + w - horizontal_padding - padding.right - 1,
y + padding.top);
}
@@ -2048,6 +2125,8 @@ get_offsets (GtkMenu *menu,
gint *horizontal_offset,
gint *vertical_offset)
{
gint vertical_padding;
gint horizontal_padding;
GtkStyleContext *context;
GtkStateFlags state;
GtkBorder padding;
@@ -2055,6 +2134,8 @@ get_offsets (GtkMenu *menu,
gtk_widget_style_get (GTK_WIDGET (menu),
"horizontal-offset", horizontal_offset,
"vertical-offset", vertical_offset,
"horizontal-padding", &horizontal_padding,
"vertical-padding", &vertical_padding,
NULL);
context = gtk_widget_get_style_context (GTK_WIDGET (menu));
@@ -2062,7 +2143,8 @@ get_offsets (GtkMenu *menu,
gtk_style_context_get_padding (context, state, &padding);
*vertical_offset -= padding.top;
*horizontal_offset += padding.left;
*vertical_offset -= vertical_padding;
*horizontal_offset += horizontal_padding;
}
static void
+5 -3
View File
@@ -1107,7 +1107,7 @@ gtk_menu_shell_leave_notify (GtkWidget *widget,
GdkEventCrossing *event)
{
if (event->mode == GDK_CROSSING_GTK_GRAB ||
event->mode == GDK_CROSSING_GTK_UNGRAB ||
event->mode == GDK_CROSSING_GTK_GRAB ||
event->mode == GDK_CROSSING_STATE_CHANGED)
return TRUE;
@@ -1723,10 +1723,12 @@ static void
gtk_real_menu_shell_cycle_focus (GtkMenuShell *menu_shell,
GtkDirectionType dir)
{
GtkMenuShellPrivate *priv = menu_shell->priv;
while (menu_shell && !GTK_IS_MENU_BAR (menu_shell))
{
if (menu_shell->priv->parent_menu_shell)
menu_shell = GTK_MENU_SHELL (menu_shell->priv->parent_menu_shell);
if (priv->parent_menu_shell)
menu_shell = GTK_MENU_SHELL (priv->parent_menu_shell);
else
menu_shell = NULL;
}
-1
View File
@@ -23,7 +23,6 @@
#include <gdk/gdkkeysyms.h>
#include "gtkaccelmapprivate.h"
#include "gtkactionhelper.h"
#include "../gdk/quartz/gdkquartz.h"
#import <Cocoa/Cocoa.h>
-2
View File
@@ -2504,7 +2504,6 @@ gtk_notebook_size_allocate (GtkWidget *widget,
{
case GTK_POS_TOP:
child_allocation.y += priv->cur_page->requisition.height;
/* fall thru */
case GTK_POS_BOTTOM:
child_allocation.height =
MAX (1, child_allocation.height -
@@ -2512,7 +2511,6 @@ gtk_notebook_size_allocate (GtkWidget *widget,
break;
case GTK_POS_LEFT:
child_allocation.x += priv->cur_page->requisition.width;
/* fall thru */
case GTK_POS_RIGHT:
child_allocation.width =
MAX (1, child_allocation.width -
+1 -4
View File
@@ -423,10 +423,7 @@ gtk_overlay_realize (GtkWidget *widget)
child = children->data;
if (child->window == NULL)
{
child->window = gtk_overlay_create_child_window (overlay, child->widget);
gtk_overlay_child_allocate (overlay, child);
}
child->window = gtk_overlay_create_child_window (overlay, child->widget);
}
}
-10
View File
@@ -37,16 +37,6 @@ G_BEGIN_DECLS
#define GTK_PARAM_WRITABLE G_PARAM_WRITABLE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
#define GTK_PARAM_READWRITE G_PARAM_READWRITE|G_PARAM_STATIC_NAME|G_PARAM_STATIC_NICK|G_PARAM_STATIC_BLURB
#ifdef G_DISABLE_CAST_CHECKS
/* This is true for debug no and minimum */
#define gtk_internal_return_if_fail(__expr) G_STMT_START{ (void)0; }G_STMT_END
#define gtk_internal_return_val_if_fail(__expr, __val) G_STMT_START{ (void)0; }G_STMT_END
#else
/* This is true for debug yes */
#define gtk_internal_return_if_fail(__expr) g_return_if_fail(__expr)
#define gtk_internal_return_val_if_fail(__expr, __val) g_return_val_if_fail(__expr, __val)
#endif
const gchar * _gtk_get_datadir (void);
const gchar * _gtk_get_libdir (void);
const gchar * _gtk_get_sysconfdir (void);
+3 -3
View File
@@ -556,15 +556,15 @@ gtk_progress_bar_get_preferred_width (GtkWidget *widget,
if (priv->ellipsize)
{
const PangoFontDescription *font_desc;
PangoContext *context;
PangoFontMetrics *metrics;
gint char_width;
/* The minimum size for ellipsized text is ~ 3 chars */
context = pango_layout_get_context (layout);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
pango_context_get_language (context));
font_desc = gtk_style_context_get_font (style_context, state);
metrics = pango_context_get_metrics (context, font_desc, pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
+5 -4
View File
@@ -922,7 +922,7 @@ set_default_size (GtkRecentChooserDefault *impl)
GtkScrolledWindow *scrollw;
GtkWidget *widget;
gint width, height;
double font_size;
gint font_size;
GdkScreen *screen;
gint monitor_num;
GtkRequisition req;
@@ -935,10 +935,11 @@ set_default_size (GtkRecentChooserDefault *impl)
state = gtk_widget_get_state_flags (widget);
/* Size based on characters and the icon size */
gtk_style_context_get (context, state, "font-size", &font_size, NULL);
font_size = pango_font_description_get_size (gtk_style_context_get_font (context, state));
font_size = PANGO_PIXELS (font_size);
width = impl->icon_size + font_size * NUM_CHARS + 0.5;
height = (impl->icon_size + font_size) * NUM_LINES + 0.5;
width = impl->icon_size + font_size * NUM_CHARS;
height = (impl->icon_size + font_size) * NUM_LINES;
/* Use at least the requisition size... */
gtk_widget_get_preferred_size (widget, &req, NULL);
+1 -1
View File
@@ -284,7 +284,7 @@ _gtk_rounded_box_guess_length (const GtkRoundedBox *box,
GtkCssSide side)
{
double length;
GtkCssSide before, after;
GtkCssCorner before, after;
before = side;
after = (side + 1) % 4;
-4
View File
@@ -1196,9 +1196,7 @@ gtk_scale_draw (GtkWidget *widget,
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
gtk_render_line (context, cr, x1, y1, x1, y2);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SEPARATOR);
if (mark->markup)
{
@@ -1249,9 +1247,7 @@ gtk_scale_draw (GtkWidget *widget,
gtk_style_context_save (context);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SEPARATOR);
gtk_render_line (context, cr, x1, y1, x2, y1);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_SEPARATOR);
if (mark->markup)
{
+88 -9
View File
@@ -114,6 +114,7 @@ struct _GtkSettingsPrivate
GdkScreen *screen;
GtkCssProvider *theme_provider;
GtkCssProvider *key_theme_provider;
GtkStyleProperties *style;
};
typedef enum
@@ -1409,29 +1410,97 @@ gtk_settings_class_init (GtkSettingsClass *class)
g_type_class_add_private (class, sizeof (GtkSettingsPrivate));
}
static void
settings_ensure_style (GtkSettings *settings)
{
GtkSettingsPrivate *priv = settings->priv;
PangoFontDescription *font_desc;
gchar *font_name;
if (priv->style)
return;
priv->style = gtk_style_properties_new ();
g_object_get (settings,
"gtk-font-name", &font_name,
NULL);
font_desc = pango_font_description_from_string (font_name);
/* Unset normal attributes from this description,
* so they do not override theme values */
if (pango_font_description_get_weight (font_desc) == PANGO_WEIGHT_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_WEIGHT);
if (pango_font_description_get_stretch (font_desc) == PANGO_STRETCH_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_STRETCH);
if (pango_font_description_get_variant (font_desc) == PANGO_VARIANT_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_VARIANT);
if (pango_font_description_get_style (font_desc) == PANGO_STYLE_NORMAL)
pango_font_description_unset_fields (font_desc,
PANGO_FONT_MASK_STYLE);
gtk_style_properties_set (priv->style, 0,
"font", font_desc,
NULL);
pango_font_description_free (font_desc);
g_free (font_name);
}
static void
gtk_settings_provider_iface_init (GtkStyleProviderIface *iface)
{
}
static GtkCssChange
gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher)
static GtkCssValue *
gtk_settings_style_provider_get_color (GtkStyleProviderPrivate *provider,
const char *name)
{
return 0;
GtkSettings *settings = GTK_SETTINGS (provider);
settings_ensure_style (settings);
return _gtk_style_provider_private_get_color (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style), name);
}
static GtkSettings *
gtk_settings_style_provider_get_settings (GtkStyleProviderPrivate *provider)
static void
gtk_settings_style_provider_lookup (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher,
GtkCssLookup *lookup)
{
return GTK_SETTINGS (provider);
GtkSettings *settings = GTK_SETTINGS (provider);
settings_ensure_style (settings);
_gtk_style_provider_private_lookup (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style),
matcher,
lookup);
}
static GtkCssChange
gtk_settings_style_provider_get_change (GtkStyleProviderPrivate *provider,
const GtkCssMatcher *matcher)
{
GtkSettings *settings = GTK_SETTINGS (provider);
settings_ensure_style (settings);
return _gtk_style_provider_private_get_change (GTK_STYLE_PROVIDER_PRIVATE (settings->priv->style),
matcher);
}
static void
gtk_settings_provider_private_init (GtkStyleProviderPrivateInterface *iface)
{
iface->get_settings = gtk_settings_style_provider_get_settings;
iface->get_color = gtk_settings_style_provider_get_color;
iface->lookup = gtk_settings_style_provider_lookup;
iface->get_change = gtk_settings_style_provider_get_change;
}
@@ -1453,6 +1522,8 @@ gtk_settings_finalize (GObject *object)
settings_update_provider (priv->screen, &priv->theme_provider, NULL);
settings_update_provider (priv->screen, &priv->key_theme_provider, NULL);
g_clear_object (&priv->style);
G_OBJECT_CLASS (gtk_settings_parent_class)->finalize (object);
}
@@ -1658,6 +1729,14 @@ gtk_settings_get_property (GObject *object,
static void
settings_invalidate_style (GtkSettings *settings)
{
GtkSettingsPrivate *priv = settings->priv;
if (priv->style)
{
g_object_unref (priv->style);
priv->style = NULL;
}
_gtk_style_provider_private_changed (GTK_STYLE_PROVIDER_PRIVATE (settings));
}
-24
View File
@@ -123,29 +123,6 @@ gtk_style_cascade_provider_iface_init (GtkStyleProviderIface *iface)
iface->get_style_property = gtk_style_cascade_get_style_property;
}
static GtkSettings *
gtk_style_cascade_get_settings (GtkStyleProviderPrivate *provider)
{
GtkStyleCascade *cascade = GTK_STYLE_CASCADE (provider);
GtkStyleCascadeIter iter;
GtkSettings *settings;
GtkStyleProvider *item;
for (item = gtk_style_cascade_iter_init (cascade, &iter);
item;
item = gtk_style_cascade_iter_next (cascade, &iter))
{
if (!GTK_IS_STYLE_PROVIDER_PRIVATE (item))
continue;
settings = _gtk_style_provider_private_get_settings (GTK_STYLE_PROVIDER_PRIVATE (item));
if (settings)
return settings;
}
return NULL;
}
static GtkCssValue *
gtk_style_cascade_get_color (GtkStyleProviderPrivate *provider,
const char *name)
@@ -256,7 +233,6 @@ static void
gtk_style_cascade_provider_private_iface_init (GtkStyleProviderPrivateInterface *iface)
{
iface->get_color = gtk_style_cascade_get_color;
iface->get_settings = gtk_style_cascade_get_settings;
iface->get_keyframes = gtk_style_cascade_get_keyframes;
iface->lookup = gtk_style_cascade_lookup;
iface->get_change = gtk_style_cascade_get_change;
+34 -72
View File
@@ -25,7 +25,6 @@
#include "gtkstylecontextprivate.h"
#include "gtkcontainerprivate.h"
#include "gtkcsscolorvalueprivate.h"
#include "gtkcsscornervalueprivate.h"
#include "gtkcssenginevalueprivate.h"
#include "gtkcssnumbervalueprivate.h"
#include "gtkcssrgbavalueprivate.h"
@@ -373,7 +372,7 @@ struct _GtkStyleContextPrivate
GtkCssChange relevant_changes;
GtkCssChange pending_changes;
const GtkBitmask *invalidating_context;
guint invalidating_context : 1;
guint invalid : 1;
};
@@ -2223,6 +2222,17 @@ _gtk_style_context_peek_property (GtkStyleContext *context,
return _gtk_css_computed_values_get_value (data->store, property_id);
}
double
_gtk_style_context_get_number (GtkStyleContext *context,
guint property_id,
double one_hundred_percent)
{
GtkCssValue *value;
value = _gtk_style_context_peek_property (context, property_id);
return _gtk_css_number_value_get (value, one_hundred_percent);
}
const GValue *
_gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type,
@@ -2961,8 +2971,7 @@ gtk_style_context_update_cache (GtkStyleContext *context,
}
static void
gtk_style_context_do_invalidate (GtkStyleContext *context,
const GtkBitmask *changes)
gtk_style_context_do_invalidate (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
@@ -2974,11 +2983,11 @@ gtk_style_context_do_invalidate (GtkStyleContext *context,
if (priv->invalidating_context)
return;
priv->invalidating_context = changes;
priv->invalidating_context = TRUE;
g_signal_emit (context, signals[CHANGED], 0);
priv->invalidating_context = NULL;
priv->invalidating_context = FALSE;
}
static GtkBitmask *
@@ -3168,7 +3177,7 @@ _gtk_style_context_validate (GtkStyleContext *context,
}
if (!_gtk_bitmask_is_empty (changes) || (change & GTK_CSS_CHANGE_FORCE_INVALIDATE))
gtk_style_context_do_invalidate (context, changes);
gtk_style_context_do_invalidate (context);
change = _gtk_css_change_for_child (change);
for (list = priv->children; list; list = list->next)
@@ -3217,25 +3226,10 @@ _gtk_style_context_queue_invalidate (GtkStyleContext *context,
void
gtk_style_context_invalidate (GtkStyleContext *context)
{
GtkBitmask *changes;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
gtk_style_context_clear_cache (context);
changes = _gtk_bitmask_new ();
changes = _gtk_bitmask_invert_range (changes,
0,
_gtk_css_style_property_get_n_properties ());
gtk_style_context_do_invalidate (context, changes);
_gtk_bitmask_free (changes);
}
static gboolean
corner_value_is_right_angle (GtkCssValue *value)
{
return _gtk_css_corner_value_get_x (value, 100) <= 0.0 &&
_gtk_css_corner_value_get_y (value, 100) <= 0.0;
gtk_style_context_do_invalidate (context);
}
/**
@@ -3252,33 +3246,21 @@ void
gtk_style_context_set_background (GtkStyleContext *context,
GdkWindow *window)
{
const GdkRGBA *color;
GtkStateFlags state;
GdkRGBA *color;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (GDK_IS_WINDOW (window));
/* This is a sophisitcated optimization.
* If we know the GDK window's background will be opaque, we mark
* it as opaque. This is so GDK can do all the optimizations it does
* for opaque windows and be fast.
* This is mainly used when scrolling.
*
* We could indeed just set black instead of the color we have.
*/
color = _gtk_css_rgba_value_get_rgba (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BACKGROUND_COLOR));
state = gtk_style_context_get_state (context);
if (color->alpha >= 1.0 &&
corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_LEFT_RADIUS)) &&
corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_TOP_RIGHT_RADIUS)) &&
corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_RIGHT_RADIUS)) &&
corner_value_is_right_angle (_gtk_style_context_peek_property (context, GTK_CSS_PROPERTY_BORDER_BOTTOM_LEFT_RADIUS)))
gtk_style_context_get (context, state,
"background-color", &color,
NULL);
if (color)
{
gdk_window_set_background_rgba (window, color);
}
else
{
GdkRGBA transparent = { 0.0, 0.0, 0.0, 0.0 };
gdk_window_set_background_rgba (window, &transparent);
gdk_rgba_free (color);
}
}
@@ -3488,9 +3470,6 @@ gtk_style_context_get_margin (GtkStyleContext *context,
* freed.
*
* Since: 3.0
*
* Deprecated: 3.8: Use gtk_style_context_get() for "font" or
* subproperties instead.
**/
const PangoFontDescription *
gtk_style_context_get_font (GtkStyleContext *context,
@@ -3509,12 +3488,15 @@ gtk_style_context_get_font (GtkStyleContext *context,
/* Yuck, fonts are created on-demand but we don't return a ref.
* Do bad things to achieve this requirement */
gtk_style_context_get (context, state, "font", &description, NULL);
g_object_set_data_full (G_OBJECT (data->store),
"font-cache-for-get_font",
description,
(GDestroyNotify) pango_font_description_free);
description = g_object_get_data (G_OBJECT (data->store), "font-cache-for-get_font");
if (description == NULL)
{
gtk_style_context_get (context, state, "font", &description, NULL);
g_object_set_data_full (G_OBJECT (data->store),
"font-cache-for-get_font",
description,
(GDestroyNotify) pango_font_description_free);
}
return description;
}
@@ -4521,26 +4503,6 @@ gtk_draw_insertion_cursor (GtkWidget *widget,
draw_arrow);
}
/**
* _gtk_style_context_get_changes:
* @context: the context to query
*
* Queries the context for the changes for the currently executing
* GtkStyleContext::invalidate signal. If no signal is currently
* emitted, this function returns %NULL.
*
* FIXME 4.0: Make this part of the signal.
*
* Returns: %NULL or the currently invalidating changes
**/
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context)
{
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
return context->priv->invalidating_context;
}
static AtkAttributeSet *
add_attribute (AtkAttributeSet *attributes,
AtkTextAttribute attr,
-2
View File
@@ -879,8 +879,6 @@ void gtk_style_context_get_background_color (GtkStyleContext *context,
void gtk_style_context_get_border_color (GtkStyleContext *context,
GtkStateFlags state,
GdkRGBA *color);
GDK_DEPRECATED_IN_3_8_FOR(gtk_style_context_get)
const PangoFontDescription *
gtk_style_context_get_font (GtkStyleContext *context,
GtkStateFlags state);
+3 -3
View File
@@ -27,11 +27,11 @@ G_BEGIN_DECLS
void _gtk_style_context_set_widget (GtkStyleContext *context,
GtkWidget *widget);
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context);
GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
guint property_id);
double _gtk_style_context_get_number (GtkStyleContext *context,
guint property_id,
double one_hundred_percent);
const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context,
GType widget_type,
GtkStateFlags state,
-2
View File
@@ -66,10 +66,8 @@ typedef gboolean (* GtkStylePropertyParser) (const gchar *string,
GType gtk_style_properties_get_type (void) G_GNUC_CONST;
/* Next 2 are implemented in gtkcsscustomproperty.c */
GDK_DEPRECATED_IN_3_8
void gtk_style_properties_register_property (GtkStylePropertyParser parse_func,
GParamSpec *pspec);
GDK_DEPRECATED_IN_3_8
gboolean gtk_style_properties_lookup_property (const gchar *property_name,
GtkStylePropertyParser *parse_func,
GParamSpec **pspec);
-15
View File
@@ -125,18 +125,3 @@ _gtk_style_provider_private_changed (GtkStyleProviderPrivate *provider)
g_signal_emit (provider, signals[CHANGED], 0);
}
GtkSettings *
_gtk_style_provider_private_get_settings (GtkStyleProviderPrivate *provider)
{
GtkStyleProviderPrivateInterface *iface;
g_return_val_if_fail (GTK_IS_STYLE_PROVIDER_PRIVATE (provider), NULL);
iface = GTK_STYLE_PROVIDER_PRIVATE_GET_INTERFACE (provider);
if (!iface->get_settings)
return NULL;
return iface->get_settings (provider);
}
-2
View File
@@ -41,7 +41,6 @@ struct _GtkStyleProviderPrivateInterface
GtkCssValue * (* get_color) (GtkStyleProviderPrivate *provider,
const char *name);
GtkSettings * (* get_settings) (GtkStyleProviderPrivate *provider);
GtkCssKeyframes * (* get_keyframes) (GtkStyleProviderPrivate *provider,
const char *name);
void (* lookup) (GtkStyleProviderPrivate *provider,
@@ -56,7 +55,6 @@ struct _GtkStyleProviderPrivateInterface
GType _gtk_style_provider_private_get_type (void) G_GNUC_CONST;
GtkSettings * _gtk_style_provider_private_get_settings (GtkStyleProviderPrivate *provider);
GtkCssValue * _gtk_style_provider_private_get_color (GtkStyleProviderPrivate *provider,
const char *name);
GtkCssKeyframes * _gtk_style_provider_private_get_keyframes(GtkStyleProviderPrivate *provider,
+20
View File
@@ -524,12 +524,15 @@ gtk_switch_draw (GtkWidget *widget,
GtkStyleContext *context;
GdkRectangle handle;
PangoLayout *layout;
PangoFontDescription *desc;
const PangoFontDescription *style_desc;
PangoRectangle rect;
gint label_x, label_y;
GtkBorder padding;
GtkStateFlags state;
gint focus_width, focus_pad;
gint x, y, width, height;
gint font_size, style_font_size;
gtk_widget_style_get (widget,
"focus-line-width", &focus_width,
@@ -582,6 +585,20 @@ gtk_switch_draw (GtkWidget *widget,
*/
layout = gtk_widget_create_pango_layout (widget, C_("switch", "ON"));
/* FIXME: this should be really done in the theme, but overriding font size
* from it doesn't currently work. So we have to hardcode this here and
* below for the "OFF" label.
*/
desc = pango_font_description_new ();
style_desc = gtk_style_context_get_font (context, state);
style_font_size = pango_font_description_get_size (style_desc);
font_size = MAX (style_font_size - 1 * PANGO_SCALE, ceil (style_font_size * PANGO_SCALE_SMALL));
pango_font_description_set_size (desc, font_size);
pango_layout_set_font_description (layout, desc);
pango_layout_get_extents (layout, NULL, &rect);
pango_extents_to_pixels (&rect, NULL);
@@ -596,6 +613,7 @@ gtk_switch_draw (GtkWidget *widget,
* glyphs then use WHITE CIRCLE (U+25CB) as the text for the state
*/
layout = gtk_widget_create_pango_layout (widget, C_("switch", "OFF"));
pango_layout_set_font_description (layout, desc);
pango_layout_get_extents (layout, NULL, &rect);
pango_extents_to_pixels (&rect, NULL);
@@ -618,6 +636,8 @@ gtk_switch_draw (GtkWidget *widget,
gtk_switch_paint_handle (widget, cr, &handle);
pango_font_description_free (desc);
return FALSE;
}
+1 -1
View File
@@ -298,7 +298,7 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
if (values->font)
pango_font_description_free (values->font);
gtk_style_context_get (context, state, "font", &values->font, NULL);
values->font = pango_font_description_copy (gtk_style_context_get_font (context, state));
}
cairo_surface_t *
+2 -10
View File
@@ -51,8 +51,6 @@
#include "gtkscrollable.h"
#include "gtktypebuiltins.h"
#include "gtktexthandleprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "a11y/gtktextviewaccessible.h"
@@ -4232,8 +4230,6 @@ gtk_text_view_style_updated (GtkWidget *widget)
GtkTextView *text_view;
GtkTextViewPrivate *priv;
PangoContext *ltr_context, *rtl_context;
GtkStyleContext *style_context;
const GtkBitmask *changes;
text_view = GTK_TEXT_VIEW (widget);
priv = text_view->priv;
@@ -4245,11 +4241,7 @@ gtk_text_view_style_updated (GtkWidget *widget)
gtk_text_view_set_background (text_view);
}
style_context = gtk_widget_get_style_context (widget);
changes = _gtk_style_context_get_changes (style_context);
if ((changes == NULL || _gtk_css_style_property_changes_affect_font (changes)) &&
priv->layout && priv->layout->default_style)
if (priv->layout && priv->layout->default_style)
{
gtk_text_view_set_attributes_from_style (text_view,
priv->layout->default_style);
@@ -6927,7 +6919,7 @@ gtk_text_view_set_attributes_from_style (GtkTextView *text_view,
if (values->font)
pango_font_description_free (values->font);
gtk_style_context_get (context, state, "font", &values->font, NULL);
values->font = pango_font_description_copy (gtk_style_context_get_font (context, state));
gtk_style_context_restore (context);
}
+10 -5
View File
@@ -355,6 +355,16 @@ _gtk_theming_engine_peek_property (GtkThemingEngine *engine,
return _gtk_style_context_peek_property (engine->priv->context, property_id);
}
double
_gtk_theming_engine_get_number (GtkThemingEngine *engine,
guint property_id,
double one_hundred_percent)
{
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), 0.0);
return _gtk_style_context_get_number (engine->priv->context, property_id, one_hundred_percent);
}
/**
* gtk_theming_engine_get_property:
* @engine: a #GtkThemingEngine
@@ -853,8 +863,6 @@ gtk_theming_engine_get_margin (GtkThemingEngine *engine,
* freed.
*
* Since: 3.0
*
* Deprecated: 3.8: Use gtk_theming_engine_get()
**/
const PangoFontDescription *
gtk_theming_engine_get_font (GtkThemingEngine *engine,
@@ -864,10 +872,8 @@ gtk_theming_engine_get_font (GtkThemingEngine *engine,
g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv = engine->priv;
return gtk_style_context_get_font (priv->context, state);
G_GNUC_END_IGNORE_DEPRECATIONS;
}
/* GtkThemingModule */
@@ -1650,7 +1656,6 @@ render_border (cairo_t *cr,
2 * other_border[GTK_CSS_LEFT]);
render_frame_fill (cr, &other_box, other_border, colors, dont_draw);
}
break;
case GTK_BORDER_STYLE_GROOVE:
case GTK_BORDER_STYLE_RIDGE:
{
-2
View File
@@ -182,7 +182,6 @@ struct _GtkThemingEngineClass
GType gtk_theming_engine_get_type (void) G_GNUC_CONST;
/* function implemented in gtkcsscustomproperty.c */
GDK_DEPRECATED_IN_3_8
void gtk_theming_engine_register_property (const gchar *name_space,
GtkStylePropertyParser parse_func,
GParamSpec *pspec);
@@ -249,7 +248,6 @@ void gtk_theming_engine_get_margin (GtkThemingEngine *engine,
GtkStateFlags state,
GtkBorder *margin);
GDK_DEPRECATED_IN_3_8_FOR(gtk_theming_engine_get)
const PangoFontDescription * gtk_theming_engine_get_font (GtkThemingEngine *engine,
GtkStateFlags state);
+3
View File
@@ -29,6 +29,9 @@ void _gtk_theming_engine_paint_spinner (cairo_t *cr,
GtkCssValue *_gtk_theming_engine_peek_property (GtkThemingEngine *engine,
guint property_id);
double _gtk_theming_engine_get_number (GtkThemingEngine *engine,
guint property_id,
double one_hundred_percent);
void _gtk_theming_engine_set_context (GtkThemingEngine *engine,
GtkStyleContext *context);
GtkStyleContext *_gtk_theming_engine_get_context (GtkThemingEngine *engine);
+8 -2
View File
@@ -3336,12 +3336,18 @@ calculate_max_homogeneous_pixels (GtkWidget *widget)
{
PangoContext *context;
PangoFontMetrics *metrics;
const PangoFontDescription *font_desc;
GtkStyleContext *style_context;
GtkStateFlags state;
gint char_width;
context = gtk_widget_get_pango_context (widget);
style_context = gtk_widget_get_style_context (widget);
state = gtk_widget_get_state_flags (widget);
metrics = pango_context_get_metrics (context,
pango_context_get_font_description (context),
font_desc = gtk_style_context_get_font (style_context, state);
metrics = pango_context_get_metrics (context, font_desc,
pango_context_get_language (context));
char_width = pango_font_metrics_get_approximate_char_width (metrics);
pango_font_metrics_unref (metrics);
+19 -11
View File
@@ -3758,14 +3758,10 @@ gtk_tree_model_filter_set_root (GtkTreeModelFilter *filter,
{
g_return_if_fail (GTK_IS_TREE_MODEL_FILTER (filter));
if (root)
{
filter->priv->virtual_root = gtk_tree_path_copy (root);
gtk_tree_model_filter_ref_path (filter, filter->priv->virtual_root);
filter->priv->virtual_root_deleted = FALSE;
}
else
if (!root)
filter->priv->virtual_root = NULL;
else
filter->priv->virtual_root = gtk_tree_path_copy (root);
}
/* public API */
@@ -3786,12 +3782,24 @@ GtkTreeModel *
gtk_tree_model_filter_new (GtkTreeModel *child_model,
GtkTreePath *root)
{
GtkTreeModel *retval;
GtkTreeModelFilter *filter;
g_return_val_if_fail (GTK_IS_TREE_MODEL (child_model), NULL);
return g_object_new (GTK_TYPE_TREE_MODEL_FILTER,
"child-model", child_model,
"virtual-root", root,
NULL);
retval = g_object_new (GTK_TYPE_TREE_MODEL_FILTER,
"child-model", child_model,
"virtual-root", root,
NULL);
filter = GTK_TREE_MODEL_FILTER (retval);
if (filter->priv->virtual_root)
{
gtk_tree_model_filter_ref_path (filter, filter->priv->virtual_root);
filter->priv->virtual_root_deleted = FALSE;
}
return retval;
}
/**
+1 -1
View File
@@ -54,7 +54,7 @@
*
* One of the important things to remember when monitoring the selection of
* a view is that the #GtkTreeSelection::changed signal is mostly a hint.
* That is, it may only emit one signal when a range of rows is selected.
* That is,it may only emit one signal when a range of rows is selected.
* Additionally, it may on occasion emit a #GtkTreeSelection::changed signal
* when nothing has happened (mostly as a result of programmers calling
* select_row on an already selected row).
+8 -14
View File
@@ -48,7 +48,6 @@
#include "gtkwidgetprivate.h"
#include "gtkentryprivate.h"
#include "gtkstylecontextprivate.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtktypebuiltins.h"
#include "gtkmain.h"
#include "gtksettings.h"
@@ -8462,8 +8461,6 @@ gtk_tree_view_style_updated (GtkWidget *widget)
GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GList *list;
GtkTreeViewColumn *column;
GtkStyleContext *style_context;
const GtkBitmask *changes;
GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->style_updated (widget);
@@ -8475,19 +8472,16 @@ gtk_tree_view_style_updated (GtkWidget *widget)
gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->priv->tree_lines_enabled);
}
style_context = gtk_widget_get_style_context (widget);
changes = _gtk_style_context_get_changes (style_context);
if (changes == NULL || _gtk_css_style_property_changes_affect_size (changes))
for (list = tree_view->priv->columns; list; list = list->next)
{
for (list = tree_view->priv->columns; list; list = list->next)
{
column = list->data;
_gtk_tree_view_column_cell_set_dirty (column, TRUE);
}
tree_view->priv->fixed_height = -1;
_gtk_rbtree_mark_invalid (tree_view->priv->tree);
column = list->data;
_gtk_tree_view_column_cell_set_dirty (column, TRUE);
}
tree_view->priv->fixed_height = -1;
_gtk_rbtree_mark_invalid (tree_view->priv->tree);
gtk_widget_queue_resize (widget);
}
+1
View File
@@ -241,6 +241,7 @@ gtk_viewport_init (GtkViewport *viewport)
gtk_widget_set_has_window (GTK_WIDGET (viewport), TRUE);
gtk_widget_set_redraw_on_allocate (GTK_WIDGET (viewport), FALSE);
gtk_container_set_resize_mode (GTK_CONTAINER (viewport), GTK_RESIZE_QUEUE);
priv->shadow_type = GTK_SHADOW_IN;
priv->view_window = NULL;
+21 -31
View File
@@ -35,7 +35,6 @@
#include "gtkcontainer.h"
#include "gtkaccelmapprivate.h"
#include "gtkclipboard.h"
#include "gtkcssstylepropertyprivate.h"
#include "gtkiconfactory.h"
#include "gtkintl.h"
#include "gtkmarshalers.h"
@@ -854,8 +853,6 @@ gtk_widget_draw_marshallerv (GClosure *closure,
param_types);
cairo_restore (cr);
va_end (args_copy);
}
static void
@@ -6717,27 +6714,15 @@ gtk_widget_real_style_updated (GtkWidget *widget)
if (widget->priv->context)
{
const GtkBitmask *changes = _gtk_style_context_get_changes (widget->priv->context);
if (gtk_widget_get_realized (widget) &&
gtk_widget_get_has_window (widget) &&
!gtk_widget_get_app_paintable (widget))
gtk_style_context_set_background (widget->priv->context,
widget->priv->window);
}
if (widget->priv->anchored)
{
if (changes && _gtk_css_style_property_changes_affect_size (changes))
gtk_widget_queue_resize (widget);
else
gtk_widget_queue_draw (widget);
}
}
else
{
if (widget->priv->anchored)
gtk_widget_queue_resize (widget);
}
if (widget->priv->anchored)
gtk_widget_queue_resize (widget);
}
static gboolean
@@ -8705,8 +8690,12 @@ gtk_widget_peek_pango_context (GtkWidget *widget)
* by gtk_widget_create_pango_context(), this context is owned by
* the widget (it can be used until the screen for the widget changes
* or the widget is removed from its toplevel), and will be updated to
* match any changes to the widget's attributes. This can be tracked
* by using the #GtkWidget::screen-changed signal on the widget.
* match any changes to the widget's attributes.
*
* If you create and keep a #PangoLayout using this context, you must
* deal with changes to the context by calling pango_layout_context_changed()
* on the layout in response to the #GtkWidget::style-updated and
* #GtkWidget::direction-changed signals for the widget.
*
* Return value: (transfer none): the #PangoContext for the widget.
**/
@@ -8734,21 +8723,18 @@ static void
update_pango_context (GtkWidget *widget,
PangoContext *context)
{
PangoFontDescription *font_desc;
const PangoFontDescription *font_desc;
GtkStyleContext *style_context;
style_context = gtk_widget_get_style_context (widget);
gtk_style_context_get (style_context,
gtk_widget_get_state_flags (widget),
"font", &font_desc,
NULL);
font_desc = gtk_style_context_get_font (style_context,
gtk_widget_get_state_flags (widget));
pango_context_set_font_description (context, font_desc);
pango_context_set_base_dir (context,
gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR ?
PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL);
pango_font_description_free (font_desc);
}
static void
@@ -8817,10 +8803,11 @@ gtk_widget_create_pango_context (GtkWidget *widget)
* font description, and base direction for drawing text for
* this widget.
*
* If you keep a #PangoLayout created in this way around, you need
* to re-create it when the widget #PangoContext is replaced.
* This can be tracked by using the #GtkWidget::screen-changed signal
* on the widget.
* If you keep a #PangoLayout created in this way around, in order to
* notify the layout of changes to the base direction or font of this
* widget, you must call pango_layout_context_changed() in response to
* the #GtkWidget::style-updated and #GtkWidget::direction-changed signals
* for the widget.
*
* Return value: (transfer full): the new #PangoLayout
**/
@@ -13963,6 +13950,9 @@ _gtk_widget_style_context_invalidated (GtkWidget *widget)
*/
widget->priv->style_update_pending = TRUE;
}
if (widget->priv->anchored)
gtk_widget_queue_resize (widget);
}
/**
+1
View File
@@ -5735,6 +5735,7 @@ gtk_window_style_updated (GtkWidget *widget)
rect.width, rect.height);
set_grip_shape (window);
gtk_widget_queue_resize (widget);
}
}
@@ -42,8 +42,6 @@
</key>
<key name='show-hidden' type='b'>
<default>false</default>
<summary>Whether to show hidden files</summary>
<description>If set to true, then hidden files are shown by default. Hidden files are either dotfiles, listed in the folder's .hidden file or backup files ending with a tilde (~).</description>
</key>
<key name='expand-folders' type='b'>
<default>false</default>
-51
View File
@@ -2715,56 +2715,6 @@ test_level_bar (void)
g_object_unref (builder);
}
static GObject *external_object = NULL, *external_object_swapped = NULL;
void
on_button_clicked (GtkButton *button, GObject *data)
{
external_object = data;
}
void
on_button_clicked_swapped (GObject *data, GtkButton *button)
{
external_object_swapped = data;
}
static void
test_expose_object (void)
{
GtkBuilder *builder;
GError *error = NULL;
GtkWidget *image;
GObject *obj;
const gchar buffer[] =
"<interface>"
" <object class=\"GtkButton\" id=\"button\">"
" <property name=\"image\">external_image</property>"
" <signal name=\"clicked\" handler=\"on_button_clicked\" object=\"builder\" swapped=\"no\"/>"
" <signal name=\"clicked\" handler=\"on_button_clicked_swapped\" object=\"builder\"/>"
" </object>"
"</interface>";
image = gtk_image_new ();
builder = gtk_builder_new ();
gtk_builder_expose_object (builder, "external_image", G_OBJECT (image));
gtk_builder_expose_object (builder, "builder", G_OBJECT (builder));
gtk_builder_add_from_string (builder, buffer, -1, &error);
g_assert (error == NULL);
obj = gtk_builder_get_object (builder, "button");
g_assert (GTK_IS_BUTTON (obj));
g_assert (gtk_button_get_image (GTK_BUTTON (obj)) == image);
/* Connect signals and fake clicked event */
gtk_builder_connect_signals (builder, NULL);
gtk_button_clicked (GTK_BUTTON (obj));
g_assert (external_object == G_OBJECT (builder));
g_assert (external_object_swapped == G_OBJECT (builder));
}
int
main (int argc, char **argv)
{
@@ -2813,7 +2763,6 @@ main (int argc, char **argv)
g_test_add_func ("/Builder/MessageDialog", test_message_dialog);
g_test_add_func ("/Builder/GMenu", test_gmenu);
g_test_add_func ("/Builder/LevelBar", test_level_bar);
g_test_add_func ("/Builder/Expose Object", test_expose_object);
return g_test_run();
}
+14 -14
View File
@@ -279,7 +279,7 @@ gtk_im_context_ime_set_client_window (GtkIMContext *context,
HIMC himc;
HWND hwnd;
hwnd = gdk_win32_window_get_impl_hwnd (client_window);
hwnd = GDK_WINDOW_HWND (client_window);
himc = ImmGetContext (hwnd);
if (himc)
{
@@ -349,7 +349,7 @@ gtk_im_context_ime_reset (GtkIMContext *context)
if (!context_ime->client_window)
return;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -380,7 +380,7 @@ get_utf8_preedit_string (GtkIMContextIME *context_ime, gint *pos_ret)
if (!context_ime->client_window)
return g_strdup ("");
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return g_strdup ("");
@@ -441,7 +441,7 @@ get_pango_attr_list (GtkIMContextIME *context_ime, const gchar *utf8str)
if (!context_ime->client_window)
return attrs;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return attrs;
@@ -579,7 +579,7 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
/* swtich current context */
context_ime->focus = TRUE;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -589,7 +589,7 @@ gtk_im_context_ime_focus_in (GtkIMContext *context)
{
gdk_window_add_filter (toplevel,
gtk_im_context_ime_message_filter, context_ime);
top_hwnd = gdk_win32_window_get_impl_hwnd (toplevel);
top_hwnd = GDK_WINDOW_HWND (toplevel);
context_ime->toplevel = toplevel;
}
@@ -652,7 +652,7 @@ gtk_im_context_ime_focus_out (GtkIMContext *context)
/* swtich current context */
context_ime->focus = FALSE;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -714,7 +714,7 @@ gtk_im_context_ime_focus_out (GtkIMContext *context)
gdk_window_remove_filter (toplevel,
gtk_im_context_ime_message_filter,
context_ime);
top_hwnd = gdk_win32_window_get_impl_hwnd (toplevel);
top_hwnd = GDK_WINDOW_HWND (toplevel);
context_ime->toplevel = NULL;
}
@@ -748,7 +748,7 @@ gtk_im_context_ime_set_cursor_location (GtkIMContext *context,
if (!context_ime->client_window)
return;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -778,7 +778,7 @@ gtk_im_context_ime_set_use_preedit (GtkIMContext *context,
HWND hwnd;
HIMC himc;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -814,7 +814,7 @@ gtk_im_context_ime_set_preedit_font (GtkIMContext *context)
if (!GTK_IS_WIDGET (widget))
return;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return;
@@ -921,7 +921,7 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
if (!context_ime->focus)
return retval;
hwnd = gdk_win32_window_get_impl_hwnd (context_ime->client_window);
hwnd = GDK_WINDOW_HWND (context_ime->client_window);
himc = ImmGetContext (hwnd);
if (!himc)
return retval;
@@ -941,8 +941,8 @@ gtk_im_context_ime_message_filter (GdkXEvent *xevent,
RECT rc;
hwnd_top =
gdk_win32_window_get_impl_hwnd (gdk_window_get_toplevel
(context_ime->client_window));
GDK_WINDOW_HWND (gdk_window_get_toplevel
(context_ime->client_window));
GetWindowRect (hwnd_top, &rc);
pt.x = wx;
pt.y = wy;
@@ -2210,8 +2210,7 @@ cups_request_printer_list_cb (GtkPrintBackendCups *cups_backend,
as inactive if it is in the list, emitting a printer_removed signal */
if (removed_printer_checklist != NULL)
{
g_list_foreach (removed_printer_checklist, (GFunc) mark_printer_inactive, backend);
g_list_free (removed_printer_checklist);
g_list_free_full (removed_printer_checklist, (GDestroyNotify) mark_printer_inactive);
list_has_changed = TRUE;
}
@@ -3170,7 +3169,7 @@ value_is_off (const char *value)
static char *
ppd_group_name (ppd_group_t *group)
{
return group->name;
return group->text;
}
static int
-1
View File
@@ -97,7 +97,6 @@ all-no:
$(srcdir)/$(GETTEXT_PACKAGE).pot: $(POTFILES)
$(XGETTEXT) --default-domain=$(GETTEXT_PACKAGE) --directory=$(top_srcdir) \
--add-comments --keyword --keyword=P_ \
--from-code=utf-8 \
--files-from=$(srcdir)/POTFILES.in \
&& test ! -f $(GETTEXT_PACKAGE).po \
|| ( rm -f $(srcdir)/$(GETTEXT_PACKAGE).pot \
-2
View File
@@ -53,8 +53,6 @@ tests/reftests/css-multi-state.ref.ui
tests/reftests/css-multi-state.ui
tests/reftests/entry-progress-coloring.ref.ui
tests/reftests/entry-progress-coloring.ui
tests/reftests/font-sizes-names.ref.ui
tests/reftests/font-sizes-names.ui
tests/reftests/grid-empty-with-spacing.ui
tests/reftests/grid-wfh.ref.ui
tests/reftests/grid-wfh.ui
+554 -571
View File
File diff suppressed because it is too large Load Diff
+586 -605
View File
File diff suppressed because it is too large Load Diff
+724 -743
View File
File diff suppressed because it is too large Load Diff
+755 -771
View File
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More