[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright gtkshell/button.c gtkshell/command_sh...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright gtkshell/button.c gtkshell/command_sh... |
Date: |
Thu, 17 May 2007 04:32:21 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/05/17 04:32:21
Modified files:
gtkshell : button.c command_shell.c macros.h terminal.c
terminal_struct.h text.c
libantiright : pipe.c
Log message:
Text editor functionality added to app mode text area.
Better reporting for pipe read performed.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/button.c?cvsroot=antiright&r1=1.44&r2=1.45
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/command_shell.c?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/macros.h?cvsroot=antiright&r1=1.11&r2=1.12
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal.c?cvsroot=antiright&r1=1.21&r2=1.22
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal_struct.h?cvsroot=antiright&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.c?cvsroot=antiright&r1=1.29&r2=1.30
http://cvs.savannah.gnu.org/viewcvs/antiright/libantiright/pipe.c?cvsroot=antiright&r1=1.10&r2=1.11
Patches:
Index: gtkshell/button.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/button.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -b -r1.44 -r1.45
--- gtkshell/button.c 16 May 2007 20:39:44 -0000 1.44
+++ gtkshell/button.c 17 May 2007 04:32:20 -0000 1.45
@@ -196,14 +196,22 @@
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)
+gsh_button(struct GSH * gsh, const gchar * string)
{
+ GtkWidget * button;
+
if(!test_image_button(gsh, string))
gsh_command_button(gsh, string);
return 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)
+{
+ return gsh->widgets.button=gsh_button(gsh, string);
+}
+
Index: gtkshell/command_shell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/command_shell.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- gtkshell/command_shell.c 16 May 2007 20:39:44 -0000 1.1
+++ gtkshell/command_shell.c 17 May 2007 04:32:20 -0000 1.2
@@ -99,7 +99,6 @@
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);
Index: gtkshell/macros.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/macros.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -b -r1.11 -r1.12
--- gtkshell/macros.h 15 May 2007 17:59:35 -0000 1.11
+++ gtkshell/macros.h 17 May 2007 04:32:20 -0000 1.12
@@ -23,19 +23,22 @@
#ifndef GSH_MACROS_H
#define GSH_MACROS_H
+#define GSHBIT(n) 1 << (n-1)
+
#define GSH_NONE 0
-#define GSH_SCROLL 1
-#define GSH_CBEXIT 2
-#define GSH_UPDATING 4
-#define GSH_HORIZONTAL_LABELS 8
-#define GSH_PROMPT_ECHOES 16
-#define GSH_FRAMED_LABELS 32
-#define GSH_MENU_BUTTON 64
-#define GSH_NO_BASE_FRAME 128
-#define GSH_NO_EXPAND 256
-#define GSH_GUIDL_NO_DUMMY 512
-#define GSH_APP_MODE 1024
-#define GSH_PANE_NEXT 2048
+#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)
typedef guint Bitmask;
#define GSH_FLAG(flag) ((gsh->bflags & flag) == flag)
Index: gtkshell/terminal.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -b -r1.21 -r1.22
--- gtkshell/terminal.c 16 May 2007 20:39:45 -0000 1.21
+++ gtkshell/terminal.c 17 May 2007 04:32:20 -0000 1.22
@@ -37,7 +37,13 @@
VSETW(size, term->dimensions.width, term->dimensions.height);
VSETW(allow_bold, TRUE);
VSETW(backspace_binding, VTE_ERASE_ASCII_BACKSPACE);
+ if(term->transparent)
+ {
+ /* Only the first terminal should be transparent,
+ to save memory. */
VSETW(background_transparent, TRUE);
+ term->transparent=FALSE;
+ }
}
static void
@@ -162,6 +168,7 @@
term->font=NULL;
term->dimensions.width=80;
term->dimensions.height=24;
+ term->transparent=TRUE;
}
static void
Index: gtkshell/terminal_struct.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal_struct.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- gtkshell/terminal_struct.h 15 May 2007 17:59:35 -0000 1.7
+++ gtkshell/terminal_struct.h 17 May 2007 04:32:20 -0000 1.8
@@ -29,6 +29,7 @@
gchar * font;
struct ARArguments * scripts;
ARDimensions dimensions;
+ gboolean transparent;
void (*delete)(struct GSH_Terminal *);
GtkWidget * (*add)(struct GSH_Terminal *, const gchar *);
gpointer gsh;
Index: gtkshell/text.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -b -r1.29 -r1.30
--- gtkshell/text.c 14 May 2007 12:16:12 -0000 1.29
+++ gtkshell/text.c 17 May 2007 04:32:20 -0000 1.30
@@ -88,6 +88,17 @@
}
+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)
{
@@ -96,8 +107,9 @@
#ifdef DEBUG
ARPASSERT(gsh);
#endif /* DEBUG */
- $(gsh, manage, gsh->editor.widget=text=gtk_text_view_new());
+ gtk_widget_show(text=gsh->editor.widget=gtk_text_view_new());
SET_OPTIONS(text);
+ setup_text_scroller(gsh, text);
return text;
}
@@ -131,11 +143,23 @@
CHECK_GEOMETRY(gsh);
}
-/* Check that the editor widget has been initialized. */
+/* Test for a text editor widget. */
#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)
@@ -146,7 +170,9 @@
{
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);
@@ -164,24 +190,31 @@
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);
}
void
gsh_editor_open(struct GSH * gsh)
{
- gchar * text;
-
TEST_EDITOR_EXISTS(gsh);
get_filename(gsh);
+ if(FILENAME_NOT_EMPTY)
+ {
+ gchar * text;
+
text=antiright_read_named_file(gsh->editor.filename);
GSH_TEXT_AREA_SET_TEXT(gsh->editor.widget, text);
g_free(text);
+ }
}
Index: libantiright/pipe.c
===================================================================
RCS file: /sources/antiright/antiright/libantiright/pipe.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -b -r1.10 -r1.11
--- libantiright/pipe.c 28 Apr 2007 22:26:23 -0000 1.10
+++ libantiright/pipe.c 17 May 2007 04:32:20 -0000 1.11
@@ -51,7 +51,8 @@
FILE * file;
gchar * contents;
- file=fopen(filename, "r");
+
+ file=fopen(filename, "a+");
contents=antiright_read_file(file);
fclose(file);
@@ -76,11 +77,31 @@
/* Execute the command indicated by command_string. */
/* Pipe is read-only. Stdout will be directed to it. */
pipe = popen(command_string, "r");
+#ifdef DEBUG
ARPASSERT(pipe);
+#endif /* DEBUG */
text=antiright_read_file(pipe);
/* Close the pipe once fgets() returns a false condition. */
- (void) pclose(pipe);
-
+ if(pclose(pipe) == -1)
+ {
+ const gchar * warning;
+
+ warning="command was not successful";
+ if(text)
+ {
+ gchar * erred_text;
+
+ ar_asprintf(&erred_text, "%s\n%s", text, warning);
+ g_free(text);
+ text=erred_text;
+ }
+ else
+ {
+ /* TEXT is NULL */
+ ARWARN(warning);
+ return g_strdup(warning);
+ }
+ }
return (text);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Antiright-devel] antiright gtkshell/button.c gtkshell/command_sh...,
Jeffrey Bedard <=