[gnome-control-center/gbsneto/gtk4: 20/35] microphone: Port to GTK4
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center/gbsneto/gtk4: 20/35] microphone: Port to GTK4
- Date: Mon, 1 Nov 2021 01:13:24 +0000 (UTC)
commit 402192b1d8a03408462f85d3459aa2d2ad6a72d3
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Wed Oct 20 17:19:07 2021 -0300
microphone: Port to GTK4
panels/meson.build | 2 +-
panels/microphone/cc-microphone-panel.c | 28 ++---
panels/microphone/cc-microphone-panel.ui | 185 +++++++++++++++----------------
shell/cc-panel-loader.c | 4 +-
4 files changed, 100 insertions(+), 119 deletions(-)
---
diff --git a/panels/meson.build b/panels/meson.build
index 064333e4c..a08f9a338 100644
--- a/panels/meson.build
+++ b/panels/meson.build
@@ -13,7 +13,7 @@ panels = [
# 'keyboard',
'location',
'lock',
-# 'microphone',
+ 'microphone',
# 'mouse',
# 'multitasking',
'notifications',
diff --git a/panels/microphone/cc-microphone-panel.c b/panels/microphone/cc-microphone-panel.c
index 8e115c06d..3bf0e8be7 100644
--- a/panels/microphone/cc-microphone-panel.c
+++ b/panels/microphone/cc-microphone-panel.c
@@ -18,7 +18,6 @@
* Author: Matthias Clasen <mclasen redhat com>
*/
-#include "list-box-helper.h"
#include "cc-microphone-panel.h"
#include "cc-microphone-resources.h"
#include "cc-util.h"
@@ -169,40 +168,35 @@ add_microphone_app (CcMicrophonePanel *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_hexpand (box, TRUE);
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_widget_set_hexpand (box, TRUE);
- gtk_container_add (GTK_CONTAINER (self->microphone_apps_list_box), row);
+ gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
+ gtk_list_box_append (self->microphone_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->microphone_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_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-microphone",
w,
@@ -380,12 +374,9 @@ cc_microphone_panel_constructed (GObject *object)
G_OBJECT_CLASS (cc_microphone_panel_parent_class)->constructed (object);
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_widget_show (box);
-
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-microphone",
widget, "active",
@@ -427,9 +418,6 @@ cc_microphone_panel_init (CcMicrophonePanel *self)
gtk_widget_init_template (GTK_WIDGET (self));
- gtk_list_box_set_header_func (self->microphone_apps_list_box,
- cc_list_box_update_header_func,
- NULL, NULL);
self->microphone_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/microphone/cc-microphone-panel.ui b/panels/microphone/cc-microphone-panel.ui
index 04f943b35..343629db5 100644
--- a/panels/microphone/cc-microphone-panel.ui
+++ b/panels/microphone/cc-microphone-panel.ui
@@ -3,125 +3,118 @@
<interface>
<requires lib="gtk+" version="3.14"/>
<template class="CcMicrophonePanel" parent="CcPanel">
- <property name="visible">True</property>
<child>
<object class="GtkStack" id="stack">
- <property name="visible">true</property>
+
<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">microphone-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">Microphone 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 record sound.</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">microphone-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">Microphone 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 record sound.</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>
+ <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 microphone allows applications
to record and listen to audio. 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>
- </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
microphone.</property>
- <property name="wrap">true</property>
- <property name="max-width-chars">50</property>
- <property name="xalign">0</property>
- </object>
- </child>
- <child>
- <object class="GtkListBox" id="microphone_apps_list_box">
- <property name="visible">true</property>
- <property name="can-focus">true</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 microphone allows
applications to record and listen to audio. 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>
+ </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
Microphone Access</property>
+ <property name="margin-bottom">12</property>
+ <property name="label" translatable="yes">Allow the applications below to use
your microphone.</property>
<property name="wrap">true</property>
<property name="max-width-chars">50</property>
+ <property name="xalign">0</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkListBox" id="microphone_apps_list_box">
+ <property name="can-focus">true</property>
+ <property name="selection-mode">none</property>
<style>
- <class name="dim-label" />
+ <class name="content"/>
</style>
+
+ <child type="placeholder">
+ <object class="GtkLabel">
+ <property name="margin-top">18</property>
+ <property name="margin-bottom">18</property>
+ <property name="margin-start">18</property>
+ <property name="margin-end">18</property>
+ <property name="label" translatable="yes">No Applications Have Asked for
Microphone 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/shell/cc-panel-loader.c b/shell/cc-panel-loader.c
index eabc05734..97c418896 100644
--- a/shell/cc-panel-loader.c
+++ b/shell/cc-panel-loader.c
@@ -70,7 +70,7 @@ extern GType cc_ua_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_microphone_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);
//extern GType cc_diagnostics_panel_get_type (void);
@@ -112,7 +112,7 @@ static CcPanelLoaderVtable default_panels[] =
//PANEL_TYPE("keyboard", cc_keyboard_panel_get_type, NULL),
PANEL_TYPE("location", cc_location_panel_get_type, NULL),
PANEL_TYPE("lock", cc_lock_panel_get_type, NULL),
- //PANEL_TYPE("microphone", cc_microphone_panel_get_type, NULL),
+ PANEL_TYPE("microphone", cc_microphone_panel_get_type, NULL),
//PANEL_TYPE("mouse", cc_mouse_panel_get_type, NULL),
//PANEL_TYPE("multitasking", cc_multitasking_panel_get_type, NULL),
#ifdef BUILD_NETWORK
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]