[gnome-control-center/wip/applications: 6/7] privacy: handle microphone and camera



commit 440871730358ad2ff01475105a247cf884741cf6
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Dec 9 18:31:57 2018 -0500

    privacy: handle microphone and camera
    
    This is just adding switches for these new settings
    to the panel, no changes to the design.

 panels/privacy/cc-privacy-panel.c  |  78 ++++++++++++++
 panels/privacy/cc-privacy-panel.ui | 210 +++++++++++++++++++++++++++++++++++++
 2 files changed, 288 insertions(+)
---
diff --git a/panels/privacy/cc-privacy-panel.c b/panels/privacy/cc-privacy-panel.c
index a2ba67ec4..bd42c9a9f 100644
--- a/panels/privacy/cc-privacy-panel.c
+++ b/panels/privacy/cc-privacy-panel.c
@@ -56,6 +56,12 @@ struct _CcPrivacyPanel
   GtkDialog   *location_dialog;
   GtkLabel    *location_label;
   GtkSwitch   *location_services_switch;
+  GtkDialog   *camera_dialog;
+  GtkLabel    *camera_label;
+  GtkSwitch   *camera_switch;
+  GtkDialog   *microphone_dialog;
+  GtkLabel    *microphone_label;
+  GtkSwitch   *microphone_switch;
   GtkComboBox *lock_after_combo;
   GtkLabel    *lock_after_label;
   GtkComboBox *purge_after_combo;
@@ -868,6 +874,72 @@ add_location (CcPrivacyPanel *self)
                             self);
 }
 
+static void
+update_camera_label (CcPrivacyPanel *self)
+{
+  if (g_settings_get_boolean (self->privacy_settings, "disable-camera"))
+    gtk_label_set_label (self->camera_label, C_("Camera status", "Off"));
+  else
+    gtk_label_set_label (self->camera_label, C_("Camera status", "On"));
+}
+
+static void
+add_camera (CcPrivacyPanel *self)
+{
+  self->camera_label = GTK_LABEL (gtk_label_new (""));
+  gtk_widget_show (GTK_WIDGET (self->camera_label));
+  update_camera_label (self);
+
+  add_row (self,
+           _("Camera"),
+           self->camera_dialog,
+           GTK_WIDGET (self->camera_label));
+
+  g_signal_connect (self->camera_dialog, "delete-event",
+                    G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+  g_settings_bind (self->privacy_settings, "disable-camera",
+                   self->camera_switch, "active",
+                   G_SETTINGS_BIND_INVERT_BOOLEAN);
+
+  g_signal_connect_object (self->privacy_settings, "changed::disable-camera",
+                           G_CALLBACK (update_camera_label), self,
+                           G_CONNECT_SWAPPED);
+}
+
+static void
+update_microphone_label (CcPrivacyPanel *self)
+{
+  if (g_settings_get_boolean (self->privacy_settings, "disable-microphone"))
+    gtk_label_set_label (self->microphone_label, C_("Microphone status", "Off"));
+  else
+    gtk_label_set_label (self->microphone_label, C_("Microphone status", "On"));
+}
+
+static void
+add_microphone (CcPrivacyPanel *self)
+{
+  self->microphone_label = GTK_LABEL (gtk_label_new (""));
+  gtk_widget_show (GTK_WIDGET (self->microphone_label));
+  update_microphone_label (self);
+
+  add_row (self,
+           _("Microphone"),
+           self->microphone_dialog,
+           GTK_WIDGET (self->microphone_label));
+
+  g_signal_connect (self->microphone_dialog, "delete-event",
+                    G_CALLBACK (gtk_widget_hide_on_delete), NULL);
+
+  g_settings_bind (self->privacy_settings, "disable-microphone",
+                   self->microphone_switch, "active",
+                   G_SETTINGS_BIND_INVERT_BOOLEAN);
+
+  g_signal_connect_object (self->privacy_settings, "changed::disable-microphone",
+                           G_CALLBACK (update_microphone_label), self,
+                           G_CONNECT_SWAPPED);
+}
+
 static void
 retain_history_combo_changed_cb (GtkWidget      *widget,
                                  CcPrivacyPanel *self)
@@ -1309,6 +1381,8 @@ cc_privacy_panel_init (CcPrivacyPanel *self)
 
   add_screen_lock (self);
   add_location (self);
+  add_camera (self);
+  add_microphone (self);
   add_usage_history (self);
   add_trash_temp (self);
   add_software (self);
@@ -1345,6 +1419,10 @@ cc_privacy_panel_class_init (CcPrivacyPanelClass *klass)
   gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, location_apps_list_box);
   gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, location_dialog);
   gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, location_services_switch);
