[gnome-control-center] printers: Move "Add Printer" button to header bar
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] printers: Move "Add Printer" button to header bar
- Date: Tue, 20 Sep 2016 13:32:35 +0000 (UTC)
commit cf99cebfb90b8e8efb38718eb4c8f1a3b07e1873
Author: Felipe Borges <felipeborges gnome org>
Date: Thu Sep 8 12:28:04 2016 +0200
printers: Move "Add Printer" button to header bar
This patch introduces a change to the Lock/Unlock logic. From now
on, unlocking the panel causes the "Lock" button to turn into the
"Add Printer" button.
https://bugzilla.gnome.org/show_bug.cgi?id=767600
panels/printers/cc-printers-panel.c | 41 ++++++++++++++++++++++++++--------
panels/printers/printers.ui | 38 +++++++++++++++++++++-----------
2 files changed, 56 insertions(+), 23 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index fb55608..cb832f6 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -99,6 +99,7 @@ struct _CcPrintersPanelPrivate
guint cups_status_check_id;
guint dbus_subscription_id;
+ GtkWidget *headerbar_buttons;
GtkWidget *popup_menu;
GList *driver_change_list;
GCancellable *get_ppd_name_cancellable;
@@ -119,6 +120,9 @@ struct _CcPrintersPanelPrivate
gpointer dummy;
};
+#define PAGE_LOCK "_lock"
+#define PAGE_ADDPRINTER "_addprinter"
+
typedef struct
{
gchar *printer_name;
@@ -160,6 +164,24 @@ cc_printers_panel_set_property (GObject *object,
}
static void
+cc_printers_panel_constructed (GObject *object)
+{
+ CcPrintersPanel *self = CC_PRINTERS_PANEL (object);
+ CcPrintersPanelPrivate *priv = self->priv;
+ GtkLockButton *button;
+ CcShell *shell;
+
+ G_OBJECT_CLASS (cc_printers_panel_parent_class)->constructed (object);
+
+ shell = cc_panel_get_shell (CC_PANEL (self));
+ cc_shell_embed_widget_in_header (shell, priv->headerbar_buttons);
+
+ button = (GtkLockButton*)
+ gtk_builder_get_object (priv->builder, "lock-button");
+ gtk_lock_button_set_permission (button, priv->permission);
+}
+
+static void
cc_printers_panel_dispose (GObject *object)
{
CcPrintersPanelPrivate *priv = CC_PRINTERS_PANEL (object)->priv;
@@ -250,14 +272,6 @@ cc_printers_panel_finalize (GObject *object)
G_OBJECT_CLASS (cc_printers_panel_parent_class)->finalize (object);
}
-static GPermission *
-cc_printers_panel_get_permission (CcPanel *panel)
-{
- CcPrintersPanelPrivate *priv = CC_PRINTERS_PANEL (panel)->priv;
-
- return priv->permission;
-}
-
static const char *
cc_printers_panel_get_help_uri (CcPanel *panel)
{
@@ -274,10 +288,10 @@ cc_printers_panel_class_init (CcPrintersPanelClass *klass)
object_class->get_property = cc_printers_panel_get_property;
object_class->set_property = cc_printers_panel_set_property;
+ object_class->constructed = cc_printers_panel_constructed;
object_class->dispose = cc_printers_panel_dispose;
object_class->finalize = cc_printers_panel_finalize;
- panel_class->get_permission = cc_printers_panel_get_permission;
panel_class->get_help_uri = cc_printers_panel_get_help_uri;
}
@@ -2698,6 +2712,9 @@ update_sensitivity (gpointer user_data)
priv->lockdown_settings &&
!g_settings_get_boolean (priv->lockdown_settings, "disable-print-setup");
+ gtk_stack_set_visible_child_name (GTK_STACK (priv->headerbar_buttons),
+ is_authorized ? PAGE_ADDPRINTER : PAGE_LOCK);
+
printer_selected = priv->current_dest >= 0 &&
priv->current_dest < priv->num_dests &&
priv->dests != NULL;
@@ -3061,7 +3078,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
GtkWidget *widget;
PpCups *cups;
GError *error = NULL;
- gchar *objects[] = { "main-vbox", NULL };
+ gchar *objects[] = { "main-vbox", "headerbar-buttons", NULL };
GtkStyleContext *context;
guint builder_result;
@@ -3118,6 +3135,10 @@ cc_printers_panel_init (CcPrintersPanel *self)
return;
}
+ widget = (GtkWidget*)
+ gtk_builder_get_object (priv->builder, "headerbar-buttons");
+ priv->headerbar_buttons = widget;
+
/* add the top level widget */
top_widget = (GtkWidget*)
gtk_builder_get_object (priv->builder, "main-vbox");
diff --git a/panels/printers/printers.ui b/panels/printers/printers.ui
index 95ab120..5991544 100644
--- a/panels/printers/printers.ui
+++ b/panels/printers/printers.ui
@@ -2,6 +2,31 @@
<interface>
<requires lib="gtk+" version="3.12"/>
<!-- interface-naming-policy project-wide -->
+ <object class="GtkStack" id="headerbar-buttons">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkLockButton" id="lock-button">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">_lock</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="printer-add-button">
+ <property name="visible">True</property>
+ <property name="sensitive">True</property>
+ <property name="use_underline">True</property>
+ <property name="label" translatable="yes">Add Printer</property>
+ <style>
+ <class name="suggested-action"/>
+ </style>
+ </object>
+ <packing>
+ <property name="name">_addprinter</property>
+ </packing>
+ </child>
+ </object>
<object class="GtkStack" id="main-vbox">
<property name="margin-start">6</property>
<property name="margin-end">6</property>
@@ -62,19 +87,6 @@
<class name="inline-toolbar"/>
</style>
<child>
- <object class="GtkToolButton" id="printer-add-button">
- <property name="visible">True</property>
- <property name="sensitive">True</property>
- <property name="use_underline">True</property>
- <property name="icon_name">list-add-symbolic</property>
- <property name="label" translatable="yes">Add Printer</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="homogeneous">True</property>
- </packing>
- </child>
- <child>
<object class="GtkToolButton" id="printer-remove-button">
<property name="visible">True</property>
<property name="use_underline">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]