X-Git-Url: http://pileus.org/git/?a=blobdiff_plain;f=gtk%2Fgtktoolitemgroup.c;h=d6aa8258c6bdcc9371231fb29f75f081dfc744e5;hb=6767541ead7cc150d1dd066d3b84d85559500c28;hp=e10e3515261a07725b0162f30c64b9f0231b2add;hpb=e9319c618212f385d5e3702cc86c51bd87970356;p=~andy%2Fgtk diff --git a/gtk/gtktoolitemgroup.c b/gtk/gtktoolitemgroup.c index e10e35152..d6aa8258c 100644 --- a/gtk/gtktoolitemgroup.c +++ b/gtk/gtktoolitemgroup.c @@ -12,8 +12,7 @@ * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * License along with this library. If not, see . * * Authors: * Mathias Hasselmann @@ -81,12 +80,10 @@ struct _GtkToolItemGroupPrivate GList *children; - gboolean animation; gint64 animation_start; GSource *animation_timeout; gint expander_size; gint header_spacing; - PangoEllipsizeMode ellipsize; gulong focus_set_id; GtkWidget *toplevel; @@ -94,6 +91,9 @@ struct _GtkToolItemGroupPrivate GtkSettings *settings; gulong settings_connection; + PangoEllipsizeMode ellipsize; + + guint animation : 1; guint collapsed : 1; }; @@ -229,6 +229,7 @@ gtk_tool_item_group_screen_changed (GtkWidget *widget, if (old_settings) { g_signal_handler_disconnect (old_settings, priv->settings_connection); + priv->settings_connection = 0; g_object_unref (old_settings); } @@ -276,6 +277,7 @@ gtk_tool_item_group_header_draw_cb (GtkWidget *widget, width = gtk_widget_get_allocated_width (widget); height = gtk_widget_get_allocated_height (widget); context = gtk_widget_get_style_context (widget); + state = gtk_widget_get_state_flags (widget); if (!priv->collapsed) state |= GTK_STATE_FLAG_ACTIVE; @@ -302,14 +304,10 @@ gtk_tool_item_group_header_draw_cb (GtkWidget *widget, y = 0; } - /* The expander is the only animatable region */ - gtk_style_context_push_animatable_region (context, GUINT_TO_POINTER (1)); - gtk_render_expander (context, cr, x, y, priv->expander_size, priv->expander_size); - gtk_style_context_pop_animatable_region (context); gtk_style_context_restore (context); return FALSE; @@ -392,7 +390,8 @@ gtk_tool_item_group_init (GtkToolItemGroup *group) priv->expander_size = DEFAULT_EXPANDER_SIZE; priv->label_widget = gtk_label_new (NULL); - gtk_misc_set_alignment (GTK_MISC (priv->label_widget), 0.0, 0.5); + gtk_widget_set_halign (priv->label_widget, GTK_ALIGN_START); + gtk_widget_set_valign (priv->label_widget, GTK_ALIGN_CENTER); alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0); gtk_container_add (GTK_CONTAINER (alignment), priv->label_widget); gtk_widget_show_all (alignment); @@ -521,6 +520,14 @@ gtk_tool_item_group_dispose (GObject *object) priv->toplevel = NULL; } + if (priv->settings_connection > 0) + { + g_signal_handler_disconnect (priv->settings, priv->settings_connection); + priv->settings_connection = 0; + } + + g_clear_object (&priv->settings); + G_OBJECT_CLASS (gtk_tool_item_group_parent_class)->dispose (object); } @@ -642,14 +649,12 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget, GtkAllocation item_area; GtkOrientation orientation; - GtkToolbarStyle style; gint min_rows; guint border_width; border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)); - style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group)); /* figure out the size of homogeneous items */ gtk_tool_item_group_get_item_size (group, &item_size, TRUE, &min_rows); @@ -665,7 +670,9 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget, item_area.width = 0; item_area.height = 0; - /* figure out the required columns (n_columns) and rows (n_rows) to place all items */ + /* figure out the required columns (n_columns) and rows (n_rows) + * to place all items + */ if (!priv->collapsed || !priv->animation || priv->animation_timeout) { guint n_columns; @@ -740,7 +747,9 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget, row_min_width = g_new0 (guint, n_rows); - /* calculate minimal and maximal required cols and minimal required rows */ + /* calculate minimal and maximal required cols and minimal + * required rows + */ for (it = priv->children; it != NULL; it = it->next) { GtkToolItemGroupChild *child = it->data; @@ -791,7 +800,9 @@ gtk_tool_item_group_real_size_query (GtkWidget *widget, min_col = MAX (min_col, row_min_width[i]); } - /* simple linear search for minimal required columns for the given maximal number of rows (n_rows) */ + /* simple linear search for minimal required columns + * for the given maximal number of rows (n_rows) + */ for (n_columns = min_col; n_columns < max_col; n_columns ++) { new_row = TRUE; @@ -885,7 +896,6 @@ gtk_tool_item_group_real_size_allocate (GtkWidget *widget, GtkAllocation item_area; GtkOrientation orientation; - GtkToolbarStyle style; GList *it; @@ -899,7 +909,6 @@ gtk_tool_item_group_real_size_allocate (GtkWidget *widget, direction = gtk_widget_get_direction (widget); orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)); - style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group)); /* chain up */ GTK_WIDGET_CLASS (gtk_tool_item_group_parent_class)->size_allocate (widget, allocation); @@ -1204,7 +1213,6 @@ gtk_tool_item_group_realize (GtkWidget *widget) GtkWidget *toplevel_window; GdkWindow *window; GdkWindowAttr attributes; - GdkDisplay *display; gint attributes_mask; guint border_width; GtkStyleContext *context; @@ -1233,12 +1241,7 @@ gtk_tool_item_group_realize (GtkWidget *widget) &attributes, attributes_mask); gtk_widget_set_window (widget, window); - display = gdk_window_get_display (window); - - if (gdk_display_supports_composite (display)) - gdk_window_set_composited (window, TRUE); - - gdk_window_set_user_data (window, widget); + gtk_widget_register_window (widget, window); gtk_style_context_set_background (context, window); @@ -1867,7 +1870,7 @@ gtk_tool_item_group_animation_cb (gpointer data) gint64 timestamp = gtk_tool_item_group_get_animation_timestamp (group); gboolean retval; - GDK_THREADS_ENTER (); + gdk_threads_enter (); /* Enque this early to reduce number of expose events. */ gtk_widget_queue_resize_no_redraw (GTK_WIDGET (group)); @@ -1880,7 +1883,7 @@ gtk_tool_item_group_animation_cb (gpointer data) retval = (priv->animation_timeout != NULL); - GDK_THREADS_LEAVE (); + gdk_threads_leave (); return retval; } @@ -1911,8 +1914,6 @@ gtk_tool_item_group_set_collapsed (GtkToolItemGroup *group, GTK_WIDGET (group)); if (collapsed != priv->collapsed) { - GtkStyleContext *context; - if (priv->animation) { if (priv->animation_timeout) @@ -1925,19 +1926,6 @@ gtk_tool_item_group_set_collapsed (GtkToolItemGroup *group, gtk_tool_item_group_animation_cb, group, NULL); g_source_attach (priv->animation_timeout, NULL); - - context = gtk_widget_get_style_context (gtk_bin_get_child (GTK_BIN (priv->header))); - - 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 (priv->header), - GUINT_TO_POINTER (1), - GTK_STATE_FLAG_ACTIVE, - !collapsed); - - gtk_style_context_restore (context); } else gtk_tool_item_group_force_expose (group); @@ -1983,7 +1971,7 @@ gtk_tool_item_group_set_ellipsize (GtkToolItemGroup *group, * * Since: 2.20 */ -G_CONST_RETURN gchar* +const gchar* gtk_tool_item_group_get_label (GtkToolItemGroup *group) { GtkToolItemGroupPrivate *priv; @@ -2245,13 +2233,11 @@ gtk_tool_item_group_get_drop_item (GtkToolItemGroup *group, gint y) { GtkAllocation allocation; - GtkOrientation orientation; GList *it; g_return_val_if_fail (GTK_IS_TOOL_ITEM_GROUP (group), NULL); gtk_widget_get_allocation (GTK_WIDGET (group), &allocation); - orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)); g_return_val_if_fail (x >= 0 && x < allocation.width, NULL); g_return_val_if_fail (y >= 0 && y < allocation.height, NULL); @@ -2288,15 +2274,10 @@ _gtk_tool_item_group_item_size_request (GtkToolItemGroup *group, GList *it; gint rows = 0; gboolean new_row = TRUE; - GtkOrientation orientation; - GtkToolbarStyle style; g_return_if_fail (GTK_IS_TOOL_ITEM_GROUP (group)); g_return_if_fail (NULL != item_size); - orientation = gtk_tool_shell_get_orientation (GTK_TOOL_SHELL (group)); - style = gtk_tool_shell_get_style (GTK_TOOL_SHELL (group)); - item_size->width = item_size->height = 0; for (it = group->priv->children; it != NULL; it = it->next)