gnome-panel r11128 - in trunk: . gnome-panel gnome-panel/libpanel-util help/workspace-switcher/pt_BR
- From: vuntz svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-panel r11128 - in trunk: . gnome-panel gnome-panel/libpanel-util help/workspace-switcher/pt_BR
- Date: Thu, 5 Jun 2008 13:36:54 +0000 (UTC)
Author: vuntz
Date: Thu Jun 5 13:36:53 2008
New Revision: 11128
URL: http://svn.gnome.org/viewvc/gnome-panel?rev=11128&view=rev
Log:
Add svn:ignore.
2008-06-05 Vincent Untz <vuntz gnome org>
* configure.in: updated for gnome-panel/libpanel-util/
2008-06-05 Vincent Untz <vuntz gnome org>
Let's start cleaning up the source. Okay, this attempt will certainly
fail at some point ;-)
First step, create an internal libpanel-util library where we put some
utility functions.
We start with the GKeyFile extensions.
* Makefile.am: updated for this change
* libpanel-util/Makefile.am: new
* libpanel-util/panel-keyfile.[ch]: new, based on panel-util.c code
* panel-ditem-editor.c: s/panel_util_key_file/panel_key_file/g
* panel-menu-items.c: s/panel_util_key_file/panel_key_file/g
* panel-run-dialog.c: s/panel_util_key_file/panel_key_file/g
* panel-util.[ch]: s/panel_util_key_file/panel_key_file/g and remove
panel_util_key_file*
* launcher.c: s/panel_util_key_file/panel_key_file/g
* gnome-desktop-item-edit.c: s/panel_util_key_file/panel_key_file/g
Added:
trunk/gnome-panel/libpanel-util/ (props changed)
trunk/gnome-panel/libpanel-util/Makefile.am
trunk/gnome-panel/libpanel-util/panel-keyfile.c
trunk/gnome-panel/libpanel-util/panel-keyfile.h
Modified:
trunk/ChangeLog
trunk/configure.in
trunk/gnome-panel/ChangeLog
trunk/gnome-panel/Makefile.am
trunk/gnome-panel/gnome-desktop-item-edit.c
trunk/gnome-panel/launcher.c
trunk/gnome-panel/panel-ditem-editor.c
trunk/gnome-panel/panel-menu-items.c
trunk/gnome-panel/panel-run-dialog.c
trunk/gnome-panel/panel-util.c
trunk/gnome-panel/panel-util.h
trunk/help/workspace-switcher/pt_BR/ (props changed)
Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in (original)
+++ trunk/configure.in Thu Jun 5 13:36:53 2008
@@ -336,6 +336,7 @@
icons/48x48/Makefile
icons/scalable/Makefile
gnome-panel/Makefile
+gnome-panel/libpanel-util/Makefile
gnome-panel/gnome-panel.desktop.in
libpanel-applet/libpanelapplet-2.0.pc
libpanel-applet/libpanelapplet-2.0-uninstalled.pc
Modified: trunk/gnome-panel/Makefile.am
==============================================================================
--- trunk/gnome-panel/Makefile.am (original)
+++ trunk/gnome-panel/Makefile.am Thu Jun 5 13:36:53 2008
@@ -1,5 +1,6 @@
## We require new-style dependency handling.
AUTOMAKE_OPTIONS = 1.3
+SUBDIRS = libpanel-util
NULL =
@@ -7,6 +8,7 @@
-I. \
-I$(srcdir) \
-I$(top_builddir)/gnome-panel \
+ -I$(top_builddir)/gnome-panel/libpanel-util \
-DPANEL_DEBUG \
-DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DGLADEDIR=\""$(gladedir)"\" \
@@ -160,6 +162,7 @@
$(NULL)
gnome_panel_LDADD = \
+ $(top_builddir)/gnome-panel/libpanel-util/libpanel-util.la \
$(PANEL_LIBS) \
$(X_LIBS)
@@ -175,6 +178,7 @@
gnome_desktop_item_edit_LDFLAGS = -export-dynamic
gnome_desktop_item_edit_LDADD = \
+ $(top_builddir)/gnome-panel/libpanel-util/libpanel-util.la \
$(PANEL_LIBS) \
$(X_LIBS)
Modified: trunk/gnome-panel/gnome-desktop-item-edit.c
==============================================================================
--- trunk/gnome-panel/gnome-desktop-item-edit.c (original)
+++ trunk/gnome-panel/gnome-desktop-item-edit.c Thu Jun 5 13:36:53 2008
@@ -5,8 +5,9 @@
#include <gtk/gtk.h>
#include <libgnomeui/gnome-ui-init.h>
+#include <libpanel-util/panel-keyfile.h>
+
#include "panel-ditem-editor.h"
-#include "panel-util.h"
#include "panel-icon-names.h"
#include "nothing.cP"
@@ -64,7 +65,7 @@
char *dir;
keyfile = panel_ditem_editor_get_key_file (dialog);
- name = panel_util_key_file_get_string (keyfile, "Name");
+ name = panel_key_file_get_string (keyfile, "Name");
validate_for_filename (name);
filename = g_filename_from_utf8 (name, -1, NULL, NULL, NULL);
Modified: trunk/gnome-panel/launcher.c
==============================================================================
--- trunk/gnome-panel/launcher.c (original)
+++ trunk/gnome-panel/launcher.c Thu Jun 5 13:36:53 2008
@@ -24,6 +24,8 @@
#include <libgnomeui/gnome-url.h>
#include <gdk/gdkx.h>
+#include <libpanel-util/panel-keyfile.h>
+
#include "launcher.h"
#include "button-widget.h"
@@ -158,7 +160,7 @@
g_return_if_fail (launcher->key_file != NULL);
/* FIXME panel_ditem_launch() should be enough for this! */
- url = panel_util_key_file_get_string (launcher->key_file, "URL");
+ url = panel_key_file_get_string (launcher->key_file, "URL");
screen = launcher_get_screen (launcher);
@@ -208,7 +210,7 @@
button_widget_get_orientation (BUTTON_WIDGET (widget)),
NULL);
- type = panel_util_key_file_get_string (launcher->key_file, "Type");
+ type = panel_key_file_get_string (launcher->key_file, "Type");
if (type && !strcmp (type, "Link"))
launch_url (launcher);
else {
@@ -536,9 +538,9 @@
g_free (path);
}
} else
- loaded = panel_util_key_file_load_from_uri (key_file, location,
- G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
- &error);
+ loaded = panel_key_file_load_from_uri (key_file, location,
+ G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+ &error);
if (!loaded) {
g_printerr (_("Unable to open desktop file %s for panel launcher%s%s\n"),
@@ -611,10 +613,9 @@
g_return_if_fail (launcher != NULL);
- name = panel_util_key_file_get_locale_string (launcher->key_file,
- "Name");
- comment = panel_util_key_file_get_locale_string (launcher->key_file,
- "Comment");
+ name = panel_key_file_get_locale_string (launcher->key_file, "Name");
+ comment = panel_key_file_get_locale_string (launcher->key_file,
+ "Comment");
/* Setup tooltip */
if ( ! string_empty (comment))
@@ -643,8 +644,7 @@
g_free (str);
/* Setup icon */
- icon = panel_util_key_file_get_locale_string (launcher->key_file,
- "Icon");
+ icon = panel_key_file_get_locale_string (launcher->key_file, "Icon");
if (icon && icon[0] == '\0') {
g_free (icon);
icon = NULL;
@@ -710,14 +710,12 @@
revert_key_file = panel_ditem_editor_get_revert_key_file (dialog);
if (revert_key_file) {
- exec = panel_util_key_file_get_string (launcher->key_file,
- "Exec");
- old_exec = panel_util_key_file_get_string (revert_key_file,
- "Exec");
+ exec = panel_key_file_get_string (launcher->key_file, "Exec");
+ old_exec = panel_key_file_get_string (revert_key_file, "Exec");
if (!old_exec || !exec || strcmp (old_exec, exec))
- panel_util_key_file_remove_key (launcher->key_file,
- "StartupNotify");
+ panel_key_file_remove_key (launcher->key_file,
+ "StartupNotify");
g_free (exec);
g_free (old_exec);
@@ -736,13 +734,13 @@
const char *uri;
key_file = panel_ditem_editor_get_key_file (dialog);
- type = panel_util_key_file_get_string (key_file, "Type");
+ type = panel_key_file_get_string (key_file, "Type");
if (type && !strcmp (type, "Application"))
- exec_or_uri = panel_util_key_file_get_string (key_file, "Exec");
+ exec_or_uri = panel_key_file_get_string (key_file, "Exec");
else if (type && !strcmp (type, "Link"))
- exec_or_uri = panel_util_key_file_get_string (key_file, "URL");
+ exec_or_uri = panel_key_file_get_string (key_file, "URL");
else
- exec_or_uri = panel_util_key_file_get_string (key_file, "Name");
+ exec_or_uri = panel_key_file_get_string (key_file, "Name");
g_free (type);
launcher = (Launcher *) data;
@@ -983,8 +981,8 @@
key_file = panel_ditem_editor_get_key_file (PANEL_DITEM_EDITOR (dialog));
if (file != NULL)
- panel_util_key_file_set_string (key_file, "Exec", file);
- panel_util_key_file_set_string (key_file, "Type", "Application");
+ panel_key_file_set_string (key_file, "Exec", file);
+ panel_key_file_set_string (key_file, "Type", "Application");
panel_ditem_editor_sync_display (PANEL_DITEM_EDITOR (dialog));
panel_ditem_register_save_uri_func (PANEL_DITEM_EDITOR (dialog),
@@ -1019,27 +1017,27 @@
char *location;
GError *error;
- key_file = panel_util_key_file_new_desktop ();
+ key_file = panel_key_file_new_desktop ();
/* set current language and the "C" locale to this name,
* this is kind of evil... */
- panel_util_key_file_set_string (key_file, "Name", name);
- panel_util_key_file_set_string (key_file, "Comment", comment);
- panel_util_key_file_set_string (key_file, "Icon", icon);
- panel_util_key_file_set_locale_string (key_file, "Name", name);
- panel_util_key_file_set_locale_string (key_file, "Comment", comment);
- panel_util_key_file_set_locale_string (key_file, "Icon", icon);
+ panel_key_file_set_string (key_file, "Name", name);
+ panel_key_file_set_string (key_file, "Comment", comment);
+ panel_key_file_set_string (key_file, "Icon", icon);
+ panel_key_file_set_locale_string (key_file, "Name", name);
+ panel_key_file_set_locale_string (key_file, "Comment", comment);
+ panel_key_file_set_locale_string (key_file, "Icon", icon);
if (exec_info) {
- panel_util_key_file_set_string (key_file, "Exec", exec_or_uri);
- panel_util_key_file_set_string (key_file, "Type", "Application");
+ panel_key_file_set_string (key_file, "Exec", exec_or_uri);
+ panel_key_file_set_string (key_file, "Type", "Application");
} else {
- panel_util_key_file_set_string (key_file, "URL", exec_or_uri);
- panel_util_key_file_set_string (key_file, "Type", "Link");
+ panel_key_file_set_string (key_file, "URL", exec_or_uri);
+ panel_key_file_set_string (key_file, "Type", "Link");
}
location = panel_make_unique_desktop_uri (NULL, exec_or_uri);
- if (panel_util_key_file_to_file (key_file, location, &error)) {
+ if (panel_key_file_to_file (key_file, location, &error)) {
panel_launcher_create (toplevel, position, location);
} else {
panel_error_dialog (GTK_WINDOW (toplevel),
Added: trunk/gnome-panel/libpanel-util/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/gnome-panel/libpanel-util/Makefile.am Thu Jun 5 13:36:53 2008
@@ -0,0 +1,25 @@
+NULL =
+
+INCLUDES = \
+ -I. \
+ -I$(srcdir) \
+ -I$(top_builddir)/gnome-panel \
+ -I$(top_builddir)/gnome-panel/libpanel-util \
+ -DPANEL_DEBUG \
+ -DGNOMELOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
+ -DGLADEDIR=\""$(gladedir)"\" \
+ -DICONDIR=\""$(datadir)/gnome-panel/pixmaps"\" \
+ -DGMENU_I_KNOW_THIS_IS_UNSTABLE \
+ $(DISABLE_DEPRECATED_CFLAGS) \
+ $(STANDARD_PROPERTIES_CFLAGS) \
+ $(PANEL_CFLAGS) \
+ $(PANELCONFIG_CFLAGS) \
+ $(WARN_CFLAGS) \
+ $(NULL)
+
+noinst_LTLIBRARIES=libpanel-util.la
+
+libpanel_util_la_SOURCES= \
+ panel-keyfile.c \
+ panel-keyfile.h \
+ $(NULL)
Added: trunk/gnome-panel/libpanel-util/panel-keyfile.c
==============================================================================
--- (empty file)
+++ trunk/gnome-panel/libpanel-util/panel-keyfile.c Thu Jun 5 13:36:53 2008
@@ -0,0 +1,277 @@
+/*
+ * panel-keyfile.c:
+ *
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * Based on code from panel-util.c (there was no copyright header at the time)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Vincent Untz <vuntz gnome org>
+ */
+
+#include <string.h>
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "panel-keyfile.h"
+
+GKeyFile *
+panel_key_file_new_desktop (void)
+{
+ GKeyFile *retval;
+
+ retval = g_key_file_new ();
+
+ //FIXME? g_key_file_set_string (retval, G_KEY_FILE_DESKTOP_GROUP, "Name", _("No Name"));
+ g_key_file_set_string (retval, G_KEY_FILE_DESKTOP_GROUP, "Encoding", "UTF-8");
+ g_key_file_set_string (retval, G_KEY_FILE_DESKTOP_GROUP, "Version", "1.0");
+
+ return retval;
+}
+
+//FIXME: kill this when bug #309224 is fixed
+gboolean
+panel_key_file_to_file (GKeyFile *keyfile,
+ const gchar *file,
+ GError **error)
+{
+ gchar *filename;
+ GError *write_error;
+ gchar *data;
+ gsize length;
+ gboolean res;
+
+ g_return_val_if_fail (keyfile != NULL, FALSE);
+ g_return_val_if_fail (file != NULL, FALSE);
+
+ write_error = NULL;
+ data = g_key_file_to_data (keyfile, &length, &write_error);
+ if (write_error) {
+ g_propagate_error (error, write_error);
+ return FALSE;
+ }
+
+ if (!g_path_is_absolute (file))
+ filename = g_filename_from_uri (file, NULL, &write_error);
+ else
+ filename = g_filename_from_utf8 (file, -1, NULL, NULL,
+ &write_error);
+
+ if (write_error) {
+ g_propagate_error (error, write_error);
+ g_free (data);
+ return FALSE;
+ }
+
+ res = g_file_set_contents (filename, data, length, &write_error);
+ g_free (filename);
+
+ if (write_error) {
+ g_propagate_error (error, write_error);
+ g_free (data);
+ return FALSE;
+ }
+
+ g_free (data);
+ return res;
+}
+
+gboolean
+panel_key_file_load_from_uri (GKeyFile *keyfile,
+ const gchar *uri,
+ GKeyFileFlags flags,
+ GError **error)
+{
+ char *scheme;
+ gboolean is_local;
+ gboolean result;
+
+ g_return_val_if_fail (keyfile != NULL, FALSE);
+ g_return_val_if_fail (uri != NULL, FALSE);
+ g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
+
+ scheme = g_uri_parse_scheme (uri);
+ is_local = (scheme == NULL) || !g_ascii_strcasecmp (scheme, "file");
+ g_free (scheme);
+
+ if (is_local) {
+ char *path;
+
+ if (g_path_is_absolute (uri))
+ path = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
+ else
+ path = g_filename_from_uri (uri, NULL, NULL);
+ result = g_key_file_load_from_file (keyfile, path,
+ flags, error);
+ g_free (path);
+ } else {
+ GFile *file;
+ char *contents;
+ gsize size;
+ gboolean ret;
+
+ file = g_file_new_for_uri (uri);
+ ret = g_file_load_contents (file, NULL, &contents, &size,
+ NULL, NULL);
+ g_object_unref (file);
+
+ if (!ret)
+ return FALSE;
+
+ result = g_key_file_load_from_data (keyfile, contents, size,
+ flags, error);
+
+ g_free (contents);
+ }
+
+ return result;
+}
+
+gboolean
+panel_key_file_get_boolean (GKeyFile *keyfile,
+ const gchar *key,
+ gboolean default_value)
+{
+ GError *error;
+ gboolean retval;
+
+ error = NULL;
+ retval = g_key_file_get_boolean (keyfile, G_KEY_FILE_DESKTOP_GROUP, key, &error);
+ if (error != NULL) {
+ retval = default_value;
+ g_error_free (error);
+ }
+
+ return retval;
+}
+
+void
+panel_key_file_set_locale_string (GKeyFile *keyfile,
+ const gchar *key,
+ const gchar *value)
+{
+ const char *locale;
+ const char * const *langs_pointer;
+ int i;
+
+ locale = NULL;
+ langs_pointer = g_get_language_names ();
+ for (i = 0; langs_pointer[i] != NULL; i++) {
+ /* find first without encoding */
+ if (strchr (langs_pointer[i], '.') == NULL) {
+ locale = langs_pointer[i];
+ break;
+ }
+ }
+
+ if (locale)
+ g_key_file_set_locale_string (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+ key, locale, value);
+ else
+ g_key_file_set_string (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+ key, value);
+}
+
+void
+panel_key_file_remove_locale_key (GKeyFile *keyfile,
+ const gchar *key)
+{
+ const char * const *langs_pointer;
+ int i;
+ char *locale_key;
+
+ locale_key = NULL;
+ langs_pointer = g_get_language_names ();
+ for (i = 0; langs_pointer[i] != NULL; i++) {
+ /* find first without encoding */
+ if (strchr (langs_pointer[i], '.') == NULL) {
+ locale_key = g_strdup_printf ("%s[%s]",
+ key, langs_pointer[i]);
+ if (g_key_file_has_key (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+ locale_key, NULL))
+ break;
+
+ g_free (locale_key);
+ locale_key = NULL;
+ }
+ }
+
+ if (locale_key) {
+ g_key_file_remove_key (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+ locale_key, NULL);
+ g_free (locale_key);
+ } else
+ g_key_file_remove_key (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+ key, NULL);
+}
+
+void
+panel_key_file_remove_all_locale_key (GKeyFile *keyfile,
+ const gchar *key)
+{
+ char **keys;
+ int key_len;
+ int i;
+
+ if (!key)
+ return;
+
+ keys = g_key_file_get_keys (keyfile, G_KEY_FILE_DESKTOP_GROUP, NULL, NULL);
+ if (!keys)
+ return;
+
+ key_len = strlen (key);
+
+ for (i = 0; keys[i] != NULL; i++) {
+ int len;
+
+ if (strncmp (keys[i], key, key_len))
+ continue;
+
+ len = strlen (keys[i]);
+ if (len == key_len ||
+ (len > key_len && keys[i][key_len] == '['))
+ g_key_file_remove_key (keyfile, G_KEY_FILE_DESKTOP_GROUP,
+ keys[i], NULL);
+ }
+
+ g_strfreev (keys);
+}
+
+void
+panel_key_file_ensure_C_key (GKeyFile *keyfile,
+ const char *key)
+{
+ char *C_value;
+ char *buffer;
+
+ /* Make sure we set the "C" locale strings to the terms we set here.
+ * This is so that if the user logs into another locale they get their
+ * own description there rather then empty. It is not the C locale
+ * however, but the user created this entry herself so it's OK */
+ C_value = panel_key_file_get_string (keyfile, key);
+ if (C_value == NULL || C_value [0] == '\0') {
+ buffer = panel_key_file_get_locale_string (keyfile, key);
+ if (buffer) {
+ panel_key_file_set_string (keyfile, key, buffer);
+ g_free (buffer);
+ }
+ }
+ g_free (C_value);
+}
Added: trunk/gnome-panel/libpanel-util/panel-keyfile.h
==============================================================================
--- (empty file)
+++ trunk/gnome-panel/libpanel-util/panel-keyfile.h Thu Jun 5 13:36:53 2008
@@ -0,0 +1,71 @@
+/*
+ * panel-keyfile.h:
+ *
+ * Copyright (C) 2008 Novell, Inc.
+ *
+ * Based on code from panel-util.h (there was no copyright header at the time)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Authors:
+ * Vincent Untz <vuntz gnome org>
+ */
+
+#ifndef PANEL_KEYFILE_H
+#define PANEL_KEYFILE_H
+
+#include "glib.h"
+
+G_BEGIN_DECLS
+
+
+GKeyFile *panel_key_file_new_desktop (void);
+gboolean panel_key_file_to_file (GKeyFile *keyfile,
+ const gchar *file,
+ GError **error);
+gboolean panel_key_file_load_from_uri (GKeyFile *keyfile,
+ const gchar *uri,
+ GKeyFileFlags flags,
+ GError **error);
+
+gboolean panel_key_file_get_boolean (GKeyFile *keyfile,
+ const gchar *key,
+ gboolean default_value);
+#define panel_key_file_get_string(key_file, key) \
+ g_key_file_get_string (key_file, G_KEY_FILE_DESKTOP_GROUP, key, NULL)
+#define panel_key_file_get_locale_string(key_file, key) \
+ g_key_file_get_locale_string(key_file, G_KEY_FILE_DESKTOP_GROUP, key, NULL, NULL)
+
+#define panel_key_file_set_boolean(key_file, key, value) \
+ g_key_file_set_boolean (key_file, G_KEY_FILE_DESKTOP_GROUP, key, value)
+#define panel_key_file_set_string(key_file, key, value) \
+ g_key_file_set_string (key_file, G_KEY_FILE_DESKTOP_GROUP, key, value)
+void panel_key_file_set_locale_string (GKeyFile *keyfile,
+ const gchar *key,
+ const gchar *value);
+
+#define panel_key_file_remove_key(key_file, key) \
+ g_key_file_remove_key (key_file, G_KEY_FILE_DESKTOP_GROUP, key, NULL)
+void panel_key_file_remove_locale_key (GKeyFile *keyfile,
+ const gchar *key);
+void panel_key_file_remove_all_locale_key (GKeyFile *keyfile,
+ const gchar *key);
+void panel_key_file_ensure_C_key (GKeyFile *keyfile,
+ const char *key);
+
+G_END_DECLS
+
+#endif /* PANEL_KEYFILE_H */
Modified: trunk/gnome-panel/panel-ditem-editor.c
==============================================================================
--- trunk/gnome-panel/panel-ditem-editor.c (original)
+++ trunk/gnome-panel/panel-ditem-editor.c Thu Jun 5 13:36:53 2008
@@ -32,6 +32,9 @@
#include <libgnomeui/gnome-icon-entry.h>
#include <libgnomeui/gnome-help.h>
+
+#include <libpanel-util/panel-keyfile.h>
+
#include "panel-ditem-editor.h"
#include "panel-icon-names.h"
#include "panel-util.h"
@@ -237,10 +240,10 @@
dialog->priv->free_key_file = FALSE;
loaded = TRUE;
} else {
- dialog->priv->key_file = panel_util_key_file_new_desktop ();
+ dialog->priv->key_file = panel_key_file_new_desktop ();
if (dialog->priv->type_directory)
- panel_util_key_file_set_string (dialog->priv->key_file,
- "Type", "Directory");
+ panel_key_file_set_string (dialog->priv->key_file,
+ "Type", "Directory");
dialog->priv->free_key_file = TRUE;
loaded = FALSE;
}
@@ -261,8 +264,8 @@
dialog->priv->dirty = FALSE;
- desktop_type = panel_util_key_file_get_string (dialog->priv->key_file,
- "Type");
+ desktop_type = panel_key_file_get_string (dialog->priv->key_file,
+ "Type");
if (desktop_type && !strcmp (desktop_type, "Directory"))
dialog->priv->type_directory = TRUE;
g_free (desktop_type);
@@ -856,11 +859,11 @@
name = gtk_entry_get_text (GTK_ENTRY (dialog->priv->name_entry));
if (name && name[0])
- panel_util_key_file_set_locale_string (dialog->priv->key_file,
- "Name", name);
+ panel_key_file_set_locale_string (dialog->priv->key_file,
+ "Name", name);
else
- panel_util_key_file_remove_all_locale_key (dialog->priv->key_file,
- "Name");
+ panel_key_file_remove_all_locale_key (dialog->priv->key_file,
+ "Name");
g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[NAME_CHANGED], 0,
name);
@@ -884,9 +887,9 @@
switch (type) {
case PANEL_DITEM_EDITOR_TYPE_APPLICATION:
case PANEL_DITEM_EDITOR_TYPE_TERMINAL_APPLICATION:
- panel_util_key_file_remove_key (dialog->priv->key_file, "URL");
- panel_util_key_file_set_string (dialog->priv->key_file, "Exec",
- exec_or_uri);
+ panel_key_file_remove_key (dialog->priv->key_file, "URL");
+ panel_key_file_set_string (dialog->priv->key_file, "Exec",
+ exec_or_uri);
icon_theme = gtk_icon_theme_get_for_screen (gtk_widget_get_screen (GTK_WIDGET (dialog)));
icon = guess_icon_from_exec (icon_theme,
@@ -894,8 +897,8 @@
if (icon) {
char *current;
- current = panel_util_key_file_get_locale_string (dialog->priv->key_file,
- "Icon");
+ current = panel_key_file_get_locale_string (dialog->priv->key_file,
+ "Icon");
if (!current || strcmp (icon, current))
setup_icon_entry (dialog, icon);
@@ -905,13 +908,13 @@
}
break;
case PANEL_DITEM_EDITOR_TYPE_LINK:
- panel_util_key_file_remove_key (dialog->priv->key_file, "Exec");
- panel_util_key_file_set_string (dialog->priv->key_file, "URL",
- exec_or_uri);
+ panel_key_file_remove_key (dialog->priv->key_file, "Exec");
+ panel_key_file_set_string (dialog->priv->key_file, "URL",
+ exec_or_uri);
break;
default:
- panel_util_key_file_remove_key (dialog->priv->key_file, "Exec");
- panel_util_key_file_remove_key (dialog->priv->key_file, "URL");
+ panel_key_file_remove_key (dialog->priv->key_file, "Exec");
+ panel_key_file_remove_key (dialog->priv->key_file, "URL");
}
g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[COMMAND_CHANGED],
@@ -926,11 +929,11 @@
comment = gtk_entry_get_text (GTK_ENTRY (dialog->priv->comment_entry));
if (comment && comment[0])
- panel_util_key_file_set_locale_string (dialog->priv->key_file,
- "Comment", comment);
+ panel_key_file_set_locale_string (dialog->priv->key_file,
+ "Comment", comment);
else
- panel_util_key_file_remove_all_locale_key (dialog->priv->key_file,
- "Comment");
+ panel_key_file_remove_all_locale_key (dialog->priv->key_file,
+ "Comment");
g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[COMMENT_CHANGED],
0, comment);
@@ -962,11 +965,11 @@
}
if (icon)
- panel_util_key_file_set_locale_string (dialog->priv->key_file,
- "Icon", icon);
+ panel_key_file_set_locale_string (dialog->priv->key_file,
+ "Icon", icon);
else
- panel_util_key_file_remove_all_locale_key (dialog->priv->key_file,
- "Icon");
+ panel_key_file_remove_all_locale_key (dialog->priv->key_file,
+ "Icon");
g_signal_emit (G_OBJECT (dialog), ditem_edit_signals[ICON_CHANGED], 0,
file);
@@ -1149,34 +1152,34 @@
case PANEL_DITEM_EDITOR_TYPE_APPLICATION:
text = _("Comm_and:");
if (dialog->priv->combo_setuped) {
- panel_util_key_file_set_string (dialog->priv->key_file,
- "Type", "Application");
- panel_util_key_file_set_boolean (dialog->priv->key_file,
- "Terminal", FALSE);
+ panel_key_file_set_string (dialog->priv->key_file,
+ "Type", "Application");
+ panel_key_file_set_boolean (dialog->priv->key_file,
+ "Terminal", FALSE);
}
break;
case PANEL_DITEM_EDITOR_TYPE_TERMINAL_APPLICATION:
text = _("_Command:");
if (dialog->priv->combo_setuped) {
- panel_util_key_file_set_string (dialog->priv->key_file,
- "Type", "Application");
- panel_util_key_file_set_boolean (dialog->priv->key_file,
- "Terminal", TRUE);
+ panel_key_file_set_string (dialog->priv->key_file,
+ "Type", "Application");
+ panel_key_file_set_boolean (dialog->priv->key_file,
+ "Terminal", TRUE);
}
break;
case PANEL_DITEM_EDITOR_TYPE_LINK:
text = _("_Location:");
if (dialog->priv->combo_setuped) {
- panel_util_key_file_set_string (dialog->priv->key_file,
- "Type", "Link");
- panel_util_key_file_remove_key (dialog->priv->key_file,
- "Terminal");
+ panel_key_file_set_string (dialog->priv->key_file,
+ "Type", "Link");
+ panel_key_file_remove_key (dialog->priv->key_file,
+ "Terminal");
}
break;
case PANEL_DITEM_EDITOR_TYPE_DIRECTORY:
if (dialog->priv->combo_setuped) {
- panel_util_key_file_set_string (dialog->priv->key_file,
- "Type", "Directory");
+ panel_key_file_set_string (dialog->priv->key_file,
+ "Type", "Directory");
}
return;
default:
@@ -1253,13 +1256,13 @@
key_file = dialog->priv->key_file;
/* Name */
- buffer = panel_util_key_file_get_locale_string (key_file, "Name");
+ buffer = panel_key_file_get_locale_string (key_file, "Name");
gtk_entry_set_text (GTK_ENTRY (dialog->priv->name_entry),
buffer ? buffer : "");
g_free (buffer);
/* Type */
- type = panel_util_key_file_get_string (key_file, "Type");
+ type = panel_key_file_get_string (key_file, "Type");
if (!dialog->priv->combo_setuped) {
setup_combo (dialog->priv->type_combo,
type_items, G_N_ELEMENTS (type_items),
@@ -1267,8 +1270,8 @@
dialog->priv->combo_setuped = TRUE;
}
- run_in_terminal = panel_util_key_file_get_boolean (key_file, "Terminal",
- FALSE);
+ run_in_terminal = panel_key_file_get_boolean (key_file, "Terminal",
+ FALSE);
editor_type = map_type_from_desktop_item (type, run_in_terminal);
g_free (type);
@@ -1289,10 +1292,10 @@
/* Command */
if (editor_type == PANEL_DITEM_EDITOR_TYPE_LINK)
- buffer = panel_util_key_file_get_string (key_file, "URL");
+ buffer = panel_key_file_get_string (key_file, "URL");
else if (editor_type == PANEL_DITEM_EDITOR_TYPE_APPLICATION ||
editor_type == PANEL_DITEM_EDITOR_TYPE_TERMINAL_APPLICATION)
- buffer = panel_util_key_file_get_string (key_file, "Exec");
+ buffer = panel_key_file_get_string (key_file, "Exec");
else
buffer = NULL;
@@ -1301,14 +1304,14 @@
g_free (buffer);
/* Comment */
- buffer = panel_util_key_file_get_locale_string (key_file, "Comment");
+ buffer = panel_key_file_get_locale_string (key_file, "Comment");
gtk_entry_set_text (GTK_ENTRY (dialog->priv->comment_entry),
buffer ? buffer : "");
g_free (buffer);
/* Icon */
- buffer = panel_util_key_file_get_locale_string (key_file, "Icon");
+ buffer = panel_key_file_get_locale_string (key_file, "Icon");
setup_icon_entry (dialog, buffer);
g_free (buffer);
@@ -1385,9 +1388,9 @@
key_file = dialog->priv->key_file;
- panel_util_key_file_ensure_C_key (key_file, "Name");
- panel_util_key_file_ensure_C_key (key_file, "Comment");
- panel_util_key_file_ensure_C_key (key_file, "Icon");
+ panel_key_file_ensure_C_key (key_file, "Name");
+ panel_key_file_ensure_C_key (key_file, "Comment");
+ panel_key_file_ensure_C_key (key_file, "Icon");
if (dialog->priv->save_uri) {
char *uri;
@@ -1403,9 +1406,9 @@
/* And now, try to save */
error = NULL;
- panel_util_key_file_to_file (dialog->priv->key_file,
- dialog->priv->uri,
- &error);
+ panel_key_file_to_file (dialog->priv->key_file,
+ dialog->priv->uri,
+ &error);
if (error != NULL) {
if (report_errors)
g_signal_emit (G_OBJECT (dialog),
@@ -1499,41 +1502,41 @@
for (i = 0; i < G_N_ELEMENTS (revert_keys); i++) {
if (revert_keys [i].type == G_TYPE_STRING) {
if (revert_keys [i].locale) {
- string = panel_util_key_file_get_locale_string (
+ string = panel_key_file_get_locale_string (
revert_key_file,
revert_keys [i].key);
if (string == NULL)
- panel_util_key_file_remove_all_locale_key (
+ panel_key_file_remove_all_locale_key (
key_file,
revert_keys [i].key);
else
- panel_util_key_file_set_locale_string (
+ panel_key_file_set_locale_string (
key_file,
revert_keys [i].key,
string);
} else {
- string = panel_util_key_file_get_string (
+ string = panel_key_file_get_string (
revert_key_file,
revert_keys [i].key);
if (string == NULL)
- panel_util_key_file_remove_key (
+ panel_key_file_remove_key (
key_file,
revert_keys [i].key);
else
- panel_util_key_file_set_string (
+ panel_key_file_set_string (
key_file,
revert_keys [i].key,
string);
}
g_free (string);
} else if (revert_keys [i].type == G_TYPE_BOOLEAN) {
- boolean = panel_util_key_file_get_boolean (
+ boolean = panel_key_file_get_boolean (
revert_key_file,
revert_keys [i].key,
revert_keys [i].default_value);
- panel_util_key_file_set_boolean (key_file,
- revert_keys [i].key,
- boolean);
+ panel_key_file_set_boolean (key_file,
+ revert_keys [i].key,
+ boolean);
} else {
g_assert_not_reached ();
}
@@ -1572,33 +1575,33 @@
for (i = 0; i < G_N_ELEMENTS (revert_keys); i++) {
if (revert_keys [i].type == G_TYPE_STRING) {
if (revert_keys [i].locale) {
- string = panel_util_key_file_get_locale_string (
+ string = panel_key_file_get_locale_string (
key_file,
revert_keys [i].key);
if (string != NULL)
- panel_util_key_file_set_locale_string (
+ panel_key_file_set_locale_string (
revert_key_file,
revert_keys [i].key,
string);
} else {
- string = panel_util_key_file_get_string (
+ string = panel_key_file_get_string (
key_file,
revert_keys [i].key);
if (string != NULL)
- panel_util_key_file_set_string (
+ panel_key_file_set_string (
revert_key_file,
revert_keys [i].key,
string);
}
g_free (string);
} else if (revert_keys [i].type == G_TYPE_BOOLEAN) {
- boolean = panel_util_key_file_get_boolean (
+ boolean = panel_key_file_get_boolean (
key_file,
revert_keys [i].key,
revert_keys [i].default_value);
- panel_util_key_file_set_boolean (revert_key_file,
- revert_keys [i].key,
- boolean);
+ panel_key_file_set_boolean (revert_key_file,
+ revert_keys [i].key,
+ boolean);
} else {
g_assert_not_reached ();
}
@@ -1631,10 +1634,10 @@
key_file = g_key_file_new ();
- if (!panel_util_key_file_load_from_uri (key_file,
- dialog->priv->uri,
- G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
- error)) {
+ if (!panel_key_file_load_from_uri (key_file,
+ dialog->priv->uri,
+ G_KEY_FILE_KEEP_COMMENTS|G_KEY_FILE_KEEP_TRANSLATIONS,
+ error)) {
g_key_file_free (key_file);
return FALSE;
}
Modified: trunk/gnome-panel/panel-menu-items.c
==============================================================================
--- trunk/gnome-panel/panel-menu-items.c (original)
+++ trunk/gnome-panel/panel-menu-items.c Thu Jun 5 13:36:53 2008
@@ -42,6 +42,8 @@
#include <libgnome/gnome-url.h>
#include <libgnomeui/gnome-url.h>
+#include <libpanel-util/panel-keyfile.h>
+
#include "menu.h"
#include "panel-action-button.h"
#include "panel-globals.h"
@@ -217,11 +219,11 @@
return;
}
- icon = panel_util_key_file_get_locale_string (key_file, "Icon");
- comment = panel_util_key_file_get_locale_string (key_file, "Comment");
+ icon = panel_key_file_get_locale_string (key_file, "Icon");
+ comment = panel_key_file_get_locale_string (key_file, "Comment");
if (string_empty (force_name))
- name = panel_util_key_file_get_locale_string (key_file, "Name");
+ name = panel_key_file_get_locale_string (key_file, "Name");
else
name = g_strdup (force_name);
Modified: trunk/gnome-panel/panel-run-dialog.c
==============================================================================
--- trunk/gnome-panel/panel-run-dialog.c (original)
+++ trunk/gnome-panel/panel-run-dialog.c Thu Jun 5 13:36:53 2008
@@ -48,6 +48,8 @@
#include <gconf/gconf-client.h>
#include <gmenu-tree.h>
+#include <libpanel-util/panel-keyfile.h>
+
#include "nothing.h"
#include "panel-gconf.h"
#include "panel-util.h"
@@ -1029,32 +1031,30 @@
* drag source is enabled, otherwise the drag icon can't be set by
* panel_run_dialog_set_icon.
*/
- temp = panel_util_key_file_get_string (key_file, "Exec");
+ temp = panel_key_file_get_string (key_file, "Exec");
if (temp) {
stripped = remove_parameters (temp);
gtk_entry_set_text (GTK_ENTRY (dialog->gtk_entry),
stripped);
g_free (stripped);
} else {
- temp = panel_util_key_file_get_string (key_file, "URL");
+ temp = panel_key_file_get_string (key_file, "URL");
gtk_entry_set_text (GTK_ENTRY (dialog->gtk_entry),
sure_string (temp));
}
g_free (temp);
- temp = panel_util_key_file_get_locale_string (key_file, "Icon");
+ temp = panel_key_file_get_locale_string (key_file, "Icon");
panel_run_dialog_set_icon (dialog, temp, FALSE);
g_free (temp);
- temp = panel_util_key_file_get_locale_string (key_file, "Comment");
+ temp = panel_key_file_get_locale_string (key_file, "Comment");
//FIXME: if sure_string () == "", we should display "Will run..." as in entry_changed()
gtk_label_set_text (GTK_LABEL (dialog->program_label),
sure_string (temp));
g_free (temp);
- terminal = panel_util_key_file_get_boolean (key_file,
- "Terminal",
- FALSE);
+ terminal = panel_key_file_get_boolean (key_file, "Terminal", FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox),
terminal);
@@ -1742,7 +1742,7 @@
if (!text || !text [0])
return NULL;
- key_file = panel_util_key_file_new_desktop ();
+ key_file = panel_key_file_new_desktop ();
disk = g_locale_from_utf8 (text, -1, NULL, NULL, NULL);
file = panel_util_get_file_optional_homedir (disk);
@@ -1756,43 +1756,39 @@
g_free (scheme);
if (exec) {
- panel_util_key_file_set_string (key_file,
- "Type", "Application");
- panel_util_key_file_set_string (key_file,
- "Exec", text);
+ panel_key_file_set_string (key_file, "Type", "Application");
+ panel_key_file_set_string (key_file, "Exec", text);
name = g_strdup (text);
} else {
char *uri;
uri = g_file_get_uri (file);
- panel_util_key_file_set_string (key_file,
- "Type", "Link");
- panel_util_key_file_set_string (key_file,
- "URL", uri);
+ panel_key_file_set_string (key_file, "Type", "Link");
+ panel_key_file_set_string (key_file, "URL", uri);
name = uri;
}
g_object_unref (file);
- panel_util_key_file_set_locale_string (key_file, "Name",
- (dialog->item_name) ?
- dialog->item_name : text);
+ panel_key_file_set_locale_string (key_file, "Name",
+ (dialog->item_name) ?
+ dialog->item_name : text);
- panel_util_key_file_set_boolean (key_file, "Terminal",
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox)));
+ panel_key_file_set_boolean (key_file, "Terminal",
+ gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->terminal_checkbox)));
if (dialog->icon_path)
- panel_util_key_file_set_locale_string (key_file, "Icon",
- dialog->icon_path);
+ panel_key_file_set_locale_string (key_file, "Icon",
+ dialog->icon_path);
else
- panel_util_key_file_set_locale_string (key_file, "Icon",
- PANEL_ICON_LAUNCHER);
+ panel_key_file_set_locale_string (key_file, "Icon",
+ PANEL_ICON_LAUNCHER);
save_uri = panel_make_unique_desktop_uri (g_get_tmp_dir (), name);
disk = g_filename_from_uri (save_uri, NULL, NULL);
- if (!disk || !panel_util_key_file_to_file (key_file, disk, NULL)) {
+ if (!disk || !panel_key_file_to_file (key_file, disk, NULL)) {
g_free (save_uri);
save_uri = NULL;
}
Modified: trunk/gnome-panel/panel-util.c
==============================================================================
--- trunk/gnome-panel/panel-util.c (original)
+++ trunk/gnome-panel/panel-util.c Thu Jun 5 13:36:53 2008
@@ -28,6 +28,8 @@
#include <libgnome/gnome-util.h>
#include <libgnomeui/gnome-help.h>
+#include <libpanel-util/panel-keyfile.h>
+
#include "applet.h"
#include "nothing.h"
#include "xstuff.h"
@@ -87,8 +89,7 @@
for (i = 0; i < G_N_ELEMENTS (keys); i++) {
char *value;
- value = panel_util_key_file_get_string (keyfile,
- keys [i]);
+ value = panel_key_file_get_string (keyfile, keys [i]);
if (value != NULL) {
gnome_desktop_item_set_string (ditem, keys [i], value);
g_free (value);
@@ -98,8 +99,8 @@
for (i = 0; i < G_N_ELEMENTS (locale_keys); i++) {
char *value;
- value = panel_util_key_file_get_locale_string (keyfile,
- locale_keys [i]);
+ value = panel_key_file_get_locale_string (keyfile,
+ locale_keys [i]);
if (value != NULL) {
gnome_desktop_item_set_string (ditem, locale_keys [i], value);
g_free (value);
@@ -1038,251 +1039,6 @@
return retval;
}
-GKeyFile *
-panel_util_key_file_new_desktop (void)
-{
- GKeyFile *retval;
-
- retval = g_key_file_new ();
-
- //FIXME? g_key_file_set_string (retval, "Desktop Entry", "Name", _("No Name"));
- g_key_file_set_string (retval, "Desktop Entry", "Encoding", "UTF-8");
- g_key_file_set_string (retval, "Desktop Entry", "Version", "1.0");
-
- return retval;
-}
-
-//FIXME: kill this when bug #309224 is fixed
-gboolean
-panel_util_key_file_to_file (GKeyFile *keyfile,
- const gchar *file,
- GError **error)
-{
- gchar *filename;
- GError *write_error;
- gchar *data;
- gsize length;
- gboolean res;
-
- g_return_val_if_fail (keyfile != NULL, FALSE);
- g_return_val_if_fail (file != NULL, FALSE);
-
- write_error = NULL;
- data = g_key_file_to_data (keyfile, &length, &write_error);
- if (write_error) {
- g_propagate_error (error, write_error);
- return FALSE;
- }
-
- if (!g_path_is_absolute (file))
- filename = g_filename_from_uri (file, NULL, &write_error);
- else
- filename = g_filename_from_utf8 (file, -1, NULL, NULL,
- &write_error);
-
- if (write_error) {
- g_propagate_error (error, write_error);
- g_free (data);
- return FALSE;
- }
-
- res = g_file_set_contents (filename, data, length, &write_error);
- g_free (filename);
-
- if (write_error) {
- g_propagate_error (error, write_error);
- g_free (data);
- return FALSE;
- }
-
- g_free (data);
- return res;
-}
-
-gboolean
-panel_util_key_file_load_from_uri (GKeyFile *keyfile,
- const gchar *uri,
- GKeyFileFlags flags,
- GError **error)
-{
- char *scheme;
- gboolean is_local;
- gboolean result;
-
- g_return_val_if_fail (keyfile != NULL, FALSE);
- g_return_val_if_fail (uri != NULL, FALSE);
- g_return_val_if_fail (error == NULL || *error == NULL, FALSE);
-
- scheme = g_uri_parse_scheme (uri);
- is_local = (scheme == NULL) || !g_ascii_strcasecmp (scheme, "file");
- g_free (scheme);
-
- if (is_local) {
- char *path;
-
- if (g_path_is_absolute (uri))
- path = g_filename_from_utf8 (uri, -1, NULL, NULL, NULL);
- else
- path = g_filename_from_uri (uri, NULL, NULL);
- result = g_key_file_load_from_file (keyfile, path,
- flags, error);
- g_free (path);
- } else {
- GFile *file;
- char *contents;
- gsize size;
- gboolean ret;
-
- file = g_file_new_for_uri (uri);
- ret = g_file_load_contents (file, NULL, &contents, &size,
- NULL, NULL);
- g_object_unref (file);
-
- if (!ret)
- return FALSE;
-
- result = g_key_file_load_from_data (keyfile, contents, size,
- flags, error);
-
- g_free (contents);
- }
-
- return result;
-}
-
-gboolean
-panel_util_key_file_get_boolean (GKeyFile *keyfile,
- const gchar *key,
- gboolean default_value)
-{
- GError *error;
- gboolean retval;
-
- error = NULL;
- retval = g_key_file_get_boolean (keyfile, "Desktop Entry", key, &error);
- if (error != NULL) {
- retval = default_value;
- g_error_free (error);
- }
-
- return retval;
-}
-
-void
-panel_util_key_file_set_locale_string (GKeyFile *keyfile,
- const gchar *key,
- const gchar *value)
-{
- const char *locale;
- const char * const *langs_pointer;
- int i;
-
- locale = NULL;
- langs_pointer = g_get_language_names ();
- for (i = 0; langs_pointer[i] != NULL; i++) {
- /* find first without encoding */
- if (strchr (langs_pointer[i], '.') == NULL) {
- locale = langs_pointer[i];
- break;
- }
- }
-
- if (locale)
- g_key_file_set_locale_string (keyfile, "Desktop Entry",
- key, locale, value);
- else
- g_key_file_set_string (keyfile, "Desktop Entry",
- key, value);
-}
-
-void
-panel_util_key_file_remove_locale_key (GKeyFile *keyfile,
- const gchar *key)
-{
- const char * const *langs_pointer;
- int i;
- char *locale_key;
-
- locale_key = NULL;
- langs_pointer = g_get_language_names ();
- for (i = 0; langs_pointer[i] != NULL; i++) {
- /* find first without encoding */
- if (strchr (langs_pointer[i], '.') == NULL) {
- locale_key = g_strdup_printf ("%s[%s]",
- key, langs_pointer[i]);
- if (g_key_file_has_key (keyfile, "Desktop Entry",
- locale_key, NULL))
- break;
-
- g_free (locale_key);
- locale_key = NULL;
- }
- }
-
- if (locale_key) {
- g_key_file_remove_key (keyfile, "Desktop Entry",
- locale_key, NULL);
- g_free (locale_key);
- } else
- g_key_file_remove_key (keyfile, "Desktop Entry",
- key, NULL);
-}
-
-void
-panel_util_key_file_remove_all_locale_key (GKeyFile *keyfile,
- const gchar *key)
-{
- char **keys;
- int key_len;
- int i;
-
- if (!key)
- return;
-
- keys = g_key_file_get_keys (keyfile, "Desktop Entry", NULL, NULL);
- if (!keys)
- return;
-
- key_len = strlen (key);
-
- for (i = 0; keys[i] != NULL; i++) {
- int len;
-
- if (strncmp (keys[i], key, key_len))
- continue;
-
- len = strlen (keys[i]);
- if (len == key_len ||
- (len > key_len && keys[i][key_len] == '['))
- g_key_file_remove_key (keyfile, "Desktop Entry",
- keys[i], NULL);
- }
-
- g_strfreev (keys);
-}
-
-void
-panel_util_key_file_ensure_C_key (GKeyFile *keyfile,
- const char *key)
-{
- char *C_value;
- char *buffer;
-
- /* Make sure we set the "C" locale strings to the terms we set here.
- * This is so that if the user logs into another locale they get their
- * own description there rather then empty. It is not the C locale
- * however, but the user created this entry herself so it's OK */
- C_value = panel_util_key_file_get_string (keyfile, key);
- if (C_value == NULL || C_value [0] == '\0') {
- buffer = panel_util_key_file_get_locale_string (keyfile, key);
- if (buffer) {
- panel_util_key_file_set_string (keyfile, key, buffer);
- g_free (buffer);
- }
- }
- g_free (C_value);
-}
-
char *
guess_icon_from_exec (GtkIconTheme *icon_theme,
GKeyFile *key_file)
@@ -1291,7 +1047,7 @@
char *icon_name;
char *path;
- exec = panel_util_key_file_get_string (key_file, "Exec");
+ exec = panel_key_file_get_string (key_file, "Exec");
if (!exec || !exec [0]) {
g_free (exec);
return NULL;
Modified: trunk/gnome-panel/panel-util.h
==============================================================================
--- trunk/gnome-panel/panel-util.h (original)
+++ trunk/gnome-panel/panel-util.h Thu Jun 5 13:36:53 2008
@@ -94,37 +94,6 @@
int width,
int height);
-GKeyFile *panel_util_key_file_new_desktop (void);
-gboolean panel_util_key_file_to_file (GKeyFile *keyfile,
- const gchar *file,
- GError **error);
-gboolean panel_util_key_file_load_from_uri (GKeyFile *keyfile,
- const gchar *uri,
- GKeyFileFlags flags,
- GError **error);
-gboolean panel_util_key_file_get_boolean (GKeyFile *keyfile,
- const gchar *key,
- gboolean default_value);
-#define panel_util_key_file_get_string(key_file, key) \
- g_key_file_get_string (key_file, "Desktop Entry", key, NULL)
-#define panel_util_key_file_get_locale_string(key_file, key) \
- g_key_file_get_locale_string(key_file, "Desktop Entry", key, NULL, NULL)
-#define panel_util_key_file_set_boolean(key_file, key, value) \
- g_key_file_set_boolean (key_file, "Desktop Entry", key, value)
-#define panel_util_key_file_set_string(key_file, key, value) \
- g_key_file_set_string (key_file, "Desktop Entry", key, value)
-void panel_util_key_file_set_locale_string (GKeyFile *keyfile,
- const gchar *key,
- const gchar *value);
-#define panel_util_key_file_remove_key(key_file, key) \
- g_key_file_remove_key (key_file, "Desktop Entry", key, NULL)
-void panel_util_key_file_remove_locale_key (GKeyFile *keyfile,
- const gchar *key);
-void panel_util_key_file_remove_all_locale_key (GKeyFile *keyfile,
- const gchar *key);
-void panel_util_key_file_ensure_C_key (GKeyFile *keyfile,
- const char *key);
-
char *guess_icon_from_exec (GtkIconTheme *icon_theme,
GKeyFile *key_file);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]