Compare commits

...

17 Commits

Author SHA1 Message Date
Emmanuele Bassi
54cc84ff43 application: Add a default <Primary>Q accelerator
We want all GTK applications to quit in a common way, to avoid
inconsistencies.
2015-10-06 12:28:42 +01:00
Olivier Fourdan
ecb0e777fa GdkAppLaunchContext: Set DISPLAY variable for X11
The environment variable DISPLAY makes sense only for X11, so set its
value in the X11 backend.

https://bugzilla.gnome.org/show_bug.cgi?id=754983
2015-10-05 23:40:56 -04:00
Matthias Clasen
35b088459e assistant: Deal with spontaneous page disappearance
Removing pages from the assistant with gtk_widget_destroy() used
to work. It broke with the recent interposition of a box between
each page and the notebook. Fix this by cleaning up when the box
child is removed.

https://bugzilla.gnome.org/show_bug.cgi?id=756042
2015-10-05 08:21:55 -04:00
Wolfgang Stöggl
1ae98e72f7 Updated German translation 2015-10-04 09:04:15 +00:00
Rafal Luzynski
3c253c46a5 flowbox: correct the behavior with "can-focus"==FALSE
In fact there were two issues:

1. GtkFlowBoxChild with "can-focus"==FALSE should pass the focus
to its child immediately.
2. GtkFlowBox with "can-focus"==FALSE should cease its custom keynav
implementation and fall back to the default GtkContainer behavior
which is more natural.

Thanks to these changes the flow box can act as a better replacement
for GtkGrid and similar containers.

https://bugzilla.gnome.org/show_bug.cgi?id=753371
2015-10-03 22:48:15 -04:00
Matthias Clasen
896f911ea1 Bump version to 3.19.0
Otherwise, internal use of new API causes deprecation warnings.
2015-10-03 22:42:12 -04:00
Matthias Clasen
47237ddd94 inspector: Add a reset button for settings
This is exercising the new gtk_settings_reset_property api.

https://bugzilla.gnome.org/show_bug.cgi?id=755008
2015-10-03 22:42:12 -04:00
Matthias Clasen
2f0d4b6868 Add gtk_settings_reset_property
This api undoes an application-specific override and makes the
setting follow the system-wide values again.

https://bugzilla.gnome.org/show_bug.cgi?id=755008
2015-10-03 22:42:12 -04:00
Matthias Clasen
d930ea7c1f style context: Avoid a compiler warning 2015-10-03 22:42:12 -04:00
John Ralls
571704824f Bug 753992 - im-quartz discard_preedit segmentation fault
Replace checking if the NSView is really a GdkWindow, which will crash
in the likely event it's not a GObject, with ensuring that the parent
GdkWindow is really a GdkWindowQuartz.
2015-10-03 22:28:36 -04:00
Benjamin Otte
2dad7c1319 gdk: Add gdk_rectangle_equal()
There's enough users inside GTK to warrant this convenience function.
2015-10-03 22:26:27 -04:00
Sébastien Wilmet
5a561a8ddb texttag: add gtk_text_tag_changed()
The function is useful for a GtkTextTag subclass that adds new
properties.

https://bugzilla.gnome.org/show_bug.cgi?id=755416
2015-10-03 22:24:17 -04:00
Benjamin Otte
cc2224cc62 gdk: Add version macros for 3.20 2015-10-03 22:24:17 -04:00
Matthias Clasen
598e17018c style context: Formatting fixes 2015-10-03 21:38:20 -04:00
Matthias Clasen
40190c295c Add a test for gtk_style_context_list_classes
This test failed before the previous commit.
2015-10-03 17:38:36 -04:00
Matthias Clasen
506fe61938 Fix gtk_style_context_list_classes
The function was always returning NULL.
2015-10-03 17:37:34 -04:00
Matthias Clasen
83b8bcb63a switch: Unclip the slider shadow
This commit arranges things so the shadow of the slider can
extend outside the widget, even if the switch itself has no
shadow.

https://bugzilla.gnome.org/show_bug.cgi?id=755791
2015-10-03 16:20:50 -04:00
24 changed files with 2122 additions and 1805 deletions

View File

