[gnome-control-center] printers: Ellipsize the "Details Dialog" title



commit 4cfb21176156849d066f36ba47502857dc043f2d
Author: Felipe Borges <felipeborges gnome org>
Date:   Wed Feb 22 16:36:54 2017 +0100

    printers: Ellipsize the "Details Dialog" title
    
    Printers with long names were causing the "Printer Details Dialog"
    to expande horizontally.
    
    This patch ellipsizes the custom title of the dialog.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=779071

 panels/printers/details-dialog.ui   |   14 ++++++++++++++
 panels/printers/pp-details-dialog.c |    9 ++++-----
 2 files changed, 18 insertions(+), 5 deletions(-)
---
diff --git a/panels/printers/details-dialog.ui b/panels/printers/details-dialog.ui
index 58f2517..4524d14 100644
--- a/panels/printers/details-dialog.ui
+++ b/panels/printers/details-dialog.ui
@@ -11,6 +11,20 @@
     <property name="type_hint">dialog</property>
     <property name="use-header-bar">1</property>
     <signal name="response" handler="pp_details_dialog_response_cb"/>
+    <child internal-child="headerbar">
+      <object class="GtkHeaderBar">
+        <property name="visible">True</property>
+        <property name="show_close_button">True</property>
+        <child type="title">
+          <object class="GtkLabel" id="dialog_title">
+            <property name="visible">True</property>
+            <property name="wrap">True</property>
+            <property name="max_width_chars">30</property>
+            <property name="ellipsize">middle</property>
+          </object>
+        </child>
+      </object>
+    </child>
     <child internal-child="vbox">
       <object class="GtkBox">
         <property name="margin">20</property>
diff --git a/panels/printers/pp-details-dialog.c b/panels/printers/pp-details-dialog.c
index 35b65dc..17462bc 100644
--- a/panels/printers/pp-details-dialog.c
+++ b/panels/printers/pp-details-dialog.c
@@ -42,6 +42,7 @@
 struct _PpDetailsDialog {
   GtkDialog parent;
 
+  GtkLabel *dialog_title;
   GtkEntry *printer_name_entry;
   GtkEntry *printer_location_entry;
   GtkLabel *printer_address_label;
@@ -113,7 +114,6 @@ printer_name_changed (GtkEditable *editable,
                       gpointer     user_data)
 {
   PpDetailsDialog *self = (PpDetailsDialog *) user_data;
-  GtkWidget *widget;
   const gchar *name;
   gchar *title;
 
@@ -121,9 +121,7 @@ printer_name_changed (GtkEditable *editable,
 
   /* Translators: This is the title of the dialog. %s is the printer name. */
   title = g_strdup_printf (_("%s Details"), name);
-
-  widget = gtk_dialog_get_header_bar (GTK_DIALOG (self));
-  gtk_header_bar_set_title (GTK_HEADER_BAR (widget), title);
+  gtk_label_set_label (self->dialog_title, title);
 
   g_free (title);
 }
@@ -376,6 +374,7 @@ pp_details_dialog_class_init (PpDetailsDialogClass *klass)
 
   gtk_widget_class_set_template_from_resource (widget_class, 
"/org/gnome/control-center/printers/details-dialog.ui");
 
+  gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, dialog_title);
   gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, printer_name_entry);
   gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, printer_location_entry);
   gtk_widget_class_bind_template_child (widget_class, PpDetailsDialog, printer_address_label);
@@ -414,7 +413,7 @@ pp_details_dialog_new (GtkWindow            *parent,
 
   /* Translators: This is the title of the dialog. %s is the printer name. */
   title = g_strdup_printf (_("%s Details"), printer_name);
-  gtk_window_set_title (GTK_WINDOW (self), title);
+  gtk_label_set_label (self->dialog_title, title);
 
   printer_url = g_strdup_printf ("<a href=\"http://%s:%d\";>%s</a>", printer_address, ippPort (), 
printer_address);
   gtk_label_set_markup (GTK_LABEL (self->printer_address_label), printer_url);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]