[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright ACE-desktop/ACE gtkshell/arguments.c ...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright ACE-desktop/ACE gtkshell/arguments.c ... |
Date: |
Tue, 17 Aug 2010 12:57:13 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 10/08/17 12:57:13
Modified files:
ACE-desktop : ACE
gtkshell : arguments.c button.c callbacks.c guidl.y
image_button.c image_button.h macros.h menu.c
option_options.c option_options.h options.c
ptk-app-menu.c ptk-app-menu.h terminal.c
libantiright : pipe.c string.c string.h system.c
Log message:
Consolidated all image loading code, with core logic in image_button.c.
Simplified and refactored image_button.c and ptk-app-menu.c. Removed
usage of ar_asprintf--use glib functionality instead. Add option -oR,
to
remove the relief from image buttons.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/ACE?cvsroot=antiright&r1=1.59&r2=1.60
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/arguments.c?cvsroot=antiright&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.61&r2=1.62
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/callbacks.c?cvsroot=antiright&r1=1.38&r2=1.39
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/guidl.y?cvsroot=antiright&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/image_button.c?cvsroot=antiright&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/image_button.h?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/macros.h?cvsroot=antiright&r1=1.22&r2=1.23
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&r1=1.31&r2=1.32
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.c?cvsroot=antiright&r1=1.43&r2=1.44
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/option_options.h?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/options.c?cvsroot=antiright&r1=1.47&r2=1.48
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/ptk-app-menu.c?cvsroot=antiright&r1=1.8&r2=1.9
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/ptk-app-menu.h?cvsroot=antiright&r1=1.2&r2=1.3
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal.c?cvsroot=antiright&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/pipe.c?cvsroot=antiright&r1=1.13&r2=1.14
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/string.c?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/string.h?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/system.c?cvsroot=antiright&r1=1.11&r2=1.12
Patches:
Index: ACE-desktop/ACE
===================================================================
RCS file: /sources/antiright/antiright/ACE-desktop/ACE,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -b -r1.59 -r1.60
--- ACE-desktop/ACE 11 Aug 2010 12:03:21 -0000 1.59
+++ ACE-desktop/ACE 17 Aug 2010 12:57:12 -0000 1.60
@@ -663,7 +663,7 @@
ACE_Init
ACE_Check_Configuration_File
-while getopts :ctp:r:L:V:A:g: OPT; do
+while getopts ':ctp:r:L:V:A:g:B:' OPT; do
case $OPT in
c|+c)
ACE_Check_Configuration_File
@@ -702,6 +702,11 @@
$@
exit 0
;;
+ b|+b)
+ shift $(($OPTIND-2))
+ $@ &
+ exit 0
+ ;;
*)
ACE_show_usage_and_exit $0
esac
Index: gtkshell/arguments.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/arguments.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- gtkshell/arguments.c 16 Aug 2010 11:51:21 -0000 1.35
+++ gtkshell/arguments.c 17 Aug 2010 12:57:12 -0000 1.36
@@ -46,12 +46,8 @@
{
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.61
retrieving revision 1.62
diff -u -b -r1.61 -r1.62
--- gtkshell/button.c 16 Aug 2010 11:51:21 -0000 1.61
+++ gtkshell/button.c 17 Aug 2010 12:57:12 -0000 1.62
@@ -23,38 +23,6 @@
#include "gtkshell.h"
#include <glib/gstdio.h>
-bool
-gsh_check_command_exists (GSH * gsh, const gchar * command)
-{
- bool return_value = TRUE;
-
-#ifndef WIN32
- 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 *path;
- {
- gchar *pipe_command;
- {
- gchar *selection = g_strdup (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);
- }
- return_value = g_file_test (path, G_FILE_TEST_EXISTS);
- g_free (path);
- }
-#endif /* !WIN32 */
-
- return return_value;
-}
-
static void
create_label_in_menu_item (GtkWidget * widget, const gchar * formatted)
{
@@ -70,8 +38,10 @@
setup_label (GtkWidget * widget, const gchar * command)
{
gchar *formatted;
+ gchar * tmp=g_strdup(command);
- formatted = antiright_beautified_label (command);
+ formatted = antiright_beautified_label (tmp);
+ g_free(tmp);
GTK_IS_MENU_ITEM (widget) ? create_label_in_menu_item (widget, formatted)
: gtk_button_set_label (GTK_BUTTON (widget), formatted);
g_free (formatted);
@@ -99,7 +69,7 @@
{
gtk_widget_show (gsh->widgets.button = (!GTK_IS_MENU (gsh->rows->v)
&& !GTK_IS_MENU_BAR (gsh->rows->v))
- ? gtk_button_new () : gtk_menu_item_new ());
+ ? gtk_button_new () : gtk_image_menu_item_new ());
}
static void
@@ -108,7 +78,6 @@
gsh_setup_drag_drop (gsh, button);
setup_callback (gsh, button, command);
}
-
static GtkWidget *
label_to_icon_translation (const gchar * label)
{
@@ -126,20 +95,16 @@
if (!strcmp (mapping[mapping_count].label,
g_strstrip ((gchar *) label)))
{
- gtk_widget_show (image =
- gtk_image_new_from_stock (mapping[mapping_count].
- icon,
-
GTK_ICON_SIZE_SMALL_TOOLBAR));
+ gtk_widget_show(image=gsh_get_image(mapping[mapping_count].icon,
+ GTK_ICON_SIZE_BUTTON));
#if GTK_MINOR_VERSION >= 12
gtk_widget_set_tooltip_text (image, label);
#endif
+ break;
}
}
-
- return image ? image : gtk_image_new_from_stock (GTK_STOCK_EXECUTE,
- GTK_ICON_SIZE_SMALL_TOOLBAR);
+ return image;
}
-
static bool
setup_icon_for_toolbutton (GtkWidget * toolbutton, gchar * label_text)
{
@@ -159,8 +124,9 @@
setup_label_for_toolbutton (GtkWidget * toolbutton, const gchar * command)
{
gchar *label_text;
-
- label_text = antiright_beautified_label (command);
+ gchar * tmp=g_strdup(command);
+ label_text = antiright_beautified_label (tmp);
+ g_free(tmp);
gtk_button_set_label (GTK_BUTTON (toolbutton), label_text);
if (setup_icon_for_toolbutton (toolbutton, label_text)
&& (gsh_is_menubar_item (label_text) == GMT_NONE))
@@ -174,7 +140,6 @@
GtkWidget *toolitem;
GtkWidget *toolbutton;
- /* FIXME: change to use the gtk tool_button widget. */
GSH_SHOW_CREATE (toolitem, tool_item);
GSH_SHOW_CREATE (toolbutton, button);
setup_label_for_toolbutton (toolbutton, command);
Index: gtkshell/callbacks.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/callbacks.c,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -b -r1.38 -r1.39
--- gtkshell/callbacks.c 16 Aug 2010 11:51:21 -0000 1.38
+++ gtkshell/callbacks.c 17 Aug 2010 12:57:12 -0000 1.39
@@ -49,7 +49,7 @@
command += 6;
split_command = g_strsplit (command, "#", 2);
- ar_asprintf (&feed_command, "%s\n", split_command[0]);
+ feed_command=g_strconcat(split_command[0], "\n", NULL);
g_strfreev (split_command);
#ifdef HAVE_VTE
vte_terminal_feed_child (VTE_TERMINAL (terminal),
Index: gtkshell/guidl.y
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/guidl.y,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- gtkshell/guidl.y 16 Aug 2010 11:51:21 -0000 1.25
+++ gtkshell/guidl.y 17 Aug 2010 12:57:12 -0000 1.26
@@ -105,9 +105,7 @@
|
OPTION STRING NUM
{
- gchar * num_string;
- ar_asprintf(&num_string, "%d", $3);
- gsh_guidl_option($2, num_string);
+ gsh_guidl_option($2, ar_dtostr($3));
/* num_string is freed in above call. */
}
;
Index: gtkshell/image_button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/image_button.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- gtkshell/image_button.c 16 Aug 2010 11:51:21 -0000 1.23
+++ gtkshell/image_button.c 17 Aug 2010 12:57:12 -0000 1.24
@@ -22,74 +22,72 @@
#include "gtkshell.h"
-static void
-set_up_containers_for_menu_item_row (GtkWidget * button, GtkWidget * hrow,
- GtkWidget * label, GtkWidget * image)
+static inline guint
+gsh_icon_size_to_pixels(const guint icon_size)
{
- GSHCA (button, hrow);
- GSHCA_TIGHT (hrow, image);
- GSHCA (hrow, label);
-}
-
-static void
-setup_row_for_menu_item_image (struct GSH *gsh, GtkWidget * label,
- GtkWidget * image)
-{
- GtkWidget *hrow;
-
- hrow = gtk_hbox_new (FALSE, 2);
- set_up_containers_for_menu_item_row (gsh->widgets.button, hrow,
- label, image);
- gtk_widget_show (hrow);
-}
-
-static void
-set_menu_item_image (struct GSH *gsh, GtkWidget * image)
-{
- GtkWidget *label;
-
- label = gtk_bin_get_child (GTK_BIN (gsh->widgets.button));
- gtk_widget_ref (label);
- gtk_container_remove (GTK_CONTAINER (gsh->widgets.button), label);
- setup_row_for_menu_item_image (gsh, label, image);
- gtk_widget_show (image);
- gtk_widget_show (label);
-}
-
-static void
-set_button_image (GtkWidget * button, GtkWidget * image)
-{
- gtk_button_set_image (GTK_BUTTON (button), image);
- gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
+ switch(icon_size)
+ {
+ case 1:
+ return 16;
+ case 2:
+ return 18;
+ case 0:
+ case 3:
+ case 4:
+ return 24;
+ case 5:
+ return 32;
+ case 6:
+ return 48;
+ default: /* in case icon_size was specified in pixels */
+ return icon_size;
+ }
}
/* Get an image from the antiright icon distribution or the GTK stock
icon set. */
-static GtkWidget *
-get_default_image (struct GSH *gsh, const gchar * name)
+GtkWidget *
+gsh_get_image (const gchar * name, const guint icon_size)
{
- gchar *prefixed_name;
- GtkWidget *image;
-
- ar_asprintf (&prefixed_name, ARDATADIR "/icons/%s", name);
- /* Determine whether to use the file name constructed in prefixed_name
- * or to use a stock icon (tried if the file does not exit). */
- image = g_file_test (prefixed_name, G_FILE_TEST_EXISTS)
- ? gtk_image_new_from_file (prefixed_name)
- : gtk_image_new_from_stock (name, gsh->icon_size);
- g_free (prefixed_name);
-
- if (!image)
- image = gtk_image_new_from_stock ("gtk-execute", gsh->icon_size);
+ const guint8 sz=gsh_icon_size_to_pixels(icon_size);
+ GtkWidget *image=NULL;
+ {
+ GdkPixbuf *pix;
+#define CHKPIX if(pix) goto imagenew
+#define LOADPB(n) gdk_pixbuf_new_from_file_at_size(n,sz,sz,NULL)
+ pix=LOADPB(name);
+ CHKPIX;
+ {
+ gchar *prefixed_name=g_strconcat(ARDATADIR "/icons/", name, NULL);
+ pix=LOADPB(prefixed_name);
+ g_free(prefixed_name);
+ }
+ CHKPIX;
+ {
+ GtkIconInfo * inf;
+#define LOOKUP(n) gtk_icon_theme_lookup_icon(gtk_icon_theme_get_default(),\
+ n, sz, 0)
+ if(!(inf=LOOKUP(name)))
+ inf=LOOKUP("exec");
+ if(inf)
+ {
+ pix=LOADPB(gtk_icon_info_get_filename(inf));
+ gtk_icon_info_free (inf);
+ }
+ }
+imagenew:
+ if(pix)
+ {
+ image=gtk_image_new_from_pixbuf(pix);
+ g_object_unref(pix);
return image;
-}
-
-GtkWidget *
-gsh_get_image (GSH * gsh, const gchar * name)
-{
- return g_file_test (name, G_FILE_TEST_EXISTS)
- ? gtk_image_new_from_file (name) : get_default_image (gsh, name);
+ }
+ }
+ if((image=gtk_image_new_from_stock (name, icon_size)))
+ return image;
+ else
+ return gtk_image_new_from_stock ("gtk-execute", icon_size);
}
void
@@ -97,19 +95,23 @@
{
GtkWidget *image;
- image = gsh_get_image (gsh, name);
$ (gsh, add.button, command);
- ARIFP (image)
+ image = gsh_get_image ((const gchar*)name, gsh->icon_size);
+ if(image)
{
+ GtkWidget *parent=gsh->rows->v;
+ GtkWidget *button=gsh->widgets.button;
gtk_widget_show (image);
- if (!GTK_IS_MENU_BAR (gsh->rows->v)
- && !GTK_IS_MENU_ITEM (gsh->rows->v) && !GTK_IS_MENU (gsh->rows->v))
+ if(!GTK_IS_MENU(parent)/* && !GTK_IS_TOOLBAR(parent))*/)
{
- set_button_image (gsh->widgets.button, image);
+ gtk_button_set_image (GTK_BUTTON (button), image);
+ if(GSH_FLAG(GSH_NO_RELIEF))
+ gtk_button_set_relief (GTK_BUTTON (button), GTK_RELIEF_NONE);
}
- else
+ else /* is menu-related */
{
- set_menu_item_image (gsh, image);
+ gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM(button), image);
}
}
}
+
Index: gtkshell/image_button.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/image_button.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gtkshell/image_button.h 16 Aug 2010 11:51:21 -0000 1.9
+++ gtkshell/image_button.h 17 Aug 2010 12:57:12 -0000 1.10
@@ -1,6 +1,6 @@
/*
AntiRight
- (c) 2002-2007 Jeffrey Bedard
+ (c) 2002-2010 Jeffrey Bedard
address@hidden
This file is part of AntiRight.
@@ -23,8 +23,9 @@
#ifndef GSH_IMAGE_BUTTON_H
#define GSH_IMAGE_BUTTON_H
-GtkWidget *gsh_get_image (GSH * gsh, const gchar * name);
+GtkWidget *gsh_get_image (const gchar *name, const guint icon_size);
void gsh_image_button (struct GSH *gsh, char *command, char *name);
#endif /* GSH_IMAGE_BUTTON_H */
+
Index: gtkshell/macros.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/macros.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -b -r1.22 -r1.23
--- gtkshell/macros.h 16 Aug 2010 11:51:21 -0000 1.22
+++ gtkshell/macros.h 17 Aug 2010 12:57:12 -0000 1.23
@@ -42,10 +42,10 @@
#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)
+#define GSH_NO_RELIEF GSHBIT(17)
#define GSH_HORIZ_CLOCK GSHBIT(18)
-typedef guint Bitmask;
+typedef guint32 Bitmask;
#define GSH_FLAG(flag) ((gsh->bflags & flag) == flag)
#define GSH_SET(flag) gsh->bflags |= flag
Index: gtkshell/menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- gtkshell/menu.c 16 Aug 2010 11:51:21 -0000 1.31
+++ gtkshell/menu.c 17 Aug 2010 12:57:12 -0000 1.32
@@ -25,26 +25,20 @@
#define SPLIT_ALL -1
-static inline void
-setup_separator_menu_item (GSH * gsh)
-{
- GtkWidget *separator;
-
- GSH_SHOW_CREATE (separator, separator_menu_item);
- gtk_menu_shell_append (GTK_MENU_SHELL (gsh->rows->v), separator);
-}
-
static void
parse_special_and_noicon_items (GSH * gsh, gchar ** pair)
{
/* Test if a separator should be created. */
if (!strncmp (pair[0], "---", 3))
{
- setup_separator_menu_item (gsh);
+ GtkWidget * separator;
+
+ GSH_ADD_WIDGET(gsh->rows->v, separator, separator_menu_item);
}
/* String does not contain \n. */
else if (strncmp (pair[0], "\\n", 2))
- { /* Support continuation lines for menu
specification. */
+ {
+ /* Support continuation lines for menu specification. */
/* Create a button. */
$ (gsh, add.button, pair[0]);
}
@@ -60,12 +54,7 @@
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);
@@ -97,8 +86,10 @@
find_and_set_label_widget (GtkWidget * label, const gchar * command)
{
gchar *label_text;
+ gchar * tmp=g_strdup(command);
- label_text = antiright_beautified_label (command);
+ label_text = antiright_beautified_label (tmp);
+ g_free(tmp);
if (GTK_IS_LABEL (label))
set_submenu_label (label, label_text);
else
Index: gtkshell/option_options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -b -r1.43 -r1.44
--- gtkshell/option_options.c 16 Aug 2010 11:51:22 -0000 1.43
+++ gtkshell/option_options.c 17 Aug 2010 12:57:12 -0000 1.44
@@ -30,16 +30,16 @@
}
void
-gsh_option_check_commands_cb (GSH * gsh, gint * counter, const gchar ** argv)
+gsh_option_color_cb (GSH * gsh, gint * counter, const gchar ** argv)
{
- GSH_SET (GSH_CHECK_COMMANDS);
+ gsh->editor.bgcolor = (gchar *) argv[++(*counter)];
+ gsh->editor.fgcolor = (gchar *) argv[++(*counter)];
}
void
-gsh_option_color_cb (GSH * gsh, gint * counter, const gchar ** argv)
+gsh_option_no_relief_cb(GSH * gsh, gint * counter, const gchar ** argv)
{
- gsh->editor.bgcolor = (gchar *) argv[++(*counter)];
- gsh->editor.fgcolor = (gchar *) argv[++(*counter)];
+ GSH_SET (GSH_NO_RELIEF);
}
void
@@ -48,8 +48,6 @@
GSH_SET (GSH_GUIDL_NO_DUMMY);
}
-/*GSH_OPTION_SET_FUNCTION(GSH_PROMPT_ECHOES); */
-
void
gsh_option_echoes_cb (GSH * gsh, gint * counter, const gchar ** argv)
{
Index: gtkshell/option_options.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/option_options.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- gtkshell/option_options.h 16 Aug 2010 11:51:22 -0000 1.12
+++ gtkshell/option_options.h 17 Aug 2010 12:57:12 -0000 1.13
@@ -25,11 +25,10 @@
void gsh_option_app_mode_cb (GSH * gsh, gint * counter, const gchar ** argv);
-void
-gsh_option_check_commands_cb (GSH * gsh, gint * counter, const gchar ** argv);
-
void gsh_option_color_cb (GSH * gsh, gint * counter, const gchar ** argv);
+void gsh_option_no_relief_cb(GSH * gsh, gint * counter, const gchar ** argv);
+
void gsh_option_no_dummy_cb (GSH * gsh, gint * counter, const gchar ** argv);
void gsh_option_echoes_cb (GSH * gsh, gint * counter, const gchar ** argv);
Index: gtkshell/options.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/options.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -b -r1.47 -r1.48
--- gtkshell/options.c 16 Aug 2010 11:51:22 -0000 1.47
+++ gtkshell/options.c 17 Aug 2010 12:57:12 -0000 1.48
@@ -160,7 +160,6 @@
/* Options */
ARTDEF ("-oa", gsh_option_app_mode_cb, "set app mode");
- ARTDEF ("-oC", gsh_option_check_commands_cb, "set check commands");
ARTDEF ("-oc", gsh_option_color_cb, "set color");
ARTDEF ("-oD", gsh_option_no_dummy_cb, "set no dummy");
ARTDEF ("-oE", gsh_option_echoes_cb, "set echoes");
@@ -175,6 +174,7 @@
ARTDEF ("-oL", gsh_option_expand_cb, "set expand");
ARTDEF ("-on", gsh_option_no_decorations_cb, "set no decorations");
ARTDEF ("-op", gsh_option_pane_next_cb, "set adding to next pane");
+ ARTDEF ("-oR", gsh_option_no_relief_cb, "set no relief on image buttons");
ARTDEF ("-or", gsh_option_rows_cb, "set number of rows");
ARTDEF ("-os", gsh_option_scroll_cb, "set scroll");
ARTDEF ("-oT", gsh_option_title_cb, "set window title");
Index: gtkshell/ptk-app-menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/ptk-app-menu.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -b -r1.8 -r1.9
--- gtkshell/ptk-app-menu.c 16 Aug 2010 14:23:42 -0000 1.8
+++ gtkshell/ptk-app-menu.c 17 Aug 2010 12:57:12 -0000 1.9
@@ -9,6 +9,28 @@
* Copyright: GNU Lesser General Public License Version 2
*
*/
+/*
+ AntiRight
+ (c) 2002-2010 Jeffrey Bedard
+ address@hidden
+
+ This file is part of AntiRight.
+
+ AntiRight 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.
+
+ AntiRight 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 AntiRight; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
#include <gtk/gtk.h>
#include <glib/gi18n.h>
@@ -32,18 +54,15 @@
//#include "misc.h" /* Misc functions for lxpanel */
-#define ICON_SIZE 18
GQuark PTK_APP_MENU_ITEM_ID = 0;
+#define ICON_SIZE GTK_ICON_SIZE_SMALL_TOOLBAR
GtkWidget *ptk_app_menu_new ();
static const char desktop_ent[] = "Desktop Entry";
static const char app_dir_name[] = "applications";
-//static time_t* times = NULL;
-
-
typedef struct _CatInfo
{
char *title;
@@ -291,64 +310,24 @@
on_menu_item_size_request (GtkWidget * item,
GtkRequisition * req, gpointer user_data)
{
- const int min_height = ICON_SIZE + (GTK_CONTAINER (item)->border_width +
+ const guint8 min_height = ICON_SIZE + (GTK_CONTAINER (item)->border_width +
item->style->ythickness) * 2;
- if (req->height < min_height)
- {
- req->height = min_height;
- }
- if (req->width < ICON_SIZE)
- req->width = ICON_SIZE;
+#define IFLTSET(x, y) if(x<y) x=y
+ IFLTSET(req->height, min_height);
+ IFLTSET(req->width, ICON_SIZE);
}
static bool
on_menu_item_expose (GtkWidget * item,
GdkEventExpose * evt, gpointer user_data)
{
- GtkWidget *img;
- GdkPixbuf *pix;
-
PtkAppMenuItem *data = (PtkAppMenuItem *) user_data;
- if ((!data) || (!GTK_IS_IMAGE_MENU_ITEM (item)))
+ if ((!data)
+ || (!GTK_IS_IMAGE_MENU_ITEM (item))
+ || (gtk_image_menu_item_get_image ((GtkImageMenuItem *) item)))
return FALSE;
- img = GTK_WIDGET (gtk_image_menu_item_get_image ((GtkImageMenuItem *) item));
- if(img) return FALSE;
- pix = NULL;
- if (data->icon[0] == '/')
- {
- pix = gdk_pixbuf_new_from_file_at_size (data->icon,
- ICON_SIZE, ICON_SIZE, NULL);
- }
- else
- {
- GtkIconInfo *inf;
- inf = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
- data->icon, ICON_SIZE, 0);
- if(!inf)
- {
- inf = gtk_icon_theme_lookup_icon (gtk_icon_theme_get_default (),
- "exec", ICON_SIZE, 0);
- }
- if (inf)
- {
- pix =
- gdk_pixbuf_new_from_file_at_size (gtk_icon_info_get_filename
- (inf), ICON_SIZE, ICON_SIZE,
- NULL);
- gtk_icon_info_free (inf);
- }
- }
- if (G_LIKELY (pix))
- {
- img = gtk_image_new_from_pixbuf (pix);
- g_object_unref(pix);
- }
- else
- {
- img = gtk_image_new ();
- gtk_image_set_pixel_size (GTK_IMAGE (img), ICON_SIZE);
- }
- gtk_image_menu_item_set_image ((GtkImageMenuItem *) item, img);
+ gtk_image_menu_item_set_image ((GtkImageMenuItem *) item,
+ gsh_get_image(data->icon, ICON_SIZE));
return FALSE;
}
@@ -377,7 +356,8 @@
translate_exec_to_cmd (const char *exec, const char *icon,
const char *title, const char *fpath)
{
- GString *cmd = g_string_sized_new (256);
+ GString *cmd = g_string_new(NULL);
+
for (; *exec; ++exec)
{
if (G_UNLIKELY (*exec == '%'))
@@ -387,33 +367,36 @@
break;
switch (*exec)
{
-#define GSAC(x) g_string_append(cmd, x)
+#define APPENDS(x) g_string_append(cmd, x)
+#define APPENDC(x) g_string_append_c(cmd, x)
case 'c':
- GSAC (title);
+ APPENDS (title);
break;
case 'i':
if (icon)
{
- GSAC ("--icon ");
- GSAC (icon);
+ APPENDS ("--icon ");
+ APPENDS (icon);
}
break;
+ case 'U':
+ case 'u':
+ case 'F':
case 'k':
{
char *uri = g_filename_to_uri (fpath, NULL, NULL);
- GSAC (uri);
+ APPENDS (uri);
g_free (uri);
break;
}
case '%':
- GSAC ("%");
+ APPENDC ('%');
break;
}
}
else
- g_string_append_c (cmd, *exec);
+ APPENDC(*exec);
}
-
return g_string_free (cmd, FALSE);
}
@@ -479,6 +462,7 @@
data->exec = exec ? translate_exec_to_cmd (exec,
data->icon, title,
fpath) : NULL;
+ // data->exec=g_strdup(exec);
g_free (title);
SETUP_MENU_ITEM_SIGNALS (menu_item, data);
data->icon = get_icon(file);
@@ -712,7 +696,7 @@
GtkWidget *menu_bar;
GSH_SHOW_CREATE (menu_bar, menu_bar);
- gtk_menu_bar_append (menu_bar, menu_button_item);
+ GSHCA(menu_bar, menu_button_item);
gtk_container_set_border_width (GTK_CONTAINER (menu_bar), 0);
return menu_bar;
Index: gtkshell/ptk-app-menu.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/ptk-app-menu.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -b -r1.2 -r1.3
--- gtkshell/ptk-app-menu.h 16 Aug 2010 11:51:22 -0000 1.2
+++ gtkshell/ptk-app-menu.h 17 Aug 2010 12:57:12 -0000 1.3
@@ -1,5 +1,31 @@
+/*
+ AntiRight
+ (c) 2002-2010 Jeffrey Bedard
+ address@hidden
+
+ This file is part of AntiRight.
+
+ AntiRight 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.
+
+ AntiRight 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 AntiRight; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
+*/
+
#ifndef PTK_APP_MENU_H
#define PTK_APP_MENU_H
-void gsh_add_app_menu_cb (GSH * gsh, gint * counter, const gchar ** argv);
+
+void
+gsh_add_app_menu_cb (GSH * gsh, gint * counter, const gchar ** argv);
+
#endif
+
Index: gtkshell/terminal.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- gtkshell/terminal.c 16 Aug 2010 11:51:22 -0000 1.36
+++ gtkshell/terminal.c 17 Aug 2010 12:57:12 -0000 1.37
@@ -87,11 +87,19 @@
{
/* Set up line and column counts so that VI has correct display
in IDE terminal. */
- gchar *height;
- gchar *width;
+ gchar *height, *width;
/* Use format of a shell export statement. */
- ar_asprintf (&height, "LINES=%d", term->dimensions.height);
- ar_asprintf (&width, "COLUMNS=%d", term->dimensions.width);
+ {
+ gchar *numstr;
+
+ numstr=ar_dtostr(term->dimensions.height);
+ height=g_strconcat("LINES=", numstr, NULL);
+ g_free(numstr);
+ numstr=ar_dtostr(term->dimensions.height);
+ width=g_strconcat("COLUMNS=", numstr, NULL);
+ g_free(numstr);
+ }
+
{
/* Null terminated list of environment elements. */
const gchar *envv[] = { height, width, NULL };
@@ -103,18 +111,8 @@
const gchar *argv[] = { shell, "-c", command, NULL };
/* Start the command in the terminal. */
#ifdef HAVE_VTE
-#if 0
- vte_reaper_add_child (
-#endif
- vte_terminal_fork_command (VTE_TERMINAL
- (term->widget), shell,
- (char **) argv,
- (char **) envv, NULL,
- TRUE, TRUE, TRUE)
-#if 0
- )
-#endif
- ;
+ vte_terminal_fork_command (VTE_TERMINAL (term->widget), shell,
+ (char **) argv, (char **) envv, NULL, TRUE, TRUE, TRUE);
#endif /* HAVE_VTE */
}
/* Free after use. */
Index: libantiright/pipe.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/pipe.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -b -r1.13 -r1.14
--- libantiright/pipe.c 15 Aug 2010 18:52:34 -0000 1.13
+++ libantiright/pipe.c 17 Aug 2010 12:57:13 -0000 1.14
@@ -35,7 +35,7 @@
total=0;
read=0;
- ar_asprintf(&text, "\0");
+ text=g_strdup("\0");
while((read = fread(buffer, sizeof(gchar), BUFSIZ, file)) != 0)
{
total += read;
Index: libantiright/string.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/string.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libantiright/string.c 11 May 2007 23:28:52 -0000 1.11
+++ libantiright/string.c 17 Aug 2010 12:57:13 -0000 1.12
@@ -22,80 +22,50 @@
#include "library.h"
-
-gint
-ar_asprintf(gchar **string, const gchar *format,...)
-{
- va_list list;
- gint return_value;
-
- va_start(list, format);
- return_value = g_vasprintf(string, format, list);
- va_end(list);
-#ifdef DEBUG
- ARASSERT(return_value != -1);
-#endif /* DEBUG */
-
- return return_value;
-}
-
-static gint
+static inline guint
get_last_space(const gchar * text)
{
- gint i;
- gint length;
+ guint i;
+ const size_t length=strlen(text);
- length=strlen(text);
for(i = 0; (i < length) && (*(text+length-i) != ' '); i++);
return length - i;
}
-static void
-substitute_char(gchar ** formatted, gint i)
-{
- if ((*formatted)[i] == '_')
- (*formatted)[i]=' ';
- /* This substitution is needed for constructing ACE
- * commands on drag & drop. */
- if ((*formatted)[i] == '@')
- (*formatted)[i]='_';
-
-}
-
-static void
-substitute(gchar **formatted, gint length)
-{
- gint i;
-
- for (i = 0; i < length; i++)
- substitute_char(formatted, i);
-
- /* Ensure that the string is null-terminated. */
- (*formatted)[i]='\0';
-}
-
-static char *
-get_substituted_label_from_text(const gchar * text)
+static inline gchar*
+substitute(gchar *s)
{
- gchar * formatted;
+ guint i;
+ const size_t l = strlen(s);
+ for(i=0; i++ < l;)
+ switch(s[i])
{
- gint length;
-
- length=ar_asprintf(&formatted, "%s", text);
- substitute(&formatted, length);
+ case '_': s[i]=' '; break;
+ case '@': s[i]='_'; break;
}
- return (formatted);
+ return g_strdup(s);
}
+
/* Free the returned value! */
-char *
-antiright_beautified_label(const gchar *text)
+gchar *
+antiright_beautified_label(gchar *text)
{
text += get_last_space(text);
- return get_substituted_label_from_text(text);
+ return(substitute(text));
+}
+
+gchar *
+ar_dtostr(const gdouble d)
+{
+ gchar *s=g_malloc(G_ASCII_DTOSTR_BUF_SIZE);
+
+ g_ascii_dtostr(s,G_ASCII_DTOSTR_BUF_SIZE, d);
+
+ return s;
}
Index: libantiright/string.h
===================================================================
RCS file: /sources/antiright/antiright/libantiright/string.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- libantiright/string.h 11 May 2007 23:28:52 -0000 1.6
+++ libantiright/string.h 17 Aug 2010 12:57:13 -0000 1.7
@@ -1,6 +1,6 @@
/*
AntiRight
- (c) 2002-2006 Jeffrey Bedard
+ (c) 2002-2010 Jeffrey Bedard
address@hidden
This file is part of AntiRight.
@@ -23,28 +23,12 @@
#ifndef LIBAR_STRING_H
#define LIBAR_STRING_H
-/* Prototype included here, as not defined in glib headers. */
-gint
-g_vasprintf(gchar ** string, gchar const * format, va_list args);
-
-gint
-ar_asprintf(gchar **string, const gchar *format, ...);
+#include <glib/gprintf.h>
gchar *
-antiright_beautified_label(const gchar *string);
+antiright_beautified_label(gchar *text);
-/* char* */
+gchar *
+ar_dtostr(const gdouble d);
-/*
- * antiright_insert_string(char *text, char *insertion, unsigned int
- * position);
- */
-/* char* */
-
-/*
- * antiright_delete_range(char *text, unsigned int start, unsigned int
- * end);
- */
-/* char* */
-/* ar_insert_txt(char* source, char* text, unsigned int position); */
#endif
Index: libantiright/system.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/system.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- libantiright/system.c 13 Dec 2007 03:31:25 -0000 1.11
+++ libantiright/system.c 17 Aug 2010 12:57:13 -0000 1.12
@@ -22,27 +22,9 @@
#include "library.h"
-static gboolean
-must_reformat(char *field_string)
-{
- if (field_string[strlen(field_string) - 1] != '&')
- return TRUE;
- else
- return FALSE;
-}
-
-static char *
-get_command_string(char *field)
-{
- char *new_field;
-
- ARIFB(must_reformat(field))
- ar_asprintf(&new_field, "%s &", field);
- else
- ar_asprintf(&new_field, "%s", field);
-
- return new_field;
-}
+#define MUST_REFORMAT(f) (f[strlen(f)-1]!='&')
+#define GET_COMMAND_STRING(f)\
+ (MUST_REFORMAT(f)?g_strconcat(f, " &", NULL):g_strdup(f))
int
antiright_system(char *field_string)
@@ -50,12 +32,8 @@
char *command;
int return_status;
- command = get_command_string(field_string);
- if((return_status=system(command) == 0 ? EXIT_SUCCESS : EXIT_FAILURE)
- == EXIT_FAILURE)
- {
- ARWARN("command could not be executed");
- }
+ command = GET_COMMAND_STRING(field_string);
+ return_status=system(command);
g_free(command);
return return_status;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright ACE-desktop/ACE gtkshell/arguments.c ...,
Jeffrey Bedard <=