antiright-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Antiright-devel] antiright gtkshell/Makefile gtkshell/app_mode.c...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright gtkshell/Makefile gtkshell/app_mode.c...
Date: Mon, 23 Aug 2010 18:13:43 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 10/08/23 18:13:43

Modified files:
        gtkshell       : Makefile app_mode.c button.h gsh.h gshterm 
                         gtkshell.c gtkshell.h macros.h menu.c 
                         terminal.c terminal.h terminal_struct.h 
        libantiright   : pipe.c system.c 
        rootcat        : Makefile 

Log message:
        Build directly to an executable, rather than building the libgtkshell.a
        intermediate library, resulting in smaller executable size.  Add a
        toolbar to the terminal notebook, with mnemonic-bound new, back, 
forward,
        and close buttons to allow for keyboard navigation between terminal 
tabs.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/Makefile?cvsroot=antiright&r1=1.64&r2=1.65
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/app_mode.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.h?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gsh.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gshterm?cvsroot=antiright&r1=1.14&r2=1.15
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.56&r2=1.57
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.63&r2=1.64
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/macros.h?cvsroot=antiright&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&r1=1.33&r2=1.34
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal.c?cvsroot=antiright&r1=1.40&r2=1.41
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal.h?cvsroot=antiright&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal_struct.h?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/pipe.c?cvsroot=antiright&r1=1.15&r2=1.16
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/system.c?cvsroot=antiright&r1=1.12&r2=1.13
http://cvs.savannah.gnu.org/viewcvs/antiright/rootcat/Makefile?cvsroot=antiright&r1=1.6&r2=1.7

Patches:
Index: gtkshell/Makefile
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/Makefile,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -b -r1.64 -r1.65
--- gtkshell/Makefile   22 Aug 2010 20:31:53 -0000      1.64
+++ gtkshell/Makefile   23 Aug 2010 18:13:42 -0000      1.65
@@ -26,12 +26,11 @@
 include ../config.mk
 
 CFLAGS+=$(DEFS) $(INCLUDE)
-ARFLAGS=-L. -lgtkshell -L../libantiright -lantiright
+ARFLAGS=-L../libantiright -lantiright
 GTKFLAGS=$(ARFLAGS) $(LDFLAGS)
 
 objects=$(patsubst %.c,%.o,$(wildcard *.c)) 
-objects+=y.tab.o lex.yy.o
-program=main.o 
+#objects+=y.tab.o lex.yy.o
 
 ifeq ($(OS),MINGW32)
        INSTALLPROG=cp
@@ -42,9 +41,8 @@
 all: y.tab.c
        $(MAKE) gtkshell
 
-gtkshell: $(objects) $(program)
-       ar rcs libgtkshell.a $(objects)
-       cc -o gtkshell $(program) $(GTKFLAGS)
+gtkshell: $(objects)
+       cc -o gtkshell $(objects) $(GTKFLAGS)
 
 lex.yy.c: guidl.lex
        $(LEX) -o lex.yy.c guidl.lex

Index: gtkshell/app_mode.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/app_mode.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gtkshell/app_mode.c 22 Aug 2010 18:56:32 -0000      1.6
+++ gtkshell/app_mode.c 23 Aug 2010 18:13:42 -0000      1.7
@@ -23,45 +23,21 @@
 
 #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)
-{
-  GtkWidget *toolbar;
-
-  GSH_SHOW_CREATE (toolbar = GWA.toolbar, toolbar);
-  gtk_toolbar_set_style (GTK_TOOLBAR (toolbar), GTK_TOOLBAR_ICONS);
-  GSHCA_TIGHT (GWA.row, toolbar);
-}
-
-static void
-setup_app_mode_frame (GSH * gsh)
-{
-  GSH_SHOW_CREATE (GWA.frame, frame, NULL);
-  GSHCA (GWA.row, GWA.frame);
-}
-
-static void
-setup_row(struct GSH * gsh)
-{
-}
+#define GWA gsh->widgets.app
 
 void
