[gtk/wip/exalm/window-headerbar: 2/6] header-bar: Don't assume there's only one icon
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/window-headerbar: 2/6] header-bar: Don't assume there's only one icon
- Date: Wed, 22 Apr 2020 18:05:21 +0000 (UTC)
commit cead405831703444622fd7f27239763df62276f4
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Wed Apr 22 21:35:32 2020 +0500
header-bar: Don't assume there's only one icon
Instead of tracking the titlebar icon widget, and updating it when the icon
changes, update the window buttons completely.
gtk/gtkheaderbar.c | 25 ++++++++-----------------
gtk/gtkheaderbarprivate.h | 2 --
gtk/gtkwindow.c | 2 +-
3 files changed, 9 insertions(+), 20 deletions(-)
---
diff --git a/gtk/gtkheaderbar.c b/gtk/gtkheaderbar.c
index 2280e77468..f34eb68fac 100644
--- a/gtk/gtkheaderbar.c
+++ b/gtk/gtkheaderbar.c
@@ -126,8 +126,6 @@ struct _GtkHeaderBarPrivate
GtkWidget *titlebar_start_separator;
GtkWidget *titlebar_end_separator;
- GtkWidget *titlebar_icon;
-
GdkSurfaceState state;
};
@@ -221,25 +219,22 @@ create_title_box (const char *title,
return label_box;
}
-gboolean
-_gtk_header_bar_update_window_icon (GtkHeaderBar *bar,
- GtkWindow *window)
+static gboolean
+update_window_icon (GtkHeaderBar *bar,
+ GtkWindow *window,
+ GtkWidget *icon)
{
- GtkHeaderBarPrivate *priv = gtk_header_bar_get_instance_private (bar);
GdkPaintable *paintable;
gint scale;
- if (priv->titlebar_icon == NULL)
- return FALSE;
-
- scale = gtk_widget_get_scale_factor (priv->titlebar_icon);
+ scale = gtk_widget_get_scale_factor (icon);
paintable = gtk_window_get_icon_for_size (window, 20 * scale);
if (paintable)
{
- gtk_image_set_from_paintable (GTK_IMAGE (priv->titlebar_icon), paintable);
+ gtk_image_set_from_paintable (GTK_IMAGE (icon), paintable);
g_object_unref (paintable);
- gtk_widget_show (priv->titlebar_icon);
+ gtk_widget_show (icon);
return TRUE;
}
@@ -311,8 +306,6 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
priv->titlebar_end_separator = NULL;
}
- priv->titlebar_icon = NULL;
-
if (!priv->show_title_buttons)
return;
@@ -361,15 +354,13 @@ _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar)
{
button = gtk_image_new ();
gtk_widget_set_valign (button, GTK_ALIGN_CENTER);
- priv->titlebar_icon = button;
gtk_widget_add_css_class (button, "titlebutton");
gtk_widget_add_css_class (button, "icon");
- if (!_gtk_header_bar_update_window_icon (bar, window))
+ if (!update_window_icon (bar, window, button))
{
g_object_ref_sink (button);
g_object_unref (button);
- priv->titlebar_icon = NULL;
button = NULL;
}
}
diff --git a/gtk/gtkheaderbarprivate.h b/gtk/gtkheaderbarprivate.h
index 3fb3eb1e3b..11d8ed0748 100644
--- a/gtk/gtkheaderbarprivate.h
+++ b/gtk/gtkheaderbarprivate.h
@@ -26,8 +26,6 @@ G_BEGIN_DECLS
void _gtk_header_bar_track_default_decoration (GtkHeaderBar *bar);
void _gtk_header_bar_update_window_buttons (GtkHeaderBar *bar);
-gboolean _gtk_header_bar_update_window_icon (GtkHeaderBar *bar,
- GtkWindow *window);
G_END_DECLS
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 28da604c6a..6793b2a904 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -3432,7 +3432,7 @@ gtk_window_realize_icon (GtkWindow *window)
gdk_toplevel_set_icon_list (GDK_TOPLEVEL (priv->surface), icon_list);
if (GTK_IS_HEADER_BAR (priv->title_box))
- _gtk_header_bar_update_window_icon (GTK_HEADER_BAR (priv->title_box), window);
+ _gtk_header_bar_update_window_buttons (GTK_HEADER_BAR (priv->title_box));
if (info->using_themed_icon)
g_list_free_full (icon_list, g_object_unref);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]