Line |
Branch |
Exec |
Source |
1 |
|
|
/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- |
2 |
|
|
* |
3 |
|
|
* Copyright (C) 2017 Mohammed Sadiq <sadiq@sadiqpk.org> |
4 |
|
|
* Copyright (C) 2010 Red Hat, Inc |
5 |
|
|
* Copyright (C) 2008 William Jon McCann <jmccann@redhat.com> |
6 |
|
|
* |
7 |
|
|
* This program is free software; you can redistribute it and/or modify |
8 |
|
|
* it under the terms of the GNU General Public License as published by |
9 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
10 |
|
|
* (at your option) any later version. |
11 |
|
|
* |
12 |
|
|
* This program is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
19 |
|
|
* |
20 |
|
|
*/ |
21 |
|
|
|
22 |
|
|
#include <config.h> |
23 |
|
|
#ifdef BUILD_WWAN |
24 |
|
|
#include <libmm-glib.h> |
25 |
|
|
#endif |
26 |
|
|
|
27 |
|
|
#include "cc-default-apps-page.h" |
28 |
|
|
#include "cc-default-apps-row.h" |
29 |
|
|
|
30 |
|
|
#include "shell/cc-object-storage.h" |
31 |
|
|
|
32 |
|
|
typedef struct |
33 |
|
|
{ |
34 |
|
|
const char *content_type; |
35 |
|
|
/* Patterns used to filter supported mime types |
36 |
|
|
when changing preferred applications. NULL |
37 |
|
|
means no other types should be changed */ |
38 |
|
|
const char *extra_type_filter; |
39 |
|
|
} DefaultAppData; |
40 |
|
|
|
41 |
|
|
struct _CcDefaultAppsPage |
42 |
|
|
{ |
43 |
|
|
AdwPreferencesGroup parent; |
44 |
|
|
|
45 |
|
|
GtkWidget *web_row; |
46 |
|
|
GtkWidget *mail_row; |
47 |
|
|
GtkWidget *calendar_row; |
48 |
|
|
GtkWidget *music_row; |
49 |
|
|
GtkWidget *video_row; |
50 |
|
|
GtkWidget *photos_row; |
51 |
|
|
GtkWidget *calls_row; |
52 |
|
|
GtkWidget *sms_row; |
53 |
|
|
|
54 |
|
|
#ifdef BUILD_WWAN |
55 |
|
|
MMManager *mm_manager; |
56 |
|
|
#endif |
57 |
|
|
}; |
58 |
|
|
|
59 |
|
|
|
60 |
|
✗ |
G_DEFINE_TYPE (CcDefaultAppsPage, cc_default_apps_page, ADW_TYPE_PREFERENCES_GROUP) |
61 |
|
|
|
62 |
|
|
#ifdef BUILD_WWAN |
63 |
|
|
static void |
64 |
|
✗ |
update_modem_apps_visibility (CcDefaultAppsPage *self) |
65 |
|
|
{ |
66 |
|
|
GList *devices; |
67 |
|
|
gboolean has_mm_objects; |
68 |
|
|
|
69 |
|
✗ |
devices = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (self->mm_manager)); |
70 |
|
✗ |
has_mm_objects = g_list_length (devices) > 0; |
71 |
|
|
|
72 |
|
✗ |
gtk_widget_set_visible (self->calls_row, has_mm_objects); |
73 |
|
✗ |
gtk_widget_set_visible (self->sms_row, has_mm_objects); |
74 |
|
|
|
75 |
|
✗ |
g_list_free_full (devices, (GDestroyNotify)g_object_unref); |
76 |
|
✗ |
} |
77 |
|
|
#endif |
78 |
|
|
|
79 |
|
|
static void |
80 |
|
✗ |
on_row_selected_item_changed (CcDefaultAppsRow *row) |
81 |
|
|
{ |
82 |
|
✗ |
cc_default_apps_row_update_default_app (row); |
83 |
|
✗ |
} |
84 |
|
|
|
85 |
|
|
static void |
86 |
|
✗ |
cc_default_apps_page_class_init (CcDefaultAppsPageClass *klass) |
87 |
|
|
{ |
88 |
|
✗ |
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); |
89 |
|
|
|
90 |
|
✗ |
gtk_widget_class_set_template_from_resource (widget_class, "/org/gnome/control-center/applications/cc-default-apps-page.ui"); |
91 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, web_row); |
92 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, mail_row); |
93 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, calendar_row); |
94 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, music_row); |
95 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, video_row); |
96 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, photos_row); |
97 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, calls_row); |
98 |
|
✗ |
gtk_widget_class_bind_template_child (widget_class, CcDefaultAppsPage, sms_row); |
99 |
|
|
|
100 |
|
✗ |
gtk_widget_class_bind_template_callback (widget_class, on_row_selected_item_changed); |
101 |
|
✗ |
} |
102 |
|
|
|
103 |
|
|
static void |
104 |
|
✗ |
cc_default_apps_page_init (CcDefaultAppsPage *self) |
105 |
|
|
{ |
106 |
|
✗ |
g_type_ensure (CC_TYPE_DEFAULT_APPS_ROW); |
107 |
|
|
|
108 |
|
✗ |
gtk_widget_init_template (GTK_WIDGET (self)); |
109 |
|
|
|
110 |
|
|
#ifdef BUILD_WWAN |
111 |
|
✗ |
if (cc_object_storage_has_object ("CcObjectStorage::mm-manager")) |
112 |
|
|
{ |
113 |
|
✗ |
self->mm_manager = cc_object_storage_get_object ("CcObjectStorage::mm-manager"); |
114 |
|
|
|
115 |
|
✗ |
g_signal_connect_swapped (self->mm_manager, "object-added", |
116 |
|
|
G_CALLBACK (update_modem_apps_visibility), self); |
117 |
|
✗ |
g_signal_connect_swapped (self->mm_manager, "object-removed", |
118 |
|
|
G_CALLBACK (update_modem_apps_visibility), self); |
119 |
|
|
|
120 |
|
✗ |
update_modem_apps_visibility (self); |
121 |
|
|
} |
122 |
|
|
#endif |
123 |
|
✗ |
} |
124 |
|
|
|
125 |
|
|
CcDefaultAppsPage * |
126 |
|
✗ |
cc_default_apps_page_new (void) |
127 |
|
|
{ |
128 |
|
✗ |
return g_object_new (CC_TYPE_DEFAULT_APPS_PAGE, |
129 |
|
|
NULL); |
130 |
|
|
} |
131 |
|
|
|