-gsh_setup_app_mode (struct GSH *gsh)
+gsh_setup_app_mode (GSH *gsh)
 {
+  /* setup row */
   GSH_SHOW_CREATE (GWA.row, vbox, FALSE, 1);
-  /* Add menu bar to application column.  */
+  /* 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);
+  /* setup toolbar */
+  GSH_ADD_WIDGET(GWA.row, GWA.toolbar, toolbar);
+  gtk_toolbar_set_style (GTK_TOOLBAR (GWA.toolbar), GTK_TOOLBAR_ICONS);
+  /* setup frame */
+  GSH_ADD_WIDGET(GWA.row, GWA.frame, frame, NULL);
+  /* setup status bar */
+  GSH_ADD_WIDGET(GWA.row, GWA.status, statusbar);
 }
+

Index: gtkshell/button.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- gtkshell/button.h   16 Aug 2010 11:51:21 -0000      1.15
+++ gtkshell/button.h   23 Aug 2010 18:13:42 -0000      1.16
@@ -25,6 +25,7 @@
 
 GtkWidget *gsh_add_button (struct GSH * gsh, const gchar * string);
 
+
 #define GSH_LABEL_TO_ICON_MAPPINGS \
 {\
        { "Run...", GTK_STOCK_EXECUTE },\

Index: gtkshell/gsh.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gsh.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/gsh.h      22 Aug 2010 18:56:32 -0000      1.7
+++ gtkshell/gsh.h      23 Aug 2010 18:13:42 -0000      1.8
@@ -22,6 +22,8 @@
 #ifndef GSH_GSH_H
 #define GSH_GSH_H
 
+#include "terminal_struct.h"
+
 struct GSH
 {
   /* member data */
@@ -65,7 +67,7 @@
   /* member classes */
   struct GSHRows *rows;
   struct GSHUpdateManager *update;
-  struct GSH_Terminal *terminal;
+  struct GSHTerminal *terminal;
 
   ARTupleVector *command_dictionary;
   gchar *usage;

Index: gtkshell/gshterm
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gshterm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -b -r1.14 -r1.15
--- gtkshell/gshterm    22 Aug 2010 20:31:53 -0000      1.14
+++ gtkshell/gshterm    23 Aug 2010 18:13:42 -0000      1.15
@@ -46,9 +46,6 @@
                t)
                        TRANSPARENT="-ott"
                        ;;
-               \?)
-                       gshterm_usage 1
-                       ;;
        esac
 done
 
@@ -59,7 +56,21 @@
 fi
 
 if [ "$GEOMETRY" != "" ]; then
-       ARGS="$ARGS -og $GEOMETRY"
+       SIZEARG="`echo $GEOMETRY | cut -d+ -f1`"
+       POSARG="`echo $GEOMETRY | cut -d+ -f2-`"
+       if [ "$POSARG" != "" ]; then
+               ARGS="$ARGS -og +$POSARG"
+       fi
+       if [ "$SIZEARG" != "" ]; then
+               WIDTH="`echo $SIZEARG | cut -dx -f1`"
+               HEIGHT="`echo $SIZEARG | cut -dx -f2`"
+               if [ "$WIDTH" != "" ]; then
+                       ARGS="$ARGS -otw $WIDTH"
+               fi
+               if [ "$HEIGHT" != "" ]; then
+                       ARGS="$ARGS -oth $HEIGHT"
+               fi
+       fi
 fi
 
 if [ "$FONT" != "" ]; then
@@ -71,7 +82,7 @@
 if [ "$COMMAND" = "" ]; then
        COMMAND=$SHELL
 fi
-#DEBUG=TRUE
+
 COMMAND="gtkshell $APP_MODE -oF $ARGS -oT '$COMMAND' -as '$COMMAND'"
 if [ "$DEBUG" = "TRUE" ]; then
        echo $COMMAND
@@ -79,3 +90,4 @@
 else
        exec sh -c "$COMMAND"
 fi
+

Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.56
retrieving revision 1.57
diff -u -b -r1.56 -r1.57
--- gtkshell/gtkshell.c 22 Aug 2010 20:31:53 -0000      1.56
+++ gtkshell/gtkshell.c 23 Aug 2010 18:13:42 -0000      1.57
@@ -100,8 +100,6 @@
   gsh->icon_size = GTK_ICON_SIZE_DND;
   /* Add initial window.  */
   $ (gsh, add.window);
-
-//  return gsh;
 }
 
 GSH *

Index: gtkshell/gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -b -r1.63 -r1.64
--- gtkshell/gtkshell.h 17 Aug 2010 19:17:24 -0000      1.63
+++ gtkshell/gtkshell.h 23 Aug 2010 18:13:42 -0000      1.64
@@ -48,7 +48,6 @@
 #include "macros.h"
 
 #include "row_struct.h"
