Skip to content

File tree

10 files changed

+96
-55
lines changed

10 files changed

+96
-55
lines changed

‎applets/clock/Makefile.am‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@ CLOCK_CPPFLAGS = \
4242
-I$(srcdir)/../../libmate-panel-applet \
4343
-I$(top_builddir)/libmate-panel-applet \
4444
-DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
45-
-DBUILDERDIR=\""$(uidir)"\" \
46-
-DCLOCK_MENU_UI_DIR=\""$(xmluidir)"\" \
47-
-DICONDIR=\""$(datadir)/mate-panel/pixmaps"\" \
4845
-DMATEWEATHER_I_KNOW_THIS_IS_UNSTABLE
4946

5047
CLOCK_LDADD = \
@@ -122,6 +119,8 @@ clock-typebuiltins.h: @REBUILD@ $(clock_enum_headers)
122119
BUILT_SOURCES = \
123120
clock-marshallers.c \
124121
clock-marshallers.h \
122+
clock-resources.c \
123+
clock-resources.h \
125124
clock-typebuiltins.c \
126125
clock-typebuiltins.h
127126

@@ -149,11 +148,15 @@ org.mate.panel.applet.ClockAppletFactory.service: $(service_in_files)
149148
$< > $@
150149
endif
151150

152-
uidir = $(datadir)/mate-panel/ui
153-
ui_DATA = clock.ui
151+
ui_FILES = \
152+
clock.ui \
153+
clock-menu.xml
154154

155-
xmluidir = $(datadir)/mate-panel/ui
156-
xmlui_DATA = clock-menu.xml
155+
clock-resources.c: clock.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/clock.gresource.xml)
156+
$(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name clock $<
157+
158+
clock-resources.h: clock.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/clock.gresource.xml)
159+
$(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name clock $<
157160

158161
clock_gschemas_in = org.mate.panel.applet.clock.gschema.xml.in
159162
gsettings_SCHEMAS = $(clock_gschemas_in:.xml.in=.xml)
@@ -164,8 +167,8 @@ gsettings_SCHEMAS = $(clock_gschemas_in:.xml.in=.xml)
164167
EXTRA_DIST = \
165168
org.mate.panel.ClockApplet.mate-panel-applet.in.in \
166169
$(clock_gschemas_in) \
167-
$(xmlui_DATA) \
168-
$(ui_DATA) \
170+
$(ui_FILES) \
171+
clock.gresource.xml \
169172
clock-marshallers.list \
170173
$(service_in_files)
171174

‎applets/clock/clock-face.c‎

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <math.h>
1616
#include <time.h>
1717

18+
#include "clock.h"
1819
#include "clock-face.h"
1920
#include "clock-location.h"
2021
#include "clock-utils.h"
@@ -436,18 +437,22 @@ clock_face_load_face (ClockFace *this, gint width, gint height)
436437
return;
437438
}
438439

439-
/* The pixbuf is not cached, let's load it */
440-
name = g_strconcat (ICONDIR, "/clock-face-", size_string[priv->size],
441-
"-", daytime_string[priv->timeofday], ".svg",
442-
NULL);
443-
priv->face_pixbuf = clock_utils_pixbuf_from_svg_file_at_size (name, width, height);
440+
/* The pixbuf is not cached, let's load it */
441+
name = g_strconcat (CLOCK_RESOURCE_PATH "icons/",
442+
"clock-face-", size_string[priv->size],
443+
"-", daytime_string[priv->timeofday], ".svg",
444+
NULL);
445+
priv->face_pixbuf = clock_utils_pixbuf_from_svg_resource_at_size (name,
446+
width, height);
444447
g_free (name);
445448

446449
if (!priv->face_pixbuf) {
447-
name = g_strconcat (ICONDIR, "/clock-face-",
448-
size_string[priv->size], ".svg", NULL);
449-
priv->face_pixbuf = clock_utils_pixbuf_from_svg_file_at_size (name, width, height);
450-
g_free (name);
450+
name = g_strconcat (CLOCK_RESOURCE_PATH "icons/",
451+
"clock-face-", size_string[priv->size], ".svg",
452+
NULL);
453+
priv->face_pixbuf = clock_utils_pixbuf_from_svg_resource_at_size (name,
454+
width, height);
455+
g_free (name);
451456
}
452457

