[gnome-control-center/gbsneto/gtk4: 23/53] camera: Port to GTK4




commit eff96c4cb1536b8ca922149cbf7e04d3adc20f3f
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Oct 19 23:11:47 2021 -0300

    camera: Port to GTK4

 panels/camera/cc-camera-panel.c  |  25 ++----
 panels/camera/cc-camera-panel.ui | 188 +++++++++++++++++++--------------------
 panels/meson.build               |   2 +-
 shell/cc-panel-loader.c          |   4 +-
 4 files changed, 102 insertions(+), 117 deletions(-)
---
diff --git a/panels/camera/cc-camera-panel.c b/panels/camera/cc-camera-panel.c
index 516aae02f..86fef1baf 100644
--- a/panels/camera/cc-camera-panel.c
+++ b/panels/camera/cc-camera-panel.c
@@ -18,7 +18,6 @@
  * Author: Matthias Clasen <mclasen redhat com>
  */
 
-#include "list-box-helper.h"
 #include "cc-camera-panel.h"
 #include "cc-camera-resources.h"
 #include "cc-util.h"
@@ -174,40 +173,36 @@ add_camera_app (CcCameraPanel *self,
     return;
 
   row = gtk_list_box_row_new ();
-  gtk_widget_show (row);
   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
-  gtk_widget_show (box);
   gtk_widget_set_margin_start (box, 12);
   gtk_widget_set_margin_end (box, 6);
   gtk_widget_set_margin_top (box, 12);
   gtk_widget_set_margin_bottom (box, 12);
-  gtk_container_add (GTK_CONTAINER (row), box);
+  gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
   gtk_widget_set_hexpand (box, TRUE);
-  gtk_container_add (GTK_CONTAINER (self->camera_apps_list_box), row);
+  gtk_list_box_append (self->camera_apps_list_box, row);
 
   icon = g_app_info_get_icon (G_APP_INFO (app_info));
-  w = gtk_image_new_from_gicon (icon, GTK_ICON_SIZE_LARGE_TOOLBAR);
-  gtk_widget_show (w);
+  w = gtk_image_new_from_gicon (icon);
   gtk_widget_set_halign (w, GTK_ALIGN_CENTER);
   gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
   gtk_size_group_add_widget (self->camera_icon_size_group, w);
-  gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
+  gtk_box_append (GTK_BOX (box), w);
 
   w = gtk_label_new (g_app_info_get_name (G_APP_INFO (app_info)));
-  gtk_widget_show (w);
+  gtk_widget_set_hexpand (w, TRUE);
   gtk_widget_set_margin_start (w, 12);
   gtk_widget_set_margin_end (w, 12);
   gtk_widget_set_halign (w, GTK_ALIGN_START);
   gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
   gtk_label_set_xalign (GTK_LABEL (w), 0);
-  gtk_box_pack_start (GTK_BOX (box), w, TRUE, TRUE, 0);
+  gtk_box_append (GTK_BOX (box), w);
 
   w = gtk_switch_new ();
-  gtk_widget_show (w);
   gtk_switch_set_active (GTK_SWITCH (w), enabled);
   gtk_widget_set_halign (w, GTK_ALIGN_END);
   gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
-  gtk_box_pack_start (GTK_BOX (box), w, FALSE, FALSE, 0);
+  gtk_box_append (GTK_BOX (box), w);
   g_settings_bind (self->privacy_settings,
                    "disable-camera",
                    w,
@@ -391,7 +386,7 @@ cc_camera_panel_constructed (GObject *object)
   widget = gtk_switch_new ();
   gtk_widget_show (widget);
   gtk_widget_set_valign (widget, GTK_ALIGN_CENTER);
-  gtk_box_pack_start (GTK_BOX (box), widget, FALSE, FALSE, 4);
+  gtk_box_append (GTK_BOX (box), widget);
 
   g_settings_bind (self->privacy_settings, "disable-camera",
                    widget, "active",
@@ -433,10 +428,6 @@ cc_camera_panel_init (CcCameraPanel *self)
 
   gtk_widget_init_template (GTK_WIDGET (self));
 
-  gtk_list_box_set_header_func (self->camera_apps_list_box,
-                                cc_list_box_update_header_func,
-                                NULL,
-                                NULL);
   self->camera_icon_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
 
   self->privacy_settings = g_settings_new ("org.gnome.desktop.privacy");
diff --git a/panels/camera/cc-camera-panel.ui b/panels/camera/cc-camera-panel.ui
index 8d87bbd61..281fed1f9 100644
--- a/panels/camera/cc-camera-panel.ui
+++ b/panels/camera/cc-camera-panel.ui
@@ -3,125 +3,119 @@
 <interface>
   <requires lib="gtk+" version="3.14"/>
   <template class="CcCameraPanel" parent="CcPanel">
-    <property name="visible">True</property>
     <child>
       <object class="GtkStack" id="stack">
-        <property name="visible">true</property>
+
+        <!-- Empty page -->
         <child>
-          <object class="GtkBox">
-            <property name="visible">true</property>
-            <property name="orientation">vertical</property>
-            <property name="valign">center</property>
-            <child>
-              <object class="GtkImage">
-                <property name="visible">true</property>
-                <property name="valign">start</property>
-                <property name="pixel-size">96</property>
-                <property name="icon-name">camera-disabled-symbolic</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
-              </object>
-              <packing>
-                <property name="fill">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">true</property>
-                <property name="margin-top">20</property>
-                <property name="margin-bottom">15</property>
-                <property name="label" translatable="yes">Camera is turned off</property>
-                <attributes>
-                  <attribute name="scale" value="1.44"/>
-                </attributes>
-              </object>
-            </child>
-            <child>
-              <object class="GtkLabel">
-                <property name="visible">true</property>
-                <property name="label" translatable="yes">No applications can capture photos or 
video.</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
+          <object class="GtkStackPage">
+            <property name="name">empty</property>
+            <property name="child">
+              <object class="GtkBox">
+                <property name="orientation">vertical</property>
+                <property name="valign">center</property>
+                <child>
+                  <object class="GtkImage">
+                    <property name="valign">start</property>
+                    <property name="pixel-size">96</property>
+                    <property name="icon-name">camera-disabled-symbolic</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="margin-top">20</property>
+                    <property name="margin-bottom">15</property>
+                    <property name="label" translatable="yes">Camera is turned off</property>
+                    <attributes>
+                      <attribute name="scale" value="1.44"/>
+                    </attributes>
+                  </object>
+                </child>
+                <child>
+                  <object class="GtkLabel">
+                    <property name="label" translatable="yes">No applications can capture photos or 
video.</property>
+                    <style>
+                      <class name="dim-label"/>
+                    </style>
+                  </object>
+                </child>
               </object>
-            </child>
+            </property>
           </object>
-          <packing>
-            <property name="name">empty</property>
-          </packing>
         </child>
-        <child>
-          <object class="GtkScrolledWindow">
-            <property name="visible">true</property>
-            <property name="hscrollbar-policy">never</property>
-            <child>
-              <object class="HdyClamp">
-                <property name="visible">True</property>
-                <property name="margin_top">32</property>
-                <property name="margin_bottom">32</property>
-                <property name="margin_start">12</property>
-                <property name="margin_end">12</property>
 
+        <!-- Cameras -->
+        <child>
+          <object class="GtkStackPage">
+            <property name="name">content</property>
+            <property name="child">
+              <object class="GtkScrolledWindow">
+                <property name="hscrollbar-policy">never</property>
                 <child>
-                  <object class="GtkBox">
-                    <property name="visible">true</property>
-                    <property name="orientation">vertical</property>
-                    <property name="hexpand">1</property>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">true</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">1</property>
-                        <property name="max-width-chars">50</property>
-                        <property name="xalign">0</property>
-                      </object>
-                    </child>
-                    <child>
-                      <object class="GtkLabel">
-                        <property name="visible">true</property>
-                        <property name="margin-bottom">12</property>
-                        <property name="label" translatable="yes">Allow the applications below to use your 
camera.</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="camera_apps_list_box">
-                        <property name="visible">true</property>
-                        <property name="can-focus">1</property>
-                        <property name="selection-mode">none</property>
-                        <style>
-                          <class name="view"/>
-                          <class name="frame"/>
-                        </style>
+                  <object class="AdwClamp">
+                    <property name="margin_top">32</property>
+                    <property name="margin_bottom">32</property>
+                    <property name="margin_start">12</property>
+                    <property name="margin_end">12</property>
 
-                        <child type="placeholder">
+                    <child>
+                      <object class="GtkBox">
+                        <property name="orientation">vertical</property>
+                        <property name="hexpand">1</property>
+                        <child>
+                          <object class="GtkLabel">
+                            <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">1</property>
+                            <property name="max-width-chars">50</property>
+                            <property name="xalign">0</property>
+                          </object>
+                        </child>
+                        <child>
                           <object class="GtkLabel">
-                            <property name="visible">true</property>
-                            <property name="margin">18</property>
-                            <property name="label" translatable="yes">No Applications Have Asked for Camera 
Access</property>
-                            <property name="wrap">true</property>
+                            <property name="margin-bottom">12</property>
+                            <property name="label" translatable="yes">Allow the applications below to use 
your camera.</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="camera_apps_list_box">
+                            <property name="selection-mode">none</property>
                             <style>
-                              <class name="dim-label" />
+                              <class name="content"/>
                             </style>
+
+                            <child type="placeholder">
+                              <object class="GtkLabel">
+                                <property name="margin-start">18</property>
+                                <property name="margin-end">18</property>
+                                <property name="margin-top">18</property>
+                                <property name="margin-bottom">18</property>
+                                <property name="label" translatable="yes">No Applications Have Asked for 
Camera Access</property>
+                                <property name="wrap">true</property>
+                                <property name="max-width-chars">50</property>
+                                <style>
+                                  <class name="dim-label" />
+                                </style>
+                              </object>
+                            </child>
                           </object>
                         </child>
                       </object>
                     </child>
+
                   </object>
                 </child>
-
               </object>
-            </child>
+            </property>
           </object>
-          <packing>
-            <property name="name">content</property>
-          </packing>
         </child>
+
       </object>
     </child>
   </template>
diff --git a/panels/meson.build b/panels/meson.build
index 518207ddd..e25f7a549 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -3,7 +3,7 @@ subdir('common')
 panels = [
 #  'applications',
 #  'background',
-#  'camera',
+  'camera',
 #  'color',
 #  'datetime',
 #  'default-apps',
diff --git a/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index 8c5647668..b9bead778 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -69,7 +69,7 @@ extern GType cc_notifications_panel_get_type (void);
 //extern GType cc_wwan_panel_get_type (void);
 #endif /* BUILD_WWAN */
 //extern GType cc_location_panel_get_type (void);
-//extern GType cc_camera_panel_get_type (void);
+extern GType cc_camera_panel_get_type (void);
 //extern GType cc_microphone_panel_get_type (void);
 //extern GType cc_usage_panel_get_type (void);
 //extern GType cc_lock_panel_get_type (void);
@@ -102,7 +102,7 @@ static CcPanelLoaderVtable default_panels[] =
 #ifdef BUILD_BLUETOOTH
   //PANEL_TYPE("bluetooth",        cc_bluetooth_panel_get_type,            NULL),
 #endif
-  //PANEL_TYPE("camera",           cc_camera_panel_get_type,               NULL),
+  PANEL_TYPE("camera",           cc_camera_panel_get_type,               NULL),
   //PANEL_TYPE("color",            cc_color_panel_get_type,                NULL),
   //PANEL_TYPE("datetime",         cc_date_time_panel_get_type,            NULL),
   //PANEL_TYPE("default-apps",     cc_default_apps_panel_get_type,         NULL),


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