1
|
|
-From b1557a160790a46e678c6bf41165265bf8669760 Mon Sep 17 00:00:00 2001
|
2
|
|
-From: Victor Kareh <vkareh@redhat.com>
|
3
|
|
-Date: Thu, 25 Apr 2019 12:32:44 -0400
|
4
|
|
-Subject: [PATCH] Resize indicator icons to fit panel
|
5
|
|
-
|
6
|
|
-This fixes two issues:
|
7
|
|
-* Some indicators have icons that are not the correct size (e.g. scalable 256px)
|
8
|
|
- and so they clip on the panel and look ugly.
|
9
|
|
-* When resizing the panel, indicators stay the same size. This updates
|
10
|
|
- the indicator icons so that they resize along with the panel.
|
11
|
|
----
|
12
|
|
- src/applet-main.c | 48 ++++++++++++++++++++++++++++++++++++++---------
|
13
|
|
- 1 file changed, 39 insertions(+), 9 deletions(-)
|
14
|
|
-
|
15
|
|
---- a/src/applet-main.c
|
16
|
|
-+++ b/src/applet-main.c
|
17
|
|
-@@ -96,6 +96,7 @@
|
18
|
|
-
|
19
|
|
- static GtkPackDirection packdirection;
|
20
|
|
- static MatePanelAppletOrient orient;
|
21
|
|
-+static guint size;
|
22
|
|
-
|
23
|
|
- #define MENU_DATA_INDICATOR_OBJECT "indicator-object"
|
24
|
|
- #define MENU_DATA_INDICATOR_ENTRY "indicator-entry"
|
25
|
|
-@@ -323,6 +324,29 @@
|
26
|
|
- return;
|
27
|
|
- }
|
28
|
|
-
|
29
|
|
-+#define PANEL_PADDING 8
|
30
|
|
-+static gboolean
|
31
|
|
-+entry_resized (GtkWidget *applet, guint newsize, gpointer data)
|
32
|
|
-+{
|
33
|
|
-+ IndicatorObject *io = (IndicatorObject *)data;
|
34
|
|
-+
|
35
|
|
-+ size = newsize;
|
36
|
|
-+
|
37
|
|
-+ /* Work on the entries */
|
38
|
|
-+ GList * entries = indicator_object_get_entries(io);
|
39
|
|
-+ GList * entry = NULL;
|
40
|
|
-+
|
41
|
|
-+ for (entry = entries; entry != NULL; entry = g_list_next(entry)) {
|
42
|
|
-+ IndicatorObjectEntry * entrydata = (IndicatorObjectEntry *)entry->data;
|
43
|
|
-+ if (entrydata->image != NULL) {
|
44
|
|
-+ /* Resize to fit panel */
|
45
|
|
-+ gtk_image_set_pixel_size (entrydata->image, size - PANEL_PADDING);
|
46
|
|
-+ }
|
47
|
|
-+ }
|
48
|
|
-+
|
49
|
|
-+ return FALSE;
|
50
|
|
-+}
|
51
|
|
-+
|
52
|
|
- static void
|
53
|
|
- entry_added (IndicatorObject * io, IndicatorObjectEntry * entry, GtkWidget * menubar)
|
54
|
|
- {
|
55
|
|
-@@ -344,6 +368,8 @@
|
56
|
|
- g_signal_connect(G_OBJECT(menuitem), "scroll-event", G_CALLBACK(entry_scrolled), entry);
|
57
|
|
-
|
58
|
|
- if (entry->image != NULL) {
|
59
|
|
-+ /* Resize to fit panel */
|
60
|
|
-+ gtk_image_set_pixel_size (entry->image, size - PANEL_PADDING);
|
61
|
|
- gtk_box_pack_start(GTK_BOX(box), GTK_WIDGET(entry->image), FALSE, FALSE, 1);
|
62
|
|
- if (gtk_widget_get_visible(GTK_WIDGET(entry->image))) {
|
63
|
|
- something_visible = TRUE;
|
64
|
|
-@@ -552,7 +578,7 @@
|
65
|
|
- }
|
66
|
|
-
|
67
|
|
- static void
|
68
|
|
--load_indicator (GtkWidget * menubar, IndicatorObject *io, const gchar *name)
|
69
|
|
-+load_indicator (MatePanelApplet *applet, GtkWidget * menubar, IndicatorObject *io, const gchar *name)
|
70
|
|
- {
|
71
|
|
- /* Set the environment it's in */
|
72
|
|
- indicator_object_set_environment(io, (const GStrv)indicator_env);
|
73
|
|
-@@ -576,6 +602,9 @@
|
74
|
|
- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_MENU_SHOW, G_CALLBACK(menu_show), menubar);
|
75
|
|
- g_signal_connect(G_OBJECT(io), INDICATOR_OBJECT_SIGNAL_ACCESSIBLE_DESC_UPDATE, G_CALLBACK(accessible_desc_update), menubar);
|
76
|
|
-
|
77
|
|
-+ /* Track panel resize */
|
78
|
|
-+ g_signal_connect_object(G_OBJECT(applet), "change-size", G_CALLBACK(entry_resized), G_OBJECT(io), 0);
|
79
|
|
-+
|
80
|
|
- /* Work on the entries */
|
81
|
|
- GList * entries = indicator_object_get_entries(io);
|
82
|
|
- GList * entry = NULL;
|
83
|
|
-@@ -589,7 +618,7 @@
|
84
|
|
- }
|
85
|
|
-
|
86
|
|
- static gboolean
|
87
|
|
--load_module (const gchar * name, GtkWidget * menubar)
|
88
|
|
-+load_module (const gchar * name, MatePanelApplet *applet, GtkWidget * menubar)
|
89
|
|
- {
|
90
|
|
- g_debug("Looking at Module: %s", name);
|
91
|
|
- g_return_val_if_fail(name != NULL, FALSE);
|
92
|
|
-@@ -605,13 +634,13 @@
|
93
|
|
- IndicatorObject * io = indicator_object_new_from_file(fullpath);
|
94
|
|
- g_free(fullpath);
|
95
|
|
-
|
96
|
|
-- load_indicator(menubar, io, name);
|
97
|
|
-+ load_indicator(applet, menubar, io, name);
|
98
|
|
-
|
99
|
|
- return TRUE;
|
100
|
|
- }
|
101
|
|
-
|
102
|
|
- static void
|
103
|
|
--load_modules (GtkWidget *menubar, gint *indicators_loaded)
|
104
|
|
-+load_modules (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
|
105
|
|
- {
|
106
|
|
- if (g_file_test(INDICATOR_DIR, (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR))) {
|
107
|
|
- GDir * dir = g_dir_open(INDICATOR_DIR, 0, NULL);
|
108
|
|
-@@ -636,7 +665,7 @@
|
109
|
|
- continue;
|
110
|
|
- }
|
111
|
|
- #endif
|
112
|
|
-- if (load_module(name, menubar)) {
|
113
|
|
-+ if (load_module(name, applet, menubar)) {
|
114
|
|
- count++;
|
115
|
|
- }
|
116
|
|
- }
|
117
|
|
-@@ -650,7 +679,7 @@
|
118
|
|
- #if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
|
119
|
|
-
|
120
|
|
- static void
|
121
|
|
--load_indicators_from_indicator_files (GtkWidget *menubar, gint *indicators_loaded)
|
122
|
|
-+load_indicators_from_indicator_files (MatePanelApplet *applet, GtkWidget *menubar, gint *indicators_loaded)
|
123
|
|
- {
|
124
|
|
- GDir *dir;
|
125
|
|
- const gchar *name;
|
126
|
|
-@@ -693,7 +722,7 @@
|
127
|
|
- #endif
|
128
|
|
-
|
129
|
|
- if (indicator) {
|
130
|
|
-- load_indicator(menubar, INDICATOR_OBJECT (indicator), name);
|
131
|
|
-+ load_indicator(applet, menubar, INDICATOR_OBJECT (indicator), name);
|
132
|
|
- count++;
|
133
|
|
- }else{
|
134
|
|
- g_warning ("unable to load '%s': %s", name, error->message);
|
135
|
|
-@@ -993,6 +1022,7 @@
|
136
|
|
- gtk_widget_set_name(GTK_WIDGET (applet), "fast-user-switch-applet");
|
137
|
|
-
|
138
|
|
- /* Build menubar */
|
139
|
|
-+ size = (mate_panel_applet_get_size (applet));
|
140
|
|
- orient = (mate_panel_applet_get_orient(applet));
|
141
|
|
- packdirection = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
|
142
|
|
- (orient == MATE_PANEL_APPLET_ORIENT_DOWN)) ?
|
143
|
|
-@@ -1010,9 +1040,9 @@
|
144
|
|
- /* Add in filter func */
|
145
|
|
- tomboy_keybinder_bind(hotkey_keycode, hotkey_filter, menubar);
|
146
|
|
-
|
147
|
|
-- load_modules(menubar, &indicators_loaded);
|
148
|
|
-+ load_modules(applet, menubar, &indicators_loaded);
|
149
|
|
- #if HAVE_AYATANA_INDICATOR_NG || HAVE_UBUNTU_INDICATOR_NG
|
150
|
|
-- load_indicators_from_indicator_files(menubar, &indicators_loaded);
|
151
|
|
-+ load_indicators_from_indicator_files(applet, menubar, &indicators_loaded);
|
152
|
|
- #endif
|
153
|
|
-
|
154
|
|
- if (indicators_loaded == 0) {
|