diff options
author | Vincent Untz <[email protected]> | 2012-02-02 14:04:27 +0100 |
---|---|---|
committer | raveit65 <[email protected]> | 2018-04-26 13:04:47 +0200 |
commit | dcb6025f4f4a0aadda5fea831d0cb520d2201b15 (patch) | |
tree | 4f91b5a0316630cd99ae0b2e224c2179b1d2aa80 /applets | |
parent | 0e8b631161bc33e75bf0663ce4f5849bb60355ec (diff) | |
download | mate-panel-dcb6025f4f4a0aadda5fea831d0cb520d2201b15.tar.bz2 mate-panel-dcb6025f4f4a0aadda5fea831d0cb520d2201b15.tar.xz |
clock: Convert to GResource
origin commits:
https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=aa2895d
https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=695d30c
https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=00f9870
https://git.gnome.org/browse/gnome-panel/commit/?h=gnome-3-4&id=9ade365
Diffstat (limited to 'applets')
-rw-r--r-- | applets/clock/Makefile.am | 21 | ||||
-rw-r--r-- | applets/clock/clock-face.c | 23 | ||||
-rw-r--r-- | applets/clock/clock-map.c | 35 | ||||
-rw-r--r-- | applets/clock/clock-utils.c | 22 | ||||
-rw-r--r-- | applets/clock/clock-utils.h | 4 | ||||
-rw-r--r-- | applets/clock/clock.c | 22 | ||||
-rw-r--r-- | applets/clock/clock.gresource.xml | 17 | ||||
-rw-r--r-- | applets/clock/clock.h | 1 | ||||
-rw-r--r-- | applets/clock/pixmaps/Makefile.am | 6 | ||||
-rw-r--r-- | applets/clock/pixmaps/clock-calendar-icon.png | bin | 653 -> 0 bytes |
10 files changed, 96 insertions, 55 deletions
diff --git a/applets/clock/Makefile.am b/applets/clock/Makefile.am index 5d1c4bfc..3b390974 100644 --- a/applets/clock/Makefile.am +++ b/applets/clock/Makefile.am @@ -42,9 +42,6 @@ CLOCK_CPPFLAGS = \ -I$(srcdir)/../../libmate-panel-applet \ -I$(top_builddir)/libmate-panel-applet \ -DMATELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \ - -DBUILDERDIR=\""$(uidir)"\" \ - -DCLOCK_MENU_UI_DIR=\""$(xmluidir)"\" \ - -DICONDIR=\""$(datadir)/mate-panel/pixmaps"\" \ -DMATEWEATHER_I_KNOW_THIS_IS_UNSTABLE CLOCK_LDADD = \ @@ -122,6 +119,8 @@ clock-typebuiltins.h: @REBUILD@ $(clock_enum_headers) BUILT_SOURCES = \ clock-marshallers.c \ clock-marshallers.h \ + clock-resources.c \ + clock-resources.h \ clock-typebuiltins.c \ clock-typebuiltins.h @@ -149,11 +148,15 @@ org.mate.panel.applet.ClockAppletFactory.service: $(service_in_files) $< > $@ endif -uidir = $(datadir)/mate-panel/ui -ui_DATA = clock.ui +ui_FILES = \ + clock.ui \ + clock-menu.xml -xmluidir = $(datadir)/mate-panel/ui -xmlui_DATA = clock-menu.xml +clock-resources.c: clock.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/clock.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name clock $< + +clock-resources.h: clock.gresource.xml $(shell $(GLIB_COMPILE_RESOURCES) --sourcedir=$(srcdir) --generate-dependencies $(srcdir)/clock.gresource.xml) + $(AM_V_GEN)$(GLIB_COMPILE_RESOURCES) --target=$@ --sourcedir=$(srcdir) --generate --c-name clock $< clock_gschemas_in = org.mate.panel.applet.clock.gschema.xml.in gsettings_SCHEMAS = $(clock_gschemas_in:.xml.in=.xml) @@ -164,8 +167,8 @@ gsettings_SCHEMAS = $(clock_gschemas_in:.xml.in=.xml) EXTRA_DIST = \ org.mate.panel.ClockApplet.mate-panel-applet.in.in \ $(clock_gschemas_in) \ - $(xmlui_DATA) \ - $(ui_DATA) \ + $(ui_FILES) \ + clock.gresource.xml \ clock-marshallers.list \ $(service_in_files) diff --git a/applets/clock/clock-face.c b/applets/clock/clock-face.c index dd63a2b6..36603865 100644 --- a/applets/clock/clock-face.c +++ b/applets/clock/clock-face.c @@ -15,6 +15,7 @@ #include <math.h> #include <time.h> +#include "clock.h" #include "clock-face.h" #include "clock-location.h" #include "clock-utils.h" @@ -436,18 +437,22 @@ clock_face_load_face (ClockFace *this, gint width, gint height) return; } - /* The pixbuf is not cached, let's load it */ - name = g_strconcat (ICONDIR, "/clock-face-", size_string[priv->size], - "-", daytime_string[priv->timeofday], ".svg", - NULL); - priv->face_pixbuf = clock_utils_pixbuf_from_svg_file_at_size (name, width, height); + /* The pixbuf is not cached, let's load it */ + name = g_strconcat (CLOCK_RESOURCE_PATH "icons/", + "clock-face-", size_string[priv->size], + "-", daytime_string[priv->timeofday], ".svg", + NULL); + priv->face_pixbuf = clock_utils_pixbuf_from_svg_resource_at_size (name, + width, height); g_free (name); if (!priv->face_pixbuf) { - name = g_strconcat (ICONDIR, "/clock-face-", - size_string[priv->size], ".svg", NULL); - priv->face_pixbuf = clock_utils_pixbuf_from_svg_file_at_size (name, width, height); - g_free (name); + name = g_strconcat (CLOCK_RESOURCE_PATH "icons/", + "clock-face-", size_string[priv->size], ".svg", + NULL); + priv->face_pixbuf = clock_utils_pixbuf_from_svg_resource_at_size (name, + width, height); + g_free (name); } /* Save the found pixbuf in the cache */ diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c index 7865d9f1..fa60bb7f 100644 --- a/applets/clock/clock-map.c +++ b/applets/clock/clock-map.c @@ -27,9 +27,9 @@ enum { }; static char *marker_files[MARKER_NB] = { - ICONDIR "/clock-map-location-marker.png", - ICONDIR "/clock-map-location-hilight.png", - ICONDIR "/clock-map-location-current.png" + "clock-map-location-marker.png", + "clock-map-location-hilight.png", + "clock-map-location-current.png" }; static guint signals[LAST_SIGNAL] = { 0 }; @@ -135,8 +135,17 @@ clock_map_init (ClockMap *this) g_assert (sizeof (marker_files)/sizeof (char *) == MARKER_NB); for (i = 0; i < MARKER_NB; i++) { - priv->location_marker_pixbuf[i] = gdk_pixbuf_new_from_file - (marker_files[i], NULL); + char *resource; + GInputStream *stream; + + resource = g_strconcat (CLOCK_RESOURCE_PATH "icons/", marker_files[i], NULL); + stream = g_resources_open_stream (resource, 0, NULL); + g_free (resource); + + if (stream != NULL) { + priv->location_marker_pixbuf[i] = gdk_pixbuf_new_from_stream (stream, NULL, NULL); + g_object_unref (stream); + } } } @@ -208,11 +217,17 @@ clock_map_refresh (ClockMap *this) } if (!priv->stock_map_pixbuf) { - GdkPixbuf *pixbuf = gdk_pixbuf_new_from_file_at_scale - (ICONDIR "/clock-map.png", - priv->width, priv->height, FALSE, NULL); - - priv->stock_map_pixbuf = pixbuf; + GInputStream *stream = g_resources_open_stream (CLOCK_RESOURCE_PATH "icons/clock-map.png", + 0, NULL); + if (stream != NULL) { + GdkPixbuf *pixbuf = gdk_pixbuf_new_from_stream_at_scale (stream, + priv->width, priv->height, + FALSE, + NULL, NULL); + g_object_unref (stream); + + priv->stock_map_pixbuf = pixbuf; + } } clock_map_place_locations (this); diff --git a/applets/clock/clock-utils.c b/applets/clock/clock-utils.c index 5b15fe5f..19cf74fe 100644 --- a/applets/clock/clock-utils.c +++ b/applets/clock/clock-utils.c @@ -128,8 +128,11 @@ clock_utils_display_help (GtkWidget *widget, } GdkPixbuf * -clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int height) +clock_utils_pixbuf_from_svg_resource_at_size (const char *resource, + int width, + int height) { + GInputStream *stream = NULL; RsvgHandle *handle = NULL; RsvgDimensionData svg_dimensions; GdkPixbuf *pixbuf = NULL; @@ -137,9 +140,16 @@ clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int heigh cairo_matrix_t matrix; cairo_t *cr = NULL; - handle = rsvg_handle_new_from_file (name, NULL); + stream = g_resources_open_stream (resource, 0, NULL); + if (!stream) + goto out; + + handle = rsvg_handle_new (); if (!handle) - return NULL; + goto out; + + if (!rsvg_handle_read_stream_sync (handle, stream, NULL, NULL)) + goto out; rsvg_handle_get_dimensions (handle, &svg_dimensions); @@ -155,7 +165,11 @@ clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int heigh pixbuf = gdk_pixbuf_get_from_surface (surface, 0, 0, width, height); cairo_surface_destroy (surface); - rsvg_handle_close (handle, NULL); +out: + if (handle) + rsvg_handle_close (handle, NULL); + if (stream) + g_object_unref (stream); return pixbuf; } diff --git a/applets/clock/clock-utils.h b/applets/clock/clock-utils.h index 647f7222..2ba0ef79 100644 --- a/applets/clock/clock-utils.h +++ b/applets/clock/clock-utils.h @@ -50,7 +50,9 @@ void clock_utils_display_help (GtkWidget *widget, const char *doc_id, const char *link_id); -GdkPixbuf * clock_utils_pixbuf_from_svg_file_at_size (const char *name, int width, int height); +GdkPixbuf *clock_utils_pixbuf_from_svg_resource_at_size (const char *resource, + int width, + int height); #ifdef __cplusplus } diff --git a/applets/clock/clock.c b/applets/clock/clock.c index a17d642e..ad659fe5 100644 --- a/applets/clock/clock.c +++ b/applets/clock/clock.c @@ -2377,9 +2377,6 @@ fill_clock_applet (MatePanelApplet *applet) ClockData *cd; GtkActionGroup *action_group; GtkAction *action; - gchar *ui_path; - char *filename; - GError *error; mate_panel_applet_set_flags (applet, MATE_PANEL_APPLET_EXPAND_MINOR); @@ -2394,17 +2391,7 @@ fill_clock_applet (MatePanelApplet *applet) cd->builder = gtk_builder_new (); gtk_builder_set_translation_domain (cd->builder, GETTEXT_PACKAGE); - filename = g_build_filename (BUILDERDIR, "clock.ui", NULL); - - error = NULL; - gtk_builder_add_from_file (cd->builder, filename, &error); - if (error) { - g_warning ("Error loading \"%s\": %s", - filename, error->message); - g_error_free (error); - } - - g_free (filename); + gtk_builder_add_from_resource (cd->builder, CLOCK_RESOURCE_PATH "clock.ui", NULL); create_clock_widget (cd); @@ -2436,10 +2423,9 @@ fill_clock_applet (MatePanelApplet *applet) clock_menu_actions, G_N_ELEMENTS (clock_menu_actions), cd); - ui_path = g_build_filename (CLOCK_MENU_UI_DIR, "clock-menu.xml", NULL); - mate_panel_applet_setup_menu_from_file (MATE_PANEL_APPLET (cd->applet), - ui_path, action_group); - g_free (ui_path); + mate_panel_applet_setup_menu_from_resource (MATE_PANEL_APPLET (cd->applet), + CLOCK_RESOURCE_PATH "clock-menu.xml", + action_group); if (mate_panel_applet_get_locked_down (MATE_PANEL_APPLET (cd->applet))) { action = gtk_action_group_get_action (action_group, "ClockPreferences"); diff --git a/applets/clock/clock.gresource.xml b/applets/clock/clock.gresource.xml new file mode 100644 index 00000000..2ab45c51 --- /dev/null +++ b/applets/clock/clock.gresource.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<gresources> + <gresource prefix="/org/mate/panel/applet/clock"> + <file compressed="true">clock.ui</file> + <file compressed="true">clock-menu.xml</file> + <file alias="icons/clock-face-large.svg">pixmaps/clock-face-large.svg</file> + <file alias="icons/clock-face-small.svg">pixmaps/clock-face-small.svg</file> + <file alias="icons/clock-face-small-morning.svg">pixmaps/clock-face-small-morning.svg</file> + <file alias="icons/clock-face-small-day.svg">pixmaps/clock-face-small-day.svg</file> + <file alias="icons/clock-face-small-evening.svg">pixmaps/clock-face-small-evening.svg</file> + <file alias="icons/clock-face-small-night.svg">pixmaps/clock-face-small-night.svg</file> + <file alias="icons/clock-map.png">pixmaps/clock-map.png</file> + <file alias="icons/clock-map-location-marker.png">pixmaps/clock-map-location-marker.png</file> + <file alias="icons/clock-map-location-current.png">pixmaps/clock-map-location-current.png</file> + <file alias="icons/clock-map-location-hilight.png">pixmaps/clock-map-location-hilight.png</file> + </gresource> +</gresources> diff --git a/applets/clock/clock.h b/applets/clock/clock.h index ad4861dd..34e7447a 100644 --- a/applets/clock/clock.h +++ b/applets/clock/clock.h @@ -32,6 +32,7 @@ extern "C" { #endif #define CLOCK_ICON "mate-panel-clock" +#define CLOCK_RESOURCE_PATH "/org/mate/panel/applet/clock/" #define CLOCK_SCHEMA "org.mate.panel.applet.clock" #ifdef __cplusplus diff --git a/applets/clock/pixmaps/Makefile.am b/applets/clock/pixmaps/Makefile.am index 3e9f5077..d041e6a9 100644 --- a/applets/clock/pixmaps/Makefile.am +++ b/applets/clock/pixmaps/Makefile.am @@ -1,6 +1,4 @@ -icondir = $(datadir)/mate-panel/pixmaps -icon_DATA = \ - clock-calendar-icon.png \ +icon_FILES = \ clock-face-large.svg \ clock-face-small.svg \ clock-face-small-morning.svg \ @@ -14,7 +12,7 @@ icon_DATA = \ EXTRA_DIST = \ clock-map.svg \ - $(icon_DATA) + $(icon_FILES) MAINTAINERCLEANFILES = Makefile.in diff --git a/applets/clock/pixmaps/clock-calendar-icon.png b/applets/clock/pixmaps/clock-calendar-icon.png Binary files differdeleted file mode 100644 index cfab7200..00000000 --- a/applets/clock/pixmaps/clock-calendar-icon.png +++ /dev/null |