[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright ACE-desktop/guidl/Horizontal_Deskbar....
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright ACE-desktop/guidl/Horizontal_Deskbar.... |
Date: |
Thu, 08 Nov 2007 06:41:54 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/11/08 06:41:54
Modified files:
ACE-desktop/guidl: Horizontal_Deskbar.gdl
gtkshell : arguments.c button.c button.h dialog.c
guidl_options.c macros.h menu.c
option_options.c
xshell : button.c
Log message:
Began initial code for command checking of items. This will allow for
dynamic menus in ACE's deskbar.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/guidl/Horizontal_Deskbar.gdl?cvsroot=antiright&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/arguments.c?cvsroot=antiright&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.h?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/dialog.c?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl_options.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/macros.h?cvsroot=antiright&r1=1.16&r2=1.17
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.c?cvsroot=antiright&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/button.c?cvsroot=antiright&r1=1.11&r2=1.12
Patches:
Index: ACE-desktop/guidl/Horizontal_Deskbar.gdl
===================================================================
RCS file:
/sources/antiright/antiright/ACE-desktop/guidl/Horizontal_Deskbar.gdl,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- ACE-desktop/guidl/Horizontal_Deskbar.gdl 2 Nov 2007 19:00:11 -0000
1.34
+++ ACE-desktop/guidl/Horizontal_Deskbar.gdl 8 Nov 2007 06:41:53 -0000
1.35
@@ -4,6 +4,7 @@
option "geometry" "+0-0";
option "undecorated";
option "no fill";
+//option "check commands";
add button "ACE ,Deck_32.png::\n
::-->,multimedia_16.png::Audio/Video::\n
Index: gtkshell/arguments.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/arguments.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- gtkshell/arguments.c 2 Nov 2007 18:01:08 -0000 1.31
+++ gtkshell/arguments.c 8 Nov 2007 06:41:53 -0000 1.32
@@ -46,8 +46,12 @@
{
if(!GSH_FLAG(GSH_ICON_SIZE_IS_CUSTOM))
gsh->icon_size=GTK_ICON_SIZE_DND;
+ if(!(GSH_FLAG(GSH_CHECK_COMMANDS) &&
+ !gsh_check_command_exists(gsh, string)))
+ {
$(gsh, add.button, string);
}
+ }
g_strfreev(tokens);
}
Index: gtkshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- gtkshell/button.c 2 Nov 2007 18:56:55 -0000 1.53
+++ gtkshell/button.c 8 Nov 2007 06:41:53 -0000 1.54
@@ -21,6 +21,36 @@
*/
#include "gtkshell.h"
+#include <sys/stat.h>
+
+gboolean
+gsh_check_command_exists(GSH * gsh, const gchar * command)
+{
+ gboolean return_value=TRUE;
+
+ if(GSH_FLAG(GSH_CHECK_COMMANDS))
+ {
+ const gchar * without_first_word=strchr(command, ' ');
+ const unsigned int space_position=strlen(command)
+ -(without_first_word?strlen(without_first_word):0);
+ gchar * selection=g_strdup(command);
+ gchar * path;
+ gchar * pipe_command;
+
+ selection[space_position]='\0';
+ ar_asprintf(&pipe_command, "which %s", selection);
+ g_free(selection);
+ path=antiright_pipe_read(pipe_command);
+ g_free(pipe_command);
+ {
+ struct stat sb;
+ return_value=stat(path, &sb)==-1?FALSE:TRUE;
+ }
+ g_free(path);
+ }
+
+ return return_value;
+}
static void
create_label_in_menu_item(GtkWidget * widget, const gchar * formatted)
Index: gtkshell/button.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gtkshell/button.h 15 Aug 2007 00:32:51 -0000 1.12
+++ gtkshell/button.h 8 Nov 2007 06:41:53 -0000 1.13
@@ -39,4 +39,7 @@
{ "Close", GTK_STOCK_CLOSE }\
}
+gboolean
+gsh_check_command_exists(GSH * gsh, const gchar * command);
+
#endif
Index: gtkshell/dialog.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/dialog.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gtkshell/dialog.c 13 Aug 2007 07:12:30 -0000 1.1
+++ gtkshell/dialog.c 8 Nov 2007 06:41:53 -0000 1.2
@@ -62,6 +62,8 @@
gtk_color_selection_get_current_color( GTK_COLOR_SELECTION(
GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel), &color);
+ /* Display the selected color on the command line in HTML
+ hexidecimal format. */
g_print("#%x%x%x\n", color.red, color.green, color.blue);
}
Index: gtkshell/guidl_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl_options.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- gtkshell/guidl_options.c 21 Jul 2007 16:16:39 -0000 1.11
+++ gtkshell/guidl_options.c 8 Nov 2007 06:41:53 -0000 1.12
@@ -50,6 +50,7 @@
DEF("application", "-oa");
DEF("icon size", "-oi");
DEF("pane next", "-op");
+ DEF("check commands", "-oC");
}
GSH_GUIDL_ITEM_FUNC(option, DICT);
Index: gtkshell/macros.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/macros.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -b -r1.16 -r1.17
--- gtkshell/macros.h 2 Nov 2007 18:01:08 -0000 1.16
+++ gtkshell/macros.h 8 Nov 2007 06:41:53 -0000 1.17
@@ -42,6 +42,7 @@
#define GSH_TERM_TRANSPARENT GSHBIT(14)
#define GSH_IN_SECONDARY_WIN GSHBIT(15)
#define GSH_ICON_SIZE_IS_CUSTOM GSHBIT(16)
+#define GSH_CHECK_COMMANDS GSHBIT(17)
typedef guint Bitmask;
Index: gtkshell/menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- gtkshell/menu.c 9 Sep 2007 18:03:17 -0000 1.25
+++ gtkshell/menu.c 8 Nov 2007 06:41:54 -0000 1.26
@@ -39,7 +39,9 @@
{
/* Test if a separator should be created. */
if(!strncmp(pair[0], "---", 3))
+ {
setup_separator_menu_item(gsh);
+ }
/* String does not contain \n. */
else if(strncmp(pair[0], "\\n", 2))
{ /* Support continuation lines for menu specification. */
@@ -58,7 +60,12 @@
ARPASSERT(pair[0]);
#endif /* DEBUG */
if(pair[1])
+ {
+ if(gsh_check_command_exists(gsh, pair[0]))
+ {
gsh_image_button(gsh, pair[0], pair[1]);
+ }
+ }
else
parse_special_and_noicon_items(gsh, pair);
g_strfreev(pair);
@@ -78,6 +85,9 @@
GList * children;
children=gtk_container_get_children(GTK_CONTAINER(label));
+#ifdef DEBUG
+ ARPASSERT(children);
+#endif /* DEBUG */
g_list_foreach(children, set_submenu_label, (gchar *)label_text);
g_list_free(children);
}
Index: gtkshell/option_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- gtkshell/option_options.c 2 Nov 2007 18:01:09 -0000 1.34
+++ gtkshell/option_options.c 8 Nov 2007 06:41:54 -0000 1.35
@@ -91,6 +91,11 @@
other gtkshell properties in the future. */
GSH_SET(GSH_APP_MODE);
break;
+ case 'C':
+ /* Check for the existance of a widget's command before
+ displaying an item for it. */
+ GSH_SET(GSH_CHECK_COMMANDS);
+ break;
case 'D':
/* Do not insert the dummy "guidl" string before the
arguments passed by means of a guidl definition.
Index: xshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/xshell/button.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- xshell/button.c 5 Sep 2007 18:19:00 -0000 1.11
+++ xshell/button.c 8 Nov 2007 06:41:54 -0000 1.12
@@ -75,6 +75,15 @@
}
static void
+xshell_system(const char * command)
+{
+ if(!strcmp(command, "Exit___"))
+ exit(0);
+ else
+ system(command);
+}
+
+static void
button_press(XWidget * button)
{
XSHButtonData * data;
@@ -85,7 +94,7 @@
xsh_decorate(button, XSH_DECOR_IN);
#endif /* XSH_DECORATE */
draw_label((XShell *)(button->xsh), button);
- system(data->command);
+ xshell_system(data->command);
}
static void
@@ -111,12 +120,21 @@
button->events.button_release=&button_release;
}
+/* The result must be freed. */
static char *
setup_label(const char * command)
{
char * label;
- label=strchr(command, '#')?label+1:(char*)command;
+ label=strdup(command);
+ /* Start label after comment character, if any. */
+ label=strchr(label, '#')?label+1:(char*)label;
+ {
+ /* Replace underscore characters in label with spaces. */
+ char * iter=label;
+ while((iter=strchr(iter, '_')))
+ iter[0]=' ';
+ }
return label;
}
@@ -153,4 +171,3 @@
}
}
-