+  gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, camera_dialog);
+  gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, camera_switch);
+  gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, microphone_dialog);
+  gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, microphone_switch);
   gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, lock_after_combo);
   gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, lock_after_label);
   gtk_widget_class_bind_template_child (widget_class, CcPrivacyPanel, purge_after_combo);
diff --git a/panels/privacy/cc-privacy-panel.ui b/panels/privacy/cc-privacy-panel.ui
index 3ff94a1a0..c043116a7 100644
--- a/panels/privacy/cc-privacy-panel.ui
+++ b/panels/privacy/cc-privacy-panel.ui
@@ -739,6 +739,216 @@ All the information we collect is made anonymous, and we will never share your d
       </object>
     </child>
   </object>
+  <object class="GtkDialog" id="camera_dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Camera</property>
+    <property name="resizable">False</property>
+    <property name="type_hint">dialog</property>
+    <property name="use_header_bar">1</property>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="margin">12</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_bottom">12</property>
+                <property name="label" translatable="yes">Use of the camera allows applications to capture 
photos and video. Disabling the camera may cause some applications to not function properly.</property>
+                <property name="wrap">True</property>
+                <property name="max_width_chars">50</property>
+                <property name="xalign">0</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="shadow_type">in</property>
+
+            <child>
+              <object class="GtkListBox">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="selection_mode">none</property>
+                <child>
+                  <object class="GtkListBoxRow" id="camera_row">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+
+                    <child>
+                      <object class="GtkGrid">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="row_spacing">0</property>
+                        <property name="column_spacing">32</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">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="hexpand">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">_Camera</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+
+                        <child>
+                          <object class="GtkSwitch" id="camera_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="halign">end</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+  <object class="GtkDialog" id="microphone_dialog">
+    <property name="can_focus">False</property>
+    <property name="border_width">5</property>
+    <property name="title" translatable="yes">Microphone</property>
+    <property name="resizable">False</property>
+    <property name="type_hint">dialog</property>
+    <property name="use_header_bar">1</property>
+    <child internal-child="vbox">
+      <object class="GtkBox">
+        <property name="can_focus">False</property>
+        <property name="orientation">vertical</property>
+        <property name="margin">12</property>
+        <property name="spacing">2</property>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <child>
+              <object class="GtkLabel">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_bottom">12</property>
+                <property name="label" translatable="yes">Use of the microphone allows applications to 
capture sounds. Disabling the microphone may cause some applications to not function properly.</property>
+                <property name="wrap">True</property>
+                <property name="max_width_chars">50</property>
+                <property name="xalign">0</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkFrame">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="shadow_type">in</property>
+
+            <child>
+              <object class="GtkListBox">
+                <property name="visible">True</property>
+                <property name="can_focus">True</property>
+                <property name="selection_mode">none</property>
+                <child>
+                  <object class="GtkListBoxRow">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+
+                    <child>
+                      <object class="GtkGrid">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="row_spacing">0</property>
+                        <property name="column_spacing">32</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">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="hexpand">True</property>
+                            <property name="xalign">0</property>
+                            <property name="label" translatable="yes">_Microphone</property>
+                            <property name="use_underline">True</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">0</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+
+                        <child>
+                          <object class="GtkSwitch" id="microphone_switch">
+                            <property name="visible">True</property>
+                            <property name="can_focus">True</property>
+                            <property name="halign">end</property>
+                          </object>
+                          <packing>
+                            <property name="left_attach">1</property>
+                            <property name="top_attach">0</property>
+                            <property name="width">1</property>
+                            <property name="height">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
   <object class="GtkDialog" id="location_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]