[gnome-control-center] printers: Vertically center text for no devices
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Vertically center text for no devices
- Date: Wed, 12 Feb 2014 15:13:22 +0000 (UTC)
commit 6d5d28e7d4628cfaf8aa5f85ed601ec099296a95
Author: Marek Kasik <mkasik redhat com>
Date: Wed Feb 12 15:15:46 2014 +0100
printers: Vertically center text for no devices
Move the text "No printers detected." to its own GtkLabel
which is vertically and horizontally centerd and show it
instead of GtkTreeView when no devices were found.
https://bugzilla.gnome.org/show_bug.cgi?id=706897
panels/printers/new-printer-dialog.ui | 34 +++++++++++++++++++++---
panels/printers/pp-new-printer-dialog.c | 43 +++++--------------------------
2 files changed, 36 insertions(+), 41 deletions(-)
---
diff --git a/panels/printers/new-printer-dialog.ui b/panels/printers/new-printer-dialog.ui
index e0e05bb..d036168 100644
--- a/panels/printers/new-printer-dialog.ui
+++ b/panels/printers/new-printer-dialog.ui
@@ -125,13 +125,37 @@
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
- <object class="GtkTreeView" id="devices-treeview">
+ <object class="GtkStack" id="stack">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="model">devices-liststore</property>
- <property name="headers_visible">False</property>
- <child internal-child="selection">
- <object class="GtkTreeSelection" id="treeview-selection"/>
+ <property name="transition-type">none</property>
+ <child>
+ <object class="GtkTreeView" id="devices-treeview">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="model">devices-liststore</property>
+ <property name="headers_visible">False</property>
+ <child internal-child="selection">
+ <object class="GtkTreeSelection" id="treeview-selection"/>
+ </child>
+ </object>
+ <packing>
+ <property name="name">standard-page</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="no-devices-label">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="sensitive">False</property>
+ <property name="label" translatable="yes" comments="Translators: No printers
were found">No printers detected.</property>
+ <attributes>
+ <attribute name="weight" value="bold"/>
+ </attributes>
+ </object>
+ <packing>
+ <property name="name">no-printers-page</property>
+ </packing>
</child>
</object>
</child>
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index 36c043d..555d24d 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -1610,14 +1610,13 @@ static void
actualize_devices_list (PpNewPrinterDialog *dialog)
{
PpNewPrinterDialogPrivate *priv = dialog->priv;
- GtkTreeViewColumn *column;
GtkTreeSelection *selection;
GtkListStore *store;
GtkTreeView *treeview;
GtkTreeIter iter;
+ GtkWidget *widget;
gboolean no_device = TRUE;
TDevice *device;
- gfloat yalign;
GList *item;
gchar *display_string;
@@ -1681,9 +1680,8 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
}
}
- column = gtk_tree_view_get_column (treeview, 0);
- if (priv->text_renderer)
- gtk_cell_renderer_get_alignment (priv->text_renderer, NULL, &yalign);
+ widget = (GtkWidget *)
+ gtk_builder_get_object (priv->builder, "stack");
if (no_device &&
!priv->cups_searching &&
@@ -1692,38 +1690,9 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
!priv->samba_host_searching &&
!priv->samba_authenticated_searching &&
!priv->samba_searching)
- {
- if (priv->text_renderer)
- gtk_cell_renderer_set_alignment (priv->text_renderer, 0.5, yalign);
-
- if (column)
- gtk_tree_view_column_set_max_width (column, 0);
-
- gtk_widget_set_sensitive (GTK_WIDGET (treeview), FALSE);
-
- display_string = g_markup_printf_escaped ("<b>%s</b>\n",
- /* Translators: No printers were found */
- _("No printers detected."));
-
- gtk_list_store_append (store, &iter);
- gtk_list_store_set (store, &iter,
- DEVICE_DISPLAY_NAME_COLUMN, display_string,
- -1);
-
- g_free (display_string);
- }
+ gtk_stack_set_visible_child_name (GTK_STACK (widget), "no-printers-page");
else
- {
- if (priv->text_renderer)
- gtk_cell_renderer_set_alignment (priv->text_renderer, 0.0, yalign);
-
- if (column)
- {
- gtk_tree_view_column_set_max_width (column, -1);
- gtk_tree_view_column_set_min_width (column, 80);
- }
- gtk_widget_set_sensitive (GTK_WIDGET (treeview), TRUE);
- }
+ gtk_stack_set_visible_child_name (GTK_STACK (widget), "standard-page");
if (!no_device &&
gtk_tree_model_get_iter_first ((GtkTreeModel *) store, &iter) &&
@@ -1809,6 +1778,8 @@ populate_devices_list (PpNewPrinterDialog *dialog)
gtk_cell_renderer_set_padding (priv->icon_renderer, 4, 4);
column = gtk_tree_view_column_new_with_attributes ("Icon", priv->icon_renderer,
"gicon", DEVICE_GICON_COLUMN, NULL);
+ gtk_tree_view_column_set_max_width (column, -1);
+ gtk_tree_view_column_set_min_width (column, 80);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]