#include "tilda.h"
#include "tilda-terminal.h"
+#include "tilda-config.h"
#include "tilda-terminal-dbus-glue.h"
+#include <stdlib.h>
+
#define DINGUS1 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?"
#define DINGUS2 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?/[-A-Za-z0-9_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]"
-
static void
tilda_terminal_dbus_register_object (TildaTerminal *tt)
{
debug_enter ();
debug_assert (TILDA_IS_TERMINAL(tt));
+ TildaWindow *parent_window = TILDA_WINDOW(tt->parent_window);
gchar *object_path;
// Register this object with DBus
object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d/Terminal%d",
- tt->window_number, tt->number);
+ parent_window->number, tt->number);
dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tt));
g_free (object_path);
}
+gboolean
+tilda_terminal_run_command (TildaTerminal *self, gchar *command, GError **error)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(self));
+
+ vte_terminal_feed_child (VTE_TERMINAL(self->vte_term), command, -1);
+ vte_terminal_feed_child (VTE_TERMINAL(self->vte_term), "\n", -1);
+
+ return TRUE;
+}
+
+gboolean
+tilda_terminal_close (TildaTerminal *self, GError **error)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_TERMINAL(self));
+
+ TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
+
+ tilda_window_remove_terminal (parent_window, self->number);
+
+ return TRUE;
+}
+
/**
* Start the current tt->shell in the given TildaTerminal
* NOTE: this will kill whatever is running in the terminal,
TildaTerminal *self = TILDA_TERMINAL(data);
- /* These can stay here. They don't need to go into a header because
- * they are only used at this point in the code. */
- enum exit_actions { HOLD_TERMINAL_OPEN, RESTART_COMMAND, EXIT_TERMINAL };
-
/* Check the user's preference for what to do when the child terminal
* is closed. Take the appropriate action */
switch (self->exit_action)
{
- case EXIT_TERMINAL:
- tilda_window_remove_term (TILDA_WINDOW(self->parent_window), self->number);
+ case TILDA_CHILD_EXIT_ACTION_EXIT:
+ tilda_window_remove_terminal (TILDA_WINDOW(self->parent_window), self->number);
break;
- case RESTART_COMMAND:
+ case TILDA_CHILD_EXIT_ACTION_RESTART:
vte_terminal_feed (VTE_TERMINAL(self->vte_term), "\r\n\r\n", 4);
tilda_terminal_start_shell (self);
break;
- case HOLD_TERMINAL_OPEN:
+ case TILDA_CHILD_EXIT_ACTION_HOLD_OPEN:
break;
default:
+ g_warning ("Bad value in self->exit_action\n");
break;
}
}
TildaTerminal *self = TILDA_TERMINAL(data);
TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
GtkWidget *label;
- const gchar *vte_title;
- gchar *new_title;
-
- enum dynamic_titles { NOT_DISPLAYED, AFTER_INITIAL, BEFORE_INITIAL, REPLACE_INITIAL };
- label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(parent_window->notebook), self->hbox);
-
- /* If we aren't using a dynamic title -- NOT_DISPLAYED -- then just
- * set it to the static title and exit */
- if (!self->dynamic_title)
- {
- gtk_label_set_text (GTK_LABEL(label), self->title);
- return;
- }
+ const gchar *vte_title = NULL;
+ gchar *new_title = NULL;
- /* Get the title from VTE */
vte_title = vte_terminal_get_window_title (VTE_TERMINAL (widget));
+ label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(parent_window->notebook), self->hbox);
- /* Take the appropriate action */
switch (self->dynamic_title)
{
- case REPLACE_INITIAL:
- new_title = g_strdup (vte_title);
+ case TILDA_DYNAMIC_TITLE_DISABLED:
+ new_title = g_strdup (self->title);
break;
- case BEFORE_INITIAL:
+ case TILDA_DYNAMIC_TITLE_AFTER_INITIAL:
+ new_title = g_strdup_printf ("%s - %s", self->title, vte_title);
+ break;
+
+ case TILDA_DYNAMIC_TITLE_BEFORE_INITIAL:
new_title = g_strdup_printf ("%s - %s", vte_title, self->title);
break;
- case AFTER_INITIAL:
- new_title = g_strdup_printf ("%s - %s", self->title, vte_title);
+ case TILDA_DYNAMIC_TITLE_REPLACE_INITIAL:
+ new_title = g_strdup (self->title);
break;
default:
- debug_printf ("ERROR: Bad value of self->dynamic_title\n");
- case NOT_DISPLAYED:
- new_title = g_strdup(self->title);
+ g_warning ("Bad value in self->dynamic-title\n");
break;
}
debug_enter ();
debug_assert (TILDA_IS_TERMINAL(self));
- enum scrollbar_positions { DISABLED, LEFT, RIGHT };
switch (self->scrollbar_position)
{
- case LEFT:
+ case TILDA_SCROLLBAR_RIGHT:
gtk_box_reorder_child (GTK_BOX(self->hbox), self->scrollbar, 0);
gtk_widget_show (self->scrollbar);
break;
- case RIGHT:
+ case TILDA_SCROLLBAR_LEFT:
gtk_box_reorder_child (GTK_BOX(self->hbox), self->scrollbar, 1);
gtk_widget_show (self->scrollbar);
break;
- default:
- debug_printf ("ERROR: Bad scrollbar position\n");
- case DISABLED:
+ case TILDA_SCROLLBAR_DISABLED:
gtk_widget_hide (self->scrollbar);
break;
+
+ default:
+ g_warning ("Bad value in self->scrollbar_position\n");
+ break;
}
}
enum tilda_terminal_properties {
TILDA_TERMINAL_NUMBER = 1,
- TILDA_TERMINAL_WINDOW_NUMBER,
- TILDA_TERMINAL_TW,
+ TILDA_TERMINAL_PARENT_WINDOW,
/* All non-constructor-only properties */
TILDA_TERMINAL_BACKGROUND_IMAGE,
debug_printf ("terminal number: %d\n", self->number);
break;
- case TILDA_TERMINAL_WINDOW_NUMBER:
- self->window_number = g_value_get_int (value);
- debug_printf ("terminal parent window number: %d\n", self->window_number);
- break;
-
- case TILDA_TERMINAL_TW:
+ case TILDA_TERMINAL_PARENT_WINDOW:
self->parent_window = g_value_get_pointer (value);
debug_printf ("terminal parent window: 0x%x\n", self->parent_window);
break;
break;
case TILDA_TERMINAL_BACKSPACE_BINDING:
- self->backspace_binding = g_value_get_int (value);
+ self->backspace_binding = g_value_get_enum (value);
vte_terminal_set_backspace_binding (VTE_TERMINAL(self->vte_term), self->backspace_binding);
debug_printf ("terminal backspace key: %d\n", self->backspace_binding);
break;
case TILDA_TERMINAL_DELETE_BINDING:
- self->delete_binding = g_value_get_int (value);
+ self->delete_binding = g_value_get_enum (value);
vte_terminal_set_delete_binding (VTE_TERMINAL(self->vte_term), self->delete_binding);
debug_printf ("terminal delete key: %d\n", self->delete_binding);
break;
case TILDA_TERMINAL_DYNAMIC_TITLE:
- self->dynamic_title = g_value_get_int (value);
+ self->dynamic_title = g_value_get_enum (value);
debug_printf ("terminal dynamic title: %d\n", self->dynamic_title);
break;
case TILDA_TERMINAL_EXIT_ACTION:
- self->exit_action = g_value_get_int (value);
+ self->exit_action = g_value_get_enum (value);
debug_printf ("terminal exit action: %d\n", self->exit_action);
break;
case TILDA_TERMINAL_SCROLLBAR_POSITION:
- self->scrollbar_position = g_value_get_int (value);
+ self->scrollbar_position = g_value_get_enum (value);
tilda_terminal_set_scrollbar_position (self);
debug_printf ("terminal scrollbar position: %d\n", self->scrollbar_position);
break;
g_value_set_int (value, self->number);
break;
- case TILDA_TERMINAL_WINDOW_NUMBER:
- g_value_set_int (value, self->window_number);
- break;
-
- case TILDA_TERMINAL_TW:
+ case TILDA_TERMINAL_PARENT_WINDOW:
g_value_set_pointer (value, self->parent_window);
break;
break;
case TILDA_TERMINAL_BACKSPACE_BINDING:
- g_value_set_int (value, self->backspace_binding);
+ g_value_set_enum (value, self->backspace_binding);
break;
case TILDA_TERMINAL_DELETE_BINDING:
- g_value_set_int (value, self->delete_binding);
+ g_value_set_enum (value, self->delete_binding);
break;
case TILDA_TERMINAL_DYNAMIC_TITLE:
- g_value_set_int (value, self->dynamic_title);
+ g_value_set_enum (value, self->dynamic_title);
break;
case TILDA_TERMINAL_EXIT_ACTION:
- g_value_set_int (value, self->exit_action);
+ g_value_set_enum (value, self->exit_action);
break;
case TILDA_TERMINAL_SCROLLBAR_POSITION:
- g_value_set_int (value, self->scrollbar_position);
+ g_value_set_enum (value, self->scrollbar_position);
break;
case TILDA_TERMINAL_SCROLL_BACKGROUND:
construct_properties);
/* Do other stuff here. The object is ready to go now, and all
- * ctor properties have been set.
- *
- * TODO: This is the place to do DBus-init */
+ * ctor properties have been set. */
self = TILDA_TERMINAL(obj);
/* Pack into the hbox */
g_signal_connect (G_OBJECT(self->vte_term), "button-press-event",
G_CALLBACK(tilda_terminal_button_press_cb), self);
- tilda_terminal_start_shell (self);
+ /* Setup all of the defaults from the config file */
+ tilda_terminal_set_property_from_config (self, "background-image");
+ tilda_terminal_set_property_from_config (self, "shell");
+ tilda_terminal_set_property_from_config (self, "font");
+ tilda_terminal_set_property_from_config (self, "title");
+ tilda_terminal_set_property_from_config (self, "working-directory");
+ tilda_terminal_set_property_from_config (self, "web-browser");
+
+ tilda_terminal_set_property_from_config (self, "scrollback-lines");
+ tilda_terminal_set_property_from_config (self, "transparency-percent");
+
+ tilda_terminal_set_property_from_config (self, "backspace-binding");
+ tilda_terminal_set_property_from_config (self, "delete-binding");
+ tilda_terminal_set_property_from_config (self, "dynamic-title");
+ tilda_terminal_set_property_from_config (self, "exit-action");
+ tilda_terminal_set_property_from_config (self, "scrollbar-position");
+
+ tilda_terminal_set_property_from_config (self, "scroll-background");
+ tilda_terminal_set_property_from_config (self, "scroll-on-output");
+ tilda_terminal_set_property_from_config (self, "scroll-on-keystroke");
+ tilda_terminal_set_property_from_config (self, "antialiased");
+ tilda_terminal_set_property_from_config (self, "allow-bold-text");
+ tilda_terminal_set_property_from_config (self, "cursor-blinks");
+ tilda_terminal_set_property_from_config (self, "audible-bell");
+ tilda_terminal_set_property_from_config (self, "visible-bell");
+ tilda_terminal_set_property_from_config (self, "double-buffered");
+ tilda_terminal_set_property_from_config (self, "mouse-autohide");
+
+ /* All right! We're all ready to go, so register with DBus, and lets start! */
tilda_terminal_dbus_register_object (self);
return obj;
* Here, complete object destruction.
* You might not need to do much...
*/
-
- // TODO: g_free() any primitives here
g_free (self->background_image);
g_free (self->shell);
g_free (self->font);
/* Install all of the properties */
pspec = g_param_spec_int ("number",
- "Terminal number",
- "Set terminal's number",
+ _("Terminal number"),
+ NULL,
0, // min value
INT_MAX, // max value
0, // def value
TILDA_TERMINAL_NUMBER,
pspec);
- pspec = g_param_spec_int ("window-number",
- "Number of the window to which this terminal belongs",
- "Set the number of the parent window",
- 0,
- INT_MAX,
- 0x0000beef,
- G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
-
- g_object_class_install_property (gobject_class,
- TILDA_TERMINAL_WINDOW_NUMBER,
- pspec);
-
pspec = g_param_spec_pointer ("parent-window",
- "Pointer to terminal's parent TildaWindow",
- "Set the pointer to the terminal's parent TildaWindow",
+ _("Pointer to terminal's parent TildaWindow"),
+ NULL,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
- TILDA_TERMINAL_TW,
+ TILDA_TERMINAL_PARENT_WINDOW,
pspec);
pspec = g_param_spec_string ("background-image",
- "Terminal's background image",
- "Get/Set terminal's background image",
+ _("Terminal's background image"),
+ NULL,
NULL,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_string ("shell",
- "Terminal's shell",
- "Get/Set terminal's shell",
+ _("Terminal's shell"),
+ NULL,
NULL,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_string ("font",
- "Terminal's font",
- "Get/Set terminal's font",
+ _("Terminal's font"),
+ NULL,
NULL,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_string ("title",
- "Terminal's title",
- "Get/Set terminal's title",
+ _("Terminal's title"),
+ NULL,
NULL,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_string ("working-directory",
- "Terminal's initial working directory",
- "Get/Set terminal's initial working directory",
+ _("Terminal's initial working directory"),
+ NULL,
NULL,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_string ("web-browser",
- "Terminal's web browser command",
+ _("Terminal's web browser command"),
NULL,
NULL,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_int ("scrollback-lines",
- "Terminal's scrollback amount (lines)",
- "Get/Set terminal's scrollback amount",
+ _("Terminal's scrollback amount (lines)"),
+ NULL,
0,
INT_MAX, // TODO: artificially limit this?
1000,
pspec);
pspec = g_param_spec_int ("transparency-percent",
- "Terminal's transparency (percent)",
- "Get/Set terminal's transparency",
+ _("Terminal's transparency (percent)"),
+ NULL,
0,
100,
0,
TILDA_TERMINAL_TRANSPARENCY_PERCENT,
pspec);
- pspec = g_param_spec_int ("backspace-binding",
- "Terminal's backspace binding",
- "Get/Set terminal's backspace key binding",
- VTE_ERASE_AUTO,
- VTE_ERASE_DELETE_SEQUENCE,
- VTE_ERASE_AUTO,
- G_PARAM_READWRITE);
+ pspec = g_param_spec_enum ("backspace-binding",
+ _("Terminal's backspace binding"),
+ NULL,
+ vte_terminal_erase_binding_get_type(),
+ VTE_ERASE_AUTO,
+ G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_BACKSPACE_BINDING,
pspec);
- pspec = g_param_spec_int ("delete-binding",
- "Terminal's delete binding",
- "Get/Set terminal's delete key binding",
- VTE_ERASE_AUTO,
- VTE_ERASE_DELETE_SEQUENCE,
- VTE_ERASE_AUTO,
- G_PARAM_READWRITE);
+ pspec = g_param_spec_enum ("delete-binding",
+ _("Terminal's delete binding"),
+ NULL,
+ vte_terminal_erase_binding_get_type(),
+ VTE_ERASE_AUTO,
+ G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_DELETE_BINDING,
pspec);
- pspec = g_param_spec_int ("dynamic-title",
- "Terminal's dynamic title generation method",
- "Get/Set terminal's dynamic title generation method",
- 0,
- INT_MAX,
- 0,
- G_PARAM_READWRITE);
+ pspec = g_param_spec_enum ("dynamic-title",
+ _("Terminal's dynamic title generation method"),
+ NULL,
+ tilda_dynamic_title_get_type(),
+ TILDA_DYNAMIC_TITLE_DISABLED,
+ G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_DYNAMIC_TITLE,
pspec);
- pspec = g_param_spec_int ("exit-action",
- "Terminal's action upon child exit",
- "Get/Set terminal's action upon child exit",
- 0,
- INT_MAX,
- 0,
- G_PARAM_READWRITE);
+ pspec = g_param_spec_enum ("exit-action",
+ _("Terminal's action upon child exit"),
+ NULL,
+ tilda_child_exit_action_get_type(),
+ TILDA_CHILD_EXIT_ACTION_EXIT,
+ G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_EXIT_ACTION,
pspec);
- pspec = g_param_spec_int ("scrollbar-position",
- "Terminal's scrollbar position",
- NULL,
- 0,
- INT_MAX,
- 0,
- G_PARAM_READWRITE);
+ pspec = g_param_spec_enum ("scrollbar-position",
+ _("Terminal's scrollbar position"),
+ NULL,
+ tilda_scrollbar_position_get_type(),
+ TILDA_SCROLLBAR_RIGHT,
+ G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_SCROLLBAR_POSITION,
pspec);
pspec = g_param_spec_boolean ("scroll-background",
- "Controls terminal's scrolling behavior",
- "Get/Set terminal's scrolling behavior",
+ _("Controls terminal's scrolling behavior"),
+ NULL,
FALSE,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_boolean ("scroll-on-output",
- "Controls terminal's scrolling behavior on output",
- "Get/Set terminal's scrolling behavior on output",
+ _("Controls terminal's scrolling behavior on output"),
+ NULL,
FALSE,
G_PARAM_READWRITE);
pspec);
pspec = g_param_spec_boolean ("scroll-on-keystroke",
- "Controls the terminal's scrolling behavior on keystroke",
+ _("Controls the terminal's scrolling behavior on keystroke"),
NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
pspec);
pspec = g_param_spec_boolean ("antialiased",
- "Attempt to antialias fonts",
+ _("Attempt to antialias fonts"),
NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
pspec);
pspec = g_param_spec_boolean ("allow-bold-text",
- "Allow bold text",
+ _("Allow bold text"),
NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
pspec);
pspec = g_param_spec_boolean ("cursor-blinks",
- NULL, NULL, FALSE, G_PARAM_READWRITE);
+ _("Enable cursor blinking"),
+ NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_CURSOR_BLINKS,
pspec);
pspec = g_param_spec_boolean ("audible-bell",
- NULL, NULL, FALSE, G_PARAM_READWRITE);
+ _("Enable the audible bell"),
+ NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_AUDIBLE_BELL,
pspec);
pspec = g_param_spec_boolean ("visible-bell",
- NULL, NULL, FALSE, G_PARAM_READWRITE);
+ _("Enable the visible bell"),
+ NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_VISIBLE_BELL,
pspec);
pspec = g_param_spec_boolean ("double-buffered",
- NULL, NULL, FALSE, G_PARAM_READWRITE);
+ _("Double buffer the terminal"),
+ NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_DOUBLE_BUFFERED,
pspec);
pspec = g_param_spec_boolean ("mouse-autohide",
- NULL, NULL, FALSE, G_PARAM_READWRITE);
+ _("Hide the mouse cursor while typing"),
+ NULL, FALSE, G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
TILDA_TERMINAL_MOUSE_AUTOHIDE,