printers: Show printer's description instead of its name

This commit is contained in:
Marek Kasik 2011-01-07 13:33:53 +01:00
parent 22f0ad394e
commit 23faa29ffd
2 changed files with 23 additions and 15 deletions

View file

@ -132,9 +132,9 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
const gchar *none = "---"; const gchar *none = "---";
GtkWidget *widget; GtkWidget *widget;
gboolean paused = FALSE; gboolean paused = FALSE;
gchar *instance = NULL; gchar *description = NULL;
gchar *location = NULL;
gchar *device_uri = NULL; gchar *device_uri = NULL;
gchar *location = NULL;
int id, i; int id, i;
priv = PRINTERS_PANEL_PRIVATE (self); priv = PRINTERS_PANEL_PRIVATE (self);
@ -155,16 +155,6 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
priv->current_dest < priv->num_dests && priv->current_dest < priv->num_dests &&
priv->dests != NULL) priv->dests != NULL)
{ {
if (priv->dests[id].instance)
instance = g_strdup_printf ("%s / %s", priv->dests[id].name, priv->dests[id].instance);
else
instance = g_strdup (priv->dests[id].name);
widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "printer-name-label");
gtk_label_set_text (GTK_LABEL (widget), instance);
g_free (instance);
for (i = 0; i < priv->dests[id].num_options; i++) for (i = 0; i < priv->dests[id].num_options; i++)
{ {
if (g_strcmp0 (priv->dests[id].options[i].name, "printer-location") == 0) if (g_strcmp0 (priv->dests[id].options[i].name, "printer-location") == 0)
@ -173,6 +163,8 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
device_uri = g_strdup (priv->dests[id].options[i].value); device_uri = g_strdup (priv->dests[id].options[i].value);
else if (g_strcmp0 (priv->dests[id].options[i].name, "printer-state") == 0) else if (g_strcmp0 (priv->dests[id].options[i].name, "printer-state") == 0)
paused = (g_strcmp0 (priv->dests[id].options[i].value, "5") == 0); paused = (g_strcmp0 (priv->dests[id].options[i].value, "5") == 0);
else if (g_strcmp0 (priv->dests[id].options[i].name, "printer-info") == 0)
description = g_strdup (priv->dests[id].options[i].value);
} }
widget = (GtkWidget*) widget = (GtkWidget*)
@ -186,8 +178,10 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
else else
gtk_label_set_text (GTK_LABEL (widget), none); gtk_label_set_text (GTK_LABEL (widget), none);
widget = (GtkWidget*) widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "printer-URI-entry"); gtk_builder_get_object (priv->builder, "printer-URI-entry");
if (device_uri) if (device_uri)
{ {
gtk_entry_set_text (GTK_ENTRY (widget), device_uri); gtk_entry_set_text (GTK_ENTRY (widget), device_uri);
@ -196,8 +190,22 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
else else
gtk_entry_set_text (GTK_ENTRY (widget), none); gtk_entry_set_text (GTK_ENTRY (widget), none);
widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "printer-description-label");
if (description)
{
gtk_label_set_text (GTK_LABEL (widget), description);
g_free (description);
}
else
gtk_label_set_text (GTK_LABEL (widget), none);
widget = (GtkWidget*) widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "printer-disable-button"); gtk_builder_get_object (priv->builder, "printer-disable-button");
gtk_widget_set_sensitive (widget, TRUE); gtk_widget_set_sensitive (widget, TRUE);
g_signal_handlers_block_by_func(G_OBJECT (widget), printer_disable_cb, self); g_signal_handlers_block_by_func(G_OBJECT (widget), printer_disable_cb, self);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), paused); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), paused);
@ -206,7 +214,7 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
else else
{ {
widget = (GtkWidget*) widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "printer-name-label"); gtk_builder_get_object (priv->builder, "printer-description-label");
gtk_label_set_text (GTK_LABEL (widget), ""); gtk_label_set_text (GTK_LABEL (widget), "");
widget = (GtkWidget*) widget = (GtkWidget*)

View file

@ -194,7 +194,7 @@
<object class="GtkLabel" id="label11"> <object class="GtkLabel" id="label11">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">1</property> <property name="xalign">1</property>
<property name="label" translatable="yes">Printer:</property> <property name="label" translatable="yes">Description:</property>
</object> </object>
<packing> <packing>
<property name="x_options">GTK_FILL</property> <property name="x_options">GTK_FILL</property>
@ -242,7 +242,7 @@
</packing> </packing>
</child> </child>
<child> <child>
<object class="GtkLabel" id="printer-name-label"> <object class="GtkLabel" id="printer-description-label">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">---</property> <property name="label" translatable="yes">---</property>