[gtk/wip/exalm/headerbar-title: 3/6] filechooserdialog: Create title and subtitle manually
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/exalm/headerbar-title: 3/6] filechooserdialog: Create title and subtitle manually
- Date: Fri, 1 May 2020 10:38:57 +0000 (UTC)
commit c9cb354002ef8c0168b5851bacd31ab9b9c034cf
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Fri May 1 01:08:57 2020 +0500
filechooserdialog: Create title and subtitle manually
title and subtitle properties will go away in the following commits, stop
using them.
gtk/gtkfilechooserdialog.c | 49 ++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 47 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkfilechooserdialog.c b/gtk/gtkfilechooserdialog.c
index 6ef46da699..def115d2a2 100644
--- a/gtk/gtkfilechooserdialog.c
+++ b/gtk/gtkfilechooserdialog.c
@@ -37,6 +37,7 @@
#include "gtkdialogprivate.h"
#include "gtklabel.h"
#include "gtkfilechooserentry.h"
+#include "gtkbox.h"
#include <stdarg.h>
@@ -430,6 +431,20 @@ add_button (GtkWidget *button, gpointer data)
gtk_size_group_add_widget (priv->buttons, button);
}
+static void
+subtitle_changed_cb (GtkWidget *widget,
+ GParamSpec *pspec,
+ GtkWidget *label)
+{
+ const gchar *subtitle;
+
+ g_object_get (widget, "subtitle", &subtitle, NULL);
+ g_object_set (label,
+ "label", subtitle,
+ "visible", subtitle != NULL,
+ NULL);
+}
+
static void
setup_search (GtkFileChooserDialog *dialog)
{
@@ -446,6 +461,8 @@ setup_search (GtkFileChooserDialog *dialog)
{
GtkWidget *button;
GtkWidget *header;
+ GtkWidget *box;
+ GtkWidget *label;
button = gtk_toggle_button_new ();
gtk_widget_set_focus_on_click (button, FALSE);
@@ -459,10 +476,38 @@ setup_search (GtkFileChooserDialog *dialog)
g_object_bind_property (button, "active",
priv->widget, "search-mode",
G_BINDING_BIDIRECTIONAL);
- g_object_bind_property (priv->widget, "subtitle",
- header, "subtitle",
+
+ box = g_object_new (GTK_TYPE_BOX,
+ "orientation", GTK_ORIENTATION_VERTICAL,
+ "valign", GTK_ALIGN_CENTER,
+ NULL);
+
+ label = g_object_new (GTK_TYPE_LABEL,
+ "halign", GTK_ALIGN_CENTER,
+ "single-line-mode", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ "width-chars", 5,
+ NULL);
+ gtk_widget_add_css_class (label, GTK_STYLE_CLASS_TITLE);
+ gtk_widget_set_parent (label, box);
+
+ g_object_bind_property (dialog, "title",
+ label, "label",
G_BINDING_SYNC_CREATE);
+ label = g_object_new (GTK_TYPE_LABEL,
+ "halign", GTK_ALIGN_CENTER,
+ "single-line-mode", TRUE,
+ "ellipsize", PANGO_ELLIPSIZE_END,
+ NULL);
+ gtk_widget_add_css_class (label, GTK_STYLE_CLASS_SUBTITLE);
+ gtk_widget_set_parent (label, box);
+
+ g_signal_connect (priv->widget, "notify::subtitle",
+ G_CALLBACK (subtitle_changed_cb), label);
+
+ gtk_header_bar_set_custom_title (GTK_HEADER_BAR (header), box);
+
gtk_container_forall (GTK_CONTAINER (header), add_button, dialog);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]