-#include "terminal_struct.h"
 #include "updated.h"
 #include "update_manager_struct.h"
 
@@ -56,8 +55,10 @@
 
 #include "module_includes.h"
 
-void gsh_GSH (GSH * gsh);
+void 
+gsh_GSH (GSH * gsh);
 
-GSH *gsh_new_GSH ();
+GSH *
+gsh_new_GSH ();
 
 #endif /* ! GSH_GTKSHELL_H */

Index: gtkshell/macros.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/macros.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- gtkshell/macros.h   22 Aug 2010 18:56:32 -0000      1.25
+++ gtkshell/macros.h   23 Aug 2010 18:13:42 -0000      1.26
@@ -83,6 +83,19 @@
        $(gsh, manage, var);\
 }
 
+#define GET_STOCK_ITEM(item, ...)\
+  gtk_##item##_new_from_stock(__VA_ARGS__)
+
+#define SHOW_STOCK_ITEM(item, var, ...)\
+  gtk_widget_show(var=GET_STOCK_ITEM(item, __VA_ARGS__))
+
+#define ADD_STOCK_ITEM(item, cont, var, ...)\
+  SHOW_STOCK_ITEM(item, var, __VA_ARGS__);\
+  GSHCA(cont, var)
+
+#define ADD_STOCK_BUTTON(cont, var, ...)\
+  ADD_STOCK_ITEM(button, cont, var, __VA_ARGS__)
+
 #define GSHCONNECT(widget, signal, cb, cbdata)\
        g_signal_connect(G_OBJECT(widget), signal, G_CALLBACK(cb), cbdata);
 

Index: gtkshell/menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.c,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -b -r1.33 -r1.34
--- gtkshell/menu.c     17 Aug 2010 19:17:24 -0000      1.33
+++ gtkshell/menu.c     23 Aug 2010 18:13:42 -0000      1.34
@@ -50,9 +50,6 @@
   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
@@ -75,9 +72,6 @@
   GList *children;
 
   children = gtk_container_get_children (GTK_CONTAINER (label));
-#ifdef DEBUG
-  ARPASSERT (children);
-#endif /* DEBUG */
   g_list_foreach (children, set_submenu_label, (gchar *) label_text);
   g_list_free (children);
 }
@@ -140,19 +134,19 @@
 static void
 perform_addition_for_each_item (struct GSH *gsh, gchar ** tokens)
 {
-  guint i;
+  guint i=0;
   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++)
+  while(tokens[++i])  
     {
       const gchar *submenu_close = "<--";
 
       if (!strncmp (tokens[i], submenu_close, 3))
        {
-         if (submenu_count != 0)
+         if (submenu_count)
            gsh->rows->v = submenus[--submenu_count];
        }
       else

Index: gtkshell/terminal.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- gtkshell/terminal.c 22 Aug 2010 20:31:54 -0000      1.40
+++ gtkshell/terminal.c 23 Aug 2010 18:13:42 -0000      1.41
@@ -22,70 +22,49 @@
 
 #include "gtkshell.h"
 
-/* Uncomment to use experimental tabbed terminal.  */
-/*     # USE_TABS */
-#define USE_TABS
-
-#ifdef HAVE_VTE
 #include <vte/reaper.h>
-#define VSET(element, widget, ...)\
-       vte_terminal_set_##element(VTE_TERMINAL(widget), __VA_ARGS__)
-#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)
+set_terminal_options (GSHTerminal *term)
 {
   GSH *gsh;
-
-  gsh = term->gsh;
+  VteTerminal *widget = (VteTerminal *)term->widget;
+#define VSETW(element, ...)\
+       vte_terminal_set_##element(widget, __VA_ARGS__)
   VSETW (size, term->dimensions.width, term->dimensions.height);
   VSETW (allow_bold, TRUE);
   VSETW (backspace_binding, VTE_ERASE_ASCII_BACKSPACE);
+  gsh_widget_set_font(GTK_WIDGET(widget), term->font);
+  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");
+  const gchar *shell = g_getenv ("SHELL");
 
   return shell ? shell : (const gchar *) GSH_DEFAULT_SHELL;
 }
 
-#ifdef USE_TABS
 static void
 handle_child_exited (GtkWidget * widget, gpointer term)
 {
-  //struct GSH_Terminal *term = user_data;
+  //GSHTerminal *term = user_data;
   GtkNotebook *notebook 
-    = GTK_NOTEBOOK (((struct GSH_Terminal *)term)->__notebook);
+    = GTK_NOTEBOOK (((GSHTerminal *)term)->__notebook);
 
   gtk_notebook_remove_page (notebook,
                            gtk_notebook_page_num (notebook, widget));
 }
-#endif /* USE_TABS */
 
 static void
-gsh_terminal_run (struct GSH_Terminal *term, const gchar * command)
+gsh_terminal_run (GSHTerminal *term, const gchar * command)
 {
   /* Set up line and column counts so that VI has correct display
      in IDE terminal.  */
@@ -112,29 +91,21 @@
        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);
 
-#ifdef USE_TABS
   /* Handle terminal exit.  */
   GSHCONNECT(term->widget, "child-exited", handle_child_exited, term);
-/*  g_signal_connect (G_OBJECT (term->widget), "child-exited",
-                   handle_child_exited, term);*/
-#endif /* USE_TABS */
 }
 
 static void