453458
/* Save the found pixbuf in the cache */

‎applets/clock/clock-map.c‎

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ enum {
2727
};
2828

2929
static char *marker_files[MARKER_NB] = {
30-
ICONDIR "/clock-map-location-marker.png",
31-
ICONDIR "/clock-map-location-hilight.png",
32-
ICONDIR "/clock-map-location-current.png"
30+
"clock-map-location-marker.png",
31+
"clock-map-location-hilight.png",
32+
"clock-map-location-current.png"
3333
};
3434

3535
static guint signals[LAST_SIGNAL] = { 0 };
@@ -135,8 +135,17 @@ clock_map_init (ClockMap *this)
135135
g_assert (sizeof (marker_files)/sizeof (char *) == MARKER_NB);
136136

137137
for (i = 0; i < MARKER_NB; i++) {
138-
priv->location_marker_pixbuf[i] = gdk_pixbuf_new_from_file
139-
(marker_files[i], NULL);
138+
char *resource;
139+
GInputStream *stream;
140+
141+
resource = g_strconcat (CLOCK_RESOURCE_PATH "icons/", marker_files[i], NULL);
142+
stream = g_resources_open_stream (resource, 0, NULL);
143+
g_free (resource);
144+
145+
if (stream != NULL) {
146+
priv->location_marker_pixbuf[i] = gdk_pixbuf_new_from_stream (stream, NULL, NULL);
147+
g_object_unref (stream);
148+
}
140149
}
141150
}
142151

@@ -208,11 +217,17 @@ clock_map_refresh (ClockMap *this)
208217
}
209218

210219
if (!priv->stock_map_pixbuf) {
211-
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale
212-
(ICONDIR "/clock-map.png",
213-
priv->width, priv->height, FALSE, NULL);
214-
215-
priv->stock_map_pixbuf = pixbuf;
220+
GInputStream *stream = g_resources_open_stream (CLOCK_RESOURCE_PATH "icons/clock-map.png",
221+
0, NULL);
222+
if (stream != NULL) {
223+
GdkPixbuf *pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream,
224+
priv->width, priv->height,
225+
FALSE,
226+
NULL, NULL);
227+
g_object_unref (stream);
228+
229+
priv->stock_map_pixbuf = pixbuf;
230+
}
216231
}
217232

218233
clock_map_place_locations (this);

‎applets/clock/clock-utils.c‎

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,18 +128,28 @@ clock_utils_display_help (GtkWidget *widget,
128128
}
129129

130130
GdkPixbuf *
131-
clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int height)
131+
clock_utils_pixbuf_from_svg_resource_at_size (const char *resource,
132+
int width,
133+
int height)
132134
{
135+
GInputStream *stream = NULL;
133136
RsvgHandle *handle = NULL;
134137
RsvgDimensionData svg_dimensions;
135138
GdkPixbuf *pixbuf = NULL;
136139
cairo_surface_t *surface = NULL;
137140
cairo_matrix_t matrix;
138141
cairo_t *cr = NULL;
139142

140-
handle = rsvg_handle_new_from_file (name, NULL);
143+
stream = g_resources_open_stream (resource, 0, NULL);
144+
if (!stream)
145+
goto out;
146+
147+
handle = rsvg_handle_new ();
141148
if (!handle)
142-
return NULL;
149+
goto out;
150+
151+
if (!rsvg_handle_read_stream_sync (handle, stream, NULL, NULL))
152+
goto out;
143153

144154
rsvg_handle_get_dimensions (handle, &svg_dimensions);
145155

@@ -155,7 +165,11 @@ clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int heigh
155165
pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height);
156166
cairo_surface_destroy (surface);
157167

158-
rsvg_handle_close (handle, NULL);
168+
out:
169+
if (handle)
170+
rsvg_handle_close (handle, NULL);
171+
if (stream)
172+
g_object_unref (stream);
159173

160174
return pixbuf;
161175
}

‎applets/clock/clock-utils.h‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ void clock_utils_display_help (GtkWidget *widget,
5050
const char *doc_id,
5151
const char *link_id);
5252

53-
GdkPixbuf * clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int height);
53+
GdkPixbuf *clock_utils_pixbuf_from_svg_resource_at_size (const char *resource,
54+
int width,
55+
int height);
5456

5557
#ifdef __cplusplus
5658
}

