terminal patch
- From: Jeroen Zwartepoorte <jeroen xs4all nl>
- To: dave ximian com
- Cc: gnome-devtools gnome org
- Subject: terminal patch
- Date: 08 Aug 2002 12:28:26 +0200
Hi Dave,
Here's a preliminary patch for the terminal plugin in anjuta2. It
contains the following changes:
- Uses the vte widget instead of the zvt if available. If it's not
available (no pkgconfig file for vte), the terminal plugin simply won't
be built. This is done primarily because limbo (rh8.0 beta) doesn't even
contain libzvt anymore and vte is scheduled to be the default terminal
widget for GNOME 2.2 anyway. It requires vte > 0.7.0 because of a bug in
earlier versions.
- Uses GConf keys from gnome-terminal to set the font, fore- and
background color and behavior.
- Implements the "New Terminal" menuitem, so more than 1 terminal can
now be created. This part is not completely finished yet.
I do have a question about the last item. Adding terminals works good
(except for some layout issues, may be my fault, may be a problem with
GdlDock), but removing a terminal doesn't work yet.
According to the exit_action gnome-terminal gconf key, i can either
destroy the terminal or restart it. Restarting already works. Exiting
doesn't. I tried to simply do a g_object_unref on the vte widget, but
that doesn't work. Next i looked for a anjuta_shell_remove_control
method, but that doesn't exist.
What's the correct way to programmatically remove a control?
Thanks,
Jeroen
? .tm_project.cache
? anjuta2.schemas
? autom4te-2.53.cache
? stamp-h1
? terminal.patch
? libanjuta/anjuta-marshal.c
? libanjuta/anjuta-marshal.h
? libanjuta/libanjuta-1.0.pc
? plugins/terminal/Makefile
? plugins/terminal/Makefile.in
? plugins/terminal/anjuta-terminal.server
Index: ChangeLog
===================================================================
RCS file: /cvs/gnome/anjuta2/ChangeLog,v
retrieving revision 1.221
diff -u -r1.221 ChangeLog
--- ChangeLog 14 Jul 2002 17:08:36 -0000 1.221
+++ ChangeLog 8 Aug 2002 10:26:04 -0000
@@ -1,3 +1,13 @@
+2002-08-08 Jeroen Zwartepoorte <jeroen xs4all nl>
+
+ * configure.in: Built terminal plugin only if vte is available.
+ * plugins/Makefile.am: Idem.
+ * plugins/terminal/Makefile.am: Use VTE_CFLAGS/LIBS.
+ * plugins/terminal/terminal-tool.c: (new_terminal), (term_init_cb),
+ (term_exited_cb), (term_destroy_cb), (term_new), (shell_set): Uses vte
+ now instead of zvt. Uses gnome-terminal gconf keys for font, colors and
+ behavior. Implemented creation of more than 1 terminal.
+
2002-07-14 Jeroen Zwartepoorte <jeroen xs4all nl>
* plugins/document-manager/anjuta-document-manager.c:
Index: configure.in
===================================================================
RCS file: /cvs/gnome/anjuta2/configure.in,v
retrieving revision 1.78
diff -u -r1.78 configure.in
--- configure.in 26 Jun 2002 16:25:27 -0000 1.78
+++ configure.in 8 Aug 2002 10:26:04 -0000
@@ -33,7 +33,7 @@
GNOME_VFS_REQUIRED=1.9.4
LIBXML_REQUIRED=2.4.12
LIBGTKHTML2_REQUIRED=1.99.2
-LIBZVT_REQUIRED=2.0.0
+VTE_REQUIRED=0.7.0
AC_SUBST(GTK_REQUIRED)
AC_SUBST(LIBGNOME_REQUIRED)
@@ -46,7 +46,7 @@
AC_SUBST(GNOME_VFS_REQUIRED)
AC_SUBST(LIBXML_REQUIRED)
AC_SUBST(LIBGTKHTML2_REQUIRED)
-AC_SUBST(LIBZVT_REQUIRED)
+AC_SUBST(VTE_REQUIRED)
dnl ==========================================================================
@@ -54,7 +54,9 @@
PKG_CHECK_MODULES(ANJUTA, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gdl-1.0 >= $GDL_REQUIRED libbonobo-2.0 >= $LIBBONOBO_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libxml-2.0 >= $LIBXML_REQUIRED)
-PKG_CHECK_MODULES(COMPONENT, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gdl-1.0 >= $GDL_REQUIRED libbonobo-2.0 >= $LIBBONOBO_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED gnome-build-1.0 >= $GNOME_BUILD_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libgtkhtml-2.0 >= $LIBGTKHTML2_REQUIRED libzvt-2.0 >= $LIBZVT_REQUIRED)
+PKG_CHECK_MODULES(COMPONENT, libgnome-2.0 >= $LIBGNOME_REQUIRED libgnomeui-2.0 >= $LIBGNOMEUI_REQUIRED gdl-1.0 >= $GDL_REQUIRED libbonobo-2.0 >= $LIBBONOBO_REQUIRED libbonoboui-2.0 >= $LIBBONOBOUI_REQUIRED libgnomecanvas-2.0 >= $LIBGNOMECANVAS_REQUIRED gnome-build-1.0 >= $GNOME_BUILD_REQUIRED gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED libgtkhtml-2.0 >= $LIBGTKHTML2_REQUIRED)
+
+PKG_CHECK_MODULES(VTE, vte >= $VTE_REQUIRED, ENABLE_VTE="yes", ENABLE_VTE="no")
AC_SUBST(ANJUTA_CFLAGS)
AC_SUBST(ANJUTA_LIBS)
@@ -62,6 +64,14 @@
AC_SUBST(LIBANJUTA_LIBS)
AC_SUBST(COMPONENT_CFLAGS)
AC_SUBST(COMPONENT_LIBS)
+AC_SUBST(VTE_CFLAGS)
+AC_SUBST(VTE_LIBS)
+
+if test "x$ENABLE_VTE" = "xno"; then
+ AC_MSG_WARN(not building terminal plugin)
+fi
+
+AM_CONDITIONAL(ENABLE_TERMINAL, test "x$ENABLE_VTE" = "xyes")
# Devhelp idl
AC_MSG_CHECKING([for Devhelp IDL])
Index: plugins/Makefile.am
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/Makefile.am,v
retrieving revision 1.26
diff -u -r1.26 Makefile.am
--- plugins/Makefile.am 26 Jun 2002 16:25:28 -0000 1.26
+++ plugins/Makefile.am 8 Aug 2002 10:26:04 -0000
@@ -4,6 +4,12 @@
DEVHELP=
endif
+if ENABLE_TERMINAL
+TERMINAL=terminal
+else
+TERMINAL=
+endif
+
#if ENABLE_EVOLUTION
# Until a new evolution is released, this shouldn't be compiled.
#MAIL=evo-mail
@@ -20,7 +26,7 @@
shell-output \
symbol-browser \
text \
- terminal
+ $(TERMINAL)
XXX = debugger asciitable \
calculator docstat files functions
Index: plugins/terminal/Makefile.am
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/terminal/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- plugins/terminal/Makefile.am 26 Jun 2002 16:25:28 -0000 1.1
+++ plugins/terminal/Makefile.am 8 Aug 2002 10:26:05 -0000
@@ -3,6 +3,7 @@
-DGNOMELOCALEDIR=\""$(datadir)/locale"\"\
-DANJUTA_DATADIR=\""$(datadir)"\" \
$(COMPONENT_CFLAGS) \
+ $(VTE_CFLAGS) \
$(WARN_FLAGS)
anjuta2_plugindir = $(anjuta2_plugin_dir)
@@ -14,7 +15,8 @@
terminal-tool.c
libanjuta_terminal_la_LIBADD = \
- $(COMPONENT_LIBS)
+ $(COMPONENT_LIBS) \
+ $(VTE_LIBS)
server_in_files = anjuta-terminal.server.in
Index: plugins/terminal/terminal-tool.c
===================================================================
RCS file: /cvs/gnome/anjuta2/plugins/terminal/terminal-tool.c,v
retrieving revision 1.1
diff -u -r1.1 terminal-tool.c
--- plugins/terminal/terminal-tool.c 26 Jun 2002 16:25:28 -0000 1.1
+++ plugins/terminal/terminal-tool.c 8 Aug 2002 10:26:05 -0000
@@ -20,12 +20,29 @@
#include <config.h>
#include <pwd.h>
#include <bonobo.h>
+#include <gconf/gconf-client.h>
#include <libanjuta/anjuta-tool.h>
#include <libanjuta/glue-plugin.h>
-#include <libzvt/libzvt.h>
+#include <vte/vte.h>
-#define ZVT_FONT "-adobe-courier-medium-r-normal-*-*-120-*-*-m-*-iso8859-1"
-#define ZVT_SCROLLSIZE 200
+/* Number of terminals created. */
+#define TERMINAL_COUNT "/apps/anjuta2/plugins/terminal/terminal_count"
+
+/* Some desktop/gnome-terminal gconf keys. */
+#define MONOSPACE_FONT "/desktop/gnome/interface/monospace_font_name"
+#define BACKGROUND_COLOR "/apps/gnome-terminal/profiles/Default/background_color"
+#define BACKSPACE_BINDING "/apps/gnome-terminal/profiles/Default/backspace_binding"
+#define CURSOR_BLINK "/apps/gnome-terminal/profiles/Default/cursor_blink"
+#define DELETE_BINDING "/apps/gnome-terminal/profiles/Default/delete_binding"
+#define EXIT_ACTION "/apps/gnome-terminal/profiles/Default/exit_action"
+#define TERMINAL_FONT "/apps/gnome-terminal/profiles/Default/font"
+#define FOREGROUND_COLOR "/apps/gnome-terminal/profiles/Default/foreground_color"
+#define SCROLLBACK_LINES "/apps/gnome-terminal/profiles/Default/scrollback_lines"
+#define SCROLL_ON_KEYSTROKE "/apps/gnome-terminal/profiles/Default/scroll_on_keystroke"
+#define SCROLL_ON_OUTPUT "/apps/gnome-terminal/profiles/Default/scroll_on_output"
+#define SILENT_BELL "/apps/gnome-terminal/profiles/Default/silent_bell"
+#define USE_SYSTEM_FONT "/apps/gnome-terminal/profiles/Default/use_system_font"
+#define WORD_CHARS "/apps/gnome-terminal/profiles/Default/word_chars"
gpointer parent_class;
extern char **environ;
@@ -38,10 +55,33 @@
AnjutaToolClass parent;
} TerminalToolClass;
+static BonoboControl *term_new (void);
+
static void
new_terminal (GtkWidget *widget,
gpointer data)
{
+ AnjutaTool *tool = ANJUTA_TOOL (data);
+ GConfClient *client;
+ BonoboControl *control;
+ char *name;
+
+ /* Increase terminal_count value. */
+ client = gconf_client_get_default ();
+ int term_count = gconf_client_get_int (client, TERMINAL_COUNT, NULL);
+ term_count++;
+ gconf_client_set_int (client, TERMINAL_COUNT, term_count, NULL);
+ g_object_unref (client);
+
+ /* Create new terminal. */
+ control = term_new ();
+ name = g_strdup_printf ("Terminal%d", term_count);
+ anjuta_shell_add_control (tool->shell,
+ BONOBO_OBJREF (control),
+ name,
+ _("Terminal"),
+ NULL);
+ g_free (name);
}
static BonoboUIVerb verbs[] = {
@@ -89,41 +129,59 @@
term_init_cb (GtkWidget *widget,
gpointer data)
{
- ZvtTerm *term = ZVT_TERM (widget);
+ VteTerminal *term = VTE_TERMINAL (widget);
struct passwd *pw;
const char *shell;
const char *name;
char **env;
-
- zvt_term_reset (term, TRUE);
- switch (zvt_term_forkpty (term, ZVT_TERM_DO_UTMP_LOG | ZVT_TERM_DO_WTMP_LOG)) {
- case -1:
- break;
- case 0:
- pw = getpwuid (getuid ());
- if (pw) {
- shell = pw->pw_shell;
- name = "-";
- } else {
- shell = "/bin/sh";
- name = "-sh";
- }
- env = get_child_environment (widget);
- execle (shell, name, NULL, env);
- g_strfreev (env);
- default:
- break;
+ GConfClient *client;
+ GdkColor color;
+ char *colorname;
+
+ vte_terminal_reset (term, TRUE, TRUE);
+
+ pw = getpwuid (getuid ());
+ if (pw) {
+ shell = pw->pw_shell;
+ name = "-";
+ } else {
+ shell = "/bin/sh";
+ name = "-sh";
}
+ env = get_child_environment (widget);
+ vte_terminal_fork_command (term, shell, NULL, env);
+ g_strfreev (env);
+
+ client = gconf_client_get_default ();
+
+ /* Set fore- and background colors. */
+ colorname = gconf_client_get_string (client, BACKGROUND_COLOR, NULL);
+ gdk_color_parse (colorname, &color);
+ vte_terminal_set_color_background (term, &color);
+ colorname = gconf_client_get_string (client, FOREGROUND_COLOR, NULL);
+ gdk_color_parse (colorname, &color);
+ vte_terminal_set_color_foreground (term, &color);
+
+ g_object_unref (client);
}
-static gboolean
-term_focus_cb (GtkWidget *widget,
- GdkEvent *event,
- gpointer data)
+static void
+term_exited_cb (GtkWidget *widget,
+ gpointer data)
{
- gtk_widget_grab_focus (widget);
+ GConfClient *client;
+ char *exit_action;
- return TRUE;
+ /* Get exit_action value. */
+ client = gconf_client_get_default ();
+ exit_action = gconf_client_get_string (client, EXIT_ACTION, NULL);
+ g_object_unref (client);
+
+ if (!strcmp (exit_action, "exit")) {
+ g_object_unref (widget);
+ } else if (!strcmp (exit_action, "restart")) {
+ term_init_cb (widget, data);
+ }
}
static void
@@ -132,42 +190,85 @@
{
g_signal_handlers_disconnect_by_func (G_OBJECT (widget),
G_CALLBACK (term_init_cb), NULL);
- zvt_term_closepty (ZVT_TERM (widget));
}
-static void
-shell_set (AnjutaTool *tool)
+static BonoboControl *
+term_new (void)
{
- GtkWidget *zvt, *sb, *frame, *hbox;
+ GConfClient *client;
+ char *text;
+ int value;
+ gboolean setting;
+ GtkWidget *vte, *sb, *frame, *hbox;
BonoboControl *control;
- anjuta_tool_merge_ui (tool,
- "anjuta-terminal-tool",
- ANJUTA_DATADIR,
- "anjuta-terminal-plugin.xml",
- verbs,
- tool);
+ client = gconf_client_get_default ();
- zvt = zvt_term_new ();
- zvt_term_set_font_name (ZVT_TERM (zvt), ZVT_FONT);
- zvt_term_set_blink (ZVT_TERM (zvt), FALSE);
- zvt_term_set_bell (ZVT_TERM (zvt), TRUE);
- zvt_term_set_scrollback (ZVT_TERM (zvt), ZVT_SCROLLSIZE);
- zvt_term_set_scroll_on_keystroke (ZVT_TERM (zvt), TRUE);
- zvt_term_set_scroll_on_output (ZVT_TERM (zvt), FALSE);
- zvt_term_set_background (ZVT_TERM (zvt), NULL, 0, 0);
- zvt_term_set_wordclass (ZVT_TERM (zvt), (unsigned char *) "-A-Za-z0-9,./?%&#:_");
- zvt_term_set_del_key_swap (ZVT_TERM (zvt), TRUE);
- zvt_term_set_del_is_del (ZVT_TERM (zvt), FALSE);
-
- g_signal_connect (G_OBJECT (zvt), "child_died",
- G_CALLBACK (term_init_cb), tool);
- g_signal_connect(G_OBJECT (zvt), "button_press_event",
- G_CALLBACK (term_focus_cb), tool);
- g_signal_connect (G_OBJECT (zvt), "destroy",
- G_CALLBACK (term_destroy_cb), tool);
+ /* Create new terminal. */
+ vte = vte_terminal_new ();
+ vte_terminal_set_size (VTE_TERMINAL (vte), 50, 1);
+ vte_terminal_set_mouse_autohide (VTE_TERMINAL (vte), TRUE);
+
+ /* Set terminal font either using the desktop wide font or g-t one. */
+ setting = gconf_client_get_bool (client, USE_SYSTEM_FONT, NULL);
+ if (setting) {
+ text = gconf_client_get_string (client, MONOSPACE_FONT, NULL);
+ if (!text)
+ text = gconf_client_get_string (client, TERMINAL_FONT, NULL);
+ } else {
+ text = gconf_client_get_string (client, TERMINAL_FONT, NULL);
+ }
+ vte_terminal_set_font_from_string (VTE_TERMINAL (vte), text);
+
+ setting = gconf_client_get_bool (client, CURSOR_BLINK, NULL);
+ vte_terminal_set_cursor_blinks (VTE_TERMINAL (vte), setting);
+ setting = gconf_client_get_bool (client, SILENT_BELL, NULL);
+ vte_terminal_set_audible_bell (VTE_TERMINAL (vte), !setting);
+ value = gconf_client_get_int (client, SCROLLBACK_LINES, NULL);
+ vte_terminal_set_scrollback_lines (VTE_TERMINAL (vte), value);
+ setting = gconf_client_get_bool (client, SCROLL_ON_KEYSTROKE, NULL);
+ vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL (vte), setting);
+ setting = gconf_client_get_bool (client, SCROLL_ON_OUTPUT, NULL);
+ vte_terminal_set_scroll_on_output (VTE_TERMINAL (vte), TRUE);
+ text = gconf_client_get_string (client, WORD_CHARS, NULL);
+ vte_terminal_set_word_chars (VTE_TERMINAL (vte), text);
+
+ text = gconf_client_get_string (client, BACKSPACE_BINDING, NULL);
+ if (!strcmp (text, "ascii-del"))
+ vte_terminal_set_backspace_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_ASCII_DELETE);
+ else if (!strcmp (text, "escape-sequence"))
+ vte_terminal_set_backspace_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_DELETE_SEQUENCE);
+ else if (!strcmp (text, "control-h"))
+ vte_terminal_set_backspace_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_ASCII_BACKSPACE);
+ else
+ vte_terminal_set_backspace_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_AUTO);
+
+ text = gconf_client_get_string (client, DELETE_BINDING, NULL);
+ if (!strcmp (text, "ascii-del"))
+ vte_terminal_set_delete_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_ASCII_DELETE);
+ else if (!strcmp (text, "escape-sequence"))
+ vte_terminal_set_delete_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_DELETE_SEQUENCE);
+ else if (!strcmp (text, "control-h"))
+ vte_terminal_set_delete_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_ASCII_BACKSPACE);
+ else
+ vte_terminal_set_delete_binding (VTE_TERMINAL (vte),
+ VTE_ERASE_AUTO);
+
+ g_object_unref (client);
+
+ g_signal_connect (G_OBJECT (vte), "child-exited",
+ G_CALLBACK (term_exited_cb), NULL);
+ g_signal_connect (G_OBJECT (vte), "destroy",
+ G_CALLBACK (term_destroy_cb), NULL);
- sb = gtk_vscrollbar_new (GTK_ADJUSTMENT (ZVT_TERM (zvt)->adjustment));
+ sb = gtk_vscrollbar_new (GTK_ADJUSTMENT (VTE_TERMINAL (vte)->adjustment));
GTK_WIDGET_UNSET_FLAGS (sb, GTK_CAN_FOCUS);
frame = gtk_frame_new (NULL);
@@ -176,19 +277,49 @@
hbox = gtk_hbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (frame), hbox);
- gtk_box_pack_start (GTK_BOX (hbox), zvt, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (hbox), vte, TRUE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox), sb, FALSE, TRUE, 0);
gtk_widget_show_all (frame);
control = bonobo_control_new (frame);
- anjuta_shell_add_control (tool->shell,
- BONOBO_OBJREF (control),
- "Terminal",
- _("Terminal"),
- NULL);
+ term_init_cb (vte, NULL);
- term_init_cb (zvt, NULL);
+ return control;
+}
+
+static void
+shell_set (AnjutaTool *tool)
+{
+ GConfClient *client;
+ int term_count, i;
+ BonoboControl *control;
+
+ anjuta_tool_merge_ui (tool,
+ "anjuta-terminal-tool",
+ ANJUTA_DATADIR,
+ "anjuta-terminal-plugin.xml",
+ verbs,
+ tool);
+
+ /* Get the number of terminals in a previous anjuta2 instance. */
+ client = gconf_client_get_default ();
+ term_count = gconf_client_get_int (client, TERMINAL_COUNT, NULL);
+ g_object_unref (client);
+
+ /* Recreate terminals. */
+ for (i = 0; i < term_count; i++) {
+ char *name = g_strdup_printf ("Terminal%d", i);
+
+ control = term_new ();
+
+ anjuta_shell_add_control (tool->shell,
+ BONOBO_OBJREF (control),
+ name,
+ _("Terminal"),
+ NULL);
+ g_free (name);
+ }
}
static void
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]