summaryrefslogtreecommitdiff
path: root/libslab
diff options
context:
space:
mode:
authormonsta <[email protected]>2017-12-09 22:55:37 +0300
committermonsta <[email protected]>2017-12-21 15:05:07 +0300
commit70b347c44a3dfb2a794b1e2512f295dd863d6aee (patch)
treebcaa1d676987082ab92c728bba5f071e4cd8f845 /libslab
parenta85d9cb9d760eec8e8280641c767bd8ce5b6f289 (diff)
downloadmate-control-center-70b347c44a3dfb2a794b1e2512f295dd863d6aee.tar.bz2
mate-control-center-70b347c44a3dfb2a794b1e2512f295dd863d6aee.tar.xz
fix support for external localizations in .desktop files
fixes https://github.com/mate-desktop/mate-control-center/issues/239 fixes https://github.com/mate-desktop/mate-control-center/issues/260
Diffstat (limited to 'libslab')
-rw-r--r--libslab/application-tile.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/libslab/application-tile.c b/libslab/application-tile.c
index 7d98da80..523643df 100644
--- a/libslab/application-tile.c
+++ b/libslab/application-tile.c
@@ -269,10 +269,10 @@ application_tile_setup (ApplicationTile *this)
GtkWidget *menu_item;
GtkContainer *menu_ctnr;
- const gchar *name;
- const gchar *desc;
+ gchar *name;
+ gchar *desc;
- const gchar *comment;
+ gchar *comment;
gchar *markup;
gchar *str;
@@ -287,9 +287,13 @@ application_tile_setup (ApplicationTile *this)
priv->image_id = g_strdup (mate_desktop_item_get_localestring (priv->desktop_item, "Icon"));
image = themed_icon_new (priv->image_id, priv->image_size);
- name = mate_desktop_item_get_localestring (priv->desktop_item, "Name");
- desc = mate_desktop_item_get_localestring (priv->desktop_item, "GenericName");
- comment = mate_desktop_item_get_localestring (priv->desktop_item, "Comment");
+ gchar *filename = g_filename_from_uri (mate_desktop_item_get_location (priv->desktop_item), NULL, NULL);
+ GKeyFile *keyfile = g_key_file_new ();
+ g_key_file_load_from_file (keyfile, filename, G_KEY_FILE_KEEP_COMMENTS | G_KEY_FILE_KEEP_TRANSLATIONS, NULL);
+
+ name = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "Name", NULL, NULL);
+ desc = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "GenericName", NULL, NULL);
+ comment = g_key_file_get_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP, "Comment", NULL, NULL);
accessible = gtk_widget_get_accessible (GTK_WIDGET (this));
if (name)
@@ -392,6 +396,12 @@ application_tile_setup (ApplicationTile *this)
}
gtk_widget_show_all (GTK_WIDGET (TILE (this)->context_menu));
+
+ g_free (name);
+ g_free (desc);
+ g_free (comment);
+ g_free (filename);
+ g_key_file_unref (keyfile);
}
static GtkWidget *