[gnome-control-center/new-printers-panel] printers: Remove printer add/remove buttons
- From: Marek Kašík <mkasik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/new-printers-panel] printers: Remove printer add/remove buttons
- Date: Sun, 16 Jan 2011 21:41:20 +0000 (UTC)
commit ef0b1cb21ca878d0f60c7562bd90abaea3a63524
Author: Marek Kasik <mkasik redhat com>
Date: Sun Jan 16 22:23:19 2011 +0100
printers: Remove printer add/remove buttons
Add setting of default printer.
panels/printers/cc-printers-panel.c | 129 +++++++++++++++--------------------
panels/printers/printers.ui | 34 +++-------
2 files changed, 64 insertions(+), 99 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index c727bb3..69ef197 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -61,6 +61,7 @@ static void actualize_jobs_list (CcPrintersPanel *self);
static void actualize_printers_list (CcPrintersPanel *self);
static void actualize_allowed_users_list (CcPrintersPanel *self);
static void printer_disable_cb (GtkToggleButton *togglebutton, gpointer user_data);
+static void printer_set_default_cb (GtkToggleButton *button, gpointer user_data);
static void
cc_printers_panel_get_property (GObject *object,
@@ -328,6 +329,15 @@ printer_selection_changed_cb (GtkTreeSelection *selection,
widget = (GtkWidget*)
+ gtk_builder_get_object (priv->builder, "printer-default-check-button");
+
+ gtk_widget_set_sensitive (widget, TRUE);
+ g_signal_handlers_block_by_func (G_OBJECT (widget), printer_set_default_cb, self);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), priv->dests[id].is_default);
+ g_signal_handlers_unblock_by_func (G_OBJECT (widget), printer_set_default_cb, self);
+
+
+ widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "supply-drawing-area");
width = gtk_widget_get_allocated_width (widget);
@@ -406,8 +416,8 @@ actualize_printers_list (CcPrintersPanel *self)
current_printer_instance = g_strdup (priv->dests[priv->current_dest].instance);
}
- if (priv->num_jobs > 0)
- cupsFreeJobs (priv->num_jobs, priv->jobs);
+ if (priv->num_dests > 0)
+ cupsFreeDests (priv->num_dests, priv->dests);
priv->num_dests = cupsGetDests (&priv->dests);
priv->current_dest = -1;
@@ -1087,51 +1097,6 @@ printer_disable_cb (GtkToggleButton *togglebutton,
}
}
-static void
-printer_delete_cb (GtkToolButton *toolbutton,
- gpointer user_data)
-{
- CcPrintersPanelPrivate *priv;
- CcPrintersPanel *self = (CcPrintersPanel*) user_data;
- DBusGProxy *proxy;
- gboolean ret = FALSE;
- GError *error = NULL;
- char *ret_error = NULL;
- char *name = NULL;
-
- priv = PRINTERS_PANEL_PRIVATE (self);
-
- if (priv->current_dest >= 0 &&
- priv->current_dest < priv->num_dests &&
- priv->dests != NULL)
- name = priv->dests[priv->current_dest].name;
-
- if (name)
- {
- proxy = get_dbus_proxy ();
-
- if (!proxy)
- return;
-
- ret = dbus_g_proxy_call (proxy, "PrinterDelete", &error,
- G_TYPE_STRING, name,
- G_TYPE_INVALID,
- G_TYPE_STRING, &ret_error,
- G_TYPE_INVALID);
-
- if (error || (ret_error && ret_error[0] != '\0'))
- {
- if (error)
- g_warning ("%s", error->message);
-
- if (ret_error && ret_error[0] != '\0')
- g_warning ("%s", ret_error);
- }
- else
- actualize_printers_list (self);
- }
-}
-
static gboolean
supply_levels_draw_cb (GtkWidget *widget,
cairo_t *cr,
@@ -1324,29 +1289,53 @@ allowed_user_remove_cb (GtkButton *button,
}
static void
-set_widget_style (GtkWidget *widget, gchar *style_data)
+printer_set_default_cb (GtkToggleButton *button,
+ gpointer user_data)
{
- GtkStyleProvider *provider;
- GtkStyleContext *context;
+ CcPrintersPanelPrivate *priv;
+ CcPrintersPanel *self = (CcPrintersPanel*) user_data;
+ DBusGProxy *proxy;
+ gboolean ret = FALSE;
+ GError *error = NULL;
+ char *ret_error = NULL;
+ char *name = NULL;
- if (widget)
+ priv = PRINTERS_PANEL_PRIVATE (self);
+
+ if (priv->current_dest >= 0 &&
+ priv->current_dest < priv->num_dests &&
+ priv->dests != NULL)
+ name = priv->dests[priv->current_dest].name;
+
+ if (name)
{
- context = gtk_widget_get_style_context (widget);
- provider = g_object_get_data (G_OBJECT (widget), "provider");
+ proxy = get_dbus_proxy ();
+
+ if (!proxy)
+ return;
- if (provider == NULL)
+ ret = dbus_g_proxy_call (proxy, "PrinterSetDefault", &error,
+ G_TYPE_STRING, name,
+ G_TYPE_INVALID,
+ G_TYPE_STRING, &ret_error,
+ G_TYPE_INVALID);
+
+ if (error || (ret_error && ret_error[0] != '\0'))
{
- provider = (GtkStyleProvider *)gtk_css_provider_new ();
- g_object_set_data (G_OBJECT (widget), "provider", provider);
- gtk_style_context_add_provider (context,
- GTK_STYLE_PROVIDER (provider),
- GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
+ if (error)
+ g_warning ("%s", error->message);
+
+ if (ret_error && ret_error[0] != '\0')
+ g_warning ("%s", ret_error);
+
}
+ else
+ actualize_printers_list (self);
- gtk_css_provider_load_from_data ((GtkCssProvider *)provider,
- style_data, -1, NULL);
- gtk_style_context_invalidate (context);
- }
+ g_signal_handlers_block_by_func (G_OBJECT (button), printer_set_default_cb, self);
+ gtk_toggle_button_set_active (button, priv->dests[priv->current_dest].is_default);
+ g_signal_handlers_unblock_by_func (G_OBJECT (button), printer_set_default_cb, self);
+ }
}
static void
@@ -1407,10 +1396,6 @@ cc_printers_panel_init (CcPrintersPanel *self)
g_signal_connect (widget, "toggled", G_CALLBACK (printer_disable_cb), self);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "printer-delete-button");
- g_signal_connect (widget, "clicked", G_CALLBACK (printer_delete_cb), self);
-
- widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "allowed-user-remove-button");
g_signal_connect (widget, "clicked", G_CALLBACK (allowed_user_remove_cb), self);
@@ -1418,11 +1403,9 @@ cc_printers_panel_init (CcPrintersPanel *self)
gtk_builder_get_object (priv->builder, "supply-drawing-area");
g_signal_connect (widget, "draw", G_CALLBACK (supply_levels_draw_cb), self);
-
- /* set plain style for borders of toolbars */
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "printers-toolbar");
- set_widget_style (widget, "GtkToolbar { border-style: none }");
+ gtk_builder_get_object (priv->builder, "printer-default-check-button");
+ g_signal_connect (widget, "toggled", G_CALLBACK (printer_set_default_cb), self);
/* make unused widgets insensitive for now */
@@ -1431,10 +1414,6 @@ cc_printers_panel_init (CcPrintersPanel *self)
gtk_widget_set_sensitive (widget, FALSE);
widget = (GtkWidget*)
- gtk_builder_get_object (priv->builder, "printer-add-button");
- gtk_widget_set_sensitive (widget, FALSE);
-
- widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "print-test-page-button");
gtk_widget_set_sensitive (widget, FALSE);
diff --git a/panels/printers/printers.ui b/panels/printers/printers.ui
index 0bb4f97..687ae9d 100644
--- a/panels/printers/printers.ui
+++ b/panels/printers/printers.ui
@@ -36,38 +36,24 @@
</packing>
</child>
<child>
- <object class="GtkToolbar" id="printers-toolbar">
+ <object class="GtkCheckButton" id="printer-default-check-button">
<property name="visible">True</property>
- <property name="toolbar_style">icons</property>
- <child>
- <object class="GtkToolButton" id="printer-add-button">
- <property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Add new printer</property>
- <property name="label" translatable="yes">AddPrinter</property>
- <property name="use_underline">True</property>
- <property name="icon_name">list-add</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
<child>
- <object class="GtkToolButton" id="printer-delete-button">
+ <object class="GtkLabel" id="label8">
<property name="visible">True</property>
- <property name="tooltip_text" translatable="yes">Remove selected printer</property>
- <property name="label" translatable="yes">RemovePrinter</property>
- <property name="use_underline">True</property>
- <property name="icon_name">list-remove</property>
+ <property name="label" translatable="yes">Default</property>
+ <attributes>
+ <attribute name="style" value="italic"/>
+ </attributes>
</object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+ <property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]