[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright gtkshell/guidl_dialog.c gtkshell/opti...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright gtkshell/guidl_dialog.c gtkshell/opti... |
Date: |
Fri, 13 Apr 2007 15:06:17 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/04/13 15:06:17
Modified files:
gtkshell : guidl_dialog.c options.c
libantiright : Makefile library.h
Log message:
Use GTree data structure for storage of key-value pairs in dictionaries.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_dialog.c?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/Makefile?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/library.h?cvsroot=antiright&r1=1.13&r2=1.14
Patches:
Index: gtkshell/guidl_dialog.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_dialog.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gtkshell/guidl_dialog.c 13 Apr 2007 03:59:00 -0000 1.1
+++ gtkshell/guidl_dialog.c 13 Apr 2007 15:06:17 -0000 1.2
@@ -30,36 +30,39 @@
g_free(option_string);
}
+GTree * gsh_guidl_dialog_dictionary=NULL;
+
+static void
+setup_dictionary()
+{
+ gsh_guidl_dialog_dictionary=g_tree_new(strcmp);
+ g_tree_insert(gsh_guidl_dialog_dictionary, "file", "-df");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "font", "-dF");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "about", "-da");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "folder", "-dd");
+ g_tree_insert(gsh_guidl_dialog_dictionary,
+ "create folder", "-dD");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "save", "-ds");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "color", "-dc");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "info", "-di");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "warning", "-dw");
+ g_tree_insert(gsh_guidl_dialog_dictionary, "error", "-de");
+}
+
/* The returned memory must be freed. */
static gchar *
lookup_dialog_flag(gchar * string)
{
- gchar * option_string=NULL;
-
- if(!strcmp(string, "file"))
- option_string=g_strdup("-df");
- else if(!strcmp(string, "font"))
- option_string=g_strdup("-dF");
- else if(!strcmp(string, "about"))
- option_string=g_strdup("-da");
- else if(!strcmp(string, "folder"))
- option_string=g_strdup("-dd");
- else if(!strcmp(string, "create folder"))
- option_string=g_strdup("-dD");
- else if(!strcmp(string, "save"))
- option_string=g_strdup("-ds");
- else if(!strcmp(string, "color"))
- option_string=g_strdup("-dc");
- else if(!strcmp(string, "info"))
- option_string=g_strdup("-di");
- else if(!strcmp(string, "warning"))
- option_string=g_strdup("-dw");
- else if(!strcmp(string, "error"))
- option_string=g_strdup("-de");
- else
- ARWARN("unknown dialog type");
+ if(gsh_guidl_dialog_dictionary == NULL)
+ setup_dictionary();
- return option_string;
+ {
+ gchar * result;
+ result = g_tree_lookup(gsh_guidl_dialog_dictionary, string);
+ if(result == NULL)
+ ARWARN("dialog keyword not found");
+ return result;
+ }
}
void
Index: gtkshell/options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gtkshell/options.c 19 Mar 2007 09:33:07 -0000 1.12
+++ gtkshell/options.c 13 Apr 2007 15:06:17 -0000 1.13
@@ -36,6 +36,8 @@
g_assert((*counter) <= argc);
}
+extern GSList * gsh_guidl_dialog_dictionary;
+
void
gsh_handle_switch_arguments(struct GSH * gsh, int argc,
char **argv, int *counter)
@@ -55,6 +57,8 @@
gsh_append_arg((char*)"guidl");
yyparse();
gsh_parse_arguments(gsh, gsh_parsed_argc, gsh_parsed_argv);
+ if(gsh_guidl_dialog_dictionary != NULL)
+ g_tree_destroy(gsh_guidl_dialog_dictionary);
/* Free parse memory in main. */
break;
case 'o':
@@ -64,6 +68,8 @@
gsh_append_arg((char*)"guidl");
yyparse();
gsh_parse_arguments(gsh, gsh_parsed_argc, gsh_parsed_argv);
+ if(gsh_guidl_dialog_dictionary != NULL)
+ g_tree_destroy(gsh_guidl_dialog_dictionary);
/* Free parse memory in main. */
break;
default:
Index: libantiright/Makefile
===================================================================
RCS file: /sources/antiright/antiright/libantiright/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- libantiright/Makefile 13 Apr 2007 14:41:56 -0000 1.5
+++ libantiright/Makefile 13 Apr 2007 15:06:17 -0000 1.6
@@ -4,7 +4,7 @@
all: libantiright.a
-objects=pipe.o string.o system.o util.o mapping.o
+objects=pipe.o string.o system.o util.o
libantiright.a: ${objects}
ar rcs libantiright.a ${objects}
Index: libantiright/library.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/library.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- libantiright/library.h 13 Apr 2007 14:41:56 -0000 1.13
+++ libantiright/library.h 13 Apr 2007 15:06:17 -0000 1.14
@@ -34,7 +34,6 @@
#include "string.h"
#include "system.h"
#include "util.h"
-#include "mapping.h"
#include "macros.h"
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright gtkshell/guidl_dialog.c gtkshell/opti...,
Jeffrey Bedard <=