@@ -9,9 +9,9 @@
# set GTK_BINARY_AGE and GTK_INTERFACE_AGE to 0.
m4_define([gtk_major_version], [3])
m4_define([gtk_minor_version], [18])
m4_define([gtk_micro_version], [1])
m4_define([gtk_interface_age], [1])
m4_define([gtk_minor_version], [19])
m4_define([gtk_micro_version], [0])
m4_define([gtk_interface_age], [0])
m4_define([gtk_binary_age],
[m4_eval(100 * gtk_minor_version + gtk_micro_version)])
m4_define([gtk_version],

View File

@@ -631,6 +631,7 @@ GdkPoint
GdkRectangle
gdk_rectangle_intersect
gdk_rectangle_union
gdk_rectangle_equal
<SUBSECTION Private>
gdk_rectangle_get_type

View File

@@ -3294,6 +3294,7 @@ gtk_settings_set_property_value
gtk_settings_set_string_property
gtk_settings_set_long_property
gtk_settings_set_double_property
gtk_settings_reset_property
GtkIMPreeditStyle
GtkIMStatusStyle
<SUBSECTION Standard>
@@ -3809,6 +3810,7 @@ gtk_text_tag_new
gtk_text_tag_get_priority
gtk_text_tag_set_priority
gtk_text_tag_event
gtk_text_tag_changed
GtkTextAttributes
GtkTextAppearance
gtk_text_attributes_new

View File

@@ -133,6 +133,27 @@ gdk_rectangle_intersect (const GdkRectangle *src1,
return return_val;
}
/**
* gdk_rectangle_equal:
* @rect1: a #GdkRectangle
* @rect2: a #GdkRectangle
*
* Checks if the two given rectangles are equal.
*
* Returns: %TRUE if the rectangles are equal.
*
* Since: 3.20
*/
gboolean
gdk_rectangle_equal (const GdkRectangle *rect1,
const GdkRectangle *rect2)
{
return rect1->x == rect2->x
&& rect1->y == rect2->y
&& rect1->width == rect2->width
&& rect1->height == rect2->height;
}
static GdkRectangle *
gdk_rectangle_copy (const GdkRectangle *rectangle)
{

View File

@@ -45,6 +45,10 @@ void gdk_rectangle_union (const GdkRectangle *src1,
const GdkRectangle *src2,
GdkRectangle *dest);
GDK_AVAILABLE_IN_3_20
gboolean gdk_rectangle_equal (const GdkRectangle *rect1,
const GdkRectangle *rect2);
GDK_AVAILABLE_IN_ALL
GType gdk_rectangle_get_type (void) G_GNUC_CONST;

View File

@@ -152,6 +152,16 @@
*/
#define GDK_VERSION_3_18 (G_ENCODE_VERSION (3, 18))
/**
* GDK_VERSION_3_20:
*
* A macro that evaluates to the 3.20 version of GDK, in a format
* that can be used by the C pre-processor.
*
* Since: 3.18
*/
#define GDK_VERSION_3_20 (G_ENCODE_VERSION (3, 20))
/* evaluates to the current stable version; for development cycles,
* this means the next stable target
*/
@@ -364,5 +374,19 @@
# define GDK_AVAILABLE_IN_3_18 _GDK_EXTERN
#endif
#if GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_20
# define GDK_DEPRECATED_IN_3_20 GDK_DEPRECATED
# define GDK_DEPRECATED_IN_3_20_FOR(f) GDK_DEPRECATED_FOR(f)
#else
# define GDK_DEPRECATED_IN_3_20 _GDK_EXTERN
# define GDK_DEPRECATED_IN_3_20_FOR(f) _GDK_EXTERN
#endif
#if GDK_VERSION_MAX_ALLOWED < GDK_VERSION_3_20
# define GDK_AVAILABLE_IN_3_20 GDK_UNAVAILABLE(3, 20)
#else
# define GDK_AVAILABLE_IN_3_20 _GDK_EXTERN
#endif
#endif /* __GDK_VERSION_MACROS_H__ */

View File

@@ -463,10 +463,17 @@ GdkAppLaunchContext *
_gdk_x11_display_get_app_launch_context (GdkDisplay *display)
{
GdkAppLaunchContext *ctx;
static gchar *display_name;
ctx = g_object_new (GDK_TYPE_X11_APP_LAUNCH_CONTEXT,
"display", display,
NULL);
display_name = g_app_launch_context_get_display (G_APP_LAUNCH_CONTEXT (ctx),
NULL, NULL);
if (display_name)
g_app_launch_context_setenv (G_APP_LAUNCH_CONTEXT (ctx),
"DISPLAY", display_name);
return ctx;
}

View File

@@ -590,6 +590,11 @@ gtk_application_load_resources (GtkApplication *application)
}
}
static void
gtk_application_quit_cb (GApplication *g_application)
{
g_application_quit (g_application);
}
static void
gtk_application_startup (GApplication *g_application)
@@ -607,6 +612,18 @@ gtk_application_startup (GApplication *g_application)
gtk_application_impl_startup (application->priv->impl, application->priv->register_session);
gtk_application_load_resources (application);
{
static const char *quit_accels[2] = { "<Primary>q", NULL };
GAction *quit_action = g_simple_action_new ("quit", NULL);
g_signal_connect_swapped (quit_action, "activate", G_CALLBACK (gtk_application_quit_cb), application);
g_action_map_add_action (G_ACTION_MAP (application), quit_action);
g_object_unref (quit_action);
gtk_application_set_accels_for_action (application, "app.quit", quit_accels);
}
}
static void

View File