-gsh_delete_GSH_Terminal (struct GSH_Terminal *term)
+gsh_delete_GSH_Terminal (GSHTerminal *term)
 {
-  if(term->__tab_command)
-    g_free(term->__tab_command);
   arfree (term);
   /* Freeing the terminal font causes a segmentation fault under
    * linux, so likely a double free.  */
@@ -142,105 +113,107 @@
    * reference counting.  */
 }
 
-#ifndef HAVE_VTE
-#define GSH_TERMINAL_TITLE "Terminal"
-#endif /* !HAVE_VTE */
-
 static void
-title_change_cb (GtkWidget * widget, gpointer data)
+info_changed_cb (GtkWidget * widget, gpointer data)
 {
-  struct GSHCBData *cb;
+  const gchar * status=vte_terminal_get_status_line(VTE_TERMINAL(widget));
+  gchar * title;
+  GtkWidget *statusbar;
   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 */
-                       GSH_TERMINAL_TITLE
-#endif /* HAVE_VTE */
-    );
+  gsh=data;
+  title=g_strdup(vte_terminal_get_window_title(VTE_TERMINAL(widget)));
+  if(status && (strnlen(status, 2)>1))
+    {
+      if ((statusbar = gsh->widgets.app.status))
+        {
+          gtk_statusbar_push (GTK_STATUSBAR (statusbar), 
+                              gtk_statusbar_get_context_id 
+                              ( GTK_STATUSBAR (statusbar), "terminal"), 
+                              status);
+        }
+      else
+        {
+          gchar *tmp=title;
+
+          title=g_strconcat(title, ": ", status, NULL);
+          g_free(tmp);
+        }
+    }
+  if(title)
+    gtk_window_set_title(GTK_WINDOW(gsh->widgets.window), title);
+  g_free(title);
 }
 
 static void
-status_changed_cb (GtkWidget * widget, gpointer data)
+setup_terminal_signals (GSHTerminal *term)
 {
-  struct GSHCBData *cb;
-  GSH *gsh;
-  GtkWidget *status;
+  GtkWidget *widget;
+  
+  if((widget = term->widget))
+    {
+      GSH *gsh=term->gsh;
 
-  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 */
-                       GSH_TERMINAL_TITLE
-#endif /* HAVE_VTE */
-      );
+      GSHCONNECT (widget, "status-line-changed", info_changed_cb, gsh);
+      GSHCONNECT (widget, "window-title-changed", info_changed_cb, gsh);
+    }
 }
 
-static void
-connect_terminal_signals_with_data (GSH * gsh, GtkWidget * widget)
+static GtkWidget *
+get_current_page(GtkNotebook *notebook)
 {
-  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);
+  return gtk_notebook_get_nth_page(notebook,
+                                   gtk_notebook_get_current_page(notebook));
 }
 
 static void
-setup_terminal_signals (struct GSH_Terminal *term)
+tab_button_close_cb (GtkWidget * button __attribute__ ((unused)), 
+                     gpointer data)
 {
-  GSH *gsh;
-  GtkWidget *widget;
+  GSHTerminal *term = data;
+  GtkNotebook *notebook = GTK_NOTEBOOK (term->__notebook);
+  gtk_widget_destroy(get_current_page(notebook));
+  info_changed_cb(get_current_page(notebook), term->gsh);
+}
 