‎applets/clock/clock.c‎

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2377,9 +2377,6 @@ fill_clock_applet (MatePanelApplet *applet)
23772377
ClockData *cd;
23782378
GtkActionGroup *action_group;
23792379
GtkAction *action;
2380-
gchar *ui_path;
2381-
char *filename;
2382-
GError *error;
23832380

23842381
mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR);
23852382

@@ -2394,17 +2391,7 @@ fill_clock_applet (MatePanelApplet *applet)
23942391

23952392
cd->builder = gtk_builder_new ();
23962393
gtk_builder_set_translation_domain (cd->builder, GETTEXT_PACKAGE);
2397-
filename = g_build_filename (BUILDERDIR, "clock.ui", NULL);
2398-
2399-
error = NULL;
2400-
gtk_builder_add_from_file (cd->builder, filename, &error);
2401-
if (error) {
2402-
g_warning ("Error loading \"%s\": %s",
2403-
filename, error->message);
2404-
g_error_free (error);
2405-
}
2406-
2407-
g_free (filename);
2394+
gtk_builder_add_from_resource (cd->builder, CLOCK_RESOURCE_PATH "clock.ui", NULL);
24082395

24092396
create_clock_widget (cd);
24102397

@@ -2436,10 +2423,9 @@ fill_clock_applet (MatePanelApplet *applet)
24362423
clock_menu_actions,
24372424
G_N_ELEMENTS (clock_menu_actions),
24382425
cd);
2439-
ui_path = g_build_filename (CLOCK_MENU_UI_DIR, "clock-menu.xml", NULL);
2440-
mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (cd->applet),
2441-
ui_path, action_group);
2442-
g_free (ui_path);
2426+
mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (cd->applet),
2427+
CLOCK_RESOURCE_PATH "clock-menu.xml",
2428+
action_group);
24432429

24442430
if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (cd->applet))) {
24452431
action = gtk_action_group_get_action (action_group, "ClockPreferences");

‎applets/clock/clock.gresource.xml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<gresources>
3+
<gresource prefix="/org/mate/panel/applet/clock">
4+
<file compressed="true">clock.ui</file>
5+
<file compressed="true">clock-menu.xml</file>
6+
<file alias="icons/clock-face-large.svg">pixmaps/clock-face-large.svg</file>
7+
<file alias="icons/clock-face-small.svg">pixmaps/clock-face-small.svg</file>
8+
<file alias="icons/clock-face-small-morning.svg">pixmaps/clock-face-small-morning.svg</file>
9+
<file alias="icons/clock-face-small-day.svg">pixmaps/clock-face-small-day.svg</file>
10+
<file alias="icons/clock-face-small-evening.svg">pixmaps/clock-face-small-evening.svg</file>
11+
<file alias="icons/clock-face-small-night.svg">pixmaps/clock-face-small-night.svg</file>
12+
<file alias="icons/clock-map.png">pixmaps/clock-map.png</file>
13+
<file alias="icons/clock-map-location-marker.png">pixmaps/clock-map-location-marker.png</file>
14+
<file alias="icons/clock-map-location-current.png">pixmaps/clock-map-location-current.png</file>
15+
<file alias="icons/clock-map-location-hilight.png">pixmaps/clock-map-location-hilight.png</file>
16+
</gresource>
17+
</gresources>

‎applets/clock/clock.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ extern "C" {
3232
#endif
3333

3434
#define CLOCK_ICON "mate-panel-clock"
35+
#define CLOCK_RESOURCE_PATH "/org/mate/panel/applet/clock/"
3536
#define CLOCK_SCHEMA "org.mate.panel.applet.clock"
3637

3738
#ifdef __cplusplus

‎applets/clock/pixmaps/Makefile.am‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
icondir = $(datadir)/mate-panel/pixmaps
2-
icon_DATA = \
3-
clock-calendar-icon.png \
1+
icon_FILES = \
42
clock-face-large.svg \
53
clock-face-small.svg \
64
clock-face-small-morning.svg \
@@ -14,7 +12,7 @@ icon_DATA = \
1412

1513
EXTRA_DIST = \
1614
clock-map.svg \
17-
$(icon_DATA)
15+
$(icon_FILES)
1816

1917
MAINTAINERCLEANFILES = Makefile.in
2018

-653 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)