[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Antiright-devel] antiright ACE-desktop/guidl/Editor.gdl gtkshell...
From: |
Jeffrey Bedard |
Subject: |
[Antiright-devel] antiright ACE-desktop/guidl/Editor.gdl gtkshell... |
Date: |
Wed, 23 May 2007 14:57:46 +0000 |
CVSROOT: /sources/antiright
Module name: antiright
Changes by: Jeffrey Bedard <jefbed> 07/05/23 14:57:46
Modified files:
ACE-desktop/guidl: Editor.gdl
gtkshell : gtkshell.c gtkshell.h menu.c terminal.c text.c
Log message:
Added recent file switcher feature for editors with view menu defined.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/antiright/ACE-desktop/guidl/Editor.gdl?cvsroot=antiright&r1=1.1&r2=1.2
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.c?cvsroot=antiright&r1=1.41&r2=1.42
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/gtkshell.h?cvsroot=antiright&r1=1.50&r2=1.51
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/menu.c?cvsroot=antiright&r1=1.20&r2=1.21
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/terminal.c?cvsroot=antiright&r1=1.23&r2=1.24
http://cvs.savannah.gnu.org/viewcvs/antiright/gtkshell/text.c?cvsroot=antiright&r1=1.31&r2=1.32
Patches:
Index: ACE-desktop/guidl/Editor.gdl
===================================================================
RCS file: /sources/antiright/antiright/ACE-desktop/guidl/Editor.gdl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- ACE-desktop/guidl/Editor.gdl 19 May 2007 05:07:19 -0000 1.1
+++ ACE-desktop/guidl/Editor.gdl 23 May 2007 14:57:46 -0000 1.2
@@ -6,8 +6,10 @@
option "title" "Editor";
option "icon size" "menu";
-add button
"File::Open...___,gtk-open::Save___,gtk-save::Save_As...___,gtk-save-as::Exit___,gtk-quit";
+add button "File::Open...___,gtk-open::Save___,gtk-save::\n
+ ::Save_As...___,gtk-save-as::Exit___,gtk-quit";
add button "Edit::Cut___,gtk-cut::Copy___,gtk-copy::Paste___,gtk-paste";
+add button "View::---";
add button "Help::gtkshell -da # About,gtk-about";
add "text";
Index: gtkshell/gtkshell.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.c,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -b -r1.41 -r1.42
--- gtkshell/gtkshell.c 15 May 2007 17:59:34 -0000 1.41
+++ gtkshell/gtkshell.c 23 May 2007 14:57:46 -0000 1.42
@@ -66,13 +66,26 @@
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)
{
-#define GWA gsh->widgets.app
GWA.menubar=NULL;
+ setup_app_menus(gsh);
GWA.frame=NULL;
+ GWA.status=NULL;
}
static void
Index: gtkshell/gtkshell.h
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/gtkshell.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -b -r1.50 -r1.51
--- gtkshell/gtkshell.h 20 May 2007 18:29:58 -0000 1.50
+++ gtkshell/gtkshell.h 23 May 2007 14:57:46 -0000 1.51
@@ -69,6 +69,14 @@
GtkWidget * last_managed;
struct /* app mode */
{
+ struct
+ {
+ GtkWidget * file;
+ GtkWidget * edit;
+ GtkWidget * tools;
+ GtkWidget * view;
+ GtkWidget * help;
+ } menus;
GtkWidget * menubar;
GtkWidget * toolbar;
GtkWidget * status;
Index: gtkshell/menu.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/menu.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -b -r1.20 -r1.21
--- gtkshell/menu.c 20 May 2007 01:04:43 -0000 1.20
+++ gtkshell/menu.c 23 May 2007 14:57:46 -0000 1.21
@@ -26,6 +26,15 @@
#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
menuitem_parse(struct GSH * gsh, gchar * string)
{
gchar **pair;
@@ -40,13 +49,7 @@
{
/* Test if a separator should be created. */
if(!strncmp(pair[0], "---", 3))
- {
- GtkWidget * separator;
-
- GSH_SHOW_CREATE(separator, separator_menu_item);
- gtk_menu_shell_append(GTK_MENU_SHELL(gsh->rows->v),
- separator);
- }
+ setup_separator_menu_item(gsh);
/* String does not contain \n. */
else if(strncmp(pair[0], "\\n", 2))
{ /* Support continuation lines for menu specification. */
@@ -68,6 +71,29 @@
}
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)
{
@@ -79,26 +105,7 @@
gtk_menu_item_set_submenu(GTK_MENU_ITEM(
gsh->widgets.button), gsh->rows->v);
label=gtk_bin_get_child(GTK_BIN(gsh->widgets.button));
- (*i)++;
- {
- gchar * label_text;
-
- label_text = antiright_beautified_label(tokens[*i]);
- if(GTK_IS_LABEL(label))
- set_submenu_label(label, label_text);
- else
- {
- GList * children;
-
- children=gtk_container_get_children(
- GTK_CONTAINER(label));
- g_list_foreach(children, set_submenu_label,
- label_text);
- g_list_free(children);
-
- }
- g_free(label_text);
- }
+ find_and_set_label_widget(label, tokens[++(*i)]);
}
static void
@@ -173,8 +180,25 @@
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, gchar * label)
+add_menu_launcher(struct GSH * gsh, const gchar * label)
{
const GtkWidget * old_row = gsh->rows->v;
GtkWidget * menu_item;
@@ -192,11 +216,14 @@
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,
- tokens[0])), menu);
+ label)), menu);
add_menu_items(gsh, menu, tokens);
+ test_for_main_app_menus(gsh, menu, label);
}
Index: gtkshell/terminal.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/terminal.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -b -r1.23 -r1.24
--- gtkshell/terminal.c 17 May 2007 16:04:35 -0000 1.23
+++ gtkshell/terminal.c 23 May 2007 14:57:46 -0000 1.24
@@ -61,6 +61,18 @@
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)
{
@@ -75,12 +87,11 @@
/* Null terminated list of environment elements. */
const gchar *envv[] = {height, width, NULL};
/* Determine which shell to use. */
- const gchar * shell = getenv("SHELL");
+ 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,
Index: gtkshell/text.c
===================================================================
RCS file: /sources/antiright/antiright/gtkshell/text.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -b -r1.31 -r1.32
--- gtkshell/text.c 19 May 2007 03:29:09 -0000 1.31
+++ gtkshell/text.c 23 May 2007 14:57:46 -0000 1.32
@@ -202,6 +202,47 @@
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)
{
@@ -209,11 +250,8 @@
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);
+ open_gsh_file_in_editor(gsh);
+ add_to_recent_files(gsh, gsh->editor.filename);
}
}
- [Antiright-devel] antiright ACE-desktop/guidl/Editor.gdl gtkshell...,
Jeffrey Bedard <=