location: Port to GTK4
An almost trivial port too.
This commit is contained in:
parent
26630338ba
commit
449c55be3a
4 changed files with 123 additions and 144 deletions
|
@ -18,7 +18,6 @@
|
|||
* Author: Matthias Clasen <mclasen@redhat.com>
|
||||
*/
|
||||
|
||||
#include "list-box-helper.h"
|
||||
#include "cc-location-panel.h"
|
||||
#include "cc-location-resources.h"
|
||||
#include "cc-util.h"
|
||||
|
@ -170,52 +169,46 @@ add_location_app (CcLocationPanel *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->location_apps_list_box), row);
|
||||
gtk_list_box_row_set_child (GTK_LIST_BOX_ROW (row), box);
|
||||
gtk_list_box_append (self->location_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->location_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, FALSE, FALSE, 0);
|
||||
gtk_box_append (GTK_BOX (box), w);
|
||||
|
||||
t = g_date_time_new_from_unix_utc (last_used);
|
||||
last_used_str = cc_util_get_smart_date (t);
|
||||
w = gtk_label_new (last_used_str);
|
||||
gtk_widget_show (w);
|
||||
g_free (last_used_str);
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (w), "dim-label");
|
||||
gtk_widget_set_margin_start (w, 12);
|
||||
gtk_widget_set_margin_end (w, 12);
|
||||
gtk_widget_set_halign (w, GTK_ALIGN_END);
|
||||
gtk_widget_set_valign (w, GTK_ALIGN_CENTER);
|
||||
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->location_settings, LOCATION_ENABLED,
|
||||
w, "sensitive",
|
||||
G_SETTINGS_BIND_DEFAULT);
|
||||
|
@ -396,12 +389,9 @@ cc_location_panel_constructed (GObject *object)
|
|||
G_OBJECT_CLASS (cc_location_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_container_add (GTK_CONTAINER (box), widget);
|
||||
gtk_box_append (GTK_BOX (box), widget);
|
||||
|
||||
g_settings_bind (self->location_settings,
|
||||
LOCATION_ENABLED,
|
||||
|
@ -448,9 +438,6 @@ cc_location_panel_init (CcLocationPanel *self)
|
|||
|
||||
gtk_widget_init_template (GTK_WIDGET (self));
|
||||
|
||||
gtk_list_box_set_header_func (self->location_apps_list_box,
|
||||
cc_list_box_update_header_func,
|
||||
NULL, NULL);
|
||||
self->location_icon_size_group = gtk_size_group_new (GTK_SIZE_GROUP_BOTH);
|
||||
self->location_settings = g_settings_new ("org.gnome.system.location");
|
||||
|
||||
|
|
|
@ -3,135 +3,127 @@
|
|||
<interface>
|
||||
<requires lib="gtk+" version="3.14"/>
|
||||
<template class="CcLocationPanel" 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">location-services-disabled-symbolic</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</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">Location services 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 obtain location information.</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<object class="GtkStackPage">
|
||||
<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>
|
||||
|
||||
<property name="child">
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="valign">center</property>
|
||||
<child>
|
||||
<object class="GtkBox">
|
||||
<property name="visible">true</property>
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="location_description_label">
|
||||
<property name="visible">true</property>
|
||||
<property name="label" translatable="yes">Location services allow applications to know your location. Using Wi-Fi and mobile broadband increases accuracy.</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="location_privacy_policy_label">
|
||||
<property name="visible">true</property>
|
||||
<property name="label" translatable="yes">Uses Mozilla Location Service: <a href='https://location.services.mozilla.com/privacy'>Privacy Policy</a></property>
|
||||
<property name="use-markup">1</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="location_apps_label">
|
||||
<property name="visible">true</property>
|
||||
<property name="halign">start</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="label" translatable="yes">Allow the applications below to determine your location.</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBox" id="location_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>
|
||||
|
||||
<child type="placeholder">
|
||||
<object class="GtkLabel">
|
||||
<property name="visible">true</property>
|
||||
<property name="margin">18</property>
|
||||
<property name="label" translatable="yes">No Applications Have Asked for Location 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 class="GtkImage">
|
||||
<property name="valign">start</property>
|
||||
<property name="pixel-size">96</property>
|
||||
<property name="icon-name">location-services-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">Location services 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 obtain location information.</property>
|
||||
<style>
|
||||
<class name="dim-label"/>
|
||||
</style>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="name">content</property>
|
||||
</packing>
|
||||
</child>
|
||||
|
||||
<child>
|
||||
<object class="GtkStackPage">
|
||||
<property name="name">content</property>
|
||||
<property name="child">
|
||||
<object class="GtkScrolledWindow">
|
||||
<property name="hscrollbar-policy">never</property>
|
||||
<child>
|
||||
<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>
|
||||
<object class="GtkBox">
|
||||
<property name="orientation">vertical</property>
|
||||
<property name="hexpand">1</property>
|
||||
<property name="spacing">12</property>
|
||||
<child>
|
||||
<object class="GtkLabel" id="location_description_label">
|
||||
<property name="label" translatable="yes">Location services allow applications to know your location. Using Wi-Fi and mobile broadband increases accuracy.</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="location_privacy_policy_label">
|
||||
<property name="label" translatable="yes">Uses Mozilla Location Service: <a href='https://location.services.mozilla.com/privacy'>Privacy Policy</a></property>
|
||||
<property name="use-markup">1</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="max-width-chars">50</property>
|
||||
<property name="xalign">0</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkLabel" id="location_apps_label">
|
||||
<property name="halign">start</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="wrap">1</property>
|
||||
<property name="label" translatable="yes">Allow the applications below to determine your location.</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkListBox" id="location_apps_list_box">
|
||||
<property name="selection-mode">none</property>
|
||||
<style>
|
||||
<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 Location 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>
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
||||
</object>
|
||||
</child>
|
||||
</template>
|
||||
|
|
|
@ -11,7 +11,7 @@ panels = [
|
|||
# 'display',
|
||||
'info-overview',
|
||||
# 'keyboard',
|
||||
# 'location',
|
||||
'location',
|
||||
# 'lock',
|
||||
# 'microphone',
|
||||
# 'mouse',
|
||||
|
|
|
@ -68,7 +68,7 @@ extern GType cc_ua_panel_get_type (void);
|
|||
#ifdef BUILD_WWAN
|
||||
//extern GType cc_wwan_panel_get_type (void);
|
||||
#endif /* BUILD_WWAN */
|
||||
//extern GType cc_location_panel_get_type (void);
|
||||
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_usage_panel_get_type (void);
|
||||
|
@ -110,7 +110,7 @@ static CcPanelLoaderVtable default_panels[] =
|
|||
//PANEL_TYPE("display", cc_display_panel_get_type, NULL),
|
||||
PANEL_TYPE("info-overview", cc_info_overview_panel_get_type, NULL),
|
||||
//PANEL_TYPE("keyboard", cc_keyboard_panel_get_type, NULL),
|
||||
//PANEL_TYPE("location", cc_location_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("mouse", cc_mouse_panel_get_type, NULL),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue