antiright-devel
[Top][All Lists]
Advanced

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

[Antiright-devel] antiright gshterm/Makefile gshterm/main.c gtksh...


From: Jeffrey Bedard
Subject: [Antiright-devel] antiright gshterm/Makefile gshterm/main.c gtksh...
Date: Fri, 16 Feb 2007 22:18:01 +0000

CVSROOT:        /sources/antiright
Module name:    antiright
Changes by:     Jeffrey Bedard <jefbed> 07/02/16 22:18:01

Modified files:
        gshterm        : Makefile main.c 
        gtkshell       : button.c gtkshell.c gtkshell.h main.c row.c 
Removed files:
        gshterm        : exit.c exit.h 

Log message:
        Fixed row layout bug in gtkshell.  Added file unlinking to
        gshterm main method and used gtk_main_quit for the terminal
        client exit callback, removing exit.[ch] functions.  Fixed
        memory leaks by recursively deleting application structures 
        before gtk_main.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/Makefile?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/main.c?cvsroot=antiright&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/exit.c?cvsroot=antiright&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/antiright/gshterm/exit.h?cvsroot=antiright&r1=1.1&r2=0
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.3&r2=1.4
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/main.c?cvsroot=antiright&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/row.c?cvsroot=antiright&r1=1.3&r2=1.4

Patches:
Index: gshterm/Makefile
===================================================================
RCS file: /sources/antiright/antiright/gshterm/Makefile,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gshterm/Makefile    10 Feb 2007 18:54:06 -0000      1.5
+++ gshterm/Makefile    16 Feb 2007 22:18:01 -0000      1.6
@@ -7,7 +7,7 @@
 LDFLAGS+=`pkg-config --libs gtk+-2.0` -lgtkshell -lantiright
 LDFLAGS+=`pkg-config --libs vte`
 
-objects=main.o gshterm.o command_line.o script.o exit.o
+objects=main.o gshterm.o command_line.o script.o 
 all: $(objects) 
        $(CC) -o gshterm $(objects) $(LDFLAGS)
 

Index: gshterm/main.c
===================================================================
RCS file: /sources/antiright/antiright/gshterm/main.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gshterm/main.c      13 Feb 2007 03:23:28 -0000      1.5
+++ gshterm/main.c      16 Feb 2007 22:18:01 -0000      1.6
@@ -21,6 +21,7 @@
 */
 
 #include "gshterm.h"
+#include <unistd.h>
 
 
 struct GSHTerm *
@@ -48,25 +49,32 @@
 main(int argc, char **argv)
 {
        struct GSHTerm *term;
+       gpointer script;
 
        /* Initialize GTK, GSH, and GSHTerm.  */
        term=gshterm_init_and_script(&argc, &argv);
        term->widget=gshterm_setup_terminal(term);
        gsh_check_and_set_geometry(term->gsh);
        g_signal_connect(G_OBJECT(term->widget), "child-exited",
-               G_CALLBACK(gshterm_exit_cb), term->script);
-
-       /* SCRIPT_NAME is left allocated as it is needed
-          by the exit callback.  */
+               G_CALLBACK(gtk_main_quit), NULL);
 
+       /* Run the script in the terminal widget.  */
        vte_terminal_fork_command(
                VTE_TERMINAL(term->widget), term->script, NULL, NULL, NULL,
                TRUE, TRUE, TRUE);
 
+       script=term->script;
+
        gtk_widget_show(term->gsh->window);
 
+       g_free(term->gsh);
+       g_free(term);
+
        gtk_main();
 
+       unlink(script);
+       g_free(script);
+
        return(0);
 }
 

Index: gtkshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gtkshell/button.c   13 Feb 2007 03:23:28 -0000      1.3
+++ gtkshell/button.c   16 Feb 2007 22:18:01 -0000      1.4
@@ -29,16 +29,24 @@
 {
  char           *label_text;
  struct GSH_CBData *cb;
+
+       /* Allocate and initialize elements.  */
  cb=(struct GSH_CBData *)xmalloc(sizeof(struct GSH_CBData));
  cb->gsh=gsh;
- /* Try to do without allocation.  */
+
  asprintf((char **)&cb->data, "%s", command);
  label_text = antiright_beautified_label(command);
  gsh->button = gtk_button_new_with_label(label_text);
  free(label_text);
+
  g_signal_connect(G_OBJECT(gsh->button), "clicked",
                  G_CALLBACK(system_cb), cb);
+
  gsh_manage(gsh, gsh->button);
+
+#ifdef DEBUG
+       g_print("row: %d out of %d rows\n", gsh->rows.row, gsh->rows.rows);
+#endif /* DEBUG */
 }
 
 void

Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gtkshell/gtkshell.c 13 Feb 2007 03:23:28 -0000      1.6
+++ gtkshell/gtkshell.c 16 Feb 2007 22:18:01 -0000      1.7
@@ -46,7 +46,7 @@
 void
 gsh_GSH_Rows(struct GSH_Rows *rows)
 {
-       rows->row=1;
+       /* rows->row is initialized by gsh_manage.  */
        rows->rows=8;
 }
 void