-  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.  */
-#ifndef USE_TABS
-  GSHCONNECT (widget, "child-exited", gtk_main_quit, NULL);
-#endif /* USE_TABS */
-  connect_terminal_signals_with_data (gsh, widget);
+static void
+change_page_cb (GtkNotebook * notebook, 
+                gint arg1 __attribute__ ((unused)), 
+                gpointer user_data)
+{
+  GSHTerminal *term = (GSHTerminal *) user_data;
+  info_changed_cb(get_current_page(notebook), term->gsh);
 }
 
-#ifdef USE_TABS
+static void
+switch_page_cb (GtkNotebook *notebook __attribute__ ((unused)),
+                GtkWidget *page,
+                guint page_number __attribute__ ((unused)),
+                gpointer user_data)
+{
+  info_changed_cb(page, user_data);
+}
 
 static void
-tab_button_close_cb (GtkWidget * button __attribute__ ((unused)), 
+tab_button_callback (GtkWidget * button __attribute__ ((unused)), 
                      gpointer data)
 {
-  struct GSH_Terminal *term = data;
-  GtkNotebook *notebook = GTK_NOTEBOOK (term->__notebook);
-  const gint current_page=gtk_notebook_get_current_page(notebook);
-
-  gtk_widget_destroy(gtk_notebook_get_nth_page (notebook, current_page));
+  GSHTerminal *term = (GSHTerminal *)data;
+  $ (term, add, get_shell());
 }
 
 static void
-change_page_cb (GtkWidget * notebook, gpointer user_data)
+tab_next(GtkWidget * button __attribute__ ((unused)), 
+                     gpointer data)
 {
-  struct GSH_Terminal *term = (struct GSH_Terminal *) user_data;
-  term->__notebook_page =
-    gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
+  gtk_notebook_next_page(GTK_NOTEBOOK(((GSHTerminal *)data)->__notebook));
 }
 
 static void
-tab_button_callback (GtkWidget * button __attribute__ ((unused)), 
+tab_prev(GtkWidget * button __attribute__ ((unused)), 
                      gpointer data)
 {
-  struct GSH_Terminal *term = (struct GSH_Terminal *)data;
-  $ (term, add, getenv("SHELL"));
+  gtk_notebook_prev_page(GTK_NOTEBOOK(((GSHTerminal *)data)->__notebook));
 }
 
 static void
@@ -254,108 +227,101 @@
 }
 
 static void
-new_terminal_tab (struct GSH_Terminal *term, gchar * command)
+setup_action_widgets(GSHTerminal * term)
 {
   GtkNotebook *notebook = GTK_NOTEBOOK(term->__notebook);
-  GtkWidget *term_widget;
-  GtkWidget *label;
-  gint tab_id;
+  GtkWidget *button;
+  GtkWidget *row;
 
-  assert(command);
-  puts(command);
-  if((term->__tab_command))
-    g_free(term->__tab_command);
-  term->__tab_command=command;
+  /* setup container for navigation buttons */
+  GSH_SHOW_CREATE(row, toolbar);
 
-  GSH_SHOW_CREATE(label, label, command);
-  gtk_widget_show (term_widget = term->widget = vte_terminal_new ());
-  tab_id = term->__notebook_page
-    = gtk_notebook_append_page (notebook, term_widget, label);
+#define TAB_BUTTON(stock, cb)\
+  ADD_STOCK_BUTTON(row, button, stock);\
+  gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE);\
+  GSHCONNECT (button, "clicked", cb, term)
+
+  /* setup New button */
+  TAB_BUTTON(GTK_STOCK_NEW, tab_button_callback);
+
+  /* setup prev button */
+  TAB_BUTTON(GTK_STOCK_GO_BACK, tab_prev);
+
+  /* setup next button */
+  TAB_BUTTON(GTK_STOCK_GO_FORWARD, tab_next);
+
+  /* setup Close button */
+  TAB_BUTTON(GTK_STOCK_CLOSE, tab_button_close_cb);
+
+  /* add the row to the tab bar */
+  gtk_notebook_set_action_widget(notebook, row, GTK_PACK_END);
+}
+
+static void
+setup_notebook(GSHTerminal *term)
+{
+  GtkWidget *notebook;
+
+  gtk_widget_show (notebook = term->__notebook = gtk_notebook_new ());
+  setup_action_widgets(term);
   GSHCONNECT (notebook, "change-current-page", change_page_cb, term);
+  GSHCONNECT (notebook, "select-page", change_page_cb, term);
+  GSHCONNECT (notebook, "switch-page", switch_page_cb, term->gsh);
   GSHCONNECT (notebook, "page-removed", page_removed_cb, term);
-//  make_tab_label (term, command, hbox, tab_id);
-  if(!gtk_notebook_get_action_widget(notebook, GTK_PACK_START))
-    {
-      GtkWidget *new;
-      gtk_widget_show(new=gtk_button_new_from_stock("gtk-new"));
-      GSHCONNECT (new, "clicked", tab_button_callback, term);
-      gtk_notebook_set_action_widget(notebook, new, GTK_PACK_START);
-    }
-  if(!gtk_notebook_get_action_widget(notebook, GTK_PACK_END))
-    {
-      GtkWidget *close;
-      gtk_widget_show(close=gtk_button_new_from_stock("gtk-close"));
-      GSHCONNECT (close, "clicked", tab_button_close_cb, term);
-      gtk_notebook_set_action_widget(notebook, close, GTK_PACK_END);
-    }
-  gtk_notebook_set_current_page(notebook, tab_id);
+}
+
+static void
+new_terminal_tab (GSHTerminal *term, gchar * command)
+{
+  GtkNotebook *notebook = GTK_NOTEBOOK(term->__notebook);
+  GtkWidget *term_widget;
+
+  gtk_widget_show (term_widget = term->widget = vte_terminal_new ());
+  gtk_notebook_set_current_page(notebook, 
+                                gtk_notebook_append_page (notebook, 
+                                                          term_widget, 
+                                                          NULL));
+  gtk_notebook_set_tab_label_text(notebook, term_widget, command);
+  gtk_notebook_set_tab_reorderable(notebook, term_widget, TRUE);
+  gtk_notebook_set_tab_detachable(notebook, term_widget, TRUE);
   gtk_widget_grab_focus(term_widget);
 }
