[gnome-control-center/printers-use-CcPermissionInfobar] printers: Use CcPermissionInfobar
- From: Felipe Borges <felipeborges src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/printers-use-CcPermissionInfobar] printers: Use CcPermissionInfobar
- Date: Mon, 13 Jan 2020 10:44:59 +0000 (UTC)
commit 6a8a3ee12555eae2dbb2dbc2e0be92399e3c37d9
Author: Felipe Borges <felipeborges gnome org>
Date: Mon Jan 13 11:41:33 2020 +0100
printers: Use CcPermissionInfobar
This makes the Printers panel consistent with the mockups at
https://gitlab.gnome.org/Teams/Design/settings-mockups/blob/master/users/users.png
See #685, #771 and !671
panels/printers/cc-printers-panel.c | 32 +++++++++++++-------------------
panels/printers/printers.ui | 36 ++++++++++++------------------------
2 files changed, 25 insertions(+), 43 deletions(-)
---
diff --git a/panels/printers/cc-printers-panel.c b/panels/printers/cc-printers-panel.c
index 9fc0c7980..1819e4aae 100644
--- a/panels/printers/cc-printers-panel.c
+++ b/panels/printers/cc-printers-panel.c
@@ -42,6 +42,7 @@
#include "pp-printer-entry.h"
#include "pp-job.h"
+#include "cc-permission-infobar.h"
#include "cc-util.h"
#define RENEW_INTERVAL 500
@@ -76,6 +77,7 @@ struct _CcPrintersPanel
gboolean is_authorized;
GSettings *lockdown_settings;
+ CcPermissionInfobar *permission_infobar;
PpNewPrinterDialog *pp_new_printer_dialog;
PpPPDSelectionDialog *pp_ppd_selection_dialog;
@@ -88,7 +90,6 @@ struct _CcPrintersPanel
guint dbus_subscription_id;
guint remove_printer_timeout_id;
- GtkWidget *headerbar_buttons;
GtkRevealer *notification;
PPDList *all_ppds_list;
GCancellable *get_all_ppds_cancellable;
@@ -116,9 +117,6 @@ struct _CcPrintersPanel
CC_PANEL_REGISTER (CcPrintersPanel, cc_printers_panel)
-#define PAGE_LOCK "_lock"
-#define PAGE_ADDPRINTER "_addprinter"
-
typedef struct
{
gchar *printer_name;
@@ -241,11 +239,10 @@ cc_printers_panel_constructed (GObject *object)
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, self->headerbar_buttons, GTK_POS_RIGHT);
widget = (GtkWidget*)
- gtk_builder_get_object (self->builder, "lock-button");
- gtk_lock_button_set_permission (GTK_LOCK_BUTTON (widget), self->permission);
+ gtk_builder_get_object (self->builder, "printer-add-button");
+ cc_shell_embed_widget_in_header (shell, widget, GTK_POS_RIGHT);
widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "search-button");
@@ -1000,9 +997,6 @@ update_sensitivity (gpointer user_data)
self->lockdown_settings &&
!g_settings_get_boolean (self->lockdown_settings, "disable-print-setup");
- gtk_stack_set_visible_child_name (GTK_STACK (self->headerbar_buttons),
- self->is_authorized ? PAGE_ADDPRINTER : PAGE_LOCK);
-
widget = (GtkWidget*) gtk_builder_get_object (self->builder, "main-vbox");
if (g_strcmp0 (gtk_stack_get_visible_child_name (GTK_STACK (widget)), "no-cups-page") == 0)
no_cups = TRUE;
@@ -1015,9 +1009,6 @@ update_sensitivity (gpointer user_data)
cups_server[0] != '/')
local_server = FALSE;
- widget = (GtkWidget*) gtk_builder_get_object (self->builder, "headerbar-buttons");
- gtk_widget_set_visible (widget, !no_cups);
-
widget = (GtkWidget*) gtk_builder_get_object (self->builder, "search-button");
gtk_widget_set_visible (widget, !no_cups);
@@ -1025,7 +1016,7 @@ update_sensitivity (gpointer user_data)
gtk_widget_set_visible (widget, !no_cups);
widget = (GtkWidget*) gtk_builder_get_object (self->builder, "printer-add-button");
- gtk_widget_set_sensitive (widget, local_server && self->is_authorized && !no_cups &&
!self->new_printer_name);
+ gtk_widget_set_visible (widget, local_server && self->is_authorized && !no_cups &&
!self->new_printer_name);
widget = (GtkWidget*) gtk_builder_get_object (self->builder, "printer-add-button2");
gtk_widget_set_sensitive (widget, local_server && self->is_authorized && !no_cups &&
!self->new_printer_name);
@@ -1188,7 +1179,7 @@ cc_printers_panel_init (CcPrintersPanel *self)
GtkWidget *widget;
PpCups *cups;
g_autoptr(GError) error = NULL;
- gchar *objects[] = { "overlay", "headerbar-buttons", "search-button", NULL };
+ gchar *objects[] = { "overlay", "permission-infobar", "printer-add-button",
"search-button", NULL };
guint builder_result;
g_resources_register (cc_printers_get_resource ());
@@ -1243,10 +1234,6 @@ cc_printers_panel_init (CcPrintersPanel *self)
return;
}
- widget = (GtkWidget*)
- gtk_builder_get_object (self->builder, "headerbar-buttons");
- self->headerbar_buttons = widget;
-
self->notification = (GtkRevealer*)
gtk_builder_get_object (self->builder, "notification");
@@ -1258,6 +1245,9 @@ cc_printers_panel_init (CcPrintersPanel *self)
gtk_builder_get_object (self->builder, "notification-dismiss-button");
g_signal_connect (widget, "clicked", G_CALLBACK (on_notification_dismissed), self);
+ self->permission_infobar = (CcPermissionInfobar*)
+ gtk_builder_get_object (self->builder, "permission-infobar");
+
/* add the top level widget */
top_widget = (GtkWidget*)
gtk_builder_get_object (self->builder, "overlay");
@@ -1300,6 +1290,10 @@ cc_printers_panel_init (CcPrintersPanel *self)
G_CALLBACK (on_permission_changed),
self,
G_CONNECT_AFTER);
+
+ cc_permission_infobar_set_permission (self->permission_infobar,
+ self->permission);
+
on_permission_changed (self->permission, NULL, self);
}
else
diff --git a/panels/printers/printers.ui b/panels/printers/printers.ui
index 2894b7e17..136c31229 100644
--- a/panels/printers/printers.ui
+++ b/panels/printers/printers.ui
@@ -1,31 +1,14 @@
<?xml version="1.0"?>
<interface>
<requires lib="gtk+" version="3.12"/>
- <!-- interface-naming-policy project-wide -->
- <object class="GtkStack" id="headerbar-buttons">
+ <object class="GtkButton" id="printer-add-button">
<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" comments="Translators: This button adds new
printer.">Add…</property>
- <style>
- <class name="suggested-action"/>
- </style>
- </object>
- <packing>
- <property name="name">_addprinter</property>
- </packing>
- </child>
+ <property name="sensitive">True</property>
+ <property name="use_underline">True</property>
+ <property name="label" translatable="yes" comments="Translators: This button adds new
printer.">Add…</property>
+ <style>
+ <class name="suggested-action"/>
+ </style>
</object>
<object class="GtkToggleButton" id="search-button">
@@ -112,6 +95,11 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="orientation">GTK_ORIENTATION_VERTICAL</property>
+ <child>
+ <object class="CcPermissionInfobar" id="permission-infobar">
+ <property name="visible">True</property>
+ </object>
+ </child>
<child>
<object class="GtkSearchBar" id="search-bar">
<property name="visible">True</property>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]