[gnome-control-center/wip/privacy-swarm: 74/78] Add a lock panel
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/wip/privacy-swarm: 74/78] Add a lock panel
- Date: Sat, 15 Dec 2018 01:21:11 +0000 (UTC)
commit d90060a4514f273153241175905e7b2e43f96897
Author: Matthias Clasen <mclasen redhat com>
Date: Tue Dec 11 14:19:58 2018 -0500
Add a lock panel
This is a broken out version of the privacy panel dialog.
panels/lock/cc-lock-panel.c | 157 +++++++++++++++++++++
panels/lock/cc-lock-panel.h | 30 ++++
panels/lock/cc-lock-panel.ui | 212 +++++++++++++++++++++++++++++
panels/lock/gnome-lock-panel.desktop.in.in | 19 +++
panels/lock/lock.gresource.xml | 6 +
panels/lock/meson.build | 40 ++++++
6 files changed, 464 insertions(+)
---
diff --git a/panels/lock/cc-lock-panel.c b/panels/lock/cc-lock-panel.c
new file mode 100644
index 000000000..6856a5a3a
--- /dev/null
+++ b/panels/lock/cc-lock-panel.c
@@ -0,0 +1,157 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2018 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Matthias Clasen <mclasen redhat com>
+ */
+
+#include "list-box-helper.h"
+#include "cc-lock-panel.h"
+#include "cc-lock-resources.h"
+#include "cc-util.h"
+
+#include <gio/gdesktopappinfo.h>
+#include <glib/gi18n.h>
+
+struct _CcLockPanel
+{
+ CcPanel parent_instance;
+
+ GSettings *lock_settings;
+ GSettings *notification_settings;
+
+ GtkListBox *lock_list_box;
+ GtkSwitch *automatic_screen_lock_switch;
+ GtkSwitch *show_notifications_switch;
+ GtkComboBox *lock_after_combo;
+};
+
+CC_PANEL_REGISTER (CcLockPanel, cc_lock_panel)
+
+static void
+cc_lock_panel_finalize (GObject *object)
+{
+ CcLockPanel *self = CC_LOCK_PANEL (object);
+
+ g_clear_object (&self->lock_settings);
+
+ G_OBJECT_CLASS (cc_lock_panel_parent_class)->finalize (object);
+}
+
+static void
+lock_combo_changed_cb (GtkWidget *widget,
+ CcLockPanel *self)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ guint delay;
+ gboolean ret;
+
+ ret = gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter);
+ if (!ret)
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (widget));
+ gtk_tree_model_get (model, &iter,
+ 1, &delay,
+ -1);
+ g_settings_set (self->lock_settings, "lock-delay", "u", delay);
+}
+
+static void
+set_lock_value_for_combo (GtkComboBox *combo_box,
+ CcLockPanel *self)
+{
+ GtkTreeIter iter;
+ GtkTreeModel *model;
+ guint value;
+ gint value_tmp, value_prev;
+ gboolean ret;
+ guint i;
+
+ model = gtk_combo_box_get_model (combo_box);
+ ret = gtk_tree_model_get_iter_first (model, &iter);
+ if (!ret)
+ return;
+
+ value_prev = 0;
+ i = 0;
+
+ g_settings_get (self->lock_settings, "lock-delay", "u", &value);
+ do
+ {
+ gtk_tree_model_get (model, &iter,
+ 1, &value_tmp,
+ -1);
+ if (value == value_tmp ||
+ (value_tmp > value_prev && value < value_tmp))
+ {
+ gtk_combo_box_set_active_iter (combo_box, &iter);
+ return;
+ }
+ value_prev = value_tmp;
+ i++;
+ } while (gtk_tree_model_iter_next (model, &iter));
+
+ gtk_combo_box_set_active (combo_box, i - 1);
+}
+
+static void
+cc_lock_panel_init (CcLockPanel *self)
+{
+ g_resources_register (cc_lock_get_resource ());
+
+ gtk_widget_init_template (GTK_WIDGET (self));
+
+ gtk_list_box_set_header_func (self->lock_list_box,
+ cc_list_box_update_header_func,
+ NULL, NULL);
+
+ self->lock_settings = g_settings_new ("org.gnome.desktop.screensaver");
+ self->notification_settings = g_settings_new ("org.gnome.desktop.notifications");
+
+ g_settings_bind (self->lock_settings, "lock-enabled",
+ self->automatic_screen_lock_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (self->lock_settings, "lock-enabled",
+ self->lock_after_combo, "sensitive",
+ G_SETTINGS_BIND_GET);
+
+ set_lock_value_for_combo (self->lock_after_combo, self);
+ g_signal_connect (self->lock_after_combo, "changed",
+ G_CALLBACK (lock_combo_changed_cb), self);
+
+ g_settings_bind (self->notification_settings, "show-in-lock-screen",
+ self->show_notifications_switch, "active",
+ G_SETTINGS_BIND_DEFAULT);
+}
+
+static void
+cc_lock_panel_class_init (CcLockPanelClass *klass)
+{
+ GObjectClass *oclass = G_OBJECT_CLASS (klass);
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+
+ oclass->finalize = cc_lock_panel_finalize;
+
+ gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/control-center/lock/cc-lock-panel.ui");
+
+ gtk_widget_class_bind_template_child (widget_class, CcLockPanel, lock_list_box);
+ gtk_widget_class_bind_template_child (widget_class, CcLockPanel, automatic_screen_lock_switch);
+ gtk_widget_class_bind_template_child (widget_class, CcLockPanel, show_notifications_switch);
+ gtk_widget_class_bind_template_child (widget_class, CcLockPanel, lock_after_combo);
+}
diff --git a/panels/lock/cc-lock-panel.h b/panels/lock/cc-lock-panel.h
new file mode 100644
index 000000000..c8db1b9ca
--- /dev/null
+++ b/panels/lock/cc-lock-panel.h
@@ -0,0 +1,30 @@
+/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*-
+ *
+ * Copyright (C) 2018 Red Hat, Inc
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Matthias Clasen <mclasen redhat com>
+ */
+
+#pragma once
+
+#include <shell/cc-panel.h>
+
+G_BEGIN_DECLS
+
+#define CC_TYPE_LOCK_PANEL (cc_lock_panel_get_type ())
+G_DECLARE_FINAL_TYPE (CcLockPanel, cc_lock_panel, CC, LOCK_PANEL, CcPanel)
+
+G_END_DECLS
diff --git a/panels/lock/cc-lock-panel.ui b/panels/lock/cc-lock-panel.ui
new file mode 100644
index 000000000..77c456e41
--- /dev/null
+++ b/panels/lock/cc-lock-panel.ui
@@ -0,0 +1,212 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+ <requires lib="gtk+" version="3.14"/>
+ <object class="GtkListStore" id="lock_after_model">
+ <columns>
+ <!-- column-name name -->
+ <column type="gchararray"/>
+ <!-- column-name value -->
+ <column type="gint"/>
+ </columns>
+ <data>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">Screen Turns Off</col>
+ <col id="1">0</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">30 seconds</col>
+ <col id="1">30</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">1 minute</col>
+ <col id="1">60</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">2 minutes</col>
+ <col id="1">120</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">3 minutes</col>
+ <col id="1">180</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">5 minutes</col>
+ <col id="1">300</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">30 minutes</col>
+ <col id="1">1800</col>
+ </row>
+ <row>
+ <col id="0" translatable="yes" context="lock_screen" comments="Translators: Option for "Lock
screen after blank for" in "Screen Lock" dialog.">1 hour</col>
+ <col id="1">3600</col>
+ </row>
+ </data>
+ </object>
+
+ <template class="CcLockPanel" parent="CcPanel">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkScrolledWindow">
+ <property name="visible">1</property>
+ <property name="hscrollbar-policy">never</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <!-- Stub boxes to make the content cover 1/3 of the screen -->
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="hexpand">1</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="hexpand">1</property>
+ </object>
+ <packing>
+ <property name="pack-type">end</property>
+ </packing>
+ </child>
+ <!-- Content -->
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="orientation">vertical</property>
+ <property name="margin">32</property>
+ <property name="hexpand">1</property>
+ <child>
+ <object class="GtkLabel" id="lock_description_label">
+ <property name="visible">1</property>
+ <property name="margin-bottom">12</property>
+ <property name="label" translatable="yes">The Screen Lock protects your privacy when you
are away.</property>
+ <property name="wrap">1</property>
+ <property name="max-width-chars">50</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBox" id="lock_list_box">
+ <property name="visible">1</property>
+ <property name="can-focus">1</property>
+ <property name="selection-mode">none</property>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">Automatic Screen _Lock</property>
+ <property name="use_underline">1</property>
+ <property name="mnemonic_widget">automatic_screen_lock_switch</property>
+ <property name="xalign">0</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="automatic_screen_lock_switch">
+ <property name="visible">1</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="label" translatable="yes">Lock screen _after blank
for</property>
+ <property name="use_underline">1</property>
+ <property name="mnemonic_widget">lock_after_combo</property>
+ <property name="sensitive" bind-source="lock_after_combo"
bind-property="sensitive"/>
+ <property name="xalign">0</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkComboBoxText" id="lock_after_combo">
+ <property name="visible">1</property>
+ <property name="valign">center</property>
+ <property name="entry_text_column">0</property>
+ <property name="model">lock_after_model</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBoxRow">
+ <property name="visible">1</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">1</property>
+ <property name="margin_start">12</property>
+ <property name="margin_end">12</property>
+ <property name="margin_top">12</property>
+ <property name="margin_bottom">12</property>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">1</property>
+ <property name="use_underline">1</property>
+ <property name="mnemonic_widget">show_notifications_switch</property>
+ <property name="label" translatable="yes">Show _Notifications</property>
+ <property name="xalign">0</property>
+ <property name="valign">center</property>
+ </object>
+ <packing>
+ <property name="expand">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="show_notifications_switch">
+ <property name="visible">1</property>
+ <property name="halign">end</property>
+ <property name="valign">center</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <style>
+ <class name="view"/>
+ <class name="frame"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/panels/lock/gnome-lock-panel.desktop.in.in b/panels/lock/gnome-lock-panel.desktop.in.in
new file mode 100644
index 000000000..9aaf068b1
--- /dev/null
+++ b/panels/lock/gnome-lock-panel.desktop.in.in
@@ -0,0 +1,19 @@
+[Desktop Entry]
+Name=Screen Lock
+Comment=Lock your screen
+Exec=gnome-control-center lock
+# FIXME
+# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
+Icon=preferences-system-time
+Terminal=false
+Type=Application
+NoDisplay=true
+StartupNotify=true
+Categories=GNOME;GTK;Settings;DesktopSettings;X-GNOME-Settings-Panel;X-GNOME-PrivacySettings;
+OnlyShowIn=GNOME;Unity;
+X-GNOME-Bugzilla-Bugzilla=GNOME
+X-GNOME-Bugzilla-Product=gnome-control-center
+X-GNOME-Bugzilla-Component=privacy
+X-GNOME-Bugzilla-Version=@VERSION@
+# Translators: Search terms to find the Privacy panel. Do NOT translate or localize the semicolons! The list
MUST also end with a semicolon!
+Keywords=screen;lock;diagnostics;crash;private;recent;temporary;tmp;index;name;network;identity;
diff --git a/panels/lock/lock.gresource.xml b/panels/lock/lock.gresource.xml
new file mode 100644
index 000000000..8b25a2102
--- /dev/null
+++ b/panels/lock/lock.gresource.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+ <gresource prefix="/org/gnome/control-center/lock">
+ <file preprocess="xml-stripblanks">cc-lock-panel.ui</file>
+ </gresource>
+</gresources>
diff --git a/panels/lock/meson.build b/panels/lock/meson.build
new file mode 100644
index 000000000..0661af4fa
--- /dev/null
+++ b/panels/lock/meson.build
@@ -0,0 +1,40 @@
+panels_list += cappletname
+desktop = 'gnome-@0@-panel.desktop'.format(cappletname)
+
+desktop_in = configure_file(
+ input: desktop + '.in.in',
+ output: desktop + '.in',
+ configuration: desktop_conf
+)
+
+i18n.merge_file(
+ desktop,
+ type: 'desktop',
+ input: desktop_in,
+ output: desktop,
+ po_dir: po_dir,
+ install: true,
+ install_dir: control_center_desktopdir
+)
+
+sources = files('cc-lock-panel.c')
+
+resource_data = files('cc-lock-panel.ui')
+
+sources += gnome.compile_resources(
+ 'cc-' + cappletname + '-resources',
+ cappletname + '.gresource.xml',
+ c_name: 'cc_' + cappletname,
+ dependencies: resource_data,
+ export: true
+)
+
+cflags += '-DGNOMELOCALEDIR="@0@"'.format(control_center_localedir)
+
+panels_libs += static_library(
+ cappletname,
+ sources: sources,
+ include_directories: [top_inc, common_inc],
+ dependencies: common_deps,
+ c_args: cflags
+)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]