-#endif /* USE_TABS */
 
 static GtkWidget *
-gsh_GSH_Terminal_add (struct GSH_Terminal *term, const gchar * command)
+gsh_GSH_Terminal_add (GSHTerminal *term, const gchar * command)
 {
-#ifdef USE_TABS
-  gboolean original_tab = TRUE;
-#endif /* USE_TABS */
+  bool original_tab;
   /* Create and set properties of the VTE-based terminal.  */
-#ifdef HAVE_VTE
-#ifdef USE_TABS
-  if (!term->__notebook)
-    gtk_widget_show (term->__notebook = gtk_notebook_new ());
-  else
-    original_tab = FALSE;
+  if ((original_tab=!(term->__notebook)))
+    setup_notebook(term);
   new_terminal_tab (term, g_strdup(command));
-#else /* ! USE_TABS */
-  gtk_widget_show (term->widget = vte_terminal_new ());
-#endif /* USE_TABS */
-#else /* not HAVE_VTE */
-  term->widget = NULL;
-#endif /* HAVE_VTE */
   setup_terminal_signals (term);
   set_terminal_options (term);
   gsh_terminal_run (term, command);
-#ifdef USE_TABS
-  return original_tab ? term->__notebook : NULL;
-#else
-  return term->widget;
-#endif /* USE_TABS */
-}
 
-static void
-assign_methods (struct GSH_Terminal *term)
-{
-  term->delete = &gsh_delete_GSH_Terminal;
-  term->add = &gsh_GSH_Terminal_add;
+  return original_tab ? term->__notebook : NULL;
 }
 
 static void
-initialize_fields (struct GSH_Terminal *term)
+setup_GSH_Terminal (GSHTerminal *term)
 {
+  /* initialize fields */
   term->widget = NULL;
   term->font = NULL;
   term->dimensions.width = 80;
   term->dimensions.height = 24;
-#ifdef USE_TABS
   term->__notebook = NULL;
-  term->__tab_command = NULL;
-#endif /* USE_TABS */
-}
-
-static void
-setup_GSH_Terminal (struct GSH_Terminal *term)
-{
-  initialize_fields (term);
-  assign_methods (term);
+  /* assign methods */
+  term->delete = &gsh_delete_GSH_Terminal;
+  term->add = &gsh_GSH_Terminal_add;
 }
 