@@ -88,6 +88,7 @@ struct _GtkAssistantPage
gchar *title;
GtkWidget *box;
GtkWidget *page;
GtkWidget *regular_title;
GtkWidget *current_title;
@@ -184,7 +185,7 @@ static void on_assistant_cancel (GtkWidget *wid
GtkAssistant *assistant);
static void on_assistant_last (GtkWidget *widget,
GtkAssistant *assistant);
static void assistant_remove_page_cb (GtkNotebook *notebook,
static void assistant_remove_page_cb (GtkContainer *container,
GtkWidget *page,
GtkAssistant *assistant);
@@ -1113,7 +1114,7 @@ on_page_notify_visibility (GtkWidget *widget,
}
static void
assistant_remove_page_cb (GtkNotebook *notebook,
assistant_remove_page_cb (GtkContainer *container,
GtkWidget *page,
GtkAssistant *assistant)
{
@@ -1122,15 +1123,6 @@ assistant_remove_page_cb (GtkNotebook *notebook,
GList *page_node;
GList *element;
if (GTK_IS_BOX (page))
{
GList *children;
children = gtk_container_get_children (GTK_CONTAINER (page));
page = GTK_WIDGET (children->data);
g_list_free (children);
}
element = find_page (assistant, page);
if (!element)
return;
@@ -1367,7 +1359,7 @@ find_page (GtkAssistant *assistant,
while (child)
{
GtkAssistantPage *page_info = child->data;
if (page_info->page == page)
if (page_info->page == page || page_info->box == page)
return child;
child = child->next;
@@ -1816,9 +1808,12 @@ gtk_assistant_insert_page (GtkAssistant *assistant,
gtk_widget_show (box);
gtk_box_pack_start (GTK_BOX (box), page, TRUE, TRUE, 0);
g_object_set (box, "margin", 12, NULL);
g_signal_connect (box, "remove", G_CALLBACK (assistant_remove_page_cb), assistant);
gtk_notebook_insert_page (GTK_NOTEBOOK (priv->content), box, NULL, position);
page_info->box = box;
if (gtk_widget_get_mapped (GTK_WIDGET (assistant)))
{
update_buttons_state (assistant);
@@ -2415,7 +2410,7 @@ gtk_assistant_set_page_has_padding (GtkAssistant *assistant,
{
page_info->has_padding = has_padding;
g_object_set (gtk_widget_get_parent (page),
g_object_set (page_info->box,
"margin", has_padding ? 12 : 0,
NULL);

View File

@@ -292,6 +292,23 @@ gtk_flow_box_child_focus (GtkWidget *widget,
child = gtk_bin_get_child (GTK_BIN (widget));
/* Without "can-focus" flag try to pass the focus to the child immediately */
if (!gtk_widget_get_can_focus (widget))
{
if (child)
{
if (gtk_widget_child_focus (child, direction))
{
GtkFlowBox *box;
box = gtk_flow_box_child_get_box (GTK_FLOW_BOX_CHILD (widget));
if (box)
gtk_flow_box_update_cursor (box, GTK_FLOW_BOX_CHILD (widget));
return TRUE;
}
}
return FALSE;
}
g_object_get (widget, "has-focus", &had_focus, NULL);
if (had_focus)
{
@@ -3193,6 +3210,12 @@ gtk_flow_box_focus (GtkWidget *widget,
GSequenceIter *iter;
GtkFlowBoxChild *next_focus_child;
/* Without "can-focus" flag fall back to the default behavior immediately */
if (!gtk_widget_get_can_focus (widget))
{
return GTK_WIDGET_CLASS (gtk_flow_box_parent_class)->focus (widget, direction);
}
focus_child = gtk_container_get_focus_child (GTK_CONTAINER (box));
next_focus_child = NULL;
@@ -3313,7 +3336,7 @@ gtk_flow_box_toggle_cursor_child (GtkFlowBox *box)
gtk_flow_box_select_and_activate (box, priv->cursor_child);
}
static void
static gboolean
gtk_flow_box_move_cursor (GtkFlowBox *box,
GtkMovementStep step,
gint count)
@@ -3331,6 +3354,10 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
GtkAdjustment *adjustment;
gboolean vertical;
/* Without "can-focus" flag fall back to the default behavior immediately */
if (!gtk_widget_get_can_focus (GTK_WIDGET (box)))
return FALSE;
vertical = priv->orientation == GTK_ORIENTATION_VERTICAL;
if (vertical)
@@ -3479,17 +3506,25 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
if (!gtk_widget_keynav_failed (GTK_WIDGET (box), direction))
{
GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (box));
if (toplevel)
gtk_widget_child_focus (toplevel,
direction == GTK_DIR_UP ?
GTK_DIR_TAB_BACKWARD :
GTK_DIR_TAB_FORWARD);
return FALSE;
}
return;
return TRUE;
}
/* If the child has its "can-focus" property set to FALSE then it will
* not grab the focus. We must pass the focus to its child directly.
*/
if (!gtk_widget_get_can_focus (GTK_WIDGET (child)))
{
GtkWidget *subchild;
subchild = gtk_bin_get_child (GTK_BIN (child));
if (subchild)
{
GtkDirectionType direction = count < 0 ? GTK_DIR_TAB_BACKWARD : GTK_DIR_TAB_FORWARD;
gtk_widget_child_focus (subchild, direction);
}
}
get_current_selection_modifiers (GTK_WIDGET (box), &modify, &extend);
@@ -3497,6 +3532,7 @@ gtk_flow_box_move_cursor (GtkFlowBox *box,
gtk_flow_box_update_cursor (box, child);
if (!modify)
gtk_flow_box_update_selection (box, child, FALSE, extend);
return TRUE;
}
/* Selection {{{2 */
@@ -3845,8 +3881,6 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
* The ::move-cursor signal is a
* [keybinding signal][GtkBindingSignal]
* which gets emitted when the user initiates a cursor movement.
* If the cursor is not visible in @text_view, this signal causes
* the viewport to be moved instead.
*
* Applications should not connect to it, but may emit it with
* g_signal_emit_by_name() if they need to control the cursor
@@ -3859,14 +3893,17 @@ gtk_flow_box_class_init (GtkFlowBoxClass *class)
* - Arrow keys move by individual children
* - Home/End keys move to the ends of the box
* - PageUp/PageDown keys move vertically by pages
*
* Returns: %TRUE to stop other handlers from being invoked for the event.
* %FALSE to propagate the event further.
*/
signals[MOVE_CURSOR] = g_signal_new (I_("move-cursor"),
GTK_TYPE_FLOW_BOX,
G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
G_STRUCT_OFFSET (GtkFlowBoxClass, move_cursor),
NULL, NULL,
_gtk_marshal_VOID__ENUM_INT,
G_TYPE_NONE, 2,
_gtk_marshal_BOOLEAN__ENUM_INT,
G_TYPE_BOOLEAN, 2,
GTK_TYPE_MOVEMENT_STEP, G_TYPE_INT);
/**
* GtkFlowBox::select-all:

View File

@@ -61,7 +61,7 @@ struct _GtkFlowBoxClass
void (*selected_children_changed) (GtkFlowBox *box);
void (*activate_cursor_child) (GtkFlowBox *box);
void (*toggle_cursor_child) (GtkFlowBox *box);
void (*move_cursor) (GtkFlowBox *box,
gboolean (*move_cursor) (GtkFlowBox *box,
GtkMovementStep step,
gint count);
void (*select_all) (GtkFlowBox *box);

View File

@@ -707,16 +707,6 @@ gtk_frame_draw (GtkWidget *widget,
return FALSE;
}
static gboolean
rectangle_equal (const GdkRectangle *a,
const GdkRectangle *b)
{
return a->x == b->x
&& a->y == b->y
&& a->width == b->width
&& a->height == b->height;
}
static void
gtk_frame_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
@@ -734,7 +724,7 @@ gtk_frame_size_allocate (GtkWidget *widget,
/* If the child allocation changed, that means that the frame is drawn
* in a new place, so we must redraw the entire widget.
*/
if (gtk_widget_get_mapped (widget) && !rectangle_equal (&priv->child_allocation, &new_allocation))
if (gtk_widget_get_mapped (widget) && !gdk_rectangle_equal (&priv->child_allocation, &new_allocation))
{
gdk_window_invalidate_rect (gtk_widget_get_window (widget), allocation, FALSE);
}

View File

@@ -3655,16 +3655,6 @@ gtk_range_compute_slider_position (GtkRange *range,
}
}
static gboolean
rectangle_equal (const GdkRectangle *a,
const GdkRectangle *b)
{
return a->x == b->x
&& a->y == b->y
&& a->width == b->width
&& a->height == b->height;
}
static void
gtk_range_calc_slider (GtkRange *range)
{
@@ -3675,7 +3665,7 @@ gtk_range_calc_slider (GtkRange *range)
gtk_adjustment_get_value (priv->adjustment),
&new_slider);
if (rectangle_equal (&priv->slider, &new_slider))
if (gdk_rectangle_equal (&priv->slider, &new_slider))
return;
gtk_range_queue_draw_location (range, MOUSE_SLIDER);

View File

@@ -3395,3 +3395,31 @@ _gtk_settings_get_setting_source (GtkSettings *settings,
return priv->property_values[pspec->param_id - 1].source;
}
/**
* gtk_settings_reset_property:
* @settings: a #GtkSettings object
* @name: the name of the setting to reset
*
* Undoes the effect of calling g_object_set() to install an
* application-specific value for a setting. After this call,
* the setting will again follow the session-wide value for
* this setting.
*
* Since: 3.20
*/
void
gtk_settings_reset_property (GtkSettings *settings,
const gchar *name)
{
GtkSettingsPrivate *priv = settings->priv;
GParamSpec *pspec;
pspec = g_object_class_find_property (G_OBJECT_GET_CLASS (settings), name);
g_return_if_fail (pspec != NULL);
g_param_value_set_default (pspec, &priv->property_values[pspec->param_id - 1].value);
priv->property_values[pspec->param_id - 1].source = GTK_SETTINGS_SOURCE_DEFAULT;
}

View File

@@ -140,6 +140,9 @@ void gtk_settings_set_double_property (GtkSettings *settings,
gdouble v_double,
const gchar *origin);
GDK_AVAILABLE_IN_3_20
void gtk_settings_reset_property (GtkSettings *settings,
const gchar *name);
G_END_DECLS

View File

@@ -329,22 +329,21 @@ gtk_style_context_set_cascade (GtkStyleContext *context,
}
static void
gtk_style_context_init (GtkStyleContext *style_context)
gtk_style_context_init (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
priv = style_context->priv =
gtk_style_context_get_instance_private (style_context);
priv = context->priv = gtk_style_context_get_instance_private (context);
priv->screen = gdk_screen_get_default ();
priv->property_cache = g_array_new (FALSE, FALSE, sizeof (PropertyValue));
gtk_style_context_set_cascade (style_context,
gtk_style_context_set_cascade (context,
_gtk_settings_get_style_cascade (gtk_settings_get_for_screen (priv->screen), 1));
/* Create default info store */
priv->cssnode = gtk_css_path_node_new (style_context);
priv->cssnode = gtk_css_path_node_new (context);
gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
}
@@ -354,32 +353,27 @@ gtk_style_context_clear_parent (GtkStyleContext *context)
GtkStyleContextPrivate *priv = context->priv;
if (priv->parent)
{
g_object_unref (priv->parent);
}
g_object_unref (priv->parent);
}
static void
gtk_style_context_finalize (GObject *object)
{
GtkStyleContextPrivate *priv;
GtkStyleContext *style_context;
style_context = GTK_STYLE_CONTEXT (object);
priv = style_context->priv;
GtkStyleContext *context = GTK_STYLE_CONTEXT (object);
GtkStyleContextPrivate *priv = context->priv;
while (priv->saved_nodes)
gtk_style_context_pop_style_node (style_context);
gtk_style_context_pop_style_node (context);
if (GTK_IS_CSS_PATH_NODE (priv->cssnode))
gtk_css_path_node_unset_context (GTK_CSS_PATH_NODE (priv->cssnode));
gtk_style_context_clear_parent (style_context);
gtk_style_context_set_cascade (style_context, NULL);
gtk_style_context_clear_parent (context);
gtk_style_context_set_cascade (context, NULL);
g_object_unref (priv->cssnode);
gtk_style_context_clear_property_cache (style_context);
gtk_style_context_clear_property_cache (context);
g_array_free (priv->property_cache, TRUE);
G_OBJECT_CLASS (gtk_style_context_parent_class)->finalize (object);
@@ -391,29 +385,23 @@ gtk_style_context_impl_set_property (GObject *object,
const GValue *value,
GParamSpec *pspec)
{
GtkStyleContext *style_context;
style_context = GTK_STYLE_CONTEXT (object);
GtkStyleContext *context = GTK_STYLE_CONTEXT (object);
switch (prop_id)
{
case PROP_SCREEN:
gtk_style_context_set_screen (style_context,
g_value_get_object (value));
gtk_style_context_set_screen (context, g_value_get_object (value));
break;
case PROP_DIRECTION:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
gtk_style_context_set_direction (style_context,
g_value_get_enum (value));
gtk_style_context_set_direction (context, g_value_get_enum (value));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_FRAME_CLOCK:
gtk_style_context_set_frame_clock (style_context,
g_value_get_object (value));
gtk_style_context_set_frame_clock (context, g_value_get_object (value));
break;
case PROP_PARENT:
gtk_style_context_set_parent (style_context,
g_value_get_object (value));
gtk_style_context_set_parent (context, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -427,11 +415,8 @@ gtk_style_context_impl_get_property (GObject *object,
GValue *value,
GParamSpec *pspec)
{
GtkStyleContext *style_context;
GtkStyleContextPrivate *priv;
style_context = GTK_STYLE_CONTEXT (object);
priv = style_context->priv;
GtkStyleContext *context = GTK_STYLE_CONTEXT (object);
GtkStyleContextPrivate *priv = context->priv;
switch (prop_id)
{
@@ -440,7 +425,7 @@ gtk_style_context_impl_get_property (GObject *object,
break;
case PROP_DIRECTION:
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
g_value_set_enum (value, gtk_style_context_get_direction (style_context));
g_value_set_enum (value, gtk_style_context_get_direction (context));
G_GNUC_END_IGNORE_DEPRECATIONS;
break;
case PROP_FRAME_CLOCK:
@@ -469,9 +454,7 @@ gtk_style_context_is_saved (GtkStyleContext *context)
static GtkCssNode *
gtk_style_context_get_root (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
priv = context->priv;
GtkStyleContextPrivate *priv = context->priv;
if (priv->saved_nodes != NULL)
return g_slist_last (priv->saved_nodes)->data;
@@ -489,7 +472,7 @@ static gboolean
gtk_style_context_has_custom_cascade (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv = context->priv;
GtkSettings *settings = gtk_settings_get_for_screen (context->priv->screen);
GtkSettings *settings = gtk_settings_get_for_screen (priv->screen);
return priv->cascade != _gtk_settings_get_style_cascade (settings, _gtk_style_cascade_get_scale (priv->cascade));
}
@@ -505,9 +488,10 @@ static GtkStateFlags
gtk_style_context_push_state (GtkStyleContext *context,
GtkStateFlags state)
{
GtkStyleContextPrivate *priv = context->priv;
GtkStateFlags current_state;
current_state = gtk_css_node_get_state (context->priv->cssnode);
current_state = gtk_css_node_get_state (priv->cssnode);
if (current_state == state)
return state;
@@ -520,16 +504,16 @@ gtk_style_context_push_state (GtkStyleContext *context,
{
GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
g_warning ("State %u for %s %p doesn't match state %u set via gtk_style_context_set_state ()",
state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (context->priv->cssnode));
state, gtk_widget_get_name (widget), widget, gtk_css_node_get_state (priv->cssnode));
}
else
{
g_warning ("State %u for context %p doesn't match state %u set via gtk_style_context_set_state ()",
state, context, gtk_css_node_get_state (context->priv->cssnode));
state, context, gtk_css_node_get_state (priv->cssnode));
}
}
gtk_css_node_set_state (context->priv->cssnode, state);
gtk_css_node_set_state (priv->cssnode, state);
return current_state;
}
@@ -564,16 +548,12 @@ gtk_style_context_new (void)
GtkStyleContext *
gtk_style_context_new_for_node (GtkCssNode *node)
{
GtkStyleContextPrivate *priv;
GtkStyleContext *context;
g_return_val_if_fail (GTK_IS_CSS_NODE (node), NULL);
context = gtk_style_context_new ();
priv = context->priv;
g_object_unref (priv->cssnode);
priv->cssnode = g_object_ref (node);
g_set_object (&context->priv->cssnode, node);
return context;
}
@@ -615,7 +595,7 @@ gtk_style_context_add_provider (GtkStyleContext *context,
if (!gtk_style_context_has_custom_cascade (context))
{
GtkStyleCascade *new_cascade;
new_cascade = _gtk_style_cascade_new ();
_gtk_style_cascade_set_scale (new_cascade, _gtk_style_cascade_get_scale (priv->cascade));
_gtk_style_cascade_set_parent (new_cascade,
@@ -643,17 +623,13 @@ void
gtk_style_context_remove_provider (GtkStyleContext *context,
GtkStyleProvider *provider)
{
GtkStyleContextPrivate *priv;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (GTK_IS_STYLE_PROVIDER (provider));
priv = context->priv;
if (!gtk_style_context_has_custom_cascade (context))
return;
_gtk_style_cascade_remove_provider (priv->cascade, provider);
_gtk_style_cascade_remove_provider (context->priv->cascade, provider);
}
/**
@@ -835,7 +811,7 @@ gtk_style_context_get_property (GtkStyleContext *context,
}
saved_state = gtk_style_context_push_state (context, state);
_gtk_style_property_query (prop,
_gtk_style_property_query (prop,
value,
gtk_style_context_query_func,
gtk_css_node_get_style (context->priv->cssnode));
@@ -960,6 +936,7 @@ gtk_style_context_set_state (GtkStyleContext *context,
GtkStateFlags flags)
{
GtkStateFlags old_flags;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
old_flags = gtk_css_node_get_state (context->priv->cssnode);
@@ -1227,7 +1204,8 @@ gtk_style_context_save (GtkStyleContext *context)
priv = context->priv;
/* Make sure we have the style existing. It is the
* parent of the new saved node after all. */
* parent of the new saved node after all.
*/
if (!gtk_style_context_is_saved (context))
gtk_style_context_lookup_style (context);
@@ -1255,7 +1233,6 @@ gtk_style_context_restore (GtkStyleContext *context)
if (context->priv->saved_nodes == NULL)
{
g_warning ("Unpaired gtk_style_context_restore() call");
return;
}
@@ -1290,16 +1267,14 @@ void
gtk_style_context_add_class (GtkStyleContext *context,
const gchar *class_name)
{
GtkStyleContextPrivate *priv;
GQuark class_quark;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (class_name != NULL);
priv = context->priv;
class_quark = g_quark_from_string (class_name);
gtk_css_node_add_class (priv->cssnode, class_quark);
gtk_css_node_add_class (context->priv->cssnode, class_quark);
}
/**
@@ -1315,20 +1290,16 @@ void
gtk_style_context_remove_class (GtkStyleContext *context,
const gchar *class_name)
{
GtkStyleContextPrivate *priv;
GQuark class_quark;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (class_name != NULL);
class_quark = g_quark_try_string (class_name);
if (!class_quark)
return;
priv = context->priv;
gtk_css_node_remove_class (priv->cssnode, class_quark);
gtk_css_node_remove_class (context->priv->cssnode, class_quark);
}
/**
@@ -1347,31 +1318,16 @@ gboolean
gtk_style_context_has_class (GtkStyleContext *context,
const gchar *class_name)
{
GtkStyleContextPrivate *priv;
GQuark class_quark;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
g_return_val_if_fail (class_name != NULL, FALSE);
class_quark = g_quark_try_string (class_name);
if (!class_quark)
return FALSE;
priv = context->priv;
return gtk_css_node_has_class (priv->cssnode, class_quark);
}
static void
quarks_to_strings (GList *list)
{
GList *l;
for (l = list; l; l = l->next)
{
l->data = (char *) g_quark_to_string (GPOINTER_TO_UINT (l->data));
}
return gtk_css_node_has_class (context->priv->cssnode, class_quark);
}
/**
@@ -1390,23 +1346,15 @@ quarks_to_strings (GList *list)
GList *
gtk_style_context_list_classes (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
GList *classes_list = NULL;
const GQuark *classes;
guint n_classes, i;
const gchar *quark_str;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
priv = context->priv;
classes = gtk_css_node_list_classes (priv->cssnode, &n_classes);
for (i = n_classes; i-- > n_classes;)
{
quark_str = g_quark_to_string (classes[i]);
classes_list = g_list_prepend (classes_list, (gchar *) quark_str);
}
classes = gtk_css_node_list_classes (context->priv->cssnode, &n_classes);
for (i = n_classes; i > 0; i--)
classes_list = g_list_prepend (classes_list, (gchar *)g_quark_to_string (classes[i - 1]));
return classes_list;
}
@@ -1429,15 +1377,13 @@ gtk_style_context_list_classes (GtkStyleContext *context)
GList *
gtk_style_context_list_regions (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
GList *regions;
GList *regions, *l;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
priv = context->priv;
regions = gtk_css_node_list_regions (priv->cssnode);
quarks_to_strings (regions);
regions = gtk_css_node_list_regions (context->priv->cssnode);
for (l = regions; l; l = l->next)
l->data = (char *) g_quark_to_string (GPOINTER_TO_UINT (l->data));
return regions;
}
@@ -1500,17 +1446,15 @@ gtk_style_context_add_region (GtkStyleContext *context,
const gchar *region_name,
GtkRegionFlags flags)
{
GtkStyleContextPrivate *priv;
GQuark region_quark;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (region_name != NULL);
g_return_if_fail (_gtk_style_context_check_region_name (region_name));
priv = context->priv;
region_quark = g_quark_from_string (region_name);
gtk_css_node_add_region (priv->cssnode, region_quark, flags);
gtk_css_node_add_region (context->priv->cssnode, region_quark, flags);
}
/**
@@ -1528,20 +1472,16 @@ void
gtk_style_context_remove_region (GtkStyleContext *context,
const gchar *region_name)
{
GtkStyleContextPrivate *priv;
GQuark region_quark;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (region_name != NULL);
region_quark = g_quark_try_string (region_name);
if (!region_quark)
return;
priv = context->priv;
gtk_css_node_remove_region (priv->cssnode, region_quark);
gtk_css_node_remove_region (context->priv->cssnode, region_quark);
}
/**
@@ -1565,7 +1505,6 @@ gtk_style_context_has_region (GtkStyleContext *context,
const gchar *region_name,
GtkRegionFlags *flags_return)
{
GtkStyleContextPrivate *priv;
GQuark region_quark;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), FALSE);
@@ -1575,13 +1514,10 @@ gtk_style_context_has_region (GtkStyleContext *context,
*flags_return = 0;
region_quark = g_quark_try_string (region_name);
if (!region_quark)
return FALSE;
priv = context->priv;
return gtk_css_node_has_region (priv->cssnode, region_quark, flags_return);
return gtk_css_node_has_region (context->priv->cssnode, region_quark, flags_return);
}
static gint
@@ -1736,7 +1672,7 @@ gtk_style_context_get_style_property (GtkStyleContext *context,
if (GTK_IS_CSS_WIDGET_NODE (root))
{
GtkWidget *widget;
widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
if (widget == NULL)
return;
@@ -1746,7 +1682,7 @@ gtk_style_context_get_style_property (GtkStyleContext *context,
else if (GTK_IS_CSS_PATH_NODE (root))
{
GtkWidgetPath *path;
path = gtk_css_path_node_get_widget_path (GTK_CSS_PATH_NODE (root));
if (path == NULL)
return;
@@ -1818,7 +1754,7 @@ gtk_style_context_get_style_valist (GtkStyleContext *context,
if (GTK_IS_CSS_WIDGET_NODE (root))
{
GtkWidget *widget;
widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (root));
if (widget == NULL)
return;
@@ -1828,7 +1764,7 @@ gtk_style_context_get_style_valist (GtkStyleContext *context,
else if (GTK_IS_CSS_PATH_NODE (root))
{
GtkWidgetPath *path;
path = gtk_css_path_node_get_widget_path (GTK_CSS_PATH_NODE (root));
if (path == NULL)
return;
@@ -1902,8 +1838,6 @@ gtk_style_context_get_style (GtkStyleContext *context,
{
va_list args;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
va_start (args, context);
gtk_style_context_get_style_valist (context, args);
va_end (args);
@@ -1999,12 +1933,9 @@ gtk_style_context_set_screen (GtkStyleContext *context,
GdkScreen *
gtk_style_context_get_screen (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
priv = context->priv;
return priv->screen;
return context->priv->screen;
}
/**
@@ -2047,12 +1978,9 @@ gtk_style_context_set_frame_clock (GtkStyleContext *context,
GdkFrameClock *
gtk_style_context_get_frame_clock (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL);
priv = context->priv;
return priv->frame_clock;
return context->priv->frame_clock;
}
/**
@@ -2483,7 +2411,7 @@ gtk_style_context_set_background (GtkStyleContext *context,
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
g_return_if_fail (GDK_IS_WINDOW (window));
/* This is a sophisitcated optimization.
/* This is a sophisticated 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.

View File

@@ -52,6 +52,8 @@
#include "a11y/gtkswitchaccessible.h"
#include "gtkactionhelper.h"
#include "gtkwidgetprivate.h"
#include "gtkcssshadowsvalueprivate.h"
#include "gtkstylecontextprivate.h"
#include "fallback-c89.c"
@@ -447,6 +449,9 @@ gtk_switch_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GtkSwitchPrivate *priv = GTK_SWITCH (widget)->priv;
GtkStyleContext *context;
GtkBorder extents;
GtkAllocation clip;
gtk_widget_set_allocation (widget, allocation);
@@ -457,7 +462,26 @@ gtk_switch_size_allocate (GtkWidget *widget,
allocation->width,
allocation->height);
_gtk_widget_set_simple_clip (widget, NULL);
context = gtk_widget_get_style_context (widget);
gtk_style_context_save (context);
gtk_style_context_remove_class (context, GTK_STYLE_CLASS_TROUGH);
gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER);
_gtk_css_shadows_value_get_extents (_gtk_style_context_peek_property (context,
GTK_CSS_PROPERTY_BOX_SHADOW),
&extents);
gtk_style_context_restore (context);
clip = *allocation;
clip.x -= extents.left;
clip.y -= extents.top;
clip.width += extents.left + extents.right;
clip.height += extents.top + extents.bottom;
_gtk_widget_set_simple_clip (widget, &clip);
}
static void

View File

@@ -1822,20 +1822,12 @@ gtk_text_tag_set_property (GObject *object,
break;
}
/* FIXME I would like to do this after all set_property in a single
* g_object_set () have been called. But an idle function won't
* work; we need to emit when the tag is changed, not when we get
* around to the event loop. So blah, we eat some inefficiency.
/* The signal is emitted for each set_property(). A possible optimization is
* to send the signal only once when several properties are set at the same
* time with e.g. g_object_set(). The signal could be emitted when the notify
* signal is thawed.
*/
/* This is also somewhat weird since we emit another object's
* signal here, but the two objects are already tightly bound.
*/
if (priv->table)
g_signal_emit_by_name (priv->table,
"tag_changed",
text_tag, size_changed);
gtk_text_tag_changed (text_tag, size_changed);
}
static void
@@ -2294,6 +2286,40 @@ gtk_text_tag_event (GtkTextTag *tag,
return retval;
}
/**
* gtk_text_tag_changed:
* @tag: a #GtkTextTag.
* @size_changed: whether the change affects the #GtkTextView layout.
*
* Emits the #GtkTextTagTable::tag-changed signal on the #GtkTextTagTable where
* the tag is included.
*
* The signal is already emitted when setting a #GtkTextTag property. This
* function is useful for a #GtkTextTag subclass.
*
* Since: 3.20
*/
void
gtk_text_tag_changed (GtkTextTag *tag,
gboolean size_changed)
{
GtkTextTagPrivate *priv;
g_return_if_fail (GTK_IS_TEXT_TAG (tag));
priv = tag->priv;
/* This is somewhat weird since we emit another object's signal here, but the
* two objects are already tightly bound. If a GtkTextTag::changed signal is
* added, this would increase significantly the number of signal connections.
*/
if (priv->table != NULL)
g_signal_emit_by_name (priv->table,
"tag-changed",
tag,
size_changed);
}
static int
tag_sort_func (gconstpointer first, gconstpointer second)
{

View File

@@ -112,7 +112,9 @@ gboolean gtk_text_tag_event (GtkTextTag *tag,
GObject *event_object,
GdkEvent *event,
const GtkTextIter *iter);
GDK_AVAILABLE_IN_3_20
void gtk_text_tag_changed (GtkTextTag *tag,
gboolean size_changed);
G_END_DECLS

View File

@@ -103,7 +103,7 @@ gtk_text_tag_table_class_init (GtkTextTagTableClass *klass)
* GtkTextTagTable::tag-changed:
* @texttagtable: the object which received the signal.
* @tag: the changed tag.
* @size_changed: whether the size has been changed.
* @size_changed: whether the change affects the #GtkTextView layout.
*/
signals[TAG_CHANGED] =
g_signal_new (I_("tag-changed"),

View File

@@ -1534,6 +1534,13 @@ add_settings_info (GtkInspectorPropEditor *editor)
gtk_container_add (GTK_CONTAINER (editor), row);
}
static void
reset_setting (GtkInspectorPropEditor *editor)
{
gtk_settings_reset_property (GTK_SETTINGS (editor->priv->object),
editor->priv->name);
}
static void
add_gtk_settings_info (GtkInspectorPropEditor *editor)
{
@@ -1541,6 +1548,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
const gchar *name;
GtkWidget *row;
const gchar *source;
GtkWidget *button;
object = editor->priv->object;
name = editor->priv->name;
@@ -1551,6 +1559,14 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
row = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 10);
gtk_container_add (GTK_CONTAINER (row), gtk_label_new (_("Source:")));
button = gtk_button_new_with_label (_("Reset"));
g_signal_connect_swapped (button, "clicked", G_CALLBACK (reset_setting), editor);
gtk_widget_set_halign (button, GTK_ALIGN_END);
gtk_widget_show (button);
gtk_widget_set_sensitive (button, FALSE);
gtk_box_pack_end (GTK_BOX (row), button, FALSE, FALSE, 0);
switch (_gtk_settings_get_setting_source (GTK_SETTINGS (object), name))
{
case GTK_SETTINGS_SOURCE_DEFAULT:
@@ -1563,6 +1579,7 @@ add_gtk_settings_info (GtkInspectorPropEditor *editor)
source = _("XSettings");
break;
case GTK_SETTINGS_SOURCE_APPLICATION:
gtk_widget_set_sensitive (button, TRUE);
source = _("Application");
break;
default:

View File

@@ -186,15 +186,11 @@ quartz_filter_keypress (GtkIMContext *context,
GTK_NOTE (MISC, g_print ("quartz_filter_keypress\n"));
if (!qc->client_window)
if (!GDK_IS_QUARTZ_WINDOW (qc->client_window))
return FALSE;
nsview = gdk_quartz_window_get_nsview (qc->client_window);
if (GDK_IS_WINDOW (nsview))
/* it gets GDK_WINDOW in some cases */
return gtk_im_context_filter_keypress (qc->slave, event);
else
win = (GdkWindow *)[ (GdkQuartzView *)nsview gdkWindow];
win = (GdkWindow *)[ (GdkQuartzView *)nsview gdkWindow];
GTK_NOTE (MISC, g_print ("client_window: %p, win: %p, nsview: %p\n",
qc->client_window, win, nsview));
@@ -242,11 +238,11 @@ discard_preedit (GtkIMContext *context)
if (!qc->client_window)
return;
NSView *nsview = gdk_quartz_window_get_nsview (qc->client_window);
if (!nsview)
if (!GDK_IS_QUARTZ_WINDOW (qc->client_window))
return;
if (GDK_IS_WINDOW (nsview))
NSView *nsview = gdk_quartz_window_get_nsview (qc->client_window);
if (!nsview)
return;
/* reset any partial input for this NSView */
@@ -328,11 +324,10 @@ quartz_set_cursor_location (GtkIMContext *context, GdkRectangle *area)
qc->cursor_rect->x = area->x + x;
qc->cursor_rect->y = area->y + y;
nsview = gdk_quartz_window_get_nsview (qc->client_window);
if (GDK_IS_WINDOW (nsview))
/* it returns GDK_WINDOW in some cases */
if (!GDK_IS_QUARTZ_WINDOW (qc->client_window))
return;
nsview = gdk_quartz_window_get_nsview (qc->client_window);
win = (GdkWindow *)[ (GdkQuartzView*)nsview gdkWindow];
g_object_set_data (G_OBJECT (win), GIC_CURSOR_RECT, qc->cursor_rect);
}

File diff suppressed because it is too large Load Diff

View File

@@ -366,6 +366,46 @@ test_widget_path_parent (void)
g_object_unref (context);
}
static void
test_style_classes (void)
{
GtkStyleContext *context;
GList *classes;
context = gtk_style_context_new ();
classes = gtk_style_context_list_classes (context);
g_assert_null (classes);
gtk_style_context_add_class (context, "A");
classes = gtk_style_context_list_classes (context);
g_assert (classes);
g_assert_null (classes->next);
g_assert_cmpstr (classes->data, ==, "A");
g_list_free (classes);
gtk_style_context_add_class (context, "B");
classes = gtk_style_context_list_classes (context);
g_assert (classes);
g_assert_cmpstr (classes->data, ==, "A");
g_assert (classes->next);
g_assert_cmpstr (classes->next->data, ==, "B");
g_assert_null (classes->next->next);
g_list_free (classes);
gtk_style_context_remove_class (context, "A");
classes = gtk_style_context_list_classes (context);
g_assert (classes);
g_assert_null (classes->next);
g_assert_cmpstr (classes->data, ==, "B");
g_list_free (classes);
g_object_unref (context);
}
int
main (int argc, char *argv[])
{
@@ -379,6 +419,7 @@ main (int argc, char *argv[])
g_test_add_func ("/style/invalidate-saved", test_invalidate_saved);
g_test_add_func ("/style/set-widget-path-saved", test_set_widget_path_saved);
g_test_add_func ("/style/widget-path-parent", test_widget_path_parent);
g_test_add_func ("/style/classes", test_style_classes);
return g_test_run ();
}