[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright Makefile configure gtkshell/Makefile ...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright Makefile configure gtkshell/Makefile ... |
Date: |
Sun, 10 Jun 2007 20:54:21 -0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/06/10 20:54:01
Modified files:
. : Makefile configure
gtkshell : Makefile gshterm main.c
Added files:
libshell : Makefile about_dialog.c about_dialog.h
add_options.c add_options.h app_mode.c
app_mode.h applets.h arguments.c arguments.h
button.c button.h callbacks.c callbacks.h
clock.c clock.h command_shell.c command_shell.h
containers.c containers.h dialog_options.c
dialog_options.h dragdrop.c dragdrop.h
file_dialog.c file_dialog.h font.c font.h
geometry.c geometry.h gshterm gtkshell.c
gtkshell.h guidl.lex guidl.y guidl_dialog.c
guidl_dialog.h guidl_dictionary.c
guidl_dictionary.h guidl_options.c
guidl_options.h guidl_util.c guidl_util.h
guidl_widgets.c guidl_widgets.h image_button.c
image_button.h init.c init.h label.c label.h
macros.h menu.c menu.h module_includes.h
option_options.c option_options.h options.c
options.h pane.c pane.h row.c row.h
row_struct.h terminal.c terminal.h
terminal_options.c terminal_options.h
terminal_struct.h test text.c text.h tree.c
tree.h update_manager.c update_manager.h
update_manager_struct.h updated.c updated.h
updated_label.c updated_label.h
updated_options.c updated_options.h
updated_progress.c updated_progress.h
xshell : Makefile button.c button.h widget.c widget.h
xshell.c xshell.h
Log message:
Separate gtkshell class hierarchy to separate library.
Added xshell, which is to be an xlib version of gtkshell
for use on low memory systems.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/Makefile?cvsroot=antiright&r1=1.17&r2=1.18
http://cvs.savannah.gnu.org/viewcvs/antiright/configure?cvsroot=antiright&r1=1.102&r2=1.103
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gshterm?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/main.c?cvsroot=antiright&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/Makefile?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/about_dialog.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/about_dialog.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/add_options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/add_options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/app_mode.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/app_mode.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/applets.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/arguments.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/arguments.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/button.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/button.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/callbacks.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/callbacks.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/clock.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/clock.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/command_shell.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/command_shell.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/containers.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/containers.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/dialog_options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/dialog_options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/dragdrop.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/dragdrop.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/file_dialog.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/file_dialog.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/font.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/font.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/geometry.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/geometry.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/gshterm?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/gtkshell.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/gtkshell.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl.lex?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl.y?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_dialog.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_dialog.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_dictionary.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_dictionary.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_util.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_util.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_widgets.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/guidl_widgets.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/image_button.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/image_button.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/init.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/init.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/label.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/label.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/macros.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/menu.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/menu.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/module_includes.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/option_options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/option_options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/pane.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/pane.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/row.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/row.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/row_struct.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/terminal.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/terminal.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/terminal_options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/terminal_options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/terminal_struct.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/test?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/text.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/text.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/tree.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/tree.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/update_manager.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/update_manager.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/update_manager_struct.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated_label.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated_label.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated_options.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated_options.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated_progress.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/libshell/updated_progress.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/Makefile?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/button.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/button.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/widget.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/widget.h?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell.c?cvsroot=antiright&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/antiright/xshell/xshell.h?cvsroot=antiright&rev=1.1
Patches:
Index: Makefile
===================================================================
RCS file: /sources/antiright/antiright/Makefile,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -b -r1.17 -r1.18
--- Makefile 21 May 2007 18:29:22 -0000 1.17
+++ Makefile 10 Jun 2007 20:53:53 -0000 1.18
@@ -29,7 +29,9 @@
all:
cd libantiright && $(MAKE)
+ cd libshell && $(MAKE)
cd gtkshell && $(MAKE)
+ cd xshell && $(MAKE)
cd ACE-desktop && $(MAKE)
ctags:
@@ -37,7 +39,9 @@
clean:
cd libantiright && $(MAKE) clean
+ cd libshell && $(MAKE) clean
cd gtkshell && $(MAKE) clean
+ cd xshell && $(MAKE) clean
cd ACE-desktop && $(MAKE) clean
distclean: clean
@@ -69,6 +73,7 @@
$(INSTALL_DATA) doc/TODO $(docdir)/antiright
$(INSTALL_DATA) doc/INSTALL $(docdir)/antiright
cd gtkshell && $(MAKE) install
+ cd xshell && $(MAKE) install
cd ACE-desktop && $(MAKE) install
bzball: distclean
Index: configure
===================================================================
RCS file: /sources/antiright/antiright/configure,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -b -r1.102 -r1.103
--- configure 1 Jun 2007 18:51:29 -0000 1.102
+++ configure 10 Jun 2007 20:53:53 -0000 1.103
@@ -24,7 +24,7 @@
#
###############################################################################
-VERSION=3.4
+VERSION=3.5
USE_DISTCC=NO
USE_CCACHE=NO
Index: gtkshell/Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- gtkshell/Makefile 1 Jun 2007 18:51:30 -0000 1.35
+++ gtkshell/Makefile 10 Jun 2007 20:53:54 -0000 1.36
@@ -27,40 +27,18 @@
CFLAGS+=$(DEFS) $(INCLUDE)
GTKFLAGS=$(LDFLAGS)
-ARFLAGS=-L../libantiright -lantiright
+ARFLAGS=-L../libantiright -L../libshell -lshell -lantiright
#LDFLAGS+=-lefence
-objects=y.tab.o lex.yy.o gtkshell.o arguments.o options.o callbacks.o\
- label.o button.o text.o updated_label.o updated_progress.o\
- updated_options.o add_options.o option_options.o dialog_options.o\
- file_dialog.o row.o containers.o geometry.o font.o dragdrop.o\
- image_button.o terminal.o terminal_options.o menu.o updated.o\
- guidl_util.o about_dialog.o init.o guidl_dialog.o guidl_dictionary.o\
- guidl_options.o guidl_widgets.o update_manager.o pane.o\
- command_shell.o app_mode.o clock.o
+objects=main.o
-program=main.o
+all: gtkshell
-all: y.tab.c gtkshell
+gtkshell: $(objects)
+ $(CC) -o gtkshell $(objects) $(ARFLAGS) $(LDFLAGS)
-
-gtkshell: y.tab.h $(objects) $(program)
- $(CC) -o gtkshell $(objects) $(program) $(ARFLAGS) $(LDFLAGS)
- ar rcs libgtkshell.a $(objects)
-
-lex.yy.c: guidl.lex
- lex guidl.lex
-
-y.tab.h: lex.yy.c guidl.y
- yacc -d guidl.y
-
-y.tab.c: y.tab.h
-
-parser-clean:
- rm -f *.yy.c *.tab.c *.tab.h
-
-clean: parser-clean
+clean:
rm -f gtkshell *.o libgtkshell.a
install:
Index: gtkshell/gshterm
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gshterm,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gtkshell/gshterm 1 Apr 2007 17:50:42 -0000 1.3
+++ gtkshell/gshterm 10 Jun 2007 20:53:54 -0000 1.4
@@ -9,9 +9,15 @@
GEOMETRY=""
COMMAND=""
DEBUG="FALSE"
+APP_MODE=""
+TRANSPARENT=""
while [ $# -gt 0 ]; do
case "$1" in
+ -a)
+ APP_MODE="-oa File::Exit___ 'Help::gtkshell -da & # About'"
+ break
+ ;;
-e)
shift
COMMAND="\"$*\""
@@ -32,6 +38,10 @@
FONT="$FONT $2"
shift
;;
+ -t)
+ TRANSPARENT="-ott"
+ break
+ ;;
esac
shift
done
@@ -54,8 +64,7 @@
fi
-
-COMMAND="gtkshell -oF $ARGS -oT $COMMAND -as $COMMAND"
+COMMAND="gtkshell $APP_MODE -oF $ARGS -oT $COMMAND -as $COMMAND"
if [ "$DEBUG" = "TRUE" ]; then
echo $COMMAND
Index: gtkshell/main.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/main.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- gtkshell/main.c 20 May 2007 18:46:05 -0000 1.23
+++ gtkshell/main.c 10 Jun 2007 20:53:54 -0000 1.24
@@ -20,7 +20,7 @@
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
USA
*/
-#include "gtkshell.h"
+#include "../libshell/gtkshell.h"
#ifdef LIBGC
#include <gc.h>
Index: libshell/Makefile
===================================================================
RCS file: libshell/Makefile
diff -N libshell/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/Makefile 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,70 @@
+###############################################################################
+#
+# AntiRight
+# (c) 2004-2007 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 ../config.mk
+
+CFLAGS+=$(DEFS) $(INCLUDE)
+GTKFLAGS=$(LDFLAGS)
+ARFLAGS=-L../libantiright -lantiright
+
+#LDFLAGS+=-lefence
+
+#xobjects=
+#gtkobjects=
+
+objects=y.tab.o lex.yy.o gtkshell.o arguments.o options.o callbacks.o\
+ label.o button.o text.o updated_label.o updated_progress.o\
+ updated_options.o add_options.o option_options.o dialog_options.o\
+ file_dialog.o row.o containers.o geometry.o font.o dragdrop.o\
+ image_button.o terminal.o terminal_options.o menu.o updated.o\
+ guidl_util.o about_dialog.o init.o guidl_dialog.o guidl_dictionary.o\
+ guidl_options.o guidl_widgets.o update_manager.o pane.o\
+ command_shell.o app_mode.o clock.o tree.o
+
+program=main.o
+
+all: y.tab.c libshell
+
+libshell: y.tab.h $(objects)
+ ar rcs libshell.a $(objects)
+
+lex.yy.c: guidl.lex
+ lex guidl.lex
+
+y.tab.h: lex.yy.c guidl.y
+ yacc -d guidl.y
+
+y.tab.c: y.tab.h
+
+parser-clean:
+ rm -f *.yy.c *.tab.c *.tab.h
+
+clean: parser-clean
+ rm -f gtkshell *.o libgtkshell.a
+
+#install:
+# install gtkshell $(PREFIX)/bin
+# install gshterm $(PREFIX)/bin
+
Index: libshell/about_dialog.c
===================================================================
RCS file: libshell/about_dialog.c
diff -N libshell/about_dialog.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/about_dialog.c 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,90 @@
+/*
+ AntiRight
+ (c) 2007 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 "gtkshell.h"
+
+static void
+setup_about_license(GtkWidget * dialog)
+{
+ gchar * text;
+
+ gtk_about_dialog_set_license(GTK_ABOUT_DIALOG(dialog),
+ text=antiright_read_named_file(GSH_LICENSE_FILE));
+ g_free(text);
+}
+
+static void
+setup_authors_field(GtkWidget * dialog)
+{
+ const gchar *authors[] = GSH_AUTHORS;
+
+ gtk_about_dialog_set_authors(GTK_ABOUT_DIALOG(dialog),
+ authors);
+}
+
+#define SET_WEBSITE(dialog)\
+ gtk_about_dialog_set_website(GTK_ABOUT_DIALOG(dialog), GSH_WEBSITE);
+
+#define SET_COMMENTS(dialog)\
+ gtk_about_dialog_set_comments(GTK_ABOUT_DIALOG(dialog), GSH_COMMENTS);
+
+#define SET_COPYRIGHT(dialog)\
+ gtk_about_dialog_set_copyright(GTK_ABOUT_DIALOG(dialog),\
+ GSH_COPYRIGHT);
+
+#define SET_VERSION(dialog)\
+ gtk_about_dialog_set_version(GTK_ABOUT_DIALOG(dialog), PACKAGE_STRING);
+
+static void
+setup_logo(GtkAboutDialog * dialog)
+{
+ GtkWidget * image;
+
+#define ARICONDIR "/share/ACE-desktop/icons/"
+ image=gtk_image_new_from_file(PREFIX ARICONDIR "ACE.png");
+ gtk_widget_show(image);
+ gtk_about_dialog_set_logo(dialog,
+ gtk_image_get_pixbuf(GTK_IMAGE(image)));
+}
+
+static GtkWidget *
+setup_about_fields(GtkWidget * dialog)
+{
+ setup_authors_field(dialog);
+ setup_about_license(dialog);
+ setup_logo(GTK_ABOUT_DIALOG(dialog));
+ SET_WEBSITE(dialog);
+ SET_COMMENTS(dialog);
+ SET_COPYRIGHT(dialog);
+ SET_VERSION(dialog);
+
+ return dialog;
+}
+
+void
+gsh_about_dialog()
+{
+ gtk_dialog_run(GTK_DIALOG(setup_about_fields(gtk_about_dialog_new())));
+ exit(0);
+}
+
+
Index: libshell/about_dialog.h
===================================================================
RCS file: libshell/about_dialog.h
diff -N libshell/about_dialog.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/about_dialog.h 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,41 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_ABOUT_DIALOG_H
+#define GSH_ABOUT_DIALOG_H
+
+#define GSH_LICENSE_FILE PREFIX "/share/doc/antiright/COPYING"
+
+#define GSH_AUTHORS \
+{\
+ "Jeffrey E. Bedard <address@hidden>",\
+ NULL\
+}
+
+#define GSH_COPYRIGHT "Copyright 2002-2007, Jeffrey E. Bedard"
+#define GSH_WEBSITE "http://www.nongnu.org/antiright"
+#define GSH_COMMENTS "This is the desktop scripting environment."
+
+void
+gsh_about_dialog() __attribute__((noreturn));
+
+#endif /* GSH_ABOUT_DIALOG_H */
Index: libshell/add_options.c
===================================================================
RCS file: libshell/add_options.c
diff -N libshell/add_options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/add_options.c 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,219 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+add_piped_label(GSH * gsh, const gchar * output)
+{
+ $(gsh, add.label, output);
+}
+
+static void
+add_piped_text(GSH * gsh, const gchar * output)
+{
+ GtkWidget * text_area;
+
+ text_area=gsh_text_area(gsh);
+ (void)gsh_text_area_set_text(text_area, output);
+}
+
+#define GENERIC_FILE_CONTENTS(gsh, add, input)\
+{\
+ add(gsh, input);\
+ g_free(input);\
+}
+
+#define ADD_PIPED_GENERIC(gsh, add)\
+ GENERIC_FILE_CONTENTS(gsh, add, antiright_read_file(stdin))
+
+#define GENERIC_COMMANDED_ADD(gsh, command, add)\
+ GENERIC_FILE_CONTENTS(gsh, add, antiright_pipe_read(command))
+
+static void
+add_new_window(GSH * gsh)
+{
+ $(gsh, add.window);
+ gsh->rows->current=1;
+ $(gsh, init);
+}
+
+static void
+add_separator(GSH * gsh)
+{
+ GtkWidget * separator;
+
+ /* Create a separator widget. If GSH has one row per column,
+ use a vertical separator, else use a horizontal separator.
+ This allows the separator to be used for ACE's Deskbar. */
+ separator = (gsh->rows->total == 1) ?
+ gtk_vseparator_new() : gtk_hseparator_new();
+ /* Show and manage the separator. */
+ $(gsh, manage, separator);
+}
+
+#define GCA_WIDGET(func) \
+ GENERIC_COMMANDED_ADD(gsh, argv[*counter], func)
+
+static void
+handle_commanded_add_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter)
+{
+#ifndef DEBUG
+ UNUSED(argc);
+#endif /* DEBUG */
+ if(!argv[*counter] || !argv[(*counter)+1])
+ return;
+ GSH_COUNT(argc, counter);
+ switch(argv[(*counter)-1][3])
+ {
+ case 'b':
+ GCA_WIDGET(gsh->add.button);
+ break;
+ case 'l':
+ GCA_WIDGET(gsh->add.label);
+ break;
+ }
+}
+
+#ifdef HAVE_VTE
+static void
+add_shell(GSH * gsh, const gchar * command)
+{
+ /* Create a terminal widget that is running COMMAND. */
+ const GtkWidget * terminal = $(gsh->terminal, add, command);
+
+ /* Let GSH manage the terminal widget. */
+ $(gsh, manage, (GtkWidget *)terminal);
+}
+#endif /* HAVE_VTE */
+
+static void
+add_command_shell(GSH * gsh, const gchar * command)
+{
+ GSHCommandShell * shell;
+
+ shell = ARNEW(gsh, GSHCommandShell);
+ $(gsh, manage, $(shell, get));
+ if(command)
+ $(shell, run, command);
+ /* The command instance is not freed here,
+ * as it is accessed by callbacks. */
+}
+
+static void
+handle_applet_arguments(GSH * gsh, const gint argc, const gchar ** argv,
+ gint * counter)
+{
+ const gchar * current_arg = argv[*counter];
+ g_assert(strlen(current_arg) > 2);
+ switch(current_arg[3])
+ {
+ case 'c': /* Add clock. */
+ $(gsh, manage, gsh_clock_new(gsh));
+ break;
+ default:
+ ARWARN("invalid applet argument");
+ }
+}
+
+void
+gsh_handle_add_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter)
+{
+ g_assert(strlen(argv[(*counter)]) > 1);
+ switch (argv[(*counter)][2])
+ {
+ case 'A': /* Add an internally updated applet. */
+ handle_applet_arguments(gsh, argc, argv, counter);
+ break;
+ case 'b':
+ GSH_COUNT(argc, counter);
+ gsh_setup_hpaned(gsh, argv[*counter]);
+ break;
+
+ case 'C':
+ add_command_shell(gsh, NULL);
+ break;
+
+ case 'c':
+ handle_commanded_add_arguments(gsh, argc, argv, counter);
+ break;
+
+ case 'e':
+ GSH_COUNT(argc, counter);
+ gsh_text_editor(gsh, argv[*counter]);
+ break;
+
+ case 'l':
+ GSH_COUNT(argc, counter);
+ $(gsh, add.label, argv[(*counter)]);
+ break;
+
+ case 'P':
+ ADD_PIPED_GENERIC(gsh, add_piped_text);
+ break;
+
+ case 'p':
+ ADD_PIPED_GENERIC(gsh, add_piped_label);
+ break;
+
+ case 'r': /* Force creation of a new row. */
+ $(gsh->rows, new);
+ break;
+
+ case 'S': /* Add a separator. */
+ add_separator(gsh);
+ break;
+
+ case 's': /* Add a shell. */
+ GSH_COUNT(argc, counter);
+#ifdef HAVE_VTE
+ add_shell(gsh, argv[*counter]);
+#else /* not HAVE_VTE */
+ add_command_shell(gsh, argv[*counter]);
+#endif /* HAVE_VTE */
+ break;
+
+ case 't':
+ if (argc != *counter)
+ GSH_COUNT(argc, counter);
+
+ gsh_setup_command_entry(gsh, argv[(*counter)]);
+
+ break;
+ case 'T':
+ gsh_text_area(gsh);
+ break;
+
+ case 'u':
+ gsh_handle_updated_arguments(gsh, argc, argv, counter);
+ break;
+
+ case 'w':
+ add_new_window(gsh);
+ break;
+
+ default:
+ ARWARN("invalid add option");
+ }
+}
Index: libshell/add_options.h
===================================================================
RCS file: libshell/add_options.h
diff -N libshell/add_options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/add_options.h 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,32 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_ADD_OPTIONS_H
+#define GSH_ADD_OPTIONS_H
+
+#include "gtkshell.h"
+
+void
+gsh_handle_add_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter);
+
+#endif
Index: libshell/app_mode.c
===================================================================
RCS file: libshell/app_mode.c
diff -N libshell/app_mode.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/app_mode.c 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,62 @@
+/*
+ AntiRight
+ (c) 2006-2007 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 "gtkshell.h"
+
+#define GW gsh->widgets
+#define GWA GW.app
+
+static void
+setup_app_mode_status_bar(struct GSH * gsh)
+{
+ GSH_SHOW_CREATE(GWA.status, statusbar);
+ GSHCA_TIGHT(GWA.row, GWA.status);
+}
+
+static void
+setup_app_mode_toolbar(GSH * gsh)
+{
+ GSH_SHOW_CREATE(GWA.toolbar, toolbar);
+ GSHCA_TIGHT(GWA.row, GWA.toolbar);
+}
+
+static void
+setup_app_mode_frame(GSH * gsh)
+{
+ GSH_SHOW_CREATE(GWA.frame, frame, NULL);
+ GSHCA(GWA.row, GWA.frame);
+}
+
+void
+gsh_setup_app_mode(struct GSH * gsh)
+{
+ GSH_SHOW_CREATE(GWA.row, vbox, FALSE, 1);
+ /* Add menu bar to application column. */
+ GSHCA_TIGHT(GWA.row, GWA.menubar);
+ setup_app_mode_toolbar(gsh);
+ setup_app_mode_frame(gsh);
+ setup_app_mode_status_bar(gsh);
+}
+
+
+
Index: libshell/app_mode.h
===================================================================
RCS file: libshell/app_mode.h
diff -N libshell/app_mode.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/app_mode.h 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2006-2007 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 GSH_APP_MODE_H
+#define GSH_APP_MODE_H
+
+void
+gsh_setup_app_mode(struct GSH * gsh);
+
+#endif /* not GSH_APP_MODE_H */
Index: libshell/applets.h
===================================================================
RCS file: libshell/applets.h
diff -N libshell/applets.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/applets.h 10 Jun 2007 20:53:54 -0000 1.1
@@ -0,0 +1,3 @@
+
+#include "clock.h"
+
Index: libshell/arguments.c
===================================================================
RCS file: libshell/arguments.c
diff -N libshell/arguments.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/arguments.c 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,94 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+#define SPLIT_ALL -1
+
+static void
+menubar_parse(GSH * gsh, const gchar * string)
+{
+ gchar **tokens;
+
+#ifdef DEBUG
+ ARPASSERT(gsh);
+ ARPASSERT(string);
+#endif /* DEBUG */
+ tokens=g_strsplit(string, "::", SPLIT_ALL);
+ /* Determine if the button is a regular button or a menu button. */
+ tokens[1] ? gsh_menubutton_parse(gsh, tokens)
+ : $(gsh, add.button, string);
+ g_strfreev(tokens);
+}
+
+static void
+add_each_menu(GSH * gsh, gchar ** menubar_tokens)
+{
+ guint i;
+
+#ifdef DEBUG
+ ARPASSERT(gsh);
+ ARPASSERT(menubar_tokens);
+#endif /* DEBUG */
+
+ for(i=0; menubar_tokens[i]; i++)
+ menubar_parse(gsh, menubar_tokens[i]);
+}
+
+/* Decide whether to use a regular button or a menu button. */
+static void
+button_parse(GSH * gsh, const gchar * string)
+{
+ gchar **menubar_tokens;
+
+#ifdef DEBUG
+ ARPASSERT(gsh);
+ ARPASSERT(string);
+#endif /* DEBUG */
+
+ /*
+ This allows a group of buttons and menu buttons to be specified
+ as one argument. This is particularly useful in eliminating the
+ need for the ADD BUTTONS tokens in GUIDL, though that feature
+ will remain as it improves readability of an interface definition.
+ */
+ menubar_tokens=g_strsplit(string, ":::", SPLIT_ALL);
+ /* If ":::" is not found, STRING will be contained in
+ menubar_tokens[0]. */
+ add_each_menu(gsh, menubar_tokens);
+ g_strfreev(menubar_tokens);
+}
+
+void
+gsh_parse_arguments(GSH * gsh, const gint argc, const gchar **argv)
+{
+ gint counter;
+
+ for (counter = 1; counter < argc; counter++)
+ (argv[counter][0] == '-') ?
+ gsh_handle_switch_arguments(gsh, argc, argv, &counter)
+ : button_parse(gsh, argv[counter]);
+#ifdef LIBGC
+ GC_gcollect();
+#endif /* LIBGC */
+}
Index: libshell/arguments.h
===================================================================
RCS file: libshell/arguments.h
diff -N libshell/arguments.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/arguments.h 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,34 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_ARGUMENTS_H
+#define GSH_ARGUMENTS_H
+
+#include "gtkshell.h"
+
+void
+gsh_parse_arguments(GSH * gsh, const gint argc, const gchar **argv);
+
+void
+gsh_check_row(GSH * gsh);
+
+#endif
Index: libshell/button.c
===================================================================
RCS file: libshell/button.c
diff -N libshell/button.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/button.c 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,215 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+create_label_in_menu_item(GtkWidget * widget, const gchar * formatted)
+{
+ GtkWidget * label;
+
+ gtk_container_add(GTK_CONTAINER(widget),
+ label = gtk_label_new(formatted));
+ gtk_widget_show(label);
+}
+
+static void
+setup_label(GtkWidget *widget, const gchar *command)
+{
+ gchar *formatted;
+
+ formatted = antiright_beautified_label(command);
+ GTK_IS_MENU_ITEM(widget) ? create_label_in_menu_item(widget, formatted)
+ : gtk_button_set_label(GTK_BUTTON(widget), formatted);
+ g_free(formatted);
+}
+
+static void
+setup_callback(struct GSH * gsh, GtkWidget * button, const gchar * command)
+{
+ if(!GSH_FLAG(GSH_MENU_BUTTON))
+ {
+ struct GSHCBData * cb;
+
+ cb=ARNEW(gsh, GSHCBData, gsh, g_strdup(command));
+ (void)g_signal_connect(G_OBJECT(button),
+ GTK_IS_MENU_ITEM(button)
+ ? "activate" : "clicked",
+ G_CALLBACK(cb->system), cb);
+ }
+ else
+ GSH_UNSET(GSH_MENU_BUTTON);
+}
+
+static void
+create_button(struct GSH * gsh)
+{
+ if(!GTK_IS_MENU(gsh->rows->v) && !GTK_IS_MENU_BAR(gsh->rows->v))
+ gsh->widgets.button=gtk_button_new();
+ else
+ gtk_widget_show(gsh->widgets.button=gtk_menu_item_new());
+}
+
+static void
+common_button_setup(GSH * gsh, GtkWidget * button, const gchar * command)
+{
+ gsh_setup_drag_drop(gsh, button);
+ setup_callback(gsh, button, command);
+}
+
+static GtkWidget *
+label_to_icon_translation(const gchar * label)
+{
+ GtkWidget * image;
+ gchar * cut_label;
+
+ cut_label=(gchar *)label;
+ g_strstrip(cut_label);
+#define MATCHES(text) !strcmp(text, cut_label)
+#define ICON(id)\
+ gtk_widget_show(image=gtk_image_new_from_stock(GTK_STOCK_##id, \
+ GTK_ICON_SIZE_SMALL_TOOLBAR))
+
+ if(MATCHES("Exit"))
+ ICON(QUIT);
+ else if(MATCHES("About"))
+ ICON(ABOUT);
+ else if(MATCHES("Open..."))
+ ICON(OPEN);
+ else if(MATCHES("Save"))
+ ICON(SAVE);
+ else if(MATCHES("Save As..."))
+ ICON(SAVE_AS);
+ else if(MATCHES("Cut"))
+ ICON(CUT);
+ else if(MATCHES("Copy"))
+ ICON(COPY);
+ else if(MATCHES("Paste"))
+ ICON(PASTE);
+ else if(MATCHES("Close"))
+ ICON(CLOSE);
+ else
+ ICON(EXECUTE);
+
+ return image;
+}
+
+static void
+setup_icon_for_toolbutton(GtkWidget * toolbutton, gchar * label_text)
+{
+ GtkWidget * icon;
+
+ icon = label_to_icon_translation(label_text);
+ if(icon)
+ gtk_button_set_image(GTK_BUTTON(toolbutton), icon);
+}
+
+static void
+setup_label_for_toolbutton(GtkWidget * toolbutton, const gchar * command)
+{
+ gchar * label_text;
+
+ label_text=antiright_beautified_label(command);
+ gtk_button_set_label(GTK_BUTTON(toolbutton), label_text);
+ setup_icon_for_toolbutton(toolbutton, label_text);
+ g_free(label_text);
+}
+
+static void
+setup_toolbutton_from_command_button(GSH * gsh, const gchar * command)
+{
+ GtkWidget * toolbutton;
+
+ /* FIXME: change to use the gtk tool_button widget. */
+ toolbutton=gtk_button_new_with_label(command);
+ common_button_setup(gsh, toolbutton, command);
+ GSHCA(gsh->widgets.app.toolbar, toolbutton);
+ setup_label_for_toolbutton(toolbutton, command);
+ gtk_button_set_relief(GTK_BUTTON(toolbutton), GTK_RELIEF_NONE);
+ gtk_widget_show(toolbutton);
+}
+
+static void
+test_create_toolbutton(GSH * gsh, const gchar * command)
+{
+ if( GSH_FLAG(GSH_APP_MODE)
+ && gsh->widgets.app.toolbar
+ && GTK_IS_MENU_ITEM(gsh->widgets.button)
+ && strcmp(command, "File")
+ && strcmp(command, "Edit")
+ && strcmp(command, "View")
+ && strcmp(command, "Help")
+ && strcmp(command, "Tools"))
+ {
+ setup_toolbutton_from_command_button(gsh, command);
+ }
+}
+
+static void
+setup_command_button(struct GSH * gsh, const gchar * command)
+{
+ GtkWidget * button;
+
+ setup_label(button=gsh->widgets.button, command);
+ common_button_setup(gsh, button, command);
+ test_create_toolbutton(gsh, command);
+ if(GTK_IS_BUTTON(button))
+ gtk_button_set_alignment(GTK_BUTTON(button), 0.0, 0.5);
+}
+
+static gboolean
+test_image_button(struct GSH * gsh, const gchar * string)
+{
+ gchar **pair;
+ gboolean return_value;
+
+ pair=g_strsplit(string, ",", 2);
+#ifdef DEBUG
+ ARPASSERT(pair);
+ ARPASSERT(pair[0]);
+#endif /* DEBUG */
+ if((return_value=(pair[1] != NULL)))
+ gsh_image_button(gsh, pair[0], pair[1]);
+ g_strfreev(pair);
+
+ return return_value;
+}
+
+static void
+gsh_command_button(GSH * gsh, const gchar * command)
+{
+ create_button(gsh);
+ setup_command_button(gsh, command);
+ gsh_manage(gsh, gsh->widgets.button);
+}
+
+/* This is just a wrapper around gsh_new_button(), to
+ follow the convention of returning a created widget. */
+GtkWidget *
+gsh_add_button(struct GSH * gsh, const gchar * string)
+{
+ if(!test_image_button(gsh, string))
+ gsh_command_button(gsh, string);
+
+ return gsh->widgets.button;
+}
+
Index: libshell/button.h
===================================================================
RCS file: libshell/button.h
diff -N libshell/button.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/button.h 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,29 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_BUTTON_H
+#define GSH_BUTTON_H
+
+GtkWidget *
+gsh_add_button(struct GSH * gsh, const gchar * string);
+
+#endif
Index: libshell/callbacks.c
===================================================================
RCS file: libshell/callbacks.c
diff -N libshell/callbacks.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/callbacks.c 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,214 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+void
+gsh_send_signal(GtkWidget * widget, const gchar * signal_name)
+{
+ g_signal_emit_by_name(widget, signal_name);
+}
+
+static void
+gsh_delete_GSHCBData(struct GSHCBData * cb)
+{
+ g_free(cb->data);
+ g_free(cb);
+}
+
+static void
+terminal_feed(gchar * command, GtkWidget * terminal)
+{
+ gchar ** split_command;
+ gchar * feed_command;
+
+ if(!terminal)
+ {
+ ARWARN("terminal command requires a terminal"
+ "to have been created");
+ return;
+ }
+
+ command+=6;
+ split_command=g_strsplit(command, "#", 2);
+ ar_asprintf(&feed_command, "%s\n", split_command[0]);
+ g_strfreev(split_command);
+#ifdef HAVE_VTE
+ vte_terminal_feed_child(VTE_TERMINAL(terminal),
+ feed_command, strlen(feed_command));
+#endif /* HAVE_VTE */
+ g_free(feed_command);
+}
+
+
+#define MATCH(str) !strncmp(command, str, strlen(str))
+
+static gboolean
+test_special_text_editor_command(struct GSH * gsh, const gchar * command)
+{
+ if(MATCH("Save_As...___"))
+ gsh_editor_save_as(gsh);
+ else if(MATCH("Save___"))
+ gsh_editor_save(gsh);
+ else if(MATCH("Open...___"))
+ gsh_editor_open(gsh);
+ else if(MATCH("Cut___"))
+ gsh_send_signal(gsh->editor.widget, "cut-clipboard");
+ else if(MATCH("Copy___"))
+ gsh_send_signal(gsh->editor.widget, "copy-clipboard");
+ else if(MATCH("Paste___"))
+ gsh_send_signal(gsh->editor.widget, "paste-clipboard");
+ else
+ return FALSE;
+
+ /* A special command match was found. */
+ return TRUE;
+}
+
+static gboolean
+test_special_command(struct GSHCBData * cb)
+{
+ const gchar * command = cb->data;
+ struct GSH * gsh = cb->gsh;
+
+
+ if(MATCH("Exit__"))
+ {
+ /* GSH is cleaned up when this causes
+ * a return back to main(). */
+ gtk_main_quit();
+ }
+ else if(MATCH("TERM__"))
+ {
+ terminal_feed((gchar *)command, gsh->terminal->widget);
+ }
+ else
+ {
+ /* Test other special command(s). */
+ if(!test_special_text_editor_command(gsh, command))
+ {
+ /* No special command found. */
+ return FALSE;
+ }
+ }
+
+ /* Special command handled. */
+ return TRUE;
+}
+
+static void
+gsh_system_cb(GtkWidget *widget, gpointer data)
+{
+#ifdef DEBUG
+ ARBUG("system_cb");
+#endif /* DEBUG */
+ UNUSED(widget);
+
+ ARWIFNP(data)
+ {
+ struct GSHCBData *cb = data;
+ if(!test_special_command(cb))
+ (void) antiright_system(cb->data);
+ GSH_TEST_EXIT(cb->gsh);
+ }
+#ifdef LIBGC
+ GC_gcollect();
+#endif /* LIBGC */
+}
+
+static void
+exec_and_test_print(struct GSHCBData * cb, const gchar * input)
+{
+ struct GSH * gsh;
+
+ gsh=cb->gsh;
+
+ if(GSH_FLAG(GSH_PROMPT_ECHOES))
+ g_print("%s\n", input);
+ else
+ sysprintf("%s %s", (char *) cb->data,
+ (char *) input);
+}
+
+static void
+gsh_entry_cb(GtkWidget *widget, gpointer data)
+{
+ struct GSHCBData *cb;
+
+#ifdef DEBUG
+ ARPASSERT(widget);
+ ARPASSERT(data);
+#endif /* DEBUG */
+
+ /* Convert to dereferencable form. */
+ cb = (struct GSHCBData *) data;
+
+ {
+ GtkWidget * combo_box;
+ /* INPUT must not be freed, as
+ it is internal to the widget. */
+ const gchar *input;
+ /* Get widget from which to retrieve text. */
+ combo_box=gtk_widget_get_ancestor(widget, GTK_TYPE_COMBO_BOX);
+ /* Get the text from the widget. */
+ input = gtk_combo_box_get_active_text(
+ GTK_COMBO_BOX(combo_box));
+#ifdef DEBUG
+ /* Check return value INPUT. */
+ ARPASSERT(input);
+#endif /* DEBUG */
+ exec_and_test_print(cb, input);
+ /* Determine whether or not to exit
+ because of this callback. */
+ GSH_TEST_EXIT(cb->gsh);
+ /* Add retrieved text to combo box popup list. */
+ gtk_combo_box_prepend_text(GTK_COMBO_BOX(combo_box),
+ (gchar *)input);
+ }
+}
+
+/* Assign the function pointers for GSHCBData's methods. */
+static void
+assign_GSHCBData_methods(struct GSHCBData * cb)
+{
+ cb->delete=&gsh_delete_GSHCBData;
+ cb->entry=&gsh_entry_cb;
+ cb->system=&gsh_system_cb;
+}
+
+/* GSHCBData Constructor */
+struct GSHCBData *
+gsh_new_GSHCBData(struct GSH * gsh, gpointer data)
+{
+ struct GSHCBData * cb;
+
+ /* Allocate. */
+ cb = xmalloc(sizeof(struct GSHCBData));
+ /* Store constructor arguments. */
+ cb->gsh=gsh;
+ cb->data=data;
+ /* Set up methods. */
+ assign_GSHCBData_methods(cb);
+
+ return cb;
+}
+
Index: libshell/callbacks.h
===================================================================
RCS file: libshell/callbacks.h
diff -N libshell/callbacks.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/callbacks.h 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,48 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_CALLBACKS_H
+#define GSH_CALLBACKS_H
+
+struct GSHCBData
+{
+ struct GSH *gsh;
+ gpointer data;
+ void (*delete)(struct GSHCBData *);
+ void (*system)(GtkWidget *, gpointer);
+ void (*entry)(GtkWidget *, gpointer);
+};
+
+struct GSHCBData *
+gsh_new_GSHCBData(struct GSH * gsh, gpointer data);
+
+#define GSH_TEST_EXIT(gsh_arg)\
+{\
+ struct GSH * gsh = gsh_arg;\
+ if (GSH_FLAG(GSH_CBEXIT))\
+ gtk_main_quit();\
+}
+
+void
+gsh_send_signal(GtkWidget * widget, const gchar * signal_name);
+
+#endif /* not GSH_CALLBACKS_H */
Index: libshell/clock.c
===================================================================
RCS file: libshell/clock.c
diff -N libshell/clock.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/clock.c 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,73 @@
+/*
+ AntiRight
+ (c) 2007 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 "gtkshell.h"
+#include <time.h>
+
+static gchar *
+get_time_string()
+{
+ gchar * time_string;
+ struct tm split_time;
+ time_t time_value;
+
+ (void)time(&time_value);
+ (void)localtime_r(&time_value, &split_time);
+ asprintf(&time_string, "%.2d/%.2d/%.2d\n%.2d:%.2d:%.2d",
+ split_time.tm_mon+1,
+ split_time.tm_mday,
+ split_time.tm_year%100,
+ split_time.tm_hour,
+ split_time.tm_min,
+ split_time.tm_sec);
+
+ return time_string;
+}
+
+static void
+update_clock(const gchar * command, gpointer clock_pointer)
+{
+ GtkWidget * clock;
+ gchar * time_string;
+
+ UNUSED(command);
+ clock=(GtkWidget *)clock_pointer;
+ time_string=get_time_string();
+ gtk_label_set_text(GTK_LABEL(clock), time_string);
+ g_free(time_string);
+}
+
+GtkWidget *
+gsh_clock_new(GSH * gsh)
+{
+ GtkWidget * clock;
+ struct GSHUpdatedWidget * updated_widget;
+
+ clock=gtk_label_new(NULL);
+ gsh_widget_set_font(clock, NULL);
+ updated_widget=ARNEW(gsh, GSHUpdatedWidget,
+ &update_clock, NULL, clock);
+ $(gsh->update, add, updated_widget);
+
+ return clock;
+}
+
Index: libshell/clock.h
===================================================================
RCS file: libshell/clock.h
diff -N libshell/clock.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/clock.h 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_CLOCK_H
+#define GSH_CLOCK_H
+
+GtkWidget *
+gsh_clock_new(GSH * gsh);
+
+#endif /* GSH_CLOCK_H */
+
Index: libshell/command_shell.c
===================================================================
RCS file: libshell/command_shell.c
diff -N libshell/command_shell.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/command_shell.c 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,126 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+gsh_delete_GSHCommandShell(GSHCommandShell * this)
+{
+ g_free(this);
+}
+
+static GtkWidget *
+get_command_shell(GSHCommandShell * this)
+{
+ return this->widgets.row;
+}
+
+static void
+run_command(GSHCommandShell * this, const gchar * command)
+{
+ gchar * result;
+
+ result=antiright_pipe_read(command);
+ gtk_label_set_text(GTK_LABEL(this->widgets.output), result);
+ g_free(result);
+}
+
+static void
+run_command_cb(GtkWidget * widget, gpointer data)
+{
+ GSHCommandShell * this;
+ GtkEntry * entry;
+
+ this=(GSHCommandShell *)data;
+ entry=GTK_ENTRY(this->widgets.input);
+ run_command(this, gtk_entry_get_text(entry));
+ gtk_entry_set_text(entry, "");
+}
+
+static void
+setup_command_shell_methods(GSHCommandShell * this)
+{
+ this->delete=&gsh_delete_GSHCommandShell;
+ this->get=&get_command_shell;
+ this->run=&run_command;
+}
+
+static void
+set_output_label_options(GtkWidget * output)
+{
+ gtk_label_set_justify(GTK_LABEL(output), GTK_JUSTIFY_LEFT);
+ gsh_widget_set_font(output, NULL);
+ gtk_label_set_selectable(GTK_LABEL(output), TRUE);
+}
+
+static void
+setup_output_scroller(GtkWidget * row, GtkWidget * output)
+{
+ GtkWidget * scroller;
+
+ GSH_SHOW_CREATE(scroller, scrolled_window, NULL, NULL);
+ gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroller),
+ GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
+ GSHCA(row, scroller);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroller),
+ output);
+}
+
+static void
+setup_output_area(GSHCommandShell * this)
+{
+ GtkWidget * output;
+
+ GSH_SHOW_CREATE(this->widgets.output, label, NULL);
+ output=this->widgets.output;
+ set_output_label_options(output);
+ setup_output_scroller(this->widgets.row, output);
+}
+
+static void
+setup_command_shell_widgets(GSHCommandShell * this)
+{
+ GSH_SHOW_CREATE(this->widgets.row, vbox, 0, FALSE);
+ setup_output_area(this);
+ GSH_SHOW_CREATE(this->widgets.input, entry);
+ GSHCONNECT(this->widgets.input, "activate", run_command_cb, this);
+ GSHCA_TIGHT(this->widgets.row, this->widgets.input);
+}
+
+static void
+setup_command_shell(GSHCommandShell * this)
+{
+ setup_command_shell_methods(this);
+ setup_command_shell_widgets(this);
+}
+
+GSHCommandShell *
+gsh_new_GSHCommandShell()
+{
+ GSHCommandShell * shell;
+
+ shell=xmalloc(sizeof(GSHCommandShell));
+ setup_command_shell(shell);
+
+ return shell;
+}
+
Index: libshell/command_shell.h
===================================================================
RCS file: libshell/command_shell.h
diff -N libshell/command_shell.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/command_shell.h 10 Jun 2007 20:53:55 -0000 1.1
@@ -0,0 +1,44 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_CMDSHELL_H
+#define GSH_CMDSHELL_H
+
+struct GSHCommandShell
+{
+ struct
+ {
+ GtkWidget * input;
+ GtkWidget * output;
+ GtkWidget * row;
+ } widgets;
+ void (*delete)(struct GSHCommandShell *);
+ void (*run)(struct GSHCommandShell *, const gchar *);
+ GtkWidget * (*get)(struct GSHCommandShell *);
+};
+
+typedef struct GSHCommandShell GSHCommandShell;
+
+GSHCommandShell *
+gsh_new_GSHCommandShell();
+
+#endif /* GSH_CMDSHELL_H */
Index: libshell/containers.c
===================================================================
RCS file: libshell/containers.c
diff -N libshell/containers.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/containers.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,110 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+/* GTK Scrolled Window Set */
+#define GSWS(item, window, ...)\
+ gtk_scrolled_window_set_##item(GTK_SCROLLED_WINDOW(window),\
+ __VA_ARGS__)
+
+static void
+set_scrolled_window_options(GtkWidget * win)
+{
+#define GSWSW(item, ...) GSWS(item, win, __VA_ARGS__)
+ GSWSW(shadow_type, GTK_SHADOW_OUT);
+/* Shortened name. */
+#define GTKPA GTK_POLICY_AUTOMATIC
+ GSWSW(policy, GTKPA, GTKPA);
+}
+
+static void
+setup_scrolled_window_containers(GtkWidget * scrolled_window,
+ GtkWidget * window, GtkWidget * hrow)
+{
+ GSHCA(window, scrolled_window);
+ /* Add the main row manager to the scrolled window. */
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(
+ scrolled_window), hrow);
+}
+
+static void
+gsh_setup_scrolled_window(struct GSH * gsh)
+{
+ GtkWidget * scrolled_window;
+
+ scrolled_window=gsh->widgets.scrolled_window
+ =gtk_scrolled_window_new(NULL, NULL);
+ set_scrolled_window_options(gsh->widgets.scrolled_window);
+ setup_scrolled_window_containers(scrolled_window, gsh->widgets.window,
+ gsh->rows->h);
+ gtk_widget_show(scrolled_window);
+}
+
+static void
+setup_framed_containers(GtkWidget * frame, GtkWidget * window,
+ GtkWidget * hrow)
+{
+ GSHCA(window, frame);
+ GSHCA(frame, hrow);
+}
+
+static void
+setup_framed(struct GSH * gsh)
+{
+ GtkWidget * frame;
+
+ frame = gtk_frame_new(NULL);
+ setup_framed_containers(frame, gsh->widgets.window, gsh->rows->h);
+ gtk_widget_show(frame);
+}
+
+void
+gsh_setup_containers(struct GSH * gsh)
+{
+ gtk_widget_show(gsh->rows->h = gtk_hbox_new(FALSE, 2));
+ $(gsh->rows, new);
+}
+
+#define GWA gsh->widgets.app
+
+static void
+setup_app_mode_frame(struct GSH * gsh)
+{
+ gtk_container_add(GTK_CONTAINER(GWA.frame),
+ gsh->rows->h);
+ gsh->rows->h=GWA.row;
+}
+
+void
+gsh_setup_base_container(struct GSH * gsh)
+{
+ if(GWA.frame)
+ setup_app_mode_frame(gsh);
+ if (GSH_FLAG(GSH_SCROLL))
+ gsh_setup_scrolled_window(gsh);
+ else if (!GSH_FLAG(GSH_NO_BASE_FRAME))
+ setup_framed(gsh);
+ else
+ GSHCA(gsh->widgets.window, gsh->rows->h);
+}
+
Index: libshell/containers.h
===================================================================
RCS file: libshell/containers.h
diff -N libshell/containers.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/containers.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,32 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_CONTAINERS_H
+#define GSH_CONTAINERS_H
+
+void
+gsh_setup_containers(struct GSH * gsh);
+
+void
+gsh_setup_base_container(struct GSH * gsh);
+
+#endif /* GSH_CONTAINERS_H */
Index: libshell/dialog_options.c
===================================================================
RCS file: libshell/dialog_options.c
diff -N libshell/dialog_options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/dialog_options.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,151 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+gsh_message_dialog(GSH * gsh, GtkMessageType type, const gchar *text)
+ __attribute__((noreturn));
+
+static void
+gsh_font_dialog() __attribute__((noreturn));
+
+static void
+gsh_color_dialog() __attribute__((noreturn));
+
+static void
+gsh_message_dialog(GSH * gsh, GtkMessageType type, const gchar *text)
+{
+ gtk_dialog_run(GTK_DIALOG(gtk_message_dialog_new(GTK_WINDOW(
+ gsh->widgets.window), GTK_DIALOG_DESTROY_WITH_PARENT, type,
+ GTK_BUTTONS_CLOSE, (gchar *) text)));
+
+ exit(0);
+}
+
+#define GMD gsh_message_dialog
+
+#define ERROR_DIALOG(gsh, message) \
+ GMD(gsh, GTK_MESSAGE_ERROR, message)
+#define INFO_DIALOG(gsh, message) \
+ GMD(gsh, GTK_MESSAGE_INFO, message)
+#define WARNING_DIALOG(gsh, message) \
+ GMD(gsh, GTK_MESSAGE_WARNING, message)
+
+static void
+select_font(GtkWidget * dialog)
+{
+ gchar *font;
+
+ font = gtk_font_selection_dialog_get_font_name(
+ GTK_FONT_SELECTION_DIALOG(dialog));
+ g_print("%s\n", font);
+ g_free(font);
+}
+
+static void
+gsh_font_dialog()
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_font_selection_dialog_new("Font Selector");
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+ select_font(dialog);
+
+ exit(0);
+}
+
+static void
+color_select(GtkWidget * dialog)
+{
+ GdkColor color;
+
+ gtk_color_selection_get_current_color( GTK_COLOR_SELECTION(
+ GTK_COLOR_SELECTION_DIALOG(dialog)->colorsel), &color);
+ g_print("#%x%x%x\n", color.red, color.green, color.blue);
+}
+
+static void
+gsh_color_dialog()
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_color_selection_dialog_new("Color Selector");
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_OK)
+ color_select(dialog);
+
+ exit(0);
+}
+
+void
+gsh_handle_dialog_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter)
+{
+#ifndef DEBUG
+ UNUSED(argc);
+#endif /* DEBUG */
+ g_assert(strlen(argv[(*counter)]) > 2);
+#ifdef DEBUG
+ ARPASSERT(gsh);
+#endif /* DEBUG */
+ switch (argv[(*counter)][2])
+ {
+ case 'a':
+ gsh_about_dialog();
+ break;
+ case 'c': /* Color Selection */
+ gsh_color_dialog();
+ break;
+ case 'D': /* Folder Creation Selector */
+ GSH_FOLDER_CREATE_DIALOG(gsh);
+ break;
+ case 'd': /* Folder Selector */
+ GSH_FOLDER_OPEN_DIALOG(gsh);
+ break;
+ case 'e': /* Error Message */
+ GSH_COUNT(argc, counter);
+ ERROR_DIALOG(gsh, argv[*counter]);
+ break;
+ case 'F': /* Font Selection */
+ gsh_font_dialog();
+ break;
+ case 'f':
+ /* File Selection */
+ GSH_FILE_OPEN_DIALOG(gsh);
+ break;
+ case 'i': /* Information */
+ GSH_COUNT(argc, counter);
+ INFO_DIALOG(gsh, argv[*counter]);
+ break;
+ case 's': /* Filename Selection for Saving */
+
+ GSH_FILE_SAVE_DIALOG(gsh);
+ break;
+ case 'w': /* Warning */
+ GSH_COUNT(argc, counter);
+ WARNING_DIALOG(gsh, argv[*counter]);
+ break;
+ default:
+ ARWARN("invalid dialog option");
+ }
+}
Index: libshell/dialog_options.h
===================================================================
RCS file: libshell/dialog_options.h
diff -N libshell/dialog_options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/dialog_options.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_DIALOG_OPTIONS
+#define GSH_DIALOG_OPTIONS
+
+void
+gsh_handle_dialog_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter);
+
+#endif
Index: libshell/dragdrop.c
===================================================================
RCS file: libshell/dragdrop.c
diff -N libshell/dragdrop.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/dragdrop.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,160 @@
+/*
+ AntiRight (c) 2007 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 "gtkshell.h"
+
+/*
+ * Portions Copyright 2005 Ryan McDougall, GNU GPL terms. Based on drag
+ * and drop tutorial: http://live.gnome.org/GnomeLove/DragNDropTutorial
+ */
+
+enum
+{
+ TARGET_STRING
+};
+
+static GtkTargetEntry target_list[] =
+{
+ {(gchar *)"text/plain", 0, TARGET_STRING}
+};
+
+static guint n_targets = G_N_ELEMENTS(target_list);
+
+static void
+drag_received(GtkWidget *widget, GdkDragContext * context, gint x,
+ gint y, GtkSelectionData * selection, guint target_type,
+ guint time, gpointer data);
+
+static gboolean
+drag_drop(GtkWidget *widget, GdkDragContext * context, gint x,
+ gint y, guint time, gpointer data);
+
+static void
+drag_data_get(GtkWidget *widget, GdkDragContext * context,
+ GtkSelectionData * selection, guint target_type,
+ guint time, gpointer data);
+
+/*static void
+ drag_begin(GtkWidget *widget, GdkDragContext * context, gpointer data);
+
+static void
+ drag_end(GtkWidget *widget, GdkDragContext * context, gpointer data);*/
+
+#define DND_SIGNAL(sig, func) \
+ (void) g_signal_connect(widget, sig, G_CALLBACK(func), NULL)
+
+#define SETUP_DRAG_DROP_SIGNALS(widget)\
+{\
+ DND_SIGNAL("drag-data-received", drag_received);\
+ DND_SIGNAL("drag-drop", drag_drop);\
+ DND_SIGNAL("drag-data-get", drag_data_get);\
+}
+
+void
+gsh_setup_drag_drop(struct GSH * gsh, GtkWidget *widget)
+{
+ gtk_drag_dest_set(widget, GTK_DEST_DEFAULT_MOTION
+ | GTK_DEST_DEFAULT_HIGHLIGHT, target_list, n_targets,
+ GDK_ACTION_COPY);
+
+ gtk_drag_source_set(widget, GDK_BUTTON1_MASK, target_list, n_targets,
+ GDK_ACTION_COPY);
+
+ SETUP_DRAG_DROP_SIGNALS(widget);
+
+ if (GSH_FLAG(GSH_CBEXIT))
+ DND_SIGNAL("drag-end", gtk_main_quit);
+}
+
+static void
+drag_received(GtkWidget *widget, GdkDragContext * context, gint x,
+ gint y, GtkSelectionData * selection, guint target_type,
+ guint time, gpointer data)
+{
+ gboolean drag_status;
+
+ UNUSED(x);
+ UNUSED(y);
+ UNUSED(data);
+ switch (target_type)
+ {
+ case TARGET_STRING:
+ sysprintf("%s %s",
+ (const gchar *)gtk_button_get_label(
+ GTK_BUTTON(widget)),
+ (gchar *) selection->data);
+ drag_status = TRUE;
+ break;
+ default:
+ drag_status = FALSE;
+ ARWARN("invalid data dropped");
+ }
+
+ gtk_drag_finish(context, drag_status, FALSE, time);
+}
+
+static gboolean
+drag_drop(GtkWidget *widget, GdkDragContext * context, gint x,
+ gint y, guint time, gpointer data)
+{
+ GdkAtom target_type;
+
+ UNUSED(x);
+ UNUSED(y);
+ UNUSED(data);
+ target_type =
+ GDK_POINTER_TO_ATOM(g_list_nth_data(context->targets,
+ TARGET_STRING));
+
+ ARIFP(context->targets)
+ {
+ gtk_drag_get_data(widget, context, target_type, time);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+static void
+drag_data_get(GtkWidget *widget, GdkDragContext * context,
+ GtkSelectionData * selection, guint target_type,
+ guint time, gpointer data)
+{
+ const gchar *source_data;
+
+ UNUSED(context);
+ UNUSED(target_type);
+ UNUSED(time);
+ UNUSED(data);
+ source_data = gtk_button_get_label(GTK_BUTTON(widget));
+ gtk_selection_data_set(selection, selection->target, sizeof(gchar),
+ (guchar *) source_data, strlen(source_data));
+}
+
+/* Use to set icon. */
+/*static void
+drag_begin(GtkWidget *widget, GdkDragContext * context, gpointer data)
+{
+}
+
+static void
+drag_end(GtkWidget *widget, GdkDragContext * context, gpointer data)
+{
+}*/
Index: libshell/dragdrop.h
===================================================================
RCS file: libshell/dragdrop.h
diff -N libshell/dragdrop.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/dragdrop.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,29 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_DRAGDROP_H
+#define GSH_DRAGDROP_H
+
+void
+ gsh_setup_drag_drop(struct GSH * gsh, GtkWidget *widget);
+
+#endif /* GSH_DRAGDROP_H */
Index: libshell/file_dialog.c
===================================================================
RCS file: libshell/file_dialog.c
diff -N libshell/file_dialog.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/file_dialog.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,50 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 "gtkshell.h"
+
+static void
+file_dialog_submit(GtkWidget * dialog)
+{
+ gchar *name;
+
+ name = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ g_print("%s\n", name);
+ g_free(name);
+}
+
+/* Taken from the GTK+ Reference Manual */
+void
+gsh_file_dialog(struct GSH * gsh, GtkFileChooserAction action)
+{
+ GtkWidget *dialog;
+
+ dialog=gtk_file_chooser_dialog_new("File Chooser",
+ GTK_WINDOW(gsh->widgets.window), action, GTK_STOCK_CANCEL,
+ GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL);
+
+ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
+ file_dialog_submit(dialog);
+
+ exit(0);
+}
+
+
Index: libshell/file_dialog.h
===================================================================
RCS file: libshell/file_dialog.h
diff -N libshell/file_dialog.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/file_dialog.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,42 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_FILE_DIALOG
+#define GSH_FILE_DIALOG
+
+void
+gsh_file_dialog(struct GSH * gsh,
+ GtkFileChooserAction action) __attribute__((noreturn));
+
+#define GSH_FILE_OPEN_DIALOG(gsh)\
+ gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_OPEN)
+
+#define GSH_FILE_SAVE_DIALOG(gsh)\
+ gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_SAVE)
+
+#define GSH_FOLDER_CREATE_DIALOG(gsh)\
+ gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_CREATE_FOLDER)
+
+#define GSH_FOLDER_OPEN_DIALOG(gsh)\
+ gsh_file_dialog(gsh, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
+
+#endif /* !GSH_FILE_DIALOG */
Index: libshell/font.c
===================================================================
RCS file: libshell/font.c
diff -N libshell/font.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/font.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,50 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+set_font(GtkWidget * widget, const gchar * font)
+{
+ PangoFontDescription *font_desc;
+#define PFD(op, arg) pango_font_description_##op(arg)
+ font_desc = PFD(from_string, font);
+ gtk_widget_modify_font(widget, font_desc);
+ PFD(free, font_desc);
+}
+
+void
+gsh_widget_set_font(GtkWidget *widget, const gchar *font)
+{
+#ifdef DEBUG
+ ARPASSERT(widget);
+#endif /* DEBUG */
+ if(!font) /* Allowed assignmet for uninitialized const var. */
+ font="Mono 12";
+#ifdef HAVE_VTE
+ if(VTE_IS_TERMINAL(widget))
+ vte_terminal_set_font_from_string(VTE_TERMINAL(widget), font);
+#endif /* HAVE_VTE */
+ else /* Not a terminal. */
+ set_font(widget, font);
+}
+
Index: libshell/font.h
===================================================================
RCS file: libshell/font.h
diff -N libshell/font.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/font.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,29 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GTKSHELL_FONT_H
+#define GTKSHELL_FONT_H
+
+void
+gsh_widget_set_font(GtkWidget *widget, const gchar *font);
+
+#endif /* GTKSHELL_FONT_H */
Index: libshell/geometry.c
===================================================================
RCS file: libshell/geometry.c
diff -N libshell/geometry.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/geometry.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,57 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+
+static gboolean
+gsh_check_geometry(struct GSH * gsh)
+{
+ /* Use a default geometry if the application has a scrolling window and
+ * the geometry has not yet been specified. */
+ if(GSH_FLAG(GSH_SCROLL) && !ARPBOOL(gsh->geometry))
+ gsh->geometry=g_strdup("400x267");
+
+ /* Result used in test of whether or not to set geometry. */
+ return ARPBOOL(gsh->geometry);
+}
+
+/* gsh->geometry is freed after this, so only call once. */
+void
+gsh_check_and_set_geometry(struct GSH * gsh)
+{
+#ifdef DEBUG
+ ARPASSERT(gsh);
+#endif /* DEBUG */
+ if (gsh_check_geometry(gsh))
+ {
+ /* Use GTK convenience function to set window geometry. */
+ gtk_window_parse_geometry(GTK_WINDOW(gsh->widgets.window),
+ gsh->geometry);
+ /* Free the geometry string pointer after use, so this function,
+ * if called twice, will use a default geometry, not the user
+ * specified one. */
+ g_free(gsh->geometry);
+ /* Mark as unallocated. */
+ gsh->geometry=NULL;
+ }
+}
Index: libshell/geometry.h
===================================================================
RCS file: libshell/geometry.h
diff -N libshell/geometry.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/geometry.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,32 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_GEOMETRY_H
+#define GSH_GEOMETRY_H
+
+void
+ gsh_set_geometry(struct GSH * gsh);
+
+void
+ gsh_check_and_set_geometry(struct GSH * gsh);
+
+#endif /* GSH_GEOMETRY_H */
Index: libshell/gshterm
===================================================================
RCS file: libshell/gshterm
diff -N libshell/gshterm
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/gshterm 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+gshterm_usage()
+{
+ echo 'gshterm [e command][f font][s size][h]'
+}
+
+FONT=""
+GEOMETRY=""
+COMMAND=""
+DEBUG="FALSE"
+APP_MODE=""
+TRANSPARENT=""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
+ -a)
+ APP_MODE="-oa File::Exit___ 'Help::gtkshell -da & # About'"
+ break
+ ;;
+ -e)
+ shift
+ COMMAND="\"$*\""
+ break
+ ;;
+ -g)
+ GEOMETRY="$2"
+ shift
+ ;;
+ -f)
+ FONT="$2"
+ shift
+ ;;
+ -h)
+ gshterm_usage
+ ;;
+ -s)
+ FONT="$FONT $2"
+ shift
+ ;;
+ -t)
+ TRANSPARENT="-ott"
+ break
+ ;;
+ esac
+ shift
+done
+
+ARGS=""
+
+if [ "$GEOMETRY" != "" ]; then
+ ARGS="$ARGS -og $GEOMETRY"
+fi
+if [ "$FONT" != "" ]; then
+ ARGS="$ARGS -otf \"$FONT\""
+else
+ ARGS="$ARGS -otf 'Mono 12'"
+fi
+
+#echo $*
+
+if [ "$COMMAND" = "" ]; then
+ COMMAND=$SHELL
+fi
+
+
+COMMAND="gtkshell $APP_MODE -oF $ARGS -oT $COMMAND -as $COMMAND"
+
+if [ "$DEBUG" = "TRUE" ]; then
+ echo $COMMAND
+fi
+
+exec sh -c "$COMMAND"
+
Index: libshell/gtkshell.c
===================================================================
RCS file: libshell/gtkshell.c
diff -N libshell/gtkshell.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/gtkshell.c 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,141 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+delete_child_classes(GSH * gsh)
+{
+ ARDELETE(gsh->rows);
+ ARDELETE(gsh->terminal);
+ ARDELETE(gsh->update);
+}
+
+static void
+gsh_delete_GSH(struct GSH * gsh)
+{
+ delete_child_classes(gsh);
+ GSH_FREE_IF(gsh->geometry);
+}
+
+static void
+setup_add_methods(GSH * gsh)
+{
+#define GSHA gsh->add
+ GSHA.window=&gsh_GSH_add_window;
+ GSHA.button=&gsh_add_button;
+ GSHA.label=&gsh_add_label;
+}
+
+static void
+setup_methods(GSH * gsh)
+{
+ gsh->delete = &gsh_delete_GSH;
+ gsh->parse = &gsh_parse_arguments;
+ gsh->finalize = &gsh_GSH_finalize;
+ gsh->init = &gsh_setup_containers;
+ gsh->manage=&gsh_manage;
+ setup_add_methods(gsh);
+}
+
+static void
+setup_child_classes(GSH * gsh)
+{
+ gsh->update = ARNEW(gsh, GSHUpdateManager);
+ gsh->rows = ARNEW(gsh, GSHRows);
+ gsh->terminal = ARNEW(gsh, GSH_Terminal, gsh);
+}
+
+#define GWA gsh->widgets.app
+
+static void
+setup_app_menus(GSH * gsh)
+{
+#define GWAM GWA.menus
+ GWAM.file=NULL;
+ GWAM.edit=NULL;
+ GWAM.view=NULL;
+ GWAM.tools=NULL;
+ GWAM.help=NULL;
+}
+
+static void
+setup_widget_app_member_fields(GSH * gsh)
+{
+ GWA.menubar=NULL;
+ setup_app_menus(gsh);
+ GWA.frame=NULL;
+ GWA.status=NULL;
+}
+
+static void
+setup_widget_member_fields(GSH * gsh)
+{
+ gsh->widgets.last_managed=NULL;
+ setup_widget_app_member_fields(gsh);
+}
+
+static void
+setup_editor_member_fields(GSH * gsh)
+{
+ gsh->editor.widget=NULL;
+ gsh->editor.filename=NULL;
+}
+
+static void
+setup_main_member_fields(GSH * gsh)
+{
+ gsh->geometry = (gchar *)NULL;
+ gsh->bflags = 0;
+ gsh->icon_size=GTK_ICON_SIZE_DND;
+}
+
+static void
+setup_member_fields(GSH * gsh)
+{
+ setup_widget_member_fields(gsh);
+ setup_editor_member_fields(gsh);
+ setup_main_member_fields(gsh);
+}
+
+static void
+setup_gsh(GSH * gsh)
+{
+ setup_child_classes(gsh);
+ setup_methods(gsh);
+ setup_member_fields(gsh);
+ /* Add initial window. */
+ $(gsh, add.window);
+}
+
+struct GSH *
+gsh_new_GSH()
+{
+ struct GSH *gsh;
+
+ gsh = (struct GSH *) xmalloc(sizeof(struct GSH));
+ setup_gsh(gsh);
+
+ return gsh;
+}
+
Index: libshell/gtkshell.h
===================================================================
RCS file: libshell/gtkshell.h
diff -N libshell/gtkshell.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/gtkshell.h 10 Jun 2007 20:53:56 -0000 1.1
@@ -0,0 +1,122 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_GTKSHELL_H
+#define GSH_GTKSHELL_H
+
+#include <gtk/gtk.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#ifdef HAVE_VTE
+#include <vte/vte.h>
+#endif /* HAVE_VTE */
+#include <unistd.h>
+#include <signal.h>
+
+#ifdef LIBGC
+#include <gc.h>
+#endif /* LIBGC */
+
+#include "../libantiright/library.h"
+
+#ifndef YYFILE
+#include "y.tab.h"
+#endif /* not YYFILE */
+
+#include "macros.h"
+
+#include "row_struct.h"
+#include "terminal_struct.h"
+#include "updated.h"
+#include "update_manager_struct.h"
+
+
+struct GSH
+{
+ /* member data */
+ /address@hidden@*/ gchar *geometry;
+ Bitmask bflags;
+ GtkIconSize icon_size;
+
+ /* member data categories */
+ struct /* widgets */
+ {
+ GtkWidget * window;
+ GtkWidget * scrolled_window;
+ GtkWidget * button;
+ GtkWidget * last_managed;
+ struct /* app mode */
+ {
+ struct
+ {
+ GtkWidget * file;
+ GtkWidget * edit;
+ GtkWidget * tools;
+ GtkWidget * view;
+ GtkWidget * help;
+ } menus;
+ GtkWidget * menubar;
+ GtkWidget * toolbar;
+ GtkWidget * status;
+ GtkWidget * frame;
+ GtkWidget * row;
+ } app;
+ } widgets;
+ struct /* text editor */
+ {
+ gchar * filename;
+ GtkWidget * widget;
+ } editor;
+
+ /* member classes */
+ struct GSHRows * rows;
+ struct GSHUpdateManager * update;
+ struct GSH_Terminal * terminal;
+
+ /* methods */
+ void (*delete)(struct GSH *);
+ void (*parse)(struct GSH *, const gint, const gchar **);
+ void (*init)(struct GSH *);
+ void (*finalize)(struct GSH *);
+ void (*manage)(struct GSH *, GtkWidget *);
+
+ /* method categories */
+ struct
+ {
+ GtkWidget * (*window)(struct GSH *);
+ GtkWidget * (*button)(struct GSH *, const gchar *);
+ GtkWidget * (*label)(struct GSH *, const gchar *);
+ } add;
+
+};
+
+typedef struct GSH GSH;
+
+#include "module_includes.h"
+
+struct GSH *
+gsh_new_GSH();
+
+#endif
Index: libshell/guidl.lex
===================================================================
RCS file: libshell/guidl.lex
diff -N libshell/guidl.lex
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl.lex 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,24 @@
+%{
+
+#include "gtkshell.h"
+
+%}
+%%
+\"[^\"]*\" {
+ /* Remove quotes. */
+ yylval.string=g_strdup(yytext+1);
+ yylval.string[yyleng-2]='\0';
+ return STRING;
+ }
+[0-9]+ yylval.number=atoi(yytext); return NUM;
+, return COMMA;
+; return END;
+option return OPTION;
+add return ADD;
+buttons return BUTTONS;
+button return BUTTON;
+echo return TOKEN_ECHO;
+dialog return DIALOG;
+[ \t\n] /* ignore */;
+"//".*$ /* comment */;
+%%
Index: libshell/guidl.y
===================================================================
RCS file: libshell/guidl.y
diff -N libshell/guidl.y
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl.y 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,146 @@
+%{
+
+/*
+ AntiRight
+ (c) 2007 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 <stdio.h>
+#define YYFILE
+#include "gtkshell.h"
+
+void
+yyerror(const char *string);
+
+int
+yywrap();
+
+void
+yyunput();
+
+void
+yyerror(const char *string)
+{
+ g_error("error: %s\n", string);
+}
+
+int
+yywrap()
+{
+ return 1;
+}
+
+struct GDLEnvironment * gsh_guidl_env;
+
+%}
+%union
+{
+ gchar * string;
+ gint number;
+}
+%token IFS SC COMMA OPTION DIALOG
+%token END ADD BUTTONS BUTTON TOKEN_ECHO
+%token <string> STRING
+%token <number> NUM
+%%
+commands:
+/* empty */
+|
+commands command END
+;
+
+command:
+option
+|
+add
+|
+dialog
+|
+TOKEN_ECHO STRING
+{
+ g_print("%s", $2);
+ g_free($2);
+}
+;
+
+dialog:
+DIALOG STRING
+{
+ gsh_guidl_dialog($2, NULL);
+}
+|
+DIALOG STRING STRING
+{
+ gsh_guidl_dialog($2, $3);
+}
+;
+
+option:
+OPTION STRING
+{
+ gsh_guidl_option($2, NULL);
+}
+|
+OPTION STRING STRING
+{
+ gsh_guidl_option($2, $3);
+}
+|
+OPTION STRING NUM
+{
+ gchar * num_string;
+ ar_asprintf(&num_string, "%d", $3);
+ gsh_guidl_option($2, num_string);
+ /* num_string is freed in above call. */
+}
+;
+
+add:
+ADD STRING STRING
+{
+ gsh_guidl_widget($2, $3);
+}
+|
+ADD STRING
+{
+ gsh_guidl_widget($2, NULL);
+}
+|
+ADD BUTTONS buttons
+|
+ADD BUTTON button
+;
+
+buttons:
+/* empty */
+|
+buttons button COMMA
+|
+buttons button
+;
+
+button:
+STRING
+{
+ $(gsh_guidl_env->args, add, $1);
+ g_free($1);
+}
+;
+
Index: libshell/guidl_dialog.c
===================================================================
RCS file: libshell/guidl_dialog.c
diff -N libshell/guidl_dialog.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_dialog.c 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,50 @@
+/*
+ AntiRight
+ (c) 2007 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
+*/
+
+/* Set the dictionary to use for this definition file. */
+#define DICT gsh_guidl_env->dictionaries->dialog
+#include "gtkshell.h"
+
+extern struct GDLEnvironment * gsh_guidl_env;
+
+#define DEF(a, b) GSH_GUIDL_DEFINE(DICT, a, b)
+
+static void
+setup_dictionary()
+{
+ DICT=ARNEW(ar, ARTupleVector);
+ /* Begin adding mappings between keys and values. */
+ DEF("file", "-df");
+ DEF("font", "-dF");
+ DEF("about", "-da");
+ DEF("folder", "-dd");
+ DEF( "create folder", "-dD");
+ DEF("save", "-ds");
+ DEF("color", "-dc");
+ DEF("info", "-di");
+ DEF("warning", "-dw");
+ DEF("error", "-de");
+}
+
+/* Generate public function to access these definitions. */
+GSH_GUIDL_ITEM_FUNC(dialog, DICT);
+
Index: libshell/guidl_dialog.h
===================================================================
RCS file: libshell/guidl_dialog.h
diff -N libshell/guidl_dialog.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_dialog.h 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,28 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_GUIDL_DIALOG_H
+#define GSH_GUIDL_DIALOG_H
+
+GSH_GUIDL_ITEM_HEAD(dialog);
+
+#endif /* GSH_GUIDL_DIALOG_H */
Index: libshell/guidl_dictionary.c
===================================================================
RCS file: libshell/guidl_dictionary.c
diff -N libshell/guidl_dictionary.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_dictionary.c 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,85 @@
+/*
+ AntiRight
+ (c) 2007 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 "gtkshell.h"
+
+extern struct GDLEnvironment * gsh_guidl_env;
+
+static void
+delete_dictionary(struct ARTupleVector * dict)
+{
+ if(dict)
+ $(dict, delete);
+}
+
+static void
+delete_contents(struct GDLDictionaries * dictionaries)
+{
+ delete_dictionary(dictionaries->widget);
+ delete_dictionary(dictionaries->option);
+ delete_dictionary(dictionaries->dialog);
+}
+
+static void
+gsh_delete_GDLDictionaries(struct GDLDictionaries * dictionaries)
+{
+ delete_contents(dictionaries);
+ g_free(dictionaries);
+}
+
+
+static void
+initialize_member_fields(struct GDLDictionaries * dictionaries)
+{
+#define NULLIFY(dict) dictionaries->dict=NULL
+ NULLIFY(widget);
+ NULLIFY(dialog);
+ NULLIFY(option);
+}
+
+static void
+setup_GDLDictionaries(struct GDLDictionaries * dictionaries)
+{
+ initialize_member_fields(dictionaries);
+ /* Set up methods. */
+ dictionaries->delete=&gsh_delete_GDLDictionaries;
+}
+
+struct GDLDictionaries *
+gsh_new_GDLDictionaries()
+{
+ struct GDLDictionaries * dictionaries;
+
+ dictionaries=g_malloc(sizeof(struct GDLDictionaries));
+ setup_GDLDictionaries(dictionaries);
+
+ return dictionaries;
+}
+
+void
+gsh_guidl_generic_item(gchar * item, gchar * argument,
+ struct ARTupleVector * dict)
+{
+ $(gsh_guidl_env, add, $(dict, find, item), argument);
+ g_free(item);
+}
+
Index: libshell/guidl_dictionary.h
===================================================================
RCS file: libshell/guidl_dictionary.h
diff -N libshell/guidl_dictionary.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_dictionary.h 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,65 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_GUIDL_DICTIONARY_H
+#define GSH_GUIDL_DICTIONARY_H
+
+struct GDLDictionaries
+{
+ struct ARTupleVector * widget;
+ struct ARTupleVector * dialog;
+ struct ARTupleVector * option;
+ void (*delete)(struct GDLDictionaries *);
+};
+
+#define GSH_GUIDL_CHECK_DICTIONARY(dict, setup)\
+{\
+ if(!dict)\
+ setup();\
+}
+
+#define GSH_GUIDL_DEFINE(dict, a, b)\
+ $(dict, add, (gchar *)a, (gchar *)b)
+
+#define GSH_GUIDL_ITEM(item, arg, dict, setup)\
+{\
+ GSH_GUIDL_CHECK_DICTIONARY(dict, setup);\
+ gsh_guidl_generic_item(item, arg, dict);\
+}
+
+#define GSH_GUIDL_ITEM_FUNC(type, dict)\
+void gsh_guidl_ ##type (gchar * item, gchar * arg)\
+{\
+ GSH_GUIDL_ITEM(item, arg, dict, setup_dictionary);\
+}
+
+#define GSH_GUIDL_ITEM_HEAD(type)\
+void gsh_guidl_ ##type (gchar * item, gchar * arg);
+
+struct GDLDictionaries *
+gsh_new_GDLDictionaries();
+
+void
+gsh_guidl_generic_item(gchar * item, gchar * argument,
+ struct ARTupleVector * dict);
+
+#endif /* GSH_GUIDL_DICTIONARY_H */
Index: libshell/guidl_options.c
===================================================================
RCS file: libshell/guidl_options.c
diff -N libshell/guidl_options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_options.c 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,54 @@
+/*
+ AntiRight
+ (c) 2007 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
+*/
+
+#define DICT gsh_guidl_env->dictionaries->option
+#include "gtkshell.h"
+
+extern struct GDLEnvironment * gsh_guidl_env;
+
+#define DEF(a, b) GSH_GUIDL_DEFINE(DICT, a, b);
+
+static void
+setup_dictionary()
+{
+ DICT=ARNEW(ar, ARTupleVector);
+ DEF("framed labels", "-of");
+ DEF("undecorated", "-on");
+ DEF("exit on activate", "-oe");
+ DEF("horizontal labels", "-oh");
+ DEF("scrolled", "-os");
+ DEF("no fill", "-ol");
+ DEF("fill", "-oL");
+ DEF("geometry", "-og");
+ DEF("title", "-oT");
+ DEF("terminal font", "-otf");
+ DEF("terminal width", "-otw");
+ DEF("terminal height", "-oth");
+ DEF("rows", "-or");
+ DEF("update frequency", "-ou");
+ DEF("application", "-oa");
+ DEF("icon size", "-oi");
+ DEF("pane next", "-op");
+}
+
+GSH_GUIDL_ITEM_FUNC(option, DICT);
+
Index: libshell/guidl_options.h
===================================================================
RCS file: libshell/guidl_options.h
diff -N libshell/guidl_options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_options.h 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,28 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_GUIDL_OPTIONS_H
+#define GSH_GUIDL_OPTIONS_H
+
+GSH_GUIDL_ITEM_HEAD(option);
+
+#endif /* GSH_GUIDL_OPTIONS_H */
Index: libshell/guidl_util.c
===================================================================
RCS file: libshell/guidl_util.c
diff -N libshell/guidl_util.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_util.c 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,86 @@
+/*
+ AntiRight
+ (c) 2007 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 "gtkshell.h"
+
+struct GDLEnvironment * gsh_guidl_env=NULL;
+
+#define EDEL(member) ARDELETE(env->member)
+
+static void
+gsh_delete_GDLEnvironment(struct GDLEnvironment * env)
+{
+ EDEL(dictionaries);
+ EDEL(args);
+}
+
+#define APPEND_ARG(env, arg) $(env->args, add, arg)
+
+static void
+gsh_GDLEnvironment_add(struct GDLEnvironment * env,
+ const gchar * switches, gchar * argument)
+{
+ /* A command base argument (for command line
+ switch translation) is required. */
+ if(switches)
+ {
+#ifdef DEBUG
+ ARPASSERT(env);
+#endif /* DEBUG */
+ APPEND_ARG(env, switches);
+ if(argument)
+ {
+ APPEND_ARG(env, argument);
+ g_free(argument);
+ }
+ }
+}
+
+#define CONSTRUCT_MEMBER_CLASSES(env)\
+{\
+ env->args=ARNEW(ar, ARArguments);\
+ env->dictionaries=ARNEW(gsh, GDLDictionaries);\
+}
+
+#define ASSIGN_METHODS(env)\
+{\
+ env->delete=&gsh_delete_GDLEnvironment;\
+ env->add=&gsh_GDLEnvironment_add;\
+}
+
+#define SETUP_GDLENVIRONMENT(env)\
+{\
+ CONSTRUCT_MEMBER_CLASSES(env);\
+ ASSIGN_METHODS(env);\
+}
+
+struct GDLEnvironment *
+gsh_new_GDLEnvironment()
+{
+ struct GDLEnvironment * env;
+
+ env = xmalloc(sizeof(struct GDLEnvironment));
+ SETUP_GDLENVIRONMENT(env);
+
+ return env;
+}
+
Index: libshell/guidl_util.h
===================================================================
RCS file: libshell/guidl_util.h
diff -N libshell/guidl_util.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_util.h 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,46 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_GUIDL_UTIL_H
+#define GSH_GUIDL_UTIL_H
+
+struct GDLEnvironment
+{
+ struct GDLDictionaries * dictionaries;
+ struct ARArguments * args;
+ /* destructor */
+ void (*delete)(struct GDLEnvironment *);
+ /* First argument to ADD is not freed. If dynamically allocated,
+ you must free. */
+ void (*add)(struct GDLEnvironment *, const gchar *, gchar *);
+};
+
+struct GDLEnvironment *
+gsh_new_GDLEnvironment();
+
+int
+yylex();
+
+int
+yyparse();
+
+#endif /* not GSH_GUIDL_UTIL_H */
Index: libshell/guidl_widgets.c
===================================================================
RCS file: libshell/guidl_widgets.c
diff -N libshell/guidl_widgets.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_widgets.c 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,54 @@
+/*
+ AntiRight
+ (c) 2007 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
+*/
+
+#define DICT gsh_guidl_env->dictionaries->widget
+#include "gtkshell.h"
+
+extern struct GDLEnvironment * gsh_guidl_env;
+
+
+#define DEF(a, b)\
+ GSH_GUIDL_DEFINE(DICT, a, b)
+
+static void
+setup_dictionary()
+{
+ DICT=ARNEW(ar, ARTupleVector);
+ DEF("label", "-al");
+ DEF("prompt", "-at");
+ DEF("terminal", "-as");
+ DEF("window", "-aw");
+ DEF("separator", "-aS");
+ DEF("updating label", "-aul");
+ DEF("updating progress", "-aup");
+ DEF("row", "-ar");
+ DEF("viewer", "-ae");
+ DEF("text", "-aT");
+ DEF("system label", "-acl");
+ DEF("system button", "-acb");
+ DEF("vertical pane", "-ab");
+ DEF("command shell", "-aC");
+ DEF("clock applet", "-aAc");
+}
+
+GSH_GUIDL_ITEM_FUNC(widget, DICT);
+
Index: libshell/guidl_widgets.h
===================================================================
RCS file: libshell/guidl_widgets.h
diff -N libshell/guidl_widgets.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/guidl_widgets.h 10 Jun 2007 20:53:57 -0000 1.1
@@ -0,0 +1,28 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_GUIDL_WIDGETS_H
+#define GSH_GUIDL_WIDGETS_H
+
+GSH_GUIDL_ITEM_HEAD(widget);
+
+#endif /* GSH_GUIDL_WIDGETS_H */
Index: libshell/image_button.c
===================================================================
RCS file: libshell/image_button.c
diff -N libshell/image_button.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/image_button.c 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,119 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+set_up_containers_for_menu_item_row(GtkWidget * button, GtkWidget * hrow,
+ GtkWidget * label, GtkWidget * image)
+{
+ 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);
+}
+
+/* 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)
+{
+ gchar * prefixed_name;
+ GtkWidget * image;
+
+ ar_asprintf(&prefixed_name, PREFIX "/share/ACE-desktop/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);
+
+ 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);
+}
+
+void
+gsh_image_button(struct GSH * gsh, char *command, char *name)
+{
+ GtkWidget * image;
+
+ image = gsh_get_image(gsh, name);
+ $(gsh, add.button, command);
+ ARIFP(image)
+ {
+ 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))
+ {
+ set_button_image(gsh->widgets.button, image);
+ }
+ else
+ {
+ set_menu_item_image(gsh, image);
+ }
+ }
+}
+
Index: libshell/image_button.h
===================================================================
RCS file: libshell/image_button.h
diff -N libshell/image_button.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/image_button.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,33 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_IMAGE_BUTTON_H
+#define GSH_IMAGE_BUTTON_H
+
+GtkWidget *
+gsh_get_image(GSH * gsh, const gchar * name);
+
+void
+gsh_image_button(struct GSH * gsh, char *command, char *name);
+
+#endif /* GSH_IMAGE_BUTTON_H */
+
Index: libshell/init.c
===================================================================
RCS file: libshell/init.c
diff -N libshell/init.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/init.c 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,62 @@
+/*
+ AntiRight
+ (c) 2007 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 "gtkshell.h"
+
+static void
+setup_quit_signal(GtkWindow * window, const gchar * signal)
+{
+ g_signal_connect(window, signal, G_CALLBACK(gtk_main_quit), NULL);
+}
+
+static void
+setup_quit_signals(GtkWindow * window)
+{
+ setup_quit_signal(window, "delete-event");
+ setup_quit_signal(window, "destroy");
+}
+
+
+GtkWidget *
+gsh_GSH_add_window(struct GSH * gsh)
+{
+ GtkWidget *window;
+
+ window = gsh->widgets.window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+ setup_quit_signals(GTK_WINDOW(window));
+
+ return window;
+}
+
+void
+gsh_GSH_finalize(struct GSH * gsh)
+{
+ /* Choose the correct parenting of the widget hierarchy based on options
+ * set. */
+ gsh_setup_base_container(gsh);
+ /* If geometry has been set in command line arguments, use that, else
+ * use a reasonable default. */
+ gsh_check_and_set_geometry(gsh);
+ /* Show everything when ready. */
+ gtk_widget_show(gsh->widgets.window);
+}
+
Index: libshell/init.h
===================================================================
RCS file: libshell/init.h
diff -N libshell/init.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/init.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,33 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_INIT_H
+#define GSH_INIT_H
+
+GtkWidget *
+gsh_GSH_add_window(struct GSH * gsh);
+
+void
+gsh_GSH_finalize(struct GSH * gsh);
+
+
+#endif /* GSH_INIT_H */
Index: libshell/label.c
===================================================================
RCS file: libshell/label.c
diff -N libshell/label.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/label.c 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,60 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+
+static void
+set_options(struct GSH * gsh, GtkWidget *label)
+{
+#define GLS(attr, ...) gtk_label_set_##attr(GTK_LABEL(label), __VA_ARGS__)
+ GLS(single_line_mode, FALSE);
+ GSH_FLAG(GSH_HORIZONTAL_LABELS) ?
+ GLS(angle, 90.0) : GLS(line_wrap, TRUE);
+ gsh_widget_set_font(label, NULL);
+}
+
+static GtkWidget *
+make_framed_label(GtkWidget * label)
+{
+ GtkWidget *frame;
+
+ frame=gtk_frame_new(NULL);
+ GSHCA(frame, label);
+ gtk_widget_show(label);
+
+ return frame;
+}
+
+GtkWidget *
+gsh_add_label(struct GSH * gsh, const gchar *text)
+{
+ GtkWidget *label;
+
+ label = gtk_label_new(text);
+ set_options(gsh, label);
+ gsh_manage(gsh, GSH_FLAG(GSH_FRAMED_LABELS)
+ ? make_framed_label(label) : label);
+
+ return label;
+}
+
Index: libshell/label.h
===================================================================
RCS file: libshell/label.h
diff -N libshell/label.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/label.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,35 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_LABEL_H
+#define GSH_LABEL_H
+
+GtkWidget *
+gsh_add_label(struct GSH * gsh, const gchar *text);
+
+void
+gsh_new_label(struct GSH * gsh, const gchar *text);
+
+void
+gsh_set_label(GtkWidget *label, const gchar *text);
+
+#endif
Index: libshell/macros.h
===================================================================
RCS file: libshell/macros.h
diff -N libshell/macros.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/macros.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,73 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_MACROS_H
+#define GSH_MACROS_H
+
+#define GSHBIT(n) 1 << (n-1)
+
+#define GSH_NONE 0
+#define GSH_SCROLL GSHBIT(1)
+#define GSH_CBEXIT GSHBIT(2)
+#define GSH_UPDATING GSHBIT(3)
+#define GSH_HORIZONTAL_LABELS GSHBIT(4)
+#define GSH_PROMPT_ECHOES GSHBIT(5)
+#define GSH_FRAMED_LABELS GSHBIT(6)
+#define GSH_MENU_BUTTON GSHBIT(7)
+#define GSH_NO_BASE_FRAME GSHBIT(8)
+#define GSH_NO_EXPAND GSHBIT(9)
+#define GSH_GUIDL_NO_DUMMY GSHBIT(10)
+#define GSH_APP_MODE GSHBIT(11)
+#define GSH_PANE_NEXT GSHBIT(12)
+#define GSH_FIRST_TERMINAL GSHBIT(13)
+#define GSH_TERM_TRANSPARENT GSHBIT(14)
+
+typedef guint Bitmask;
+
+#define GSH_FLAG(flag) ((gsh->bflags & flag) == flag)
+#define GSH_SET(flag) gsh->bflags |= flag
+#define GSH_UNSET(flag) gsh->bflags &= ~flag
+
+#define GSH_ACTION_IF(action, arg) if(arg) action(arg)
+#define GSH_DESTROY_IF(widget) GSH_ACTION_IF(gtk_widget_destroy, widget)
+#define GSH_FREE_IF(var) GSH_ACTION_IF(g_free, var)
+
+#define GSH_FIXME() \
+ sysprintf("gtkshell -dw '%s:%d: FIXME'",\
+ __FILE__, __LINE__)
+
+/* GSH Container Add */
+#define GSHCA(container, widget)\
+ gtk_container_add(GTK_CONTAINER(container), widget)
+/* Add without expansion. */
+#define GSHCA_TIGHT(cont, widget)\
+ gtk_box_pack_start(GTK_BOX(cont), widget, FALSE, FALSE, 0);
+
+/* Create and show a widget at the same time. */
+#define GSH_SHOW_CREATE(var, type, ...)\
+ gtk_widget_show(var=gtk_##type##_new(__VA_ARGS__))
+
+#define GSHCONNECT(widget, signal, cb, cbdata)\
+ g_signal_connect(G_OBJECT(widget), signal, G_CALLBACK(cb), cbdata);
+
+#endif /* not GSH_MACROS_H */
+
Index: libshell/menu.c
===================================================================
RCS file: libshell/menu.c
diff -N libshell/menu.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/menu.c 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,231 @@
+/*
+ AntiRight
+ (c) 2006-2007 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 "gtkshell.h"
+
+#define SPLIT_ALL -1
+
+static 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);
+ /* String does not contain \n. */
+ else if(strncmp(pair[0], "\\n", 2))
+ { /* Support continuation lines for menu specification. */
+ /* Create a button. */
+ $(gsh, add.button, pair[0]);
+ }
+}
+
+static void
+menuitem_parse(struct GSH * gsh, gchar * string)
+{
+ gchar **pair;
+
+ pair=g_strsplit(string, ",", 2);
+#ifdef DEBUG
+ ARPASSERT(pair[0]);
+#endif /* DEBUG */
+ if(pair[1])
+ gsh_image_button(gsh, pair[0], pair[1]);
+ else
+ parse_special_and_noicon_items(gsh, pair);
+ g_strfreev(pair);
+}
+
+static void
+set_submenu_label(gpointer widget, gpointer user_data)
+{
+ if(GTK_IS_LABEL((GtkWidget *)widget))
+ gtk_label_set_text(GTK_LABEL((GtkWidget *)widget),
+ (const gchar *)user_data);
+}
+
+static void
+find_and_set_compound_label_widget(GtkWidget * label, const gchar * label_text)
+{
+ GList * children;
+
+ children=gtk_container_get_children(GTK_CONTAINER(label));
+ g_list_foreach(children, set_submenu_label, (gchar *)label_text);
+ g_list_free(children);
+}
+
+static void
+find_and_set_label_widget(GtkWidget * label, const gchar * command)
+{
+ gchar * label_text;
+
+ label_text = antiright_beautified_label(command);
+ if(GTK_IS_LABEL(label))
+ set_submenu_label(label, label_text);
+ else
+ find_and_set_compound_label_widget(label, label_text);
+ g_free(label_text);
+}
+
+static void
+begin_submenu(GSH * gsh, GtkWidget ** submenus,
+ guint *submenu_count, guint * i, gchar ** tokens)
+{
+ GtkWidget * label;
+
+ GSH_UNSET(GSH_MENU_BUTTON);
+ submenus[(*submenu_count)++]=gsh->rows->v;
+ gtk_widget_show(gsh->rows->v = gtk_menu_new());
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(
+ gsh->widgets.button), gsh->rows->v);
+ label=gtk_bin_get_child(GTK_BIN(gsh->widgets.button));
+ find_and_set_label_widget(label, tokens[++(*i)]);
+}
+
+static void
+perform_addition_for_each_item(struct GSH * gsh, gchar ** tokens)
+{
+ guint i;
+ const guint max_menus = 6;
+ /* Any more is not practical. */
+ GtkWidget *submenus[max_menus];
+ guint submenu_count = 0;
+
+ for(i=1; ARPBOOL(tokens[i]); i++)
+ {
+ const gchar * submenu_close = "<--";
+
+ if(!strncmp(tokens[i], submenu_close, 3))
+ {
+ if(submenu_count!=0)
+ gsh->rows->v=submenus[--submenu_count];
+ }
+ else
+ {
+ const gchar * submenu_open = "-->";
+ const gboolean start_submenu = (!strncmp(tokens[i],
+ submenu_open, 3) && submenu_count < max_menus);
+
+ if(start_submenu)
+ GSH_SET(GSH_MENU_BUTTON);
+ /* Create the menu item. */
+ menuitem_parse(gsh, tokens[i]);
+ if(start_submenu)
+ begin_submenu(gsh, submenus, &submenu_count,
+ &i, tokens);
+ }
+ }
+}
+
+
+static void
+add_menu_items(struct GSH * gsh, GtkWidget * menu, gchar **tokens)
+{
+#define GSHR gsh->rows
+ /* Set gsh->rows->v to a row within a menu.
+ * Create the menu before overwriting, then
+ * set back at end. */
+ const GtkWidget * old_row = gsh->rows->v;
+
+ GSHR->v=menu;
+ perform_addition_for_each_item(gsh, tokens);
+ GSHR->v=(GtkWidget *)old_row;
+}
+
+#define GW gsh->widgets
+#define GWA GW.app
+
+static void
+manage_menu_bar(GSH * gsh)
+{
+ GSH_FLAG(GSH_APP_MODE) ? gsh_setup_app_mode(gsh)
+ : $(gsh, manage, GWA.menubar);
+}
+
+static GtkWidget *
+add_menu_bar(struct GSH * gsh)
+{
+ if(!GWA.menubar)
+ {
+ GSH_SHOW_CREATE(GWA.menubar, menu_bar);
+ manage_menu_bar(gsh);
+ }
+
+ return GWA.menubar;
+}
+
+static void
+test_for_main_app_menus(GSH * gsh, GtkWidget * menu, const gchar * label)
+{
+#define GSHMENUS GWA.menus
+
+ if(!strcmp(label, "File"))
+ GSHMENUS.file=menu;
+ else if(!strcmp(label, "Edit"))
+ GSHMENUS.edit=menu;
+ else if(!strcmp(label, "Tools"))
+ GSHMENUS.tools=menu;
+ else if(!strcmp(label, "View"))
+ GSHMENUS.view=menu;
+ else if(!strcmp(label, "Help"))
+ GSHMENUS.help=menu;
+}
+
+static GtkWidget *
+add_menu_launcher(struct GSH * gsh, const gchar * label)
+{
+ const GtkWidget * old_row = gsh->rows->v;
+ GtkWidget * menu_item;
+
+ gsh->rows->v=add_menu_bar(gsh);
+ GSH_SET(GSH_MENU_BUTTON);
+ menu_item = $(gsh, add.button, label);
+ gtk_widget_show(menu_item);
+ gsh->rows->v=(GtkWidget *)old_row;
+
+ return menu_item;
+}
+
+void
+gsh_menubutton_parse(struct GSH * gsh, gchar **tokens)
+{
+ GtkWidget * menu;
+ const gchar * label;
+
+ label=tokens[0];
+ GSH_SHOW_CREATE(menu, menu);
+ gtk_menu_item_set_submenu(GTK_MENU_ITEM(add_menu_launcher(gsh,
+ label)), menu);
+ add_menu_items(gsh, menu, tokens);
+ test_for_main_app_menus(gsh, menu, label);
+}
+
+
Index: libshell/menu.h
===================================================================
RCS file: libshell/menu.h
diff -N libshell/menu.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/menu.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2006-2007 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 GSH_MENU_H
+#define GSH_MENU_H
+
+void
+gsh_menubutton_parse(struct GSH * gsh, gchar **tokens);
+
+#endif /* GSH_MENU_H */
Index: libshell/module_includes.h
===================================================================
RCS file: libshell/module_includes.h
diff -N libshell/module_includes.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/module_includes.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,62 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_MODULE_INCLUDES_H
+#define GSH_MODULE_INCLUDES_H
+
+#include "arguments.h"
+#include "options.h"
+#include "callbacks.h"
+#include "label.h"
+#include "button.h"
+#include "text.h"
+#include "updated_label.h"
+#include "updated_progress.h"
+#include "option_options.h"
+#include "updated_options.h"
+#include "add_options.h"
+#include "dialog_options.h"
+#include "file_dialog.h"
+#include "row.h"
+#include "containers.h"
+#include "geometry.h"
+#include "font.h"
+#include "dragdrop.h"
+#include "image_button.h"
+#include "terminal_options.h"
+#include "terminal.h"
+#include "guidl_dictionary.h"
+#include "guidl_util.h"
+#include "about_dialog.h"
+#include "menu.h"
+#include "init.h"
+#include "guidl_dialog.h"
+#include "guidl_options.h"
+#include "guidl_widgets.h"
+#include "update_manager.h"
+#include "pane.h"
+#include "command_shell.h"
+#include "app_mode.h"
+#include "applets.h"
+#include "tree.h"
+
+#endif /* not GSH_MODULE_INCLUDES_H */
Index: libshell/option_options.c
===================================================================
RCS file: libshell/option_options.c
diff -N libshell/option_options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/option_options.c 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,174 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+/* This is for windows that should not be touched by the window manager,
+ such as the ACE Deskbar panel. */
+static void
+set_no_decorations(GSH * gsh)
+{
+ /* Alias to minimize dereferences through GSH. */
+ GtkWindow * window;
+
+ /* Recreate main window as popup type. This is not recommended, but is
+ necessary when using window managers that do not decorate according
+ to hints, such as evilwm. */
+ gsh->widgets.window=gtk_window_new(GTK_WINDOW_POPUP);
+ window=GTK_WINDOW(gsh->widgets.window);
+
+ /* GTK WINDOW SET */
+#define GWS(attr, ...) gtk_window_set_##attr(window, __VA_ARGS__)
+ GWS(type_hint, GDK_WINDOW_TYPE_HINT_DESKTOP);
+ GWS(decorated, FALSE);
+ GWS(skip_taskbar_hint, TRUE);
+ /* Show window on all desktops. */
+ gtk_window_stick(window);
+ /* Window does not seem to really accept focus when this is set, most
+ likely because of the POPUP option's side effect of overriding
+ window manager redirection. */
+ GWS(accept_focus, TRUE);
+}
+
+static void
+set_icon_size(GSH * gsh, const gchar * arg)
+{
+ /* Define some shortcuts. */
+#define GIS gsh->icon_size
+ /* GTK_ICON_SIZE_ */
+#define GTKIS(size) GTK_ICON_SIZE_##size
+ /* Test for gsh->icon_size equality. */
+#define GISCMP(text) !strcmp(text, arg)
+
+ if(GISCMP("menu"))
+ gsh->icon_size=GTKIS(MENU);
+ else if(GISCMP("small toolbar"))
+ GIS=GTKIS(SMALL_TOOLBAR);
+ else if(GISCMP("large toolbar") || GISCMP("toolbar"))
+ GIS=GTKIS(LARGE_TOOLBAR);
+ else if(GISCMP("button"))
+ GIS=GTKIS(BUTTON);
+ else if(GISCMP("dialog"))
+ GIS=GTKIS(DIALOG);
+ else /* default */
+ GIS=GTKIS(DND);
+}
+
+void
+gsh_handle_option_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter)
+{
+ switch (argv[(*counter)][2])
+ {
+ case 'a':
+ /* Run in application mode. Here, a menu bar and status
+ bar encloses the application. This option may also affect
+ other gtkshell properties in the future. */
+ GSH_SET(GSH_APP_MODE);
+ break;
+ case 'D':
+ /* Do not insert the dummy "guidl" string before the
+ arguments passed by means of a guidl definition.
+ It is not necessary to include this as an option
+ within the guidl description itself, as the dummy
+ option is inserted prior to parsing. */
+ GSH_SET(GSH_GUIDL_NO_DUMMY);
+ break;
+
+ case 'E': /* Make a text entry simply print the
+ * text. */
+ GSH_SET(GSH_PROMPT_ECHOES);
+ break;
+
+ case 'e':
+ GSH_SET(GSH_CBEXIT);
+ break;
+
+ case 'F':
+ GSH_SET(GSH_NO_BASE_FRAME);
+ break;
+
+ case 'f':
+ GSH_SET(GSH_FRAMED_LABELS);
+ break;
+
+ case 'g':
+ GSH_COUNT(argc, counter);
+
+ ARIFP(gsh->geometry)
+ free(gsh->geometry);
+
+ ar_asprintf(&gsh->geometry, "%s", argv[(*counter)]);
+
+ break;
+
+ case 'h':
+ GSH_SET(GSH_HORIZONTAL_LABELS);
+ break;
+ case 'i':
+ GSH_COUNT(argc, counter);
+ set_icon_size(gsh, argv[*counter]);
+ break;
+ case 'l':
+ GSH_SET(GSH_NO_EXPAND);
+ break;
+
+ case 'L':
+ GSH_UNSET(GSH_NO_EXPAND);
+ break;
+
+ case 'n': /* no decorations, desktop panel not to be touched by the
+ * window manager. */
+ set_no_decorations(gsh);
+ break;
+
+ case 'p': /* Pane next widget with previous. */
+ GSH_SET(GSH_PANE_NEXT);
+ break;
+
+ case 'r': /* Set number of rows per column. */
+ GSH_COUNT(argc, counter);
+ gsh->rows->total=(unsigned int)atoi(argv[(*counter)]);
+ break;
+
+ case 's': /* Use scrolling parent container. */
+ GSH_SET(GSH_SCROLL);
+ break;
+
+ case 'T': /* Set the window title. */
+ GSH_COUNT(argc, counter);
+ gtk_window_set_title(GTK_WINDOW(gsh->widgets.window),
+ argv[*counter]);
+ break;
+
+ case 't':
+ gsh_handle_terminal_options(gsh, argc, argv, counter);
+ break;
+
+ case 'u': /* Set time for updating widgets' timer, in miliseconds. */
+ GSH_COUNT(argc, counter);
+ gsh->update->period = atoi(argv[*counter]);
+ break;
+ }
+}
+
Index: libshell/option_options.h
===================================================================
RCS file: libshell/option_options.h
diff -N libshell/option_options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/option_options.h 10 Jun 2007 20:53:58 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_OPTION_OPTIONS_H
+#define GSH_OPTION_OPTIONS_H
+
+void
+gsh_handle_option_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter);
+
+#endif
Index: libshell/options.c
===================================================================
RCS file: libshell/options.c
diff -N libshell/options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/options.c 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,121 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+extern FILE *yyin, *yyout;
+extern struct GDLEnvironment * gsh_guidl_env;
+
+#ifdef DEBUG
+static void
+print_arguments(const gint argc, const gchar ** argv)
+{
+ gint i;
+ for(i=0; i<argc; i++)
+ printf("'%s' ", argv[i]);
+ putchar('\n');
+}
+#endif /* DEBUG */
+
+
+/* Determine whether or not to include an initial
+ dummy argument. Needed as argv[0] is skipped
+ by the command line handling code. */
+static void
+check_for_dummy_argument(GSH * gsh)
+{
+ if(!GSH_FLAG(GSH_GUIDL_NO_DUMMY))
+ $(gsh_guidl_env->args, add, (const gchar *)"guidl");
+}
+
+static void
+check_gsh_guidl_env()
+{
+ if(!gsh_guidl_env)
+ gsh_guidl_env=ARNEW(gsh, GDLEnvironment);
+}
+
+static void
+common_guidl_handler(GSH * gsh)
+{
+ check_gsh_guidl_env();
+ check_for_dummy_argument(gsh);
+ yyparse();
+ /* Shortcut for specification of arguments. */
+#define GGEA gsh_guidl_env->args
+#ifdef DEBUG
+ print_arguments(GGEA->argc, GGEA->argv);
+#endif /* DEBUG */
+ $(gsh, parse, GGEA->argc, (const gchar **)GGEA->argv);
+ $(gsh_guidl_env, delete);
+ gsh_guidl_env=NULL;
+}
+
+static void
+guidl_handler_for_file(GSH * gsh, const gchar * filename)
+{
+ /* If the argument is "-", use stdin for yyin. */
+ /* Otherwise, use FILENAME. */
+ if(strcmp("-", filename))
+ yyin=fopen(filename, "r");
+ common_guidl_handler(gsh);
+}
+
+void
+gsh_invalid_option(const gchar ** argv, const gint option)
+{
+ g_warning("%s: %s undefined\n", argv[0], argv[option]);
+}
+
+#define HANDLE(type)\
+ gsh_handle_##type##_arguments(gsh, argc, argv, counter)
+
+void
+gsh_handle_switch_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter)
+{
+ $(gsh->rows, check);
+ switch (argv[*counter][1])
+ {
+ case 'a':
+ HANDLE(add);
+ break;
+ case 'd':
+ HANDLE(dialog);
+ break;
+ case 'f':
+ GSH_COUNT(argc, counter);
+ guidl_handler_for_file(gsh, argv[*counter]);
+ break;
+ case 'o':
+ HANDLE(option);
+ break;
+ case 't': /* test area. */
+ {
+ GSH_COUNT(argc, counter);
+ $(gsh, manage, gsh_tree_view_new(gsh, argv[*counter]));
+ }
+ break;
+ default:
+ gsh_invalid_option(argv, *counter);
+ }
+}
Index: libshell/options.h
===================================================================
RCS file: libshell/options.h
diff -N libshell/options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/options.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,45 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_OPTIONS_H
+#define GSH_OPTIONS_H
+
+#include "gtkshell.h"
+
+#ifdef DEBUG
+#define GSH_COUNT(argc, counter) \
+{\
+ (*counter)++;\
+ g_assert((*counter) <= argc);\
+}
+#else /* not DEBUG */
+#define GSH_COUNT(argc, counter) \
+{\
+ (*counter)++;\
+}
+#endif /* DEBUG */
+
+void
+gsh_handle_switch_arguments(GSH * gsh, const gint argc, const gchar **argv,
+ gint *counter);
+
+#endif /* not GSH_OPTIONS_H */
Index: libshell/pane.c
===================================================================
RCS file: libshell/pane.c
diff -N libshell/pane.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/pane.c 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,122 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+reparent(GtkWidget * widget, GtkWidget * old, GtkWidget * new)
+{
+ gtk_widget_ref(widget);
+ gtk_container_remove(GTK_CONTAINER(old), widget);
+ gtk_container_add(GTK_CONTAINER(new), widget);
+ gtk_widget_unref(widget);
+}
+
+#define REPARENT_TO(new) reparent(gsh->rows->v, gsh->rows->h, new)
+
+static void
+split_columns_for_pane(struct GSH * gsh, GtkWidget * pane)
+{
+ struct GSHRows * rows;
+
+ rows=gsh->rows;
+ $(rows, new);
+ $(gsh, manage, pane);
+ $(rows, new);
+}
+
+static GtkWidget *
+setup_first_pane_half(struct GSH * gsh, const gchar ** pair)
+{
+ GtkWidget * first;
+
+ gtk_widget_show(first=gtk_frame_new(pair[0]));
+ REPARENT_TO(first);
+
+ return first;
+}
+
+static GtkWidget *
+setup_second_pane_half(struct GSH * gsh, gchar ** pair)
+{
+ GtkWidget * second;
+
+ gtk_widget_show(second=gtk_frame_new(pair[1]));
+ g_strfreev(pair);
+ REPARENT_TO(second);
+
+ return second;
+}
+
+static void
+assign_pane_sections(GtkWidget * pane, GtkWidget * first, GtkWidget * second)
+{
+ gtk_paned_add1(GTK_PANED(pane), first);
+ gtk_paned_add2(GTK_PANED(pane), second);
+}
+
+void
+gsh_setup_hpaned(struct GSH * gsh, const gchar * label_pair)
+{
+ GtkWidget * pane;
+ pane=gtk_hpaned_new();
+ {
+ gchar **pair;
+
+ pair=g_strsplit(label_pair, ",", 2);
+ {
+ GtkWidget * first;
+
+ first=setup_first_pane_half(gsh, (const gchar **)pair);
+ split_columns_for_pane(gsh, pane);
+ {
+ GtkWidget * second;
+
+ /* PAIR freed here. */
+ second=setup_second_pane_half(gsh, pair);
+ assign_pane_sections(pane, first, second);
+ }
+ }
+ }
+}
+
+
+void
+gsh_pane_previous(struct GSH * gsh, GtkWidget * target)
+{
+ GtkWidget * pane;
+ GtkWidget * prev_frame;
+
+ pane=gtk_vpaned_new();
+ prev_frame = gtk_frame_new(NULL);
+#ifdef DEBUG
+ ARPASSERT(gsh->widgets.last_managed);
+#endif /* DEBUG */
+ reparent(gsh->widgets.last_managed, gsh->rows->v, prev_frame);
+ assign_pane_sections(pane, prev_frame, target);
+ gtk_widget_show(prev_frame);
+ gtk_widget_show(target);
+ GSH_UNSET(GSH_PANE_NEXT);
+ $(gsh, manage, pane);
+}
Index: libshell/pane.h
===================================================================
RCS file: libshell/pane.h
diff -N libshell/pane.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/pane.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,34 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_PANE_H
+#define GSH_PANE_H
+
+void
+gsh_setup_hpaned(struct GSH * gsh, const gchar * label_pair);
+
+void
+gsh_pane_previous(struct GSH * gsh, GtkWidget * target);
+
+#endif /* not GSH_PANE_H */
Index: libshell/row.c
===================================================================
RCS file: libshell/row.c
diff -N libshell/row.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/row.c 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,136 @@
+/*
+ AntiRight
+ (c) 2007 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 "gtkshell.h"
+
+static void
+gsh_GSHRows_new(struct GSHRows * this)
+{
+ gtk_container_add(GTK_CONTAINER(this->h),
+ this->v=gtk_vbox_new(FALSE, 2));
+ gtk_widget_show(this->v);
+ this->current = 1;
+}
+
+static void
+gsh_GSHRows_check(struct GSHRows * this)
+{
+ if(this->current > this->total)
+ $(this, new);
+}
+
+static void
+gsh_delete_GSHRows(struct GSHRows * rows)
+{
+ g_free(rows);
+}
+
+#define SETUP_METHODS(rows)\
+{\
+ rows->delete=&gsh_delete_GSHRows;\
+ rows->new=&gsh_GSHRows_new;\
+ rows->check=&gsh_GSHRows_check;\
+}
+
+/* Use an arbitrary, though reasonable, initial number of rows. */
+#define SETUP_MEMBER_FIELDS(rows)\
+{\
+ rows->current=1;\
+ rows->total=8;\
+}
+
+#define SETUP_GSHROWS(rows)\
+{\
+ SETUP_MEMBER_FIELDS(rows);\
+ SETUP_METHODS(rows);\
+}
+
+struct GSHRows *
+gsh_new_GSHRows()
+{
+ struct GSHRows * rows;
+
+ rows = xmalloc(sizeof(struct GSHRows));
+ SETUP_GSHROWS(rows);
+
+ return rows;
+}
+
+static void
+gsh_manage_generic(struct GSH * gsh, GtkWidget *widget)
+{
+ gtk_widget_show(widget);
+ gsh->rows->current++;
+ gsh->widgets.last_managed=widget;
+}
+
+static gboolean
+test_manage_menu_item(GtkWidget * container, GtkWidget * widget)
+{
+ if(GTK_IS_MENU(container) || GTK_IS_MENU_BAR(container)
+ || GTK_IS_MENU_ITEM(container))
+ {
+ gtk_menu_shell_append(GTK_MENU_SHELL(container), widget);
+ return TRUE;
+ }
+ else
+ return FALSE;
+}
+
+static void
+manage_normal(struct GSH * gsh, GtkWidget * widget)
+{
+ if(test_manage_menu_item(gsh->rows->v, widget))
+ return;
+ $(gsh->rows, check);
+ gtk_container_add(GTK_CONTAINER(gsh->rows->v), widget);
+ gsh_manage_generic(gsh, widget);
+}
+
+#define GR gsh->rows
+#define CONTAINER GR->v
+#define TEST_MANAGE_UNEXPANDED(gsh)\
+ (GSH_FLAG(GSH_NO_EXPAND) &&(GR->total != 1)\
+ && !GTK_IS_MENU(CONTAINER) && !GTK_IS_MENU_BAR(CONTAINER)\
+ && !GTK_IS_MENU_ITEM(CONTAINER))
+
+
+static void
+manage_unexpanded(struct GSH * gsh, GtkWidget * widget)
+{
+ $(gsh->rows, check);
+ gtk_box_pack_start(GTK_BOX(gsh->rows->v), widget,
+ FALSE, FALSE, 0);
+ gsh_manage_generic(gsh, widget);
+}
+
+void
+gsh_manage(struct GSH * gsh, GtkWidget *widget)
+{
+ if(GSH_FLAG(GSH_PANE_NEXT))
+ gsh_pane_previous(gsh, widget);
+ else if(TEST_MANAGE_UNEXPANDED(gsh))
+ manage_unexpanded(gsh, widget);
+ else
+ manage_normal(gsh, widget);
+}
+
Index: libshell/row.h
===================================================================
RCS file: libshell/row.h
diff -N libshell/row.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/row.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,35 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_ROW_H
+#define GSH_ROW_H
+
+void
+gsh_manage(struct GSH * gsh, GtkWidget *widget);
+
+void
+gsh_check_row(struct GSH * gsh);
+
+struct GSHRows *
+gsh_new_GSHRows();
+
+#endif /* GSH_ROW_H */
Index: libshell/row_struct.h
===================================================================
RCS file: libshell/row_struct.h
diff -N libshell/row_struct.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/row_struct.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,37 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_ROW_STRUCT_H
+#define GSH_ROW_STRUCT_H
+
+struct GSHRows
+{
+ GtkWidget *h;
+ GtkWidget *v;
+ unsigned int current;
+ unsigned int total;
+ void (*delete)(struct GSHRows *);
+ void (*new)(struct GSHRows *);
+ void (*check)(struct GSHRows *);
+};
+
+#endif /* GSH_ROW_STRUCT */
Index: libshell/terminal.c
===================================================================
RCS file: libshell/terminal.c
diff -N libshell/terminal.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/terminal.c 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,232 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+#ifdef HAVE_VTE
+#define VSET(element, widget, ...)\
+ vte_terminal_set_##element(VTE_TERMINAL(widget), __VA_ARGS__)
+#endif /* HAVE_VTE */
+
+#define GT term
+
+#ifdef HAVE_VTE
+#define VSETW(element, ...)\
+ VSET(element, term->widget, __VA_ARGS__)
+#endif /* HAVE_VTE */
+
+#ifdef HAVE_VTE
+static void
+set_vte_specific_terminal_options(struct GSH_Terminal * term)
+{
+ VSETW(size, term->dimensions.width, term->dimensions.height);
+ VSETW(allow_bold, TRUE);
+ VSETW(backspace_binding, VTE_ERASE_ASCII_BACKSPACE);
+ {
+ GSH * gsh;
+
+ gsh=(GSH *)term->gsh;
+ if(GSH_FLAG(GSH_TERM_TRANSPARENT))
+ {
+ VSETW(background_transparent, TRUE);
+ }
+ }
+}
+#endif /* HAVE_VTE */
+
+static void
+set_terminal_options(struct GSH_Terminal * term)
+{
+#ifdef HAVE_VTE
+ set_vte_specific_terminal_options(term);
+#endif /* HAVE_VTE */
+ if(term->widget)
+ gsh_widget_set_font(term->widget, term->font);
+}
+
+static const gchar *
+get_shell()
+{
+ /* This fixes the failure of environment inheritance
+ under cygwin. */
+ const gchar * shell = getenv("SHELL");
+ if(shell)
+ return shell;
+ else
+ return (const gchar *)"/bin/sh";
+}
+
+static void
+gsh_terminal_run(struct GSH_Terminal * term, const gchar * command)
+{
+ /* Set up line and column counts so that VI has correct display
+ in IDE terminal. */
+ gchar * height;
+ gchar * width;
+ /* Use format of a shell export statement. */
+ ar_asprintf(&height, "LINES=%d", term->dimensions.height);
+ ar_asprintf(&width, "COLUMNS=%d", term->dimensions.width);
+ {
+ /* Null terminated list of environment elements. */
+ const gchar *envv[] = {height, width, NULL};
+ /* Determine which shell to use. */
+ const gchar * shell = get_shell();
+ /* Null terminated list of program arguments. Use
+ the shell as a command processor, such to avoid
+ handling argument separation here. */
+ const gchar *argv[] = { shell, "-c", command, NULL };
+ /* Start the command in the terminal. */
+#ifdef HAVE_VTE
+ vte_terminal_fork_command(VTE_TERMINAL(term->widget), shell,
+ (char **)argv, (char **)envv, NULL, TRUE, TRUE, TRUE);
+#endif /* HAVE_VTE */
+ }
+ /* Free after use. */
+ g_free(height);
+ g_free(width);
+}
+
+static void
+gsh_delete_GSH_Terminal(struct GSH_Terminal * term)
+{
+ g_free(term);
+ /* Freeing the terminal font causes a segmentation fault under
+ * linux, so likely a double free. */
+ /* The terminal widget itself is freed by gobject system
+ * reference counting. */
+}
+
+static void
+title_change_cb(GtkWidget * widget, gpointer data)
+{
+ struct GSHCBData * cb;
+ GSH * gsh;
+ GtkWindow * window;
+
+ cb=(struct GSHCBData *)data;
+ gsh=cb->gsh;
+ window=GTK_WINDOW(gsh->widgets.window);
+ gtk_window_set_title(window,
+#ifdef HAVE_VTE
+ vte_terminal_get_window_title(VTE_TERMINAL(widget))
+#else /* not HAVE_VTE */
+ "Terminal"
+#endif /* HAVE_VTE */
+ );
+}
+
+static void
+status_changed_cb(GtkWidget * widget, gpointer data)
+{
+ struct GSHCBData * cb;
+ GSH * gsh;
+ GtkWidget * status;
+
+ cb=(struct GSHCBData *)data;
+ gsh=cb->gsh;
+ if((status=gsh->widgets.app.status))
+ gtk_statusbar_push(GTK_STATUSBAR(status),
+ gtk_statusbar_get_context_id(GTK_STATUSBAR(status),
+ "terminal"),
+#ifdef HAVE_VTE
+ vte_terminal_get_status_line(VTE_TERMINAL(widget))
+#else /* not HAVE_VTE */
+ "terminal"
+#endif /* HAVE_VTE */
+ );
+}
+
+static void
+setup_terminal_signals(struct GSH_Terminal * term)
+{
+ GSH * gsh;
+ GtkWidget * widget;
+
+ gsh=(GSH *)term->gsh;
+ widget=term->widget;
+ /* Return if no widget was created. */
+ if(!widget)
+ return;
+ /* Exit from the application if the terminal process dies. */
+ GSHCONNECT(widget, "child-exited", gtk_main_quit, NULL);
+ {
+ struct GSHCBData * cb;
+
+ cb=ARNEW(gsh, GSHCBData, gsh, NULL);
+ GSHCONNECT(widget, "status-line-changed",
+ status_changed_cb, cb);
+ GSHCONNECT(widget, "window-title-changed",
+ title_change_cb, cb);
+ }
+}
+
+static GtkWidget *
+gsh_GSH_Terminal_add(struct GSH_Terminal * term, const gchar * command)
+{
+ /* Create and set properties of the VTE-based terminal. */
+#ifdef HAVE_VTE
+ term->widget = vte_terminal_new();
+#else /* not HAVE_VTE */
+ term->widget = NULL;
+#endif /* HAVE_VTE */
+ setup_terminal_signals(term);
+ set_terminal_options(term);
+ gsh_terminal_run(term, command);
+
+ return term->widget;
+}
+
+static void
+assign_methods(struct GSH_Terminal * term)
+{
+ term->delete=&gsh_delete_GSH_Terminal;
+ term->add=&gsh_GSH_Terminal_add;
+}
+
+static void
+initialize_fields(struct GSH_Terminal * term)
+{
+ term->widget=NULL;
+ term->font=NULL;
+ term->dimensions.width=80;
+ term->dimensions.height=24;
+}
+
+static void
+setup_GSH_Terminal(struct GSH_Terminal * term)
+{
+ initialize_fields(term);
+ assign_methods(term);
+}
+
+struct GSH_Terminal *
+gsh_new_GSH_Terminal(GSH * gsh)
+{
+ struct GSH_Terminal * term;
+
+ term=xmalloc(sizeof(struct GSH_Terminal));
+ setup_GSH_Terminal(term);
+ term->gsh = (gpointer)gsh;
+
+ return term;
+}
+
Index: libshell/terminal.h
===================================================================
RCS file: libshell/terminal.h
diff -N libshell/terminal.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/terminal.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,29 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_TERMINAL_H
+#define GSH_TERMINAL_H
+
+struct GSH_Terminal *
+gsh_new_GSH_Terminal();
+
+#endif
Index: libshell/terminal_options.c
===================================================================
RCS file: libshell/terminal_options.c
diff -N libshell/terminal_options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/terminal_options.c 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,59 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+void
+gsh_handle_terminal_options(GSH * gsh, const gint argc,
+ const gchar ** argv, gint *counter)
+{
+#ifndef DEBUG
+ UNUSED(argc);
+#endif /* DEBUG */
+ /* Handle -ot tertiary options. */
+ switch(argv[(*counter)][3])
+ {
+#define GSHT gsh->terminal
+#define GSHTD GSHT->dimensions
+ case 'f': /* Set font for terminal widget. */
+ GSH_COUNT(argc, counter);
+ GSHT->font=(gchar *)argv[*counter];
+ break;
+ case 'h': /* Set terminal widget height. */
+ GSH_COUNT(argc, counter);
+ GSHTD.height=atoi(argv[*counter]);
+ break;
+ case 'T': /* Set not transparent. (Default) */
+ GSH_UNSET(GSH_TERM_TRANSPARENT);
+ break;
+ case 't': /* Set transparent. */
+ GSH_SET(GSH_TERM_TRANSPARENT);
+ break;
+ case 'w': /* Set terminal widget width. */
+ GSH_COUNT(argc, counter);
+ GSHTD.width=atoi(argv[*counter]);
+ break;
+ default: /* Error message. */
+ ARWARN("invalid tertiary terminal option");
+ }
+}
Index: libshell/terminal_options.h
===================================================================
RCS file: libshell/terminal_options.h
diff -N libshell/terminal_options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/terminal_options.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,32 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_TERMINAL_OPTIONS_H
+#define GSH_TERMINAL_OPTIONS_H
+
+void
+gsh_handle_terminal_options(GSH * gsh, const gint argc,
+ const gchar ** argv, gint *counter);
+
+#endif /* not GSH_TERMINAL_OPTIONS_H */
+
Index: libshell/terminal_struct.h
===================================================================
RCS file: libshell/terminal_struct.h
diff -N libshell/terminal_struct.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/terminal_struct.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,41 @@
+/*
+ AntiRight
+ (c) 2007 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 GSH_TERMINAL_STRUCT_H
+#define GSH_TERMINAL_STRUCT_H
+
+struct GSH_Terminal
+{
+ GtkWidget * widget;
+ gchar * font;
+ struct ARArguments * scripts;
+ ARDimensions dimensions;
+ void (*delete)(struct GSH_Terminal *);
+ GtkWidget * (*add)(struct GSH_Terminal *, const gchar *);
+ gpointer gsh;
+};
+
+struct GSH_Terminal *
+gsh_new_GSH_Terminal();
+
+#endif /* not GSH_TERMINAL_STRUCT_H */
+
Index: libshell/test
===================================================================
RCS file: libshell/test
diff -N libshell/test
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/test 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,25 @@
+>
+ <menubar>
+ <menu name="FileMenu" action="FileMenuAction">
+ <menuitem name="New" action="New2Action" />
+ <placeholder name="FileMenuAdditions" />
+ </menu>
+ <menu name="JustifyMenu" action="JustifyMenuAction">
+ <menuitem name="Left" action="justify-left"/>
+ <menuitem name="Centre" action="justify-center"/>
+ <menuitem name="Right" action="justify-right"/>
+ <menuitem name="Fill" action="justify-fill"/>
+ </menu>
+ </menubar>
+ <toolbar action="toolbar1">
+ <placeholder name="JustifyToolItems">
+ <separator/>
+ <toolitem name="Left" action="justify-left"/>
+ <toolitem name="Centre" action="justify-center"/>
+ <toolitem name="Right" action="justify-right"/>
+ <toolitem name="Fill" action="justify-fill"/>
+ <separator/>
+ </placeholder>
+ </toolbar>
+</ui>
+
Index: libshell/text.c
===================================================================
RCS file: libshell/text.c
diff -N libshell/text.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/text.c 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,270 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+#define ADD_ENTRY(widget, str)\
+ gtk_combo_box_prepend_text(GTK_COMBO_BOX(widget), str)
+
+/* Some sample entries to use when history is not useful, such as a
+ * dialog presentation of this field, where the window displaying the
+ * field closes on the first activation. */
+static void
+append_sample_entries(GtkWidget * widget)
+{
+ ADD_ENTRY(widget, "ACE -A Terminal");
+ ADD_ENTRY(widget, "ACE -A Settings");
+ ADD_ENTRY(widget, "ACE -A IDE");
+ ADD_ENTRY(widget, "ACE");
+}
+
+#ifdef DEBUG
+#define VALIDATE_ENTRY_PARAMETERS(gsh, entry, command)\
+{\
+ ARPASSERT(gsh);\
+ ARPASSERT(entry);\
+ ARPASSERT(command);\
+}
+#else /* not DEBUG */
+#define VALIDATE_ENTRY_PARAMETERS(gsh, entry, command) /* undefined */
+#endif /* DEBUG */
+
+static void
+setup_entry_cb(struct GSH * gsh, GtkWidget * entry, const gchar * command)
+{
+
+ struct GSHCBData * cb;
+
+ VALIDATE_ENTRY_PARAMETERS(gsh, entry, command);
+ cb=ARNEW(gsh, GSHCBData, gsh, (gpointer)(command ? command : "echo"));
+ g_signal_connect(G_OBJECT(gtk_bin_get_child(GTK_BIN(entry))),
+ "activate", G_CALLBACK(cb->entry), (gpointer)cb);
+}
+
+GtkWidget *
+gsh_setup_command_entry(struct GSH * gsh, const gchar *command)
+{
+ GtkWidget *entry;
+
+#ifdef DEBUG
+ ARPASSERT(gsh);
+#endif /* DEBUG */
+
+ /* Create widget and assign callback. */
+ setup_entry_cb(gsh, entry=gtk_combo_box_entry_new_text(), command);
+ append_sample_entries(entry);
+ gsh_manage(gsh, entry);
+
+ return entry;
+}
+
+#define SET_WRAP_MODE(text)\
+ gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD)
+
+#define SET_MONOSPACED_FONT(text)\
+ gsh_widget_set_font(text, NULL)
+
+#define SET_OPTIONS(text)\
+{\
+ SET_WRAP_MODE(text);\
+ SET_MONOSPACED_FONT(text);\
+}
+
+
+static void
+setup_text_scroller(GSH * gsh, GtkWidget * text)
+{
+ GtkWidget * scroller;
+
+ GSH_SHOW_CREATE(scroller, scrolled_window, NULL, NULL);
+ gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroller),
+ text);
+ $(gsh, manage, scroller);
+}
+
+GtkWidget *
+gsh_text_area(struct GSH * gsh)
+{
+ GtkWidget *text;
+
+#ifdef DEBUG
+ ARPASSERT(gsh);
+#endif /* DEBUG */
+ gtk_widget_show(text=gsh->editor.widget=gtk_text_view_new());
+ SET_OPTIONS(text);
+ setup_text_scroller(gsh, text);
+
+ return text;
+}
+
+#define CHECK_GEOMETRY(gsh)\
+{\
+ ARIFNP(gsh->geometry)\
+ gsh->geometry=g_strdup("775x700");\
+}
+
+#ifdef DEBUG
+#define VALIDATE_TEXT_EDITOR_PARAMETERS(gsh, filename)\
+{\
+ ARPASSERT(gsh);\
+ ARPASSERT(filename);\
+}
+#else /* not DEBUG */
+#define VALIDATE_TEXT_EDITOR_PARAMETERS(gsh, filename) /* undefined */
+#endif /* DEBUG */
+
+GtkTextBuffer *
+gsh_text_area_set_text(GtkWidget * widget, const gchar * text)
+{
+ GtkTextBuffer * buffer;
+
+ buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget));
+ gtk_text_buffer_set_text(buffer, text, strlen(text));
+
+ return buffer;
+}
+
+/* This is currently just a text file viewer. */
+void
+gsh_text_editor(struct GSH * gsh, const gchar *filename)
+{
+ gchar * text;
+
+ VALIDATE_TEXT_EDITOR_PARAMETERS(gsh, filename);
+ text=antiright_read_named_file(filename);
+ (void)gsh_text_area_set_text(gsh_text_area(gsh), text);
+ g_free(text);
+ CHECK_GEOMETRY(gsh);
+}
+
+/* Check that the editor widget has been initialized. */
+#define TEST_EDITOR_EXISTS(gsh)\
+ if(!gsh->editor.widget)\
+ return;
+/* Text editor does not exist, so return. */
+
+static gchar *
+get_text(GtkWidget * editor)
+{
+ GtkTextBuffer * buffer;
+ GtkTextIter start, end;
+
+ buffer=gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor));
+ gtk_text_buffer_get_start_iter(buffer, &start);
+ gtk_text_buffer_get_end_iter(buffer, &end);
+ return gtk_text_buffer_get_text(buffer, &start, &end, TRUE);
+}
+
+void
+gsh_editor_save(struct GSH * gsh)
+{
+ TEST_EDITOR_EXISTS(gsh);
+ /* Choose action based on whether or not file has been chosen.*/
+ if(gsh->editor.filename)
+ {
+ gchar * text;
+
+ text=get_text(gsh->editor.widget);
+ AR_TEXT_TO_FILE(gsh->editor.filename, text);
+ g_free(text);
+ }
+ else
+ gsh_editor_save_as(gsh);
+}
+
+#define PROMPT_FILENAME() antiright_pipe_read("gtkshell -df")
+
+static void
+get_filename(struct GSH * gsh)
+{
+ /* Make sure that FILENAME is freed if previously used. */
+ if(gsh->editor.filename)
+ g_free(gsh->editor.filename);
+ /* Get the filename. */
+ gsh->editor.filename=PROMPT_FILENAME();
+}
+
+#define FILENAME_NOT_EMPTY strcmp(gsh->editor.filename, "")
+
+void
+gsh_editor_save_as(struct GSH * gsh)
+{
+ TEST_EDITOR_EXISTS(gsh);
+ get_filename(gsh);
+ /* Make sure filename is not empty. */
+ if(FILENAME_NOT_EMPTY)
+ gsh_editor_save(gsh);
+}
+
+static void
+open_gsh_file_in_editor(GSH * gsh)
+{
+ gchar * text;
+
+ text=antiright_read_named_file(gsh->editor.filename);
+ gsh_text_area_set_text(gsh->editor.widget, text);
+ g_free(text);
+}
+
+static void
+recent_file_cb(GtkWidget * widget, gpointer data)
+{
+ GSH * gsh;
+
+ gsh=(GSH *)data;
+ if(gsh->editor.filename)
+ g_free(gsh->editor.filename);
+ gsh->editor.filename=g_strdup(
+ (gchar *)gtk_label_get_text(
+ GTK_LABEL(gtk_bin_get_child(GTK_BIN(widget)))));
+ gsh_editor_save(gsh);
+ open_gsh_file_in_editor(gsh);
+}
+
+static void
+add_to_recent_files(GSH * gsh, const gchar * filename)
+{
+ GtkWidget * menu;
+
+ if((menu=gsh->widgets.app.menus.view))
+ {
+ GtkWidget * button;
+
+ button=gtk_menu_item_new_with_label(filename);
+ GSHCONNECT(button, "activate", recent_file_cb, gsh);
+ gtk_widget_show(button);
+ gtk_menu_shell_append(GTK_MENU_SHELL(menu), button);
+ }
+}
+
+void
+gsh_editor_open(struct GSH * gsh)
+{
+ TEST_EDITOR_EXISTS(gsh);
+ get_filename(gsh);
+ if(FILENAME_NOT_EMPTY)
+ {
+ open_gsh_file_in_editor(gsh);
+ add_to_recent_files(gsh, gsh->editor.filename);
+ }
+}
+
Index: libshell/text.h
===================================================================
RCS file: libshell/text.h
diff -N libshell/text.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/text.h 10 Jun 2007 20:53:59 -0000 1.1
@@ -0,0 +1,50 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_TEXT_H
+#define GSH_TEXT_H
+
+GtkTextBuffer *
+gsh_text_area_set_text(GtkWidget * widget, const gchar * text);
+
+GtkWidget *
+gsh_setup_command_entry(struct GSH * gsh, const gchar *command);
+
+void
+gsh_setup_prompt_command_entry(struct GSH * gsh, const gchar *command);
+
+GtkWidget *
+gsh_text_area(struct GSH * gsh);
+
+void
+gsh_text_editor(struct GSH * gsh, const gchar *filename);
+
+void
+gsh_editor_save_as(struct GSH * gsh);
+
+void
+gsh_editor_save(struct GSH * gsh);
+
+void
+gsh_editor_open(struct GSH * gsh);
+
+#endif
Index: libshell/tree.c
===================================================================
RCS file: libshell/tree.c
diff -N libshell/tree.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/tree.c 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,75 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+enum {
+ KEY_COLUMN,
+ VALUE_COLUMN,
+ COLUMN_COUNT
+};
+
+static void
+add_item(GtkListStore * store, GtkTreeIter * iter,
+ const gchar * key, const gchar * value)
+{
+ gtk_list_store_append(store, iter);
+ gtk_list_store_set(store, iter,
+ KEY_COLUMN, key,
+ VALUE_COLUMN, value,
+ -1);
+}
+
+static GtkTreeModel *
+setup_model(void)
+{
+ GtkListStore * store;
+ GtkTreeIter iter;
+
+ store=gtk_list_store_new(COLUMN_COUNT, G_TYPE_STRING, G_TYPE_STRING);
+ add_item(store, &iter, "DISPLAY", ":0");
+
+ return GTK_TREE_MODEL(store);
+}
+
+#define ADD_COLUMN(view, name, id)\
+ gtk_tree_view_insert_column_with_attributes(GTK_TREE_VIEW(view),\
+ -1, name, renderer, "text", id, NULL)
+
+GtkWidget *
+gsh_tree_view_new(GSH * gsh, const gchar * input)
+{
+ GtkTreeModel * model;
+ GtkCellRenderer * renderer;
+ GtkWidget * view;
+
+ model=setup_model();
+ view=gtk_tree_view_new();
+ renderer=gtk_cell_renderer_text_new();
+ ADD_COLUMN(view, "KEY", KEY_COLUMN);
+ ADD_COLUMN(view, "VALUE", VALUE_COLUMN);
+ gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
+ g_object_unref(model);
+
+ return view;
+}
+
Index: libshell/tree.h
===================================================================
RCS file: libshell/tree.h
diff -N libshell/tree.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/tree.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_TREE_H
+#define GSH_TREE_H
+
+GtkWidget *
+gsh_tree_view_new(GSH * gsh, const gchar * input);
+
+#endif /* GSH_TREE_H */
+
Index: libshell/update_manager.c
===================================================================
RCS file: libshell/update_manager.c
diff -N libshell/update_manager.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/update_manager.c 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,174 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 "gtkshell.h"
+
+static void
+gsh_update_each(gpointer data, gpointer user_data)
+{
+ UNUSED(user_data);
+ /*
+ * Ensure that the argument containing the structure is not
+ * empty.
+ */
+#ifdef DEBUG
+ ARWIFNP(data)
+ {
+#endif /* DEBUG */
+ struct GSHUpdatedWidget *item;
+
+ /*
+ * Assign data to structure and call function pointer
+ * with parameters.
+ */
+ item = (struct GSHUpdatedWidget *) data;
+#ifdef DEBUG
+ ARPASSERT(item->update);
+#endif /* DEBUG */
+ $(item, update);
+#ifdef DEBUG
+ }
+#endif /* DEBUG */
+}
+
+static gint
+gsh_perform_updates(gpointer data)
+{
+ struct GSHUpdateManager * updaters;
+
+#ifdef DEBUG
+ ARBUG("gsh_perform_updates()");
+#endif /* DEBUG */
+
+ updaters = (struct GSHUpdateManager *) data;
+
+
+#ifdef DEBUG
+ if (updaters && updaters->list)
+#endif /* DEBUG */
+ g_slist_foreach(updaters->list, gsh_update_each, NULL);
+#ifdef DEBUG
+ else
+ {
+ ARWARN("data invalid, operation not performed.");
+ return FALSE;
+ }
+#endif /* DEBUG */
+
+ return TRUE;
+}
+
+static void
+gsh_GSHUpdateManager_start(struct GSHUpdateManager * updaters)
+{
+#ifdef DEBUG
+ ARBUG("gsh_start_updates()");
+#endif /* DEBUG */
+ if(updaters->updating)
+ return;
+ else
+ updaters->updating=TRUE;
+#ifdef DEBUG
+ ARWIFNP (updaters)
+ {
+#endif /* DEBUG */
+ (void) gsh_perform_updates(updaters);
+ (void) g_timeout_add(updaters->period, gsh_perform_updates,
+ updaters);
+#ifdef DEBUG
+ }
+#endif /* DEBUG */
+}
+
+static void
+gsh_GSHUpdateManager_add(struct GSHUpdateManager * updaters,
+ struct GSHUpdatedWidget * item)
+{
+
+#ifdef DEBUG
+ ARBUG("gsh_append_updater()");
+
+ if (ARPBOOL(updaters) && ARPBOOL(item))
+#endif /* DEBUG */
+ updaters->list = g_slist_prepend(updaters->list, item);
+ /* Begin updating, if necessary. */
+ gsh_GSHUpdateManager_start(updaters);
+#ifdef DEBUG
+ ARBUG("end gsh_append_updater()");
+#endif /* DEBUG */
+}
+
+
+static void
+gsh_delete_each_updater(gpointer data, gpointer user_data)
+{
+ struct GSHUpdatedWidget * item;
+
+ UNUSED(user_data);
+ item=(struct GSHUpdatedWidget *)data;
+ $(item, delete);
+}
+
+static void
+gsh_delete_GSHUpdateManager(struct GSHUpdateManager * updaters)
+{
+ g_slist_foreach(updaters->list, gsh_delete_each_updater, NULL);
+ g_slist_free(updaters->list);
+ g_free(updaters);
+}
+
+/* Setup method function pointer assignments. */
+static void
+assign_methods(struct GSHUpdateManager * update)
+{
+ update->delete=&gsh_delete_GSHUpdateManager;
+ update->add=&gsh_GSHUpdateManager_add;
+}
+
+/* Setup member data fields. */
+static void
+initialize_fields(struct GSHUpdateManager * update)
+{
+ update->period = 1000;
+ update->list = (GSList *) NULL;
+ update->updating=FALSE;
+}
+
+static void
+setup(struct GSHUpdateManager * update)
+{
+ assign_methods(update);
+ initialize_fields(update);
+}
+
+struct GSHUpdateManager *
+gsh_new_GSHUpdateManager()
+{
+ struct GSHUpdateManager * updater;
+
+ updater=xmalloc(sizeof(struct GSHUpdateManager));
+ setup(updater);
+
+ return updater;
+}
+
+
Index: libshell/update_manager.h
===================================================================
RCS file: libshell/update_manager.h
diff -N libshell/update_manager.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/update_manager.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_UPD_MAN_H
+#define GSH_UPD_MAN_H
+
+struct GSHUpdateManager *
+gsh_new_GSHUpdateManager();
+
+#endif /* GSH_UPD_MAN_H */
+
Index: libshell/update_manager_struct.h
===================================================================
RCS file: libshell/update_manager_struct.h
diff -N libshell/update_manager_struct.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/update_manager_struct.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,36 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_UMS_H
+#define GSH_UMS_H
+
+struct GSHUpdateManager
+{
+ unsigned int period;
+ /address@hidden@*/ GSList *list;
+ gboolean updating;
+ void (*delete)(struct GSHUpdateManager *);
+ void (*add)(struct GSHUpdateManager * , struct GSHUpdatedWidget *);
+};
+
+#endif /* GSH_UMS_H */
+
Index: libshell/updated.c
===================================================================
RCS file: libshell/updated.c
diff -N libshell/updated.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated.c 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,63 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+gsh_delete_GSHUpdatedWidget(struct GSHUpdatedWidget * item)
+{
+ GSH_FREE_IF(item->command);
+ g_free(item);
+}
+
+static void
+gsh_GSHUpdatedWidget_update(struct GSHUpdatedWidget * item)
+{
+ item->function(item->command, item->widget);
+}
+
+/* Assign GSHUpdatedWidget class methods. */
+#define ASSIGN_METHODS(updater)\
+{\
+ updater->update=&gsh_GSHUpdatedWidget_update;\
+ updater->delete=&gsh_delete_GSHUpdatedWidget;\
+}
+
+struct GSHUpdatedWidget *
+gsh_new_GSHUpdatedWidget(void (*function)(const gchar *, gpointer),
+ const gchar * command, GtkWidget * widget)
+{
+ struct GSHUpdatedWidget * updater;
+
+ updater=xmalloc(sizeof(struct GSHUpdatedWidget));
+ ASSIGN_METHODS(updater);
+ /* Assign widget-specific update information, specifically
+ * the widget command, a pointer to the widget, and the widget's
+ * updater function. */
+ updater->command=g_strdup(command);
+ updater->widget=widget;
+ updater->function=function;
+
+ return updater;
+}
+
+
Index: libshell/updated.h
===================================================================
RCS file: libshell/updated.h
diff -N libshell/updated.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,39 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_UPDATED_H
+#define GSH_UPDATED_H
+
+struct GSHUpdatedWidget
+{
+ GtkWidget * widget;
+ gchar * command;
+ void (*function)(const gchar *, gpointer);
+ void (*update)(struct GSHUpdatedWidget *);
+ void (*delete)(struct GSHUpdatedWidget *);
+};
+
+struct GSHUpdatedWidget *
+gsh_new_GSHUpdatedWidget(void (*function)(const gchar *, gpointer),
+ const gchar * command, GtkWidget * widget);
+
+#endif
Index: libshell/updated_label.c
===================================================================
RCS file: libshell/updated_label.c
diff -N libshell/updated_label.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated_label.c 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,77 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 "gtkshell.h"
+
+/* This ensures that the result string is not empty, avoiding
+ * certain formatting problems.
+ * Otherwise, a GTK warning and termination occurs. */
+
+#define CHECK_RESULTS(results) \
+{\
+ if (results[0] == '\0')\
+ {\
+ g_free(results);\
+ results=g_strdup("(empty)");\
+ }\
+}
+
+static void
+gsh_update_label(const gchar *command, gpointer widget)
+{
+ gchar *results;
+
+#ifdef DEBUG
+ ARBUG("gsh_update_label()");
+
+ ARPASSERT(command);
+ ARPASSERT(widget);
+#endif /* DEBUG */
+ results=antiright_pipe_read(command);
+ CHECK_RESULTS(results);
+ if(GTK_IS_LABEL(widget))
+ gtk_label_set_text(GTK_LABEL(widget), results);
+ else if(GTK_IS_STATUSBAR(widget))
+ gtk_statusbar_push(GTK_STATUSBAR(widget),
+ gtk_statusbar_get_context_id(GTK_STATUSBAR(widget),
+ "updater"), results);
+ g_free(results);
+}
+
+void
+gsh_add_updated_label(struct GSH * gsh, const gchar *command)
+{
+#define GWA gsh->widgets.app
+ GtkWidget * status = GWA.status;
+#ifdef DEBUG
+ g_message("gsh_add_updated_label()");
+ ARPASSERT(gsh);
+ ARPASSERT(command);
+#endif /* DEBUG */
+ $(gsh->update, add, ARNEW(gsh, GSHUpdatedWidget, &gsh_update_label,
+ command, (GSH_FLAG(GSH_APP_MODE) && status)
+ ? status : gsh_add_label(gsh, (char *)command)));
+ GSH_UNSET(GSH_APP_MODE);
+ /* Prevent two updaters from being
+ assigned to the status bar label. */
+ GWA.status=NULL;
+}
Index: libshell/updated_label.h
===================================================================
RCS file: libshell/updated_label.h
diff -N libshell/updated_label.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated_label.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,29 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_UPDATED_LABEL_H
+#define GSH_UPDATED_LABEL_H
+
+void
+gsh_add_updated_label(struct GSH * gsh, const gchar *command);
+
+#endif /* GSH_UPDATED_LABEL_H */
Index: libshell/updated_options.c
===================================================================
RCS file: libshell/updated_options.c
diff -N libshell/updated_options.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated_options.c 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,54 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 "gtkshell.h"
+
+static void
+add_updater(GSH * gsh, const gint argc, gint * counter,
+ const gchar ** argv, void (*add_func)(GSH *, const gchar *))
+{
+ GSH_COUNT(argc, counter);
+ add_func(gsh, argv[*counter]);
+}
+
+#define UADD(type) \
+ add_updater(gsh, argc, counter, argv, &gsh_add_updated_##type)
+
+void
+gsh_handle_updated_arguments(GSH * gsh, const gint argc,
+ const gchar **argv, gint *counter)
+{
+#ifdef DEBUG
+ ARPASSERT(gsh);
+#endif /* DEBUG */
+
+ g_assert(strlen(argv[(*counter)]) > 2);
+ switch (argv[(*counter)][3])
+ {
+ case 'l':
+ UADD(label);
+ break;
+ case 'p':
+ UADD(progress);
+ break;
+ }
+}
Index: libshell/updated_options.h
===================================================================
RCS file: libshell/updated_options.h
diff -N libshell/updated_options.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated_options.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,30 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 GSH_UPDATED_OPTIONS_H
+#define GSH_UPDATED_OPTIONS_H
+
+void
+gsh_handle_updated_arguments(GSH * gsh, const gint argc,
+ const gchar **argv, gint *counter);
+
+#endif
Index: libshell/updated_progress.c
===================================================================
RCS file: libshell/updated_progress.c
diff -N libshell/updated_progress.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated_progress.c 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,53 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "gtkshell.h"
+
+static void
+gsh_update_progress(const gchar *command, gpointer widget)
+{
+ gchar *results;
+
+#ifdef DEBUG
+ ARPASSERT(command);
+ ARPASSERT(widget);
+#endif /* DEBUG */
+
+ gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR((GtkWidget *) widget),
+ strtod(results=antiright_pipe_read((char*)command), NULL));
+ g_free(results);
+}
+
+void
+gsh_add_updated_progress(struct GSH * gsh, const gchar *command)
+{
+ GtkWidget *progress;
+
+#ifdef DEBUG
+ ARPASSERT(gsh);
+ ARPASSERT(command);
+#endif /* DEBUG */
+ progress=gtk_progress_bar_new();
+ $(gsh, manage, progress);
+ $(gsh->update, add, ARNEW(gsh, GSHUpdatedWidget,
+ &gsh_update_progress, command, progress));
+}
Index: libshell/updated_progress.h
===================================================================
RCS file: libshell/updated_progress.h
diff -N libshell/updated_progress.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ libshell/updated_progress.h 10 Jun 2007 20:54:00 -0000 1.1
@@ -0,0 +1,29 @@
+/*
+ AntiRight
+ (c) 2002-2006 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 GSH_UPDATED_PROGRESS_H
+#define GSH_UPDATED_PROGRESS_H
+
+void
+gsh_add_updated_progress(struct GSH * gsh, const gchar *command);
+
+#endif
Index: xshell/Makefile
===================================================================
RCS file: xshell/Makefile
diff -N xshell/Makefile
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/Makefile 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,49 @@
+###############################################################################
+#
+# AntiRight
+# (c) 2004-2007 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 ../config.mk
+
+PREFIX=/usr/local
+CC=gcc
+INCLUDES=-I/usr/X11R6/include -I/usr/pkg/include
+CFLAGS+=$(INCLUDES)
+#CFLAGS+=-DDEBUG -g3 -Wall -W
+LIBS=-L/usr/X11R6/lib -L/usr/pkg/lib -lX11
+LDFLAGS+=$(LIBS)
+
+OBJECTS=xshell.o widget.o button.o
+
+all: xshell
+
+xshell: $(OBJECTS)
+ $(CC) -o xshell $(OBJECTS) $(LDFLAGS)
+
+clean:
+ rm -f *.o xshell
+
+install:
+ cp xshell $(PREFIX)/bin
+
Index: xshell/button.c
===================================================================
RCS file: xshell/button.c
diff -N xshell/button.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/button.c 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,105 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "xshell.h"
+
+static void
+draw_label(XWidget * button)
+{
+ XShell * xsh;
+ XSHButtonData * data;
+ char * label;
+
+ xsh=(XShell *)button->xsh;
+ data=(XSHButtonData *)button->data;
+ label=data->label;
+#ifdef DEBUG
+ assert(label);
+ assert(xsh->gui.display);
+ puts(label);
+#endif /* DEBUG */
+ XDrawString(xsh->gui.display, button->window, xsh->gui.gc,
+ 3, 12, label, strlen(label));
+}
+
+static void
+expose(XWidget * button)
+{
+ draw_label(button);
+}
+
+static void
+button_press(XWidget * button)
+{
+ XSHButtonData * data;
+
+ XMSG("PRESSED");
+ data=(XSHButtonData *)button->data;
+ system(data->command);
+}
+
+static void
+key_press(XWidget * button)
+{
+ button_press(button);
+}
+
+static void
+configure(XWidget * button)
+{
+ expose(button);
+}
+
+static void
+setup_events(XWidget * button)
+{
+ button->events.expose=&expose;
+ button->events.configure=&configure;
+ button->events.key_press=&key_press;
+ button->events.button_press=&button_press;
+}
+
+void
+xshell_button_new(XShell * xsh, XWidget * parent, int x, int y,
+ const char * command)
+{
+ XWidget * button;
+ XSHButtonData * data;
+ char * label;
+
+ xshell_XWidget_new(xsh, parent, x, y, 100, 16);
+ button=xsh->gui.last_widget;
+ data=malloc(sizeof(XSHButtonData));
+ data->command=(char *)command;
+ label=strchr(command, '#');
+ if(label)
+ {
+ data->label=label+1;
+ }
+ else
+ {
+ data->label=(char *)command;
+ }
+ button->data=data;
+ setup_events(button);
+}
+
Index: xshell/button.h
===================================================================
RCS file: xshell/button.h
diff -N xshell/button.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/button.h 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,40 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 XSH_BUTTON_H
+#define XSH_BUTTON_H
+
+struct XSHButtonData
+{
+ char * command;
+ char * label;
+};
+
+typedef struct XSHButtonData XSHButtonData;
+
+void
+xshell_button_new(XShell * xsh, XWidget * parent, int x, int y,
+ const char * command);
+
+#endif /* XSH_BUTTON_H */
+
Index: xshell/widget.c
===================================================================
RCS file: xshell/widget.c
diff -N xshell/widget.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/widget.c 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,168 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "xshell.h"
+
+static XWidget *
+find_last_widget(XWidget * first)
+{
+ XWidget * iter;
+
+ for(iter=first; iter->next; iter=iter->next);
+
+ return iter;
+}
+
+static void
+select_event(XWidget * iter, unsigned int event_type)
+{
+ switch(event_type)
+ {
+ case XSH_EXPOSE_EVENT:
+ XMSG("expose");
+ if(iter->events.expose)
+ (iter->events.expose)(iter);
+ XMSG("expose done");
+ break;
+ case XSH_KEY_PRESS_EVENT:
+ XMSG("key press");
+ if(iter->events.key_press)
+ (iter->events.key_press)(iter);
+ break;
+ case XSH_BUTTON_PRESS_EVENT:
+ XMSG("button press");
+ if(iter->events.button_press)
+ (iter->events.button_press)(iter);
+ break;
+ case XSH_CONFIGURE_EVENT:
+ XMSG("configure");
+ if(iter->events.configure)
+ (iter->events.configure)(iter);
+ break;
+ };
+
+}
+
+void
+xshell_foreach_XWidget(XWidget * head, unsigned int event_type, Window w)
+{
+ XWidget * iter;
+
+ XMSG("xshell_foreach_XWidget()");
+ iter=head;
+ while(iter)
+ {
+ XMSG("event received");
+#ifdef DEBUG
+ assert(iter);
+#endif /* DEBUG */
+ if(w!=iter->window)
+ {
+ iter=iter->next;
+ continue;
+ }
+ select_event(iter, event_type);
+ iter=iter->next;
+ }
+ XMSG("end xshell_foreach_XWidget()");
+}
+
+static void
+nullify_widget_events(XWidget * widget)
+{
+ widget->events.expose=NULL;
+ widget->events.key_press=NULL;
+ widget->events.button_press=NULL;
+ widget->events.configure=NULL;
+}
+
+static void
+nullify_widget_members(XWidget * widget)
+{
+ widget->data=NULL;
+ nullify_widget_events(widget);
+}
+
+static void
+setup_widget_geometry(XWidget * widget, int width, int height, int x, int y)
+{
+ widget->geometry.x=x;
+ widget->geometry.y=y;
+ widget->geometry.width=width;
+ widget->geometry.height=height;
+}
+
+static void
+initialize_widget_members(XWidget * widget,
+ int x, int y, int width, int height)
+{
+ nullify_widget_members(widget);
+ setup_widget_geometry(widget, width, height, x, y);
+}
+
+static void
+setup_widget_window(XShell * xsh, XWidget * widget, XWidget * parent)
+{
+ Display * dpy;
+ XSHGeometry * geometry;
+
+ XMSG("create widget window");
+ dpy=xsh->gui.display;
+ geometry=&(widget->geometry);
+ widget->window=XCreateSimpleWindow(dpy,
+ parent ? parent->window : DefaultRootWindow(dpy),
+ geometry->x, geometry->y,
+ geometry->width, geometry->height, 1,
+ xsh->gui.colors.white, xsh->gui.colors.black);
+ XSelectInput(dpy, widget->window, ButtonPressMask
+ | ExposureMask | KeyPressMask | PropertyChangeMask);
+ XMSG("show widget window");
+ XMapWindow(dpy, widget->window);
+}
+
+void
+xshell_XWidget_new(XShell * xsh, XWidget * parent,
+ int x, int y, int width, int height)
+{
+ XWidget * widget;
+
+ XMSG("xshell_XWidget_new()");
+ widget=malloc(sizeof(XWidget));
+ if(xsh->gui.widgets)
+ {
+ XMSG("xsh->gui.widgets");
+ XWidget * last;
+
+ last=find_last_widget(xsh->gui.widgets);
+ last->next=widget;
+ }
+ else
+ {
+ XMSG("!xsh->gui.widgets");
+ xsh->gui.widgets=widget;
+ }
+ initialize_widget_members(widget, x, y, width, height);
+ widget->xsh=(void *)xsh;
+ setup_widget_window(xsh, widget, parent);
+ xsh->gui.last_widget=widget;
+}
Index: xshell/widget.h
===================================================================
RCS file: xshell/widget.h
diff -N xshell/widget.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/widget.h 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,35 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 XSH_WIDGET_H
+#define XSH_WIDGET_H
+
+void
+xshell_XWidget_new(XShell * xsh, XWidget * parent,
+ int x, int y, int width, int height);
+
+void
+xshell_foreach_XWidget(XWidget * head, unsigned int type, Window w);
+
+#endif /* XSH_WIDGET_H */
+
Index: xshell/xshell.c
===================================================================
RCS file: xshell/xshell.c
diff -N xshell/xshell.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/xshell.c 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,169 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 "xshell.h"
+
+static void
+setup_colors(XShell * xsh)
+{
+ Display * dpy;
+ int screen;
+
+ dpy=xsh->gui.display;
+ screen=DefaultScreen(dpy);
+ xsh->gui.colors.black=BlackPixel(dpy, screen);
+ xsh->gui.colors.white=WhitePixel(dpy, screen);
+}
+
+static void
+event_loop(XShell * xsh)
+{
+ XEvent event;
+ Display *dpy;
+
+ for(dpy=xsh->gui.display;;XNextEvent(dpy, &event))
+ {
+ switch(event.type)
+ {
+ case Expose:
+ xshell_foreach_XWidget(xsh->gui.widgets,
+ XSH_EXPOSE_EVENT, event.xexpose.window);
+ break;
+ case ConfigureRequest:
+ xshell_foreach_XWidget(xsh->gui.widgets,
+ XSH_CONFIGURE_EVENT,
+ event.xconfigurerequest.window);
+ break;
+ case KeyPress:
+ xshell_foreach_XWidget(xsh->gui.widgets,
+ XSH_KEY_PRESS_EVENT,
+ event.xkey.window);
+ break;
+ case ButtonPress:
+ xshell_foreach_XWidget(xsh->gui.widgets,
+ XSH_BUTTON_PRESS_EVENT,
+ event.xbutton.window);
+ break;
+ }
+ }
+}
+
+static void
+setup_XShell(XShell * xsh)
+{
+ xsh->gui.widgets=NULL;
+}
+
+static void
+delete_widgets(XWidget * head)
+{
+ XWidget * iter;
+
+ iter=head;
+ while(iter)
+ {
+ XWidget * next;
+
+ next=iter->next;
+ free(iter);
+ iter=next;
+ }
+}
+
+static void
+cleanup(XShell * xsh)
+{
+ Display * dpy;
+
+ dpy=xsh->gui.display;
+ delete_widgets(xsh->gui.widgets);
+ XFreeGC(dpy, xsh->gui.gc);
+ XCloseDisplay(dpy);
+}
+
+static void
+setup_gc(XShell * xsh)
+{
+ XGCValues values;
+ Display * dpy;
+
+ dpy=xsh->gui.display;
+ values.foreground=xsh->gui.colors.white;
+ xsh->gui.gc=XCreateGC(dpy, xsh->gui.widgets->window,
+ GCForeground, &values);
+}
+
+static void
+setup_close_button(XShell * xsh)
+{
+ xshell_button_new(xsh, xsh->gui.widgets, 84, 0, "Exit___ #X");
+ xsh->gui.last_widget->events.button_press=(void (*)(XWidget *))exit;
+ xsh->gui.last_widget->events.key_press=NULL;
+}
+
+static void
+setup_title(XShell * xsh , const char * title)
+{
+ xshell_button_new(xsh, xsh->gui.widgets, 0, 0, title);
+ xsh->gui.last_widget->events.button_press=NULL;
+ xsh->gui.last_widget->events.key_press=NULL;
+}
+
+static void
+setup_titlebar(XShell * xsh, const char * title)
+{
+ setup_title(xsh, title);
+ setup_close_button(xsh);
+}
+
+int
+main(int argc, char ** argv)
+{
+ XShell xsh;
+ Display * dpy;
+ unsigned int counter;
+
+ setup_XShell(&xsh);
+ dpy=xsh.gui.display=XOpenDisplay(NULL);
+ setup_colors(&xsh);
+ xshell_XWidget_new(&xsh, NULL, 0, 0, 100, 16);
+ setup_gc(&xsh);
+ for(counter=1; counter<(unsigned int)argc; counter++)
+ {
+ puts(argv[counter]);
+ xshell_button_new(&xsh, xsh.gui.widgets,
+ /*(100*(((counter-1)*16)%300)), ((counter-1)*16), */
+ /*((counter*16)%xsh.gui.widgets->geometry.height)*100,*/
+ 0,
+ counter*16,
+ argv[counter]);
+ }
+ XResizeWindow(xsh.gui.display, xsh.gui.widgets->window, 100,
+ counter*16);
+ setup_titlebar(&xsh, argv[0]);
+ event_loop(&xsh);
+ cleanup(&xsh);
+
+ return 0;
+}
+
Index: xshell/xshell.h
===================================================================
RCS file: xshell/xshell.h
diff -N xshell/xshell.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ xshell/xshell.h 10 Jun 2007 20:54:01 -0000 1.1
@@ -0,0 +1,94 @@
+/*
+ AntiRight
+ (c) 2002-2007 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 XSHELL_H
+#define XSHELL_H
+
+#include <X11/Xlib.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <assert.h>
+#include <string.h>
+
+#ifdef DEBUG
+#define XMSG(msg) fprintf(stderr, "%s:%d: %s\n", __FILE__, __LINE__, msg);
+#else /* not DEBUG */
+#define XMSG(msg) /* unused */
+#endif /* DEBUG */
+
+#define XSH_EXPOSE_EVENT 1
+#define XSH_KEY_PRESS_EVENT 2
+#define XSH_BUTTON_PRESS_EVENT 3
+#define XSH_CONFIGURE_EVENT 4
+
+struct XSHGeometry
+{
+ int x;
+ int y;
+ unsigned int width;
+ unsigned int height;
+};
+
+typedef struct XSHGeometry XSHGeometry;
+
+struct XWidget
+{
+ Window window;
+ XSHGeometry geometry;
+ struct
+ {
+ void (*expose)(struct XWidget *);
+ void (*button_press)(struct XWidget *);
+ void (*key_press)(struct XWidget *);
+ void (*configure)(struct XWidget *);
+ } events;
+ void * data;
+ void * xsh; /* Ensure root access. */
+ struct XWidget *next;
+};
+
+typedef struct XWidget XWidget;
+
+struct XShell
+{
+ struct {
+ Display * display;
+ XWidget * widgets;
+ XWidget * last_widget;
+ GC gc;
+
+ struct
+ {
+ unsigned long black;
+ unsigned long white;
+ } colors;
+ } gui;
+};
+
+typedef struct XShell XShell;
+
+#include "widget.h"
+#include "button.h"
+
+#endif /* XSHELL_H */
+
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright Makefile configure gtkshell/Makefile ...,
Jeffrey Bedard <=