-struct GSH_Terminal *
+GSHTerminal *
 gsh_new_GSH_Terminal (GSH * gsh)
 {
-  struct GSH_Terminal *term;
+  GSHTerminal *term;
 
-  term = armalloc (sizeof (struct GSH_Terminal));
+  term = armalloc (sizeof (GSHTerminal));
   setup_GSH_Terminal (term);
   term->gsh = (gpointer) gsh;
 

Index: gtkshell/terminal.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- gtkshell/terminal.h 16 Aug 2010 11:51:22 -0000      1.9
+++ gtkshell/terminal.h 23 Aug 2010 18:13:42 -0000      1.10
@@ -23,8 +23,10 @@
 #ifndef GSH_TERMINAL_H
 #define GSH_TERMINAL_H
 
+#include "terminal_struct.h"
+
 #define GSH_DEFAULT_SHELL "/bin/sh"
 
-struct GSH_Terminal *gsh_new_GSH_Terminal (GSH * gsh);
+GSHTerminal *gsh_new_GSH_Terminal (GSH * gsh);
 
 #endif

Index: gtkshell/terminal_struct.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal_struct.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- gtkshell/terminal_struct.h  22 Aug 2010 18:56:33 -0000      1.15
+++ gtkshell/terminal_struct.h  23 Aug 2010 18:13:42 -0000      1.16
@@ -22,23 +22,19 @@
 
 #ifndef GSH_TERMINAL_STRUCT_H
 #define GSH_TERMINAL_STRUCT_H
-#define USE_TABS
-struct GSH_Terminal
+
+struct GSHTerminal
 {
   GtkWidget *widget;
   gchar *font;
   struct ARArguments *scripts;
   ARDimensions dimensions;
-  void (*delete) (struct GSH_Terminal *);
-  GtkWidget *(*add) (struct GSH_Terminal *, const gchar *);
+  void (*delete) (struct GSHTerminal *);
+  GtkWidget *(*add) (struct GSHTerminal *, const gchar *);
   gpointer gsh;
-#ifdef USE_TABS
   GtkWidget *__notebook;
-  gchar *__tab_command;
-  gint __notebook_page;
-#endif                         /* USE_TABS */
 };
 
-struct GSH_Terminal *gsh_new_GSH_Terminal ();
+typedef struct GSHTerminal GSHTerminal;
 
 #endif /* not GSH_TERMINAL_STRUCT_H */

Index: libantiright/pipe.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/pipe.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -b -r1.15 -r1.16
--- libantiright/pipe.c 22 Aug 2010 18:56:33 -0000      1.15
+++ libantiright/pipe.c 23 Aug 2010 18:13:42 -0000      1.16
@@ -40,7 +40,6 @@
        {
                total += read;
                text = (gchar *) g_realloc(text, total*sizeof(gchar));
-               ARPASSERT(text);
                g_strlcat(text, buffer, total);
        }
 

Index: libantiright/system.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/system.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -b -r1.12 -r1.13
--- libantiright/system.c       17 Aug 2010 12:57:13 -0000      1.12
+++ libantiright/system.c       23 Aug 2010 18:13:42 -0000      1.13
@@ -1,6 +1,6 @@
 /*
   AntiRight
-  (c) 2002-2007 Jeffrey Bedard
+  (c) 2002-2010 Jeffrey Bedard
   address@hidden
 
   This file is part of AntiRight.

Index: rootcat/Makefile
===================================================================
RCS file: /sources/antiright/antiright/rootcat/Makefile,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- rootcat/Makefile    22 Aug 2010 18:56:33 -0000      1.6
+++ rootcat/Makefile    23 Aug 2010 18:13:43 -0000      1.7
@@ -34,8 +34,8 @@
 
 LDFLAGS=-L/usr/pkg/lib -L/usr/X11R6/lib -lX11 -lXft -lXext
 CFLAGS+=$(INCLUDES)
-CFLAGS+=-g3
-objs=rootcat.o StringRenderer.o
+#CFLAGS+=-g3
+objs=$(patsubst %.c,%.o,$(wildcard *.c)) 
 
 all: $(PROG)
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]