diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-12-17 15:25:15 +0900 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2010-12-17 15:25:15 +0900 |
commit | 71e7cd0ec407f489549ed045b7e9bfdff8c70c58 (patch) | |
tree | aab2e74e2a73dcd875eaf2c55509186ac362461c | |
parent | 735fa8b1976e3bbe045e5365d42f0d67007e5293 (diff) | |
parent | e9a77a153501dd5f1ecf1726f23afac0229eed61 (diff) | |
download | gtk+-71e7cd0ec407f489549ed045b7e9bfdff8c70c58.tar.gz |
Merge branch 'master' into treeview-refactor
Conflicts:
tests/testtreeedit.c
92 files changed, 3111 insertions, 4199 deletions
diff --git a/demos/gtk-demo/assistant.c b/demos/gtk-demo/assistant.c index 09f48d4653..232d345c07 100644 --- a/demos/gtk-demo/assistant.c +++ b/demos/gtk-demo/assistant.c @@ -110,7 +110,7 @@ create_page1 (GtkWidget *assistant) gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), box, "Page 1"); gtk_assistant_set_page_type (GTK_ASSISTANT (assistant), box, GTK_ASSISTANT_PAGE_INTRO); - pixbuf = gtk_widget_render_icon (assistant, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (assistant, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); gtk_assistant_set_page_header_image (GTK_ASSISTANT (assistant), box, pixbuf); g_object_unref (pixbuf); } @@ -133,7 +133,7 @@ create_page2 (GtkWidget *assistant) gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), box, TRUE); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), box, "Page 2"); - pixbuf = gtk_widget_render_icon (assistant, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (assistant, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); gtk_assistant_set_page_header_image (GTK_ASSISTANT (assistant), box, pixbuf); g_object_unref (pixbuf); } @@ -152,7 +152,7 @@ create_page3 (GtkWidget *assistant) gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), label, TRUE); gtk_assistant_set_page_title (GTK_ASSISTANT (assistant), label, "Confirmation"); - pixbuf = gtk_widget_render_icon (assistant, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (assistant, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); gtk_assistant_set_page_header_image (GTK_ASSISTANT (assistant), label, pixbuf); g_object_unref (pixbuf); } diff --git a/demos/gtk-demo/clipboard.c b/demos/gtk-demo/clipboard.c index e77b88c9b2..1a321cc682 100644 --- a/demos/gtk-demo/clipboard.c +++ b/demos/gtk-demo/clipboard.c @@ -77,8 +77,8 @@ get_image_pixbuf (GtkImage *image) return g_object_ref (gtk_image_get_pixbuf (image)); case GTK_IMAGE_STOCK: gtk_image_get_stock (image, &stock_id, &size); - return gtk_widget_render_icon (GTK_WIDGET (image), - stock_id, size, NULL); + return gtk_widget_render_icon_pixbuf (GTK_WIDGET (image), + stock_id, size); default: g_warning ("Image storage type %d not handled", gtk_image_get_storage_type (image)); @@ -125,7 +125,7 @@ drag_data_received (GtkWidget *widget, { GdkPixbuf *pixbuf; - if (selection_data->length > 0) + if (gtk_selection_data_get_length (selection_data) > 0) { pixbuf = gtk_selection_data_get_pixbuf (selection_data); gtk_image_set_from_pixbuf (GTK_IMAGE (data), pixbuf); diff --git a/demos/gtk-demo/combobox.c b/demos/gtk-demo/combobox.c index fbe6c12eeb..e9bf96ba22 100644 --- a/demos/gtk-demo/combobox.c +++ b/demos/gtk-demo/combobox.c @@ -65,8 +65,8 @@ create_stock_icon_store (void) { if (stock_id[i]) { - pixbuf = gtk_widget_render_icon (cellview, stock_id[i], - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, stock_id[i], + GTK_ICON_SIZE_BUTTON); gtk_stock_lookup (stock_id[i], &item); label = strip_underscore (item.label); gtk_list_store_append (store, &iter); diff --git a/demos/gtk-demo/stock_browser.c b/demos/gtk-demo/stock_browser.c index e6fed81dd4..d0d3442034 100644 --- a/demos/gtk-demo/stock_browser.c +++ b/demos/gtk-demo/stock_browser.c @@ -166,9 +166,9 @@ create_model (void) } g_free (sizes); - info.small_icon = gtk_widget_render_icon (window, info.id, - size, - NULL); + info.small_icon = gtk_widget_render_icon_pixbuf (window, + info.id, + size); if (size != GTK_ICON_SIZE_MENU) { diff --git a/demos/gtk-demo/toolpalette.c b/demos/gtk-demo/toolpalette.c index 2431d6a4fe..73ab5c1878 100644 --- a/demos/gtk-demo/toolpalette.c +++ b/demos/gtk-demo/toolpalette.c @@ -41,7 +41,7 @@ canvas_item_new (GtkWidget *widget, GdkPixbuf *pixbuf; stock_id = gtk_tool_button_get_stock_id (button); - pixbuf = gtk_widget_render_icon (widget, stock_id, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (widget, stock_id, GTK_ICON_SIZE_DIALOG); if (pixbuf) { diff --git a/docs/reference/gdk/Makefile.am b/docs/reference/gdk/Makefile.am index 3015baa9fa..0f7dab671c 100644 --- a/docs/reference/gdk/Makefile.am +++ b/docs/reference/gdk/Makefile.am @@ -45,8 +45,7 @@ INCLUDES = \ $(GTK_DEBUG_FLAGS) \ $(GDK_DEP_CFLAGS) -GTKDOC_LIBS = $(top_builddir)/gdk/$(gdktargetlib) - +GTKDOC_LIBS = $(top_builddir)/gdk/$(gdktargetlib) $(GDK_DEP_LIBS) # Extra options to supply to gtkdoc-mkdb MKDB_OPTIONS=--sgml-mode --output-format=xml --name-space=gdk diff --git a/docs/reference/gdk/gdk-docs.sgml b/docs/reference/gdk/gdk-docs.sgml index c77b8be902..ed18e2fbbd 100644 --- a/docs/reference/gdk/gdk-docs.sgml +++ b/docs/reference/gdk/gdk-docs.sgml @@ -22,6 +22,7 @@ <xi:include href="xml/gdkdisplaymanager.xml" /> <xi:include href="xml/gdkscreen.xml" /> <xi:include href="xml/regions.xml" /> + <xi:include href="xml/pixbufs.xml" /> <xi:include href="xml/colors.xml" /> <xi:include href="xml/rgba_colors.xml" /> <xi:include href="xml/visuals.xml" /> diff --git a/docs/reference/gdk/gdk3-sections.txt b/docs/reference/gdk/gdk3-sections.txt index f4b7e32999..a70c8bb276 100644 --- a/docs/reference/gdk/gdk3-sections.txt +++ b/docs/reference/gdk/gdk3-sections.txt @@ -478,6 +478,8 @@ gdk_window_get_device_cursor gdk_window_set_device_cursor gdk_window_get_device_events gdk_window_set_device_events +gdk_window_get_source_events +gdk_window_set_source_events <SUBSECTION> GdkPointerHooks @@ -701,7 +703,7 @@ GdkDeviceKey GdkDeviceAxis GdkAxisUse GdkGrabOwnership -gdk_enable_multidevice +gdk_disable_multidevice gdk_device_manager_get_display gdk_device_manager_list_devices gdk_device_manager_get_client_pointer diff --git a/docs/reference/gtk/Makefile.am b/docs/reference/gtk/Makefile.am index 94231fed3e..85bec08a32 100644 --- a/docs/reference/gtk/Makefile.am +++ b/docs/reference/gtk/Makefile.am @@ -108,7 +108,8 @@ CPPFLAGS += \ GTKDOC_LIBS = \ $(top_builddir)/gdk/$(gdktargetlib) \ - $(top_builddir)/gtk/$(gtktargetlib) + $(top_builddir)/gtk/$(gtktargetlib) \ + $(GTK_DEP_LIBS) # Extra options to supply to gtkdoc-mkdb diff --git a/docs/reference/gtk/gtk3-sections.txt b/docs/reference/gtk/gtk3-sections.txt index 5702bdb406..6fefb960ad 100644 --- a/docs/reference/gtk/gtk3-sections.txt +++ b/docs/reference/gtk/gtk3-sections.txt @@ -4987,7 +4987,6 @@ gtk_widget_pop_composite_child gtk_widget_push_composite_child gtk_widget_queue_draw_area gtk_widget_queue_draw_region -gtk_widget_reset_shapes gtk_widget_set_app_paintable gtk_widget_set_double_buffered gtk_widget_set_redraw_on_allocate @@ -5534,6 +5533,7 @@ gtk_style_context_get_border_color gtk_style_context_get_border gtk_style_context_get_padding gtk_style_context_get_margin +gtk_style_context_get_font gtk_style_context_invalidate gtk_style_context_state_is_running gtk_style_context_lookup_color @@ -5644,6 +5644,7 @@ gtk_theming_engine_get_border_color gtk_theming_engine_get_border gtk_theming_engine_get_padding gtk_theming_engine_get_margin +gtk_theming_engine_get_font gtk_theming_engine_has_class gtk_theming_engine_has_region gtk_theming_engine_lookup_color diff --git a/docs/reference/gtk/tmpl/gtkdrawingarea.sgml b/docs/reference/gtk/tmpl/gtkdrawingarea.sgml index 2ec329cc83..ae46d2bc54 100644 --- a/docs/reference/gtk/tmpl/gtkdrawingarea.sgml +++ b/docs/reference/gtk/tmpl/gtkdrawingarea.sgml @@ -35,8 +35,8 @@ the application may want to connect to: </listitem> <listitem> <para> - The "expose_event" signal to handle redrawing the - contents of the widget. + The "draw" signal to handle redrawing the contents of the + widget. </para> </listitem> </itemizedlist> @@ -53,40 +53,47 @@ that drawing is implicitly clipped to the exposed area. <title>Simple <structname>GtkDrawingArea</structname> usage.</title> <programlisting> gboolean -expose_event_callback (GtkWidget *widget, GdkEventExpose *event, gpointer data) +draw_callback (GtkWidget *widget, cairo_t *cr, gpointer data) { - cairo_t *cr; - - cr = gdk_cairo_create (event->window); + guint width, height; + GdkRGBA color; - cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); - cairo_paint (cr); + width = gtk_widget_get_allocated_width (widget); + height = gtk_widget_get_allocated_height (widget); + cairo_arc (cr, + width / 2.0, height / 2.0, + MIN (width, height) / 2.0, + 0, 2 * G_PI); - cairo_destroy (cr); - - return TRUE; + gtk_style_context_get_color (gtk_widget_get_style_context (widget), + 0, + &color); + gdk_cairo_set_source_rgba (cr, &color); + + cairo_fill (cr); + + return FALSE; } [...] GtkWidget *drawing_area = gtk_drawing_area_new (<!-- -->); gtk_widget_set_size_request (drawing_area, 100, 100); - g_signal_connect (G_OBJECT (drawing_area), "expose_event", - G_CALLBACK (expose_event_callback), NULL); + g_signal_connect (G_OBJECT (drawing_area), "draw", + G_CALLBACK (draw_callback), NULL); </programlisting> </example> <para> -Expose events are normally delivered when a drawing area first comes -onscreen, or when it's covered by another window and then uncovered -(exposed). You can also force an expose event by adding to the "damage -region" of the drawing area's window; gtk_widget_queue_draw_area() and -gdk_window_invalidate_rect() are equally good ways to do this. You'll -then get an expose event for the invalid region. +Draw signals are normally delivered when a drawing area first comes +onscreen, or when it's covered by another window and then uncovered. +You can also force a redraw by adding to the "damage region" of the +drawing area's window; use gtk_widget_queue_draw_area() to do this. +You'll then get a draw event for the invalid region. </para> <para> The available routines for drawing are documented on the <link -linkend="gdk-Drawing-Primitives">GDK Drawing Primitives</link> page. -See also gdk_draw_pixbuf() for drawing a #GdkPixbuf. +linkend="gdk3-Cairo-Interaction">GDK Drawing Primitives</link> page +and the cairo documentation. </para> <para> diff --git a/gdk/Makefile.am b/gdk/Makefile.am index 987379bc9c..c56c721cd6 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -98,8 +98,7 @@ gdk_built_public_sources = \ gdk_private_headers = \ gdkinternals.h \ gdkdeviceprivate.h \ - gdkintl.h \ - gdkpoly-generic.h + gdkintl.h gdk_c_sources = \ gdk.c \ @@ -1063,24 +1063,24 @@ gdk_set_program_class (const char *program_class) } /** - * gdk_enable_multidevice: + * gdk_disable_multidevice: * - * Enables multidevice support in GDK. This call must happen prior + * Disables multidevice support in GDK. This call must happen prior * to gdk_display_open(), gtk_init(), gtk_init_with_args() or * gtk_init_check() in order to take effect. * - * Note that individual #GdkWindow<!-- -->s still need to explicitly - * enable multidevice awareness through gdk_window_set_support_multidevice(). - * - * This function must be called before initializing GDK. + * Most common GTK+ applications won't ever need to call this. Only + * applications that do mixed GDK/Xlib calls could want to disable + * multidevice support if such Xlib code deals with input devices in + * any way and doesn't observe the presence of XInput 2. * * Since: 3.0 **/ void -gdk_enable_multidevice (void) +gdk_disable_multidevice (void) { if (gdk_initialized) return; - _gdk_enable_multidevice = TRUE; + _gdk_disable_multidevice = TRUE; } diff --git a/gdk/gdk.symbols b/gdk/gdk.symbols index 4479b6fa8a..8d5cba8333 100644 --- a/gdk/gdk.symbols +++ b/gdk/gdk.symbols @@ -80,6 +80,7 @@ gdk_device_set_source gdk_devices_list gdk_device_type_get_type G_GNUC_CONST gdk_device_ungrab +gdk_disable_multidevice gdk_display_add_client_message_filter gdk_display_beep gdk_display_close @@ -135,7 +136,9 @@ gdk_drag_abort gdk_drag_action_get_type G_GNUC_CONST gdk_drag_begin gdk_drag_context_get_actions +gdk_drag_context_get_dest_window gdk_drag_context_get_device +gdk_drag_context_get_protocol gdk_drag_context_get_selected_action gdk_drag_context_get_source_window gdk_drag_context_get_suggested_action @@ -155,7 +158,6 @@ gdk_drag_protocol_get_type G_GNUC_CONST gdk_drag_status gdk_drop_finish gdk_drop_reply -gdk_enable_multidevice gdk_error_trap_pop gdk_error_trap_pop_ignored gdk_error_trap_push @@ -434,6 +436,7 @@ gdk_window_get_position gdk_window_get_root_coords gdk_window_get_root_origin gdk_window_get_screen +gdk_window_get_source_events gdk_window_get_state gdk_window_get_support_multidevice gdk_window_get_toplevel @@ -507,6 +510,7 @@ gdk_window_set_override_redirect gdk_window_set_role gdk_window_set_skip_pager_hint gdk_window_set_skip_taskbar_hint +gdk_window_set_source_events gdk_window_set_startup_id gdk_window_set_static_gravities gdk_window_set_support_multidevice diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c index 4e9b3d24e8..57a1a83368 100644 --- a/gdk/gdkdevice.c +++ b/gdk/gdkdevice.c @@ -59,11 +59,25 @@ struct _GdkDevicePrivate GdkDeviceKey *keys; GdkDeviceManager *device_manager; GdkDisplay *display; + + /* Paired master for master, + * associated master for slaves + */ GdkDevice *associated; + + GList *slaves; GdkDeviceType type; GArray *axes; }; +enum { + CHANGED, + LAST_SIGNAL +}; + +static guint signals [LAST_SIGNAL] = { 0 }; + + static void gdk_device_dispose (GObject *object); static void gdk_device_set_property (GObject *object, guint prop_id, @@ -238,6 +252,26 @@ gdk_device_class_init (GdkDeviceClass *klass) 0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * GdkDevice::changed: + * @device: the #GdkDevice that changed. + * + * The ::changed signal is emitted either when the #GdkDevice + * has changed the number of either axes or keys. For example + * In X this will normally happen when the slave device routing + * events through the master device changes (for example, user + * switches from the USB mouse to a tablet), in that case the + * master device will change to reflect the new slave device + * axes and keys. + */ + signals[CHANGED] = + g_signal_new (g_intern_static_string ("changed"), + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + 0, NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + g_type_class_add_private (object_class, sizeof (GdkDevicePrivate)); } @@ -262,6 +296,9 @@ gdk_device_dispose (GObject *object) device = GDK_DEVICE (object); priv = device->priv; + if (priv->type == GDK_DEVICE_TYPE_SLAVE) + _gdk_device_remove_slave (priv->associated, device); + if (priv->associated) { _gdk_device_set_associated_device (priv->associated, NULL); @@ -792,6 +829,22 @@ gdk_device_get_associated_device (GdkDevice *device) return priv->associated; } +static void +_gdk_device_set_device_type (GdkDevice *device, + GdkDeviceType type) +{ + GdkDevicePrivate *priv; + + priv = device->priv; + + if (priv->type != type) + { + priv->type = type; + + g_object_notify (G_OBJECT (device), "type"); + } +} + void _gdk_device_set_associated_device (GdkDevice *device, GdkDevice *associated) @@ -814,6 +867,73 @@ _gdk_device_set_associated_device (GdkDevice *device, if (associated) priv->associated = g_object_ref (associated); + + if (priv->type != GDK_DEVICE_TYPE_MASTER) + { + if (priv->associated) + _gdk_device_set_device_type (device, GDK_DEVICE_TYPE_SLAVE); + else + _gdk_device_set_device_type (device, GDK_DEVICE_TYPE_FLOATING); + } +} + +/** + * gdk_device_list_slave_devices: + * @device: a #GdkDevice + * + * If the device if of type %GDK_DEVICE_TYPE_MASTER, it will return + * the list of slave devices attached to it, otherwise it will return + * %NULL + * + * Returns: (transfer container): the list of slave devices, or %NULL. The + * list must be freed with g_list_free(), the contents of the list + * are owned by GTK+ and should not be freed. + **/ +GList * +gdk_device_list_slave_devices (GdkDevice *device) +{ + GdkDevicePrivate *priv; + + g_return_val_if_fail (GDK_IS_DEVICE (device), NULL); + g_return_val_if_fail (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_MASTER, NULL); + + priv = device->priv; + + return g_list_copy (priv->slaves); +} + +void +_gdk_device_add_slave (GdkDevice *device, + GdkDevice *slave) +{ + GdkDevicePrivate *priv; + + g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER); + g_return_if_fail (gdk_device_get_device_type (slave) != GDK_DEVICE_TYPE_MASTER); + + priv = device->priv; + + if (!g_list_find (priv->slaves, slave)) + priv->slaves = g_list_prepend (priv->slaves, slave); +} + +void +_gdk_device_remove_slave (GdkDevice *device, + GdkDevice *slave) +{ + GdkDevicePrivate *priv; + GList *elem; + + g_return_if_fail (gdk_device_get_device_type (device) == GDK_DEVICE_TYPE_MASTER); + g_return_if_fail (gdk_device_get_device_type (slave) != GDK_DEVICE_TYPE_MASTER); + + priv = device->priv; + elem = g_list_find (priv->slaves, slave); + + if (!elem) + return; + + priv->slaves = g_list_delete_link (priv->slaves, elem); } /** diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h index 27375f7621..2c797a9fc8 100644 --- a/gdk/gdkdevice.h +++ b/gdk/gdkdevice.h @@ -222,6 +222,7 @@ gboolean gdk_device_get_axis (GdkDevice *device, GdkDisplay * gdk_device_get_display (GdkDevice *device); GdkDevice * gdk_device_get_associated_device (GdkDevice *device); +GList * gdk_device_list_slave_devices (GdkDevice *device); GdkDeviceType gdk_device_get_device_type (GdkDevice *device); diff --git a/gdk/gdkdevicemanager.c b/gdk/gdkdevicemanager.c index 56499bcb64..5ef51b7724 100644 --- a/gdk/gdkdevicemanager.c +++ b/gdk/gdkdevicemanager.c @@ -36,12 +36,13 @@ * additional features such as sub-pixel positioning information and additional * device-dependent information. * @Title: GdkDeviceManager - * @See_also: #GdkDevice, #GdkEvent, gdk_enable_multidevice() + * @See_also: #GdkDevice, #GdkEvent, gdk_disable_multidevice() * - * By default, GDK supports the traditional single keyboard/pointer input scheme (Plus additional - * special input devices such as tablets. In short, backwards compatible with 2.X). Since version 3.0, - * if gdk_enable_multidevice() is called before gdk_display_open() and the platform supports it, GDK - * will be aware of multiple keyboard/pointer pairs interacting simultaneously with the user interface. + * By default, and if the platform supports it, GDK is aware of multiple keyboard/pointer pairs + * and multitouch devices, this behavior can be changed by calling gdk_disable_multidevice() + * before gdk_display_open(), although there would be rarely a reason to do that. For a widget + * or window to be dealt as multipointer aware, gdk_window_set_support_multidevice() or + * gtk_widget_set_support_multidevice() must have been called on it. * * Conceptually, in multidevice mode there are 2 device types, virtual devices (or master devices) * are represented by the pointer cursors and keyboard foci that are seen on the screen. physical @@ -84,8 +85,8 @@ * * In order to query the device hierarchy and be aware of changes in the device hierarchy (such as * virtual devices being created or removed, or physical devices being plugged or unplugged), GDK - * provides #GdkDeviceManager. On X11, multidevice support is implemented through XInput 2. If - * gdk_enable_multidevice() is called, the XInput 2.x #GdkDeviceManager implementation will be used + * provides #GdkDeviceManager. On X11, multidevice support is implemented through XInput 2. Unless + * gdk_disable_multidevice() is called, the XInput 2.x #GdkDeviceManager implementation will be used * as input source, else either the core or XInput 1.x implementations will be used. */ @@ -182,12 +183,16 @@ gdk_device_manager_class_init (GdkDeviceManagerClass *klass) * @device_manager: the object on which the signal is emitted * @device: the #GdkDevice that changed. * - * The ::device-changed signal is emitted either when some - * #GdkDevice has changed the number of either axes or keys. - * For example In X this will normally happen when the slave - * device routing events through the master device changes, - * in that case the master device will change to reflect the - * new slave device axes and keys. + * The ::device-changed signal is emitted whenever a device + * has changed in the hierarchy, either slave devices being + * disconnected from their master device or connected to + * another one, or master devices being added or removed + * a slave device. + * + * If a slave device is detached from all master devices + * (gdk_device_get_associated_device() returns %NULL), its + * #GdkDeviceType will change to %GDK_DEVICE_TYPE_FLOATING, + * if it's attached, it will change to %GDK_DEVICE_TYPE_SLAVE. */ signals [DEVICE_CHANGED] = g_signal_new (g_intern_static_string ("device-changed"), diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h index d878ae634d..f7318620d8 100644 --- a/gdk/gdkdeviceprivate.h +++ b/gdk/gdkdeviceprivate.h @@ -125,6 +125,10 @@ GdkTimeCoord ** _gdk_device_allocate_history (GdkDevice *device, void _gdk_input_check_extension_events (GdkDevice *device); +void _gdk_device_add_slave (GdkDevice *device, + GdkDevice *slave); +void _gdk_device_remove_slave (GdkDevice *device, + GdkDevice *slave); G_END_DECLS diff --git a/gdk/gdkdisplay.c b/gdk/gdkdisplay.c index 5ef630d7bb..9a083e18b7 100644 --- a/gdk/gdkdisplay.c +++ b/gdk/gdkdisplay.c @@ -1302,6 +1302,7 @@ _gdk_display_add_device_grab (GdkDisplay *display, static void synthesize_crossing_events (GdkDisplay *display, GdkDevice *device, + GdkDevice *source_device, GdkWindow *src_window, GdkWindow *dest_window, GdkCrossingMode crossing_mode, @@ -1337,7 +1338,7 @@ synthesize_crossing_events (GdkDisplay *display, _gdk_synthesize_crossing_events (display, src_window, dest_window, - device, + device, source_device, crossing_mode, x, y, state, time, @@ -1351,7 +1352,7 @@ synthesize_crossing_events (GdkDisplay *display, _gdk_synthesize_crossing_events (display, src_window, NULL, - device, + device, source_device, crossing_mode, x, y, state, time, @@ -1366,7 +1367,7 @@ synthesize_crossing_events (GdkDisplay *display, _gdk_synthesize_crossing_events (display, src_window, NULL, - device, + device, source_device, crossing_mode, x, y, state, time, @@ -1377,7 +1378,7 @@ synthesize_crossing_events (GdkDisplay *display, _gdk_synthesize_crossing_events (display, NULL, dest_window, - device, + device, source_device, crossing_mode, x, y, state, time, @@ -1414,6 +1415,7 @@ get_current_toplevel (GdkDisplay *display, static void switch_to_pointer_grab (GdkDisplay *display, GdkDevice *device, + GdkDevice *source_device, GdkDeviceGrabInfo *grab, GdkDeviceGrabInfo *last_grab, guint32 time, @@ -1449,7 +1451,7 @@ switch_to_pointer_grab (GdkDisplay *display, src_window = info->window_under_pointer; if (src_window != grab->window) - synthesize_crossing_events (display, device, + synthesize_crossing_events (display, device, source_device, src_window, grab->window, GDK_CROSSING_GRAB, time, serial); @@ -1500,7 +1502,7 @@ switch_to_pointer_grab (GdkDisplay *display, } if (pointer_window != last_grab->window) - synthesize_crossing_events (display, device, + synthesize_crossing_events (display, device, source_device, last_grab->window, pointer_window, GDK_CROSSING_UNGRAB, time, serial); @@ -1515,6 +1517,7 @@ switch_to_pointer_grab (GdkDisplay *display, void _gdk_display_device_grab_update (GdkDisplay *display, GdkDevice *device, + GdkDevice *source_device, gulong current_serial) { GdkDeviceGrabInfo *current_grab, *next_grab; @@ -1539,7 +1542,7 @@ _gdk_display_device_grab_update (GdkDisplay *display, if (!current_grab->activated) { if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD) - switch_to_pointer_grab (display, device, current_grab, NULL, time, current_serial); + switch_to_pointer_grab (display, device, source_device, current_grab, NULL, time, current_serial); } break; @@ -1567,7 +1570,7 @@ _gdk_display_device_grab_update (GdkDisplay *display, g_hash_table_insert (display->device_grabs, device, grabs); if (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD) - switch_to_pointer_grab (display, device, + switch_to_pointer_grab (display, device, source_device, next_grab, current_grab, time, current_serial); diff --git a/gdk/gdkdnd.c b/gdk/gdkdnd.c index cccae0968a..22967adc10 100644 --- a/gdk/gdkdnd.c +++ b/gdk/gdkdnd.c @@ -185,3 +185,40 @@ gdk_drag_context_get_source_window (GdkDragContext *context) return context->source_window; } + +/** + * gdk_drag_context_get_dest_window: + * @context: a #GdkDragContext + * + * Returns the destination windw for the DND operation. + * + * Return value: (transfer none): a #GdkWindow + * + * Since: 3.0 + **/ +GdkWindow * +gdk_drag_context_get_dest_window (GdkDragContext *context) +{ + g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); + + return context->dest_window; +} + +/** + * gdk_drag_context_get_protocol: + * @context: a #GdkDragContext + * + * Returns the drag protocol thats used by this context. + * + * Returns: the drag protocol + * + * Since: 3.0 + */ +GdkDragProtocol +gdk_drag_context_get_protocol (GdkDragContext *context) +{ + g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_DRAG_PROTO_NONE); + + return context->protocol; +} + diff --git a/gdk/gdkdnd.h b/gdk/gdkdnd.h index b257d1e8f0..e383c957e2 100644 --- a/gdk/gdkdnd.h +++ b/gdk/gdkdnd.h @@ -146,6 +146,8 @@ GdkDragAction gdk_drag_context_get_suggested_action (GdkDragContext *context) GdkDragAction gdk_drag_context_get_selected_action (GdkDragContext *context); GdkWindow *gdk_drag_context_get_source_window (GdkDragContext *context); +GdkWindow *gdk_drag_context_get_dest_window (GdkDragContext *context); +GdkDragProtocol gdk_drag_context_get_protocol (GdkDragContext *context); /* Destination side */ diff --git a/gdk/gdkevents.c b/gdk/gdkevents.c index 438beb8a1f..d6322db795 100644 --- a/gdk/gdkevents.c +++ b/gdk/gdkevents.c @@ -1077,6 +1077,66 @@ gdk_event_get_device (const GdkEvent *event) } /** + * gdk_event_set_source_device: + * @event: a #GdkEvent + * @device: a #GdkDevice + * + * Sets the slave device for @event to @device. The event + * must have been allocated by GTK+, for instance, by + * gdk_event_copy(). + * + * Since: 3.0 + **/ +void +gdk_event_set_source_device (GdkEvent *event, + GdkDevice *device) +{ + GdkEventPrivate *private; + + g_return_if_fail (gdk_event_is_allocated (event)); + g_return_if_fail (GDK_IS_DEVICE (device)); + + private = (GdkEventPrivate *) event; + + private->source_device = device; +} + +/** + * gdk_event_get_source_device: + * @event: a #GdkEvent + * + * This function returns the hardware (slave) #GdkDevice that has triggered the event, + * falling back to the virtual (master) device (as in gdk_event_get_device()) if the + * event wasn't caused by interaction with a hardware device. This may happen for + * example in synthesized crossing events after a #GdkWindow updates its geometry or + * a grab is acquired/released. + * + * If the event does not contain device field, this function will return %NULL. + * + * Returns: a #GdkDevice, or %NULL. + * + * Since: 3.0 + **/ +GdkDevice * +gdk_event_get_source_device (const GdkEvent *event) +{ + GdkEventPrivate *private; + + g_return_val_if_fail (event != NULL, NULL); + + if (!gdk_event_is_allocated (event)) + return NULL; + + private = (GdkEventPrivate *) event; + + if (private->source_device) + return private->source_device; + + /* Fallback to event device */ + return gdk_event_get_device (event); +} + +/** * gdk_event_request_motions: * @event: a valid #GdkEvent * diff --git a/gdk/gdkevents.h b/gdk/gdkevents.h index fcefc6c1c8..b7e5ed37a2 100644 --- a/gdk/gdkevents.h +++ b/gdk/gdkevents.h @@ -1089,6 +1089,9 @@ gboolean gdk_event_get_axis (const GdkEvent *event, void gdk_event_set_device (GdkEvent *event, GdkDevice *device); GdkDevice* gdk_event_get_device (const GdkEvent *event); +void gdk_event_set_source_device (GdkEvent *event, + GdkDevice *device); +GdkDevice* gdk_event_get_source_device (const GdkEvent *event); void gdk_event_request_motions (const GdkEventMotion *event); gboolean gdk_events_get_distance (GdkEvent *event1, diff --git a/gdk/gdkglobals.c b/gdk/gdkglobals.c index 5413886694..2a572981dc 100644 --- a/gdk/gdkglobals.c +++ b/gdk/gdkglobals.c @@ -38,6 +38,6 @@ gchar *_gdk_display_name = NULL; gint _gdk_screen_number = -1; gchar *_gdk_display_arg_name = NULL; gboolean _gdk_native_windows = FALSE; -gboolean _gdk_enable_multidevice = FALSE; +gboolean _gdk_disable_multidevice = FALSE; GSList *_gdk_displays = NULL; diff --git a/gdk/gdkinternals.h b/gdk/gdkinternals.h index b5f5a57fa3..c98d2180c5 100644 --- a/gdk/gdkinternals.h +++ b/gdk/gdkinternals.h @@ -156,6 +156,7 @@ struct _GdkEventPrivate GdkScreen *screen; gpointer windowing_data; GdkDevice *device; + GdkDevice *source_device; }; /* Tracks information about the pointer grab on this display */ @@ -263,6 +264,10 @@ struct _GdkWindow GList *devices_inside; GHashTable *device_events; + + GHashTable *source_event_masks; + gulong device_added_handler_id; + gulong device_changed_handler_id; }; #define GDK_WINDOW_TYPE(d) (((GDK_WINDOW (d)))->window_type) @@ -272,7 +277,7 @@ extern GSList *_gdk_displays; extern gchar *_gdk_display_name; extern gint _gdk_screen_number; extern gchar *_gdk_display_arg_name; -extern gboolean _gdk_enable_multidevice; +extern gboolean _gdk_disable_multidevice; void _gdk_events_queue (GdkDisplay *display); GdkEvent* _gdk_event_unqueue (GdkDisplay *display); @@ -440,6 +445,7 @@ void _gdk_windowing_launch_failed (GAppLaunchContext *context, void _gdk_display_device_grab_update (GdkDisplay *display, GdkDevice *device, + GdkDevice *source_device, gulong current_serial); GdkDeviceGrabInfo *_gdk_display_get_last_device_grab (GdkDisplay *display, GdkDevice *device); @@ -498,6 +504,7 @@ void _gdk_synthesize_crossing_events (GdkDisplay *display, GdkWindow *src, GdkWindow *dest, GdkDevice *device, + GdkDevice *source_device, GdkCrossingMode mode, gint toplevel_x, gint toplevel_y, diff --git a/gdk/gdkmain.h b/gdk/gdkmain.h index 75ffb4e62a..2d05590e7a 100644 --- a/gdk/gdkmain.h +++ b/gdk/gdkmain.h @@ -72,7 +72,7 @@ void gdk_pre_parse_libgtk_only (void); * Returns: the resulting locale. */ gchar* gdk_set_locale (void); -void gdk_enable_multidevice (void); +void gdk_disable_multidevice (void); G_CONST_RETURN gchar *gdk_get_program_class (void); void gdk_set_program_class (const gchar *program_class); diff --git a/gdk/gdkpoly-generic.h b/gdk/gdkpoly-generic.h deleted file mode 100644 index 660c689adb..0000000000 --- a/gdk/gdkpoly-generic.h +++ /dev/null @@ -1,291 +0,0 @@ -/* $TOG: poly.h /main/5 1998/02/06 17:47:27 kaleb $ */ -/************************************************************************ - -Copyright 1987, 1998 The Open Group - -All Rights Reserved. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - - -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the name of Digital not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -************************************************************************/ - -/* - * This file contains a few macros to help track - * the edge of a filled object. The object is assumed - * to be filled in scanline order, and thus the - * algorithm used is an extension of Bresenham's line - * drawing algorithm which assumes that y is always the - * major axis. - * Since these pieces of code are the same for any filled shape, - * it is more convenient to gather the library in one - * place, but since these pieces of code are also in - * the inner loops of output primitives, procedure call - * overhead is out of the question. - * See the author for a derivation if needed. - */ - - -/* - * In scan converting polygons, we want to choose those pixels - * which are inside the polygon. Thus, we add .5 to the starting - * x coordinate for both left and right edges. Now we choose the - * first pixel which is inside the pgon for the left edge and the - * first pixel which is outside the pgon for the right edge. - * Draw the left pixel, but not the right. - * - * How to add .5 to the starting x coordinate: - * If the edge is moving to the right, then subtract dy from the - * error term from the general form of the algorithm. - * If the edge is moving to the left, then add dy to the error term. - * - * The reason for the difference between edges moving to the left - * and edges moving to the right is simple: If an edge is moving - * to the right, then we want the algorithm to flip immediately. - * If it is moving to the left, then we don't want it to flip until - * we traverse an entire pixel. - */ -#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \ - int dx; /* local storage */ \ -\ - /* \ - * if the edge is horizontal, then it is ignored \ - * and assumed not to be processed. Otherwise, do this stuff. \ - */ \ - if ((dy) != 0) { \ - xStart = (x1); \ - dx = (x2) - xStart; \ - if (dx < 0) { \ - m = dx / (dy); \ - m1 = m - 1; \ - incr1 = -2 * dx + 2 * (dy) * m1; \ - incr2 = -2 * dx + 2 * (dy) * m; \ - d = 2 * m * (dy) - 2 * dx - 2 * (dy); \ - } else { \ - m = dx / (dy); \ - m1 = m + 1; \ - incr1 = 2 * dx - 2 * (dy) * m1; \ - incr2 = 2 * dx - 2 * (dy) * m; \ - d = -2 * m * (dy) + 2 * dx; \ - } \ - } \ -} - -#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \ - if (m1 > 0) { \ - if (d > 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } else {\ - if (d >= 0) { \ - minval += m1; \ - d += incr1; \ - } \ - else { \ - minval += m; \ - d += incr2; \ - } \ - } \ -} - - -/* - * This structure contains all of the information needed - * to run the bresenham algorithm. - * The variables may be hardcoded into the declarations - * instead of using this structure to make use of - * register declarations. - */ -typedef struct { - int minor_axis; /* minor axis */ - int d; /* decision variable */ - int m, m1; /* slope and slope+1 */ - int incr1, incr2; /* error increments */ -} BRESINFO; - - -#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \ - BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \ - bres.m, bres.m1, bres.incr1, bres.incr2) - -#define BRESINCRPGONSTRUCT(bres) \ - BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2) - - - -/* - * These are the data structures needed to scan - * convert regions. Two different scan conversion - * methods are available -- the even-odd method, and - * the winding number method. - * The even-odd rule states that a point is inside - * the polygon if a ray drawn from that point in any - * direction will pass through an odd number of - * path segments. - * By the winding number rule, a point is decided - * to be inside the polygon if a ray drawn from that - * point in any direction passes through a different - * number of clockwise and counter-clockwise path - * segments. - * - * These data structures are adapted somewhat from - * the algorithm in (Foley/Van Dam) for scan converting - * polygons. - * The basic algorithm is to start at the top (smallest y) - * of the polygon, stepping down to the bottom of - * the polygon by incrementing the y coordinate. We - * keep a list of edges which the current scanline crosses, - * sorted by x. This list is called the Active Edge Table (AET) - * As we change the y-coordinate, we update each entry in - * in the active edge table to reflect the edges new xcoord. - * This list must be sorted at each scanline in case - * two edges intersect. - * We also keep a data structure known as the Edge Table (ET), - * which keeps track of all the edges which the current - * scanline has not yet reached. The ET is basically a - * list of ScanLineList structures containing a list of - * edges which are entered at a given scanline. There is one - * ScanLineList per scanline at which an edge is entered. - * When we enter a new edge, we move it from the ET to the AET. - * - * From the AET, we can implement the even-odd rule as in - * (Foley/Van Dam). - * The winding number rule is a little trickier. We also - * keep the EdgeTableEntries in the AET linked by the - * nextWETE (winding EdgeTableEntry) link. This allows - * the edges to be linked just as before for updating - * purposes, but only uses the edges linked by the nextWETE - * link as edges representing spans of the polygon to - * drawn (as with the even-odd rule). - */ - -/* - * for the winding number rule - */ -#define CLOCKWISE 1 -#define COUNTERCLOCKWISE -1 - -typedef struct _EdgeTableEntry { - int ymax; /* ycoord at which we exit this edge. */ - BRESINFO bres; /* Bresenham info to run the edge */ - struct _EdgeTableEntry *next; /* next in the list */ - struct _EdgeTableEntry *back; /* for insertion sort */ - struct _EdgeTableEntry *nextWETE; /* for winding num rule */ - int ClockWise; /* flag for winding number rule */ -} EdgeTableEntry; - - -typedef struct _ScanLineList{ - int scanline; /* the scanline represented */ - EdgeTableEntry *edgelist; /* header node */ - struct _ScanLineList *next; /* next in the list */ -} ScanLineList; - - -typedef struct { - int ymax; /* ymax for the polygon */ - int ymin; /* ymin for the polygon */ - ScanLineList scanlines; /* header node */ -} EdgeTable; - - -/* - * Here is a struct to help with storage allocation - * so we can allocate a big chunk at a time, and then take - * pieces from this heap when we need to. - */ -#define SLLSPERBLOCK 25 - -typedef struct _ScanLineListBlock { - ScanLineList SLLs[SLLSPERBLOCK]; - struct _ScanLineListBlock *next; -} ScanLineListBlock; - - - -/* - * - * a few macros for the inner loops of the fill code where - * performance considerations don't allow a procedure call. - * - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The winding number rule is in effect, so we must notify - * the caller when the edge has been removed so he - * can reorder the Winding Active Edge Table. - */ -#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - fixWAET = 1; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres); \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} - - -/* - * Evaluate the given edge at the given scanline. - * If the edge has expired, then we leave it and fix up - * the active edge table; otherwise, we increment the - * x value to be ready for the next scanline. - * The even-odd rule is in effect. - */ -#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \ - if (pAET->ymax == y) { /* leaving this edge */ \ - pPrevAET->next = pAET->next; \ - pAET = pPrevAET->next; \ - if (pAET) \ - pAET->back = pPrevAET; \ - } \ - else { \ - BRESINCRPGONSTRUCT(pAET->bres); \ - pPrevAET = pAET; \ - pAET = pAET->next; \ - } \ -} diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 7ac839640f..54f5d2f5d1 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -576,6 +576,9 @@ gdk_window_finalize (GObject *object) if (window->device_events) g_hash_table_destroy (window->device_events); + if (window->source_event_masks) + g_hash_table_destroy (window->source_event_masks); + if (window->devices_inside) g_list_free (window->devices_inside); @@ -7164,6 +7167,9 @@ gdk_window_shape_combine_region (GdkWindow *window, if (GDK_WINDOW_DESTROYED (window)) return; + if (!window->shape && shape_region == NULL) + return; + window->shaped = (shape_region != NULL); if (window->shape) @@ -8335,6 +8341,7 @@ send_crossing_event (GdkDisplay *display, GdkNotifyType notify_type, GdkWindow *subwindow, GdkDevice *device, + GdkDevice *source_device, gint toplevel_x, gint toplevel_y, GdkModifierType mask, @@ -8394,6 +8401,10 @@ send_crossing_event (GdkDisplay *display, { event = _gdk_make_event ((GdkWindow *)window, type, event_in_queue, TRUE); gdk_event_set_device (event, device); + + if (source_device) + gdk_event_set_source_device (event, source_device); + event->crossing.time = time_; event->crossing.subwindow = subwindow; if (subwindow) @@ -8421,6 +8432,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, GdkWindow *src, GdkWindow *dest, GdkDevice *device, + GdkDevice *source_device, GdkCrossingMode mode, gint toplevel_x, gint toplevel_y, @@ -8476,7 +8488,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, a, GDK_LEAVE_NOTIFY, mode, notify_type, - NULL, device, + NULL, device, source_device, toplevel_x, toplevel_y, mask, time_, event_in_queue, @@ -8498,7 +8510,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, mode, notify_type, (GdkWindow *)last, - device, + device, source_device, toplevel_x, toplevel_y, mask, time_, event_in_queue, @@ -8545,7 +8557,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, mode, notify_type, (GdkWindow *)next, - device, + device, source_device, toplevel_x, toplevel_y, mask, time_, event_in_queue, @@ -8567,7 +8579,7 @@ _gdk_synthesize_crossing_events (GdkDisplay *display, mode, notify_type, NULL, - device, + device, source_device, toplevel_x, toplevel_y, mask, time_, event_in_queue, @@ -8900,6 +8912,143 @@ gdk_window_geometry_changed (GdkWindow *window) _gdk_synthesize_crossing_events_for_geometry_change (window); } +static void +source_events_device_added (GdkDeviceManager *device_manager, + GdkDevice *device, + gpointer user_data) +{ + GdkWindow *window; + GdkEventMask event_mask; + GdkInputSource source; + + if (gdk_device_get_device_type (device) != GDK_DEVICE_TYPE_FLOATING) + return; + + window = user_data; + source = gdk_device_get_source (device); + + event_mask = GPOINTER_TO_INT (g_hash_table_lookup (window->source_event_masks, + GINT_TO_POINTER (source))); + if (event_mask) + gdk_window_set_device_events (window, device, event_mask); +} + +static void +source_events_device_changed (GdkDeviceManager *device_manager, + GdkDevice *device, + gpointer user_data) +{ + GdkDeviceType type; + GdkInputSource source; + GdkEventMask event_mask; + GdkWindow *window; + + window = user_data; + type = gdk_device_get_device_type (device); + source = gdk_device_get_source (device); + + event_mask = GPOINTER_TO_INT (g_hash_table_lookup (window->source_event_masks, + GINT_TO_POINTER (source))); + + if (!event_mask) + return; + + if (type == GDK_DEVICE_TYPE_FLOATING) + { + /* The device was just floated, enable its event mask */ + gdk_window_set_device_events (window, device, event_mask); + } + else if (type == GDK_DEVICE_TYPE_SLAVE) + gdk_window_set_device_events (window, device, 0); +} + +/** + * gdk_window_set_source_events: + * @window: a #GdkWindow + * @source: a #GdkInputSource to define the source class. + * @event_mask: event mask for @window + * + * Sets the event mask for any floating device (i.e. not attached to any + * visible pointer) that has the source defined as @source. This event + * mask will be applied both to currently existing, newly added devices + * after this call, and devices being attached/detached. + * + * Since: 3.0 + **/ +void +gdk_window_set_source_events (GdkWindow *window, + GdkInputSource source, + GdkEventMask event_mask) +{ + GdkDeviceManager *device_manager; + GdkDisplay *display; + GList *devices, *d; + guint size; + + g_return_if_fail (GDK_IS_WINDOW (window)); + + display = gdk_window_get_display (window); + device_manager = gdk_display_get_device_manager (display); + + devices = gdk_device_manager_list_devices (device_manager, GDK_DEVICE_TYPE_FLOATING); + + /* Set event mask for existing devices */ + for (d = devices; d; d = d->next) + { + GdkDevice *device = d->data; + + if (source == gdk_device_get_source (device)) + gdk_window_set_device_events (window, device, event_mask); + } + + /* Update accounting */ + if (G_UNLIKELY (!window->source_event_masks)) + window->source_event_masks = g_hash_table_new (NULL, NULL); + + if (event_mask) + g_hash_table_insert (window->source_event_masks, + GUINT_TO_POINTER (source), + GUINT_TO_POINTER (event_mask)); + else + g_hash_table_remove (window->source_event_masks, + GUINT_TO_POINTER (source)); + + size = g_hash_table_size (window->source_event_masks); + + /* Update handler if needed */ + if (!window->device_added_handler_id && size > 0) + { + window->device_added_handler_id = + g_signal_connect (device_manager, "device-added", + G_CALLBACK (source_events_device_added), window); + window->device_changed_handler_id = + g_signal_connect (device_manager, "device-changed", + G_CALLBACK (source_events_device_changed), window); + } + else if (window->device_added_handler_id && size == 0) + g_signal_handler_disconnect (device_manager, window->device_added_handler_id); +} + +/** + * gdk_window_get_source_events: + * @window: a #GdkWindow + * @source: a #GdkInputSource to define the source class. + * + * Returns the event mask for @window corresponding to the device class specified + * by @source. + * + * Returns: source event mask for @window + **/ +GdkEventMask +gdk_window_get_source_events (GdkWindow *window, + GdkInputSource source) +{ + g_return_val_if_fail (GDK_IS_WINDOW (window), 0); + + return GPOINTER_TO_UINT (g_hash_table_lookup (window->source_event_masks, + GUINT_TO_POINTER (source))); +} + static gboolean do_synthesize_crossing_event (gpointer data) { @@ -8939,7 +9088,7 @@ do_synthesize_crossing_event (gpointer data) _gdk_synthesize_crossing_events (display, pointer_info->window_under_pointer, new_window_under_pointer, - device, + device, NULL, GDK_CROSSING_NORMAL, pointer_info->toplevel_x, pointer_info->toplevel_y, @@ -9055,7 +9204,7 @@ proxy_pointer_event (GdkDisplay *display, GdkWindow *toplevel_window, *event_window; GdkWindow *pointer_window; GdkPointerWindowInfo *pointer_info; - GdkDevice *device; + GdkDevice *device, *source_device; GdkEvent *event; guint state; gdouble toplevel_x, toplevel_y; @@ -9067,6 +9216,7 @@ proxy_pointer_event (GdkDisplay *display, gdk_event_get_state (source_event, &state); time_ = gdk_event_get_time (source_event); device = gdk_event_get_device (source_event); + source_device = gdk_event_get_source_device (source_event); pointer_info = _gdk_display_get_pointer_info (display, device); toplevel_window = convert_native_coords_to_toplevel (event_window, toplevel_x, toplevel_y, @@ -9100,7 +9250,7 @@ proxy_pointer_event (GdkDisplay *display, _gdk_synthesize_crossing_events (display, pointer_info->window_under_pointer, event_window, - device, + device, source_device, source_event->crossing.mode, toplevel_x, toplevel_y, state, time_, @@ -9116,7 +9266,7 @@ proxy_pointer_event (GdkDisplay *display, source_event->crossing.mode, source_event->crossing.detail, NULL, - device, + device, source_device, toplevel_x, toplevel_y, state, time_, source_event, @@ -9146,7 +9296,7 @@ proxy_pointer_event (GdkDisplay *display, source_event->crossing.mode, source_event->crossing.detail, NULL, - device, + device, source_device, toplevel_x, toplevel_y, state, time_, source_event, @@ -9156,7 +9306,7 @@ proxy_pointer_event (GdkDisplay *display, _gdk_synthesize_crossing_events (display, event_window, pointer_window, - device, + device, source_device, source_event->crossing.mode, toplevel_x, toplevel_y, state, time_, @@ -9175,7 +9325,7 @@ proxy_pointer_event (GdkDisplay *display, _gdk_synthesize_crossing_events (display, pointer_info->window_under_pointer, pointer_window, - device, + device, source_device, GDK_CROSSING_NORMAL, toplevel_x, toplevel_y, state, time_, @@ -9236,6 +9386,7 @@ proxy_pointer_event (GdkDisplay *display, event->motion.device = source_event->motion.device; event->motion.axes = g_memdup (source_event->motion.axes, sizeof (gdouble) * gdk_device_get_n_axes (source_event->motion.device)); + gdk_event_set_source_device (event, source_device); } } @@ -9265,7 +9416,7 @@ proxy_button_event (GdkEvent *source_event, gdouble toplevel_x, toplevel_y; GdkDisplay *display; GdkWindow *w; - GdkDevice *device; + GdkDevice *device, *source_device; type = source_event->any.type; event_window = source_event->any.window; @@ -9273,6 +9424,7 @@ proxy_button_event (GdkEvent *source_event, gdk_event_get_state (source_event, &state); time_ = gdk_event_get_time (source_event); device = gdk_event_get_device (source_event); + source_device = gdk_event_get_source_device (source_event); display = gdk_window_get_display (source_event->any.window); toplevel_window = convert_native_coords_to_toplevel (event_window, toplevel_x, toplevel_y, @@ -9309,7 +9461,7 @@ proxy_button_event (GdkEvent *source_event, serial, time_, TRUE); - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, source_device, serial); } pointer_window = get_pointer_window (display, toplevel_window, device, @@ -9346,6 +9498,8 @@ proxy_button_event (GdkEvent *source_event, event->button.axes = g_memdup (source_event->button.axes, sizeof (gdouble) * gdk_device_get_n_axes (source_event->button.device)); + gdk_event_set_source_device (event, source_device); + if (type == GDK_BUTTON_PRESS) _gdk_event_button_generate (display, event); return TRUE; @@ -9359,6 +9513,7 @@ proxy_button_event (GdkEvent *source_event, event->scroll.y_root = source_event->scroll.y_root; event->scroll.state = state; event->scroll.device = source_event->scroll.device; + gdk_event_set_source_device (event, source_device); return TRUE; default: @@ -9452,20 +9607,21 @@ _gdk_windowing_got_event (GdkDisplay *display, guint old_state, old_button; GdkDeviceGrabInfo *button_release_grab; GdkPointerWindowInfo *pointer_info; - GdkDevice *device; + GdkDevice *device, *source_device; gboolean is_toplevel; if (gdk_event_get_time (event) != GDK_CURRENT_TIME) display->last_event_time = gdk_event_get_time (event); device = gdk_event_get_device (event); + source_device = gdk_event_get_source_device (event); if (device) { GdkInputMode mode; g_object_get (device, "input-mode", &mode, NULL); - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, source_device, serial); if (mode == GDK_MODE_DISABLED || !_gdk_display_check_grab_ownership (display, device, serial)) @@ -9510,7 +9666,7 @@ _gdk_windowing_got_event (GdkDisplay *display, serial, gdk_event_get_time (event), TRUE); - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, source_device, serial); } if (event->type == GDK_BUTTON_RELEASE && !event->any.send_event) @@ -9523,7 +9679,7 @@ _gdk_windowing_got_event (GdkDisplay *display, { button_release_grab->serial_end = serial; button_release_grab->implicit_ungrab = FALSE; - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, source_device, serial); } } @@ -9645,7 +9801,7 @@ _gdk_windowing_got_event (GdkDisplay *display, { button_release_grab->serial_end = serial; button_release_grab->implicit_ungrab = FALSE; - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, source_device, serial); } } diff --git a/gdk/gdkwindow.h b/gdk/gdkwindow.h index 69fee5ad09..164281dc3c 100644 --- a/gdk/gdkwindow.h +++ b/gdk/gdkwindow.h @@ -778,6 +778,12 @@ void gdk_window_set_device_events (GdkWindow *window, GdkEventMask gdk_window_get_device_events (GdkWindow *window, GdkDevice *device); +void gdk_window_set_source_events (GdkWindow *window, + GdkInputSource source, + GdkEventMask event_mask); +GdkEventMask gdk_window_get_source_events (GdkWindow *window, + GdkInputSource source); + void gdk_window_set_icon_list (GdkWindow *window, GList *pixbufs); void gdk_window_set_icon_name (GdkWindow *window, diff --git a/gdk/x11/gdkdevicemanager-x11.c b/gdk/x11/gdkdevicemanager-x11.c index a6bb50b7c3..4a6953d3be 100644 --- a/gdk/x11/gdkdevicemanager-x11.c +++ b/gdk/x11/gdkdevicemanager-x11.c @@ -48,7 +48,7 @@ _gdk_device_manager_new (GdkDisplay *display) major = 2; minor = 0; - if (_gdk_enable_multidevice && + if (!_gdk_disable_multidevice && XIQueryVersion (xdisplay, &major, &minor) != BadRequest) { GdkDeviceManagerXI2 *device_manager_xi2; diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c index 25d7a841a6..ee3461c3fe 100644 --- a/gdk/x11/gdkdevicemanager-xi2.c +++ b/gdk/x11/gdkdevicemanager-xi2.c @@ -263,15 +263,29 @@ add_device (GdkDeviceManagerXI2 *device_manager, if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard) device_manager->master_devices = g_list_append (device_manager->master_devices, device); - else if (dev->use == XISlavePointer || dev->use == XISlaveKeyboard) + else if (dev->use == XISlavePointer || dev->use == XISlaveKeyboard || dev->use == XIFloatingSlave) device_manager->slave_devices = g_list_append (device_manager->slave_devices, device); - else if (dev->use == XIFloatingSlave) - device_manager->floating_devices = g_list_append (device_manager->floating_devices, device); else g_warning ("Unhandled device: %s\n", gdk_device_get_name (device)); if (emit_signal) - g_signal_emit_by_name (device_manager, "device-added", device); + { + if (dev->use == XISlavePointer || dev->use == XISlaveKeyboard) + { + GdkDevice *master; + + /* The device manager is already constructed, then + * keep the hierarchy coherent for the added device. + */ + master = g_hash_table_lookup (device_manager->id_table, + GINT_TO_POINTER (dev->attachment)); + + _gdk_device_set_associated_device (device, master); + _gdk_device_add_slave (master, device); + } + + g_signal_emit_by_name (device_manager, "device-added", device); + } return device; } @@ -289,7 +303,6 @@ remove_device (GdkDeviceManagerXI2 *device_manager, { device_manager->master_devices = g_list_remove (device_manager->master_devices, device); device_manager->slave_devices = g_list_remove (device_manager->slave_devices, device); - device_manager->floating_devices = g_list_remove (device_manager->floating_devices, device); g_signal_emit_by_name (device_manager, "device-removed", device); @@ -301,7 +314,7 @@ remove_device (GdkDeviceManagerXI2 *device_manager, } static void -relate_devices (gpointer key, +relate_masters (gpointer key, gpointer value, gpointer user_data) { @@ -317,12 +330,28 @@ relate_devices (gpointer key, } static void +relate_slaves (gpointer key, + gpointer value, + gpointer user_data) +{ + GdkDeviceManagerXI2 *device_manager; + GdkDevice *slave, *master; + + device_manager = user_data; + slave = g_hash_table_lookup (device_manager->id_table, key); + master = g_hash_table_lookup (device_manager->id_table, value); + + _gdk_device_set_associated_device (slave, master); + _gdk_device_add_slave (master, slave); +} + +static void gdk_device_manager_xi2_constructed (GObject *object) { GdkDeviceManagerXI2 *device_manager_xi2; GdkDisplay *display; GdkScreen *screen; - GHashTable *relations; + GHashTable *masters, *slaves; Display *xdisplay; XIDeviceInfo *info, *dev; int ndevices, i; @@ -332,7 +361,9 @@ gdk_device_manager_xi2_constructed (GObject *object) device_manager_xi2 = GDK_DEVICE_MANAGER_XI2 (object); display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (object)); xdisplay = GDK_DISPLAY_XDISPLAY (display); - relations = g_hash_table_new (NULL, NULL); + + masters = g_hash_table_new (NULL, NULL); + slaves = g_hash_table_new (NULL, NULL); info = XIQueryDevice(xdisplay, XIAllDevices, &ndevices); @@ -347,7 +378,14 @@ gdk_device_manager_xi2_constructed (GObject *object) if (dev->use == XIMasterPointer || dev->use == XIMasterKeyboard) { - g_hash_table_insert (relations, + g_hash_table_insert (masters, + GINT_TO_POINTER (dev->deviceid), + GINT_TO_POINTER (dev->attachment)); + } + else if (dev->use == XISlavePointer || + dev->use == XISlaveKeyboard) + { + g_hash_table_insert (slaves, GINT_TO_POINTER (dev->deviceid), GINT_TO_POINTER (dev->attachment)); } @@ -356,8 +394,11 @@ gdk_device_manager_xi2_constructed (GObject *object) XIFreeDeviceInfo(info); /* Stablish relationships between devices */ - g_hash_table_foreach (relations, relate_devices, object); - g_hash_table_destroy (relations); + g_hash_table_foreach (masters, relate_masters, object); + g_hash_table_destroy (masters); + + g_hash_table_foreach (slaves, relate_slaves, object); + g_hash_table_destroy (slaves); /* Connect to hierarchy change events */ screen = gdk_display_get_default_screen (display); @@ -388,10 +429,6 @@ gdk_device_manager_xi2_dispose (GObject *object) g_list_free (device_manager_xi2->slave_devices); device_manager_xi2->slave_devices = NULL; - g_list_foreach (device_manager_xi2->floating_devices, (GFunc) g_object_unref, NULL); - g_list_free (device_manager_xi2->floating_devices); - device_manager_xi2->floating_devices = NULL; - if (device_manager_xi2->id_table) { g_hash_table_destroy (device_manager_xi2->id_table); @@ -416,10 +453,21 @@ gdk_device_manager_xi2_list_devices (GdkDeviceManager *device_manager, list = device_manager_xi2->master_devices; break; case GDK_DEVICE_TYPE_SLAVE: - list = device_manager_xi2->slave_devices; - break; case GDK_DEVICE_TYPE_FLOATING: - list = device_manager_xi2->floating_devices; + { + GList *devs = device_manager_xi2->slave_devices; + + while (devs) + { + GdkDevice *dev; + + dev = devs->data; + devs = devs->next; + + if (type == gdk_device_get_device_type (dev)) + list = g_list_prepend (list, dev); + } + } break; default: g_assert_not_reached (); @@ -457,32 +505,61 @@ static void handle_hierarchy_changed (GdkDeviceManagerXI2 *device_manager, XIHierarchyEvent *ev) { + GdkDisplay *display; + Display *xdisplay; GdkDevice *device; + XIDeviceInfo *info; + int ndevices; gint i; - /* We only care about enabled devices */ - if (!(ev->flags & XIDeviceEnabled) && - !(ev->flags & XIDeviceDisabled)) - return; + display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager)); + xdisplay = GDK_DISPLAY_XDISPLAY (display); for (i = 0; i < ev->num_info; i++) { if (ev->info[i].flags & XIDeviceEnabled) { - GdkDisplay *display; - Display *xdisplay; - XIDeviceInfo *info; - int ndevices; - - display = gdk_device_manager_get_display (GDK_DEVICE_MANAGER (device_manager)); - xdisplay = GDK_DISPLAY_XDISPLAY (display); - info = XIQueryDevice(xdisplay, ev->info[i].deviceid, &ndevices); device = add_device (device_manager, &info[0], TRUE); XIFreeDeviceInfo(info); } else if (ev->info[i].flags & XIDeviceDisabled) remove_device (device_manager, ev->info[i].deviceid); + else if (ev->info[i].flags & XISlaveAttached || + ev->info[i].flags & XISlaveDetached) + { + GdkDevice *master, *slave; + + slave = g_hash_table_lookup (device_manager->id_table, + GINT_TO_POINTER (ev->info[i].deviceid)); + + /* Remove old master info */ + master = gdk_device_get_associated_device (slave); + + if (master) + { + _gdk_device_remove_slave (master, slave); + _gdk_device_set_associated_device (slave, NULL); + + g_signal_emit_by_name (device_manager, "device-changed", master); + } + + /* Add new master if it's an attachment event */ + if (ev->info[i].flags & XISlaveAttached) + { + info = XIQueryDevice(xdisplay, ev->info[i].deviceid, &ndevices); + + master = g_hash_table_lookup (device_manager->id_table, + GINT_TO_POINTER (info->attachment)); + + _gdk_device_set_associated_device (slave, master); + _gdk_device_add_slave (master, slave); + + g_signal_emit_by_name (device_manager, "device-changed", master); + } + + g_signal_emit_by_name (device_manager, "device-changed", slave); + } } } @@ -499,6 +576,8 @@ handle_device_changed (GdkDeviceManagerXI2 *device_manager, _gdk_device_reset_axes (device); translate_device_classes (display, device, ev->classes, ev->num_classes); + + g_signal_emit_by_name (G_OBJECT (device), "changed"); } static GdkCrossingMode @@ -641,6 +720,7 @@ translate_keyboard_string (GdkEventKey *event) static void generate_focus_event (GdkWindow *window, GdkDevice *device, + GdkDevice *source_device, gboolean in) { GdkEvent *event; @@ -650,6 +730,7 @@ generate_focus_event (GdkWindow *window, event->focus_change.send_event = FALSE; event->focus_change.in = in; gdk_event_set_device (event, device); + gdk_event_set_source_device (event, source_device); gdk_event_put (event); gdk_event_free (event); @@ -658,6 +739,7 @@ generate_focus_event (GdkWindow *window, static void handle_focus_change (GdkWindow *window, GdkDevice *device, + GdkDevice *source_device, gint detail, gint mode, gboolean in) @@ -717,7 +799,7 @@ handle_focus_change (GdkWindow *window, } if (HAS_FOCUS (toplevel) != had_focus) - generate_focus_event (window, device, (in) ? TRUE : FALSE); + generate_focus_event (window, device, source_device, (in) ? TRUE : FALSE); } static gdouble * @@ -916,7 +998,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, XIDeviceEvent *xev = (XIDeviceEvent *) ev; GdkKeymap *keymap = gdk_keymap_get_for_display (display); GdkModifierType consumed, state; - GdkDevice *device; + GdkDevice *device, *source_device; event->key.type = xev->evtype == XI_KeyPress ? GDK_KEY_PRESS : GDK_KEY_RELEASE; @@ -933,6 +1015,10 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, GUINT_TO_POINTER (xev->deviceid)); gdk_event_set_device (event, device); + source_device = g_hash_table_lookup (device_manager->id_table, + GUINT_TO_POINTER (xev->sourceid)); + gdk_event_set_source_device (event, source_device); + event->key.keyval = GDK_KEY_VoidSymbol; gdk_keymap_translate_keyboard_state (keymap, @@ -961,6 +1047,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, case XI_ButtonRelease: { XIDeviceEvent *xev = (XIDeviceEvent *) ev; + GdkDevice *source_device; switch (xev->detail) { @@ -989,6 +1076,10 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, event->scroll.device = g_hash_table_lookup (device_manager->id_table, GUINT_TO_POINTER (xev->deviceid)); + source_device = g_hash_table_lookup (device_manager->id_table, + GUINT_TO_POINTER (xev->sourceid)); + gdk_event_set_source_device (event, source_device); + event->scroll.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); break; default: @@ -1004,6 +1095,10 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, event->button.device = g_hash_table_lookup (device_manager->id_table, GUINT_TO_POINTER (xev->deviceid)); + source_device = g_hash_table_lookup (device_manager->id_table, + GUINT_TO_POINTER (xev->sourceid)); + gdk_event_set_source_device (event, source_device); + event->button.axes = translate_axes (event->button.device, event->button.x, event->button.y, @@ -1036,6 +1131,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, case XI_Motion: { XIDeviceEvent *xev = (XIDeviceEvent *) ev; + GdkDevice *source_device; event->motion.type = GDK_MOTION_NOTIFY; @@ -1050,6 +1146,10 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, event->motion.device = g_hash_table_lookup (device_manager->id_table, GINT_TO_POINTER (xev->deviceid)); + source_device = g_hash_table_lookup (device_manager->id_table, + GUINT_TO_POINTER (xev->sourceid)); + gdk_event_set_source_device (event, source_device); + event->motion.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); /* There doesn't seem to be motion hints in XI */ @@ -1075,7 +1175,7 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, case XI_Leave: { XIEnterEvent *xev = (XIEnterEvent *) ev; - GdkDevice *device; + GdkDevice *device, *source_device; event->crossing.type = (ev->evtype == XI_Enter) ? GDK_ENTER_NOTIFY : GDK_LEAVE_NOTIFY; @@ -1093,6 +1193,10 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, GINT_TO_POINTER (xev->deviceid)); gdk_event_set_device (event, device); + source_device = g_hash_table_lookup (device_manager->id_table, + GUINT_TO_POINTER (xev->sourceid)); + gdk_event_set_source_device (event, source_device); + event->crossing.mode = translate_crossing_mode (xev->mode); event->crossing.detail = translate_notify_type (xev->detail); event->crossing.state = gdk_device_xi2_translate_state (&xev->mods, &xev->buttons); @@ -1102,12 +1206,16 @@ gdk_device_manager_xi2_translate_event (GdkEventTranslator *translator, case XI_FocusOut: { XIEnterEvent *xev = (XIEnterEvent *) ev; - GdkDevice *device; + GdkDevice *device, *source_device; device = g_hash_table_lookup (device_manager->id_table, GINT_TO_POINTER (xev->deviceid)); - handle_focus_change (window, device, xev->detail, xev->mode, + source_device = g_hash_table_lookup (device_manager->id_table, + GUINT_TO_POINTER (xev->sourceid)); + + handle_focus_change (window, device, source_device, + xev->detail, xev->mode, (ev->evtype == XI_FocusIn) ? TRUE : FALSE); return_val = FALSE; diff --git a/gdk/x11/gdkdevicemanager-xi2.h b/gdk/x11/gdkdevicemanager-xi2.h index 20054c160c..e16a6f7bf8 100644 --- a/gdk/x11/gdkdevicemanager-xi2.h +++ b/gdk/x11/gdkdevicemanager-xi2.h @@ -43,7 +43,6 @@ struct _GdkDeviceManagerXI2 GList *master_devices; GList *slave_devices; - GList *floating_devices; GdkDevice *client_pointer; diff --git a/gdk/x11/gdkdisplay-x11.c b/gdk/x11/gdkdisplay-x11.c index bfcc358cce..27ef251919 100644 --- a/gdk/x11/gdkdisplay-x11.c +++ b/gdk/x11/gdkdisplay-x11.c @@ -1633,7 +1633,7 @@ device_ungrab_callback (GdkDisplay *display, { GdkDevice *device = data; - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, NULL, serial); } diff --git a/gdk/x11/gdkmain-x11.c b/gdk/x11/gdkmain-x11.c index f9df29592f..2ce5e34875 100644 --- a/gdk/x11/gdkmain-x11.c +++ b/gdk/x11/gdkmain-x11.c @@ -136,7 +136,7 @@ has_pointer_grab_callback (GdkDisplay *display, { GdkDevice *device = data; - _gdk_display_device_grab_update (display, device, serial); + _gdk_display_device_grab_update (display, device, NULL, serial); } GdkGrabStatus diff --git a/gdk/x11/gdkwindow-x11.h b/gdk/x11/gdkwindow-x11.h index fd63e8b462..85d892b283 100644 --- a/gdk/x11/gdkwindow-x11.h +++ b/gdk/x11/gdkwindow-x11.h @@ -30,11 +30,14 @@ #include "gdk/x11/gdkprivate-x11.h" #include "gdk/gdkwindowimpl.h" +#include <X11/Xlib.h> + #ifdef HAVE_XDAMAGE #include <X11/extensions/Xdamage.h> #endif #ifdef HAVE_XSYNC +#include <X11/Xlib.h> #include <X11/extensions/sync.h> #endif diff --git a/gtk/gtk.symbols b/gtk/gtk.symbols index b7c384bd77..d121000676 100644 --- a/gtk/gtk.symbols +++ b/gtk/gtk.symbols @@ -3539,7 +3539,6 @@ gtk_widget_render_icon gtk_widget_render_icon_pixbuf gtk_widget_reparent gtk_widget_reset_rc_styles -gtk_widget_reset_shapes gtk_widget_reset_style gtk_widget_send_expose gtk_widget_send_focus_change diff --git a/gtk/gtkaboutdialog.c b/gtk/gtkaboutdialog.c index 677f16acb9..4844ed792d 100644 --- a/gtk/gtkaboutdialog.c +++ b/gtk/gtkaboutdialog.c @@ -35,15 +35,18 @@ #include <gdk/gdkkeysyms.h> #include "gtkaboutdialog.h" +#include "gtkalignment.h" #include "gtkbutton.h" #include "gtkbbox.h" #include "gtkdialog.h" +#include "gtkgrid.h" #include "gtkhbox.h" #include "gtkimage.h" #include "gtklabel.h" #include "gtklinkbutton.h" #include "gtkmarshalers.h" #include "gtknotebook.h" +#include "gtkorientable.h" #include "gtkscrolledwindow.h" #include "gtkstock.h" #include "gtktextview.h" @@ -52,6 +55,7 @@ #include "gtkshow.h" #include "gtkmain.h" #include "gtkmessagedialog.h" +#include "gtktogglebutton.h" #include "gtkprivate.h" #include "gtkintl.h" @@ -98,7 +102,7 @@ static GdkColor default_visited_link_color = { 0, 0x5555, 0x1a1a, 0x8b8b }; /* Translators: this is the license preamble; the string at the end * contains the URL of the license. */ -static const gchar *gtk_license_preamble = N_("This program comes with ABSOLUTELY NO WARRANTY; for details, visit %s"); +static const gchar *gtk_license_preamble = N_("This program comes with ABSOLUTELY NO WARRANTY; for details, visit <a href=\"%s\">%s</a>"); /* URLs for each GtkLicense type; keep in the same order as the enumeration */ static const gchar *gtk_license_urls[] = { @@ -132,16 +136,20 @@ struct _GtkAboutDialogPrivate gchar **documenters; gchar **artists; + gint credits_page; + gint license_page; + + GtkWidget *notebook; GtkWidget *logo_image; GtkWidget *name_label; + GtkWidget *version_label; GtkWidget *comments_label; GtkWidget *copyright_label; + GtkWidget *license_label; GtkWidget *website_label; GtkWidget *credits_button; - GtkWidget *credits_dialog; GtkWidget *license_button; - GtkWidget *license_dialog; GdkCursor *hand_cursor; GdkCursor *regular_cursor; @@ -197,9 +205,9 @@ static void set_cursor_if_appropriate (GtkAboutDialog GdkDevice *device, gint x, gint y); -static void display_credits_dialog (GtkWidget *button, +static void display_credits_page (GtkWidget *button, gpointer data); -static void display_license_dialog (GtkWidget *button, +static void display_license_page (GtkWidget *button, gpointer data); static void close_cb (GtkAboutDialog *about); static gboolean gtk_about_dialog_activate_link (GtkAboutDialog *about, @@ -534,11 +542,99 @@ emit_activate_link (GtkAboutDialog *about, } static void +update_license_button_visibility (GtkAboutDialog *about) +{ + GtkAboutDialogPrivate *priv = about->priv; + + if (priv->license_type == GTK_LICENSE_CUSTOM && priv->license != NULL) + gtk_widget_show (priv->license_button); + else + gtk_widget_hide (priv->license_button); +} + +static void +update_credits_button_visibility (GtkAboutDialog *about) +{ + GtkAboutDialogPrivate *priv = about->priv; + gboolean show; + + show = (priv->authors != NULL || + priv->documenters != NULL || + priv->artists != NULL || + (priv->translator_credits != NULL && + strcmp (priv->translator_credits, "translator_credits") && + strcmp (priv->translator_credits, "translator-credits"))); + if (show) + gtk_widget_show (priv->credits_button); + else + gtk_widget_hide (priv->credits_button); +} + +static void +switch_page (GtkAboutDialog *about, + gint page) +{ + GtkAboutDialogPrivate *priv = about->priv; + + gtk_notebook_set_current_page (GTK_NOTEBOOK (priv->notebook), page); +} + +static void +display_main_page (GtkButton *button, + gpointer data) +{ + GtkAboutDialog *about = (GtkAboutDialog *)data; + + switch_page (about, 0); +} + +static void +credits_button_clicked (GtkButton *button, + gpointer data) +{ + GtkAboutDialog *about = (GtkAboutDialog *)data; + GtkAboutDialogPrivate *priv = about->priv; + gboolean active; + + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + + if (active) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->license_button), FALSE); + display_credits_page (NULL, data); + } + else + { + display_main_page (NULL, data); + } +} + +static void +license_button_clicked (GtkButton *button, + gpointer data) +{ + GtkAboutDialog *about = (GtkAboutDialog *)data; + GtkAboutDialogPrivate *priv = about->priv; + gboolean active; + + active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)); + + if (active) + { + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->credits_button), FALSE); + display_license_page (NULL, data); + } + else + { + display_main_page (NULL, data); + } +} +static void gtk_about_dialog_init (GtkAboutDialog *about) { GtkDialog *dialog = GTK_DIALOG (about); GtkAboutDialogPrivate *priv; - GtkWidget *vbox, *hbox, *button, *close_button, *image; + GtkWidget *vbox, *page_vbox, *hbox, *button, *close_button, *image; GtkWidget *content_area, *action_area; /* Data */ @@ -574,7 +670,7 @@ gtk_about_dialog_init (GtkAboutDialog *about) /* Widgets */ gtk_widget_push_composite_child (); - vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); + vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); gtk_box_pack_start (GTK_BOX (content_area), vbox, TRUE, TRUE, 0); @@ -586,20 +682,30 @@ gtk_about_dialog_init (GtkAboutDialog *about) gtk_label_set_justify (GTK_LABEL (priv->name_label), GTK_JUSTIFY_CENTER); gtk_box_pack_start (GTK_BOX (vbox), priv->name_label, FALSE, FALSE, 0); + priv->notebook = gtk_notebook_new (); + gtk_box_pack_start (GTK_BOX (vbox), priv->notebook, TRUE, TRUE, 0); + gtk_widget_set_size_request (priv->notebook, 400, 100); + + page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); + gtk_widget_show (page_vbox); + gtk_notebook_set_show_tabs (GTK_NOTEBOOK (priv->notebook), FALSE); + gtk_notebook_set_show_border (GTK_NOTEBOOK (priv->notebook), FALSE); + gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL); + + priv->version_label = gtk_label_new (NULL); + gtk_label_set_selectable (GTK_LABEL (priv->version_label), TRUE); + gtk_label_set_justify (GTK_LABEL (priv->version_label), GTK_JUSTIFY_CENTER); + gtk_box_pack_start (GTK_BOX (page_vbox), priv->version_label, FALSE, FALSE, 0); + priv->comments_label = gtk_label_new (NULL); gtk_label_set_selectable (GTK_LABEL (priv->comments_label), TRUE); gtk_label_set_justify (GTK_LABEL (priv->comments_label), GTK_JUSTIFY_CENTER); gtk_label_set_line_wrap (GTK_LABEL (priv->comments_label), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), priv->comments_label, FALSE, FALSE, 0); - - priv->copyright_label = gtk_label_new (NULL); - gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE); - gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER); - gtk_box_pack_start (GTK_BOX (vbox), priv->copyright_label, FALSE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (page_vbox), priv->comments_label, FALSE, FALSE, 0); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_set_homogeneous (GTK_BOX (hbox), TRUE); - gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, FALSE, 0); + gtk_box_pack_start (GTK_BOX (page_vbox), hbox, FALSE, FALSE, 0); priv->website_label = button = gtk_label_new (""); gtk_widget_set_no_show_all (button, TRUE); @@ -608,7 +714,20 @@ gtk_about_dialog_init (GtkAboutDialog *about) g_signal_connect_swapped (button, "activate-link", G_CALLBACK (emit_activate_link), about); + priv->license_label = gtk_label_new (NULL); + gtk_label_set_use_markup (GTK_LABEL (priv->license_label), TRUE); + gtk_label_set_selectable (GTK_LABEL (priv->license_label), TRUE); + gtk_label_set_justify (GTK_LABEL (priv->license_label), GTK_JUSTIFY_CENTER); + gtk_box_pack_end (GTK_BOX (page_vbox), priv->license_label, FALSE, FALSE, 0); + gtk_label_set_line_wrap (GTK_LABEL (priv->license_label), TRUE); + + priv->copyright_label = gtk_label_new (NULL); + gtk_label_set_selectable (GTK_LABEL (priv->copyright_label), TRUE); + gtk_label_set_justify (GTK_LABEL (priv->copyright_label), GTK_JUSTIFY_CENTER); + gtk_box_pack_end (GTK_BOX (page_vbox), priv->copyright_label, FALSE, FALSE, 0); + gtk_widget_show (vbox); + gtk_widget_show (priv->notebook); gtk_widget_show (priv->logo_image); gtk_widget_show (priv->name_label); gtk_widget_show (hbox); @@ -619,30 +738,30 @@ gtk_about_dialog_init (GtkAboutDialog *about) gtk_dialog_set_default_response (GTK_DIALOG (about), GTK_RESPONSE_CANCEL); /* Add the credits button */ - button = gtk_button_new_with_mnemonic (_("C_redits")); + button = gtk_toggle_button_new_with_mnemonic (_("C_redits")); gtk_widget_set_can_default (button, TRUE); image = gtk_image_new_from_stock (GTK_STOCK_ABOUT, GTK_ICON_SIZE_BUTTON); gtk_button_set_image (GTK_BUTTON (button), image); gtk_widget_set_no_show_all (button, TRUE); - gtk_box_pack_end (GTK_BOX (action_area), - button, FALSE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE); g_signal_connect (button, "clicked", - G_CALLBACK (display_credits_dialog), about); + G_CALLBACK (credits_button_clicked), about); priv->credits_button = button; - priv->credits_dialog = NULL; + priv->credits_page = 0; /* Add the license button */ - button = gtk_button_new_from_stock (_("_License")); + button = gtk_toggle_button_new_with_mnemonic (_("_License")); gtk_widget_set_can_default (button, TRUE); gtk_widget_set_no_show_all (button, TRUE); - gtk_box_pack_end (GTK_BOX (action_area), - button, FALSE, TRUE, 0); + gtk_box_pack_end (GTK_BOX (action_area), button, FALSE, TRUE, 0); gtk_button_box_set_child_secondary (GTK_BUTTON_BOX (action_area), button, TRUE); g_signal_connect (button, "clicked", - G_CALLBACK (display_license_dialog), about); + G_CALLBACK (license_button_clicked), about); priv->license_button = button; - priv->license_dialog = NULL; + priv->license_page = 0; + + switch_page (about, 0); gtk_window_set_resizable (GTK_WINDOW (about), FALSE); @@ -874,7 +993,7 @@ update_website (GtkAboutDialog *about) else { markup = g_strdup_printf ("<a href=\"%s\">%s</a>", - priv->website_url, priv->website_url); + priv->website_url, _("Homepage")); } gtk_label_set_markup (GTK_LABEL (priv->website_label), markup); @@ -935,14 +1054,16 @@ update_name_version (GtkAboutDialog *about) g_free (title_string); if (priv->version != NULL) - name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", - priv->name, priv->version); + { + gtk_label_set_markup (GTK_LABEL (priv->version_label), priv->version); + gtk_widget_show (priv->version_label); + } else - name_string = g_markup_printf_escaped ("<span size=\"xx-large\" weight=\"bold\">%s</span>", - priv->name); + gtk_widget_hide (priv->version_label); + name_string = g_markup_printf_escaped ("<span weight=\"bold\">%s</span>", + priv->name); gtk_label_set_markup (GTK_LABEL (priv->name_label), name_string); - g_free (name_string); } @@ -1187,16 +1308,18 @@ gtk_about_dialog_set_license (GtkAboutDialog *about, { priv->license = g_strdup (license); priv->license_type = GTK_LICENSE_CUSTOM; - gtk_widget_show (priv->license_button); } else { priv->license = NULL; priv->license_type = GTK_LICENSE_UNKNOWN; - gtk_widget_hide (priv->license_button); } g_free (tmp); + gtk_widget_hide (priv->license_label); + + update_license_button_visibility (about); + g_object_notify (G_OBJECT (about), "license"); g_object_notify (G_OBJECT (about), "license-type"); } @@ -1380,24 +1503,6 @@ gtk_about_dialog_get_authors (GtkAboutDialog *about) return (const gchar * const *) priv->authors; } -static void -update_credits_button_visibility (GtkAboutDialog *about) -{ - GtkAboutDialogPrivate *priv = about->priv; - gboolean show; - - show = priv->authors != NULL || - priv->documenters != NULL || - priv->artists != NULL || - (priv->translator_credits != NULL && - strcmp (priv->translator_credits, "translator_credits") && - strcmp (priv->translator_credits, "translator-credits")); - if (show) - gtk_widget_show (priv->credits_button); - else - gtk_widget_hide (priv->credits_button); -} - /** * gtk_about_dialog_set_authors: * @about: a #GtkAboutDialog @@ -1955,7 +2060,6 @@ text_view_visibility_notify_event (GtkWidget *text_view, static GtkWidget * text_view_new (GtkAboutDialog *about, - GtkWidget *dialog, gchar **strings, GtkWrapMode wrap_mode) { @@ -1969,6 +2073,8 @@ text_view_new (GtkAboutDialog *about, GdkColor color; GdkColor link_color; GdkColor visited_link_color; + gint size; + PangoFontDescription *font_desc; GtkAboutDialogPrivate *priv = about->priv; @@ -2000,6 +2106,12 @@ text_view_new (GtkAboutDialog *about, gtk_text_view_set_editable (text_view, FALSE); gtk_text_view_set_wrap_mode (text_view, wrap_mode); + size = pango_font_description_get_size (gtk_widget_get_style (view)->font_desc); + font_desc = pango_font_description_new (); + pango_font_description_set_size (font_desc, size * PANGO_SCALE_SMALL); + gtk_widget_modify_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); @@ -2051,7 +2163,7 @@ text_view_new (GtkAboutDialog *about, if (*q1 == '<') { - gtk_text_buffer_insert_at_cursor (buffer, q0, (q1 - q0) + 1); + gtk_text_buffer_insert_at_cursor (buffer, q0, q1 - q0 + 1); gtk_text_buffer_get_end_iter (buffer, &end); q1++; link_type = "email"; @@ -2109,81 +2221,153 @@ text_view_new (GtkAboutDialog *about, } static void -add_credits_page (GtkAboutDialog *about, - GtkWidget *credits_dialog, - GtkWidget *notebook, - gchar *title, - gchar **people) +add_credits_section (GtkAboutDialog *about, + GtkGrid *grid, + gint *row, + gchar *title, + gchar **people) { - GtkWidget *sw, *view; + GtkWidget *label; + gchar *markup; + gchar **p; + gchar *q0, *q1, *q2, *r1, *r2; - view = text_view_new (about, credits_dialog, people, GTK_WRAP_NONE); + if (people == NULL) + return; - sw = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (sw), view); + markup = g_strdup_printf ("<span size=\"small\">%s</span>", title); + label = gtk_label_new (markup); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + g_free (markup); + gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5); + gtk_grid_attach (grid, label, 0, *row, 1, 1); - gtk_notebook_append_page (GTK_NOTEBOOK (notebook), - sw, gtk_label_new (title)); -} + for (p = people; *p; p++) + { + GString *str; -static void -display_credits_dialog (GtkWidget *button, - gpointer data) -{ - GtkAboutDialog *about = (GtkAboutDialog *)data; - GtkAboutDialogPrivate *priv = about->priv; - GtkWidget *dialog, *notebook; - GtkDialog *credits_dialog; - GtkWidget *content_area; - GtkWidget *action_area; + str = g_string_new ("<span size=\"small\">"); - if (priv->credits_dialog != NULL) - { - gtk_window_present (GTK_WINDOW (priv->credits_dialog)); - return; - } + q0 = *p; + while (*q0) + { + q1 = strchr (q0, '<'); + q2 = q1 ? strchr (q1, '>') : NULL; + r1 = strstr (q0, "http://"); + if (r1) + { + r2 = strpbrk (r1, " \n\t"); + if (!r2) + r2 = strchr (r1, '\0'); + } + else + r2 = NULL; - dialog = gtk_dialog_new_with_buttons (_("Credits"), - GTK_WINDOW (about), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, - NULL); - credits_dialog = GTK_DIALOG (dialog); + if (r1 && r2 && (!q1 || !q2 || (r1 < q1))) + { + q1 = r1; + q2 = r2; + } + else if (q1 && (q1[1] == 'a' || q1[1] == 'A') && q1[2] == ' ') + { + /* if it is a <a> link leave it for the label to parse */ + q1 = NULL; + } - content_area = gtk_dialog_get_content_area (credits_dialog); - action_area = gtk_dialog_get_action_area (credits_dialog); + if (q1 && q2) + { + gchar *link; + gchar *text; - gtk_container_set_border_width (GTK_CONTAINER (credits_dialog), 5); - gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */ - gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); + if (*q1 == '<') + { + /* email */ + gchar *escaped; - priv->credits_dialog = dialog; - gtk_window_set_default_size (GTK_WINDOW (dialog), 360, 260); - gtk_dialog_set_default_response (credits_dialog, GTK_RESPONSE_CANCEL); + text = g_strstrip (g_strndup (q0, q1 - q0)); + q1++; + link = g_strndup (q1, q2 - q1); + q2++; + escaped = g_uri_escape_string (link, NULL, FALSE); + g_string_append_printf (str, + "<a href=\"mailto:%s\">%s</a>", + escaped, + text); + g_free (escaped); + g_free (link); + g_free (text); + } + else + { + /* uri */ + text = g_strstrip (g_strndup (q0, q1 - q0)); + link = g_strndup (q1, q2 - q1); + g_string_append_printf (str, + "<a href=\"%s\">%s</a>", + link, + text); + g_free (link); + g_free (text); + } - gtk_window_set_modal (GTK_WINDOW (dialog), - gtk_window_get_modal (GTK_WINDOW (about))); + q0 = q2; + } + else + { + g_string_append (str, q0); + break; + } + } + g_string_append (str, "</span>"); + + label = gtk_label_new (str->str); + gtk_label_set_use_markup (GTK_LABEL (label), TRUE); + g_string_free (str, TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); + gtk_grid_attach (grid, label, 1, *row, 1, 1); + (*row)++; + } - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), dialog); - g_signal_connect (dialog, "destroy", - G_CALLBACK (gtk_widget_destroyed), - &(priv->credits_dialog)); + /* skip one at the end */ + (*row)++; +} - notebook = gtk_notebook_new (); - gtk_container_set_border_width (GTK_CONTAINER (notebook), 5); - gtk_box_pack_start (GTK_BOX (content_area), notebook, TRUE, TRUE, 0); +static void +create_credits_page (GtkAboutDialog *about) +{ + GtkAboutDialogPrivate *priv = about->priv; + GtkWidget *page_vbox; + GtkWidget *sw; + GtkWidget *grid; + GtkWidget *alignment; + gint row; + + page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); + gtk_widget_show (page_vbox); + priv->credits_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL); + + sw = gtk_scrolled_window_new (NULL, NULL); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_NONE); + gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), + GTK_POLICY_NEVER, + GTK_POLICY_AUTOMATIC); + gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0); + + alignment = gtk_alignment_new (0.5, 0, 0, 0); + gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (sw), alignment); + + grid = gtk_grid_new (); + gtk_container_set_border_width (GTK_CONTAINER (grid), 5); + gtk_orientable_set_orientation (GTK_ORIENTABLE (grid), GTK_ORIENTATION_VERTICAL); + gtk_grid_set_column_spacing (GTK_GRID (grid), 2); + gtk_grid_set_row_spacing (GTK_GRID (grid), 12); + gtk_container_add (GTK_CONTAINER (alignment), grid); if (priv->authors != NULL) - add_credits_page (about, dialog, notebook, _("Written by"), priv->authors); + add_credits_section (about, GTK_GRID (grid), &row, _("Created by"), priv->authors); if (priv->documenters != NULL) - add_credits_page (about, dialog, notebook, _("Documented by"), priv->documenters); + add_credits_section (about, GTK_GRID (grid), &row, _("Documented by"), priv->documenters); /* Don't show an untranslated gettext msgid */ if (priv->translator_credits != NULL && @@ -2195,86 +2379,68 @@ display_credits_dialog (GtkWidget *button, translators[0] = priv->translator_credits; translators[1] = NULL; - add_credits_page (about, dialog, notebook, _("Translated by"), translators); + add_credits_section (about, GTK_GRID (grid), &row, _("Translated by"), translators); } if (priv->artists != NULL) - add_credits_page (about, dialog, notebook, _("Artwork by"), priv->artists); + add_credits_section (about, GTK_GRID (grid), &row, _("Artwork by"), priv->artists); - gtk_widget_show_all (dialog); + gtk_widget_show_all (sw); } static void -set_policy (GtkWidget *sw) +display_credits_page (GtkWidget *button, + gpointer data) { - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); + GtkAboutDialog *about = (GtkAboutDialog *)data; + GtkAboutDialogPrivate *priv = about->priv; + + if (priv->credits_page == 0) + create_credits_page (about); + + switch_page (about, priv->credits_page); } static void -display_license_dialog (GtkWidget *button, - gpointer data) +create_license_page (GtkAboutDialog *about) { - GtkAboutDialog *about = (GtkAboutDialog *)data; GtkAboutDialogPrivate *priv = about->priv; - GtkWidget *dialog, *view, *sw; - GtkDialog *license_dialog; - GtkWidget *content_area; - GtkWidget *action_area; + GtkWidget *page_vbox; + GtkWidget *sw; + GtkWidget *view; gchar *strings[2]; - if (priv->license_dialog != NULL) - { - gtk_window_present (GTK_WINDOW (priv->license_dialog)); - return; - } - - dialog = gtk_dialog_new_with_buttons (_("License"), - GTK_WINDOW (about), - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_CLOSE, GTK_RESPONSE_CANCEL, - NULL); - license_dialog = GTK_DIALOG (dialog); - - content_area = gtk_dialog_get_content_area (license_dialog); - action_area = gtk_dialog_get_action_area (license_dialog); - - gtk_container_set_border_width (GTK_CONTAINER (license_dialog), 5); - gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */ - gtk_container_set_border_width (GTK_CONTAINER (action_area), 5); - - priv->license_dialog = dialog; - gtk_window_set_default_size (GTK_WINDOW (dialog), 420, 320); - gtk_dialog_set_default_response (license_dialog, GTK_RESPONSE_CANCEL); - - gtk_window_set_modal (GTK_WINDOW (dialog), - gtk_window_get_modal (GTK_WINDOW (about))); - - g_signal_connect (dialog, "response", - G_CALLBACK (gtk_widget_destroy), dialog); - g_signal_connect (dialog, "destroy", - G_CALLBACK (gtk_widget_destroyed), - &(priv->license_dialog)); + page_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 8); + priv->license_page = gtk_notebook_append_page (GTK_NOTEBOOK (priv->notebook), page_vbox, NULL); sw = gtk_scrolled_window_new (NULL, NULL); gtk_container_set_border_width (GTK_CONTAINER (sw), 5); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), - GTK_SHADOW_IN); + gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (sw), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - g_signal_connect (sw, "map", G_CALLBACK (set_policy), NULL); - gtk_box_pack_start (GTK_BOX (content_area), sw, TRUE, TRUE, 0); + GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_box_pack_start (GTK_BOX (page_vbox), sw, TRUE, TRUE, 0); strings[0] = priv->license; strings[1] = NULL; - view = text_view_new (about, dialog, strings, + view = text_view_new (about, strings, priv->wrap_license ? GTK_WRAP_WORD : GTK_WRAP_NONE); gtk_container_add (GTK_CONTAINER (sw), view); - gtk_widget_show_all (dialog); + gtk_widget_show_all (page_vbox); +} + +static void +display_license_page (GtkWidget *button, + gpointer data) +{ + GtkAboutDialog *about = (GtkAboutDialog *)data; + GtkAboutDialogPrivate *priv = about->priv; + + if (priv->license_page == 0) + create_license_page (about); + + switch_page (about, priv->license_page); } /** @@ -2297,22 +2463,8 @@ gtk_about_dialog_new (void) static void close_cb (GtkAboutDialog *about) { - GtkAboutDialogPrivate *priv = about->priv; - - if (priv->license_dialog != NULL) - { - gtk_widget_destroy (priv->license_dialog); - priv->license_dialog = NULL; - } - - if (priv->credits_dialog != NULL) - { - gtk_widget_destroy (priv->credits_dialog); - priv->credits_dialog = NULL; - } - + switch_page (about, 0); gtk_widget_hide (GTK_WIDGET (about)); - } /** @@ -2360,6 +2512,7 @@ gtk_show_about_dialog (GtkWindow *parent, if (parent) { + gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); gtk_window_set_transient_for (GTK_WINDOW (dialog), parent); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); g_object_set_data_full (G_OBJECT (parent), @@ -2409,37 +2562,35 @@ gtk_about_dialog_set_license_type (GtkAboutDialog *about, if (priv->license_type != GTK_LICENSE_CUSTOM) { const gchar *url; + gchar *license_string; GString *str; url = gtk_license_urls[priv->license_type]; if (url == NULL) url = priv->website_url; - /* compose the new license string as: - * - * <program-name>\n - * <copyright line 1>\n - * ... - * <copyright line n>\n - * \n - * license preamble + URL - * - */ str = g_string_sized_new (256); - g_string_append (str, priv->name); - g_string_append (str, "\n"); - g_string_append (str, priv->copyright); - g_string_append (str, "\n\n"); - g_string_append_printf (str, _(gtk_license_preamble), url); + g_string_append_printf (str, _(gtk_license_preamble), url, url); g_free (priv->license); priv->license = g_string_free (str, FALSE); priv->wrap_license = TRUE; - gtk_widget_show (priv->license_button); + + license_string = g_strdup_printf ("<span size=\"small\">%s</span>", + priv->license); + gtk_label_set_markup (GTK_LABEL (priv->license_label), license_string); + g_free (license_string); + gtk_widget_show (priv->license_label); + + update_license_button_visibility (about); g_object_notify (G_OBJECT (about), "wrap-license"); g_object_notify (G_OBJECT (about), "license"); } + else + { + gtk_widget_show (priv->license_label); + } g_object_notify (G_OBJECT (about), "license-type"); diff --git a/gtk/gtkbuilder.c b/gtk/gtkbuilder.c index 97b0053da3..faa3ef79ad 100644 --- a/gtk/gtkbuilder.c +++ b/gtk/gtkbuilder.c @@ -913,7 +913,7 @@ gtk_builder_add_from_file (GtkBuilder *builder, * gtk_builder_add_objects_from_file: * @builder: a #GtkBuilder * @filename: the name of the file to parse - * @object_ids: nul-terminated array of objects to build + * @object_ids: (array zero-terminated=1) (element-type utf8): nul-terminated array of objects to build * @error: (allow-none): return location for an error, or %NULL * * Parses a file containing a <link linkend="BUILDER-UI">GtkBuilder diff --git a/gtk/gtkcalendar.c b/gtk/gtkcalendar.c index 57a26d6d7e..1836ef88b6 100644 --- a/gtk/gtkcalendar.c +++ b/gtk/gtkcalendar.c @@ -3379,19 +3379,19 @@ gtk_calendar_drag_motion (GtkWidget *widget, { GtkCalendarPrivate *priv = GTK_CALENDAR_GET_PRIVATE (widget); GdkAtom target; - - if (!priv->drag_highlight) + + if (!priv->drag_highlight) { priv->drag_highlight = 1; gtk_drag_highlight (widget); } - + target = gtk_drag_dest_find_target (widget, context, NULL); - if (target == GDK_NONE || context->suggested_action == 0) + if (target == GDK_NONE || gdk_drag_context_get_suggested_action (context) == 0) gdk_drag_status (context, 0, time); else { - set_status_pending (context, context->suggested_action); + set_status_pending (context, gdk_drag_context_get_suggested_action (context)); gtk_drag_get_data (widget, context, target, time); } diff --git a/gtk/gtkcellrendererpixbuf.c b/gtk/gtkcellrendererpixbuf.c index 729d08a89d..8a191d981a 100644 --- a/gtk/gtkcellrendererpixbuf.c +++ b/gtk/gtkcellrendererpixbuf.c @@ -481,10 +481,9 @@ gtk_cell_renderer_pixbuf_create_stock_pixbuf (GtkCellRendererPixbuf *cellpixbuf, if (priv->pixbuf) g_object_unref (priv->pixbuf); - priv->pixbuf = gtk_widget_render_icon (widget, - priv->stock_id, - priv->stock_size, - priv->stock_detail); + priv->pixbuf = gtk_widget_render_icon_pixbuf (widget, + priv->stock_id, + priv->stock_size); g_object_notify (G_OBJECT (cellpixbuf), "pixbuf"); } diff --git a/gtk/gtkclipboard.c b/gtk/gtkclipboard.c index 7273bd3944..245d1049e0 100644 --- a/gtk/gtkclipboard.c +++ b/gtk/gtkclipboard.c @@ -331,7 +331,10 @@ selection_get_cb (GtkWidget *widget, guint info, guint time) { - GtkClipboard *clipboard = gtk_widget_get_clipboard (widget, selection_data->selection); + GtkClipboard *clipboard; + + clipboard = gtk_widget_get_clipboard (widget, + gtk_selection_data_get_selection (selection_data)); if (clipboard && clipboard->get_func) clipboard->get_func (clipboard, selection_data, info, clipboard->user_data); @@ -863,8 +866,8 @@ selection_received (GtkWidget *widget, { RequestContentsInfo *request_info = get_request_contents_info (widget); set_request_contents_info (widget, NULL); - - request_info->callback (gtk_widget_get_clipboard (widget, selection_data->selection), + + request_info->callback (gtk_widget_get_clipboard (widget, gtk_selection_data_get_selection (selection_data)), selection_data, request_info->user_data); @@ -935,14 +938,16 @@ request_text_received_func (GtkClipboard *clipboard, * if we asked for compound_text and didn't get it, try string; * If we asked for anything else and didn't get it, give up. */ - if (selection_data->target == gdk_atom_intern_static_string ("UTF8_STRING")) + GdkAtom target = gtk_selection_data_get_target (selection_data); + + if (target == gdk_atom_intern_static_string ("UTF8_STRING")) { gtk_clipboard_request_contents (clipboard, gdk_atom_intern_static_string ("COMPOUND_TEXT"), request_text_received_func, info); return; } - else if (selection_data->target == gdk_atom_intern_static_string ("COMPOUND_TEXT")) + else if (target == gdk_atom_intern_static_string ("COMPOUND_TEXT")) { gtk_clipboard_request_contents (clipboard, GDK_TARGET_STRING, @@ -1000,8 +1005,8 @@ request_rich_text_received_func (GtkClipboard *clipboard, guint8 *result = NULL; gsize length = 0; - result = selection_data->data; - length = selection_data->length; + result = (guint8 *) gtk_selection_data_get_data (selection_data); + length = gtk_selection_data_get_length (selection_data); info->current_atom++; @@ -1013,7 +1018,8 @@ request_rich_text_received_func (GtkClipboard *clipboard, return; } - info->callback (clipboard, selection_data->target, result, length, + info->callback (clipboard, gtk_selection_data_get_target (selection_data), + result, length, info->user_data); g_free (info->atoms); g_free (info); @@ -1081,21 +1087,23 @@ request_image_received_func (GtkClipboard *clipboard, * if we asked for image/gif and didn't get it, try image/bmp; * If we asked for anything else and didn't get it, give up. */ - if (selection_data->target == gdk_atom_intern_static_string ("image/png")) + GdkAtom target = gtk_selection_data_get_target (selection_data); + + if (target == gdk_atom_intern_static_string ("image/png")) { gtk_clipboard_request_contents (clipboard, gdk_atom_intern_static_string ("image/jpeg"), request_image_received_func, info); return; } - else if (selection_data->target == gdk_atom_intern_static_string ("image/jpeg")) + else if (target == gdk_atom_intern_static_string ("image/jpeg")) { gtk_clipboard_request_contents (clipboard, gdk_atom_intern_static_string ("image/gif"), request_image_received_func, info); return; } - else if (selection_data->target == gdk_atom_intern_static_string ("image/gif")) + else if (target == gdk_atom_intern_static_string ("image/gif")) { gtk_clipboard_request_contents (clipboard, gdk_atom_intern_static_string ("image/bmp"), @@ -1276,7 +1284,7 @@ clipboard_received_func (GtkClipboard *clipboard, { WaitResults *results = data; - if (selection_data->length >= 0) + if (gtk_selection_data_get_length (selection_data) >= 0) results->data = gtk_selection_data_copy (selection_data); g_main_loop_quit (results->loop); diff --git a/gtk/gtkcolorbutton.c b/gtk/gtkcolorbutton.c index c363f3aa26..9afc7542f2 100644 --- a/gtk/gtkcolorbutton.c +++ b/gtk/gtkcolorbutton.c @@ -350,22 +350,25 @@ gtk_color_button_drag_data_received (GtkWidget *widget, guint32 time, GtkColorButton *color_button) { + gint length; guint16 *dropped; - if (selection_data->length < 0) + length = gtk_selection_data_get_length (selection_data); + + if (length < 0) return; /* We accept drops with the wrong format, since the KDE color * chooser incorrectly drops application/x-color with format 8. */ - if (selection_data->length != 8) + if (length != 8) { g_warning (_("Received invalid color data\n")); return; } - dropped = (guint16 *)selection_data->data; + dropped = (guint16 *) gtk_selection_data_get_data (selection_data); color_button->priv->rgba.red = dropped[0] / 65535.; color_button->priv->rgba.green = dropped[1] / 65535.; @@ -428,7 +431,8 @@ gtk_color_button_drag_data_get (GtkWidget *widget, dropped[2] = (guint16) (color_button->priv->rgba.blue * 65535); dropped[3] = (guint16) (color_button->priv->rgba.alpha * 65535); - gtk_selection_data_set (selection_data, selection_data->target, + gtk_selection_data_set (selection_data, + gtk_selection_data_get_target (selection_data), 16, (guchar *)dropped, 8); } @@ -721,7 +725,7 @@ gtk_color_button_set_alpha (GtkColorButton *color_button, /** * gtk_color_button_get_color: * @color_button: a #GtkColorButton. - * @color: a #GdkColor to fill in with the current color. + * @color: (out): a #GdkColor to fill in with the current color. * * Sets @color to be the current color in the #GtkColorButton widget. * @@ -780,7 +784,7 @@ gtk_color_button_set_rgba (GtkColorButton *color_button, /** * gtk_color_button_get_rgba: * @color_button: a #GtkColorButton. - * @rgba: a #GdkRGBA to fill in with the current color + * @rgba: (out): a #GdkRGBA to fill in with the current color * * Sets @rgba to be the current color in the #GtkColorButton widget. * diff --git a/gtk/gtkcolorsel.c b/gtk/gtkcolorsel.c index 2ed64827af..d0debfca3c 100644 --- a/gtk/gtkcolorsel.c +++ b/gtk/gtkcolorsel.c @@ -808,6 +808,7 @@ color_sample_drop_handle (GtkWidget *widget, { GtkColorSelection *colorsel = data; GtkColorSelectionPrivate *priv; + gint length; guint16 *vals; gdouble color[4]; priv = colorsel->private_data; @@ -818,21 +819,23 @@ color_sample_drop_handle (GtkWidget *widget, * B * opacity */ - - if (selection_data->length < 0) + + length = gtk_selection_data_get_length (selection_data); + + if (length < 0) return; /* We accept drops with the wrong format, since the KDE color * chooser incorrectly drops application/x-color with format 8. */ - if (selection_data->length != 8) + if (length != 8) { g_warning ("Received invalid color data\n"); return; } - - vals = (guint16 *)selection_data->data; - + + vals = (guint16 *) gtk_selection_data_get_data (selection_data); + if (widget == priv->cur_sample) { color[0] = (gdouble)vals[0] / 0xffff; @@ -1533,23 +1536,26 @@ palette_drop_handle (GtkWidget *widget, gpointer data) { GtkColorSelection *colorsel = GTK_COLOR_SELECTION (data); + gint length; guint16 *vals; gdouble color[4]; - - if (selection_data->length < 0) + + length = gtk_selection_data_get_length (selection_data); + + if (length < 0) return; /* We accept drops with the wrong format, since the KDE color * chooser incorrectly drops application/x-color with format 8. */ - if (selection_data->length != 8) + if (length != 8) { g_warning ("Received invalid color data\n"); return; } - - vals = (guint16 *)selection_data->data; - + + vals = (guint16 *) gtk_selection_data_get_data (selection_data); + color[0] = (gdouble)vals[0] / 0xffff; color[1] = (gdouble)vals[1] / 0xffff; color[2] = (gdouble)vals[2] / 0xffff; diff --git a/gtk/gtkcomboboxtext.c b/gtk/gtkcomboboxtext.c index c7b82d1063..4e67c6c1c1 100644 --- a/gtk/gtkcomboboxtext.c +++ b/gtk/gtkcomboboxtext.c @@ -265,6 +265,7 @@ gtk_combo_box_text_insert (GtkComboBoxText *combo_box, store = GTK_LIST_STORE (gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box))); g_return_if_fail (GTK_IS_LIST_STORE (store)); text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box)); + g_return_if_fail (text_column >= 0); column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), text_column); g_return_if_fail (column_type == G_TYPE_STRING); @@ -276,6 +277,7 @@ gtk_combo_box_text_insert (GtkComboBoxText *combo_box, gint id_column; id_column = gtk_combo_box_get_id_column (GTK_COMBO_BOX (combo_box)); + g_return_if_fail (id_column >= 0); column_type = gtk_tree_model_get_column_type (GTK_TREE_MODEL (store), id_column); g_return_if_fail (column_type == G_TYPE_STRING); @@ -359,6 +361,7 @@ gtk_combo_box_text_get_active_text (GtkComboBoxText *combo_box) model = gtk_combo_box_get_model (GTK_COMBO_BOX (combo_box)); g_return_val_if_fail (GTK_IS_LIST_STORE (model), NULL); text_column = gtk_combo_box_get_entry_text_column (GTK_COMBO_BOX (combo_box)); + g_return_val_if_fail (text_column >= 0, NULL); column_type = gtk_tree_model_get_column_type (model, text_column); g_return_val_if_fail (column_type == G_TYPE_STRING, NULL); gtk_tree_model_get (model, &iter, text_column, &text, -1); diff --git a/gtk/gtkcssprovider.c b/gtk/gtkcssprovider.c index 5faa07666c..1ea5ed9ae2 100644 --- a/gtk/gtkcssprovider.c +++ b/gtk/gtkcssprovider.c @@ -1150,7 +1150,7 @@ compare_selector (GtkWidgetPath *path, SelectorPath *selector) { GSList *elements = selector->elements; - gboolean match = TRUE; + gboolean match = TRUE, first = TRUE, first_match = FALSE; guint64 score = 0; gint i; @@ -1165,6 +1165,9 @@ compare_selector (GtkWidgetPath *path, match = compare_selector_element (path, i, elem, &elem_score); + if (match && first) + first_match = TRUE; + /* Only move on to the next index if there is no match * with the current element (whether to continue or not * handled right after in the combinator check), or a @@ -1197,6 +1200,8 @@ compare_selector (GtkWidgetPath *path, score <<= 4; score |= elem_score; } + + first = FALSE; } /* If there are pending selector @@ -1208,6 +1213,13 @@ compare_selector (GtkWidgetPath *path, if (!match) score = 0; + else if (first_match) + { + /* Assign more weight to these selectors + * that matched right from the first element. + */ + score <<= 4; + } return score; } @@ -3577,6 +3589,15 @@ gtk_css_provider_get_default (void) "@define-color tooltip_bg_color #eee1b3; \n" "@define-color tooltip_fg_color #000; \n" "\n" + "@define-color info_fg_color rgb (181, 171, 156);\n" + "@define-color info_bg_color rgb (252, 252, 189);\n" + "@define-color warning_fg_color rgb (173, 120, 41);\n" + "@define-color warning_bg_color rgb (250, 173, 61);\n" + "@define-color question_fg_color rgb (97, 122, 214);\n" + "@define-color question_bg_color rgb (138, 173, 212);\n" + "@define-color error_fg_color rgb (166, 38, 38);\n" + "@define-color error_bg_color rgb (237, 54, 54);\n" + "\n" "*,\n" "GtkTreeView > GtkButton {\n" " background-color: @bg_color;\n" @@ -3596,8 +3617,16 @@ gtk_css_provider_get_default (void) " color: @selected_fg_color;\n" "}\n" "\n" + ".expander {\n" + " color: #fff;\n" + "}\n" + "\n" ".expander:prelight {\n" - " color: @selected_fg_color\n" + " color: @text_color;\n" + "}\n" + "\n" + ".expander:active {\n" + " transition: 300ms linear;\n" "}\n" "\n" "*:insensitive {\n" @@ -3772,10 +3801,33 @@ gtk_css_provider_get_default (void) ".spinner:active {\n" " transition: 750ms linear loop;\n" "}\n" + "\n" + ".info {\n" + " background-color: @info_bg_color;\n" + " color: @info_fg_color;\n" + "}\n" + "\n" + ".warning {\n" + " background-color: @warning_bg_color;\n" + " color: @warning_fg_color;\n" + "}\n" + "\n" + ".question {\n" + " background-color: @question_bg_color;\n" + " color: @question_fg_color;\n" + "}\n" + "\n" + ".error {\n" + " background-color: @error_bg_color;\n" + " color: @error_fg_color;\n" + "}\n" "\n"; provider = gtk_css_provider_new (); - gtk_css_provider_load_from_data (provider, str, -1, NULL); + if (!gtk_css_provider_load_from_data (provider, str, -1, NULL)) + { + g_error ("Failed to load the internal default CSS."); + } } return provider; @@ -3856,6 +3908,8 @@ gtk_css_provider_get_named (const gchar *name, } } + g_free (subpath); + if (path) { GError *error = NULL; diff --git a/gtk/gtkdnd-quartz.c b/gtk/gtkdnd-quartz.c index 687f1aa606..0f35cbadfc 100644 --- a/gtk/gtkdnd-quartz.c +++ b/gtk/gtkdnd-quartz.c @@ -1566,8 +1566,8 @@ set_icon_stock_pixbuf (GdkDragContext *context, if (stock_id) { - pixbuf = gtk_widget_render_icon (info->widget, stock_id, - GTK_ICON_SIZE_DND, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (info->widget, stock_id, + GTK_ICON_SIZE_DND, NULL); if (!pixbuf) { diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 08496d5761..b6e9ea0d2b 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -981,7 +981,6 @@ gtk_drag_get_data (GtkWidget *widget, g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (!context->is_source); selection_widget = gtk_drag_get_ipc_widget (widget); @@ -1016,14 +1015,13 @@ gtk_drag_get_source_widget (GdkDragContext *context) GSList *tmp_list; g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), NULL); - g_return_val_if_fail (!context->is_source, NULL); tmp_list = source_widgets; while (tmp_list) { GtkWidget *ipc_widget = tmp_list->data; - if (gtk_widget_get_window (ipc_widget) == context->source_window) + if (gtk_widget_get_window (ipc_widget) == gdk_drag_context_get_source_window (context)) { GtkDragSourceInfo *info; info = g_object_get_data (G_OBJECT (ipc_widget), "gtk-info"); @@ -1057,13 +1055,12 @@ gtk_drag_finish (GdkDragContext *context, GdkAtom target = GDK_NONE; g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (!context->is_source); if (success && del) { target = gdk_atom_intern_static_string ("DELETE"); } - else if (context->protocol == GDK_DRAG_PROTO_MOTIF) + else if (gdk_drag_context_get_protocol (context) == GDK_DRAG_PROTO_MOTIF) { target = gdk_atom_intern_static_string (success ? "XmTRANSFER_SUCCESS" : @@ -1072,7 +1069,7 @@ gtk_drag_finish (GdkDragContext *context, if (target != GDK_NONE) { - GtkWidget *selection_widget = gtk_drag_get_ipc_widget_for_screen (gdk_window_get_screen (context->source_window)); + GtkWidget *selection_widget = gtk_drag_get_ipc_widget_for_screen (gdk_window_get_screen (gdk_drag_context_get_source_window (context))); g_object_ref (context); @@ -1639,7 +1636,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, else if (event->type == GDK_DROP_START && !info->proxy_source) { gdk_drop_reply (context, found, event->dnd.time); - if ((context->protocol == GDK_DRAG_PROTO_MOTIF) && !found) + if ((gdk_drag_context_get_protocol (context) == GDK_DRAG_PROTO_MOTIF) && !found) gtk_drag_finish (context, FALSE, FALSE, event->dnd.time); } } @@ -1657,7 +1654,7 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, * @target_list: (allow-none): list of droppable targets, or %NULL to use * gtk_drag_dest_get_target_list (@widget). * - * Looks for a match between @context->targets and the + * Looks for a match between the supported targets of @context and the * @dest_target_list, returning the first matching target, otherwise * returning %GDK_NONE. @dest_target_list should usually be the return * value from gtk_drag_dest_get_target_list(), but some widgets may @@ -1665,7 +1662,8 @@ _gtk_drag_dest_handle_event (GtkWidget *toplevel, * that case, they will have to implement a drag_motion handler that * passes the correct target list to this function. * - * Return value: first target that the source offers and the dest can accept, or %GDK_NONE + * Return value: first target that the source offers and the dest can + * accept, or %GDK_NONE **/ GdkAtom gtk_drag_dest_find_target (GtkWidget *widget, @@ -1678,7 +1676,6 @@ gtk_drag_dest_find_target (GtkWidget *widget, g_return_val_if_fail (GTK_IS_WIDGET (widget), GDK_NONE); g_return_val_if_fail (GDK_IS_DRAG_CONTEXT (context), GDK_NONE); - g_return_val_if_fail (!context->is_source, GDK_NONE); source_widget = gtk_drag_get_source_widget (context); @@ -1693,7 +1690,7 @@ gtk_drag_dest_find_target (GtkWidget *widget, while (tmp_target) { GtkTargetPair *pair = tmp_target->data; - tmp_source = context->targets; + tmp_source = gdk_drag_context_list_targets (context); while (tmp_source) { if (tmp_source->data == GUINT_TO_POINTER (pair->target)) @@ -1723,6 +1720,7 @@ gtk_drag_selection_received (GtkWidget *widget, GdkDragContext *context; GtkDragDestInfo *info; GtkWidget *drop_widget; + GdkAtom target; drop_widget = data; @@ -1730,23 +1728,24 @@ gtk_drag_selection_received (GtkWidget *widget, info = gtk_drag_get_dest_info (context, FALSE); if (info->proxy_data && - info->proxy_data->target == selection_data->target) + gtk_selection_data_get_target (info->proxy_data) == gtk_selection_data_get_target (selection_data)) { gtk_selection_data_set (info->proxy_data, - selection_data->type, - selection_data->format, - selection_data->data, - selection_data->length); + gtk_selection_data_get_data_type (selection_data), + gtk_selection_data_get_format (selection_data), + gtk_selection_data_get_data (selection_data), + gtk_selection_data_get_length (selection_data)); gtk_main_quit (); return; } - if (selection_data->target == gdk_atom_intern_static_string ("DELETE")) + target = gtk_selection_data_get_target (selection_data); + if (target == gdk_atom_intern_static_string ("DELETE")) { gtk_drag_finish (context, TRUE, FALSE, time); } - else if ((selection_data->target == gdk_atom_intern_static_string ("XmTRANSFER_SUCCESS")) || - (selection_data->target == gdk_atom_intern_static_string ("XmTRANSFER_FAILURE"))) + else if ((target == gdk_atom_intern_static_string ("XmTRANSFER_SUCCESS")) || + (target == gdk_atom_intern_static_string ("XmTRANSFER_FAILURE"))) { /* Do nothing */ } @@ -1761,11 +1760,11 @@ gtk_drag_selection_received (GtkWidget *widget, guint target_info; if (gtk_target_list_find (site->target_list, - selection_data->target, + target, &target_info)) { if (!(site->flags & GTK_DEST_DEFAULT_DROP) || - selection_data->length >= 0) + gtk_selection_data_get_length (selection_data) >= 0) g_signal_emit_by_name (drop_widget, "drag-data-received", context, info->drop_x, info->drop_y, @@ -1786,8 +1785,8 @@ gtk_drag_selection_received (GtkWidget *widget, { gtk_drag_finish (context, - (selection_data->length >= 0), - (context->action == GDK_ACTION_MOVE), + (gtk_selection_data_get_length (selection_data) >= 0), + (gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE), time); } @@ -1906,7 +1905,7 @@ gtk_drag_find_widget (GtkWidget *widget, } static void -gtk_drag_proxy_begin (GtkWidget *widget, +gtk_drag_proxy_begin (GtkWidget *widget, GtkDragDestInfo *dest_info, guint32 time) { @@ -1924,7 +1923,7 @@ gtk_drag_proxy_begin (GtkWidget *widget, ipc_widget = gtk_drag_get_ipc_widget (widget); context = gdk_drag_begin (gtk_widget_get_window (ipc_widget), - dest_info->context->targets); + gdk_drag_context_list_targets (dest_info->context)); source_info = gtk_drag_get_source_info (context, TRUE); @@ -1932,10 +1931,10 @@ gtk_drag_proxy_begin (GtkWidget *widget, source_info->widget = g_object_ref (widget); source_info->target_list = gtk_target_list_new (NULL, 0); - tmp_list = dest_info->context->targets; + tmp_list = gdk_drag_context_list_targets (dest_info->context); while (tmp_list) { - gtk_target_list_add (source_info->target_list, + gtk_target_list_add (source_info->target_list, GDK_POINTER_TO_ATOM (tmp_list->data), 0, 0); tmp_list = tmp_list->next; } @@ -2123,8 +2122,9 @@ gtk_drag_dest_motion (GtkWidget *widget, dest_window, proto, current_event->dnd.x_root, current_event->dnd.y_root, - context->suggested_action, - context->actions, time); + gdk_drag_context_get_suggested_action (context), + gdk_drag_context_get_actions (context), + time); if (!site->proxy_window && dest_window) g_object_unref (dest_window); @@ -2141,8 +2141,8 @@ gtk_drag_dest_motion (GtkWidget *widget, if (site->track_motion || site->flags & GTK_DEST_DEFAULT_MOTION) { - if (context->suggested_action & site->actions) - action = context->suggested_action; + if (gdk_drag_context_get_suggested_action (context) & site->actions) + action = gdk_drag_context_get_suggested_action (context); else { gint i; @@ -2150,7 +2150,7 @@ gtk_drag_dest_motion (GtkWidget *widget, for (i = 0; i < 8; i++) { if ((site->actions & (1 << i)) && - (context->actions & (1 << i))) + (gdk_drag_context_get_actions (context) & (1 << i))) { action = (1 << i); break; @@ -2205,7 +2205,7 @@ gtk_drag_dest_drop (GtkWidget *widget, if (site->do_proxy) { if (info->proxy_source || - (info->context->protocol == GDK_DRAG_PROTO_ROOTWIN)) + (gdk_drag_context_get_protocol (info->context) == GDK_DRAG_PROTO_ROOTWIN)) { gtk_drag_drop (info->proxy_source, time); } @@ -2245,8 +2245,9 @@ gtk_drag_dest_drop (GtkWidget *widget, dest_window, proto, current_event->dnd.x_root, current_event->dnd.y_root, - context->suggested_action, - context->actions, time); + gdk_drag_context_get_suggested_action (context), + gdk_drag_context_get_actions (context), + time); if (!site->proxy_window && dest_window) g_object_unref (dest_window); @@ -3024,7 +3025,6 @@ gtk_drag_set_icon_widget (GdkDragContext *context, gint hot_y) { g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->is_source); g_return_if_fail (GTK_IS_WIDGET (widget)); gtk_drag_set_icon_window (context, widget, hot_x, hot_y, FALSE); @@ -3097,7 +3097,7 @@ set_icon_stock_pixbuf (GdkDragContext *context, g_return_if_fail (pixbuf != NULL || stock_id != NULL); g_return_if_fail (pixbuf == NULL || stock_id == NULL); - screen = gdk_window_get_screen (context->source_window); + screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DND); @@ -3109,8 +3109,8 @@ set_icon_stock_pixbuf (GdkDragContext *context, if (stock_id) { - pixbuf = gtk_widget_render_icon (window, stock_id, - GTK_ICON_SIZE_DND, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (window, stock_id, + GTK_ICON_SIZE_DND); if (!pixbuf) { @@ -3123,7 +3123,7 @@ set_icon_stock_pixbuf (GdkDragContext *context, else g_object_ref (pixbuf); - display = gdk_window_get_display (context->source_window); + display = gdk_window_get_display (gdk_drag_context_get_source_window (context)); width = gdk_pixbuf_get_width (pixbuf); height = gdk_pixbuf_get_height (pixbuf); @@ -3173,7 +3173,6 @@ gtk_drag_set_icon_pixbuf (GdkDragContext *context, gint hot_y) { g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->is_source); g_return_if_fail (GDK_IS_PIXBUF (pixbuf)); set_icon_stock_pixbuf (context, NULL, pixbuf, hot_x, hot_y, FALSE); @@ -3196,7 +3195,6 @@ gtk_drag_set_icon_stock (GdkDragContext *context, gint hot_y) { g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->is_source); g_return_if_fail (stock_id != NULL); set_icon_stock_pixbuf (context, stock_id, NULL, hot_x, hot_y, FALSE); @@ -3264,13 +3262,12 @@ gtk_drag_set_icon_surface (GdkDragContext *context, cairo_pattern_t *pattern; g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->is_source); g_return_if_fail (surface != NULL); _gtk_cairo_surface_extents (surface, &extents); - screen = gdk_window_get_screen (context->source_window); + screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); window = gtk_window_new (GTK_WINDOW_POPUP); gtk_window_set_type_hint (GTK_WINDOW (window), GDK_WINDOW_TYPE_HINT_DND); @@ -3359,10 +3356,9 @@ gtk_drag_set_icon_name (GdkDragContext *context, gint width, height, icon_size; g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->is_source); g_return_if_fail (icon_name != NULL); - screen = gdk_window_get_screen (context->source_window); + screen = gdk_window_get_screen (gdk_drag_context_get_source_window (context)); g_return_if_fail (screen != NULL); settings = gtk_settings_get_for_screen (screen); @@ -3395,7 +3391,6 @@ void gtk_drag_set_icon_default (GdkDragContext *context) { g_return_if_fail (GDK_IS_DRAG_CONTEXT (context)); - g_return_if_fail (context->is_source); gtk_drag_set_icon_stock (context, GTK_STOCK_DND, -2, -2); } @@ -3438,7 +3433,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget, { if (info->proxy_dest->proxy_drop_wait) { - gboolean result = context->action != 0; + gboolean result = gdk_drag_context_get_selected_action (context) != 0; /* Aha - we can finally pass the MOTIF DROP on... */ gdk_drop_reply (info->proxy_dest->context, result, info->proxy_dest->proxy_drop_time); @@ -3450,7 +3445,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget, else { gdk_drag_status (info->proxy_dest->context, - event->dnd.context->action, + gdk_drag_context_get_selected_action (event->dnd.context), event->dnd.time); } } @@ -3458,7 +3453,7 @@ _gtk_drag_source_handle_event (GtkWidget *widget, else if (info->have_grab) { cursor = gtk_drag_get_cursor (gtk_widget_get_display (widget), - event->dnd.context->action, + gdk_drag_context_get_selected_action (event->dnd.context), info); if (info->cursor != cursor) { @@ -3528,7 +3523,7 @@ gtk_drag_source_check_selection (GtkDragSourceInfo *info, tmp_list = tmp_list->next; } - if (info->context->protocol == GDK_DRAG_PROTO_MOTIF) + if (gdk_drag_context_get_protocol (info->context) == GDK_DRAG_PROTO_MOTIF) { gtk_selection_add_target (info->ipc_widget, selection, @@ -3642,7 +3637,7 @@ static void gtk_drag_drop (GtkDragSourceInfo *info, guint32 time) { - if (info->context->protocol == GDK_DRAG_PROTO_ROOTWIN) + if (gdk_drag_context_get_protocol (info->context) == GDK_DRAG_PROTO_ROOTWIN) { GtkSelectionData selection_data; GList *tmp_list; @@ -3803,7 +3798,7 @@ gtk_drag_selection_get (GtkWidget *widget, info->proxy_dest->proxy_data = selection_data; gtk_drag_get_data (info->widget, info->proxy_dest->context, - selection_data->target, + gtk_selection_data_get_target (selection_data), time); gtk_main (); info->proxy_dest->proxy_data = NULL; @@ -3811,7 +3806,7 @@ gtk_drag_selection_get (GtkWidget *widget, else { if (gtk_target_list_find (info->target_list, - selection_data->target, + gtk_selection_data_get_target (selection_data), &target_info)) { g_signal_emit_by_name (info->widget, "drag-data-get", @@ -4330,7 +4325,8 @@ gtk_drag_button_release_cb (GtkWidget *widget, if (event->button != info->button) return FALSE; - if ((info->context->action != 0) && (info->context->dest_window != NULL)) + if ((gdk_drag_context_get_selected_action (info->context) != 0) && + (gdk_drag_context_get_dest_window (info->context) != NULL)) { gtk_drag_end (info, event->time); gtk_drag_drop (info, event->time); diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 4eb96a34e8..8463311fc0 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -353,8 +353,10 @@ static void gtk_entry_get_preferred_height (GtkWidget *widget, static void gtk_entry_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_entry_draw_frame (GtkWidget *widget, + GtkStyleContext *context, cairo_t *cr); static void gtk_entry_draw_progress (GtkWidget *widget, + GtkStyleContext *context, cairo_t *cr); static gint gtk_entry_draw (GtkWidget *widget, cairo_t *cr); @@ -377,8 +379,7 @@ static gint gtk_entry_focus_in (GtkWidget *widget, static gint gtk_entry_focus_out (GtkWidget *widget, GdkEventFocus *event); static void gtk_entry_grab_focus (GtkWidget *widget); -static void gtk_entry_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void gtk_entry_style_updated (GtkWidget *widget); static gboolean gtk_entry_query_tooltip (GtkWidget *widget, gint x, gint y, @@ -386,8 +387,8 @@ static gboolean gtk_entry_query_tooltip (GtkWidget *widget, GtkTooltip *tooltip); static void gtk_entry_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir); -static void gtk_entry_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gtk_entry_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state); static void gtk_entry_screen_changed (GtkWidget *widget, GdkScreen *old_screen); @@ -681,12 +682,12 @@ gtk_entry_class_init (GtkEntryClass *class) widget_class->focus_in_event = gtk_entry_focus_in; widget_class->focus_out_event = gtk_entry_focus_out; widget_class->grab_focus = gtk_entry_grab_focus; - widget_class->style_set = gtk_entry_style_set; + widget_class->style_updated = gtk_entry_style_updated; widget_class->query_tooltip = gtk_entry_query_tooltip; widget_class->drag_begin = gtk_entry_drag_begin; widget_class->drag_end = gtk_entry_drag_end; widget_class->direction_changed = gtk_entry_direction_changed; - widget_class->state_changed = gtk_entry_state_changed; + widget_class->state_flags_changed = gtk_entry_state_flags_changed; widget_class->screen_changed = gtk_entry_screen_changed; widget_class->mnemonic_activate = gtk_entry_mnemonic_activate; @@ -2309,10 +2310,9 @@ find_invisible_char (GtkWidget *widget) 0x273a /* SIXTEEN POINTED ASTERISK */ }; - if (gtk_widget_get_style (widget)) - gtk_widget_style_get (widget, - "invisible-char", &invisible_chars[0], - NULL); + gtk_widget_style_get (widget, + "invisible-char", &invisible_chars[0], + NULL); layout = gtk_widget_create_pango_layout (widget, NULL); @@ -2347,6 +2347,7 @@ find_invisible_char (GtkWidget *widget) static void gtk_entry_init (GtkEntry *entry) { + GtkStyleContext *context; GtkEntryPrivate *priv; entry->priv = G_TYPE_INSTANCE_GET_PRIVATE (entry, @@ -2393,6 +2394,8 @@ gtk_entry_init (GtkEntry *entry) g_signal_connect (priv->im_context, "delete-surrounding", G_CALLBACK (gtk_entry_delete_surrounding_cb), entry); + context = gtk_widget_get_style_context (GTK_WIDGET (entry)); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_ENTRY); } static gint @@ -2934,14 +2937,17 @@ _gtk_entry_get_borders (GtkEntry *entry, { GtkEntryPrivate *priv = entry->priv; GtkWidget *widget = GTK_WIDGET (entry); - GtkStyle *style; if (priv->has_frame) { - style = gtk_widget_get_style (widget); + GtkStyleContext *context; + GtkBorder padding; - *xborder = style->xthickness; - *yborder = style->ythickness; + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, 0, &padding); + + *xborder = padding.left; + *yborder = padding.top; } else { @@ -2967,14 +2973,20 @@ gtk_entry_get_preferred_width (GtkWidget *widget, gint xborder, yborder; GtkBorder inner_border; PangoContext *context; + GtkStyleContext *style_context; + GtkStateFlags state; gint icon_widths = 0; gint icon_width, i; gint width; gtk_widget_ensure_style (widget); 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, - gtk_widget_get_style (widget)->font_desc, + gtk_style_context_get_font (style_context, state), pango_context_get_language (context)); _gtk_entry_get_borders (entry, &xborder, &yborder); @@ -3017,13 +3029,19 @@ gtk_entry_get_preferred_height (GtkWidget *widget, PangoFontMetrics *metrics; gint xborder, yborder; GtkBorder inner_border; + GtkStyleContext *style_context; + GtkStateFlags state; PangoContext *context; gint height; gtk_widget_ensure_style (widget); 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, - gtk_widget_get_style (widget)->font_desc, + gtk_style_context_get_font (style_context, state), pango_context_get_language (context)); priv->ascent = pango_font_metrics_get_ascent (metrics); @@ -3375,15 +3393,14 @@ draw_icon (GtkWidget *widget, static void -gtk_entry_draw_frame (GtkWidget *widget, - cairo_t *cr) +gtk_entry_draw_frame (GtkWidget *widget, + GtkStyleContext *context, + cairo_t *cr) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = entry->priv; - GtkStyle *style; GdkWindow *window; gint x = 0, y = 0, width, height; - GtkStateType state; GtkAllocation allocation; gint frame_x, frame_y; @@ -3418,20 +3435,14 @@ gtk_entry_draw_frame (GtkWidget *widget, height -= 2 * priv->focus_width; } - style = gtk_widget_get_style (widget); - state = gtk_widget_get_state (widget); - - gtk_paint_flat_box (style, cr, - state, GTK_SHADOW_NONE, - widget, "entry_bg", - x, y, width, height); + gtk_render_background (context, cr, + x, y, width, height); if (priv->has_frame) - gtk_paint_shadow (style, cr, - state, priv->shadow_type, - widget, "entry", x, y, width, height); + gtk_render_frame (context, cr, + x, y, width, height); - gtk_entry_draw_progress (widget, cr); + gtk_entry_draw_progress (widget, context, cr); if (gtk_widget_has_focus (widget) && !priv->interior_focus) { @@ -3440,10 +3451,8 @@ gtk_entry_draw_frame (GtkWidget *widget, width += 2 * priv->focus_width; height += 2 * priv->focus_width; - gtk_paint_focus (style, cr, - gtk_widget_get_state (widget), - widget, "entry", - 0, 0, width, height); + gtk_render_focus (context, cr, + 0, 0, width, height); } cairo_restore (cr); @@ -3514,26 +3523,24 @@ get_progress_area (GtkWidget *widget, } static void -gtk_entry_draw_progress (GtkWidget *widget, - cairo_t *cr) +gtk_entry_draw_progress (GtkWidget *widget, + GtkStyleContext *context, + cairo_t *cr) { gint x, y, width, height; - GtkStateType state; get_progress_area (widget, &x, &y, &width, &height); if ((width <= 0) || (height <= 0)) return; - state = GTK_STATE_SELECTED; - if (!gtk_widget_get_sensitive (widget)) - state = GTK_STATE_INSENSITIVE; + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); + + gtk_render_activity (context, cr, + x, y, width, height); - gtk_paint_box (gtk_widget_get_style (widget), cr, - state, GTK_SHADOW_OUT, - widget, "entry-progress", - x, y, - width, height); + gtk_style_context_restore (context); } static gint @@ -3541,20 +3548,21 @@ gtk_entry_draw (GtkWidget *widget, cairo_t *cr) { GtkEntry *entry = GTK_ENTRY (widget); - GtkStyle *style; - GtkStateType state; + GtkStyleContext *context; + GtkStateFlags state; GtkEntryPrivate *priv = entry->priv; int i; - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); - state = gtk_widget_has_focus (widget) ? - GTK_STATE_ACTIVE : gtk_widget_get_state (widget); + if (gtk_widget_has_focus (widget)) + state |= GTK_STATE_FLAG_FOCUSED; if (gtk_cairo_should_draw_window (cr, gtk_widget_get_window (widget))) { /* Draw entry_bg, shadow, progress and focus */ - gtk_entry_draw_frame (widget, cr); + gtk_entry_draw_frame (widget, context, cr); /* Draw text and cursor */ cairo_save (cr); @@ -4309,8 +4317,8 @@ gtk_entry_direction_changed (GtkWidget *widget, } static void -gtk_entry_state_changed (GtkWidget *widget, - GtkStateType previous_state) +gtk_entry_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = entry->priv; @@ -4508,8 +4516,7 @@ icon_margin_changed (GtkEntry *entry) } static void -gtk_entry_style_set (GtkWidget *widget, - GtkStyle *previous_style) +gtk_entry_style_updated (GtkWidget *widget) { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = entry->priv; @@ -5596,7 +5603,9 @@ get_layout_position (GtkEntry *entry, } static void -draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color) +draw_text_with_color (GtkEntry *entry, + cairo_t *cr, + GdkRGBA *default_color) { GtkEntryPrivate *priv = entry->priv; PangoLayout *layout = gtk_entry_ensure_layout (entry, TRUE); @@ -5611,7 +5620,7 @@ draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color) get_layout_position (entry, &x, &y); cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, default_color); + gdk_cairo_set_source_rgba (cr, default_color); pango_cairo_show_layout (cr, layout); if (gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &start_pos, &end_pos)) @@ -5619,25 +5628,22 @@ draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color) gint *ranges; gint n_ranges, i; PangoRectangle logical_rect; - GdkColor *selection_color, *text_color; + GdkRGBA selection_color, text_color; GtkBorder inner_border; - GtkStyle *style; + GtkStyleContext *context; + GtkStateFlags state; + context = gtk_widget_get_style_context (widget); pango_layout_get_pixel_extents (layout, NULL, &logical_rect); gtk_entry_get_pixel_ranges (entry, &ranges, &n_ranges); - style = gtk_widget_get_style (widget); + state = GTK_STATE_FLAG_SELECTED; if (gtk_widget_has_focus (widget)) - { - selection_color = &style->base [GTK_STATE_SELECTED]; - text_color = &style->text [GTK_STATE_SELECTED]; - } - else - { - selection_color = &style->base [GTK_STATE_ACTIVE]; - text_color = &style->text [GTK_STATE_ACTIVE]; - } + state |= GTK_STATE_FLAG_FOCUSED; + + gtk_style_context_get_background_color (context, state, &selection_color); + gtk_style_context_get_color (context, state, &text_color); _gtk_entry_effective_inner_border (entry, &inner_border); @@ -5650,11 +5656,11 @@ draw_text_with_color (GtkEntry *entry, cairo_t *cr, GdkColor *default_color) cairo_clip (cr); - gdk_cairo_set_source_color (cr, selection_color); + gdk_cairo_set_source_rgba (cr, &selection_color); cairo_paint (cr); cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, text_color); + gdk_cairo_set_source_rgba (cr, &text_color); pango_cairo_show_layout (cr, layout); g_free (ranges); @@ -5668,9 +5674,9 @@ gtk_entry_draw_text (GtkEntry *entry, { GtkEntryPrivate *priv = entry->priv; GtkWidget *widget = GTK_WIDGET (entry); - GtkStateType state; - GtkStyle *style; - GdkColor text_color, bar_text_color; + GtkStateFlags state = 0; + GdkRGBA text_color, bar_text_color; + GtkStyleContext *context; gint pos_x, pos_y; gint width, height; gint progress_x, progress_y, progress_width, progress_height; @@ -5679,13 +5685,17 @@ gtk_entry_draw_text (GtkEntry *entry, /* Nothing to display at all */ if (gtk_entry_get_display_mode (entry) == DISPLAY_BLANK) return; - - state = GTK_STATE_SELECTED; - if (!gtk_widget_get_sensitive (widget)) - state = GTK_STATE_INSENSITIVE; - style = gtk_widget_get_style (widget); - text_color = style->text[gtk_widget_get_state (widget)]; - bar_text_color = style->fg[state]; + + state = gtk_widget_get_state_flags (widget); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_get_color (context, state, &text_color); + + /* Get foreground color for progressbars */ + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); + gtk_style_context_get_color (context, state, &bar_text_color); + gtk_style_context_restore (context); get_progress_area (widget, &progress_x, &progress_y, @@ -5698,7 +5708,7 @@ gtk_entry_draw_text (GtkEntry *entry, /* If the color is the same, or the progress area has a zero * size, then we only need to draw once. */ - if ((text_color.pixel == bar_text_color.pixel) || + if (gdk_rgba_equal (&text_color, &bar_text_color) || ((progress_width == 0) || (progress_height == 0))) { draw_text_with_color (entry, cr, &text_color); @@ -5869,10 +5879,18 @@ gtk_entry_draw_cursor (GtkEntry *entry, if (!block_at_line_end) { + GtkStyleContext *context; + GtkStateFlags state; + GdkRGBA color; + + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + gtk_style_context_get_background_color (context, state, &color); + gdk_cairo_rectangle (cr, &rect); cairo_clip (cr); cairo_move_to (cr, x, y); - gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); + gdk_cairo_set_source_rgba (cr, &color); pango_cairo_show_layout (cr, layout); } @@ -6634,15 +6652,13 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, case GTK_IMAGE_STOCK: state = gtk_widget_get_state_flags (widget); gtk_widget_set_state_flags (widget, 0, TRUE); - icon_info->pixbuf = gtk_widget_render_icon (widget, - icon_info->stock_id, - GTK_ICON_SIZE_MENU, - NULL); + icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget, + icon_info->stock_id, + GTK_ICON_SIZE_MENU); if (!icon_info->pixbuf) - icon_info->pixbuf = gtk_widget_render_icon (widget, - GTK_STOCK_MISSING_IMAGE, - GTK_ICON_SIZE_MENU, - NULL); + icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget, + GTK_STOCK_MISSING_IMAGE, + GTK_ICON_SIZE_MENU); gtk_widget_set_state_flags (widget, state, TRUE); break; @@ -6666,10 +6682,9 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, { state = gtk_widget_get_state_flags (widget); gtk_widget_set_state_flags (widget, 0, TRUE); - icon_info->pixbuf = gtk_widget_render_icon (widget, - GTK_STOCK_MISSING_IMAGE, - GTK_ICON_SIZE_MENU, - NULL); + icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget, + GTK_STOCK_MISSING_IMAGE, + GTK_ICON_SIZE_MENU); gtk_widget_set_state_flags (widget, state, TRUE); } } @@ -6700,10 +6715,9 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry, { state = gtk_widget_get_state_flags (widget); gtk_widget_set_state_flags (widget, 0, TRUE); - icon_info->pixbuf = gtk_widget_render_icon (widget, - GTK_STOCK_MISSING_IMAGE, - GTK_ICON_SIZE_MENU, - NULL); + icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget, + GTK_STOCK_MISSING_IMAGE, + GTK_ICON_SIZE_MENU); gtk_widget_set_state_flags (widget, state, TRUE); } } @@ -8975,15 +8989,17 @@ gtk_entry_drag_motion (GtkWidget *widget, { GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = entry->priv; - GtkStyle *style; + GtkStyleContext *style_context; GtkWidget *source_widget; GdkDragAction suggested_action; gint new_position, old_position; gint sel1, sel2; + GtkBorder padding; - style = gtk_widget_get_style (widget); - x -= style->xthickness; - y -= style->ythickness; + style_context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (style_context, 0, &padding); + x -= padding.left; + y -= padding.top; old_position = priv->dnd_position; new_position = gtk_entry_find_position (entry, x + priv->scroll_offset); @@ -8992,7 +9008,7 @@ gtk_entry_drag_motion (GtkWidget *widget, gtk_drag_dest_find_target (widget, context, NULL) != GDK_NONE) { source_widget = gtk_drag_get_source_widget (context); - suggested_action = context->suggested_action; + suggested_action = gdk_drag_context_get_suggested_action (context); if (!gtk_editable_get_selection_bounds (GTK_EDITABLE (entry), &sel1, &sel2) || new_position < sel1 || new_position > sel2) @@ -9002,7 +9018,7 @@ gtk_entry_drag_motion (GtkWidget *widget, /* Default to MOVE, unless the user has * pressed ctrl or alt to affect available actions */ - if ((context->actions & GDK_ACTION_MOVE) != 0) + if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0) suggested_action = GDK_ACTION_MOVE; } @@ -9043,14 +9059,16 @@ gtk_entry_drag_data_received (GtkWidget *widget, GtkEntry *entry = GTK_ENTRY (widget); GtkEntryPrivate *priv = entry->priv; GtkEditable *editable = GTK_EDITABLE (widget); - GtkStyle *style; + GtkStyleContext *style_context; + GtkBorder padding; gchar *str; str = (gchar *) gtk_selection_data_get_text (selection_data); - style = gtk_widget_get_style (widget); - x -= style->xthickness; - y -= style->ythickness; + style_context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (style_context, 0, &padding); + x -= padding.left; + y -= padding.top; if (str && priv->editable) { @@ -9079,7 +9097,7 @@ gtk_entry_drag_data_received (GtkWidget *widget, end_change (entry); } - gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time); + gtk_drag_finish (context, TRUE, gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE, time); } else { diff --git a/gtk/gtkexpander.c b/gtk/gtkexpander.c index 236ff279f6..f389bf043a 100644 --- a/gtk/gtkexpander.c +++ b/gtk/gtkexpander.c @@ -57,8 +57,6 @@ struct _GtkExpanderPrivate GdkWindow *event_window; gint spacing; - GtkExpanderStyle expander_style; - guint animation_timeout; guint expand_timer; guint expanded : 1; @@ -99,8 +97,8 @@ static gboolean gtk_expander_focus (GtkWidget *widget, GtkDirectionType direction); static void gtk_expander_grab_notify (GtkWidget *widget, gboolean was_grabbed); -static void gtk_expander_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gtk_expander_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state); static gboolean gtk_expander_drag_motion (GtkWidget *widget, GdkDragContext *context, gint x, @@ -179,7 +177,7 @@ gtk_expander_class_init (GtkExpanderClass *klass) widget_class->leave_notify_event = gtk_expander_leave_notify; widget_class->focus = gtk_expander_focus; widget_class->grab_notify = gtk_expander_grab_notify; - widget_class->state_changed = gtk_expander_state_changed; + widget_class->state_flags_changed = gtk_expander_state_flags_changed; widget_class->drag_motion = gtk_expander_drag_motion; widget_class->drag_leave = gtk_expander_drag_leave; widget_class->get_preferred_width = gtk_expander_get_preferred_width; @@ -297,9 +295,6 @@ gtk_expander_init (GtkExpander *expander) priv->event_window = NULL; priv->spacing = 0; - priv->expander_style = GTK_EXPANDER_COLLAPSED; - priv->animation_timeout = 0; - priv->expanded = FALSE; priv->use_underline = FALSE; priv->use_markup = FALSE; @@ -414,10 +409,10 @@ gtk_expander_destroy (GtkWidget *widget) { GtkExpanderPrivate *priv = GTK_EXPANDER (widget)->priv; - if (priv->animation_timeout) + if (priv->expand_timer) { - g_source_remove (priv->animation_timeout); - priv->animation_timeout = 0; + g_source_remove (priv->expand_timer); + priv->expand_timer = 0; } GTK_WIDGET_CLASS (gtk_expander_parent_class)->destroy (widget); @@ -723,6 +718,7 @@ gtk_expander_paint_prelight (GtkExpander *expander, cairo_t *cr) GtkContainer *container; GtkExpanderPrivate *priv; GdkRectangle area; + GtkStyleContext *context; gboolean interior_focus; int focus_width; int focus_pad; @@ -763,44 +759,59 @@ gtk_expander_paint_prelight (GtkExpander *expander, cairo_t *cr) area.height = MAX (area.height, expander_size + 2 * expander_spacing); area.height += !interior_focus ? (focus_width + focus_pad) * 2 : 0; - gtk_paint_flat_box (gtk_widget_get_style (widget), - cr, - GTK_STATE_PRELIGHT, - GTK_SHADOW_ETCHED_OUT, - widget, "expander", - area.x, area.y, - area.width, area.height); + context = gtk_widget_get_style_context (widget); + gtk_render_background (context, cr, + area.x, area.y, + area.width, area.height); } static void gtk_expander_paint (GtkExpander *expander, cairo_t *cr) { + GtkExpanderPrivate *priv = expander->priv; GtkWidget *widget; GdkRectangle clip; GtkAllocation allocation; - GtkStateType state; + GtkStyleContext *context; + GtkStateFlags state = 0; + gint size; widget = GTK_WIDGET (expander); + context = gtk_widget_get_style_context (widget); get_expander_bounds (expander, &clip); gtk_widget_get_allocation (widget, &allocation); - state = gtk_widget_get_state (widget); + gtk_style_context_save (context); + if (expander->priv->prelight) { - state = GTK_STATE_PRELIGHT; - + state = GTK_STATE_FLAG_PRELIGHT; + gtk_style_context_set_state (context, state); gtk_expander_paint_prelight (expander, cr); } - gtk_paint_expander (gtk_widget_get_style (widget), - cr, - state, - widget, - "expander", - clip.x + clip.width / 2 - allocation.x, - clip.y + clip.height / 2 - allocation.y, - expander->priv->expander_style); + gtk_widget_style_get (widget, "expander-size", &size, NULL); + + state = gtk_style_context_get_state (context); + + /* Set active flag as per the expanded state */ + if (priv->expanded) + state |= GTK_STATE_FLAG_ACTIVE; + + gtk_style_context_set_state (context, state); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER); + + /* The expander is the only animatable region */ + gtk_style_context_push_animatable_region (context, GUINT_TO_POINTER (1)); + + gtk_render_expander (context, cr, + clip.x - allocation.x, + clip.y - allocation.y, + size, size); + + gtk_style_context_pop_animatable_region (context); + gtk_style_context_restore (context); } static void @@ -810,6 +821,7 @@ gtk_expander_paint_focus (GtkExpander *expander, GtkWidget *widget; GtkExpanderPrivate *priv; GdkRectangle rect; + GtkStyleContext *context; gint x, y, width, height; gboolean interior_focus; gint border_width; @@ -882,11 +894,9 @@ gtk_expander_paint_focus (GtkExpander *expander, height = rect.height + 2 * focus_pad; } - gtk_paint_focus (gtk_widget_get_style (widget), - cr, - gtk_widget_get_state (widget), - widget, "expander", - x, y, width, height); + context = gtk_widget_get_style_context (widget); + gtk_render_focus (context, cr, + x, y, width, height); } static gboolean @@ -945,8 +955,8 @@ gtk_expander_grab_notify (GtkWidget *widget, } static void -gtk_expander_state_changed (GtkWidget *widget, - GtkStateType previous_state) +gtk_expander_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state) { if (!gtk_widget_is_sensitive (widget)) GTK_EXPANDER (widget)->priv->button_down = FALSE; @@ -1522,73 +1532,6 @@ gtk_expander_new_with_mnemonic (const gchar *label) NULL); } -static gboolean -gtk_expander_animation_timeout (GtkExpander *expander) -{ - GtkExpanderPrivate *priv = expander->priv; - GtkWidget *widget = GTK_WIDGET (expander); - GtkWidget *child; - GdkRectangle area; - gboolean finish = FALSE; - - if (gtk_widget_get_realized (widget)) - { - get_expander_bounds (expander, &area); - gdk_window_invalidate_rect (gtk_widget_get_window (widget), &area, TRUE); - } - - if (priv->expanded) - { - if (priv->expander_style == GTK_EXPANDER_COLLAPSED) - { - priv->expander_style = GTK_EXPANDER_SEMI_EXPANDED; - } - else - { - priv->expander_style = GTK_EXPANDER_EXPANDED; - finish = TRUE; - } - } - else - { - if (priv->expander_style == GTK_EXPANDER_EXPANDED) - { - priv->expander_style = GTK_EXPANDER_SEMI_COLLAPSED; - } - else - { - priv->expander_style = GTK_EXPANDER_COLLAPSED; - finish = TRUE; - } - } - - if (finish) - { - priv->animation_timeout = 0; - - child = gtk_bin_get_child (GTK_BIN (expander)); - if (child) - gtk_widget_set_child_visible (child, priv->expanded); - gtk_widget_queue_resize (widget); - } - - return !finish; -} - -static void -gtk_expander_start_animation (GtkExpander *expander) -{ - GtkExpanderPrivate *priv = expander->priv; - - if (priv->animation_timeout) - g_source_remove (priv->animation_timeout); - - priv->animation_timeout = - gdk_threads_add_timeout (50, - (GSourceFunc) gtk_expander_animation_timeout, - expander); -} - /** * gtk_expander_set_expanded: * @expander: a #GtkExpander @@ -1615,30 +1558,37 @@ gtk_expander_set_expanded (GtkExpander *expander, if (priv->expanded != expanded) { - GtkSettings *settings = gtk_widget_get_settings (GTK_WIDGET (expander)); - gboolean enable_animations; + GtkWidget *widget = GTK_WIDGET (expander); + GtkSettings *settings = gtk_widget_get_settings (widget); + GtkStyleContext *context; + gboolean enable_animations; + context = gtk_widget_get_style_context (widget); priv->expanded = expanded; g_object_get (settings, "gtk-enable-animations", &enable_animations, NULL); - if (enable_animations && gtk_widget_get_realized (GTK_WIDGET (expander))) - { - gtk_expander_start_animation (expander); - } - else + if (enable_animations && gtk_widget_get_realized (widget)) { - priv->expander_style = expanded ? GTK_EXPANDER_EXPANDED : - GTK_EXPANDER_COLLAPSED; - - child = gtk_bin_get_child (GTK_BIN (expander)); - if (child) - { - gtk_widget_set_child_visible (child, priv->expanded); - gtk_widget_queue_resize (GTK_WIDGET (expander)); - } + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_EXPANDER); + + gtk_style_context_notify_state_change (context, + gtk_widget_get_window (widget), + GUINT_TO_POINTER (1), + GTK_STATE_ACTIVE, + expanded); + gtk_style_context_restore (context); } + child = gtk_bin_get_child (GTK_BIN (expander)); + + if (child) + { + gtk_widget_set_child_visible (child, priv->expanded); + gtk_widget_queue_resize (widget); + } + g_object_notify (G_OBJECT (expander), "expanded"); } } diff --git a/gtk/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c index 3db63bf8d9..695664dc65 100644 --- a/gtk/gtkfilechooserbutton.c +++ b/gtk/gtkfilechooserbutton.c @@ -1041,7 +1041,7 @@ gtk_file_chooser_button_drag_data_received (GtkWidget *widget, data, type, drag_time); - if (widget == NULL || context == NULL || data == NULL || data->length < 0) + if (widget == NULL || context == NULL || data == NULL || gtk_selection_data_get_length (data) < 0) return; switch (type) diff --git a/gtk/gtkfilechooserdefault.c b/gtk/gtkfilechooserdefault.c index a3de75b65d..ef98afef50 100644 --- a/gtk/gtkfilechooserdefault.c +++ b/gtk/gtkfilechooserdefault.c @@ -1124,7 +1124,7 @@ set_preview_widget (GtkFileChooserDefault *impl, static GdkPixbuf * render_search_icon (GtkFileChooserDefault *impl) { - return gtk_widget_render_icon (GTK_WIDGET (impl), GTK_STOCK_FIND, GTK_ICON_SIZE_MENU, NULL); + return gtk_widget_render_icon_pixbuf (GTK_WIDGET (impl), GTK_STOCK_FIND, GTK_ICON_SIZE_MENU); } static GdkPixbuf * @@ -1144,7 +1144,7 @@ render_recent_icon (GtkFileChooserDefault *impl) /* fallback */ if (!retval) - retval = gtk_widget_render_icon (GTK_WIDGET (impl), GTK_STOCK_FILE, GTK_ICON_SIZE_MENU, NULL); + retval = gtk_widget_render_icon_pixbuf (GTK_WIDGET (impl), GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); return retval; } @@ -3075,11 +3075,11 @@ shortcuts_drag_motion_cb (GtkWidget *widget, } #endif - if (context->suggested_action == GDK_ACTION_COPY || - (context->actions & GDK_ACTION_COPY) != 0) + if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_COPY || + (gdk_drag_context_get_actions (context) & GDK_ACTION_COPY) != 0) action = GDK_ACTION_COPY; - else if (context->suggested_action == GDK_ACTION_MOVE || - (context->actions & GDK_ACTION_MOVE) != 0) + else if (gdk_drag_context_get_suggested_action (context) == GDK_ACTION_MOVE || + (gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0) action = GDK_ACTION_MOVE; else { @@ -3228,6 +3228,7 @@ shortcuts_drag_data_received_cb (GtkWidget *widget, GtkFileChooserDefault *impl; GtkTreePath *tree_path; GtkTreeViewDropPosition tree_pos; + GdkAtom target; int position; int bookmarks_index; @@ -3247,9 +3248,11 @@ shortcuts_drag_data_received_cb (GtkWidget *widget, g_assert (position >= bookmarks_index); position -= bookmarks_index; - if (gtk_targets_include_uri (&selection_data->target, 1)) + target = gtk_selection_data_get_target (selection_data); + + if (gtk_targets_include_uri (&target, 1)) shortcuts_drop_uris (impl, selection_data, position); - else if (selection_data->target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) + else if (target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) shortcuts_reorder (impl, position); g_signal_stop_emission_by_name (widget, "drag-data-received"); diff --git a/gtk/gtkiconfactory.c b/gtk/gtkiconfactory.c index 5b21c62fd6..c39574c23d 100644 --- a/gtk/gtkiconfactory.c +++ b/gtk/gtkiconfactory.c @@ -872,7 +872,7 @@ icon_size_lookup_intern (GtkSettings *settings, * modified by user preferences for a particular * #GtkSettings. Normally @size would be * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function - * isn't normally needed, gtk_widget_render_icon() is the usual + * isn't normally needed, gtk_widget_render_icon_pixbuf() is the usual * way to get an icon for rendering, then just look at the size of * the rendered pixbuf. The rendered pixbuf may not even correspond to * the width/height returned by gtk_icon_size_lookup(), because themes @@ -905,7 +905,7 @@ gtk_icon_size_lookup_for_settings (GtkSettings *settings, * (See gtk_icon_size_lookup_for_settings().) * Normally @size would be * #GTK_ICON_SIZE_MENU, #GTK_ICON_SIZE_BUTTON, etc. This function - * isn't normally needed, gtk_widget_render_icon() is the usual + * isn't normally needed, gtk_widget_render_icon_pixbuf() is the usual * way to get an icon for rendering, then just look at the size of * the rendered pixbuf. The rendered pixbuf may not even correspond to * the width/height returned by gtk_icon_size_lookup(), because themes @@ -1131,7 +1131,7 @@ static guint cache_serial = 0; * for a given size and state on request, and automatically caches * some of the rendered #GdkPixbuf objects. * - * Normally you would use gtk_widget_render_icon() instead of + * Normally you would use gtk_widget_render_icon_pixbuf() instead of * using #GtkIconSet directly. The one case where you'd use * #GtkIconSet is to create application-specific icon sets to place in * a #GtkIconFactory. @@ -1577,7 +1577,7 @@ render_fallback_image (GtkStyleContext *context, * means render at the size of the source and don't scale. * * Renders an icon using gtk_render_icon_pixbuf(). In most cases, - * gtk_widget_render_icon() is better, since it automatically provides + * gtk_widget_render_icon_pixbuf() is better, since it automatically provides * most of the arguments from the current widget settings. This * function never returns %NULL; if the icon can't be rendered * (perhaps because an image file fails to load), a default "missing diff --git a/gtk/gtkiconview.c b/gtk/gtkiconview.c index 243106e9fd..e4da1a0939 100644 --- a/gtk/gtkiconview.c +++ b/gtk/gtkiconview.c @@ -6825,7 +6825,7 @@ out: { GtkWidget *source_widget; - *suggested_action = context->suggested_action; + *suggested_action = gdk_drag_context_get_suggested_action (context); source_widget = gtk_drag_get_source_widget (context); if (source_widget == widget) @@ -6833,7 +6833,7 @@ out: /* Default to MOVE, unless the user has * pressed ctrl or shift to affect available actions */ - if ((context->actions & GDK_ACTION_MOVE) != 0) + if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0) *suggested_action = GDK_ACTION_MOVE; } @@ -7037,7 +7037,7 @@ gtk_icon_view_drag_data_get (GtkWidget *widget, goto done; /* If drag_data_get does nothing, try providing row data. */ - if (selection_data->target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) + if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) gtk_tree_set_row_drag_data (selection_data, model, source_row); @@ -7274,7 +7274,7 @@ gtk_icon_view_drag_data_received (GtkWidget *widget, if (dest_row == NULL) return; - if (selection_data->length >= 0) + if (gtk_selection_data_get_length (selection_data) >= 0) { if (gtk_tree_drag_dest_drag_data_received (GTK_TREE_DRAG_DEST (model), dest_row, @@ -7284,7 +7284,7 @@ gtk_icon_view_drag_data_received (GtkWidget *widget, gtk_drag_finish (context, accepted, - (context->action == GDK_ACTION_MOVE), + (gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE), time); gtk_tree_path_free (dest_row); diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c index 184451ef23..340b71cb7a 100644 --- a/gtk/gtkimage.c +++ b/gtk/gtkimage.c @@ -1485,10 +1485,9 @@ ensure_pixbuf_for_icon_name (GtkImage *image, if (priv->data.name.pixbuf == NULL) { priv->data.name.pixbuf = - gtk_widget_render_icon (GTK_WIDGET (image), - GTK_STOCK_MISSING_IMAGE, - priv->icon_size, - NULL); + gtk_widget_render_icon_pixbuf (GTK_WIDGET (image), + GTK_STOCK_MISSING_IMAGE, + priv->icon_size); priv->was_symbolic = FALSE; } } @@ -1560,10 +1559,9 @@ ensure_pixbuf_for_gicon (GtkImage *image, if (priv->data.gicon.pixbuf == NULL) { priv->data.gicon.pixbuf = - gtk_widget_render_icon (GTK_WIDGET (image), - GTK_STOCK_MISSING_IMAGE, - priv->icon_size, - NULL); + gtk_widget_render_icon_pixbuf (GTK_WIDGET (image), + GTK_STOCK_MISSING_IMAGE, + priv->icon_size); priv->was_symbolic = FALSE; } } @@ -1621,10 +1619,9 @@ gtk_image_draw (GtkWidget *widget, break; case GTK_IMAGE_STOCK: - pixbuf = gtk_widget_render_icon (widget, - priv->data.stock.stock_id, - priv->icon_size, - NULL); + pixbuf = gtk_widget_render_icon_pixbuf (widget, + priv->data.stock.stock_id, + priv->icon_size); /* already done */ needs_state_transform = FALSE; @@ -1890,10 +1887,9 @@ gtk_image_calc_size (GtkImage *image) switch (priv->storage_type) { case GTK_IMAGE_STOCK: - pixbuf = gtk_widget_render_icon (widget, - priv->data.stock.stock_id, - priv->icon_size, - NULL); + pixbuf = gtk_widget_render_icon_pixbuf (widget, + priv->data.stock.stock_id, + priv->icon_size); break; case GTK_IMAGE_ICON_SET: diff --git a/gtk/gtkinfobar.c b/gtk/gtkinfobar.c index a7879606b4..5ec7a04d2f 100644 --- a/gtk/gtkinfobar.c +++ b/gtk/gtkinfobar.c @@ -157,8 +157,7 @@ static void gtk_info_bar_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -static void gtk_info_bar_style_set (GtkWidget *widget, - GtkStyle *prev_style); +static void gtk_info_bar_style_updated (GtkWidget *widget); static gboolean gtk_info_bar_draw (GtkWidget *widget, cairo_t *cr); static void gtk_info_bar_buildable_interface_init (GtkBuildableIface *iface); @@ -300,29 +299,34 @@ gtk_info_bar_draw (GtkWidget *widget, cairo_t *cr) { GtkInfoBarPrivate *priv = GTK_INFO_BAR (widget)->priv; - const char* type_detail[] = { - "infobar-info", - "infobar-warning", - "infobar-question", - "infobar-error", - "infobar" + const char* type_class[] = { + GTK_STYLE_CLASS_INFO, + GTK_STYLE_CLASS_WARNING, + GTK_STYLE_CLASS_QUESTION, + GTK_STYLE_CLASS_ERROR, + NULL }; if (priv->message_type != GTK_MESSAGE_OTHER) { - const char *detail; - - detail = type_detail[priv->message_type]; - - gtk_paint_box (gtk_widget_get_style (widget), - cr, - GTK_STATE_NORMAL, - GTK_SHADOW_OUT, - widget, - detail, - 0, 0, - gtk_widget_get_allocated_width (widget), - gtk_widget_get_allocated_height (widget)); + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + + if (type_class[priv->message_type]) + gtk_style_context_add_class (context, + type_class[priv->message_type]); + + gtk_render_background (context, cr, 0, 0, + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); + gtk_render_frame (context, cr, 0, 0, + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); + + gtk_style_context_restore (context); } if (GTK_WIDGET_CLASS (gtk_info_bar_parent_class)->draw) @@ -345,7 +349,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass) object_class->set_property = gtk_info_bar_set_property; object_class->finalize = gtk_info_bar_finalize; - widget_class->style_set = gtk_info_bar_style_set; + widget_class->style_updated = gtk_info_bar_style_updated; widget_class->draw = gtk_info_bar_draw; klass->close = gtk_info_bar_close; @@ -491,100 +495,7 @@ gtk_info_bar_class_init (GtkInfoBarClass *klass) } static void -gtk_info_bar_update_colors (GtkInfoBar *info_bar) -{ - GtkWidget *widget = GTK_WIDGET (info_bar); - GtkInfoBarPrivate *priv = info_bar->priv; - GdkRGBA info_default_border_color = { 0.71, 0.67, 0.61, 1.0 }; - GdkRGBA info_default_fill_color = { 0.99, 0.99, 0.74, 1.0 }; - GdkRGBA warning_default_border_color = { 0.68, 0.47, 0.16, 1.0 }; - GdkRGBA warning_default_fill_color = { 0.98, 0.68, 0.24, 1.0 }; - GdkRGBA question_default_border_color = { 0.38, 0.48, 0.84, 1.0 }; - GdkRGBA question_default_fill_color = { 0.54, 0.68, 0.83, 1.0 }; - GdkRGBA error_default_border_color = { 0.65, 0.15, 0.15, 1.0 }; - GdkRGBA error_default_fill_color = { 0.93, 0.21, 0.21, 1.0 }; - GdkRGBA other_default_border_color = { 0.71, 0.67, 0.61, 1.0 }; - GdkRGBA other_default_fill_color = { 0.99, 0.99, 0.74, 1.0 }; - GdkRGBA *fg, *bg; - GdkRGBA sym_fg, sym_bg; - GdkRGBA *color, *bg_color; - GtkStyleContext *context; - - const char* fg_color_name[] = { - "info_fg_color", - "warning_fg_color", - "question_fg_color", - "error_fg_color", - "other_fg_color" - }; - const char* bg_color_name[] = { - "info_bg_color", - "warning_bg_color", - "question_bg_color", - "error_bg_color", - "other_bg_color" - }; - - context = gtk_widget_get_style_context (widget); - - if (gtk_style_context_lookup_color (context, fg_color_name[priv->message_type], &sym_fg) && - gtk_style_context_lookup_color (context, bg_color_name[priv->message_type], &sym_bg)) - { - fg = &sym_fg; - bg = &sym_bg; - } - else - { - switch (priv->message_type) - { - case GTK_MESSAGE_INFO: - fg = &info_default_border_color; - bg = &info_default_fill_color; - break; - - case GTK_MESSAGE_WARNING: - fg = &warning_default_border_color; - bg = &warning_default_fill_color; - break; - - case GTK_MESSAGE_QUESTION: - fg = &question_default_border_color; - bg = &question_default_fill_color; - break; - - case GTK_MESSAGE_ERROR: - fg = &error_default_border_color; - bg = &error_default_fill_color; - break; - - case GTK_MESSAGE_OTHER: - fg = &other_default_border_color; - bg = &other_default_fill_color; - break; - - default: - g_assert_not_reached(); - fg = NULL; - bg = NULL; - } - } - - gtk_style_context_get (context, 0, - "color", &color, - "background-color", &bg_color, - NULL); - if (!gdk_rgba_equal (bg_color, bg)) - gtk_widget_override_background_color (widget, 0, bg); - if (!gdk_rgba_equal (color, fg)) - gtk_widget_override_color (widget, 0, fg); - - gdk_rgba_free (color); - gdk_rgba_free (bg_color); -} - -static void -gtk_info_bar_style_set (GtkWidget *widget, - GtkStyle *prev_style) +gtk_info_bar_style_updated (GtkWidget *widget) { GtkInfoBar *info_bar = GTK_INFO_BAR (widget); gint button_spacing; @@ -605,8 +516,6 @@ gtk_info_bar_style_set (GtkWidget *widget, gtk_box_set_spacing (GTK_BOX (info_bar->priv->content_area), content_area_spacing); gtk_container_set_border_width (GTK_CONTAINER (info_bar->priv->content_area), content_area_border); - - gtk_info_bar_update_colors (info_bar); } static void @@ -1191,7 +1100,6 @@ gtk_info_bar_set_message_type (GtkInfoBar *info_bar, { priv->message_type = message_type; - gtk_info_bar_update_colors (info_bar); gtk_widget_queue_draw (GTK_WIDGET (info_bar)); atk_obj = gtk_widget_get_accessible (GTK_WIDGET (info_bar)); diff --git a/gtk/gtklinkbutton.c b/gtk/gtklinkbutton.c index 6b159d3c8f..9a6b6fa1f2 100644 --- a/gtk/gtklinkbutton.c +++ b/gtk/gtklinkbutton.c @@ -601,7 +601,7 @@ gtk_link_button_drag_data_get_cb (GtkWidget *widget, uri = g_strdup_printf ("%s\r\n", link_button->priv->uri); gtk_selection_data_set (selection, - selection->target, + gtk_selection_data_get_target (selection), 8, (guchar *) uri, strlen (uri)); diff --git a/gtk/gtknotebook.c b/gtk/gtknotebook.c index f5a4db5cc9..df0383d78f 100644 --- a/gtk/gtknotebook.c +++ b/gtk/gtknotebook.c @@ -358,12 +358,11 @@ static gint gtk_notebook_focus_out (GtkWidget *widget, GdkEventFocus *event); static void gtk_notebook_grab_notify (GtkWidget *widget, gboolean was_grabbed); -static void gtk_notebook_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gtk_notebook_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state); static gint gtk_notebook_focus (GtkWidget *widget, GtkDirectionType direction); -static void gtk_notebook_style_set (GtkWidget *widget, - GtkStyle *previous); +static void gtk_notebook_style_updated (GtkWidget *widget); /*** Drag and drop Methods ***/ static void gtk_notebook_drag_begin (GtkWidget *widget, @@ -422,6 +421,8 @@ static void gtk_notebook_forall (GtkContainer *container, gboolean include_internals, GtkCallback callback, gpointer callback_data); +static GtkWidgetPath * gtk_notebook_get_path_for_child (GtkContainer *container, + GtkWidget *widget); /*** GtkNotebook Methods ***/ static gint gtk_notebook_real_insert_page (GtkNotebook *notebook, @@ -463,8 +464,7 @@ static void gtk_notebook_paint (GtkWidget *widget, static void gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, cairo_t *cr, - guint position, - gboolean is_last); + GtkRegionFlags flags); static void gtk_notebook_draw_arrow (GtkNotebook *notebook, cairo_t *cr, GtkNotebookArrow arrow); @@ -653,11 +653,11 @@ gtk_notebook_class_init (GtkNotebookClass *class) widget_class->leave_notify_event = gtk_notebook_leave_notify; widget_class->motion_notify_event = gtk_notebook_motion_notify; widget_class->grab_notify = gtk_notebook_grab_notify; - widget_class->state_changed = gtk_notebook_state_changed; + widget_class->state_flags_changed = gtk_notebook_state_flags_changed; widget_class->focus_in_event = gtk_notebook_focus_in; widget_class->focus_out_event = gtk_notebook_focus_out; widget_class->focus = gtk_notebook_focus; - widget_class->style_set = gtk_notebook_style_set; + widget_class->style_updated = gtk_notebook_style_updated; widget_class->drag_begin = gtk_notebook_drag_begin; widget_class->drag_end = gtk_notebook_drag_end; widget_class->drag_motion = gtk_notebook_drag_motion; @@ -674,6 +674,7 @@ gtk_notebook_class_init (GtkNotebookClass *class) container_class->get_child_property = gtk_notebook_get_child_property; container_class->set_child_property = gtk_notebook_set_child_property; container_class->child_type = gtk_notebook_child_type; + container_class->get_path_for_child = gtk_notebook_get_path_for_child; class->switch_page = gtk_notebook_real_switch_page; class->insert_page = gtk_notebook_real_insert_page; @@ -1149,6 +1150,7 @@ static void gtk_notebook_init (GtkNotebook *notebook) { GtkNotebookPrivate *priv; + GtkStyleContext *context; gtk_widget_set_can_focus (GTK_WIDGET (notebook), TRUE); gtk_widget_set_has_window (GTK_WIDGET (notebook), FALSE); @@ -1204,6 +1206,9 @@ gtk_notebook_init (GtkNotebook *notebook) G_CALLBACK (gtk_notebook_drag_failed), NULL); gtk_drag_dest_set_track_motion (GTK_WIDGET (notebook), TRUE); + + context = gtk_widget_get_style_context (GTK_WIDGET (notebook)); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_NOTEBOOK); } static void @@ -1668,7 +1673,7 @@ gtk_notebook_get_property (GObject *object, * gtk_notebook_motion_notify * gtk_notebook_focus_in * gtk_notebook_focus_out - * gtk_notebook_style_set + * gtk_notebook_style_updated * gtk_notebook_drag_begin * gtk_notebook_drag_end * gtk_notebook_drag_failed @@ -1915,6 +1920,89 @@ gtk_notebook_unrealize (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_notebook_parent_class)->unrealize (widget); } +static GtkRegionFlags +_gtk_notebook_get_tab_flags (GtkNotebook *notebook, + GtkNotebookPage *page) +{ + GtkNotebookPrivate *priv = notebook->priv; + gint i = 0, page_num = -1; + GtkRegionFlags flags = 0; + gboolean is_last = FALSE; + GList *pages; + + if (page->pack == GTK_PACK_START) + { + gint last = -1; + + for (pages = priv->children; pages; pages = pages->next) + { + GtkNotebookPage *p = pages->data; + + if (!gtk_widget_get_visible (p->tab_label)) + continue; + + if (p->pack == GTK_PACK_END) + last = i; + + if (page->pack == p->pack) + i++; + + /* No need to keep counting tabs after it */ + if (page == p) + { + page_num = i; + is_last = (last == -1 && pages->next == NULL); + break; + } + } + } + else + { + gboolean found = FALSE; + + is_last = TRUE; + + /* Count all pack_start tabs from the beginning + * of the list until we find the page, then all + * items until the end, that should give us the + * tab position + */ + for (pages = priv->children; pages; pages = pages->next) + { + GtkNotebookPage *p = pages->data; + + if (!gtk_widget_get_visible (p->tab_label)) + continue; + + if (p->pack == GTK_PACK_START || p == page || found) + i++; + + if (page == p) + found = TRUE; + else if (p->pack == GTK_PACK_END && !found) + is_last = FALSE; + } + + page_num = i; + } + + if (page_num < 0) + return 0; + + if ((page_num) % 2 == 0) + flags |= GTK_REGION_EVEN; + else + flags |= GTK_REGION_ODD; + + if (page_num == 1) + flags |= GTK_REGION_FIRST; + + if (is_last) + flags |= GTK_REGION_LAST; + + return flags; +} + static void gtk_notebook_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -1987,12 +2075,14 @@ gtk_notebook_size_request (GtkWidget *widget, if (priv->show_border || priv->show_tabs) { - GtkStyle *style; + GtkStyleContext *context; + GtkBorder notebook_padding; - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, 0, ¬ebook_padding); - requisition->width += style->xthickness * 2; - requisition->height += style->ythickness * 2; + requisition->width += notebook_padding.left + notebook_padding.right; + requisition->height += notebook_padding.top + notebook_padding.bottom; if (priv->show_tabs) { @@ -2011,14 +2101,26 @@ gtk_notebook_size_request (GtkWidget *widget, if (gtk_widget_get_visible (page->child)) { + GtkBorder tab_padding; + if (!gtk_widget_get_visible (page->tab_label)) gtk_widget_show (page->tab_label); gtk_widget_get_preferred_size (page->tab_label, &child_requisition, NULL); - page->requisition.width = child_requisition.width + 2 * style->xthickness; - page->requisition.height = child_requisition.height + 2 * style->ythickness; + /* Get border/padding for tab */ + gtk_style_context_save (context); + gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, + _gtk_notebook_get_tab_flags (notebook, page)); + gtk_style_context_get_padding (context, 0, &tab_padding); + gtk_style_context_restore (context); + + page->requisition.width = child_requisition.width + + tab_padding.left + tab_padding.right; + + page->requisition.height = child_requisition.height + + tab_padding.top + tab_padding.bottom; switch (priv->tab_pos) { @@ -2052,8 +2154,8 @@ gtk_notebook_size_request (GtkWidget *widget, { gtk_widget_get_preferred_size (priv->action_widget[i], &action_widget_requisition[i], NULL); - action_widget_requisition[i].width += style->xthickness; - action_widget_requisition[i].height += style->ythickness; + action_widget_requisition[i].width += notebook_padding.left; + action_widget_requisition[i].height += notebook_padding.top; } } @@ -2249,12 +2351,12 @@ gtk_notebook_size_allocate (GtkWidget *widget, { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; - GtkStyle *style; + GtkStyleContext *context; gint tab_pos = get_effective_tab_pos (notebook); gboolean is_rtl; gint focus_width; - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL); @@ -2291,10 +2393,16 @@ gtk_notebook_size_allocate (GtkWidget *widget, if (priv->show_tabs || priv->show_border) { - child_allocation.x += style->xthickness; - child_allocation.y += style->ythickness; - child_allocation.width = MAX (1, child_allocation.width - style->xthickness * 2); - child_allocation.height = MAX (1, child_allocation.height - style->ythickness * 2); + GtkStyleContext *context; + GtkBorder padding; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, 0, &padding); + + child_allocation.x += padding.left; + child_allocation.y += padding.top; + child_allocation.width = MAX (1, child_allocation.width - padding.left - padding.right); + child_allocation.height = MAX (1, child_allocation.height - padding.top - padding.bottom); if (priv->show_tabs && priv->children && priv->cur_page) { @@ -2338,7 +2446,7 @@ gtk_notebook_size_allocate (GtkWidget *widget, /* fall through */ case GTK_POS_TOP: widget_allocation.width = requisition.width; - widget_allocation.height = priv->cur_page->requisition.height - style->ythickness; + widget_allocation.height = priv->cur_page->requisition.height - padding.top; if ((i == ACTION_WIDGET_START && is_rtl) || (i == ACTION_WIDGET_END && !is_rtl)) @@ -2351,7 +2459,7 @@ gtk_notebook_size_allocate (GtkWidget *widget, /* fall through */ case GTK_POS_LEFT: widget_allocation.height = requisition.height; - widget_allocation.width = priv->cur_page->requisition.width - style->xthickness; + widget_allocation.width = priv->cur_page->requisition.width - padding.left; if (i == ACTION_WIDGET_END) widget_allocation.y += allocation->height - 2 * border_width - requisition.height; @@ -2434,8 +2542,12 @@ gtk_notebook_draw (GtkWidget *widget, if (priv->operation == DRAG_OPERATION_REORDER && gtk_cairo_should_draw_window (cr, priv->drag_window)) { + GtkStyleContext *context; + GdkRGBA bg_color; + cairo_save (cr); gtk_cairo_transform_to_window (cr, widget, priv->drag_window); + context = gtk_widget_get_style_context (widget); /* FIXME: This is a workaround to make tabs reordering work better * with engines with rounded tabs. If the drag window background @@ -2444,12 +2556,13 @@ gtk_notebook_draw (GtkWidget *widget, * Ideally, these corners should be made transparent, Either by using * ARGB visuals or shape windows. */ - gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->bg [GTK_STATE_NORMAL]); + gtk_style_context_get_background_color (context, 0, &bg_color); + gdk_cairo_set_source_rgba (cr, &bg_color); cairo_paint (cr); gtk_notebook_draw_tab (notebook, priv->cur_page, - cr, 0, FALSE); + cr, 0); cairo_restore (cr); @@ -3322,8 +3435,8 @@ gtk_notebook_grab_notify (GtkWidget *widget, } static void -gtk_notebook_state_changed (GtkWidget *widget, - GtkStateType previous_state) +gtk_notebook_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state) { if (!gtk_widget_is_sensitive (widget)) stop_scrolling (GTK_NOTEBOOK (widget)); @@ -3348,8 +3461,7 @@ gtk_notebook_focus_out (GtkWidget *widget, } static void -gtk_notebook_style_set (GtkWidget *widget, - GtkStyle *previous) +gtk_notebook_style_updated (GtkWidget *widget) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; @@ -3371,7 +3483,7 @@ gtk_notebook_style_set (GtkWidget *widget, priv->has_after_previous = has_after_previous; priv->has_after_next = has_after_next; - GTK_WIDGET_CLASS (gtk_notebook_parent_class)->style_set (widget, previous); + GTK_WIDGET_CLASS (gtk_notebook_parent_class)->style_updated (widget); } static gboolean @@ -3381,25 +3493,29 @@ on_drag_icon_draw (GtkWidget *widget, { GtkWidget *notebook, *child; GtkRequisition requisition; + GtkStyleContext *context; gint gap_pos; notebook = GTK_WIDGET (data); child = gtk_bin_get_child (GTK_BIN (widget)); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, 0); gtk_widget_get_preferred_size (widget, &requisition, NULL); gap_pos = get_tab_gap_pos (GTK_NOTEBOOK (notebook)); - gtk_paint_extension (gtk_widget_get_style (notebook), - cr, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - widget, "tab", - 0, 0, - requisition.width, requisition.height, - gap_pos); + gtk_render_extension (context, cr, 0, 0, + requisition.width, requisition.height, + gap_pos); + if (child) gtk_container_propagate_draw (GTK_CONTAINER (widget), child, cr); + gtk_style_context_restore (context); + return TRUE; } @@ -3724,13 +3840,16 @@ gtk_notebook_drag_data_get (GtkWidget *widget, guint info, guint time) { - if (data->target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB")) + GdkAtom target; + + target = gtk_selection_data_get_target (data); + if (target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB")) { GtkNotebook *notebook = GTK_NOTEBOOK (widget); GtkNotebookPrivate *priv = notebook->priv; gtk_selection_data_set (data, - data->target, + target, 8, (void*) &priv->detached_tab->child, sizeof (gpointer)); @@ -3754,9 +3873,9 @@ gtk_notebook_drag_data_received (GtkWidget *widget, source_widget = gtk_drag_get_source_widget (context); if (source_widget && - data->target == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB")) + gtk_selection_data_get_target (data) == gdk_atom_intern_static_string ("GTK_NOTEBOOK_TAB")) { - child = (void*) data->data; + child = (void*) gtk_selection_data_get_data (data); do_detach_tab (GTK_NOTEBOOK (source_widget), notebook, *child, x, y); gtk_drag_finish (context, TRUE, FALSE, time); @@ -4320,6 +4439,40 @@ gtk_notebook_forall (GtkContainer *container, } } +static GtkWidgetPath * +gtk_notebook_get_path_for_child (GtkContainer *container, + GtkWidget *widget) +{ + GtkNotebookPrivate *priv; + GtkNotebook *notebook; + GtkNotebookPage *page; + GtkWidgetPath *path; + GtkRegionFlags flags; + GList *c; + + path = GTK_CONTAINER_CLASS (gtk_notebook_parent_class)->get_path_for_child (container, widget); + + notebook = GTK_NOTEBOOK (container); + priv = notebook->priv; + + for (c = priv->children; c; c = c->next) + { + page = c->data; + + if (page->tab_label == widget) + break; + } + + /* Widget is not a tab label */ + if (!c) + return path; + + flags = _gtk_notebook_get_tab_flags (notebook, page); + gtk_widget_path_iter_add_region (path, -1, GTK_STYLE_REGION_TAB, flags); + + return path; +} + static GType gtk_notebook_child_type (GtkContainer *container) { @@ -4478,10 +4631,11 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook) GtkAllocation allocation; GtkWidget *widget; GtkNotebookPage *page; - GtkStyle *style; + GtkStyleContext *context; GdkRectangle redraw_rect; gint border; gint tab_pos = get_effective_tab_pos (notebook); + GtkBorder padding; widget = GTK_WIDGET (notebook); border = gtk_container_get_border_width (GTK_CONTAINER (notebook)); @@ -4494,38 +4648,40 @@ gtk_notebook_redraw_tabs (GtkNotebook *notebook) redraw_rect.x = border; redraw_rect.y = border; - style = gtk_widget_get_style (widget); gtk_widget_get_allocation (widget, &allocation); + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, 0, &padding); + switch (tab_pos) { case GTK_POS_BOTTOM: redraw_rect.y = allocation.height - border - - page->allocation.height - style->ythickness; + page->allocation.height - padding.bottom; if (page != priv->cur_page) - redraw_rect.y -= style->ythickness; + redraw_rect.y -= padding.bottom; /* fall through */ case GTK_POS_TOP: redraw_rect.width = allocation.width - 2 * border; - redraw_rect.height = page->allocation.height + style->ythickness; + redraw_rect.height = page->allocation.height + padding.top; if (page != priv->cur_page) - redraw_rect.height += style->ythickness; + redraw_rect.height += padding.top; break; case GTK_POS_RIGHT: redraw_rect.x = allocation.width - border - - page->allocation.width - style->xthickness; + page->allocation.width - padding.right; if (page != priv->cur_page) - redraw_rect.x -= style->xthickness; + redraw_rect.x -= padding.right; /* fall through */ case GTK_POS_LEFT: - redraw_rect.width = page->allocation.width + style->xthickness; + redraw_rect.width = page->allocation.width + padding.left; redraw_rect.height = allocation.height - 2 * border; if (page != priv->cur_page) - redraw_rect.width += style->xthickness; + redraw_rect.width += padding.left; break; } @@ -4785,7 +4941,7 @@ gtk_notebook_update_labels (GtkNotebook *notebook) else gtk_label_set_text (GTK_LABEL (page->menu_label), string); } - } + } } static gint @@ -4897,13 +5053,18 @@ gtk_notebook_paint (GtkWidget *widget, gint x, y; guint border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); gint gap_x = 0, gap_width = 0, step = STEP_PREV; - gboolean is_rtl, cur_page_end; - gint tab_pos, i, cur_page_pos; - + gboolean is_rtl; + gint tab_pos; + GtkStyleContext *context; + GtkRegionFlags tab_flags; + gboolean has_pack_start, has_pack_end; + notebook = GTK_NOTEBOOK (widget); priv = notebook->priv; is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; tab_pos = get_effective_tab_pos (notebook); + context = gtk_widget_get_style_context (widget); + showarrow = has_pack_start = has_pack_end = FALSE; if ((!priv->show_tabs && !priv->show_border) || !priv->cur_page || !gtk_widget_get_visible (priv->cur_page->child)) @@ -4918,10 +5079,10 @@ gtk_notebook_paint (GtkWidget *widget, if (priv->show_border && (!priv->show_tabs || !priv->children)) { - gtk_paint_box (gtk_widget_get_style (widget), cr, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - widget, "notebook", - x, y, width, height); + gtk_render_background (context, cr, + x, y, width, height); + gtk_render_frame (context, cr, + x, y, width, height); return; } @@ -4981,37 +5142,92 @@ gtk_notebook_paint (GtkWidget *widget, break; } } - gtk_paint_box_gap (gtk_widget_get_style (widget), cr, - GTK_STATE_NORMAL, GTK_SHADOW_OUT, - widget, "notebook", - x, y, width, height, - tab_pos, gap_x, gap_width); - showarrow = FALSE; + for (children = priv->children; children; children = children->next) + { + page = children->data; + + if (!gtk_widget_get_visible (page->child)) + continue; + + if (page->pack == GTK_PACK_START) + has_pack_start = TRUE; + else + has_pack_end = TRUE; + + if (!gtk_widget_get_mapped (page->tab_label)) + showarrow = TRUE; + + /* No point in keeping searching */ + if (has_pack_start && has_pack_end && showarrow) + break; + } + + gtk_style_context_save (context); + + if (!showarrow || !priv->scrollable) + { + GtkJunctionSides junction = 0; + + /* Apply junction sides, if no arrows are shown, + * then make corners with connecting tabs square. + */ + switch (tab_pos) + { + case GTK_POS_TOP: + if (has_pack_start) + junction |= (is_rtl) ? GTK_JUNCTION_CORNER_TOPRIGHT : GTK_JUNCTION_CORNER_TOPLEFT; + + if (has_pack_end) + junction |= (is_rtl) ? GTK_JUNCTION_CORNER_TOPLEFT : GTK_JUNCTION_CORNER_TOPRIGHT; + break; + case GTK_POS_BOTTOM: + if (has_pack_start) + junction |= (is_rtl) ? GTK_JUNCTION_CORNER_BOTTOMRIGHT : GTK_JUNCTION_CORNER_BOTTOMLEFT; + + if (has_pack_end) + junction |= (is_rtl) ? GTK_JUNCTION_CORNER_BOTTOMLEFT : GTK_JUNCTION_CORNER_BOTTOMRIGHT; + break; + case GTK_POS_LEFT: + if (has_pack_start) + junction |= GTK_JUNCTION_CORNER_TOPLEFT; + + if (has_pack_end) + junction |= GTK_JUNCTION_CORNER_BOTTOMLEFT; + break; + case GTK_POS_RIGHT: + if (has_pack_start) + junction |= GTK_JUNCTION_CORNER_TOPRIGHT; + + if (has_pack_end) + junction |= GTK_JUNCTION_CORNER_BOTTOMRIGHT; + break; + } + + gtk_style_context_set_junction_sides (context, junction); + } + + gtk_render_background (context, cr, + x, y, width, height); + gtk_render_frame_gap (context, cr, + x, y, width, height, + tab_pos, gap_x, gap_x + gap_width); + + gtk_style_context_restore (context); + children = gtk_notebook_search_page (notebook, NULL, step, TRUE); - i = 0; while (children) { page = children->data; children = gtk_notebook_search_page (notebook, children, step, TRUE); - if (!gtk_widget_get_visible (page->child)) + if (!gtk_widget_get_visible (page->child) || + !gtk_widget_get_mapped (page->tab_label)) continue; - if (!gtk_widget_get_mapped (page->tab_label)) - showarrow = TRUE; - else - { - if (page != priv->cur_page) - gtk_notebook_draw_tab (notebook, page, cr, i, children != NULL); - else - { - cur_page_pos = i; - cur_page_end = (children != NULL); - } - i++; - } + tab_flags = _gtk_notebook_get_tab_flags (notebook, page); + gtk_notebook_draw_tab (notebook, page, cr, tab_flags); } if (showarrow && priv->scrollable) @@ -5027,21 +5243,22 @@ gtk_notebook_paint (GtkWidget *widget, } if (priv->operation != DRAG_OPERATION_REORDER) - gtk_notebook_draw_tab (notebook, priv->cur_page, cr, cur_page_pos, cur_page_end); + { + tab_flags = _gtk_notebook_get_tab_flags (notebook, priv->cur_page); + gtk_notebook_draw_tab (notebook, priv->cur_page, cr, tab_flags); + } } static void gtk_notebook_draw_tab (GtkNotebook *notebook, GtkNotebookPage *page, cairo_t *cr, - guint position, - gboolean is_last) + GtkRegionFlags flags) { GtkNotebookPrivate *priv; - GtkStateType state_type; + GtkStateFlags state = 0; GtkWidget *widget; GtkStyleContext *context; - GtkRegionFlags flags = 0; if (!NOTEBOOK_IS_TAB_LABEL_PARENT (notebook, page) || !gtk_widget_get_mapped (page->tab_label) || @@ -5052,27 +5269,14 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, priv = notebook->priv; if (priv->cur_page == page) - state_type = GTK_STATE_NORMAL; - else - state_type = GTK_STATE_ACTIVE; - - if ((position + 1) % 2 == 0) - flags |= GTK_REGION_EVEN; - else - flags |= GTK_REGION_ODD; - - if (position == 0) - flags |= GTK_REGION_FIRST; - - if (is_last) - flags |= GTK_REGION_LAST; + state = GTK_STATE_FLAG_ACTIVE; context = gtk_widget_get_style_context (widget); - gtk_style_context_add_region (context, "tab", flags); + gtk_style_context_save (context); + gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, flags); + gtk_style_context_set_state (context, state); - gtk_paint_extension (gtk_widget_get_style (widget), cr, - state_type, GTK_SHADOW_OUT, - widget, "tab", + gtk_render_extension (context, cr, page->allocation.x, page->allocation.y, page->allocation.width, @@ -5088,15 +5292,14 @@ gtk_notebook_draw_tab (GtkNotebook *notebook, gtk_widget_get_allocation (page->tab_label, &allocation); gtk_widget_style_get (widget, "focus-line-width", &focus_width, NULL); - gtk_paint_focus (gtk_widget_get_style (widget), cr, - gtk_widget_get_state (widget), widget, "tab", - allocation.x - focus_width, - allocation.y - focus_width, - allocation.width + 2 * focus_width, - allocation.height + 2 * focus_width); + gtk_render_focus (context, cr, + allocation.x - focus_width, + allocation.y - focus_width, + allocation.width + 2 * focus_width, + allocation.height + 2 * focus_width); } - gtk_style_context_remove_region (context, "tab"); + gtk_style_context_restore (context); } static void @@ -5105,17 +5308,18 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, GtkNotebookArrow nbarrow) { GtkNotebookPrivate *priv = notebook->priv; - GtkStateType state_type; - GtkShadowType shadow_type; + GtkStyleContext *context; + GtkStateFlags state = 0; GtkWidget *widget; GdkRectangle arrow_rect; - GtkArrowType arrow; gboolean is_rtl, left; gint scroll_arrow_hlength; gint scroll_arrow_vlength; gint arrow_size; + gdouble angle; widget = GTK_WIDGET (notebook); + context = gtk_widget_get_style_context (widget); gtk_notebook_get_arrow_rect (notebook, &arrow_rect, nbarrow); @@ -5130,44 +5334,39 @@ gtk_notebook_draw_arrow (GtkNotebook *notebook, if (priv->in_child == nbarrow) { + state |= GTK_STATE_FLAG_PRELIGHT; + if (priv->click_child == nbarrow) - state_type = GTK_STATE_ACTIVE; - else - state_type = GTK_STATE_PRELIGHT; + state |= GTK_STATE_FLAG_ACTIVE; } else - state_type = gtk_widget_get_state (widget); - - if (priv->click_child == nbarrow) - shadow_type = GTK_SHADOW_IN; - else - shadow_type = GTK_SHADOW_OUT; + state = gtk_widget_get_state_flags (widget); if (priv->focus_tab && !gtk_notebook_search_page (notebook, priv->focus_tab, left ? STEP_PREV : STEP_NEXT, TRUE)) - { - shadow_type = GTK_SHADOW_ETCHED_IN; - state_type = GTK_STATE_INSENSITIVE; - } - + state = GTK_STATE_FLAG_INSENSITIVE; + if (priv->tab_pos == GTK_POS_LEFT || priv->tab_pos == GTK_POS_RIGHT) { - arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_UP : GTK_ARROW_DOWN); + angle = (ARROW_IS_LEFT (nbarrow)) ? 0 : G_PI; arrow_size = scroll_arrow_vlength; } else { - arrow = (ARROW_IS_LEFT (nbarrow) ? GTK_ARROW_LEFT : GTK_ARROW_RIGHT); + angle = (ARROW_IS_LEFT (nbarrow)) ? 3 * (G_PI / 2) : G_PI / 2; arrow_size = scroll_arrow_hlength; } - - gtk_paint_arrow (gtk_widget_get_style (widget), - cr, state_type, - shadow_type, widget, "notebook", - arrow, TRUE, arrow_rect.x, arrow_rect.y, - arrow_size, arrow_size); + + gtk_style_context_save (context); + gtk_style_context_set_state (context, state); + + gtk_render_arrow (context, cr, angle, + arrow_rect.x, arrow_rect.y, + arrow_size); + + gtk_style_context_restore (context); } /* Private GtkNotebook Size Allocate Functions: @@ -5189,7 +5388,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook, GtkNotebookPrivate *priv = notebook->priv; GtkAllocation allocation, action_allocation; GtkWidget *widget; - GtkStyle *style; + GtkStyleContext *context; GList *children; gint tab_pos = get_effective_tab_pos (notebook); gint tab_overlap; @@ -5199,12 +5398,13 @@ gtk_notebook_tab_space (GtkNotebook *notebook, gboolean is_rtl; gint i; guint border_width; + GtkBorder padding; widget = GTK_WIDGET (notebook); children = priv->children; is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL; - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); gtk_widget_style_get (GTK_WIDGET (notebook), "arrow-spacing", &arrow_spacing, @@ -5213,6 +5413,7 @@ gtk_notebook_tab_space (GtkNotebook *notebook, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (notebook)); + gtk_style_context_get_padding (context, 0, &padding); gtk_widget_get_allocation (widget, &allocation); @@ -5231,9 +5432,9 @@ gtk_notebook_tab_space (GtkNotebook *notebook, if ((i == ACTION_WIDGET_START && !is_rtl) || (i == ACTION_WIDGET_END && is_rtl)) - *min += action_allocation.width + style->xthickness; + *min += action_allocation.width + padding.left; else - *max -= action_allocation.width + style->xthickness; + *max -= action_allocation.width + padding.right; } } @@ -5261,9 +5462,9 @@ gtk_notebook_tab_space (GtkNotebook *notebook, gtk_widget_get_allocation (priv->action_widget[i], &action_allocation); if (i == ACTION_WIDGET_START) - *min += action_allocation.height + style->ythickness; + *min += action_allocation.height + padding.top; else - *max -= action_allocation.height + style->ythickness; + *max -= action_allocation.height + padding.bottom; } } @@ -5599,15 +5800,15 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, GtkWidget *widget; GtkContainer *container; GtkNotebookPage *page; - GtkStyle *style; + GtkStyleContext *context; gboolean allocate_at_bottom; gint tab_overlap, tab_pos, tab_extra_space; gint left_x, right_x, top_y, bottom_y, anchor; - gint xthickness, ythickness; guint border_width; gboolean gap_left, packing_changed; GtkAllocation child_allocation = { 0, }; GtkOrientation tab_expand_orientation; + GtkBorder padding; widget = GTK_WIDGET (notebook); container = GTK_CONTAINER (notebook); @@ -5622,9 +5823,7 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, child_allocation.x = allocation.x + border_width; child_allocation.y = allocation.y + border_width; - style = gtk_widget_get_style (widget); - xthickness = style->xthickness; - ythickness = style->ythickness; + context = gtk_widget_get_style_context (widget); switch (tab_pos) { @@ -5662,10 +5861,16 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, else tab_expand_orientation = GTK_ORIENTATION_VERTICAL; + gtk_style_context_save (context); + while (*children && *children != last_child) { page = (*children)->data; + gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, + _gtk_notebook_get_tab_flags (notebook, page)); + gtk_style_context_get_padding (context, 0, &padding); + if (direction == STEP_NEXT && page->pack != GTK_PACK_START) { if (!showarrow) @@ -5817,16 +6022,16 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, switch (tab_pos) { case GTK_POS_TOP: - page->allocation.y += ythickness; + page->allocation.y += padding.top; /* fall through */ case GTK_POS_BOTTOM: - page->allocation.height = MAX (1, page->allocation.height - ythickness); + page->allocation.height = MAX (1, page->allocation.height - padding.top); break; case GTK_POS_LEFT: - page->allocation.x += xthickness; + page->allocation.x += padding.left; /* fall through */ case GTK_POS_RIGHT: - page->allocation.width = MAX (1, page->allocation.width - xthickness); + page->allocation.width = MAX (1, page->allocation.width - padding.left); break; } } @@ -5893,6 +6098,8 @@ gtk_notebook_calculate_tabs_allocation (GtkNotebook *notebook, gtk_widget_set_child_visible (page->tab_label, TRUE); } + gtk_style_context_restore (context); + /* Don't move the current tab past the last position during tabs reordering */ if (children && priv->operation == DRAG_OPERATION_REORDER && @@ -5983,15 +6190,14 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, GtkNotebookPrivate *priv = notebook->priv; GtkAllocation child_allocation, label_allocation; GtkRequisition tab_requisition; - GtkStyle *style; - gint xthickness; - gint ythickness; + GtkStyleContext *context; gint padding; gint focus_width; gint tab_curvature; gint tab_pos = get_effective_tab_pos (notebook); gboolean tab_allocation_changed; gboolean was_visible = page->tab_allocated_visible; + GtkBorder tab_padding; if (!page->tab_label || !gtk_widget_get_visible (page->tab_label) || @@ -6001,9 +6207,13 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, return was_visible; } - style = gtk_widget_get_style (widget); - xthickness = style->xthickness; - ythickness = style->ythickness; + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + gtk_style_context_add_region (context, GTK_STYLE_REGION_TAB, + _gtk_notebook_get_tab_flags (notebook, page)); + + gtk_style_context_get_padding (context, 0, &tab_padding); gtk_widget_get_preferred_size (page->tab_label, &tab_requisition, NULL); gtk_widget_style_get (widget, @@ -6017,8 +6227,10 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, padding = tab_curvature + focus_width + priv->tab_hborder; if (page->fill) { - child_allocation.x = xthickness + focus_width + priv->tab_hborder; - child_allocation.width = MAX (1, page->allocation.width - 2 * child_allocation.x); + child_allocation.x = tab_padding.left + focus_width + priv->tab_hborder; + child_allocation.width = MAX (1, (page->allocation.width - + tab_padding.left - tab_padding.right - + 2 * (focus_width + priv->tab_hborder))); child_allocation.x += page->allocation.x; } else @@ -6032,9 +6244,10 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, child_allocation.y = priv->tab_vborder + focus_width + page->allocation.y; if (tab_pos == GTK_POS_TOP) - child_allocation.y += ythickness; + child_allocation.y += tab_padding.top; - child_allocation.height = MAX (1, (page->allocation.height - ythickness - + child_allocation.height = MAX (1, (page->allocation.height - + tab_padding.top - tab_padding.bottom - 2 * (priv->tab_vborder + focus_width))); break; case GTK_POS_LEFT: @@ -6042,9 +6255,10 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, padding = tab_curvature + focus_width + priv->tab_vborder; if (page->fill) { - child_allocation.y = ythickness + padding; + child_allocation.y = tab_padding.top + padding; child_allocation.height = MAX (1, (page->allocation.height - - 2 * child_allocation.y)); + tab_padding.bottom - tab_padding.top - + 2 * padding)); child_allocation.y += page->allocation.y; } else @@ -6058,9 +6272,9 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, child_allocation.x = priv->tab_hborder + focus_width + page->allocation.x; if (tab_pos == GTK_POS_LEFT) - child_allocation.x += xthickness; + child_allocation.x += tab_padding.left; - child_allocation.width = MAX (1, (page->allocation.width - xthickness - + child_allocation.width = MAX (1, (page->allocation.width - tab_padding.right - 2 * (priv->tab_hborder + focus_width))); break; } @@ -6079,6 +6293,8 @@ gtk_notebook_page_allocate (GtkNotebook *notebook, tab_allocation_changed = TRUE; } + gtk_style_context_restore (context); + return tab_allocation_changed; } @@ -6208,6 +6424,8 @@ gtk_notebook_update_tab_states (GtkNotebook *notebook) gtk_widget_set_state_flags (page->tab_label, GTK_STATE_FLAG_ACTIVE, TRUE); else gtk_widget_set_state_flags (page->tab_label, 0, TRUE); + + gtk_widget_reset_style (page->tab_label); } } } @@ -7898,8 +8116,8 @@ gtk_notebook_get_tab_detachable (GtkNotebook *notebook, * GtkWidget **child; * * notebook = gtk_drag_get_source_widget (context); - * child = (void*) selection_data->data; - * + * child = (void*) gtk_selection_data_get_data (selection_data); + * * process_widget (*child); * gtk_container_remove (GTK_CONTAINER (notebook), *child); * } diff --git a/gtk/gtkprintunixdialog.c b/gtk/gtkprintunixdialog.c index b90f7a37f7..bbe59da91b 100644 --- a/gtk/gtkprintunixdialog.c +++ b/gtk/gtkprintunixdialog.c @@ -1928,6 +1928,7 @@ selected_printer_changed (GtkTreeSelection *selection, priv->options_changed_handler = g_signal_connect_swapped (priv->options, "changed", G_CALLBACK (options_changed_cb), dialog); + schedule_idle_mark_conflicts (dialog); } update_dialog_from_settings (dialog); diff --git a/gtk/gtkrange.c b/gtk/gtkrange.c index 3345e88a32..c2409afb3f 100644 --- a/gtk/gtkrange.c +++ b/gtk/gtkrange.c @@ -214,12 +214,11 @@ static gboolean gtk_range_grab_broken (GtkWidget *widget, GdkEventGrabBroken *event); static void gtk_range_grab_notify (GtkWidget *widget, gboolean was_grabbed); -static void gtk_range_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gtk_range_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state); static gboolean gtk_range_scroll_event (GtkWidget *widget, GdkEventScroll *event); -static void gtk_range_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void gtk_range_style_updated (GtkWidget *widget); static void update_slider_position (GtkRange *range, gint mouse_x, gint mouse_y); @@ -316,8 +315,8 @@ gtk_range_class_init (GtkRangeClass *class) widget_class->leave_notify_event = gtk_range_leave_notify; widget_class->grab_broken_event = gtk_range_grab_broken; widget_class->grab_notify = gtk_range_grab_notify; - widget_class->state_changed = gtk_range_state_changed; - widget_class->style_set = gtk_range_style_set; + widget_class->state_flags_changed = gtk_range_state_flags_changed; + widget_class->style_updated = gtk_range_style_updated; widget_class->key_press_event = gtk_range_key_press; class->move_slider = gtk_range_move_slider; @@ -1044,9 +1043,12 @@ gtk_range_set_min_slider_size (GtkRange *range, { priv->min_slider_size = min_size; - priv->need_recalc = TRUE; - gtk_range_calc_layout (range, priv->adjustment->value); - gtk_widget_queue_draw (GTK_WIDGET (range)); + if (gtk_widget_is_drawable (GTK_WIDGET (range))) + { + priv->need_recalc = TRUE; + gtk_range_calc_layout (range, priv->adjustment->value); + gtk_widget_queue_draw (GTK_WIDGET (range)); + } } } @@ -1769,8 +1771,6 @@ gtk_range_realize (GtkWidget *widget) priv->event_window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); gdk_window_set_user_data (priv->event_window, range); - - gtk_widget_style_attach (widget); } static void @@ -1813,81 +1813,74 @@ gtk_range_unmap (GtkWidget *widget) GTK_WIDGET_CLASS (gtk_range_parent_class)->unmap (widget); } -static const gchar * -gtk_range_get_slider_detail (GtkRange *range) +static void +_gtk_range_update_context_for_stepper (GtkRange *range, + GtkStyleContext *context, + Stepper stepper) { GtkRangePrivate *priv = range->priv; - const gchar *slider_detail; - - if (priv->slider_detail_quark) - return g_quark_to_string (priv->slider_detail_quark); - - slider_detail = GTK_RANGE_GET_CLASS (range)->slider_detail; - - if (slider_detail && slider_detail[0] == 'X') - { - gchar *detail = g_strdup (slider_detail); - - detail[0] = priv->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v'; - - priv->slider_detail_quark = g_quark_from_string (detail); - - g_free (detail); - - return g_quark_to_string (priv->slider_detail_quark); - } + GtkJunctionSides sides = 0; + gboolean vertical, is_rtl; - return slider_detail; -} + vertical = (priv->orientation == GTK_ORIENTATION_VERTICAL); + is_rtl = (gtk_widget_get_direction (GTK_WIDGET (range)) == GTK_TEXT_DIR_RTL); -static const gchar * -gtk_range_get_stepper_detail (GtkRange *range, - Stepper stepper) -{ - GtkRangePrivate *priv = range->priv; - const gchar *stepper_detail; - gchar *detail; - const gchar *position = NULL; - - if (priv->stepper_detail_quark[stepper]) - return g_quark_to_string (priv->stepper_detail_quark[stepper]); + /* Take junction sides from what's been + * previously set to the widget itself + */ + sides = gtk_style_context_get_junction_sides (context); - stepper_detail = GTK_RANGE_GET_CLASS (range)->stepper_detail; + if (vertical) + sides &= ~(GTK_JUNCTION_TOP | GTK_JUNCTION_BOTTOM); + else + sides &= ~(GTK_JUNCTION_LEFT | GTK_JUNCTION_RIGHT); switch (stepper) { case STEPPER_A: - position = "_start"; + if (vertical) + sides |= GTK_JUNCTION_BOTTOM; + else + sides |= (is_rtl) ? GTK_JUNCTION_LEFT : GTK_JUNCTION_RIGHT; break; case STEPPER_B: if (priv->has_stepper_a) - position = "_start_inner"; + { + if (vertical) + sides |= GTK_JUNCTION_TOP; + else + sides |= (is_rtl) ? GTK_JUNCTION_RIGHT : GTK_JUNCTION_LEFT; + } + + if (vertical) + sides |= GTK_JUNCTION_BOTTOM; else - position = "_start"; + sides |= (is_rtl) ? GTK_JUNCTION_LEFT : GTK_JUNCTION_RIGHT; break; case STEPPER_C: if (priv->has_stepper_d) - position = "_end_inner"; + { + if (vertical) + sides |= GTK_JUNCTION_BOTTOM; + else + sides |= (is_rtl) ? GTK_JUNCTION_LEFT : GTK_JUNCTION_RIGHT; + } + + if (vertical) + sides |= GTK_JUNCTION_TOP; else - position = "_end"; + sides |= (is_rtl) ? GTK_JUNCTION_RIGHT : GTK_JUNCTION_LEFT; break; case STEPPER_D: - position = "_end"; + if (vertical) + sides |= GTK_JUNCTION_TOP; + else + sides |= (is_rtl) ? GTK_JUNCTION_RIGHT : GTK_JUNCTION_LEFT; break; - default: - g_assert_not_reached (); } - detail = g_strconcat (stepper_detail, position, NULL); - - if (detail[0] == 'X') - detail[0] = priv->orientation == GTK_ORIENTATION_HORIZONTAL ? 'h' : 'v'; - - priv->stepper_detail_quark[stepper] = g_quark_from_string (detail); - - g_free (detail); - - return g_quark_to_string (priv->stepper_detail_quark[stepper]); + gtk_style_context_set_junction_sides (context, sides); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); } static void @@ -1900,17 +1893,15 @@ draw_stepper (GtkRange *range, { GtkRangePrivate *priv = range->priv; GtkAllocation allocation; - GtkStateType state_type; - GtkShadowType shadow_type; - GtkStyle *style; + GtkStateFlags state = 0; + GtkStyleContext *context; GtkWidget *widget = GTK_WIDGET (range); GdkWindow *window; gfloat arrow_scaling; GdkRectangle *rect; gint arrow_x; gint arrow_y; - gint arrow_width; - gint arrow_height; + gdouble arrow_size, angle; gboolean arrow_sensitive; switch (stepper) @@ -1948,37 +1939,34 @@ draw_stepper (GtkRange *range, } if (!gtk_widget_is_sensitive (GTK_WIDGET (range)) || !arrow_sensitive) - state_type = GTK_STATE_INSENSITIVE; - else if (clicked) - state_type = GTK_STATE_ACTIVE; - else if (prelighted) - state_type = GTK_STATE_PRELIGHT; - else - state_type = GTK_STATE_NORMAL; - - if (clicked && arrow_sensitive) - shadow_type = GTK_SHADOW_IN; + state = GTK_STATE_FLAG_INSENSITIVE; else - shadow_type = GTK_SHADOW_OUT; + { + if (clicked) + state |= GTK_STATE_FLAG_ACTIVE; + if (prelighted) + state |= GTK_STATE_FLAG_PRELIGHT; + } - style = gtk_widget_get_style (widget); window = gtk_widget_get_window (widget); + context = gtk_widget_get_style_context (widget); + + gtk_style_context_save (context); + _gtk_range_update_context_for_stepper (range, context, stepper); + gtk_style_context_set_state (context, state); - gtk_paint_box (style, cr, - state_type, shadow_type, - widget, - gtk_range_get_stepper_detail (range, stepper), - rect->x, - rect->y, - rect->width, - rect->height); + gtk_render_background (context, cr, + rect->x, rect->y, + rect->width, rect->height); + gtk_render_frame (context, cr, + rect->x, rect->y, + rect->width, rect->height); gtk_widget_style_get (widget, "arrow-scaling", &arrow_scaling, NULL); - arrow_width = rect->width * arrow_scaling; - arrow_height = rect->height * arrow_scaling; - arrow_x = rect->x + (rect->width - arrow_width) / 2; - arrow_y = rect->y + (rect->height - arrow_height) / 2; + arrow_size = MIN (rect->width, rect->height) * arrow_scaling; + arrow_x = rect->x + (rect->width - arrow_size) / 2; + arrow_y = rect->y + (rect->height - arrow_size) / 2; if (clicked && arrow_sensitive) { @@ -1993,13 +1981,29 @@ draw_stepper (GtkRange *range, arrow_y += arrow_displacement_y; } - gtk_paint_arrow (style, cr, - state_type, shadow_type, - widget, - gtk_range_get_stepper_detail (range, stepper), - arrow_type, - TRUE, - arrow_x, arrow_y, arrow_width, arrow_height); + switch (arrow_type) + { + case GTK_ARROW_RIGHT: + angle = G_PI / 2; + break; + case GTK_ARROW_DOWN: + angle = G_PI; + break; + case GTK_ARROW_LEFT: + angle = 3 * (G_PI / 2); + break; + case GTK_ARROW_UP: + default: + angle = 0; + break; + } + + gtk_render_arrow (context, cr, + angle, + arrow_x, arrow_y, + arrow_size); + + gtk_style_context_restore (context); } static gboolean @@ -2009,15 +2013,15 @@ gtk_range_draw (GtkWidget *widget, GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = range->priv; gboolean sensitive; - GtkStateType state; - GtkShadowType shadow_type; - GtkStyle *style; + GtkStateFlags state = 0; GdkWindow *window; gint focus_line_width = 0; gint focus_padding = 0; gboolean touchscreen; gboolean draw_trough = TRUE; + GtkStyleContext *context; + context = gtk_widget_get_style_context (widget); g_object_get (gtk_widget_get_settings (widget), "gtk-touchscreen-mode", &touchscreen, NULL); @@ -2026,7 +2030,6 @@ gtk_range_draw (GtkWidget *widget, priv->adjustment->upper == priv->adjustment->lower) draw_trough = FALSE; - style = gtk_widget_get_style (widget); if (gtk_widget_get_can_focus (GTK_WIDGET (range))) gtk_widget_style_get (GTK_WIDGET (range), "focus-line-width", &focus_line_width, @@ -2072,6 +2075,11 @@ gtk_range_draw (GtkWidget *widget, "stepper-spacing", &stepper_spacing, NULL); + gtk_style_context_save (context); + + if (!sensitive) + gtk_style_context_set_state (context, GTK_STATE_FLAG_INSENSITIVE); + if (stepper_spacing > 0) trough_under_steppers = FALSE; @@ -2117,6 +2125,9 @@ gtk_range_draw (GtkWidget *widget, } } + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_TROUGH); + if (draw_trough) { gint trough_change_pos_x = width; @@ -2131,40 +2142,36 @@ gtk_range_draw (GtkWidget *widget, priv->slider.height / 2 - y); - gtk_paint_box (style, cr, - sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, - GTK_SHADOW_IN, - GTK_WIDGET (range), - should_invert (range) ? "trough-upper" : "trough-lower", - x, y, - trough_change_pos_x, trough_change_pos_y); + /* FIXME: was trough-upper and trough-lower really used, + * in that case, it should still be exposed somehow. + */ + gtk_render_background (context, cr, x, y, + trough_change_pos_x, + trough_change_pos_y); if (priv->orientation == GTK_ORIENTATION_HORIZONTAL) trough_change_pos_y = 0; else trough_change_pos_x = 0; - gtk_paint_box (style, cr, - sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, - GTK_SHADOW_IN, - GTK_WIDGET (range), - should_invert (range) ? "trough-lower" : "trough-upper", - x + trough_change_pos_x, y + trough_change_pos_y, - width - trough_change_pos_x, - height - trough_change_pos_y); + gtk_render_background (context, cr, + x + trough_change_pos_x, y + trough_change_pos_y, + width - trough_change_pos_x, + height - trough_change_pos_y); + + gtk_render_frame (context, cr, + x, y, width, height); } else { - gtk_paint_box (style, cr, - sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, - GTK_SHADOW_IN, - GTK_WIDGET (range), - "trough-upper", - x, y, - width, - height); + gtk_render_background (context, cr, + x, y, width, height); + gtk_render_frame (context, cr, + x, y, width, height); } + gtk_style_context_restore (context); + if (priv->show_fill_level && priv->adjustment->upper - priv->adjustment->page_size - priv->adjustment->lower != 0) @@ -2176,6 +2183,9 @@ gtk_range_draw (GtkWidget *widget, gint fill_height = height; gchar *fill_detail; + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_PROGRESSBAR); + fill_level = CLAMP (fill_level, priv->adjustment->lower, priv->adjustment->upper - priv->adjustment->page_size); @@ -2214,40 +2224,40 @@ gtk_range_draw (GtkWidget *widget, else fill_detail = "trough-fill-level"; - gtk_paint_box (style, cr, - sensitive ? GTK_STATE_ACTIVE : GTK_STATE_INSENSITIVE, - GTK_SHADOW_OUT, - GTK_WIDGET (range), fill_detail, - fill_x, fill_y, - fill_width, fill_height); + gtk_render_activity (context, cr, + fill_x, fill_y, + fill_width, fill_height); + + gtk_style_context_restore (context); } + gtk_style_context_restore (context); + if (sensitive && gtk_widget_has_focus (widget)) - gtk_paint_focus (style, cr, - gtk_widget_get_state (widget), - widget, "trough", - priv->range_rect.x, - priv->range_rect.y, - priv->range_rect.width, - priv->range_rect.height); + { + gtk_style_context_save (context); + gtk_style_context_set_state (context, + gtk_widget_get_state_flags (widget)); + + gtk_render_focus (context, cr, + priv->range_rect.x, + priv->range_rect.y, + priv->range_rect.width, + priv->range_rect.height); + + gtk_style_context_restore (context); + } } cairo_restore (cr); - shadow_type = GTK_SHADOW_OUT; - if (!sensitive) - state = GTK_STATE_INSENSITIVE; + state = GTK_STATE_FLAG_INSENSITIVE; else if (!touchscreen && priv->mouse_location == MOUSE_SLIDER) - state = GTK_STATE_PRELIGHT; - else - state = GTK_STATE_NORMAL; + state = GTK_STATE_FLAG_PRELIGHT; if (priv->grab_location == MOUSE_SLIDER) - { - state = GTK_STATE_ACTIVE; - shadow_type = GTK_SHADOW_IN; - } + state |= GTK_STATE_FLAG_ACTIVE; cairo_save (cr); gdk_cairo_rectangle (cr, &priv->slider); @@ -2255,17 +2265,18 @@ gtk_range_draw (GtkWidget *widget, if (draw_trough) { - gtk_paint_slider (style, - cr, - state, - shadow_type, - widget, - gtk_range_get_slider_detail (range), - priv->slider.x, - priv->slider.y, - priv->slider.width, - priv->slider.height, - priv->orientation); + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_SLIDER); + gtk_style_context_set_state (context, state); + + gtk_render_slider (context, cr, + priv->slider.x, + priv->slider.y, + priv->slider.width, + priv->slider.height, + priv->orientation); + + gtk_style_context_restore (context); } cairo_restore (cr); @@ -2867,8 +2878,8 @@ gtk_range_grab_notify (GtkWidget *widget, } static void -gtk_range_state_changed (GtkWidget *widget, - GtkStateType previous_state) +gtk_range_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state) { if (!gtk_widget_is_sensitive (widget)) stop_scrolling (GTK_RANGE (widget)); @@ -2973,15 +2984,14 @@ gtk_range_adjustment_value_changed (GtkAdjustment *adjustment, } static void -gtk_range_style_set (GtkWidget *widget, - GtkStyle *previous_style) +gtk_range_style_updated (GtkWidget *widget) { GtkRange *range = GTK_RANGE (widget); GtkRangePrivate *priv = range->priv; priv->need_recalc = TRUE; - GTK_WIDGET_CLASS (gtk_range_parent_class)->style_set (widget, previous_style); + GTK_WIDGET_CLASS (gtk_range_parent_class)->style_updated (widget); } static void diff --git a/gtk/gtkrc.c b/gtk/gtkrc.c index 54cf2fcd76..b0f239a97d 100644 --- a/gtk/gtkrc.c +++ b/gtk/gtkrc.c @@ -141,14 +141,9 @@ struct _GtkRcStylePrivate static GtkRcContext *gtk_rc_context_get (GtkSettings *settings); -static guint gtk_rc_style_hash (const gchar *name); -static gboolean gtk_rc_style_equal (const gchar *a, - const gchar *b); static guint gtk_rc_styles_hash (const GSList *rc_styles); static gboolean gtk_rc_styles_equal (const GSList *a, const GSList *b); -static GtkRcStyle* gtk_rc_style_find (GtkRcContext *context, - const gchar *name); static GSList * gtk_rc_styles_match (GSList *rc_styles, GSList *sets, guint path_length, @@ -171,53 +166,6 @@ static void gtk_rc_parse_any (GtkRcContext *context, const gchar *input_name, gint input_fd, const gchar *input_string); -static guint gtk_rc_parse_statement (GtkRcContext *context, - GScanner *scanner); -static guint gtk_rc_parse_style (GtkRcContext *context, - GScanner *scanner); -static guint gtk_rc_parse_assignment (GScanner *scanner, - GtkRcStyle *style, - GtkRcProperty *prop); -static guint gtk_rc_parse_bg (GScanner *scanner, - GtkRcStyle *style); -static guint gtk_rc_parse_fg (GScanner *scanner, - GtkRcStyle *style); -static guint gtk_rc_parse_text (GScanner *scanner, - GtkRcStyle *style); -static guint gtk_rc_parse_base (GScanner *scanner, - GtkRcStyle *style); -static guint gtk_rc_parse_xthickness (GScanner *scanner, - GtkRcStyle *style); -static guint gtk_rc_parse_ythickness (GScanner *scanner, - GtkRcStyle *style); -static guint gtk_rc_parse_bg_pixmap (GtkRcContext *context, - GScanner *scanner, - GtkRcStyle *rc_style); -static guint gtk_rc_parse_font (GScanner *scanner, - GtkRcStyle *rc_style); -static guint gtk_rc_parse_fontset (GScanner *scanner, - GtkRcStyle *rc_style); -static guint gtk_rc_parse_font_name (GScanner *scanner, - GtkRcStyle *rc_style); -static guint gtk_rc_parse_engine (GtkRcContext *context, - GScanner *scanner, - GtkRcStyle **rc_style); -static guint gtk_rc_parse_pixmap_path (GtkRcContext *context, - GScanner *scanner); -static void gtk_rc_parse_pixmap_path_string (GtkRcContext *context, - GScanner *scanner, - const gchar *pix_path); -static guint gtk_rc_parse_module_path (GScanner *scanner); -static guint gtk_rc_parse_im_module_file (GScanner *scanner); -static guint gtk_rc_parse_path_pattern (GtkRcContext *context, - GScanner *scanner); -static guint gtk_rc_parse_stock (GtkRcContext *context, - GScanner *scanner, - GtkRcStyle *rc_style, - GtkIconFactory *factory); -static guint gtk_rc_parse_logical_color (GScanner *scanner, - GtkRcStyle *rc_style, - GHashTable *hash); static void gtk_rc_clear_hash_node (gpointer key, gpointer data, @@ -927,25 +875,6 @@ gtk_rc_context_parse_string (GtkRcContext *context, void gtk_rc_parse_string (const gchar *rc_string) { - GtkRcFile *rc_file; - GSList *tmp_list; - - g_return_if_fail (rc_string != NULL); - -#if 0 - rc_file = g_new (GtkRcFile, 1); - rc_file->is_string = TRUE; - rc_file->name = g_strdup (rc_string); - rc_file->canonical_name = NULL; - rc_file->directory = NULL; - rc_file->mtime = 0; - rc_file->reload = TRUE; - - global_rc_files = g_slist_append (global_rc_files, rc_file); - - for (tmp_list = rc_contexts; tmp_list; tmp_list = tmp_list->next) - gtk_rc_context_parse_string (tmp_list->data, rc_string); -#endif } static GtkRcFile * @@ -1121,16 +1050,6 @@ gtk_rc_context_parse_file (GtkRcContext *context, void gtk_rc_parse (const gchar *filename) { - GSList *tmp_list; - - g_return_if_fail (filename != NULL); - -#if 0 - add_to_rc_file_list (&global_rc_files, filename, TRUE); - - for (tmp_list = rc_contexts; tmp_list; tmp_list = tmp_list->next) - gtk_rc_context_parse_file (tmp_list->data, filename, GTK_PATH_PRIO_RC, TRUE); -#endif } /* Handling of RC styles */ @@ -2198,93 +2117,6 @@ gtk_rc_parse_any (GtkRcContext *context, gint input_fd, const gchar *input_string) { - GScanner *scanner; - guint i; - gboolean done; - -#if 0 - scanner = gtk_rc_scanner_new (); - - if (input_fd >= 0) - { - g_assert (input_string == NULL); - - g_scanner_input_file (scanner, input_fd); - } - else - { - g_assert (input_string != NULL); - - g_scanner_input_text (scanner, input_string, strlen (input_string)); - } - scanner->input_name = input_name; - - for (i = 0; i < G_N_ELEMENTS (symbols); i++) - g_scanner_scope_add_symbol (scanner, 0, symbol_names + symbols[i].name_offset, GINT_TO_POINTER (symbols[i].token)); - done = FALSE; - while (!done) - { - if (g_scanner_peek_next_token (scanner) == G_TOKEN_EOF) - done = TRUE; - else - { - guint expected_token; - - expected_token = gtk_rc_parse_statement (context, scanner); - - if (expected_token != G_TOKEN_NONE) - { - const gchar *symbol_name = NULL; - gchar *msg = NULL; - - if (scanner->scope_id == 0) - { - guint token; - - /* if we are in scope 0, we know the symbol names - * that are associated with certain token values. - * so we look them up to make the error messages - * more readable. - */ - if (expected_token > GTK_RC_TOKEN_INVALID && - expected_token < GTK_RC_TOKEN_LAST) - { - const gchar *sym = NULL; - - for (i = 0; i < G_N_ELEMENTS (symbols); i++) - if (symbols[i].token == expected_token) - sym = symbol_names + symbols[i].name_offset; - - if (sym) - msg = g_strconcat ("e.g. `", sym, "'", NULL); - } - - token = scanner->token; - if (token > GTK_RC_TOKEN_INVALID && - token < GTK_RC_TOKEN_LAST) - { - symbol_name = "???"; - for (i = 0; i < G_N_ELEMENTS (symbols); i++) - if (symbols[i].token == scanner->token) - symbol_name = symbol_names + symbols[i].name_offset; - } - } - - g_scanner_unexp_token (scanner, - expected_token, - NULL, - "keyword", - symbol_name, - msg, - TRUE); - g_free (msg); - done = TRUE; - } - } - } - - g_scanner_destroy (scanner); -#endif } static guint @@ -2317,35 +2149,6 @@ gtk_rc_styles_equal (const GSList *a, return (a == b); } -static guint -gtk_rc_style_hash (const gchar *name) -{ - guint result; - - result = 0; - while (*name) - result += (result << 3) + *name++; - - return result; -} - -static gboolean -gtk_rc_style_equal (const gchar *a, - const gchar *b) -{ - return (strcmp (a, b) == 0); -} - -static GtkRcStyle* -gtk_rc_style_find (GtkRcContext *context, - const gchar *name) -{ - if (context->rc_style_ht) - return g_hash_table_lookup (context->rc_style_ht, (gpointer) name); - else - return NULL; -} - static GtkStyle * gtk_rc_style_to_style (GtkRcContext *context, GtkRcStyle *rc_style) @@ -2475,759 +2278,6 @@ lookup_color (GtkRcStyle *style, return FALSE; } -static guint -rc_parse_token_or_compound (GScanner *scanner, - GtkRcStyle *style, - GString *gstring, - GTokenType delimiter) -{ - guint token = g_scanner_get_next_token (scanner); - - /* we either scan a single token (skipping comments) - * or a compund statement. - * compunds are enclosed in (), [] or {} braces, we read - * them in via deep recursion. - */ - - switch (token) - { - gchar *string; - case G_TOKEN_INT: - g_string_append_printf (gstring, " 0x%lx", scanner->value.v_int); - break; - case G_TOKEN_FLOAT: - g_string_append_printf (gstring, " %f", scanner->value.v_float); - break; - case G_TOKEN_STRING: - string = g_strescape (scanner->value.v_string, NULL); - g_string_append (gstring, " \""); - g_string_append (gstring, string); - g_string_append_c (gstring, '"'); - g_free (string); - break; - case G_TOKEN_IDENTIFIER: - g_string_append_c (gstring, ' '); - g_string_append (gstring, scanner->value.v_identifier); - break; - case G_TOKEN_COMMENT_SINGLE: - case G_TOKEN_COMMENT_MULTI: - return rc_parse_token_or_compound (scanner, style, gstring, delimiter); - case G_TOKEN_LEFT_PAREN: - g_string_append_c (gstring, ' '); - g_string_append_c (gstring, token); - token = rc_parse_token_or_compound (scanner, style, gstring, G_TOKEN_RIGHT_PAREN); - if (token != G_TOKEN_NONE) - return token; - break; - case G_TOKEN_LEFT_CURLY: - g_string_append_c (gstring, ' '); - g_string_append_c (gstring, token); - token = rc_parse_token_or_compound (scanner, style, gstring, G_TOKEN_RIGHT_CURLY); - if (token != G_TOKEN_NONE) - return token; - break; - case G_TOKEN_LEFT_BRACE: - g_string_append_c (gstring, ' '); - g_string_append_c (gstring, token); - token = rc_parse_token_or_compound (scanner, style, gstring, G_TOKEN_RIGHT_BRACE); - if (token != G_TOKEN_NONE) - return token; - break; - case '@': - if (g_scanner_peek_next_token (scanner) == G_TOKEN_IDENTIFIER) - { - GdkColor color; - gchar rbuf[G_ASCII_DTOSTR_BUF_SIZE]; - gchar gbuf[G_ASCII_DTOSTR_BUF_SIZE]; - gchar bbuf[G_ASCII_DTOSTR_BUF_SIZE]; - - g_scanner_get_next_token (scanner); - - if (!style || !lookup_color (style, scanner->value.v_identifier, - &color)) - { - g_scanner_warn (scanner, "Invalid symbolic color '%s'", - scanner->value.v_identifier); - return G_TOKEN_IDENTIFIER; - } - - - g_string_append_printf (gstring, " { %s, %s, %s }", - g_ascii_formatd (rbuf, sizeof (rbuf), - "%0.4f", - color.red / 65535.0), - g_ascii_formatd (gbuf, sizeof (gbuf), - "%0.4f", - color.green / 65535.0), - g_ascii_formatd (bbuf, sizeof (bbuf), - "%0.4f", - color.blue / 65535.0)); - break; - } - else - return G_TOKEN_IDENTIFIER; - default: - if (token >= 256 || token < 1) - return delimiter ? delimiter : G_TOKEN_STRING; - g_string_append_c (gstring, ' '); - g_string_append_c (gstring, token); - if (token == delimiter) - return G_TOKEN_NONE; - break; - } - if (!delimiter) - return G_TOKEN_NONE; - else - return rc_parse_token_or_compound (scanner, style, gstring, delimiter); -} - -static guint -gtk_rc_parse_assignment (GScanner *scanner, - GtkRcStyle *style, - GtkRcProperty *prop) -{ -#define MY_SCAN_IDENTIFIER TRUE -#define MY_SCAN_SYMBOLS FALSE -#define MY_IDENTIFIER_2_STRING FALSE -#define MY_CHAR_2_TOKEN TRUE -#define MY_SCAN_IDENTIFIER_NULL FALSE -#define MY_NUMBERS_2_INT TRUE - - gboolean scan_identifier = scanner->config->scan_identifier; - gboolean scan_symbols = scanner->config->scan_symbols; - gboolean identifier_2_string = scanner->config->identifier_2_string; - gboolean char_2_token = scanner->config->char_2_token; - gboolean scan_identifier_NULL = scanner->config->scan_identifier_NULL; - gboolean numbers_2_int = scanner->config->numbers_2_int; - gboolean negate = FALSE; - gboolean is_color = FALSE; - guint token; - - /* check that this is an assignment */ - if (g_scanner_get_next_token (scanner) != '=') - return '='; - - /* adjust scanner mode */ - scanner->config->scan_identifier = MY_SCAN_IDENTIFIER; - scanner->config->scan_symbols = MY_SCAN_SYMBOLS; - scanner->config->identifier_2_string = MY_IDENTIFIER_2_STRING; - scanner->config->char_2_token = MY_CHAR_2_TOKEN; - scanner->config->scan_identifier_NULL = MY_SCAN_IDENTIFIER_NULL; - scanner->config->numbers_2_int = MY_NUMBERS_2_INT; - - /* record location */ - if (g_getenv ("GTK_DEBUG")) - prop->origin = g_strdup_printf ("%s:%u", scanner->input_name, scanner->line); - else - prop->origin = NULL; - - /* parse optional symbolic color prefix */ - if (g_scanner_peek_next_token (scanner) == '@') - { - g_scanner_get_next_token (scanner); /* eat color prefix */ - is_color = TRUE; - } - - /* parse optional sign */ - if (!is_color && g_scanner_peek_next_token (scanner) == '-') - { - g_scanner_get_next_token (scanner); /* eat sign */ - negate = TRUE; - } - - /* parse one of LONG, DOUBLE and STRING or, if that fails, create an - * unparsed compund - */ - token = g_scanner_peek_next_token (scanner); - - if (is_color && token != G_TOKEN_IDENTIFIER) - { - token = G_TOKEN_IDENTIFIER; - goto out; - } - - switch (token) - { - case G_TOKEN_INT: - g_scanner_get_next_token (scanner); - g_value_init (&prop->value, G_TYPE_LONG); - g_value_set_long (&prop->value, negate ? -scanner->value.v_int : scanner->value.v_int); - token = G_TOKEN_NONE; - break; - case G_TOKEN_FLOAT: - g_scanner_get_next_token (scanner); - g_value_init (&prop->value, G_TYPE_DOUBLE); - g_value_set_double (&prop->value, negate ? -scanner->value.v_float : scanner->value.v_float); - token = G_TOKEN_NONE; - break; - case G_TOKEN_STRING: - g_scanner_get_next_token (scanner); - if (negate) - token = G_TOKEN_INT; - else - { - g_value_init (&prop->value, G_TYPE_STRING); - g_value_set_string (&prop->value, scanner->value.v_string); - token = G_TOKEN_NONE; - } - break; - case G_TOKEN_IDENTIFIER: - if (is_color) - { - GdkColor color; - gchar rbuf[G_ASCII_DTOSTR_BUF_SIZE]; - gchar gbuf[G_ASCII_DTOSTR_BUF_SIZE]; - gchar bbuf[G_ASCII_DTOSTR_BUF_SIZE]; - GString *gstring; - - g_scanner_get_next_token (scanner); - - if (!style || !lookup_color (style, scanner->value.v_identifier, - &color)) - { - g_scanner_warn (scanner, "Invalid symbolic color '%s'", - scanner->value.v_identifier); - token = G_TOKEN_IDENTIFIER; - break; - } - - gstring = g_string_new (NULL); - - g_string_append_printf (gstring, " { %s, %s, %s }", - g_ascii_formatd (rbuf, sizeof (rbuf), - "%0.4f", - color.red / 65535.0), - g_ascii_formatd (gbuf, sizeof (gbuf), - "%0.4f", - color.green / 65535.0), - g_ascii_formatd (bbuf, sizeof (bbuf), - "%0.4f", - color.blue / 65535.0)); - - g_value_init (&prop->value, G_TYPE_GSTRING); - g_value_take_boxed (&prop->value, gstring); - token = G_TOKEN_NONE; - break; - } - /* fall through */ - case G_TOKEN_LEFT_PAREN: - case G_TOKEN_LEFT_CURLY: - case G_TOKEN_LEFT_BRACE: - if (!negate) - { - GString *gstring = g_string_new (NULL); - gboolean parse_on = TRUE; - - /* allow identifier(foobar) to support color expressions */ - if (token == G_TOKEN_IDENTIFIER) - { - g_scanner_get_next_token (scanner); - - g_string_append_c (gstring, ' '); - g_string_append (gstring, scanner->value.v_identifier); - - /* temporarily reset scanner mode to default, so we - * don't peek the next token in a mode that only makes - * sense in this function; because if anything but - * G_TOKEN_LEFT_PAREN follows, the next token will be - * parsed by our caller. - * - * FIXME: right fix would be to call g_scanner_unget() - * but that doesn't exist - */ - scanner->config->scan_identifier = scan_identifier; - scanner->config->scan_symbols = scan_symbols; - scanner->config->identifier_2_string = identifier_2_string; - scanner->config->char_2_token = char_2_token; - scanner->config->scan_identifier_NULL = scan_identifier_NULL; - scanner->config->numbers_2_int = numbers_2_int; - - token = g_scanner_peek_next_token (scanner); - - /* restore adjusted scanner mode */ - scanner->config->scan_identifier = MY_SCAN_IDENTIFIER; - scanner->config->scan_symbols = MY_SCAN_SYMBOLS; - scanner->config->identifier_2_string = MY_IDENTIFIER_2_STRING; - scanner->config->char_2_token = MY_CHAR_2_TOKEN; - scanner->config->scan_identifier_NULL = MY_SCAN_IDENTIFIER_NULL; - scanner->config->numbers_2_int = MY_NUMBERS_2_INT; - - if (token != G_TOKEN_LEFT_PAREN) - { - token = G_TOKEN_NONE; - parse_on = FALSE; - } - } - - if (parse_on) - token = rc_parse_token_or_compound (scanner, style, gstring, 0); - - if (token == G_TOKEN_NONE) - { - g_string_append_c (gstring, ' '); - g_value_init (&prop->value, G_TYPE_GSTRING); - g_value_take_boxed (&prop->value, gstring); - } - else - g_string_free (gstring, TRUE); - break; - } - /* fall through */ - default: - g_scanner_get_next_token (scanner); - token = G_TOKEN_INT; - break; - } - - out: - - /* restore scanner mode */ - scanner->config->scan_identifier = scan_identifier; - scanner->config->scan_symbols = scan_symbols; - scanner->config->identifier_2_string = identifier_2_string; - scanner->config->char_2_token = char_2_token; - scanner->config->scan_identifier_NULL = scan_identifier_NULL; - scanner->config->numbers_2_int = numbers_2_int; - - return token; -} - -static gboolean -is_c_identifier (const gchar *string) -{ - const gchar *p; - gboolean is_varname; - - is_varname = strchr ("_" G_CSET_a_2_z G_CSET_A_2_Z, string[0]) != NULL; - for (p = string + 1; *p && is_varname; p++) - is_varname &= strchr (G_CSET_DIGITS "-_" G_CSET_a_2_z G_CSET_A_2_Z, *p) != NULL; - - return is_varname; -} - -static void -parse_include_file (GtkRcContext *context, - GScanner *scanner, - const gchar *filename) -{ - char *to_parse = NULL; - - if (g_path_is_absolute (filename)) - { - /* For abolute paths, we call gtk_rc_context_parse_file unconditionally. We - * don't print an error in this case. - */ - to_parse = g_strdup (filename); - } - else - { - /* if a relative path, we look relative to all the RC files in the - * include stack. We require the file to be found in this case - * so we can give meaningful error messages, and because on reparsing - * non-absolute paths don't make sense. - */ - GSList *tmp_list = current_files_stack; - while (tmp_list) - { - GtkRcFile *curfile = tmp_list->data; - gchar *tmpname = g_build_filename (curfile->directory, filename, NULL); - - if (g_file_test (tmpname, G_FILE_TEST_EXISTS)) - { - to_parse = tmpname; - break; - } - - g_free (tmpname); - - tmp_list = tmp_list->next; - } - } - - if (to_parse) - { - gtk_rc_context_parse_file (context, to_parse, context->default_priority, FALSE); - g_free (to_parse); - } - else - { - g_scanner_warn (scanner, - _("Unable to find include file: \"%s\""), - filename); - } - -} - -static guint -gtk_rc_parse_statement (GtkRcContext *context, - GScanner *scanner) -{ - guint token; - - token = g_scanner_peek_next_token (scanner); - switch (token) - { - case GTK_RC_TOKEN_INCLUDE: - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_INCLUDE) - return GTK_RC_TOKEN_INCLUDE; - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - parse_include_file (context, scanner, scanner->value.v_string); - return G_TOKEN_NONE; - - case GTK_RC_TOKEN_STYLE: - return gtk_rc_parse_style (context, scanner); - - case GTK_RC_TOKEN_BINDING: - return _gtk_binding_parse_binding (scanner); - - case GTK_RC_TOKEN_PIXMAP_PATH: - return gtk_rc_parse_pixmap_path (context, scanner); - - case GTK_RC_TOKEN_WIDGET: - return gtk_rc_parse_path_pattern (context, scanner); - - case GTK_RC_TOKEN_WIDGET_CLASS: - return gtk_rc_parse_path_pattern (context, scanner); - - case GTK_RC_TOKEN_CLASS: - return gtk_rc_parse_path_pattern (context, scanner); - - case GTK_RC_TOKEN_MODULE_PATH: - return gtk_rc_parse_module_path (scanner); - - case GTK_RC_TOKEN_IM_MODULE_FILE: - return gtk_rc_parse_im_module_file (scanner); - - case G_TOKEN_IDENTIFIER: - if (is_c_identifier (scanner->next_value.v_identifier)) - { - GtkRcProperty prop = { 0, 0, NULL, { 0, }, }; - gchar *name; - - g_scanner_get_next_token (scanner); /* eat identifier */ - name = g_strdup (scanner->value.v_identifier); - - token = gtk_rc_parse_assignment (scanner, NULL, &prop); - if (token == G_TOKEN_NONE) - { - GtkSettingsValue svalue; - - svalue.origin = prop.origin; - memcpy (&svalue.value, &prop.value, sizeof (prop.value)); - g_strcanon (name, G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-'); - _gtk_settings_set_property_value_from_rc (context->settings, - name, - &svalue); - } - g_free (prop.origin); - if (G_VALUE_TYPE (&prop.value)) - g_value_unset (&prop.value); - g_free (name); - - return token; - } - else - { - g_scanner_get_next_token (scanner); - return G_TOKEN_IDENTIFIER; - } - default: - g_scanner_get_next_token (scanner); - return /* G_TOKEN_SYMBOL */ GTK_RC_TOKEN_STYLE; - } -} - -static void -fixup_rc_set (GSList *list, - GtkRcStyle *orig, - GtkRcStyle *new) -{ - while (list) - { - GtkRcSet *set = list->data; - if (set->rc_style == orig) - set->rc_style = new; - list = list->next; - } -} - -static void -fixup_rc_sets (GtkRcContext *context, - GtkRcStyle *orig, - GtkRcStyle *new) -{ - fixup_rc_set (context->rc_sets_widget, orig, new); - fixup_rc_set (context->rc_sets_widget_class, orig, new); - fixup_rc_set (context->rc_sets_class, orig, new); -} - -static guint -gtk_rc_parse_style (GtkRcContext *context, - GScanner *scanner) -{ - GtkRcStyle *rc_style; - GtkRcStyle *orig_style; - GtkRcStyle *parent_style = NULL; - GtkRcStylePrivate *rc_priv = NULL; - guint token; - gint i; - GtkIconFactory *our_factory = NULL; - GHashTable *our_hash = NULL; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_STYLE) - return GTK_RC_TOKEN_STYLE; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - rc_style = gtk_rc_style_find (context, scanner->value.v_string); - if (rc_style) - orig_style = g_object_ref (rc_style); - else - orig_style = NULL; - - if (!rc_style) - { - rc_style = gtk_rc_style_new (); - rc_style->name = g_strdup (scanner->value.v_string); - - for (i = 0; i < 5; i++) - rc_style->bg_pixmap_name[i] = NULL; - - for (i = 0; i < 5; i++) - rc_style->color_flags[i] = 0; - } - - rc_priv = GTK_RC_STYLE_GET_PRIVATE (rc_style); - - /* If there's a list, its first member is always the factory belonging - * to this RcStyle - */ - if (rc_style->icon_factories) - our_factory = rc_style->icon_factories->data; - if (rc_priv->color_hashes) - our_hash = rc_priv->color_hashes->data; - - token = g_scanner_peek_next_token (scanner); - if (token == G_TOKEN_EQUAL_SIGN) - { - token = g_scanner_get_next_token (scanner); - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - { - token = G_TOKEN_STRING; - goto err; - } - - parent_style = gtk_rc_style_find (context, scanner->value.v_string); - if (parent_style) - { - for (i = 0; i < 5; i++) - { - rc_style->color_flags[i] = parent_style->color_flags[i]; - rc_style->fg[i] = parent_style->fg[i]; - rc_style->bg[i] = parent_style->bg[i]; - rc_style->text[i] = parent_style->text[i]; - rc_style->base[i] = parent_style->base[i]; - } - - rc_style->xthickness = parent_style->xthickness; - rc_style->ythickness = parent_style->ythickness; - - if (parent_style->font_desc) - { - if (rc_style->font_desc) - pango_font_description_free (rc_style->font_desc); - rc_style->font_desc = pango_font_description_copy (parent_style->font_desc); - } - - if (parent_style->rc_properties) - { - guint i; - - for (i = 0; i < parent_style->rc_properties->len; i++) - insert_rc_property (rc_style, - &g_array_index (parent_style->rc_properties, GtkRcProperty, i), - TRUE); - } - - for (i = 0; i < 5; i++) - { - g_free (rc_style->bg_pixmap_name[i]); - rc_style->bg_pixmap_name[i] = g_strdup (parent_style->bg_pixmap_name[i]); - } - } - } - - /* get icon_factories and color_hashes from the parent style; - * if the parent_style doesn't have color_hashes, initializes - * the color_hashes with the settings' color scheme (if it exists) - */ - gtk_rc_style_copy_icons_and_colors (rc_style, parent_style, context); - - if (rc_style->icon_factories) - our_factory = rc_style->icon_factories->data; - if (rc_priv->color_hashes) - our_hash = rc_priv->color_hashes->data; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_LEFT_CURLY) - { - token = G_TOKEN_LEFT_CURLY; - goto err; - } - - token = g_scanner_peek_next_token (scanner); - while (token != G_TOKEN_RIGHT_CURLY) - { - switch (token) - { - case GTK_RC_TOKEN_BG: - token = gtk_rc_parse_bg (scanner, rc_style); - break; - case GTK_RC_TOKEN_FG: - token = gtk_rc_parse_fg (scanner, rc_style); - break; - case GTK_RC_TOKEN_TEXT: - token = gtk_rc_parse_text (scanner, rc_style); - break; - case GTK_RC_TOKEN_BASE: - token = gtk_rc_parse_base (scanner, rc_style); - break; - case GTK_RC_TOKEN_XTHICKNESS: - token = gtk_rc_parse_xthickness (scanner, rc_style); - break; - case GTK_RC_TOKEN_YTHICKNESS: - token = gtk_rc_parse_ythickness (scanner, rc_style); - break; - case GTK_RC_TOKEN_BG_PIXMAP: - token = gtk_rc_parse_bg_pixmap (context, scanner, rc_style); - break; - case GTK_RC_TOKEN_FONT: - token = gtk_rc_parse_font (scanner, rc_style); - break; - case GTK_RC_TOKEN_FONTSET: - token = gtk_rc_parse_fontset (scanner, rc_style); - break; - case GTK_RC_TOKEN_FONT_NAME: - token = gtk_rc_parse_font_name (scanner, rc_style); - break; - case GTK_RC_TOKEN_ENGINE: - token = gtk_rc_parse_engine (context, scanner, &rc_style); - break; - case GTK_RC_TOKEN_STOCK: - if (our_factory == NULL) - gtk_rc_style_prepend_empty_icon_factory (rc_style); - our_factory = rc_style->icon_factories->data; - token = gtk_rc_parse_stock (context, scanner, rc_style, our_factory); - break; - case GTK_RC_TOKEN_COLOR: - if (our_hash == NULL) - { - gtk_rc_style_prepend_empty_color_hash (rc_style); - our_hash = rc_priv->color_hashes->data; - } - token = gtk_rc_parse_logical_color (scanner, rc_style, our_hash); - break; - case G_TOKEN_IDENTIFIER: - if (is_c_identifier (scanner->next_value.v_identifier)) - { - GtkRcProperty prop = { 0, 0, NULL, { 0, }, }; - gchar *name; - - g_scanner_get_next_token (scanner); /* eat type name */ - prop.type_name = g_quark_from_string (scanner->value.v_identifier); - if (g_scanner_get_next_token (scanner) != ':' || - g_scanner_get_next_token (scanner) != ':') - { - token = ':'; - break; - } - if (g_scanner_get_next_token (scanner) != G_TOKEN_IDENTIFIER || - !is_c_identifier (scanner->value.v_identifier)) - { - token = G_TOKEN_IDENTIFIER; - break; - } - - /* it's important that we do the same canonification as GParamSpecPool here */ - name = g_strdup (scanner->value.v_identifier); - g_strcanon (name, G_CSET_DIGITS "-" G_CSET_a_2_z G_CSET_A_2_Z, '-'); - prop.property_name = g_quark_from_string (name); - g_free (name); - - token = gtk_rc_parse_assignment (scanner, rc_style, &prop); - if (token == G_TOKEN_NONE) - { - g_return_val_if_fail (G_VALUE_TYPE (&prop.value) != 0, G_TOKEN_ERROR); - insert_rc_property (rc_style, &prop, TRUE); - } - - g_free (prop.origin); - if (G_VALUE_TYPE (&prop.value)) - g_value_unset (&prop.value); - } - else - { - g_scanner_get_next_token (scanner); - token = G_TOKEN_IDENTIFIER; - } - break; - default: - g_scanner_get_next_token (scanner); - token = G_TOKEN_RIGHT_CURLY; - break; - } - - if (token != G_TOKEN_NONE) - goto err; - - token = g_scanner_peek_next_token (scanner); - } /* while (token != G_TOKEN_RIGHT_CURLY) */ - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_RIGHT_CURLY) - { - token = G_TOKEN_RIGHT_CURLY; - goto err; - } - - if (rc_style != orig_style) - { - if (!context->rc_style_ht) - context->rc_style_ht = g_hash_table_new ((GHashFunc) gtk_rc_style_hash, - (GEqualFunc) gtk_rc_style_equal); - - g_hash_table_replace (context->rc_style_ht, rc_style->name, rc_style); - - /* If we copied the data into a new rc style, fix up references to the old rc style - * in bindings that we have. - */ - if (orig_style) - fixup_rc_sets (context, orig_style, rc_style); - } - - if (orig_style) - g_object_unref (orig_style); - - return G_TOKEN_NONE; - - err: - if (rc_style != orig_style) - g_object_unref (rc_style); - - if (orig_style) - g_object_unref (orig_style); - - return token; -} - const GtkRcProperty* _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style, GQuark type_name, @@ -3252,181 +2302,6 @@ _gtk_rc_style_lookup_rc_property (GtkRcStyle *rc_style, return node; } -static guint -gtk_rc_parse_bg (GScanner *scanner, - GtkRcStyle *style) -{ - GtkStateType state; - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_BG) - return GTK_RC_TOKEN_BG; - - token = gtk_rc_parse_state (scanner, &state); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - style->color_flags[state] |= GTK_RC_BG; - return gtk_rc_parse_color_full (scanner, style, &style->bg[state]); -} - -static guint -gtk_rc_parse_fg (GScanner *scanner, - GtkRcStyle *style) -{ - GtkStateType state; - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_FG) - return GTK_RC_TOKEN_FG; - - token = gtk_rc_parse_state (scanner, &state); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - style->color_flags[state] |= GTK_RC_FG; - return gtk_rc_parse_color_full (scanner, style, &style->fg[state]); -} - -static guint -gtk_rc_parse_text (GScanner *scanner, - GtkRcStyle *style) -{ - GtkStateType state; - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_TEXT) - return GTK_RC_TOKEN_TEXT; - - token = gtk_rc_parse_state (scanner, &state); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - style->color_flags[state] |= GTK_RC_TEXT; - return gtk_rc_parse_color_full (scanner, style, &style->text[state]); -} - -static guint -gtk_rc_parse_base (GScanner *scanner, - GtkRcStyle *style) -{ - GtkStateType state; - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_BASE) - return GTK_RC_TOKEN_BASE; - - token = gtk_rc_parse_state (scanner, &state); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - style->color_flags[state] |= GTK_RC_BASE; - return gtk_rc_parse_color_full (scanner, style, &style->base[state]); -} - -static guint -gtk_rc_parse_xthickness (GScanner *scanner, - GtkRcStyle *style) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_XTHICKNESS) - return GTK_RC_TOKEN_XTHICKNESS; - - if (g_scanner_get_next_token (scanner) != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - if (g_scanner_get_next_token (scanner) != G_TOKEN_INT) - return G_TOKEN_INT; - - style->xthickness = scanner->value.v_int; - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_ythickness (GScanner *scanner, - GtkRcStyle *style) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_YTHICKNESS) - return GTK_RC_TOKEN_YTHICKNESS; - - if (g_scanner_get_next_token (scanner) != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - if (g_scanner_get_next_token (scanner) != G_TOKEN_INT) - return G_TOKEN_INT; - - style->ythickness = scanner->value.v_int; - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_bg_pixmap (GtkRcContext *context, - GScanner *scanner, - GtkRcStyle *rc_style) -{ - GtkStateType state; - guint token; - gchar *pixmap_file; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_BG_PIXMAP) - return GTK_RC_TOKEN_BG_PIXMAP; - - token = gtk_rc_parse_state (scanner, &state); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - if ((strcmp (scanner->value.v_string, "<parent>") == 0) || - (strcmp (scanner->value.v_string, "<none>") == 0)) - pixmap_file = g_strdup (scanner->value.v_string); - else - pixmap_file = gtk_rc_find_pixmap_in_path (context->settings, - scanner, scanner->value.v_string); - - if (pixmap_file) - { - g_free (rc_style->bg_pixmap_name[state]); - rc_style->bg_pixmap_name[state] = pixmap_file; - } - - return G_TOKEN_NONE; -} - static gchar* gtk_rc_check_pixmap_dir (const gchar *dir, const gchar *pixmap_file) @@ -3513,219 +2388,6 @@ gtk_rc_find_module_in_path (const gchar *module_file) return _gtk_find_module (module_file, "engines"); } -static guint -gtk_rc_parse_font (GScanner *scanner, - GtkRcStyle *rc_style) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_FONT) - return GTK_RC_TOKEN_FONT; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - /* Ignore, do nothing */ - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_fontset (GScanner *scanner, - GtkRcStyle *rc_style) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_FONTSET) - return GTK_RC_TOKEN_FONTSET; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - /* Do nothing - silently ignore */ - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_font_name (GScanner *scanner, - GtkRcStyle *rc_style) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_FONT_NAME) - return GTK_RC_TOKEN_FONT; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - return G_TOKEN_EQUAL_SIGN; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - if (rc_style->font_desc) - pango_font_description_free (rc_style->font_desc); - - rc_style->font_desc = - pango_font_description_from_string (scanner->value.v_string); - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_engine (GtkRcContext *context, - GScanner *scanner, - GtkRcStyle **rc_style) -{ - guint token; - GtkThemeEngine *engine; - guint result = G_TOKEN_NONE; - GtkRcStyle *new_style = NULL; - gboolean parsed_curlies = FALSE; - GtkRcStylePrivate *rc_priv, *new_priv; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_ENGINE) - return GTK_RC_TOKEN_ENGINE; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - if (!scanner->value.v_string[0]) - { - /* Support engine "" {} to mean override to the default engine - */ - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_LEFT_CURLY) - return G_TOKEN_LEFT_CURLY; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_RIGHT_CURLY) - return G_TOKEN_RIGHT_CURLY; - - parsed_curlies = TRUE; - - rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style); - - if (G_OBJECT_TYPE (*rc_style) != GTK_TYPE_RC_STYLE) - { - new_style = gtk_rc_style_new (); - gtk_rc_style_real_merge (new_style, *rc_style); - - new_style->name = g_strdup ((*rc_style)->name); - - /* take over icon factories and color hashes - * from the to-be-deleted style - */ - new_style->icon_factories = (*rc_style)->icon_factories; - (*rc_style)->icon_factories = NULL; - new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style); - new_priv->color_hashes = rc_priv->color_hashes; - rc_priv->color_hashes = NULL; - } - else - (*rc_style)->engine_specified = TRUE; - } - else - { - engine = gtk_theme_engine_get (scanner->value.v_string); - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_LEFT_CURLY) - return G_TOKEN_LEFT_CURLY; - - if (engine) - { - GtkRcStyleClass *new_class; - - rc_priv = GTK_RC_STYLE_GET_PRIVATE (*rc_style); - new_style = gtk_theme_engine_create_rc_style (engine); - g_type_module_unuse (G_TYPE_MODULE (engine)); - - new_class = GTK_RC_STYLE_GET_CLASS (new_style); - - new_class->merge (new_style, *rc_style); - - new_style->name = g_strdup ((*rc_style)->name); - - /* take over icon factories and color hashes - * from the to-be-deleted style - */ - new_style->icon_factories = (*rc_style)->icon_factories; - (*rc_style)->icon_factories = NULL; - new_priv = GTK_RC_STYLE_GET_PRIVATE (new_style); - new_priv->color_hashes = rc_priv->color_hashes; - rc_priv->color_hashes = NULL; - - if (new_class->parse) - { - parsed_curlies = TRUE; - result = new_class->parse (new_style, context->settings, scanner); - - if (result != G_TOKEN_NONE) - { - /* copy icon factories and color hashes back - */ - (*rc_style)->icon_factories = new_style->icon_factories; - new_style->icon_factories = NULL; - rc_priv->color_hashes = new_priv->color_hashes; - new_priv->color_hashes = NULL; - - g_object_unref (new_style); - new_style = NULL; - } - } - } - } - - if (!parsed_curlies) - { - /* Skip over remainder, looking for nested {}'s - */ - guint count = 1; - - result = G_TOKEN_RIGHT_CURLY; - while ((token = g_scanner_get_next_token (scanner)) != G_TOKEN_EOF) - { - if (token == G_TOKEN_LEFT_CURLY) - count++; - else if (token == G_TOKEN_RIGHT_CURLY) - count--; - - if (count == 0) - { - result = G_TOKEN_NONE; - break; - } - } - } - - if (new_style) - { - new_style->engine_specified = TRUE; - - g_object_unref (*rc_style); - *rc_style = new_style; - } - - return result; -} - /** * gtk_rc_parse_state: * @scanner: @@ -4079,516 +2741,6 @@ gtk_rc_parse_color_full (GScanner *scanner, } } -static guint -gtk_rc_parse_pixmap_path (GtkRcContext *context, - GScanner *scanner) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_PIXMAP_PATH) - return GTK_RC_TOKEN_PIXMAP_PATH; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - gtk_rc_parse_pixmap_path_string (context, scanner, scanner->value.v_string); - - return G_TOKEN_NONE; -} - -static void -gtk_rc_parse_pixmap_path_string (GtkRcContext *context, - GScanner *scanner, - const gchar *pix_path) -{ - g_strfreev (context->pixmap_path); - context->pixmap_path = g_strsplit (pix_path, G_SEARCHPATH_SEPARATOR_S, -1); -} - -static guint -gtk_rc_parse_module_path (GScanner *scanner) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_MODULE_PATH) - return GTK_RC_TOKEN_MODULE_PATH; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - g_warning ("module_path directive is now ignored\n"); - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_im_module_file (GScanner *scanner) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_IM_MODULE_FILE) - return GTK_RC_TOKEN_IM_MODULE_FILE; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - g_free (im_module_file); - - im_module_file = g_strdup (scanner->value.v_string); - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_path_pattern (GtkRcContext *context, - GScanner *scanner) -{ - guint token; - GtkPathType path_type; - gchar *pattern; - gboolean is_binding; - GtkPathPriorityType priority = context->default_priority; - - token = g_scanner_get_next_token (scanner); - switch (token) - { - case GTK_RC_TOKEN_WIDGET: - path_type = GTK_PATH_WIDGET; - break; - case GTK_RC_TOKEN_WIDGET_CLASS: - path_type = GTK_PATH_WIDGET_CLASS; - break; - case GTK_RC_TOKEN_CLASS: - path_type = GTK_PATH_CLASS; - break; - default: - return GTK_RC_TOKEN_WIDGET_CLASS; - } - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - pattern = g_strdup (scanner->value.v_string); - - token = g_scanner_get_next_token (scanner); - if (token == GTK_RC_TOKEN_STYLE) - is_binding = FALSE; - else if (token == GTK_RC_TOKEN_BINDING) - is_binding = TRUE; - else - { - g_free (pattern); - return GTK_RC_TOKEN_STYLE; - } - - if (g_scanner_peek_next_token (scanner) == ':') - { - token = gtk_rc_parse_priority (scanner, &priority); - if (token != G_TOKEN_NONE) - { - g_free (pattern); - return token; - } - } - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_STRING) - { - g_free (pattern); - return G_TOKEN_STRING; - } - - if (is_binding) - { - GtkBindingSet *binding; - - binding = gtk_binding_set_find (scanner->value.v_string); - if (!binding) - { - g_free (pattern); - return G_TOKEN_STRING; - } - gtk_binding_set_add_path (binding, path_type, pattern, priority); - } - else - { - GtkRcStyle *rc_style; - GtkRcSet *rc_set; - - rc_style = gtk_rc_style_find (context, scanner->value.v_string); - - if (!rc_style) - { - g_free (pattern); - return G_TOKEN_STRING; - } - - rc_set = g_new (GtkRcSet, 1); - rc_set->type = path_type; - - if (path_type == GTK_PATH_WIDGET_CLASS) - { - rc_set->pspec = NULL; - rc_set->path = _gtk_rc_parse_widget_class_path (pattern); - } - else - { - rc_set->pspec = g_pattern_spec_new (pattern); - rc_set->path = NULL; - } - - rc_set->rc_style = rc_style; - rc_set->priority = priority; - - if (path_type == GTK_PATH_WIDGET) - context->rc_sets_widget = g_slist_prepend (context->rc_sets_widget, rc_set); - else if (path_type == GTK_PATH_WIDGET_CLASS) - context->rc_sets_widget_class = g_slist_prepend (context->rc_sets_widget_class, rc_set); - else - context->rc_sets_class = g_slist_prepend (context->rc_sets_class, rc_set); - } - - g_free (pattern); - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_hash_key (GScanner *scanner, - gchar **hash_key) -{ - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_LEFT_BRACE) - return G_TOKEN_LEFT_BRACE; - - token = g_scanner_get_next_token (scanner); - - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - *hash_key = g_strdup (scanner->value.v_string); - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_RIGHT_BRACE) - { - g_free (*hash_key); - return G_TOKEN_RIGHT_BRACE; - } - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_icon_source (GtkRcContext *context, - GScanner *scanner, - GtkIconSet *icon_set, - gboolean *icon_set_valid) -{ - guint token; - gchar *full_filename; - GtkIconSource *source = NULL; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_LEFT_CURLY) - return G_TOKEN_LEFT_CURLY; - - token = g_scanner_get_next_token (scanner); - - if (token != G_TOKEN_STRING && token != '@') - return G_TOKEN_STRING; - - if (token == G_TOKEN_STRING) - { - /* Filename */ - - source = gtk_icon_source_new (); - full_filename = gtk_rc_find_pixmap_in_path (context->settings, scanner, scanner->value.v_string); - if (full_filename) - { - gtk_icon_source_set_filename (source, full_filename); - g_free (full_filename); - } - } - else - { - /* Icon name */ - - token = g_scanner_get_next_token (scanner); - - if (token != G_TOKEN_STRING) - return G_TOKEN_STRING; - - source = gtk_icon_source_new (); - gtk_icon_source_set_icon_name (source, scanner->value.v_string); - } - - /* We continue parsing even if we didn't find the pixmap so that rest of the - * file is read, even if the syntax is bad. However we don't validate the - * icon_set so the caller can choose not to install it. - */ - token = g_scanner_get_next_token (scanner); - - if (token == G_TOKEN_RIGHT_CURLY) - goto done; - else if (token != G_TOKEN_COMMA) - { - gtk_icon_source_free (source); - return G_TOKEN_COMMA; - } - - /* Get the direction */ - - token = g_scanner_get_next_token (scanner); - - switch (token) - { - case GTK_RC_TOKEN_RTL: - gtk_icon_source_set_direction_wildcarded (source, FALSE); - gtk_icon_source_set_direction (source, GTK_TEXT_DIR_RTL); - break; - - case GTK_RC_TOKEN_LTR: - gtk_icon_source_set_direction_wildcarded (source, FALSE); - gtk_icon_source_set_direction (source, GTK_TEXT_DIR_LTR); - break; - - case '*': - break; - - default: - gtk_icon_source_free (source); - return GTK_RC_TOKEN_RTL; - break; - } - - token = g_scanner_get_next_token (scanner); - - if (token == G_TOKEN_RIGHT_CURLY) - goto done; - else if (token != G_TOKEN_COMMA) - { - gtk_icon_source_free (source); - return G_TOKEN_COMMA; - } - - /* Get the state */ - - token = g_scanner_get_next_token (scanner); - - switch (token) - { - case GTK_RC_TOKEN_NORMAL: - gtk_icon_source_set_state_wildcarded (source, FALSE); - gtk_icon_source_set_state (source, GTK_STATE_NORMAL); - break; - - case GTK_RC_TOKEN_PRELIGHT: - gtk_icon_source_set_state_wildcarded (source, FALSE); - gtk_icon_source_set_state (source, GTK_STATE_PRELIGHT); - break; - - - case GTK_RC_TOKEN_INSENSITIVE: - gtk_icon_source_set_state_wildcarded (source, FALSE); - gtk_icon_source_set_state (source, GTK_STATE_INSENSITIVE); - break; - - case GTK_RC_TOKEN_ACTIVE: - gtk_icon_source_set_state_wildcarded (source, FALSE); - gtk_icon_source_set_state (source, GTK_STATE_ACTIVE); - break; - - case GTK_RC_TOKEN_SELECTED: - gtk_icon_source_set_state_wildcarded (source, FALSE); - gtk_icon_source_set_state (source, GTK_STATE_SELECTED); - break; - - case '*': - break; - - default: - gtk_icon_source_free (source); - return GTK_RC_TOKEN_PRELIGHT; - break; - } - - token = g_scanner_get_next_token (scanner); - - if (token == G_TOKEN_RIGHT_CURLY) - goto done; - else if (token != G_TOKEN_COMMA) - { - gtk_icon_source_free (source); - return G_TOKEN_COMMA; - } - - /* Get the size */ - - token = g_scanner_get_next_token (scanner); - - if (token != '*') - { - GtkIconSize size; - - if (token != G_TOKEN_STRING) - { - gtk_icon_source_free (source); - return G_TOKEN_STRING; - } - - size = gtk_icon_size_from_name (scanner->value.v_string); - - if (size != GTK_ICON_SIZE_INVALID) - { - gtk_icon_source_set_size_wildcarded (source, FALSE); - gtk_icon_source_set_size (source, size); - } - } - - /* Check the close brace */ - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_RIGHT_CURLY) - { - gtk_icon_source_free (source); - return G_TOKEN_RIGHT_CURLY; - } - - done: - if (gtk_icon_source_get_filename (source) || - gtk_icon_source_get_icon_name (source)) - { - gtk_icon_set_add_source (icon_set, source); - *icon_set_valid = TRUE; - } - gtk_icon_source_free (source); - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_stock (GtkRcContext *context, - GScanner *scanner, - GtkRcStyle *rc_style, - GtkIconFactory *factory) -{ - GtkIconSet *icon_set = NULL; - gboolean icon_set_valid = FALSE; - gchar *stock_id = NULL; - guint token; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_STOCK) - return GTK_RC_TOKEN_STOCK; - - token = gtk_rc_parse_hash_key (scanner, &stock_id); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - { - g_free (stock_id); - return G_TOKEN_EQUAL_SIGN; - } - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_LEFT_CURLY) - { - g_free (stock_id); - return G_TOKEN_LEFT_CURLY; - } - - token = g_scanner_peek_next_token (scanner); - while (token != G_TOKEN_RIGHT_CURLY) - { - if (icon_set == NULL) - icon_set = gtk_icon_set_new (); - - token = gtk_rc_parse_icon_source (context, - scanner, icon_set, &icon_set_valid); - if (token != G_TOKEN_NONE) - { - g_free (stock_id); - gtk_icon_set_unref (icon_set); - return token; - } - - token = g_scanner_get_next_token (scanner); - - if (token != G_TOKEN_COMMA && - token != G_TOKEN_RIGHT_CURLY) - { - g_free (stock_id); - gtk_icon_set_unref (icon_set); - return G_TOKEN_RIGHT_CURLY; - } - } - - if (icon_set) - { - if (icon_set_valid) - gtk_icon_factory_add (factory, - stock_id, - icon_set); - - gtk_icon_set_unref (icon_set); - } - - g_free (stock_id); - - return G_TOKEN_NONE; -} - -static guint -gtk_rc_parse_logical_color (GScanner *scanner, - GtkRcStyle *rc_style, - GHashTable *hash) -{ - gchar *color_id = NULL; - guint token; - GdkColor color; - - token = g_scanner_get_next_token (scanner); - if (token != GTK_RC_TOKEN_COLOR) - return GTK_RC_TOKEN_COLOR; - - token = gtk_rc_parse_hash_key (scanner, &color_id); - if (token != G_TOKEN_NONE) - return token; - - token = g_scanner_get_next_token (scanner); - if (token != G_TOKEN_EQUAL_SIGN) - { - g_free (color_id); - return G_TOKEN_EQUAL_SIGN; - } - - token = gtk_rc_parse_color_full (scanner, rc_style, &color); - if (token != G_TOKEN_NONE) - { - g_free (color_id); - return token; - } - - /* Because the hash is created with destroy functions, - * g_hash_table_insert will free any old values for us, - * if a mapping with the specified key already exists. - */ - g_hash_table_insert (hash, color_id, gdk_color_copy (&color)); - - return G_TOKEN_NONE; -} - - GSList * _gtk_rc_parse_widget_class_path (const gchar *pattern) { diff --git a/gtk/gtkscale.c b/gtk/gtkscale.c index cd00b2ea2e..d81868e52e 100644 --- a/gtk/gtkscale.c +++ b/gtk/gtkscale.c @@ -127,8 +127,7 @@ static void gtk_scale_get_preferred_width (GtkWidget *widget, static void gtk_scale_get_preferred_height (GtkWidget *widget, gint *minimum, gint *natural); -static void gtk_scale_style_set (GtkWidget *widget, - GtkStyle *previous); +static void gtk_scale_style_updated (GtkWidget *widget); static void gtk_scale_get_range_border (GtkRange *range, GtkBorder *border); static void gtk_scale_get_mark_label_size (GtkScale *scale, @@ -204,7 +203,7 @@ gtk_scale_class_init (GtkScaleClass *class) gobject_class->get_property = gtk_scale_get_property; gobject_class->finalize = gtk_scale_finalize; - widget_class->style_set = gtk_scale_style_set; + widget_class->style_updated = gtk_scale_style_updated; widget_class->screen_changed = gtk_scale_screen_changed; widget_class->draw = gtk_scale_draw; widget_class->get_preferred_width = gtk_scale_get_preferred_width; @@ -430,6 +429,7 @@ gtk_scale_init (GtkScale *scale) { GtkScalePrivate *priv; GtkRange *range = GTK_RANGE (scale); + GtkStyleContext *context; scale->priv = G_TYPE_INSTANCE_GET_PRIVATE (scale, GTK_TYPE_SCALE, @@ -449,6 +449,9 @@ gtk_scale_init (GtkScale *scale) g_signal_connect (scale, "notify::orientation", G_CALLBACK (gtk_scale_orientation_notify), NULL); + + context = gtk_widget_get_style_context (GTK_WIDGET (scale)); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_SCALE); } static void @@ -921,8 +924,7 @@ gtk_scale_get_mark_label_size (GtkScale *scale, } static void -gtk_scale_style_set (GtkWidget *widget, - GtkStyle *previous) +gtk_scale_style_updated (GtkWidget *widget) { gint slider_length; GtkRange *range; @@ -937,7 +939,7 @@ gtk_scale_style_set (GtkWidget *widget, _gtk_scale_clear_layout (GTK_SCALE (widget)); - GTK_WIDGET_CLASS (gtk_scale_parent_class)->style_set (widget, previous); + GTK_WIDGET_CLASS (gtk_scale_parent_class)->style_updated (widget); } static void @@ -1032,8 +1034,8 @@ gtk_scale_draw (GtkWidget *widget, GtkScale *scale = GTK_SCALE (widget); GtkScalePrivate *priv = scale->priv; GtkRange *range = GTK_RANGE (scale); - GtkStateType state_type; - GtkStyle *style; + GtkStateFlags state = 0; + GtkStyleContext *context; gint n_marks; gint *marks; gint focus_padding; @@ -1041,7 +1043,7 @@ gtk_scale_draw (GtkWidget *widget, gint value_spacing; gint min_sep = 4; - style = gtk_widget_get_style (widget); + context = gtk_widget_get_style_context (widget); gtk_widget_style_get (widget, "focus-padding", &focus_padding, "slider-width", &slider_width, @@ -1053,9 +1055,8 @@ gtk_scale_draw (GtkWidget *widget, */ GTK_WIDGET_CLASS (gtk_scale_parent_class)->draw (widget, cr); - state_type = GTK_STATE_NORMAL; if (!gtk_widget_is_sensitive (widget)) - state_type = GTK_STATE_INSENSITIVE; + state |= GTK_STATE_FLAG_INSENSITIVE; if (priv->marks) { @@ -1098,8 +1099,12 @@ gtk_scale_draw (GtkWidget *widget, max_pos = find_next_pos (widget, m, marks + i, GTK_POS_TOP, 0) - min_sep; } - gtk_paint_vline (style, cr, state_type, - widget, "scale-mark", y1, y2, x1); + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK); + gtk_style_context_set_state (context, state); + + gtk_render_line (context, cr, + x1, y1, x1, y2); if (mark->markup) { @@ -1124,10 +1129,11 @@ gtk_scale_draw (GtkWidget *widget, min_pos_after = x3 + logical_rect.width + min_sep; } - gtk_paint_layout (style, cr, state_type, - FALSE, widget, "scale-mark", - x3, y3, layout); + gtk_render_layout (context, cr, + x3, y3, layout); } + + gtk_style_context_restore (context); } else { @@ -1147,8 +1153,12 @@ gtk_scale_draw (GtkWidget *widget, } y1 = marks[i]; - gtk_paint_hline (style, cr, state_type, - widget, "range-mark", x1, x2, y1); + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_MARK); + gtk_style_context_set_state (context, state); + + gtk_render_line (context, cr, + x1, y1, x2, y1); if (mark->markup) { @@ -1173,10 +1183,11 @@ gtk_scale_draw (GtkWidget *widget, min_pos_after = y3 + logical_rect.height + min_sep; } - gtk_paint_layout (style, cr, state_type, - FALSE, widget, "scale-mark", - x3, y3, layout); + gtk_render_layout (context, cr, + x3, y3, layout); } + + gtk_style_context_restore (context); } } @@ -1197,17 +1208,10 @@ gtk_scale_draw (GtkWidget *widget, gtk_scale_get_layout_offsets (scale, &x, &y); gtk_widget_get_allocation (widget, &allocation); - gtk_paint_layout (style, - cr, - state_type, - FALSE, - widget, - orientation == GTK_ORIENTATION_HORIZONTAL ? - "hscale" : "vscale", - x - allocation.x, - y - allocation.y, - layout); - + gtk_render_layout (context, cr, + x - allocation.x, + y - allocation.y, + layout); } return FALSE; diff --git a/gtk/gtkscrollbar.c b/gtk/gtkscrollbar.c index df4ad75b9c..4a852f2bed 100644 --- a/gtk/gtkscrollbar.c +++ b/gtk/gtkscrollbar.c @@ -56,8 +56,7 @@ */ -static void gtk_scrollbar_style_set (GtkWidget *widget, - GtkStyle *previous); +static void gtk_scrollbar_style_updated (GtkWidget *widget); G_DEFINE_TYPE (GtkScrollbar, gtk_scrollbar, GTK_TYPE_RANGE) @@ -66,9 +65,7 @@ gtk_scrollbar_class_init (GtkScrollbarClass *class) { GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); - widget_class->style_set = gtk_scrollbar_style_set; - - GTK_RANGE_CLASS (class)->stepper_detail = "Xscrollbar"; + widget_class->style_updated = gtk_scrollbar_style_updated; gtk_widget_class_install_style_property (widget_class, g_param_spec_int ("min-slider-length", @@ -125,8 +122,7 @@ gtk_scrollbar_init (GtkScrollbar *scrollbar) } static void -gtk_scrollbar_style_set (GtkWidget *widget, - GtkStyle *previous) +gtk_scrollbar_style_updated (GtkWidget *widget) { GtkRange *range = GTK_RANGE (widget); gint slider_length; @@ -147,7 +143,7 @@ gtk_scrollbar_style_set (GtkWidget *widget, _gtk_range_set_steppers (range, has_a, has_b, has_c, has_d); - GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_set (widget, previous); + GTK_WIDGET_CLASS (gtk_scrollbar_parent_class)->style_updated (widget); } /** diff --git a/gtk/gtksearchenginetracker.c b/gtk/gtksearchenginetracker.c index e46691a944..ad9ff7fe2f 100644 --- a/gtk/gtksearchenginetracker.c +++ b/gtk/gtksearchenginetracker.c @@ -1,5 +1,4 @@ /* - * Copyright (C) 2005 Jamie McCracken <jamiemcc@gnome.org> * Copyright (C) 2009-2010 Nokia <ivan.frade@nokia.com> * * This library is free software; you can redistribute it and/or @@ -16,163 +15,143 @@ * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * - * Authors: Jamie McCracken <jamiemcc@gnome.org> - * Jürg Billeter <juerg.billeter@codethink.co.uk> + * Authors: Jürg Billeter <juerg.billeter@codethink.co.uk> * Martyn Russell <martyn@lanedo.com> * * Based on nautilus-search-engine-tracker.c */ #include "config.h" -#include <gmodule.h> -#include "gtksearchenginetracker.h" -/* we dlopen() libtracker at runtime */ +#include <gio/gio.h> +#include <gmodule.h> -typedef struct _TrackerClient TrackerClient; +#include "gtksearchenginetracker.h" -typedef enum -{ - TRACKER_UNAVAILABLE = 0, - TRACKER_0_6 = 1 << 0, - TRACKER_0_7 = 1 << 1, - TRACKER_0_8 = 1 << 2, - TRACKER_0_9 = 1 << 3 -} TrackerVersion; - - -/* Tracker 0.6 API */ -typedef void (*TrackerArrayReply) (char **result, - GError *error, - gpointer user_data); - -static TrackerClient * - (*tracker_connect) (gboolean enable_warnings, - gint timeout) = NULL; -static void (*tracker_disconnect) (TrackerClient *client) = NULL; -static int (*tracker_get_version) (TrackerClient *client, - GError **error) = NULL; -static void (*tracker_cancel_last_call) (TrackerClient *client) = NULL; - -static void (*tracker_search_metadata_by_text_async) (TrackerClient *client, - const char *query, - TrackerArrayReply callback, - gpointer user_data) = NULL; -static void (*tracker_search_metadata_by_text_and_location_async) (TrackerClient *client, - const char *query, - const char *location, - TrackerArrayReply callback, - gpointer user_data) = NULL; - - -/* Tracker 0.7->0.9 API */ -typedef enum { - TRACKER_CLIENT_ENABLE_WARNINGS = 1 << 0 -} TrackerClientFlags; - -typedef void (*TrackerReplyGPtrArray) (GPtrArray *result, - GError *error, - gpointer user_data); - -static TrackerClient * (*tracker_client_new) (TrackerClientFlags flags, - gint timeout) = NULL; -static gchar * (*tracker_sparql_escape) (const gchar *str) = NULL; -static guint (*tracker_resources_sparql_query_async) (TrackerClient *client, - const gchar *query, - TrackerReplyGPtrArray callback, - gpointer user_data) = NULL; - - -static struct TrackerDlMapping -{ - const char *fn_name; - gpointer *fn_ptr_ref; - TrackerVersion versions; -} tracker_dl_mapping[] = +/* If defined, we use fts:match, this has to be enabled in Tracker to + * work which it usually is. The alternative is to undefine it and + * use filename matching instead. This doesn't use the content of the + * file however. + */ +#undef FTS_MATCHING + +#define MODULE_FILENAME "libtracker-sparql-0.10.so.0" + +#define MODULE_MAP(a) { #a, (gpointer *)&a } + +/* Connection object */ +typedef struct _TrackerSparqlConnection TrackerSparqlConnection; + +#define TRACKER_SPARQL_TYPE_CONNECTION (tracker_sparql_connection_get_type ()) +#define TRACKER_SPARQL_CONNECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_SPARQL_TYPE_CONNECTION, TrackerSparqlConnection)) + +/* Cursor object */ +typedef struct _TrackerSparqlCursor TrackerSparqlCursor; + +#define TRACKER_SPARQL_TYPE_CURSOR (tracker_sparql_cursor_get_type ()) +#define TRACKER_SPARQL_CURSOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TRACKER_SPARQL_TYPE_CURSOR, TrackerSparqlCursor)) + +/* API */ +static GType (*tracker_sparql_connection_get_type) (void) = NULL; +static TrackerSparqlConnection * (*tracker_sparql_connection_get) (GCancellable *cancellable, + GError **error) = NULL; +static void (*tracker_sparql_connection_query_async) (TrackerSparqlConnection *self, + const gchar *sparql, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) = NULL; +static TrackerSparqlCursor * (*tracker_sparql_connection_query_finish) (TrackerSparqlConnection *self, + GAsyncResult *_res_, + GError **error) = NULL; +static GType (*tracker_sparql_cursor_get_type) (void) = NULL; +static void (*tracker_sparql_cursor_next_async) (TrackerSparqlCursor *self, + GCancellable *cancellable, + GAsyncReadyCallback callback, + gpointer user_data) = NULL; +static gboolean (*tracker_sparql_cursor_next_finish) (TrackerSparqlCursor *self, + GAsyncResult *_res_, + GError **error) = NULL; +static const gchar * (*tracker_sparql_cursor_get_string) (TrackerSparqlCursor *self, + gint *column, + glong *length) = NULL; +static gchar * (*tracker_sparql_escape_string) (const gchar *literal) = NULL; + +static struct TrackerFunctions { -#define MAP(a,v) { #a, (gpointer *)&a, v } - MAP (tracker_connect, TRACKER_0_6 | TRACKER_0_7), - MAP (tracker_disconnect, TRACKER_0_6 | TRACKER_0_7), - MAP (tracker_get_version, TRACKER_0_6), - MAP (tracker_cancel_last_call, TRACKER_0_6 | TRACKER_0_7 | TRACKER_0_8 | TRACKER_0_9), - MAP (tracker_search_metadata_by_text_async, TRACKER_0_6 | TRACKER_0_7), - MAP (tracker_search_metadata_by_text_and_location_async, TRACKER_0_6 | TRACKER_0_7), - MAP (tracker_client_new, TRACKER_0_8 | TRACKER_0_9), - MAP (tracker_sparql_escape, TRACKER_0_8 | TRACKER_0_9), - MAP (tracker_resources_sparql_query_async, TRACKER_0_8 | TRACKER_0_9) -#undef MAP + const char *name; + gpointer *pointer; +} funcs[] = { + MODULE_MAP (tracker_sparql_connection_get_type), + MODULE_MAP (tracker_sparql_connection_get), + MODULE_MAP (tracker_sparql_connection_query_async), + MODULE_MAP (tracker_sparql_connection_query_finish), + MODULE_MAP (tracker_sparql_cursor_get_type), + MODULE_MAP (tracker_sparql_cursor_next_async), + MODULE_MAP (tracker_sparql_cursor_next_finish), + MODULE_MAP (tracker_sparql_cursor_get_string), + MODULE_MAP (tracker_sparql_escape_string) }; -static TrackerVersion -open_libtracker (void) +static gboolean +init (void) { - static gboolean done = FALSE; - static TrackerVersion version = TRACKER_UNAVAILABLE; - - if (!done) - { - gint i; - GModule *tracker; - GModuleFlags flags; - - done = TRUE; - flags = G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL; - - /* So this is the order: - * - * - 0.9 (latest unstable) - * - 0.8 (stable) - * - 0.7 (unstable, 0.6 sucks so badly) - * - 0.6 (stable) - */ - if ((tracker = g_module_open ("libtracker-client-0.9.so.0", flags)) != NULL) - version = TRACKER_0_9; - else if ((tracker = g_module_open ("libtracker-client-0.8.so.0", flags)) != NULL) - version = TRACKER_0_8; - else if ((tracker = g_module_open ("libtracker-client-0.7.so.0", flags)) != NULL) - version = TRACKER_0_7; - else if ((tracker = g_module_open ("libtrackerclient.so.0", flags)) != NULL) - version = TRACKER_0_6; - else - { - g_debug ("No tracker backend available"); - return TRACKER_UNAVAILABLE; - } - - for (i = 0; i < G_N_ELEMENTS (tracker_dl_mapping); i++) - { - if ((tracker_dl_mapping[i].versions & version) == 0) - continue; - - if (!g_module_symbol (tracker, - tracker_dl_mapping[i].fn_name, - tracker_dl_mapping[i].fn_ptr_ref)) - { - g_warning ("Missing symbol '%s' in libtracker\n", - tracker_dl_mapping[i].fn_name); - g_module_close (tracker); - - for (i = 0; i < G_N_ELEMENTS (tracker_dl_mapping); i++) - tracker_dl_mapping[i].fn_ptr_ref = NULL; - - return TRACKER_UNAVAILABLE; + static gboolean inited = FALSE; + gint i; + GModule *m; + GModuleFlags flags; + + if (inited) + return TRUE; + + flags = G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL; + + /* Only support 0.10 onwards */ + if ((m = g_module_open (MODULE_FILENAME, flags)) == NULL) + { + g_debug ("No tracker backend available or it is not new enough"); + g_debug ("Only available using '%s'", MODULE_FILENAME); + return FALSE; + } + + inited = TRUE; + + /* Check for the symbols we need */ + for (i = 0; i < G_N_ELEMENTS (funcs); i++) + { + if (!g_module_symbol (m, funcs[i].name, funcs[i].pointer)) + { + g_warning ("Missing symbol '%s' in libtracker-sparql\n", + funcs[i].name); + g_module_close (m); + + for (i = 0; i < G_N_ELEMENTS (funcs); i++) + funcs[i].pointer = NULL; + + return FALSE; + } } - } - } - return version; + g_debug ("Loaded Tracker library and all required symbols"); + + return TRUE; } +/* + * GtkSearchEngineTracker object + */ struct _GtkSearchEngineTrackerPrivate { - GtkQuery *query; - TrackerClient *client; - gboolean query_pending; - TrackerVersion version; + TrackerSparqlConnection *connection; + GCancellable *cancellable; + GtkQuery *query; + gboolean query_pending; }; G_DEFINE_TYPE (GtkSearchEngineTracker, _gtk_search_engine_tracker, GTK_TYPE_SEARCH_ENGINE); +static void cursor_callback (GObject *object, + GAsyncResult *result, + gpointer user_data); static void finalize (GObject *object) @@ -181,56 +160,106 @@ finalize (GObject *object) tracker = GTK_SEARCH_ENGINE_TRACKER (object); + if (tracker->priv->cancellable) + { + g_cancellable_cancel (tracker->priv->cancellable); + g_object_unref (tracker->priv->cancellable); + tracker->priv->cancellable = NULL; + } + if (tracker->priv->query) { g_object_unref (tracker->priv->query); tracker->priv->query = NULL; } - if (tracker->priv->version == TRACKER_0_8 || - tracker->priv->version == TRACKER_0_9) - g_object_unref (tracker->priv->client); - else - tracker_disconnect (tracker->priv->client); + if (tracker->priv->connection) + { + g_object_unref (tracker->priv->connection); + tracker->priv->connection = NULL; + } G_OBJECT_CLASS (_gtk_search_engine_tracker_parent_class)->finalize (object); } +static void +cursor_next (GtkSearchEngineTracker *tracker, + TrackerSparqlCursor *cursor) +{ + tracker_sparql_cursor_next_async (cursor, + tracker->priv->cancellable, + cursor_callback, + tracker); +} -/* stolen from tracker sources, tracker.c */ static void -sparql_append_string_literal (GString *sparql, - const gchar *str) +cursor_callback (GObject *object, + GAsyncResult *result, + gpointer user_data) { - gchar *s; + GtkSearchEngineTracker *tracker; + GError *error = NULL; + TrackerSparqlCursor *cursor; + GList *hits; + gboolean success; - s = tracker_sparql_escape (str); + tracker = GTK_SEARCH_ENGINE_TRACKER (user_data); - g_string_append_c (sparql, '"'); - g_string_append (sparql, s); - g_string_append_c (sparql, '"'); + cursor = TRACKER_SPARQL_CURSOR (object); + success = tracker_sparql_cursor_next_finish (cursor, result, &error); - g_free (s); -} + if (error) + { + _gtk_search_engine_error (GTK_SEARCH_ENGINE (tracker), error->message); + + g_error_free (error); + + if (cursor) + g_object_unref (cursor); + + return; + } + + if (!success) + { + _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker)); + + if (cursor) + g_object_unref (cursor); + + return; + } + + /* We iterate result by result, not n at a time. */ + hits = g_list_append (NULL, (gchar*) tracker_sparql_cursor_get_string (cursor, 0, NULL)); + _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (tracker), hits); + g_list_free (hits); + /* Get next */ + cursor_next (tracker, cursor); +} static void -search_callback (gpointer results, - GError *error, - gpointer user_data) +query_callback (GObject *object, + GAsyncResult *result, + gpointer user_data) { GtkSearchEngineTracker *tracker; - gchar **results_p; - GList *hit_uris; - GPtrArray *OUT_result; - gchar *uri; - gint i; + TrackerSparqlConnection *connection; + TrackerSparqlCursor *cursor; + GError *error = NULL; tracker = GTK_SEARCH_ENGINE_TRACKER (user_data); - hit_uris = NULL; tracker->priv->query_pending = FALSE; + connection = TRACKER_SPARQL_CONNECTION (object); + cursor = tracker_sparql_connection_query_finish (connection, + result, + &error); + + g_debug ("Query returned cursor:%p", cursor); + if (error) { _gtk_search_engine_error (GTK_SEARCH_ENGINE (tracker), error->message); @@ -238,118 +267,96 @@ search_callback (gpointer results, return; } - if (!results) - return; + if (!cursor) + { + _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker)); + return; + } - if (tracker->priv->version == TRACKER_0_8 || - tracker->priv->version == TRACKER_0_9) - { - OUT_result = (GPtrArray*) results; + cursor_next (tracker, cursor); +} - for (i = 0; i < OUT_result->len; i++) - { - uri = g_strdup (((gchar **) OUT_result->pdata[i])[0]); - if (uri) - hit_uris = g_list_prepend (hit_uris, uri); - } +static void +sparql_append_string_literal (GString *sparql, + const gchar *str) +{ + gchar *s; - g_ptr_array_foreach (OUT_result, (GFunc) g_free, NULL); - g_ptr_array_free (OUT_result, TRUE); - } - else - { - for (results_p = results; *results_p; results_p++) - { - if (tracker->priv->version == TRACKER_0_6) - uri = g_filename_to_uri (*results_p, NULL, NULL); - else - uri = g_strdup (*results_p); - - if (uri) - hit_uris = g_list_prepend (hit_uris, uri); - } - g_strfreev ((gchar **) results); - } + s = tracker_sparql_escape_string (str); - _gtk_search_engine_hits_added (GTK_SEARCH_ENGINE (tracker), hit_uris); - _gtk_search_engine_finished (GTK_SEARCH_ENGINE (tracker)); + g_string_append_c (sparql, '"'); + g_string_append (sparql, s); + g_string_append_c (sparql, '"'); - g_list_foreach (hit_uris, (GFunc) g_free, NULL); - g_list_free (hit_uris); + g_free (s); } - static void gtk_search_engine_tracker_start (GtkSearchEngine *engine) { GtkSearchEngineTracker *tracker; - gchar *search_text, *location, *location_uri; + gchar *search_text, *location_uri; GString *sparql; tracker = GTK_SEARCH_ENGINE_TRACKER (engine); if (tracker->priv->query_pending) - return; + { + g_debug ("Attempt to start a new search while one is pending, doing nothing"); + return; + } if (tracker->priv->query == NULL) - return; + { + g_debug ("Attempt to start a new search with no GtkQuery, doing nothing"); + return; + } search_text = _gtk_query_get_text (tracker->priv->query); location_uri = _gtk_query_get_location (tracker->priv->query); - location = NULL; - if (location_uri) - { - if (tracker->priv->version == TRACKER_0_6) - { - location = g_filename_from_uri (location_uri, NULL, NULL); - g_free (location_uri); - } - else - location = location_uri; - } + g_debug ("Query starting, search criteria:'%s', location:'%s'", search_text, location_uri); - if (tracker->priv->version == TRACKER_0_8 || - tracker->priv->version == TRACKER_0_9) - { - sparql = g_string_new ("SELECT nie:url(?urn) WHERE { ?urn a nfo:FileDataObject; fts:match "); - sparql_append_string_literal (sparql, search_text); - if (location) - { - g_string_append (sparql, " . FILTER (fn:starts-with(nie:url(?urn),"); - sparql_append_string_literal (sparql, location); - g_string_append (sparql, "))"); - } - g_string_append (sparql, " } ORDER BY DESC(fts:rank(?urn)) ASC(nie:url(?urn))"); - - tracker_resources_sparql_query_async (tracker->priv->client, - sparql->str, - (TrackerReplyGPtrArray) search_callback, - tracker); - g_string_free (sparql, TRUE); - } - else - { - if (location) - { - tracker_search_metadata_by_text_and_location_async (tracker->priv->client, - search_text, - location, - (TrackerArrayReply) search_callback, - tracker); - } - else - { - tracker_search_metadata_by_text_async (tracker->priv->client, - search_text, - (TrackerArrayReply) search_callback, - tracker); - } - } + /* Using FTS: */ + sparql = g_string_new ("SELECT nie:url(?urn) " + "WHERE {" + " ?urn a nfo:FileDataObject ;" + " tracker:available true ; " + " fts:match "); + sparql_append_string_literal (sparql, search_text); + +#ifdef FTS_MATCHING + if (location_uri) + { + g_string_append (sparql, " . FILTER (fn:starts-with(nie:url(?urn),"); + sparql_append_string_literal (sparql, location_uri); + g_string_append (sparql, "))"); + } + + g_string_append (sparql, " } ORDER BY DESC(fts:rank(?urn)) ASC(nie:url(?urn))"); +#else /* FTS_MATCHING */ + /* Using filename matching: */ + sparql = g_string_new ("SELECT nie:url(?urn) " + "WHERE {" + " ?urn a nfo:FileDataObject ;" + " tracker:available true ." + " FILTER (fn:contains(nfo:fileName(?urn),"); + sparql_append_string_literal (sparql, search_text); + + g_string_append (sparql, + "))" + "} ORDER BY DESC(nie:url(?urn)) DESC(nfo:fileName(?urn))"); +#endif /* FTS_MATCHING */ + + tracker_sparql_connection_query_async (tracker->priv->connection, + sparql->str, + tracker->priv->cancellable, + query_callback, + tracker); + g_string_free (sparql, TRUE); tracker->priv->query_pending = TRUE; g_free (search_text); - g_free (location); } static void @@ -359,9 +366,11 @@ gtk_search_engine_tracker_stop (GtkSearchEngine *engine) tracker = GTK_SEARCH_ENGINE_TRACKER (engine); + g_debug ("Query stopping"); + if (tracker->priv->query && tracker->priv->query_pending) { - tracker_cancel_last_call (tracker->priv->client); + g_cancellable_cancel (tracker->priv->cancellable); tracker->priv->query_pending = FALSE; } } @@ -374,7 +383,7 @@ gtk_search_engine_tracker_is_indexed (GtkSearchEngine *engine) static void gtk_search_engine_tracker_set_query (GtkSearchEngine *engine, - GtkQuery *query) + GtkQuery *query) { GtkSearchEngineTracker *tracker; @@ -410,7 +419,9 @@ _gtk_search_engine_tracker_class_init (GtkSearchEngineTrackerClass *class) static void _gtk_search_engine_tracker_init (GtkSearchEngineTracker *engine) { - engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, GTK_TYPE_SEARCH_ENGINE_TRACKER, GtkSearchEngineTrackerPrivate); + engine->priv = G_TYPE_INSTANCE_GET_PRIVATE (engine, + GTK_TYPE_SEARCH_ENGINE_TRACKER, + GtkSearchEngineTrackerPrivate); } @@ -418,49 +429,35 @@ GtkSearchEngine * _gtk_search_engine_tracker_new (void) { GtkSearchEngineTracker *engine; - TrackerClient *tracker_client; - TrackerVersion version; - GError *err = NULL; - - version = open_libtracker (); - - if (version == TRACKER_0_8 || - version == TRACKER_0_9) - { - tracker_client = tracker_client_new (TRACKER_CLIENT_ENABLE_WARNINGS, G_MAXINT); - } - else - { - if (!tracker_connect) - return NULL; - - tracker_client = tracker_connect (FALSE, -1); - } - - if (!tracker_client) - return NULL; - - - if (version == TRACKER_0_6) - { - if (!tracker_get_version) - return NULL; - - tracker_get_version (tracker_client, &err); - - if (err != NULL) - { - g_error_free (err); - tracker_disconnect (tracker_client); - return NULL; - } - } + TrackerSparqlConnection *connection; + GCancellable *cancellable; + GError *error = NULL; + + if (!init ()) + return NULL; + + g_debug ("Creating GtkSearchEngineTracker..."); + + cancellable = g_cancellable_new (); + connection = tracker_sparql_connection_get (cancellable, &error); + + if (error) + { + g_warning ("Could not establish a connection to Tracker: %s", error->message); + g_error_free (error); + return NULL; + } + else if (!connection) + { + g_warning ("Could not establish a connection to Tracker, no TrackerSparqlConnection was returned"); + return NULL; + } engine = g_object_new (GTK_TYPE_SEARCH_ENGINE_TRACKER, NULL); - engine->priv->client = tracker_client; + engine->priv->connection = connection; + engine->priv->cancellable = cancellable; engine->priv->query_pending = FALSE; - engine->priv->version = version; return GTK_SEARCH_ENGINE (engine); } diff --git a/gtk/gtksizerequest.c b/gtk/gtksizerequest.c index c5e49e7db3..41ec2599f4 100644 --- a/gtk/gtksizerequest.c +++ b/gtk/gtksizerequest.c @@ -239,6 +239,14 @@ compute_size_for_orientation (GtkWidget *widget, &min_size, &nat_size); pop_recursion_check (widget, orientation); } +#ifndef G_DISABLE_CHECKS + if (gtk_widget_get_screen (widget)) + { + guint screen_width = gdk_screen_get_width (gtk_widget_get_screen (widget)); + min_size = MIN (min_size, screen_width); + nat_size = MIN (nat_size, screen_width); + } +#endif } else { @@ -272,6 +280,14 @@ compute_size_for_orientation (GtkWidget *widget, &min_size, &nat_size); pop_recursion_check (widget, orientation); } +#ifndef G_DISABLE_CHECKS + if (gtk_widget_get_screen (widget)) + { + guint screen_height = gdk_screen_get_height (gtk_widget_get_screen (widget)); + min_size = MIN (min_size, screen_height); + nat_size = MIN (nat_size, screen_height); + } +#endif } if (min_size > nat_size) diff --git a/gtk/gtkspinbutton.c b/gtk/gtkspinbutton.c index a8e0f0833c..0f513bade3 100644 --- a/gtk/gtkspinbutton.c +++ b/gtk/gtkspinbutton.c @@ -133,11 +133,11 @@ static gint gtk_spin_button_focus_out (GtkWidget *widget, GdkEventFocus *event); static void gtk_spin_button_grab_notify (GtkWidget *widget, gboolean was_grabbed); -static void gtk_spin_button_state_changed (GtkWidget *widget, - GtkStateType previous_state); -static void gtk_spin_button_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void gtk_spin_button_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state); +static void gtk_spin_button_style_updated (GtkWidget *widget); static void gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, + GtkStyleContext *context, cairo_t *cr, GtkArrowType arrow_type); static gboolean gtk_spin_button_timer (GtkSpinButton *spin_button); @@ -170,7 +170,6 @@ static gint gtk_spin_button_default_input (GtkSpinButton *spin_button, static gint gtk_spin_button_default_output (GtkSpinButton *spin_button); static gint spin_button_get_arrow_size (GtkSpinButton *spin_button); -static gint spin_button_get_shadow_type (GtkSpinButton *spin_button); static guint spinbutton_signals[LAST_SIGNAL] = {0}; @@ -214,8 +213,8 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class) widget_class->leave_notify_event = gtk_spin_button_leave_notify; widget_class->focus_out_event = gtk_spin_button_focus_out; widget_class->grab_notify = gtk_spin_button_grab_notify; - widget_class->state_changed = gtk_spin_button_state_changed; - widget_class->style_set = gtk_spin_button_style_set; + widget_class->state_flags_changed = gtk_spin_button_state_flags_changed; + widget_class->style_updated = gtk_spin_button_style_updated; entry_class->activate = gtk_spin_button_activate; entry_class->get_text_area_size = gtk_spin_button_get_text_area_size; @@ -505,6 +504,7 @@ static void gtk_spin_button_init (GtkSpinButton *spin_button) { GtkSpinButtonPrivate *priv; + GtkStyleContext *context; spin_button->priv = G_TYPE_INSTANCE_GET_PRIVATE (spin_button, GTK_TYPE_SPIN_BUTTON, @@ -529,6 +529,9 @@ gtk_spin_button_init (GtkSpinButton *spin_button) gtk_spin_button_set_adjustment (spin_button, gtk_adjustment_new (0, 0, 0, 0, 0, 0)); + + context = gtk_widget_get_style_context (GTK_WIDGET (spin_button)); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_SPINBUTTON); } static void @@ -580,15 +583,15 @@ gtk_spin_button_realize (GtkWidget *widget) { GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); GtkSpinButtonPrivate *priv = spin_button->priv; + GtkStyleContext *context; + GtkStateFlags state; GtkAllocation allocation; GtkRequisition requisition; - GtkStyle *style; GdkWindowAttr attributes; gint attributes_mask; gboolean return_val; gint arrow_size; - - style = gtk_widget_get_style (widget); + GtkBorder padding; arrow_size = spin_button_get_arrow_size (spin_button); @@ -609,9 +612,13 @@ gtk_spin_button_realize (GtkWidget *widget) attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; - attributes.x = allocation.x + allocation.width - arrow_size - 2 * style->xthickness; + state = gtk_widget_get_state_flags (widget); + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, state, &padding); + + attributes.x = allocation.x + allocation.width - arrow_size - (padding.left + padding.right); attributes.y = allocation.y + (allocation.height - requisition.height) / 2; - attributes.width = arrow_size + 2 * style->xthickness; + attributes.width = arrow_size + padding.left + padding.right; attributes.height = requisition.height; priv->panel = gdk_window_new (gtk_widget_get_window (widget), @@ -673,10 +680,11 @@ gtk_spin_button_get_preferred_width (GtkWidget *widget, GtkSpinButton *spin_button = GTK_SPIN_BUTTON (widget); GtkSpinButtonPrivate *priv = spin_button->priv; GtkEntry *entry = GTK_ENTRY (widget); - GtkStyle *style; + GtkStyleContext *style_context; + GtkBorder padding; gint arrow_size; - style = gtk_widget_get_style (widget); + style_context = gtk_widget_get_style_context (widget); arrow_size = spin_button_get_arrow_size (spin_button); @@ -685,6 +693,7 @@ gtk_spin_button_get_preferred_width (GtkWidget *widget, if (gtk_entry_get_width_chars (entry) < 0) { PangoContext *context; + PangoFontDescription *font_desc; PangoFontMetrics *metrics; gint width; gint w; @@ -701,9 +710,13 @@ gtk_spin_button_get_preferred_width (GtkWidget *widget, "focus-line-width", &focus_width, NULL); + /* FIXME: update to get_font_desc */ + gtk_style_context_get (style_context, 0, + "font", &font_desc, + NULL); + context = gtk_widget_get_pango_context (widget); - metrics = pango_context_get_metrics (context, - style->font_desc, + metrics = pango_context_get_metrics (context, font_desc, pango_context_get_language (context)); digit_width = pango_font_metrics_get_approximate_digit_width (metrics); @@ -734,8 +747,12 @@ gtk_spin_button_get_preferred_width (GtkWidget *widget, *natural = width; } - *minimum += arrow_size + 2 * style->xthickness; - *natural += arrow_size + 2 * style->xthickness; + gtk_style_context_get_padding (style_context, + gtk_widget_get_state_flags (widget), + &padding); + + *minimum += arrow_size + padding.left + padding.right; + *natural += arrow_size + padding.left + padding.right; } static void @@ -746,11 +763,18 @@ gtk_spin_button_size_allocate (GtkWidget *widget, GtkSpinButtonPrivate *priv = spin->priv; GtkAllocation panel_allocation; GtkRequisition requisition; + GtkStyleContext *context; + GtkStateFlags state; + GtkBorder padding; gint arrow_size; gint panel_width; arrow_size = spin_button_get_arrow_size (spin); - panel_width = arrow_size + 2 * gtk_widget_get_style (widget)->xthickness; + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + + gtk_style_context_get_padding (context, state, &padding); + panel_width = arrow_size + padding.left + padding.right; gtk_widget_get_preferred_size (widget, &requisition, NULL); @@ -787,30 +811,46 @@ gtk_spin_button_draw (GtkWidget *widget, { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); GtkSpinButtonPrivate *priv = spin->priv; - GtkShadowType shadow_type; - GtkStateType state; + GtkStyleContext *context; + GtkStateFlags state = 0; + gboolean is_rtl; + + is_rtl = (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL); + context = gtk_widget_get_style_context (widget); + gtk_style_context_save (context); + + if (is_rtl) + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_LEFT); + else + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_RIGHT); GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->draw (widget, cr); + gtk_style_context_restore (context); cairo_save (cr); - shadow_type = spin_button_get_shadow_type (spin); + state = gtk_widget_get_state_flags (widget); - state = gtk_widget_has_focus (widget) ? - GTK_STATE_ACTIVE : gtk_widget_get_state (widget); + if (gtk_widget_has_focus (widget)) + state |= GTK_STATE_FLAG_FOCUSED; + + gtk_style_context_save (context); + gtk_style_context_set_state (context, state); + + if (is_rtl) + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_RIGHT); + else + gtk_style_context_set_junction_sides (context, GTK_JUNCTION_LEFT); gtk_cairo_transform_to_window (cr, widget, priv->panel); if (gtk_entry_get_has_frame (GTK_ENTRY (widget))) - gtk_paint_box (gtk_widget_get_style (widget), cr, - state, shadow_type, - widget, "spinbutton", - 0, 0, - gdk_window_get_width (priv->panel), - gdk_window_get_height (priv->panel)); + gtk_render_background (context, cr, 0, 0, + gdk_window_get_width (priv->panel), + gdk_window_get_height (priv->panel)); - gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_UP); - gtk_spin_button_draw_arrow (spin, cr, GTK_ARROW_DOWN); + gtk_spin_button_draw_arrow (spin, context, cr, GTK_ARROW_UP); + gtk_spin_button_draw_arrow (spin, context, cr, GTK_ARROW_DOWN); cairo_restore (cr); @@ -844,15 +884,17 @@ spin_button_at_limit (GtkSpinButton *spin_button, } static void -gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, - cairo_t *cr, - GtkArrowType arrow_type) +gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, + GtkStyleContext *context, + cairo_t *cr, + GtkArrowType arrow_type) { GtkSpinButtonPrivate *priv; - GtkStateType state_type; - GtkShadowType shadow_type; - GtkStyle *style; + GtkJunctionSides junction; + GtkStateFlags state; GtkWidget *widget; + GtkBorder padding; + gdouble angle; gint x; gint y; gint panel_height; @@ -862,12 +904,13 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, g_return_if_fail (arrow_type == GTK_ARROW_UP || arrow_type == GTK_ARROW_DOWN); + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_BUTTON); + priv = spin_button->priv; widget = GTK_WIDGET (spin_button); + junction = gtk_style_context_get_junction_sides (context); - style = gtk_widget_get_style (widget); - - width = spin_button_get_arrow_size (spin_button) + 2 * style->xthickness; panel_height = gdk_window_get_height (priv->panel); if (arrow_type == GTK_ARROW_UP) @@ -876,6 +919,8 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, y = 0; height = panel_height / 2; + angle = 0; + junction |= GTK_JUNCTION_BOTTOM; } else { @@ -883,41 +928,34 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, y = panel_height / 2; height = (panel_height + 1) / 2; + angle = G_PI; + junction |= GTK_JUNCTION_TOP; } if (spin_button_at_limit (spin_button, arrow_type)) - { - shadow_type = GTK_SHADOW_OUT; - state_type = GTK_STATE_INSENSITIVE; - } + state = GTK_STATE_FLAG_INSENSITIVE; else { if (priv->click_child == arrow_type) - { - state_type = GTK_STATE_ACTIVE; - shadow_type = GTK_SHADOW_IN; - } + state = GTK_STATE_ACTIVE; else { if (priv->in_child == arrow_type && priv->click_child == NO_ARROW) - { - state_type = GTK_STATE_PRELIGHT; - } + state = GTK_STATE_FLAG_PRELIGHT; else - { - state_type = gtk_widget_get_state (widget); - } - - shadow_type = GTK_SHADOW_OUT; + state = gtk_widget_get_state_flags (widget); } } - - gtk_paint_box (style, cr, - state_type, shadow_type, - widget, - (arrow_type == GTK_ARROW_UP)? "spinbutton_up" : "spinbutton_down", - x, y, width, height); + + gtk_style_context_get_padding (context, state, &padding); + gtk_style_context_set_junction_sides (context, junction); + gtk_style_context_set_state (context, state); + + width = spin_button_get_arrow_size (spin_button) + padding.left + padding.right; + + gtk_render_background (context, cr, x, y, width, height); + gtk_render_frame (context, cr, x, y, width, height); height = panel_height; @@ -949,11 +987,10 @@ gtk_spin_button_draw_arrow (GtkSpinButton *spin_button, height = h; width = w; - gtk_paint_arrow (style, cr, - state_type, shadow_type, - widget, "spinbutton", - arrow_type, TRUE, - x, y, width, height); + gtk_render_arrow (context, cr, + angle, x, y, width); + + gtk_style_context_restore (context); } static gint @@ -1029,8 +1066,8 @@ gtk_spin_button_grab_notify (GtkWidget *widget, } static void -gtk_spin_button_state_changed (GtkWidget *widget, - GtkStateType previous_state) +gtk_spin_button_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); @@ -1042,17 +1079,20 @@ gtk_spin_button_state_changed (GtkWidget *widget, } static void -gtk_spin_button_style_set (GtkWidget *widget, - GtkStyle *previous_style) +gtk_spin_button_style_updated (GtkWidget *widget) { GtkSpinButton *spin = GTK_SPIN_BUTTON (widget); GtkSpinButtonPrivate *priv = spin->priv; - if (previous_style && gtk_widget_get_realized (widget)) - gtk_style_set_background (gtk_widget_get_style (widget), - priv->panel, GTK_STATE_NORMAL); + if (gtk_widget_get_realized (widget)) + { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + gtk_style_context_set_background (context, priv->panel); + } - GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->style_set (widget, previous_style); + GTK_WIDGET_CLASS (gtk_spin_button_parent_class)->style_updated (widget); } @@ -1201,12 +1241,19 @@ gtk_spin_button_button_release (GtkWidget *widget, if (event->button == 3) { GtkRequisition requisition; + GtkStyleContext *context; + GtkStateFlags state; + GtkBorder padding; gtk_widget_get_preferred_size (widget, &requisition, NULL); + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + gtk_style_context_get_padding (context, state, &padding); + if (event->y >= 0 && event->x >= 0 && event->y <= requisition.height && - event->x <= arrow_size + 2 * gtk_widget_get_style (widget)->xthickness) + event->x <= arrow_size + padding.left + padding.right) { if (click_child == GTK_ARROW_UP && event->y <= requisition.height / 2) @@ -1488,13 +1535,22 @@ gtk_spin_button_get_text_area_size (GtkEntry *entry, gint *width, gint *height) { + GtkStyleContext *context; + GtkStateFlags state; + GtkWidget *widget; + GtkBorder padding; gint arrow_size; gint panel_width; GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->get_text_area_size (entry, x, y, width, height); + widget = GTK_WIDGET (entry); + state = gtk_widget_get_state_flags (widget); + context = gtk_widget_get_style_context (widget); + gtk_style_context_get_padding (context, state, &padding); + arrow_size = spin_button_get_arrow_size (GTK_SPIN_BUTTON (entry)); - panel_width = arrow_size + 2 * gtk_widget_get_style (GTK_WIDGET (entry))->xthickness; + panel_width = arrow_size + padding.left + padding.right; if (width) *width -= panel_width; @@ -2243,37 +2299,24 @@ gtk_spin_button_get_wrap (GtkSpinButton *spin_button) static gint spin_button_get_arrow_size (GtkSpinButton *spin_button) { - GtkStyle *style; + PangoFontDescription *font_desc; + GtkStyleContext *context; gint size; gint arrow_size; - style = gtk_widget_get_style (GTK_WIDGET (spin_button)); - size = pango_font_description_get_size (style->font_desc); + /* FIXME: use getter */ + context = gtk_widget_get_style_context (GTK_WIDGET (spin_button)); + gtk_style_context_get (context, 0, + "font", &font_desc, + NULL); + + size = pango_font_description_get_size (font_desc); arrow_size = MAX (PANGO_PIXELS (size), MIN_ARROW_WIDTH); return arrow_size - arrow_size % 2; /* force even */ } /** - * spin_button_get_shadow_type: - * @spin_button: a #GtkSpinButton - * - * Convenience function to Get the shadow type from the underlying widget's - * style. - * - * Return value: the #GtkShadowType - **/ -static gint -spin_button_get_shadow_type (GtkSpinButton *spin_button) -{ - GtkShadowType rc_shadow_type; - - gtk_widget_style_get (GTK_WIDGET (spin_button), "shadow-type", &rc_shadow_type, NULL); - - return rc_shadow_type; -} - -/** * gtk_spin_button_set_snap_to_ticks: * @spin_button: a #GtkSpinButton * @snap_to_ticks: a flag indicating if invalid values should be corrected. diff --git a/gtk/gtkstatusicon.c b/gtk/gtkstatusicon.c index f3bf6383b4..32972a5e50 100644 --- a/gtk/gtkstatusicon.c +++ b/gtk/gtkstatusicon.c @@ -1434,10 +1434,9 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon) #ifdef GDK_WINDOWING_WIN32 { GdkPixbuf *pixbuf = - gtk_widget_render_icon (priv->dummy_widget, - priv->image_data.stock_id, - GTK_ICON_SIZE_SMALL_TOOLBAR, - NULL); + gtk_widget_render_icon_pixbuf (priv->dummy_widget, + priv->image_data.stock_id, + GTK_ICON_SIZE_SMALL_TOOLBAR); prev_hicon = priv->nid.hIcon; priv->nid.hIcon = gdk_win32_pixbuf_to_hicon_libgtk_only (pixbuf); @@ -1454,10 +1453,9 @@ gtk_status_icon_update_image (GtkStatusIcon *status_icon) { GdkPixbuf *pixbuf; - pixbuf = gtk_widget_render_icon (priv->dummy_widget, - priv->image_data.stock_id, - GTK_ICON_SIZE_SMALL_TOOLBAR, - NULL); + pixbuf = gtk_widget_render_icon_pixbuf (priv->dummy_widget, + priv->image_data.stock_id, + GTK_ICON_SIZE_SMALL_TOOLBAR); QUARTZ_POOL_ALLOC; [priv->status_item setImage:pixbuf]; QUARTZ_POOL_RELEASE; diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 2aee8b2992..3abea8b12f 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -34,6 +34,7 @@ #include "gtkanimationdescription.h" #include "gtktimeline.h" #include "gtkiconfactory.h" +#include "gtkwidgetprivate.h" /** * SECTION:gtkstylecontext @@ -2982,8 +2983,7 @@ _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context) void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, - gint rel_x, - gint rel_y) + GtkWidget *widget) { GtkStyleContextPrivate *priv; GSList *l; @@ -2998,6 +2998,7 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, while (l) { AnimationInfo *info; + gint rel_x, rel_y; GSList *cur; guint i; @@ -3017,6 +3018,7 @@ _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, } info->invalidation_region = cairo_region_create (); + _gtk_widget_get_translation_to_window (widget, info->window, &rel_x, &rel_y); for (i = 0; i < info->rectangles->len; i++) { @@ -3254,7 +3256,7 @@ gtk_style_context_get_border_color (GtkStyleContext *context, * gtk_style_context_get_border: * @context: a #GtkStyleContext * @state: state to retrieve the border for - * @color: (out): return value for the border settings + * @border: (out): return value for the border settings * * Gets the border for a given state as a #GtkBorder. * @@ -3286,7 +3288,7 @@ gtk_style_context_get_border (GtkStyleContext *context, * gtk_style_context_get_padding: * @context: a #GtkStyleContext * @state: state to retrieve the padding for - * @color: (out): return value for the padding settings + * @padding: (out): return value for the padding settings * * Gets the padding for a given state as a #GtkBorder. * @@ -3318,7 +3320,7 @@ gtk_style_context_get_padding (GtkStyleContext *context, * gtk_style_context_get_margin: * @context: a #GtkStyleContext * @state: state to retrieve the border for - * @color: (out): return value for the margin settings + * @margin: (out): return value for the margin settings * * Gets the margin for a given state as a #GtkBorder. * @@ -3346,6 +3348,38 @@ gtk_style_context_get_margin (GtkStyleContext *context, *margin = *b; } +/** + * gtk_style_context_get_font: + * @context: a #GtkStyleContext + * @state: state to retrieve the font for + * + * Returns the font description for a given state. The returned + * object is const and will remain valid until the + * #GtkStyleContext::changed signal happens. + * + * Returns: the #PangoFontDescription for the given state. This + * object is owned by GTK+ and should not be freed. + * + * Since: 3.0 + **/ +const PangoFontDescription * +gtk_style_context_get_font (GtkStyleContext *context, + GtkStateFlags state) +{ + GtkStyleContextPrivate *priv; + StyleData *data; + const GValue *value; + + g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); + + priv = context->priv; + g_return_val_if_fail (priv->widget_path != NULL, NULL); + + data = style_data_lookup (context); + value = _gtk_style_properties_peek_property (data->store, "font", state); + return g_value_get_boxed (value); +} + /* Paint methods */ /** diff --git a/gtk/gtkstylecontext.h b/gtk/gtkstylecontext.h index a67e523a83..80d5abca21 100644 --- a/gtk/gtkstylecontext.h +++ b/gtk/gtkstylecontext.h @@ -254,6 +254,13 @@ struct _GtkStyleContextClass #define GTK_STYLE_CLASS_SCROLLBAR "scrollbar" /** + * GTK_STYLE_CLASS_SCALE: + * + * A CSS class to match scale widgets. + */ +#define GTK_STYLE_CLASS_SCALE "scale" + +/** * GTK_STYLE_CLASS_HEADER: * * A CSS class to match a header element. @@ -295,6 +302,74 @@ struct _GtkStyleContextClass */ #define GTK_STYLE_CLASS_SPINNER "spinner" +/** + * GTK_STYLE_CLASS_MARK: + * + * A widget class defining marks in a widget, such as in scales + */ +#define GTK_STYLE_CLASS_MARK "mark" + +/** + * GTK_STYLE_CLASS_EXPANDER: + * + * A widget class defining an expander, such as those in treeviews + */ +#define GTK_STYLE_CLASS_EXPANDER "expander" + +/** + * GTK_STYLE_CLASS_SPINBUTTON: + * + * A widget class defining an spinbutton + */ +#define GTK_STYLE_CLASS_SPINBUTTON "spinbutton" + +/** + * GTK_STYLE_CLASS_NOTEBOOK: + * + * A widget class defining a notebook + */ +#define GTK_STYLE_CLASS_NOTEBOOK "notebook" + +/** + * GTK_STYLE_CLASS_VIEW: + * + * A widget class defining a view, such as iconviews or treeviews + */ +#define GTK_STYLE_CLASS_VIEW "view" + +/** + * GTK_STYLE_CLASS_INFO: + * + * A widget class for an area displaying an informational message, + * such as those in infobars + */ +#define GTK_STYLE_CLASS_INFO "info" + +/** + * GTK_STYLE_CLASS_WARNING: + * + * A widget class for an area displaying a warning message, + * such as those in infobars + */ +#define GTK_STYLE_CLASS_WARNING "warning" + +/** + * GTK_STYLE_CLASS_QUESTION: + * + * A widget class for an area displaying a question to the user, + * such as those in infobars + */ +#define GTK_STYLE_CLASS_QUESTION "question" + +/** + * GTK_STYLE_CLASS_ERROR: + * + * A widget class for an area displaying an error message, + * such as those in infobars + */ +#define GTK_STYLE_CLASS_ERROR "error" + + /* Predefined set of widget regions */ /** @@ -439,6 +514,9 @@ void gtk_style_context_get_border_color (GtkStyleContext *context, GtkStateFlags state, GdkRGBA *color); +const PangoFontDescription * gtk_style_context_get_font (GtkStyleContext *context, + GtkStateFlags state); + void gtk_style_context_get_border (GtkStyleContext *context, GtkStateFlags state, GtkBorder *border); @@ -456,8 +534,7 @@ const GValue * _gtk_style_context_peek_style_property (GtkStyleContext *context, GParamSpec *pspec); void _gtk_style_context_invalidate_animation_areas (GtkStyleContext *context); void _gtk_style_context_coalesce_animation_areas (GtkStyleContext *context, - gint rel_x, - gint rel_y); + GtkWidget *widget); void gtk_style_context_invalidate (GtkStyleContext *context); void gtk_style_context_reset_widgets (GdkScreen *screen); diff --git a/gtk/gtktextbuffer.c b/gtk/gtktextbuffer.c index f1cd6f5098..c71d79b967 100644 --- a/gtk/gtktextbuffer.c +++ b/gtk/gtktextbuffer.c @@ -3156,7 +3156,7 @@ clipboard_get_selection_cb (GtkClipboard *clipboard, * used within-process */ gtk_selection_data_set (selection_data, - selection_data->target, + gtk_selection_data_get_target (selection_data), 8, /* bytes */ (void*)&buffer, sizeof (buffer)); @@ -3167,11 +3167,11 @@ clipboard_get_selection_cb (GtkClipboard *clipboard, gsize len; str = gtk_text_buffer_serialize (buffer, buffer, - selection_data->target, + gtk_selection_data_get_target (selection_data), &start, &end, &len); gtk_selection_data_set (selection_data, - selection_data->target, + gtk_selection_data_get_target (selection_data), 8, /* bytes */ str, len); g_free (str); @@ -3226,7 +3226,7 @@ clipboard_get_contents_cb (GtkClipboard *clipboard, * be used within-process. OK to supply a NULL value for contents. */ gtk_selection_data_set (selection_data, - selection_data->target, + gtk_selection_data_get_target (selection_data), 8, /* bytes */ (void*)&contents, sizeof (contents)); @@ -3244,11 +3244,11 @@ clipboard_get_contents_cb (GtkClipboard *clipboard, gtk_text_buffer_get_bounds (contents, &start, &end); str = gtk_text_buffer_serialize (clipboard_source_buffer, contents, - selection_data->target, + gtk_selection_data_get_target (selection_data), &start, &end, &len); gtk_selection_data_set (selection_data, - selection_data->target, + gtk_selection_data_get_target (selection_data), 8, /* bytes */ str, len); g_free (str); @@ -3404,23 +3404,22 @@ selection_data_get_buffer (GtkSelectionData *selection_data, GtkTextBuffer *src_buffer = NULL; /* If we can get the owner, the selection is in-process */ - owner = gdk_selection_owner_get_for_display (selection_data->display, - selection_data->selection); + owner = gdk_selection_owner_get_for_display (gtk_selection_data_get_display (selection_data), + gtk_selection_data_get_selection (selection_data)); if (owner == NULL) return NULL; if (gdk_window_get_window_type (owner) == GDK_WINDOW_FOREIGN) return NULL; - - if (selection_data->type != - gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS")) + + if (gtk_selection_data_get_data_type (selection_data) != gdk_atom_intern_static_string ("GTK_TEXT_BUFFER_CONTENTS")) return NULL; - if (selection_data->length != sizeof (src_buffer)) + if (gtk_selection_data_get_length (selection_data) != sizeof (src_buffer)) return NULL; - - memcpy (&src_buffer, selection_data->data, sizeof (src_buffer)); + + memcpy (&src_buffer, gtk_selection_data_get_data (selection_data), sizeof (src_buffer)); if (src_buffer == NULL) return NULL; diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c index de6619d86e..e57f957e51 100644 --- a/gtk/gtktextview.c +++ b/gtk/gtktextview.c @@ -304,14 +304,13 @@ static void gtk_text_view_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void gtk_text_view_realize (GtkWidget *widget); static void gtk_text_view_unrealize (GtkWidget *widget); -static void gtk_text_view_style_set (GtkWidget *widget, - GtkStyle *previous_style); +static void gtk_text_view_style_updated (GtkWidget *widget); static void gtk_text_view_direction_changed (GtkWidget *widget, GtkTextDirection previous_direction); static void gtk_text_view_grab_notify (GtkWidget *widget, gboolean was_grabbed); -static void gtk_text_view_state_changed (GtkWidget *widget, - GtkStateType previous_state); +static void gtk_text_view_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state); static gint gtk_text_view_event (GtkWidget *widget, GdkEvent *event); @@ -409,8 +408,7 @@ static void gtk_text_view_get_first_para_iter (GtkTextView *text_vi GtkTextIter *iter); static void gtk_text_view_update_layout_width (GtkTextView *text_view); static void gtk_text_view_set_attributes_from_style (GtkTextView *text_view, - GtkTextAttributes *values, - GtkStyle *style); + GtkTextAttributes *values); static void gtk_text_view_ensure_layout (GtkTextView *text_view); static void gtk_text_view_destroy_layout (GtkTextView *text_view); static void gtk_text_view_check_keymap_direction (GtkTextView *text_view); @@ -603,10 +601,10 @@ gtk_text_view_class_init (GtkTextViewClass *klass) widget_class->destroy = gtk_text_view_destroy; widget_class->realize = gtk_text_view_realize; widget_class->unrealize = gtk_text_view_unrealize; - widget_class->style_set = gtk_text_view_style_set; + widget_class->style_updated = gtk_text_view_style_updated; widget_class->direction_changed = gtk_text_view_direction_changed; widget_class->grab_notify = gtk_text_view_grab_notify; - widget_class->state_changed = gtk_text_view_state_changed; + widget_class->state_flags_changed = gtk_text_view_state_flags_changed; widget_class->get_preferred_width = gtk_text_view_get_preferred_width; widget_class->get_preferred_height = gtk_text_view_get_preferred_height; widget_class->size_allocate = gtk_text_view_size_allocate; @@ -3949,11 +3947,14 @@ gtk_text_view_realize (GtkWidget *widget) GtkAllocation allocation; GtkTextView *text_view; GtkTextViewPrivate *priv; + GtkStyleContext *context; + GtkStateFlags state; GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; GSList *tmp_list; - + GdkRGBA color; + text_view = GTK_TEXT_VIEW (widget); priv = text_view->priv; @@ -3977,11 +3978,11 @@ gtk_text_view_realize (GtkWidget *widget) gtk_widget_set_window (widget, window); gdk_window_set_user_data (window, widget); - /* must come before text_window_realize calls */ - gtk_widget_style_attach (widget); + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); - gdk_window_set_background (window, - >k_widget_get_style (widget)->bg[gtk_widget_get_state (widget)]); + gtk_style_context_get_background_color (context, state, &color); + gdk_window_set_background_rgba (window, &color); text_window_realize (priv->text_window, widget); @@ -4066,42 +4067,47 @@ gtk_text_view_unrealize (GtkWidget *widget) static void gtk_text_view_set_background (GtkTextView *text_view) { - GtkStyle *style; - GtkStateType state; + GtkStyleContext *context; + GtkStateFlags state; GtkWidget *widget; GtkTextViewPrivate *priv; + GdkRGBA color; widget = GTK_WIDGET (text_view); priv = text_view->priv; - style = gtk_widget_get_style (widget); - state = gtk_widget_get_state (widget); + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + + /* Set bin window background */ + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW); + + gtk_style_context_get_background_color (context, state, &color); + gdk_window_set_background_rgba (priv->text_window->bin_window, &color); - gdk_window_set_background (gtk_widget_get_window (widget), - &style->bg[state]); + gtk_style_context_restore (context); - gdk_window_set_background (priv->text_window->bin_window, - &style->base[state]); + /* Set lateral panes background */ + gtk_style_context_get_background_color (context, state, &color); + + gdk_window_set_background_rgba (gtk_widget_get_window (widget), &color); if (priv->left_window) - gdk_window_set_background (priv->left_window->bin_window, - &style->bg[state]); + gdk_window_set_background_rgba (priv->left_window->bin_window, &color); + if (priv->right_window) - gdk_window_set_background (priv->right_window->bin_window, - &style->bg[state]); + gdk_window_set_background_rgba (priv->right_window->bin_window, &color); if (priv->top_window) - gdk_window_set_background (priv->top_window->bin_window, - &style->bg[state]); + gdk_window_set_background_rgba (priv->top_window->bin_window, &color); if (priv->bottom_window) - gdk_window_set_background (priv->bottom_window->bin_window, - &style->bg[state]); + gdk_window_set_background_rgba (priv->bottom_window->bin_window, &color); } static void -gtk_text_view_style_set (GtkWidget *widget, - GtkStyle *previous_style) +gtk_text_view_style_updated (GtkWidget *widget) { GtkTextView *text_view; GtkTextViewPrivate *priv; @@ -4115,11 +4121,10 @@ gtk_text_view_style_set (GtkWidget *widget, gtk_text_view_set_background (text_view); } - if (priv->layout && previous_style) + if (priv->layout && priv->layout->default_style) { gtk_text_view_set_attributes_from_style (text_view, - priv->layout->default_style, - gtk_widget_get_style (widget)); + priv->layout->default_style); ltr_context = gtk_widget_create_pango_context (widget); pango_context_set_base_dir (ltr_context, PANGO_DIRECTION_LTR); @@ -4148,8 +4153,8 @@ gtk_text_view_direction_changed (GtkWidget *widget, } static void -gtk_text_view_state_changed (GtkWidget *widget, - GtkStateType previous_state) +gtk_text_view_state_flags_changed (GtkWidget *widget, + GtkStateFlags previous_state) { GtkTextView *text_view = GTK_TEXT_VIEW (widget); GdkCursor *cursor; @@ -4870,13 +4875,14 @@ gtk_text_view_draw_focus (GtkWidget *widget, NULL); if (gtk_widget_has_focus (widget) && !interior_focus) - { - gtk_paint_focus (gtk_widget_get_style (widget), cr, - gtk_widget_get_state (widget), - widget, "textview", - 0, 0, - gtk_widget_get_allocated_width (widget), - gtk_widget_get_allocated_height (widget)); + { + GtkStyleContext *context; + + context = gtk_widget_get_style_context (widget); + + gtk_render_focus (context, cr, 0, 0, + gtk_widget_get_allocated_width (widget), + gtk_widget_get_allocated_height (widget)); } } @@ -6535,16 +6541,30 @@ gtk_text_view_end_selection_drag (GtkTextView *text_view) static void gtk_text_view_set_attributes_from_style (GtkTextView *text_view, - GtkTextAttributes *values, - GtkStyle *style) + GtkTextAttributes *values) { - values->appearance.bg_color = style->base[GTK_STATE_NORMAL]; - values->appearance.fg_color = style->text[GTK_STATE_NORMAL]; + GtkStyleContext *context; + GdkRGBA bg_color, fg_color; + GtkStateFlags state; + + context = gtk_widget_get_style_context (GTK_WIDGET (text_view)); + state = gtk_widget_get_state_flags (GTK_WIDGET (text_view)); + + gtk_style_context_get_background_color (context, state, &bg_color); + gtk_style_context_get_color (context, state, &fg_color); + + values->appearance.bg_color.red = CLAMP (bg_color.red * 65535. + 0.5, 0, 65535); + values->appearance.bg_color.green = CLAMP (bg_color.green * 65535. + 0.5, 0, 65535); + values->appearance.bg_color.blue = CLAMP (bg_color.blue * 65535. + 0.5, 0, 65535); + + values->appearance.fg_color.red = CLAMP (fg_color.red * 65535. + 0.5, 0, 65535); + values->appearance.fg_color.green = CLAMP (fg_color.green * 65535. + 0.5, 0, 65535); + values->appearance.fg_color.blue = CLAMP (fg_color.blue * 65535. + 0.5, 0, 65535); if (values->font) pango_font_description_free (values->font); - values->font = pango_font_description_copy (style->font_desc); + values->font = pango_font_description_copy (gtk_style_context_get_font (context, state)); } static void @@ -6638,10 +6658,7 @@ gtk_text_view_ensure_layout (GtkTextView *text_view) style = gtk_text_attributes_new (); - gtk_widget_ensure_style (widget); - gtk_text_view_set_attributes_from_style (text_view, - style, - gtk_widget_get_style (widget)); + gtk_text_view_set_attributes_from_style (text_view, style); style->pixels_above_lines = priv->pixels_above_lines; style->pixels_below_lines = priv->pixels_below_lines; @@ -6907,7 +6924,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget, { /* Extract the selected text */ str = gtk_text_buffer_serialize (buffer, buffer, - selection_data->target, + gtk_selection_data_get_target (selection_data), &start, &end, &len); } @@ -6915,7 +6932,7 @@ gtk_text_view_drag_data_get (GtkWidget *widget, if (str) { gtk_selection_data_set (selection_data, - selection_data->target, + gtk_selection_data_get_target (selection_data), 8, /* bytes */ (guchar *) str, len); g_free (str); @@ -7028,7 +7045,7 @@ gtk_text_view_drag_motion (GtkWidget *widget, { GtkWidget *source_widget; - suggested_action = context->suggested_action; + suggested_action = gdk_drag_context_get_suggested_action (context); source_widget = gtk_drag_get_source_widget (context); @@ -7037,7 +7054,7 @@ gtk_text_view_drag_motion (GtkWidget *widget, /* Default to MOVE, unless the user has * pressed ctrl or alt to affect available actions */ - if ((context->actions & GDK_ACTION_MOVE) != 0) + if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0) suggested_action = GDK_ACTION_MOVE; } } @@ -7171,10 +7188,10 @@ gtk_text_view_drag_data_received (GtkWidget *widget, GtkTextIter start, end; gboolean copy_tags = TRUE; - if (selection_data->length != sizeof (src_buffer)) + if (gtk_selection_data_get_length (selection_data) != sizeof (src_buffer)) return; - memcpy (&src_buffer, selection_data->data, sizeof (src_buffer)); + memcpy (&src_buffer, gtk_selection_data_get_data (selection_data), sizeof (src_buffer)); if (src_buffer == NULL) return; @@ -7194,7 +7211,7 @@ gtk_text_view_drag_data_received (GtkWidget *widget, atoms = gtk_text_buffer_get_deserialize_formats (buffer, &n_atoms); - for (list = context->targets; list; list = g_list_next (list)) + for (list = gdk_drag_context_list_targets (context); list; list = g_list_next (list)) { gint i; @@ -7238,17 +7255,17 @@ gtk_text_view_drag_data_received (GtkWidget *widget, } } } - else if (selection_data->length > 0 && + else if (gtk_selection_data_get_length (selection_data) > 0 && info == GTK_TEXT_BUFFER_TARGET_INFO_RICH_TEXT) { gboolean retval; GError *error = NULL; retval = gtk_text_buffer_deserialize (buffer, buffer, - selection_data->target, + gtk_selection_data_get_target (selection_data), &drop_point, - (guint8 *) selection_data->data, - selection_data->length, + (guint8 *) gtk_selection_data_get_data (selection_data), + gtk_selection_data_get_length (selection_data), &error); if (!retval) @@ -7262,7 +7279,7 @@ gtk_text_view_drag_data_received (GtkWidget *widget, done: gtk_drag_finish (context, success, - success && context->action == GDK_ACTION_MOVE, + success && gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE, time); if (success) @@ -8352,10 +8369,13 @@ static void text_window_realize (GtkTextWindow *win, GtkWidget *widget) { + GtkStyleContext *context; + GtkStateFlags state; GdkWindow *window; GdkWindowAttr attributes; gint attributes_mask; GdkCursor *cursor; + GdkRGBA color; attributes.window_type = GDK_WINDOW_CHILD; attributes.x = win->allocation.x; @@ -8397,6 +8417,9 @@ text_window_realize (GtkTextWindow *win, gdk_window_show (win->bin_window); gdk_window_set_user_data (win->bin_window, win->widget); + context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); + if (win->type == GTK_TEXT_WINDOW_TEXT) { if (gtk_widget_is_sensitive (widget)) @@ -8411,14 +8434,18 @@ text_window_realize (GtkTextWindow *win, gtk_im_context_set_client_window (GTK_TEXT_VIEW (widget)->priv->im_context, win->window); + gtk_style_context_save (context); + gtk_style_context_add_class (context, GTK_STYLE_CLASS_VIEW); + + gtk_style_context_get_background_color (context, state, &color); + gdk_window_set_background_rgba (win->bin_window, &color); - gdk_window_set_background (win->bin_window, - >k_widget_get_style (widget)->base[gtk_widget_get_state (widget)]); + gtk_style_context_restore (context); } else { - gdk_window_set_background (win->bin_window, - >k_widget_get_style (widget)->bg[gtk_widget_get_state (widget)]); + gtk_style_context_get_background_color (context, state, &color); + gdk_window_set_background_rgba (win->bin_window, &color); } g_object_set_qdata (G_OBJECT (win->window), diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c index 1c77dbce6d..7914029602 100644 --- a/gtk/gtkthemingengine.c +++ b/gtk/gtkthemingengine.c @@ -874,6 +874,29 @@ gtk_theming_engine_get_margin (GtkThemingEngine *engine, gtk_style_context_get_margin (priv->context, state, margin); } +/** + * gtk_theming_engine_get_font: + * @engine: a #GtkThemingEngine + * @state: state to retrieve the font for + * + * Returns the font description for a given state. + * + * Returns: the #PangoFontDescription for the given state. This + * object is owned by GTK+ and should not be freed. + * + * Since: 3.0 + **/ +const PangoFontDescription * +gtk_theming_engine_get_font (GtkThemingEngine *engine, + GtkStateFlags state) +{ + GtkThemingEnginePrivate *priv; + + g_return_val_if_fail (GTK_IS_THEMING_ENGINE (engine), NULL); + + priv = engine->priv; + return gtk_style_context_get_font (priv->context, state); +} /* GtkThemingModule */ @@ -1461,8 +1484,7 @@ render_background_internal (GtkThemingEngine *engine, GtkStateFlags flags; gboolean running; gdouble progress, alpha = 1; - gint radius, border_width; - GtkBorder *border; + gint radius; flags = gtk_theming_engine_get_state (engine); cairo_save (cr); @@ -1470,14 +1492,10 @@ render_background_internal (GtkThemingEngine *engine, gtk_theming_engine_get (engine, flags, "background-image", &pattern, "background-color", &bg_color, - "border-width", &border, "border-radius", &radius, NULL); running = gtk_theming_engine_state_is_running (engine, GTK_STATE_PRELIGHT, &progress); - border_width = MIN (MIN (border->top, border->bottom), - MIN (border->left, border->right)); - _cairo_round_rectangle_sides (cr, (gdouble) radius, x, y, width, height, SIDE_ALL, junction); @@ -1694,7 +1712,6 @@ render_background_internal (GtkThemingEngine *engine, cairo_restore (cr); gdk_rgba_free (bg_color); - gtk_border_free (border); } static void @@ -1992,6 +2009,8 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, double x_double, y_double; gdouble angle; gint line_width; + gboolean running, is_rtl; + gdouble progress; cairo_save (cr); flags = gtk_theming_engine_get_state (engine); @@ -1999,23 +2018,23 @@ gtk_theming_engine_render_expander (GtkThemingEngine *engine, gtk_theming_engine_get (engine, flags, "color", &fg_color, NULL); - gtk_theming_engine_get (engine, 0, - "color", &outline_color, + gtk_theming_engine_get (engine, flags, + "border-color", &outline_color, NULL); + running = gtk_theming_engine_state_is_running (engine, GTK_STATE_ACTIVE, &progress); + is_rtl = (gtk_theming_engine_get_direction (engine) == GTK_TEXT_DIR_RTL); line_width = 1; - /* FIXME: LTR/RTL */ - if (flags & GTK_STATE_FLAG_ACTIVE) - { - angle = G_PI / 2; - interp = 1.0; - } + if (!running) + progress = (flags & GTK_STATE_FLAG_ACTIVE) ? 1 : 0; + + if (is_rtl) + angle = (G_PI) - ((G_PI / 2) * progress); else - { - angle = 0; - interp = 0; - } + angle = (G_PI / 2) * progress; + + interp = progress; /* Compute distance that the stroke extends beyonds the end * of the triangle we draw. @@ -2510,12 +2529,11 @@ gtk_theming_engine_render_extension (GtkThemingEngine *engine, gap_side == GTK_POS_BOTTOM) render_background_internal (engine, cr, 0, 0, width, height, - junction); + GTK_JUNCTION_BOTTOM); else render_background_internal (engine, cr, 0, 0, height, width, - junction); - + GTK_JUNCTION_BOTTOM); cairo_restore (cr); cairo_save (cr); diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h index 64b39216e2..ab90bf5a7b 100644 --- a/gtk/gtkthemingengine.h +++ b/gtk/gtkthemingengine.h @@ -240,6 +240,8 @@ void gtk_theming_engine_get_margin (GtkThemingEngine *engine, GtkStateFlags state, GtkBorder *margin); +const PangoFontDescription * gtk_theming_engine_get_font (GtkThemingEngine *engine, + GtkStateFlags state); GtkThemingEngine * gtk_theming_engine_load (const gchar *name); diff --git a/gtk/gtktoolpalette.c b/gtk/gtktoolpalette.c index 383d6b5555..6cd32cb214 100644 --- a/gtk/gtktoolpalette.c +++ b/gtk/gtktoolpalette.c @@ -1672,23 +1672,25 @@ gtk_tool_palette_get_drag_item (GtkToolPalette *palette, const GtkSelectionData *selection) { GtkToolPaletteDragData *data; + GdkAtom target; g_return_val_if_fail (GTK_IS_TOOL_PALETTE (palette), NULL); g_return_val_if_fail (NULL != selection, NULL); - g_return_val_if_fail (selection->format == 8, NULL); - g_return_val_if_fail (selection->length == sizeof (GtkToolPaletteDragData), NULL); - g_return_val_if_fail (selection->target == dnd_target_atom_item || - selection->target == dnd_target_atom_group, + g_return_val_if_fail (gtk_selection_data_get_format (selection) == 8, NULL); + g_return_val_if_fail (gtk_selection_data_get_length (selection) == sizeof (GtkToolPaletteDragData), NULL); + target = gtk_selection_data_get_target (selection); + g_return_val_if_fail (target == dnd_target_atom_item || + target == dnd_target_atom_group, NULL); - data = (GtkToolPaletteDragData*) selection->data; + data = (GtkToolPaletteDragData*) gtk_selection_data_get_data (selection); g_return_val_if_fail (data->palette == palette, NULL); - if (dnd_target_atom_item == selection->target) + if (dnd_target_atom_item == target) g_return_val_if_fail (GTK_IS_TOOL_ITEM (data->item), NULL); - else if (dnd_target_atom_group == selection->target) + else if (dnd_target_atom_group == target) g_return_val_if_fail (GTK_IS_TOOL_ITEM_GROUP (data->item), NULL); return data->item; @@ -1818,12 +1820,15 @@ gtk_tool_palette_item_drag_data_get (GtkWidget *widget, gpointer data) { GtkToolPaletteDragData drag_data = { GTK_TOOL_PALETTE (data), NULL }; + GdkAtom target; - if (selection->target == dnd_target_atom_item) + target = gtk_selection_data_get_target (selection); + + if (target == dnd_target_atom_item) drag_data.item = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM); if (drag_data.item) - gtk_selection_data_set (selection, selection->target, 8, + gtk_selection_data_set (selection, target, 8, (guchar*) &drag_data, sizeof (drag_data)); } @@ -1836,12 +1841,15 @@ gtk_tool_palette_child_drag_data_get (GtkWidget *widget, gpointer data) { GtkToolPaletteDragData drag_data = { GTK_TOOL_PALETTE (data), NULL }; + GdkAtom target; + + target = gtk_selection_data_get_target (selection); - if (selection->target == dnd_target_atom_group) + if (target == dnd_target_atom_group) drag_data.item = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM_GROUP); if (drag_data.item) - gtk_selection_data_set (selection, selection->target, 8, + gtk_selection_data_set (selection, target, 8, (guchar*) &drag_data, sizeof (drag_data)); } diff --git a/gtk/gtktrayicon-x11.c b/gtk/gtktrayicon-x11.c index 150b634823..4689d3ca53 100644 --- a/gtk/gtktrayicon-x11.c +++ b/gtk/gtktrayicon-x11.c @@ -445,6 +445,9 @@ gtk_tray_icon_get_visual_property (GtkTrayIcon *icon) gulong bytes_after; int error, result; GdkVisual *visual; + gint red_prec; + gint green_prec; + gint blue_prec; g_assert (icon->priv->manager_window != None); @@ -468,9 +471,13 @@ gtk_tray_icon_get_visual_property (GtkTrayIcon *icon) visual = gdk_x11_screen_lookup_visual (screen, visual_id); } + gdk_visual_get_red_pixel_details (visual, NULL, NULL, &red_prec); + gdk_visual_get_green_pixel_details (visual, NULL, NULL, &green_prec); + gdk_visual_get_blue_pixel_details (visual, NULL, NULL, &blue_prec); + icon->priv->manager_visual = visual; icon->priv->manager_visual_rgba = visual != NULL && - (visual->red_prec + visual->blue_prec + visual->green_prec < visual->depth); + (red_prec + blue_prec + green_prec < gdk_visual_get_depth (visual)); /* For the background-relative hack we use when we aren't using a real RGBA * visual, we can't be double-buffered */ @@ -844,7 +851,7 @@ gtk_tray_icon_set_visual (GtkTrayIcon *icon) * to be either the screen default visual or a TrueColor visual; ignore it * if it is something else */ - if (visual && visual->type != GDK_VISUAL_TRUE_COLOR) + if (visual && gdk_visual_get_visual_type (visual) != GDK_VISUAL_TRUE_COLOR) visual = NULL; if (visual == NULL) diff --git a/gtk/gtktreednd.c b/gtk/gtktreednd.c index f5f436bf02..68cc171177 100644 --- a/gtk/gtktreednd.c +++ b/gtk/gtktreednd.c @@ -273,7 +273,7 @@ gtk_tree_set_row_drag_data (GtkSelectionData *selection_data, g_return_val_if_fail (GTK_IS_TREE_MODEL (tree_model), FALSE); g_return_val_if_fail (path != NULL, FALSE); - if (selection_data->target != gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) + if (gtk_selection_data_get_target (selection_data) != gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) return FALSE; path_str = gtk_tree_path_to_string (path); @@ -336,14 +336,14 @@ gtk_tree_get_row_drag_data (GtkSelectionData *selection_data, if (path) *path = NULL; - - if (selection_data->target != gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) + + if (gtk_selection_data_get_target (selection_data) != gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) return FALSE; - if (selection_data->length < 0) + if (gtk_selection_data_get_length (selection_data) < 0) return FALSE; - trd = (void*) selection_data->data; + trd = (void*) gtk_selection_data_get_data (selection_data); if (tree_model) *tree_model = trd->model; diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c index 41769b14b8..d92aa2ff17 100644 --- a/gtk/gtktreeview.c +++ b/gtk/gtktreeview.c @@ -7471,7 +7471,7 @@ out: { GtkWidget *source_widget; - *suggested_action = context->suggested_action; + *suggested_action = gdk_drag_context_get_suggested_action (context); source_widget = gtk_drag_get_source_widget (context); if (source_widget == widget) @@ -7479,7 +7479,7 @@ out: /* Default to MOVE, unless the user has * pressed ctrl or shift to affect available actions */ - if ((context->actions & GDK_ACTION_MOVE) != 0) + if ((gdk_drag_context_get_actions (context) & GDK_ACTION_MOVE) != 0) *suggested_action = GDK_ACTION_MOVE; } @@ -7711,7 +7711,7 @@ gtk_tree_view_drag_data_get (GtkWidget *widget, goto done; /* If drag_data_get does nothing, try providing row data. */ - if (selection_data->target == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) + if (gtk_selection_data_get_target (selection_data) == gdk_atom_intern_static_string ("GTK_TREE_MODEL_ROW")) { gtk_tree_set_row_drag_data (selection_data, model, @@ -7991,7 +7991,7 @@ gtk_tree_view_drag_data_received (GtkWidget *widget, if (dest_row == NULL) return; - if (selection_data->length >= 0) + if (gtk_selection_data_get_length (selection_data) >= 0) { if (path_down_mode) { @@ -8002,7 +8002,7 @@ gtk_tree_view_drag_data_received (GtkWidget *widget, } } - if (selection_data->length >= 0) + if (gtk_selection_data_get_length (selection_data) >= 0) { if (gtk_tree_drag_dest_drag_data_received (GTK_TREE_DRAG_DEST (model), dest_row, @@ -8012,7 +8012,7 @@ gtk_tree_view_drag_data_received (GtkWidget *widget, gtk_drag_finish (context, accepted, - (context->action == GDK_ACTION_MOVE), + (gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE), time); if (gtk_tree_path_get_depth (dest_row) == 1 diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index 214c3913b5..5053b1f8fe 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -5564,9 +5564,7 @@ _gtk_widget_draw_internal (GtkWidget *widget, } context = gtk_widget_get_style_context (widget); - _gtk_style_context_coalesce_animation_areas (context, - widget->priv->allocation.x, - widget->priv->allocation.y); + _gtk_style_context_coalesce_animation_areas (context, widget); } /** @@ -5688,11 +5686,11 @@ gtk_widget_event (GtkWidget *widget, } /* Returns TRUE if a translation should be done */ -static gboolean -gtk_widget_get_translation_to_window (GtkWidget *widget, - GdkWindow *window, - int *x, - int *y) +gboolean +_gtk_widget_get_translation_to_window (GtkWidget *widget, + GdkWindow *window, + int *x, + int *y) { GdkWindow *w, *widget_window; @@ -5755,7 +5753,7 @@ gtk_cairo_transform_to_window (cairo_t *cr, g_return_if_fail (GTK_IS_WIDGET (widget)); g_return_if_fail (GDK_IS_WINDOW (window)); - if (gtk_widget_get_translation_to_window (widget, window, &x, &y)) + if (_gtk_widget_get_translation_to_window (widget, window, &x, &y)) cairo_translate (cr, x, y); } @@ -5798,9 +5796,9 @@ gtk_widget_send_expose (GtkWidget *widget, gdk_cairo_region (cr, event->expose.region); cairo_clip (cr); - do_clip = gtk_widget_get_translation_to_window (widget, - event->expose.window, - &x, &y); + do_clip = _gtk_widget_get_translation_to_window (widget, + event->expose.window, + &x, &y); cairo_translate (cr, -x, -y); _gtk_widget_draw_internal (widget, cr, do_clip); @@ -8441,10 +8439,7 @@ gtk_widget_set_style_internal (GtkWidget *widget, GtkStyle *previous_style; if (gtk_widget_get_realized (widget)) - { - gtk_widget_reset_shapes (widget); - gtk_style_detach (priv->style); - } + gtk_style_detach (priv->style); previous_style = priv->style; priv->style = style; @@ -8691,7 +8686,9 @@ reset_style_recurse (GtkWidget *widget, gpointer data) * @widget: a #GtkWidget * * Updates the style context of @widget and all descendents - * by updating its widget path. + * by updating its widget path. #GtkContainer<!-- -->s may want + * to use this on a child when reordering it in a way that a different + * style might apply to it. See also gtk_container_get_path_for_child(). * * Since: 3.0 */ @@ -11228,42 +11225,6 @@ gtk_widget_input_shape_combine_region (GtkWidget *widget, } -static void -gtk_reset_shapes_recurse (GtkWidget *widget, - GdkWindow *window) -{ - gpointer data; - GList *list; - - gdk_window_get_user_data (window, &data); - if (data != widget) - return; - - gdk_window_shape_combine_region (window, NULL, 0, 0); - for (list = gdk_window_peek_children (window); list; list = list->next) - gtk_reset_shapes_recurse (widget, list->data); -} - -/** - * gtk_widget_reset_shapes: - * @widget: a #GtkWidget - * - * Recursively resets the shape on this widget and its descendants. - **/ -void -gtk_widget_reset_shapes (GtkWidget *widget) -{ - GtkWidgetPrivate *priv; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (gtk_widget_get_realized (widget)); - - priv = widget->priv; - - if (!priv->has_shape_mask) - gtk_reset_shapes_recurse (widget, priv->window); -} - /* style properties */ diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h index 2a079ea0b6..30fafe690a 100644 --- a/gtk/gtkwidget.h +++ b/gtk/gtkwidget.h @@ -831,6 +831,10 @@ void gtk_widget_class_path (GtkWidget *widget, gchar **path, gchar **path_reversed); +GdkPixbuf *gtk_widget_render_icon (GtkWidget *widget, + const gchar *stock_id, + GtkIconSize size, + const gchar *detail); #endif /* GTK_DISABLE_DEPRECATED */ PangoContext *gtk_widget_create_pango_context (GtkWidget *widget); @@ -838,10 +842,9 @@ PangoContext *gtk_widget_get_pango_context (GtkWidget *widget); PangoLayout *gtk_widget_create_pango_layout (GtkWidget *widget, const gchar *text); -GdkPixbuf *gtk_widget_render_icon (GtkWidget *widget, +GdkPixbuf *gtk_widget_render_icon_pixbuf (GtkWidget *widget, const gchar *stock_id, - GtkIconSize size, - const gchar *detail); + GtkIconSize size); /* handle composite names for GTK_COMPOSITE_CHILD widgets, * the returned name is newly allocated. @@ -897,9 +900,6 @@ void gtk_widget_shape_combine_region (GtkWidget *widget, void gtk_widget_input_shape_combine_region (GtkWidget *widget, cairo_region_t *region); -/* internal function */ -void gtk_widget_reset_shapes (GtkWidget *widget); - GList* gtk_widget_list_mnemonic_labels (GtkWidget *widget); void gtk_widget_add_mnemonic_label (GtkWidget *widget, GtkWidget *label); diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h index b31efd9b5b..c5666468f3 100644 --- a/gtk/gtkwidgetprivate.h +++ b/gtk/gtkwidgetprivate.h @@ -88,6 +88,11 @@ void _gtk_widget_restore_size_request (GtkWidget *widget, int old_width, int old_height); +gboolean _gtk_widget_get_translation_to_window (GtkWidget *widget, + GdkWindow *window, + int *x, + int *y); + G_END_DECLS #endif /* __GTK_WIDGET_PRIVATE_H__ */ diff --git a/modules/input/gtkimcontextxim.c b/modules/input/gtkimcontextxim.c index 035edc3a00..a6adf9f280 100644 --- a/modules/input/gtkimcontextxim.c +++ b/modules/input/gtkimcontextxim.c @@ -1755,14 +1755,19 @@ static gboolean on_status_window_draw (GtkWidget *widget, cairo_t *cr) { - GtkStyle *style; + GtkStyleContext *style; + GdkRGBA color; - style = gtk_widget_get_style (widget); + style = gtk_widget_get_style_context (widget); - gdk_cairo_set_source_color (cr, &style->base[GTK_STATE_NORMAL]); + gtk_style_context_get_background_color (style, 0, &color); + gdk_cairo_set_source_rgba (cr, &color); + cairo_paint (cr); + + gtk_style_context_get_color (style, 0, &color); + gdk_cairo_set_source_rgba (cr, &color); cairo_paint (cr); - gdk_cairo_set_source_color (cr, &style->text[GTK_STATE_NORMAL]); cairo_rectangle (cr, 0, 0, gtk_widget_get_allocated_width (widget) - 1, @@ -1772,26 +1777,6 @@ on_status_window_draw (GtkWidget *widget, return FALSE; } -/* We watch the ::style-set signal for our label widget - * and use that to change it's foreground color to match - * the 'text' color of the toplevel window. The text/base - * pair of colors might be reversed from the fg/bg pair - * that are normally used for labels. - */ -static void -on_status_window_style_set (GtkWidget *toplevel, - GtkStyle *previous_style, - GtkWidget *label) -{ - GtkStyle *style; - gint i; - - style = gtk_widget_get_style (toplevel); - - for (i = 0; i < 5; i++) - gtk_widget_modify_fg (label, i, &style->text[i]); -} - /* Creates the widgets for the status window; called when we * first need to show text for the status window. */ @@ -1811,8 +1796,6 @@ status_window_make_window (StatusWindow *status_window) gtk_misc_set_padding (GTK_MISC (status_label), 1, 1); gtk_widget_show (status_label); - g_signal_connect (window, "style-set", - G_CALLBACK (on_status_window_style_set), status_label); gtk_container_add (GTK_CONTAINER (window), status_label); g_signal_connect (window, "draw", diff --git a/modules/other/gail/libgail-util/gailmisc.c b/modules/other/gail/libgail-util/gailmisc.c index a70a4f0109..83910bb562 100644 --- a/modules/other/gail/libgail-util/gailmisc.c +++ b/modules/other/gail/libgail-util/gailmisc.c @@ -19,6 +19,7 @@ #include "config.h" +#include <math.h> #include <stdlib.h> #include <gtk/gtk.h> #include "gailmisc.h" @@ -373,9 +374,11 @@ gail_misc_get_default_attributes (AtkAttributeSet *attrib_set, GtkWidget *widget) { PangoContext *context; - GtkStyle *style_value; + GtkStyleContext *style_context; gint int_value; PangoWrapMode mode; + GdkRGBA color; + gchar *value; attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_DIRECTION, @@ -453,25 +456,26 @@ gail_misc_get_default_attributes (AtkAttributeSet *attrib_set, g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_WRAP_MODE, int_value))); - style_value = gtk_widget_get_style (widget); - if (style_value) - { - GdkColor color; - gchar *value; + style_context = gtk_widget_get_style_context (widget); + + gtk_style_context_get_background_color (style_context, 0, &color); + value = g_strdup_printf ("%u,%u,%u", + (guint) ceil (color.red * 65536 - color.red), + (guint) ceil (color.green * 65536 - color.green), + (guint) ceil (color.blue * 65536 - color.blue)); + attrib_set = gail_misc_add_attribute (attrib_set, + ATK_TEXT_ATTR_BG_COLOR, + value); + + gtk_style_context_get_color (style_context, 0, &color); + value = g_strdup_printf ("%u,%u,%u", + (guint) ceil (color.red * 65536 - color.red), + (guint) ceil (color.green * 65536 - color.green), + (guint) ceil (color.blue * 65536 - color.blue)); + attrib_set = gail_misc_add_attribute (attrib_set, + ATK_TEXT_ATTR_FG_COLOR, + value); - color = style_value->base[GTK_STATE_NORMAL]; - value = g_strdup_printf ("%u,%u,%u", - color.red, color.green, color.blue); - attrib_set = gail_misc_add_attribute (attrib_set, - ATK_TEXT_ATTR_BG_COLOR, - value); - color = style_value->text[GTK_STATE_NORMAL]; - value = g_strdup_printf ("%u,%u,%u", - color.red, color.green, color.blue); - attrib_set = gail_misc_add_attribute (attrib_set, - ATK_TEXT_ATTR_FG_COLOR, - value); - } attrib_set = gail_misc_add_attribute (attrib_set, ATK_TEXT_ATTR_FG_STIPPLE, g_strdup (atk_text_attribute_get_value (ATK_TEXT_ATTR_FG_STIPPLE, @@ -16,8 +16,8 @@ msgstr "" "Project-Id-Version: gtk+.master\n" "Report-Msgid-Bugs-To: http://bugzilla.gnome.org/enter_bug.cgi?product=gtk" "%2b&component=general\n" -"POT-Creation-Date: 2010-11-29 20:28+0000\n" -"PO-Revision-Date: 2010-12-02 19:10+0100\n" +"POT-Creation-Date: 2010-12-15 13:52+0000\n" +"PO-Revision-Date: 2010-12-15 21:40+0100\n" "Last-Translator: Jorge González <jorgegonz@svn.gnome.org>\n" "Language-Team: Español <gnome-es-list@gnome.org>\n" "MIME-Version: 1.0\n" @@ -86,7 +86,7 @@ msgstr "Opciones de depuración GTK+ que establecer" #. Placeholder in --gdk-no-debug=FLAGS in --help output #. Placeholder in --gtk-debug=FLAGS in --help output #. Placeholder in --gtk-no-debug=FLAGS in --help output -#: ../gdk/gdk.c:177 ../gdk/gdk.c:180 ../gtk/gtkmain.c:525 ../gtk/gtkmain.c:528 +#: ../gdk/gdk.c:177 ../gdk/gdk.c:180 ../gtk/gtkmain.c:523 ../gtk/gtkmain.c:526 msgid "FLAGS" msgstr "OPCIONES" @@ -335,56 +335,64 @@ msgstr "Hacer llamadas a X síncronas" #. Translators: this is the license preamble; the string at the end #. * contains the URL of the license. #. -#: ../gtk/gtkaboutdialog.c:101 +#: ../gtk/gtkaboutdialog.c:105 #, c-format -msgid "This program comes with ABSOLUTELY NO WARRANTY; for details, visit %s" +#| msgid "" +#| "This program comes with ABSOLUTELY NO WARRANTY; for details, visit %s" +msgid "" +"This program comes with ABSOLUTELY NO WARRANTY; for details, visit <a href=" +"\"%s\">%s</a>" msgstr "" -"Este programa viene SIN NINGUNA GARANTÍA; para obtener más detalles visite %s" +"Este programa viene SIN NINGUNA GARANTÍA; para obtener más detalles visite " +"<a href=\"%s\">%s</a>" -#: ../gtk/gtkaboutdialog.c:339 ../gtk/gtkaboutdialog.c:2233 +#: ../gtk/gtkaboutdialog.c:347 msgid "License" msgstr "Licencia" -#: ../gtk/gtkaboutdialog.c:340 +#: ../gtk/gtkaboutdialog.c:348 msgid "The license of the program" msgstr "La licencia del programa" #. Add the credits button -#: ../gtk/gtkaboutdialog.c:622 +#: ../gtk/gtkaboutdialog.c:741 msgid "C_redits" msgstr "C_réditos" #. Add the license button -#: ../gtk/gtkaboutdialog.c:636 +#: ../gtk/gtkaboutdialog.c:754 msgid "_License" msgstr "_Licencia" -#: ../gtk/gtkaboutdialog.c:840 +#: ../gtk/gtkaboutdialog.c:959 msgid "Could not show link" msgstr "No se pudo mostrar el enlace" -#: ../gtk/gtkaboutdialog.c:933 +#: ../gtk/gtkaboutdialog.c:996 +#| msgctxt "keyboard label" +#| msgid "Home" +msgid "Homepage" +msgstr "Página web" + +#: ../gtk/gtkaboutdialog.c:1052 #, c-format msgid "About %s" msgstr "Acerca de %s" -#: ../gtk/gtkaboutdialog.c:2151 -msgid "Credits" -msgstr "Créditos" - -#: ../gtk/gtkaboutdialog.c:2183 -msgid "Written by" -msgstr "Escrito por" +#: ../gtk/gtkaboutdialog.c:2367 +#| msgid "C_reate" +msgid "Created by" +msgstr "Arte por" -#: ../gtk/gtkaboutdialog.c:2186 +#: ../gtk/gtkaboutdialog.c:2370 msgid "Documented by" msgstr "Documentado por" -#: ../gtk/gtkaboutdialog.c:2198 +#: ../gtk/gtkaboutdialog.c:2382 msgid "Translated by" msgstr "Traducido por" -#: ../gtk/gtkaboutdialog.c:2202 +#: ../gtk/gtkaboutdialog.c:2386 msgid "Artwork by" msgstr "Arte por" @@ -748,7 +756,7 @@ msgid "default:mm" msgstr "default:mm" #. And show the custom paper dialog -#: ../gtk/gtkcustompaperunixdialog.c:374 ../gtk/gtkprintunixdialog.c:3240 +#: ../gtk/gtkcustompaperunixdialog.c:374 ../gtk/gtkprintunixdialog.c:3241 msgid "Manage Custom Sizes" msgstr "Gestionar tamaños personalizados" @@ -801,23 +809,23 @@ msgstr "_Derecho:" msgid "Paper Margins" msgstr "Márgenes del papel" -#: ../gtk/gtkentry.c:8794 ../gtk/gtktextview.c:8229 +#: ../gtk/gtkentry.c:8807 ../gtk/gtktextview.c:8246 msgid "Input _Methods" msgstr "_Métodos de entrada" -#: ../gtk/gtkentry.c:8808 ../gtk/gtktextview.c:8243 +#: ../gtk/gtkentry.c:8821 ../gtk/gtktextview.c:8260 msgid "_Insert Unicode Control Character" msgstr "_Insertar un carácter de control Unicode" -#: ../gtk/gtkentry.c:10208 +#: ../gtk/gtkentry.c:10225 msgid "Caps Lock and Num Lock are on" msgstr "Bloq Mayús y Bloq Num están activados" -#: ../gtk/gtkentry.c:10210 +#: ../gtk/gtkentry.c:10227 msgid "Num Lock is on" msgstr "Bloq Num está activado" -#: ../gtk/gtkentry.c:10212 +#: ../gtk/gtkentry.c:10229 msgid "Caps Lock is on" msgstr "Bloq Mayús está activado" @@ -1222,7 +1230,7 @@ msgstr "Selección de tipografías" msgid "Error loading icon: %s" msgstr "Ocurrió un error al cargar el icono: %s" -#: ../gtk/gtkicontheme.c:1355 +#: ../gtk/gtkicontheme.c:1352 #, c-format msgid "" "Could not find the icon '%s'. The '%s' theme\n" @@ -1235,12 +1243,12 @@ msgstr "" "Puede obtener una copia desde:\n" "\t%s" -#: ../gtk/gtkicontheme.c:1536 +#: ../gtk/gtkicontheme.c:1533 #, c-format msgid "Icon '%s' not present in theme" msgstr "El icono «%s» no está presente en el tema" -#: ../gtk/gtkicontheme.c:3057 +#: ../gtk/gtkicontheme.c:3054 msgid "Failed to load icon" msgstr "No se pudo cargar el icono" @@ -1266,12 +1274,12 @@ msgid "System (%s)" msgstr "Sistema (%s)" #. Open Link -#: ../gtk/gtklabel.c:6214 +#: ../gtk/gtklabel.c:6249 msgid "_Open Link" msgstr "_Abrir enlace" #. Copy Link Address -#: ../gtk/gtklabel.c:6226 +#: ../gtk/gtklabel.c:6261 msgid "Copy _Link Address" msgstr "Copiar la dirección del _enlace" @@ -1284,27 +1292,27 @@ msgid "Invalid URI" msgstr "URI inválida" #. Description of --gtk-module=MODULES in --help output -#: ../gtk/gtkmain.c:518 +#: ../gtk/gtkmain.c:516 msgid "Load additional GTK+ modules" msgstr "Cargar módulos adicionales GTK+" #. Placeholder in --gtk-module=MODULES in --help output -#: ../gtk/gtkmain.c:519 +#: ../gtk/gtkmain.c:517 msgid "MODULES" msgstr "MÓDULOS" #. Description of --g-fatal-warnings in --help output -#: ../gtk/gtkmain.c:521 +#: ../gtk/gtkmain.c:519 msgid "Make all warnings fatal" msgstr "Hacer todas las advertencias fatales" #. Description of --gtk-debug=FLAGS in --help output -#: ../gtk/gtkmain.c:524 +#: ../gtk/gtkmain.c:522 msgid "GTK+ debugging flags to set" msgstr "Opciones de depuración GTK+ a poner" #. Description of --gtk-no-debug=FLAGS in --help output -#: ../gtk/gtkmain.c:527 +#: ../gtk/gtkmain.c:525 msgid "GTK+ debugging flags to unset" msgstr "Opciones de depuración GTK+ a quitar" @@ -1313,20 +1321,20 @@ msgstr "Opciones de depuración GTK+ a quitar" #. * Do *not* translate it to "predefinito:LTR", if it #. * it isn't default:LTR or default:RTL it will not work #. -#: ../gtk/gtkmain.c:790 +#: ../gtk/gtkmain.c:788 msgid "default:LTR" msgstr "default:LTR" -#: ../gtk/gtkmain.c:855 +#: ../gtk/gtkmain.c:852 #, c-format msgid "Cannot open display: %s" msgstr "No se puede abrir el visor: %s" -#: ../gtk/gtkmain.c:914 +#: ../gtk/gtkmain.c:911 msgid "GTK+ Options" msgstr "Opciones GTK+" -#: ../gtk/gtkmain.c:914 +#: ../gtk/gtkmain.c:911 msgid "Show GTK+ Options" msgstr "Mostrar opciones GTK+" @@ -1411,7 +1419,7 @@ msgstr "Shell Z" msgid "Cannot end process with PID %d: %s" msgstr "No se puede finalizar el proceso con PID %d: %s" -#: ../gtk/gtknotebook.c:4756 ../gtk/gtknotebook.c:7319 +#: ../gtk/gtknotebook.c:4911 ../gtk/gtknotebook.c:7568 #, c-format msgid "Page %u" msgstr "Página %u" @@ -1444,7 +1452,7 @@ msgstr "" " Superior: %s %s\n" " Inferior: %s %s" -#: ../gtk/gtkpagesetupunixdialog.c:858 ../gtk/gtkprintunixdialog.c:3291 +#: ../gtk/gtkpagesetupunixdialog.c:858 ../gtk/gtkprintunixdialog.c:3292 msgid "Manage Custom Sizes..." msgstr "Gestión de tamaños personalizados…" @@ -1452,7 +1460,7 @@ msgstr "Gestión de tamaños personalizados…" msgid "_Format for:" msgstr "_Formato para:" -#: ../gtk/gtkpagesetupunixdialog.c:931 ../gtk/gtkprintunixdialog.c:3463 +#: ../gtk/gtkpagesetupunixdialog.c:931 ../gtk/gtkprintunixdialog.c:3464 msgid "_Paper size:" msgstr "Tamaño del _papel:" @@ -1460,7 +1468,7 @@ msgstr "Tamaño del _papel:" msgid "_Orientation:" msgstr "_Orientación:" -#: ../gtk/gtkpagesetupunixdialog.c:1026 ../gtk/gtkprintunixdialog.c:3525 +#: ../gtk/gtkpagesetupunixdialog.c:1026 ../gtk/gtkprintunixdialog.c:3526 msgid "Page Setup" msgstr "Configuración de página" @@ -1639,41 +1647,41 @@ msgstr "Falló la obtención de la información de la impresora" msgid "Getting printer information..." msgstr "Obteniendo la información de la impresora…" -#: ../gtk/gtkprintunixdialog.c:2139 +#: ../gtk/gtkprintunixdialog.c:2140 msgid "Printer" msgstr "Impresora" #. Translators: this is the header for the location column in the print dialog -#: ../gtk/gtkprintunixdialog.c:2149 +#: ../gtk/gtkprintunixdialog.c:2150 msgid "Location" msgstr "Lugar" #. Translators: this is the header for the printer status column in the print dialog -#: ../gtk/gtkprintunixdialog.c:2160 +#: ../gtk/gtkprintunixdialog.c:2161 msgid "Status" msgstr "Estado" -#: ../gtk/gtkprintunixdialog.c:2186 +#: ../gtk/gtkprintunixdialog.c:2187 msgid "Range" msgstr "Rango" -#: ../gtk/gtkprintunixdialog.c:2190 +#: ../gtk/gtkprintunixdialog.c:2191 msgid "_All Pages" msgstr "_Todas las páginas" -#: ../gtk/gtkprintunixdialog.c:2197 +#: ../gtk/gtkprintunixdialog.c:2198 msgid "C_urrent Page" msgstr "Página a_ctual" -#: ../gtk/gtkprintunixdialog.c:2207 +#: ../gtk/gtkprintunixdialog.c:2208 msgid "Se_lection" msgstr "Se_lección" -#: ../gtk/gtkprintunixdialog.c:2216 +#: ../gtk/gtkprintunixdialog.c:2217 msgid "Pag_es:" msgstr "Págin_as:" -#: ../gtk/gtkprintunixdialog.c:2217 +#: ../gtk/gtkprintunixdialog.c:2218 msgid "" "Specify one or more page ranges,\n" " e.g. 1-3,7,11" @@ -1681,28 +1689,28 @@ msgstr "" "Especifique uno o más rangos de páginas,\n" "ej. 1-3,7,11" -#: ../gtk/gtkprintunixdialog.c:2227 +#: ../gtk/gtkprintunixdialog.c:2228 msgid "Pages" msgstr "Páginas" -#: ../gtk/gtkprintunixdialog.c:2240 +#: ../gtk/gtkprintunixdialog.c:2241 msgid "Copies" msgstr "Copias" #. FIXME chpe: too much space between Copies and spinbutton, put those 2 in a hbox and make it span 2 columns -#: ../gtk/gtkprintunixdialog.c:2245 +#: ../gtk/gtkprintunixdialog.c:2246 msgid "Copie_s:" msgstr "_Copias:" -#: ../gtk/gtkprintunixdialog.c:2263 +#: ../gtk/gtkprintunixdialog.c:2264 msgid "C_ollate" msgstr "_Intercalar" -#: ../gtk/gtkprintunixdialog.c:2271 +#: ../gtk/gtkprintunixdialog.c:2272 msgid "_Reverse" msgstr "In_vertir" -#: ../gtk/gtkprintunixdialog.c:2291 +#: ../gtk/gtkprintunixdialog.c:2292 msgid "General" msgstr "General" @@ -1712,42 +1720,42 @@ msgstr "General" #. Translators: These strings name the possible arrangements of #. * multiple pages on a sheet when printing #. -#: ../gtk/gtkprintunixdialog.c:3024 +#: ../gtk/gtkprintunixdialog.c:3025 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3534 msgid "Left to right, top to bottom" msgstr "De izquierda a derecha, de arriba a abajo" -#: ../gtk/gtkprintunixdialog.c:3024 +#: ../gtk/gtkprintunixdialog.c:3025 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3534 msgid "Left to right, bottom to top" msgstr "De izquierda a derecha, de abajo a arriba" -#: ../gtk/gtkprintunixdialog.c:3025 +#: ../gtk/gtkprintunixdialog.c:3026 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3535 msgid "Right to left, top to bottom" msgstr "De derecha a izquierda, de arriba a abajo" -#: ../gtk/gtkprintunixdialog.c:3025 +#: ../gtk/gtkprintunixdialog.c:3026 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3535 msgid "Right to left, bottom to top" msgstr "De derecha a izquierda, de abajo a arriba" -#: ../gtk/gtkprintunixdialog.c:3026 +#: ../gtk/gtkprintunixdialog.c:3027 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3536 msgid "Top to bottom, left to right" msgstr "De arriba a abajo, de izquierda a derecha" -#: ../gtk/gtkprintunixdialog.c:3026 +#: ../gtk/gtkprintunixdialog.c:3027 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3536 msgid "Top to bottom, right to left" msgstr "De arriba a abajo, de derecha a izquierda" -#: ../gtk/gtkprintunixdialog.c:3027 +#: ../gtk/gtkprintunixdialog.c:3028 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3537 msgid "Bottom to top, left to right" msgstr "De abajo a arriba, de izquierda a derecha" -#: ../gtk/gtkprintunixdialog.c:3027 +#: ../gtk/gtkprintunixdialog.c:3028 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3537 msgid "Bottom to top, right to left" msgstr "De abajo a arriba, de derecha a izquierda" @@ -1755,125 +1763,125 @@ msgstr "De abajo a arriba, de derecha a izquierda" #. Translators, this string is used to label the option in the print #. * dialog that controls in what order multiple pages are arranged #. -#: ../gtk/gtkprintunixdialog.c:3031 ../gtk/gtkprintunixdialog.c:3044 +#: ../gtk/gtkprintunixdialog.c:3032 ../gtk/gtkprintunixdialog.c:3045 #: ../modules/printbackends/cups/gtkprintbackendcups.c:3569 msgid "Page Ordering" msgstr "Orden de las hojas" -#: ../gtk/gtkprintunixdialog.c:3060 +#: ../gtk/gtkprintunixdialog.c:3061 msgid "Left to right" msgstr "Izquierda a derecha" -#: ../gtk/gtkprintunixdialog.c:3061 +#: ../gtk/gtkprintunixdialog.c:3062 msgid "Right to left" msgstr "Derecha a izquierda" -#: ../gtk/gtkprintunixdialog.c:3073 +#: ../gtk/gtkprintunixdialog.c:3074 msgid "Top to bottom" msgstr "De arriba a abajo" -#: ../gtk/gtkprintunixdialog.c:3074 +#: ../gtk/gtkprintunixdialog.c:3075 msgid "Bottom to top" msgstr "De abajo a arriba" -#: ../gtk/gtkprintunixdialog.c:3314 +#: ../gtk/gtkprintunixdialog.c:3315 msgid "Layout" msgstr "Disposición" -#: ../gtk/gtkprintunixdialog.c:3318 +#: ../gtk/gtkprintunixdialog.c:3319 msgid "T_wo-sided:" msgstr "Por las _dos caras:" -#: ../gtk/gtkprintunixdialog.c:3333 +#: ../gtk/gtkprintunixdialog.c:3334 msgid "Pages per _side:" msgstr "Páginas por _hoja:" -#: ../gtk/gtkprintunixdialog.c:3350 +#: ../gtk/gtkprintunixdialog.c:3351 msgid "Page or_dering:" msgstr "Or_den de páginas:" -#: ../gtk/gtkprintunixdialog.c:3366 +#: ../gtk/gtkprintunixdialog.c:3367 msgid "_Only print:" msgstr "_Sólo imprimir:" #. In enum order -#: ../gtk/gtkprintunixdialog.c:3381 +#: ../gtk/gtkprintunixdialog.c:3382 msgid "All sheets" msgstr "Todas las hojas" -#: ../gtk/gtkprintunixdialog.c:3382 +#: ../gtk/gtkprintunixdialog.c:3383 msgid "Even sheets" msgstr "Hojas pares" -#: ../gtk/gtkprintunixdialog.c:3383 +#: ../gtk/gtkprintunixdialog.c:3384 msgid "Odd sheets" msgstr "Hojas impares" -#: ../gtk/gtkprintunixdialog.c:3386 +#: ../gtk/gtkprintunixdialog.c:3387 msgid "Sc_ale:" msgstr "_Escala:" -#: ../gtk/gtkprintunixdialog.c:3413 +#: ../gtk/gtkprintunixdialog.c:3414 msgid "Paper" msgstr "Papel" -#: ../gtk/gtkprintunixdialog.c:3417 +#: ../gtk/gtkprintunixdialog.c:3418 msgid "Paper _type:" msgstr "_Tipo de papel:" -#: ../gtk/gtkprintunixdialog.c:3432 +#: ../gtk/gtkprintunixdialog.c:3433 msgid "Paper _source:" msgstr "_Fuente del papel:" -#: ../gtk/gtkprintunixdialog.c:3447 +#: ../gtk/gtkprintunixdialog.c:3448 msgid "Output t_ray:" msgstr "_Bandeja de salida:" -#: ../gtk/gtkprintunixdialog.c:3487 +#: ../gtk/gtkprintunixdialog.c:3488 msgid "Or_ientation:" msgstr "Or_ientación:" #. In enum order -#: ../gtk/gtkprintunixdialog.c:3502 +#: ../gtk/gtkprintunixdialog.c:3503 msgid "Portrait" msgstr "Retrato" -#: ../gtk/gtkprintunixdialog.c:3503 +#: ../gtk/gtkprintunixdialog.c:3504 msgid "Landscape" msgstr "Paisaje" -#: ../gtk/gtkprintunixdialog.c:3504 +#: ../gtk/gtkprintunixdialog.c:3505 msgid "Reverse portrait" msgstr "Retrato invertido" -#: ../gtk/gtkprintunixdialog.c:3505 +#: ../gtk/gtkprintunixdialog.c:3506 msgid "Reverse landscape" msgstr "Paisaje invertido" -#: ../gtk/gtkprintunixdialog.c:3550 +#: ../gtk/gtkprintunixdialog.c:3551 msgid "Job Details" msgstr "Detalles de la tarea" -#: ../gtk/gtkprintunixdialog.c:3556 +#: ../gtk/gtkprintunixdialog.c:3557 msgid "Pri_ority:" msgstr "_Prioridad:" -#: ../gtk/gtkprintunixdialog.c:3571 +#: ../gtk/gtkprintunixdialog.c:3572 msgid "_Billing info:" msgstr "Info de _facturación:" -#: ../gtk/gtkprintunixdialog.c:3589 +#: ../gtk/gtkprintunixdialog.c:3590 msgid "Print Document" msgstr "Imprimir documento" #. Translators: this is one of the choices for the print at option #. * in the print dialog #. -#: ../gtk/gtkprintunixdialog.c:3598 +#: ../gtk/gtkprintunixdialog.c:3599 msgid "_Now" msgstr "_Ahora" -#: ../gtk/gtkprintunixdialog.c:3609 +#: ../gtk/gtkprintunixdialog.c:3610 msgid "A_t:" msgstr "_En:" @@ -1881,7 +1889,7 @@ msgstr "_En:" #. * You can remove the am/pm values below for your locale if they are not #. * supported. #. -#: ../gtk/gtkprintunixdialog.c:3615 +#: ../gtk/gtkprintunixdialog.c:3616 msgid "" "Specify the time of print,\n" " e.g. 15:30, 2:35 pm, 14:15:20, 11:46:30 am, 4 pm" @@ -1889,77 +1897,72 @@ msgstr "" "Especifique la hora de impresión,\n" "ej. 15:30, 2:35 pm, 14:15:20, 11:46:30 am, 4 pm" -#: ../gtk/gtkprintunixdialog.c:3625 +#: ../gtk/gtkprintunixdialog.c:3626 msgid "Time of print" msgstr "Hora de la impresión" -#: ../gtk/gtkprintunixdialog.c:3641 +#: ../gtk/gtkprintunixdialog.c:3642 msgid "On _hold" msgstr "En _espera" -#: ../gtk/gtkprintunixdialog.c:3642 +#: ../gtk/gtkprintunixdialog.c:3643 msgid "Hold the job until it is explicitly released" msgstr "Retener el trabajo hasta que se libere explícitamente" -#: ../gtk/gtkprintunixdialog.c:3662 +#: ../gtk/gtkprintunixdialog.c:3663 msgid "Add Cover Page" msgstr "Añadir página de cubierta" #. Translators, this is the label used for the option in the print #. * dialog that controls the front cover page. #. -#: ../gtk/gtkprintunixdialog.c:3671 +#: ../gtk/gtkprintunixdialog.c:3672 msgid "Be_fore:" msgstr "An_tes:" #. Translators, this is the label used for the option in the print #. * dialog that controls the back cover page. #. -#: ../gtk/gtkprintunixdialog.c:3689 +#: ../gtk/gtkprintunixdialog.c:3690 msgid "_After:" msgstr "_Después:" #. Translators: this is the tab label for the notebook tab containing #. * job-specific options in the print dialog #. -#: ../gtk/gtkprintunixdialog.c:3707 +#: ../gtk/gtkprintunixdialog.c:3708 msgid "Job" msgstr "Tarea" -#: ../gtk/gtkprintunixdialog.c:3773 +#: ../gtk/gtkprintunixdialog.c:3774 msgid "Advanced" msgstr "Avanzado" #. Translators: this will appear as tab label in print dialog. -#: ../gtk/gtkprintunixdialog.c:3811 +#: ../gtk/gtkprintunixdialog.c:3812 msgid "Image Quality" msgstr "Calidad de imagen" #. Translators: this will appear as tab label in print dialog. -#: ../gtk/gtkprintunixdialog.c:3815 +#: ../gtk/gtkprintunixdialog.c:3816 msgid "Color" msgstr "Color" #. Translators: this will appear as tab label in print dialog. #. It's a typographical term, as in "Binding and finishing" -#: ../gtk/gtkprintunixdialog.c:3820 +#: ../gtk/gtkprintunixdialog.c:3821 msgid "Finishing" msgstr "Terminando" -#: ../gtk/gtkprintunixdialog.c:3830 +#: ../gtk/gtkprintunixdialog.c:3831 msgid "Some of the settings in the dialog conflict" msgstr "Algunos de los ajustes del diálogo están en conflicto" -#: ../gtk/gtkprintunixdialog.c:3853 +#: ../gtk/gtkprintunixdialog.c:3854 msgid "Print" msgstr "Imprimir" -#: ../gtk/gtkrc.c:2834 -#, c-format -msgid "Unable to find include file: \"%s\"" -msgstr "No se ha podido encontrar el archivo «include»: «%s»" - -#: ../gtk/gtkrc.c:3470 ../gtk/gtkrc.c:3473 +#: ../gtk/gtkrc.c:2366 ../gtk/gtkrc.c:2369 #, c-format msgid "Unable to locate image file in pixmap_path: \"%s\"" msgstr "Imposible encontrar un archivo imagen en pixmap_path: «%s»" @@ -2070,12 +2073,12 @@ msgstr "" "No se encontró ninguna aplicación registrada con el nombre «%s» para el " "elemento con el URI «%s»" -#: ../gtk/gtkspinner.c:456 +#: ../gtk/gtkspinner.c:326 msgctxt "throbbing progress animation widget" msgid "Spinner" msgstr "Marcador incrementable" -#: ../gtk/gtkspinner.c:457 +#: ../gtk/gtkspinner.c:327 msgid "Provides visual indication of progress" msgstr "Proporciona una indicación visual del progreso" @@ -2589,7 +2592,7 @@ msgstr "_Reducir" #. * glyphs then use MEDIUM VERTICAL BAR (U+2759) as the text for #. * the state #. -#: ../gtk/gtkswitch.c:297 ../gtk/gtkswitch.c:340 ../gtk/gtkswitch.c:532 +#: ../gtk/gtkswitch.c:296 ../gtk/gtkswitch.c:339 ../gtk/gtkswitch.c:531 msgctxt "switch" msgid "ON" msgstr "ENCENDIDO" @@ -2597,18 +2600,17 @@ msgstr "ENCENDIDO" #. Translators: if the "off" state label requires more than three #. * glyphs then use WHITE CIRCLE (U+25CB) as the text for the state #. -#: ../gtk/gtkswitch.c:305 ../gtk/gtkswitch.c:341 ../gtk/gtkswitch.c:553 +#: ../gtk/gtkswitch.c:304 ../gtk/gtkswitch.c:340 ../gtk/gtkswitch.c:552 msgctxt "switch" msgid "OFF" msgstr "APAGADO" -#: ../gtk/gtkswitch.c:938 -#| msgid "inch" +#: ../gtk/gtkswitch.c:943 msgctxt "light switch widget" msgid "Switch" msgstr "Interruptor" -#: ../gtk/gtkswitch.c:939 +#: ../gtk/gtkswitch.c:944 msgid "Switches between on and off states" msgstr "Cambia entre los estados encendido y apagado" @@ -2622,108 +2624,108 @@ msgstr "Error desconocido al intentar deserializar %s" msgid "No deserialize function found for format %s" msgstr "No se encontró función de deserialización para el formato %s" -#: ../gtk/gtktextbufferserialize.c:803 ../gtk/gtktextbufferserialize.c:829 +#: ../gtk/gtktextbufferserialize.c:799 ../gtk/gtktextbufferserialize.c:825 #, c-format msgid "Both \"id\" and \"name\" were found on the <%s> element" msgstr "Se encontraron tanto «id» como «name» en el elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:813 ../gtk/gtktextbufferserialize.c:839 +#: ../gtk/gtktextbufferserialize.c:809 ../gtk/gtktextbufferserialize.c:835 #, c-format msgid "The attribute \"%s\" was found twice on the <%s> element" msgstr "Se encontró el atributo «%s» dos veces en el elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:855 +#: ../gtk/gtktextbufferserialize.c:851 #, c-format msgid "<%s> element has invalid ID \"%s\"" msgstr "El elemento <%s> tiene el ID inválido «%s»" -#: ../gtk/gtktextbufferserialize.c:865 +#: ../gtk/gtktextbufferserialize.c:861 #, c-format msgid "<%s> element has neither a \"name\" nor an \"id\" attribute" msgstr "El elemento <%s> no tiene ni un elemento «name» ni un elemento «id»" -#: ../gtk/gtktextbufferserialize.c:952 +#: ../gtk/gtktextbufferserialize.c:948 #, c-format msgid "Attribute \"%s\" repeated twice on the same <%s> element" msgstr "El atributo «%s» se repite dos veces en el mismo elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:970 ../gtk/gtktextbufferserialize.c:995 +#: ../gtk/gtktextbufferserialize.c:966 ../gtk/gtktextbufferserialize.c:991 #, c-format msgid "Attribute \"%s\" is invalid on <%s> element in this context" msgstr "El atributo «%s» es inválido en el elemento <%s> en este contexto" -#: ../gtk/gtktextbufferserialize.c:1034 +#: ../gtk/gtktextbufferserialize.c:1030 #, c-format msgid "Tag \"%s\" has not been defined." msgstr "La etiqueta «%s» no ha sido definida." -#: ../gtk/gtktextbufferserialize.c:1046 +#: ../gtk/gtktextbufferserialize.c:1042 msgid "Anonymous tag found and tags can not be created." msgstr "Se encontró una etiqueta anónima y las etiquetas no se pueden crear." -#: ../gtk/gtktextbufferserialize.c:1057 +#: ../gtk/gtktextbufferserialize.c:1053 #, c-format msgid "Tag \"%s\" does not exist in buffer and tags can not be created." msgstr "" "La etiqueta «%s» no existe en el búfer y las etiquetas no se pueden crear." -#: ../gtk/gtktextbufferserialize.c:1156 ../gtk/gtktextbufferserialize.c:1231 -#: ../gtk/gtktextbufferserialize.c:1336 ../gtk/gtktextbufferserialize.c:1410 +#: ../gtk/gtktextbufferserialize.c:1152 ../gtk/gtktextbufferserialize.c:1227 +#: ../gtk/gtktextbufferserialize.c:1332 ../gtk/gtktextbufferserialize.c:1406 #, c-format msgid "Element <%s> is not allowed below <%s>" msgstr "El elemento <%s» no se permite debajo de <%s>" -#: ../gtk/gtktextbufferserialize.c:1187 +#: ../gtk/gtktextbufferserialize.c:1183 #, c-format msgid "\"%s\" is not a valid attribute type" msgstr "«%s» no es un tipo de atributo válido" -#: ../gtk/gtktextbufferserialize.c:1195 +#: ../gtk/gtktextbufferserialize.c:1191 #, c-format msgid "\"%s\" is not a valid attribute name" msgstr "«%s» no es un nombre de atributo válido" -#: ../gtk/gtktextbufferserialize.c:1205 +#: ../gtk/gtktextbufferserialize.c:1201 #, c-format msgid "" "\"%s\" could not be converted to a value of type \"%s\" for attribute \"%s\"" msgstr "«%s» no se pudo convertir a un valor de tipo «%s»para el atributo «%s»" -#: ../gtk/gtktextbufferserialize.c:1214 +#: ../gtk/gtktextbufferserialize.c:1210 #, c-format msgid "\"%s\" is not a valid value for attribute \"%s\"" msgstr "«%s» no es un valor válido para el atributo «%s»" -#: ../gtk/gtktextbufferserialize.c:1299 +#: ../gtk/gtktextbufferserialize.c:1295 #, c-format msgid "Tag \"%s\" already defined" msgstr "La etiqueta «%s» ya está definida" -#: ../gtk/gtktextbufferserialize.c:1312 +#: ../gtk/gtktextbufferserialize.c:1308 #, c-format msgid "Tag \"%s\" has invalid priority \"%s\"" msgstr "La etiqueta «%s» tiene prioridad «%s» inválida" -#: ../gtk/gtktextbufferserialize.c:1365 +#: ../gtk/gtktextbufferserialize.c:1361 #, c-format msgid "Outermost element in text must be <text_view_markup> not <%s>" msgstr "" "El elemento más externo en el texto debe ser <text_view_markup> no <%s>" -#: ../gtk/gtktextbufferserialize.c:1374 ../gtk/gtktextbufferserialize.c:1390 +#: ../gtk/gtktextbufferserialize.c:1370 ../gtk/gtktextbufferserialize.c:1386 #, c-format msgid "A <%s> element has already been specified" msgstr "Ya se ha especificado un elemento <%s>" -#: ../gtk/gtktextbufferserialize.c:1396 +#: ../gtk/gtktextbufferserialize.c:1392 msgid "A <text> element can't occur before a <tags> element" msgstr "Un elemento <text> no puede estar antes de un elemento <tags>" -#: ../gtk/gtktextbufferserialize.c:1796 +#: ../gtk/gtktextbufferserialize.c:1792 msgid "Serialized data is malformed" msgstr "Los datos serializados están mal formados" -#: ../gtk/gtktextbufferserialize.c:1874 +#: ../gtk/gtktextbufferserialize.c:1870 msgid "" "Serialized data is malformed. First section isn't GTKTEXTBUFFERCONTENTS-0001" msgstr "" @@ -4269,6 +4271,15 @@ msgstr "" "No se ha podido cargar la imagen «%s»: el motivo es desconocido, " "probablemente el archivo gráfico esté corrupto" +#~ msgid "Credits" +#~ msgstr "Créditos" + +#~ msgid "Written by" +#~ msgstr "Escrito por" + +#~ msgid "Unable to find include file: \"%s\"" +#~ msgstr "No se ha podido encontrar el archivo «include»: «%s»" + #~ msgid "Error creating folder '%s': %s" #~ msgstr "Error al crear la carpeta «%s» : %s" @@ -4989,9 +5000,6 @@ msgstr "" #~ msgid "_Folder name:" #~ msgstr "_Nombre de la carpeta:" -#~ msgid "C_reate" -#~ msgstr "C_rear" - #~ msgid "" #~ "The filename \"%s\" contains symbols that are not allowed in filenames" #~ msgstr "" diff --git a/tests/testassistant.c b/tests/testassistant.c index a6b4ef5e67..8501bbcc76 100644 --- a/tests/testassistant.c +++ b/tests/testassistant.c @@ -513,11 +513,11 @@ create_full_featured_assistant (GtkWidget *widget) gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE); /* set a side image */ - pixbuf = gtk_widget_render_icon (page, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (page, GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG); gtk_assistant_set_page_side_image (GTK_ASSISTANT (assistant), page, pixbuf); /* set a header image */ - pixbuf = gtk_widget_render_icon (page, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (page, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); gtk_assistant_set_page_header_image (GTK_ASSISTANT (assistant), page, pixbuf); page = get_test_page ("Invisible page"); @@ -531,7 +531,7 @@ create_full_featured_assistant (GtkWidget *widget) gtk_assistant_set_page_complete (GTK_ASSISTANT (assistant), page, TRUE); /* set a header image */ - pixbuf = gtk_widget_render_icon (page, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (page, GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG); gtk_assistant_set_page_header_image (GTK_ASSISTANT (assistant), page, pixbuf); } diff --git a/tests/testcombo.c b/tests/testcombo.c index 4a04f1a6bd..f321fb0a55 100644 --- a/tests/testcombo.c +++ b/tests/testcombo.c @@ -166,8 +166,8 @@ create_tree_blaat (void) store = gtk_tree_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_BOOLEAN); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_BUTTON); gtk_tree_store_append (store, &iter, NULL); gtk_tree_store_set (store, &iter, 0, pixbuf, @@ -175,8 +175,8 @@ create_tree_blaat (void) 2, FALSE, -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_STOP, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_STOP, + GTK_ICON_SIZE_BUTTON); gtk_tree_store_append (store, &iter2, &iter); gtk_tree_store_set (store, &iter2, 0, pixbuf, @@ -184,8 +184,8 @@ create_tree_blaat (void) 2, FALSE, -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_NEW, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_NEW, + GTK_ICON_SIZE_BUTTON); gtk_tree_store_append (store, &iter2, &iter); gtk_tree_store_set (store, &iter2, 0, pixbuf, @@ -193,8 +193,8 @@ create_tree_blaat (void) 2, FALSE, -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_CLEAR, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_CLEAR, + GTK_ICON_SIZE_BUTTON); gtk_tree_store_append (store, &iter, NULL); gtk_tree_store_set (store, &iter, 0, pixbuf, @@ -211,8 +211,8 @@ create_tree_blaat (void) -1); #endif - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_OPEN, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_OPEN, + GTK_ICON_SIZE_BUTTON); gtk_tree_store_append (store, &iter, NULL); gtk_tree_store_set (store, &iter, 0, pixbuf, @@ -237,8 +237,8 @@ create_empty_list_blaat (void) store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, @@ -268,24 +268,24 @@ populate_list_blaat (gpointer data) cellview = gtk_cell_view_new (); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_STOP, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_STOP, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, 1, "gtk-stock-stop", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_NEW, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_NEW, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, 1, "gtk-stock-new", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_CLEAR, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_CLEAR, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, @@ -298,8 +298,8 @@ populate_list_blaat (gpointer data) 1, "separator", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_OPEN, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_OPEN, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, @@ -321,32 +321,32 @@ create_list_blaat (void) store = gtk_list_store_new (2, GDK_TYPE_PIXBUF, G_TYPE_STRING); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, 1, "gtk-stock-dialog-warning", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_STOP, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_STOP, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, 1, "gtk-stock-stop", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_NEW, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_NEW, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, 1, "gtk-stock-new", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_CLEAR, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_CLEAR, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, @@ -359,8 +359,8 @@ create_list_blaat (void) 1, "separator", -1); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_OPEN, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_OPEN, + GTK_ICON_SIZE_BUTTON); gtk_list_store_append (store, &iter); gtk_list_store_set (store, &iter, 0, pixbuf, @@ -1077,8 +1077,8 @@ main (int argc, char **argv) cellview = gtk_cell_view_new (); renderer = gtk_cell_renderer_pixbuf_new (); - pixbuf = gtk_widget_render_icon (cellview, GTK_STOCK_DIALOG_WARNING, - GTK_ICON_SIZE_BUTTON, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (cellview, GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_BUTTON); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (cellview), renderer, diff --git a/tests/testdnd.c b/tests/testdnd.c index 8777acd1d4..9913564470 100644 --- a/tests/testdnd.c +++ b/tests/testdnd.c @@ -377,13 +377,14 @@ target_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, - GtkSelectionData *data, + GtkSelectionData *selection_data, guint info, guint time) { - if ((data->length >= 0) && (data->format == 8)) + if (gtk_selection_data_get_length (selection_data) >= 0 && + gtk_selection_data_get_format (selection_data) == 8) { - g_print ("Received \"%s\" in trashcan\n", (gchar *)data->data); + g_print ("Received \"%s\" in trashcan\n", (gchar *) gtk_selection_data_get_data (selection_data)); gtk_drag_finish (context, TRUE, FALSE, time); return; } @@ -396,13 +397,14 @@ label_drag_data_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, - GtkSelectionData *data, + GtkSelectionData *selection_data, guint info, guint time) { - if ((data->length >= 0) && (data->format == 8)) + if (gtk_selection_data_get_length (selection_data) >= 0 && + gtk_selection_data_get_format (selection_data) == 8) { - g_print ("Received \"%s\" in label\n", (gchar *)data->data); + g_print ("Received \"%s\" in label\n", (gchar *) gtk_selection_data_get_data (selection_data)); gtk_drag_finish (context, TRUE, FALSE, time); return; } @@ -422,7 +424,7 @@ source_drag_data_get (GtkWidget *widget, g_print ("I was dropped on the rootwin\n"); else gtk_selection_data_set (selection_data, - selection_data->target, + gtk_selection_data_get_target (selection_data), 8, (guchar *) "I'm Data!", 9); } diff --git a/tests/testgtk.c b/tests/testgtk.c index 76d68387f7..dee4802a20 100644 --- a/tests/testgtk.c +++ b/tests/testgtk.c @@ -8917,19 +8917,19 @@ create_snapshot (GtkWidget *widget) void selection_test_received (GtkWidget *tree_view, - GtkSelectionData *data) + GtkSelectionData *selection_data) { GtkTreeModel *model; GtkListStore *store; GdkAtom *atoms; int i, l; - if (data->length < 0) + if (gtk_selection_data_get_length (selection_data) < 0) { g_print ("Selection retrieval failed\n"); return; } - if (data->type != GDK_SELECTION_TYPE_ATOM) + if (gtk_selection_data_get_data_type (selection_data) != GDK_SELECTION_TYPE_ATOM) { g_print ("Selection \"TARGETS\" was not returned as atoms!\n"); return; @@ -8943,9 +8943,9 @@ selection_test_received (GtkWidget *tree_view, /* Add new items to list */ - atoms = (GdkAtom *)data->data; + gtk_selection_data_get_targets (selection_data, + &atoms, &l); - l = data->length / sizeof (GdkAtom); for (i = 0; i < l; i++) { char *name; diff --git a/tests/testiconview-keynav.c b/tests/testiconview-keynav.c index 07e9479fa2..002c003e76 100644 --- a/tests/testiconview-keynav.c +++ b/tests/testiconview-keynav.c @@ -209,20 +209,28 @@ focus_in (GtkWidget *view, return FALSE; } +#define CSS \ + "GtkWindow {\n" \ + " background-color: @base_color;\n" \ + "}\n" + static void -header_style_set (GtkWidget *widget, - GtkStyle *old_style) +set_styles (void) { - GtkStyle *style; + GtkCssProvider *provider; + GdkScreen *screen; + + provider = gtk_css_provider_new (); + + if (!gtk_css_provider_load_from_data (provider, CSS, -1, NULL)) + { + g_assert_not_reached (); + } - style = gtk_widget_get_style (widget); + screen = gdk_display_get_default_screen (gdk_display_get_default ()); - g_signal_handlers_block_by_func (widget, header_style_set, NULL); - gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, - &style->base[GTK_STATE_NORMAL]); - gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, - &style->text[GTK_STATE_NORMAL]); - g_signal_handlers_unblock_by_func (widget, header_style_set, NULL); + gtk_style_context_add_provider_for_screen (screen, GTK_STYLE_PROVIDER (provider), + GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); } int @@ -234,6 +242,8 @@ main (int argc, char *argv[]) gtk_init (&argc, &argv); + set_styles (); + window = gtk_window_new (GTK_WINDOW_TOPLEVEL); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window), vbox); @@ -263,12 +273,6 @@ main (int argc, char *argv[]) G_CALLBACK (focus_in), NULL); g_signal_connect (views.view2, "focus-out-event", G_CALLBACK (focus_out), NULL); - g_signal_connect (views.header1, "style-set", - G_CALLBACK (header_style_set), NULL); - g_signal_connect (views.header2, "style-set", - G_CALLBACK (header_style_set), NULL); - g_signal_connect (window, "style-set", - G_CALLBACK (header_style_set), NULL); gtk_container_add (GTK_CONTAINER (vbox), views.header1); gtk_container_add (GTK_CONTAINER (vbox), views.view1); diff --git a/tests/testimage.c b/tests/testimage.c index 375a5b8142..d44559e9b3 100644 --- a/tests/testimage.c +++ b/tests/testimage.c @@ -61,7 +61,7 @@ drag_data_received (GtkWidget *widget, GdkPixbuf *pixbuf; - if (selection_data->length < 0) + if (gtk_selection_data_get_length (selection_data) < 0) return; pixbuf = gtk_selection_data_get_pixbuf (selection_data); diff --git a/tests/testinput.c b/tests/testinput.c index b125c7562c..c7348d7657 100644 --- a/tests/testinput.c +++ b/tests/testinput.c @@ -119,26 +119,27 @@ static void draw_brush (GtkWidget *widget, GdkInputSource source, gdouble x, gdouble y, gdouble pressure) { - GtkStyle *style; - GdkColor color; + GdkRGBA color; GdkRectangle update_rect; cairo_t *cr; - style = gtk_widget_get_style (widget); + color.alpha = 1.0; switch (source) { case GDK_SOURCE_MOUSE: - color = style->dark[gtk_widget_get_state (widget)]; + color.red = color.green = 0.0; + color.blue = 1.0; break; case GDK_SOURCE_PEN: - color.red = color.green = color.blue = 0; + color.red = color.green = color.blue = 0.0; break; case GDK_SOURCE_ERASER: - color.red = color.green = color.blue = 65535; + color.red = color.green = color.blue = 1.0; break; default: - color = style->light[gtk_widget_get_state (widget)]; + color.red = color.blue = 0.0; + color.green = 1.0; } update_rect.x = x - 10 * pressure; @@ -147,7 +148,7 @@ draw_brush (GtkWidget *widget, GdkInputSource source, update_rect.height = 20 * pressure; cr = cairo_create (surface); - gdk_cairo_set_source_color (cr, &color); + gdk_cairo_set_source_rgba (cr, &color); gdk_cairo_rectangle (cr, &update_rect); cairo_fill (cr); cairo_destroy (cr); diff --git a/tests/testnotebookdnd.c b/tests/testnotebookdnd.c index 459146d609..3621b0a2b3 100644 --- a/tests/testnotebookdnd.c +++ b/tests/testnotebookdnd.c @@ -111,9 +111,9 @@ on_notebook_drag_begin (GtkWidget *widget, if (page_num > 2) { - pixbuf = gtk_widget_render_icon (widget, - (page_num % 2) ? GTK_STOCK_HELP : GTK_STOCK_STOP, - GTK_ICON_SIZE_DND, NULL); + pixbuf = gtk_widget_render_icon_pixbuf (widget, + (page_num % 2) ? GTK_STOCK_HELP : GTK_STOCK_STOP, + GTK_ICON_SIZE_DND); gtk_drag_set_icon_pixbuf (context, pixbuf, 0, 0); g_object_unref (pixbuf); @@ -134,7 +134,7 @@ on_button_drag_data_received (GtkWidget *widget, GtkWidget **child; source = gtk_drag_get_source_widget (context); - child = (void*) data->data; + child = (void*) gtk_selection_data_get_data (data); tab_label = gtk_notebook_get_tab_label (GTK_NOTEBOOK (source), *child); g_print ("Removing tab: %s\n", gtk_label_get_text (GTK_LABEL (tab_label))); diff --git a/tests/testselection.c b/tests/testselection.c index b6b79d3a2f..de4ec6a950 100644 --- a/tests/testselection.c +++ b/tests/testselection.c @@ -265,24 +265,28 @@ stringify_span (guchar *data, gint *position) } void -selection_received (GtkWidget *widget, GtkSelectionData *data) +selection_received (GtkWidget *widget, GtkSelectionData *selection_data) { int position; int i; SelType seltype; char *str; + guchar *data; GtkTextBuffer *buffer; - - if (data->length < 0) + GdkAtom type; + + if (gtk_selection_data_get_length (selection_data) < 0) { g_print("Error retrieving selection\n"); return; } + type = gtk_selection_data_get_data_type (selection_data); + seltype = SEL_TYPE_NONE; for (i=0; i<LAST_SEL_TYPE; i++) { - if (seltypes[i] == data->type) + if (seltypes[i] == type) { seltype = i; break; @@ -291,7 +295,7 @@ selection_received (GtkWidget *widget, GtkSelectionData *data) if (seltype == SEL_TYPE_NONE) { - char *name = gdk_atom_name (data->type); + char *name = gdk_atom_name (type); g_print("Don't know how to handle type: %s\n", name?name:"<unknown>"); return; @@ -306,38 +310,39 @@ selection_received (GtkWidget *widget, GtkSelectionData *data) gtk_text_buffer_set_text (buffer, "", -1); position = 0; - while (position < data->length) + while (position < gtk_selection_data_get_length (selection_data)) { + data = (guchar *) gtk_selection_data_get_data (selection_data); switch (seltype) { case ATOM: - str = stringify_atom (data->data, &position); + str = stringify_atom (data, &position); break; case COMPOUND_TEXT: case STRING: case TEXT: - str = stringify_text (data->data, &position); + str = stringify_text (data, &position); break; case BITMAP: case DRAWABLE: case PIXMAP: case WINDOW: case COLORMAP: - str = stringify_xid (data->data, &position); + str = stringify_xid (data, &position); break; case INTEGER: case PIXEL: - str = stringify_integer (data->data, &position); + str = stringify_integer (data, &position); break; case SPAN: - str = stringify_span (data->data, &position); + str = stringify_span (data, &position); break; default: { - char *name = gdk_atom_name (data->type); + char *name = gdk_atom_name (gtk_selection_data_get_data_type (selection_data)); g_print("Can't convert type %s to string\n", name?name:"<unknown>"); - position = data->length; + position = gtk_selection_data_get_length (selection_data); continue; } } diff --git a/tests/testtreeedit.c b/tests/testtreeedit.c index 86956975d4..01e1f2bbe7 100644 --- a/tests/testtreeedit.c +++ b/tests/testtreeedit.c @@ -56,8 +56,8 @@ create_model (void) GtkWidget *blah; blah = gtk_window_new (GTK_WINDOW_TOPLEVEL); - foo = gtk_widget_render_icon (blah, GTK_STOCK_NEW, GTK_ICON_SIZE_MENU, NULL); - bar = gtk_widget_render_icon (blah, GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU, NULL); + foo = gtk_widget_render_icon_pixbuf (blah, GTK_STOCK_NEW, GTK_ICON_SIZE_MENU); + bar = gtk_widget_render_icon_pixbuf (blah, GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU); gtk_widget_destroy (blah); model = gtk_tree_store_new (NUM_COLUMNS, |