[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright/gtkshell options.c ptk-app-menu.c
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright/gtkshell options.c ptk-app-menu.c |
Date: |
Mon, 06 Sep 2010 20:48:57 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 10/09/06 20:48:57
Modified files:
gtkshell : options.c ptk-app-menu.c
Log message:
Added key/value configuration interface, using -cg to print a value for
a specified key, and -cs to set a specified key to a specified value.
This may speed up ACE, and may lock down some of the XDG compliance.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.55&r2=1.56
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/ptk-app-menu.c?cvsroot=antiright&r1=1.15&r2=1.16
Patches:
Index: options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -b -r1.55 -r1.56
--- options.c 4 Sep 2010 08:06:20 -0000 1.55
+++ options.c 6 Sep 2010 20:48:57 -0000 1.56
@@ -21,6 +21,8 @@
*/
#include "gtkshell.h"
+#include <glib/gstdio.h>
+#include <fcntl.h>
extern FILE *yyin, *yyout;
extern struct GDLEnvironment *gsh_guidl_env;
@@ -66,6 +68,9 @@
common_guidl_handler (gsh);
}
+#define GSH_KEY_FILE "gtkshell"
+#define GSH_KEY_FILE_GROUP "user"
+
static inline gchar *
add_to_usage (gchar *usage, const gchar * key, const gchar * descr)
{
@@ -77,6 +82,68 @@
return usage;
}
+static gchar *
+get_key_filename(void)
+{
+ return g_build_filename(g_get_user_config_dir(), GSH_KEY_FILE, NULL);
+}
+
+static gchar *
+get_value(const gchar * key)
+{
+ GKeyFile *kf;
+ gchar *value;
+ gchar *fn;
+
+ kf = g_key_file_new();
+ fn = get_key_filename();
+ g_key_file_load_from_file(kf, fn, G_KEY_FILE_NONE, NULL);
+ g_free(fn);
+ value = g_key_file_get_string(kf, GSH_KEY_FILE_GROUP, key, NULL);
+ g_key_file_free(kf);
+
+ return value;
+}
+
+__attribute__ ((noreturn))
+static void
+print_value(GSH *gsh __attribute__ ((unused)),
+ gint *counter, const gchar **argv)
+{
+ gchar *value;
+
+ value = get_value(argv[++(*counter)]);
+ if(value)
+ {
+ puts(value);
+ g_free(value);
+ }
+ exit(0);
+}
+
+__attribute__ ((noreturn))
+static void
+set_value(GSH *gsh __attribute__ ((unused)),
+ gint *counter, const gchar **argv)
+{
+ GKeyFile *kf;
+ gchar *data, *fn;
+ gsize data_size;
+ const gchar *key = argv[++(*counter)];
+ const gchar *value = argv[++(*counter)];
+
+ kf = g_key_file_new();
+ g_key_file_set_string(kf, GSH_KEY_FILE_GROUP, key, value);
+ data=g_key_file_to_data(kf, &data_size, NULL);
+ g_key_file_free(kf);
+ fn = get_key_filename();
+ g_file_set_contents(fn, data, (gssize)data_size, NULL);
+ g_free(fn);
+ g_free(data);
+ exit(0);
+}
+
+
static ARTupleVector *
gsh_define_command_line_options (GSH * gsh)
{
@@ -121,6 +188,10 @@
ARTDEF ("-aul", gsh_add_updating_label_cb, "add updating label");
ARTDEF ("-aup", gsh_add_updating_progress_cb, "add updating progress bar");
+ /* Configuration utility */
+ ARTDEF ("-cg", print_value, "print value");
+ ARTDEF ("-cs", set_value, "set value");
+
/* Options */
ARTDEF ("-oa", gsh_option_app_mode_cb, "set app mode");
ARTDEF ("-oc", gsh_option_color_cb, "set color");
Index: ptk-app-menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/ptk-app-menu.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- ptk-app-menu.c 3 Sep 2010 09:17:41 -0000 1.15
+++ ptk-app-menu.c 6 Sep 2010 20:48:57 -0000 1.16
@@ -230,17 +230,19 @@
};
static const CatInfo known_cats[] = {
- {N_("Other"), "Other", "gnome-other", NULL},
- {N_("Game"), "Games", "gnome-joystick", game_cats},
- {N_("Education"), "Education", "gnome-amusements", education_cats},
- {N_("Development"), "Development", "gnome-devel", development_cats},
- {N_("Audio & Video"), "Multimedia", "gnome-multimedia", audiovideo_cats},
- {N_("Graphics"), "Graphics", "gnome-graphics", graphics_cats},
- {N_("Settings"), "Settings", "gnome-settings", settings_cats},
- {N_("System Tools"), "System-Tools", "gnome-system", system_cats},
- {N_("Network"), "Internet", "gnome-globe", network_cats},
- {N_("Office"), "Office", "gnome-applications", office_cats},
- {N_("Accessories"), "Accessories", "gnome-util", utility_cats}
+ {N_("Other"), "Other", "applications-other", NULL},
+ {N_("Game"), "Games", "applications-games", game_cats},
+ {N_("Education"), "Education", "applications-other", education_cats},
+ {N_("Development"), "Development", "applications-development",
+ development_cats},
+ {N_("Audio & Video"), "Multimedia", "applications-multimedia",
+ audiovideo_cats},
+ {N_("Graphics"), "Graphics", "applications-graphics", graphics_cats},
+ {N_("Settings"), "Settings", "preferences-system", settings_cats},
+ {N_("System Tools"), "System-Tools", "applications-system", system_cats},
+ {N_("Network"), "Internet", "applications-internet", network_cats},
+ {N_("Office"), "Office", "applications-office", office_cats},
+ {N_("Accessories"), "Accessories", "applications-accessories", utility_cats}
};
static int
@@ -338,10 +340,12 @@
GSHCONNECT (menu_item, "expose-event", on_menu_item_expose, data);\
GSHCONNECT (menu_item, "size-request", on_menu_item_size_request, data);\
}
-
static char *
translate_exec_to_cmd (const char *exec, const char *icon,
- const char *title, const char *fpath)
+ const char *title)
+#if 0
+ , const char *fpath)
+#endif
{
GString *cmd = g_string_new (NULL);
@@ -366,6 +370,7 @@
APPENDS (icon);
}
break;
+#if 0
case 'U':
case 'u':
case 'F':
@@ -376,6 +381,7 @@
g_free (uri);
break;
}
+#endif
case '%':
APPENDC ('%');
break;
@@ -447,9 +453,9 @@
(GCompareFunc) find_menu_item_by_name);
data = setup_menu_item_label (prev, title, &menu_item);
data->name = g_strdup (fpath + prefix_len);
- data->exec = exec ? translate_exec_to_cmd (exec,
- data->icon, title,
- fpath) : NULL;
+ data->exec = exec
+ ? translate_exec_to_cmd (exec, data->icon, title)
+ : NULL;
g_free (title);
SETUP_MENU_ITEM_SIGNALS (menu_item, data);
data->icon = get_icon (file);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright/gtkshell options.c ptk-app-menu.c,
Jeffrey Bedard <=