[gnome-control-center] printers: Don't set color for selected text
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Don't set color for selected text
- Date: Fri, 28 Feb 2014 10:08:13 +0000 (UTC)
commit 352f01bb1101bc28edd1a0c1fd4418a6eec7e9f5
Author: Marek Kasik <mkasik redhat com>
Date: Wed Feb 26 11:20:02 2014 +0100
printers: Don't set color for selected text
Show description of selected device in default color
in new printer dialog.
https://bugzilla.gnome.org/show_bug.cgi?id=693183
panels/printers/new-printer-dialog.ui | 2 +
panels/printers/pp-new-printer-dialog.c | 88 ++++++++++++++++++++++++------
2 files changed, 72 insertions(+), 18 deletions(-)
---
diff --git a/panels/printers/new-printer-dialog.ui b/panels/printers/new-printer-dialog.ui
index e566a5c..1f9a115 100644
--- a/panels/printers/new-printer-dialog.ui
+++ b/panels/printers/new-printer-dialog.ui
@@ -9,6 +9,8 @@
<column type="gchararray"/>
<!-- column-name device_display_name -->
<column type="gchararray"/>
+ <!-- column-name device_description -->
+ <column type="gchararray"/>
<!-- column-name server_needs_authentication -->
<column type="gboolean"/>
</columns>
diff --git a/panels/printers/pp-new-printer-dialog.c b/panels/printers/pp-new-printer-dialog.c
index d61511b..7b00afb 100644
--- a/panels/printers/pp-new-printer-dialog.c
+++ b/panels/printers/pp-new-printer-dialog.c
@@ -75,6 +75,7 @@ enum
DEVICE_GICON_COLUMN = 0,
DEVICE_NAME_COLUMN,
DEVICE_DISPLAY_NAME_COLUMN,
+ DEVICE_DESCRIPTION_COLUMN,
SERVER_NEEDS_AUTHENTICATION_COLUMN,
DEVICE_N_COLUMNS
};
@@ -1705,7 +1706,7 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
gboolean no_device = TRUE;
TDevice *device;
GList *item;
- gchar *display_string;
+ gchar *description;
treeview = (GtkTreeView *)
gtk_builder_get_object (priv->builder, "devices-treeview");
@@ -1728,42 +1729,34 @@ actualize_devices_list (PpNewPrinterDialog *dialog)
device->acquisition_method == ACQUISITION_METHOD_SAMBA) &&
device->show)
{
+ description = NULL;
if (device->device_location)
- display_string = g_markup_printf_escaped ("<b>%s</b>\n<small><span
foreground=\"#555555\">%s</span></small>",
- device->display_name,
- device->device_location);
- else
- display_string = g_markup_printf_escaped ("<b>%s</b>\n ",
- device->display_name);
+ description = g_strdup (device->device_location);
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
DEVICE_GICON_COLUMN, device->network_device ? priv->remote_printer_icon :
priv->local_printer_icon,
DEVICE_NAME_COLUMN, device->device_name,
- DEVICE_DISPLAY_NAME_COLUMN, display_string,
+ DEVICE_DISPLAY_NAME_COLUMN, device->display_name,
+ DEVICE_DESCRIPTION_COLUMN, description,
-1);
no_device = FALSE;
- g_free (display_string);
+ g_free (description);
}
else if (device->is_authenticated_server &&
device->host_name != NULL)
{
- display_string = g_markup_printf_escaped ("<b>%s</b>\n<small><span
foreground=\"#555555\">%s</span></small>",
- device->host_name,
- /* Translators: This item is a server which needs
authentication to show its printers */
- _("Server requires authentication"));
-
gtk_list_store_append (store, &iter);
gtk_list_store_set (store, &iter,
DEVICE_GICON_COLUMN, priv->authenticated_server_icon,
DEVICE_NAME_COLUMN, device->host_name,
- DEVICE_DISPLAY_NAME_COLUMN, display_string,
+ DEVICE_DISPLAY_NAME_COLUMN, device->host_name,
+ /* Translators: This item is a server which needs authentication to show its
printers */
+ DEVICE_DESCRIPTION_COLUMN, _("Server requires authentication"),
SERVER_NEEDS_AUTHENTICATION_COLUMN, TRUE,
-1);
no_device = FALSE;
-
- g_free (display_string);
}
}
@@ -1830,6 +1823,63 @@ cups_get_dests_cb (GObject *source_object,
}
static void
+cell_data_func (GtkTreeViewColumn *tree_column,
+ GtkCellRenderer *cell,
+ GtkTreeModel *tree_model,
+ GtkTreeIter *iter,
+ gpointer user_data)
+{
+ PpNewPrinterDialog *dialog = (PpNewPrinterDialog *) user_data;
+ PpNewPrinterDialogPrivate *priv = dialog->priv;
+ GtkWidget *treeview;
+ gboolean selected = FALSE;
+ gchar *name = NULL;
+ gchar *description = NULL;
+ gchar *text;
+
+ treeview = (GtkWidget*)
+ gtk_builder_get_object (priv->builder, "devices-treeview");
+
+ if (treeview != NULL)
+ selected = gtk_tree_selection_iter_is_selected (gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview)),
+ iter);
+
+ gtk_tree_model_get (tree_model, iter,
+ DEVICE_DISPLAY_NAME_COLUMN, &name,
+ DEVICE_DESCRIPTION_COLUMN, &description,
+ -1);
+
+ if (name != NULL)
+ {
+ if (description != NULL)
+ {
+ if (selected)
+ text = g_markup_printf_escaped ("<b>%s</b>\n<small>%s</small>",
+ name,
+ description);
+ else
+ text = g_markup_printf_escaped ("<b>%s</b>\n<small><span
foreground=\"#555555\">%s</span></small>",
+ name,
+ description);
+ }
+ else
+ {
+ text = g_markup_printf_escaped ("<b>%s</b>\n ",
+ name);
+ }
+
+ g_object_set (G_OBJECT (cell),
+ "markup", text,
+ NULL);
+
+ g_free (text);
+ }
+
+ g_free (name);
+ g_free (description);
+}
+
+static void
populate_devices_list (PpNewPrinterDialog *dialog)
{
PpNewPrinterDialogPrivate *priv = dialog->priv;
@@ -1872,7 +1922,9 @@ populate_devices_list (PpNewPrinterDialog *dialog)
priv->text_renderer = gtk_cell_renderer_text_new ();
column = gtk_tree_view_column_new_with_attributes ("Devices", priv->text_renderer,
- "markup", DEVICE_DISPLAY_NAME_COLUMN, NULL);
+ NULL);
+ gtk_tree_view_column_set_cell_data_func (column, priv->text_renderer, cell_data_func,
+ dialog, NULL);
gtk_tree_view_append_column (GTK_TREE_VIEW (treeview), column);
cups = pp_cups_new ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]