@@ -72,10 +72,16 @@
 {
        struct GSH *gsh;
 
-       gtk_init(argc, argv);
        gsh=gsh_new_GSH();
-       gsh->window=gsh_create_main_window();
+       gsh_stack_init(gsh, argc, argv);
 
        return gsh;
 }
+void
+gsh_stack_init(struct GSH *gsh, int *argc, char ***argv)
+{
+       gtk_init(argc, argv);
+       gsh_GSH(gsh);
+       gsh->window=gsh_create_main_window();
+}
 

Index: gtkshell/gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gtkshell/gtkshell.h 13 Feb 2007 03:23:28 -0000      1.6
+++ gtkshell/gtkshell.h 16 Feb 2007 22:18:01 -0000      1.7
@@ -71,6 +71,8 @@
 #include "containers.h"
 #include "geometry.h"
 
+void
+gsh_stack_init(struct GSH *gsh, int *argc, char ***argv);
 
 struct GSH *
 gsh_init(int *argc, char ***argv);

Index: gtkshell/main.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/main.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- gtkshell/main.c     12 Feb 2007 16:36:56 -0000      1.4
+++ gtkshell/main.c     16 Feb 2007 22:18:01 -0000      1.5
@@ -29,11 +29,11 @@
 
        gsh=gsh_init(&argc, &argv);
 
-       if(((argc > 1) && (strlen(argv[1]) == 3)) 
+       gsh->flags.dont_scroll= 
+               (((argc > 1) 
+               && (strlen(argv[1]) == 3)) 
                && !strncmp(argv[1], "-os", 3))
-        gsh->flags.dont_scroll=TRUE;
-    else
-        gsh->flags.dont_scroll=FALSE;
+               ? TRUE : FALSE;
 
        gsh_setup_containers(gsh);
        gsh_parse_arguments(gsh, argc, argv);
@@ -42,6 +42,9 @@
 
        gtk_widget_show(gsh->window);
        
+       /* Free object references and initialization variables */
+       g_free(gsh); 
+
        gtk_main();
 
        return (0);

Index: gtkshell/row.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/row.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -b -r1.3 -r1.4
--- gtkshell/row.c      13 Feb 2007 03:23:28 -0000      1.3
+++ gtkshell/row.c      16 Feb 2007 22:18:01 -0000      1.4
@@ -26,12 +26,14 @@
 gsh_manage(struct GSH *gsh, GtkWidget *widget)
 {
  gsh_check_row(gsh);
- gtk_container_add(GTK_CONTAINER(gsh->rows.h), widget);
+ gtk_container_add(GTK_CONTAINER(gsh->rows.v), widget);
  gtk_widget_show(widget);
  gsh->rows.row++;
+
 #ifdef DEBUG
- printf("gsh_row: %d, gsh_rows: %d\n", gsh->rows.row, gsh->rows.rows);
+ g_print("gsh_row: %d, gsh_rows: %d\n", gsh->rows.row, gsh->rows.rows);
 #endif
+
 }
 
 
@@ -41,18 +43,24 @@
  gsh->rows.v = gtk_vbox_new(FALSE, 2);
  gtk_container_add(GTK_CONTAINER(gsh->rows.h), gsh->rows.v);
  gtk_widget_show(gsh->rows.v);
- gsh->rows.row = 1;
+ gsh->rows.row = 0;
 }
 
 void
 gsh_check_row(struct GSH *gsh)
 {
+
 #ifdef DEBUG
  printf("==> gsh_row: %d, gsh_rows: %d\n", gsh->rows.row, gsh->rows.rows);
 #endif
 
- if(gsh->rows.row > gsh->rows.rows)
+ if(gsh->rows.row == gsh->rows.rows)
  {
+
+#ifdef DEBUG 
+       g_print("new row");
+#endif
+
   gsh_new_row(gsh);
  }
 }

Index: gshterm/exit.c
===================================================================
RCS file: gshterm/exit.c
diff -N gshterm/exit.c
--- gshterm/exit.c      9 Feb 2007 16:10:42 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,44 +0,0 @@
-/*
-  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 "gshterm.h"
-
-void
-gshterm_delete_tmp(gpointer data)
-{
-       char *sys_command;
-
-       asprintf(&sys_command, "rm -f %s", (char*)data);
-       system(sys_command);
-       free(sys_command);
-}
-
-void
-gshterm_exit_cb(GtkWidget *widget, gpointer data)
-{
-       UNUSED(widget);
-
-       gshterm_delete_tmp(data);
-       exit(0);
-}
-
-

Index: gshterm/exit.h
===================================================================
RCS file: gshterm/exit.h
diff -N gshterm/exit.h
--- gshterm/exit.h      9 Feb 2007 16:10:42 -0000       1.1
+++ /dev/null   1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-/*
-  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 GHSTERM_EXIT_H
-#define GSHTERM_EXIT_H
-
-void
-gshterm_exit_cb(GtkWidget *widget, gpointer data);
-
-#endif /* GSHTERM_EXIT_H */
-




reply via email to

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