X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=tilda-terminal.c;h=14567dab471d15d6622f47c345131a745b0ed476;hb=93db48f0c2f7a1185d4da9d9ab7cde83b9a3aa94;hp=57f14b0e166a3375b268ebbd6413ea131f520a51;hpb=3e2d4445566d732617d584a2cb4a2aef5573ecba;p=tilda-gobject.git diff --git a/tilda-terminal.c b/tilda-terminal.c index 57f14b0..14567da 100644 --- a/tilda-terminal.c +++ b/tilda-terminal.c @@ -2,11 +2,6 @@ #include "tilda-terminal.h" #include "tilda-terminal-dbus-glue.h" -// FIXME: temporary helpers for gettext -// TODO: remove these -#define _(X) X -#define N_(X) X - #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_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]" @@ -17,15 +12,41 @@ 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, @@ -123,7 +144,7 @@ tilda_terminal_child_exited_cb (GtkWidget *widget, gpointer data) switch (self->exit_action) { case EXIT_TERMINAL: - tilda_window_remove_term (TILDA_WINDOW(self->parent_window), self->number); + tilda_window_remove_terminal (TILDA_WINDOW(self->parent_window), self->number); break; case RESTART_COMMAND: vte_terminal_feed (VTE_TERMINAL(self->vte_term), "\r\n\r\n", 4); @@ -337,8 +358,7 @@ static GObjectClass *parent_class = NULL; 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, @@ -402,12 +422,7 @@ tilda_terminal_set_property (GObject *object, 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; @@ -576,11 +591,7 @@ tilda_terminal_get_property (GObject *object, 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; @@ -701,9 +712,7 @@ tilda_terminal_constructor (GType type, 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 */ @@ -770,8 +779,6 @@ tilda_terminal_finalize (GObject *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); @@ -807,8 +814,8 @@ tilda_terminal_class_init (gpointer g_class, /* 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 @@ -818,30 +825,18 @@ tilda_terminal_class_init (gpointer g_class, 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); @@ -850,8 +845,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_string ("shell", - "Terminal's shell", - "Get/Set terminal's shell", + _("Terminal's shell"), + NULL, NULL, G_PARAM_READWRITE); @@ -860,8 +855,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_string ("font", - "Terminal's font", - "Get/Set terminal's font", + _("Terminal's font"), + NULL, NULL, G_PARAM_READWRITE); @@ -870,8 +865,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_string ("title", - "Terminal's title", - "Get/Set terminal's title", + _("Terminal's title"), + NULL, NULL, G_PARAM_READWRITE); @@ -880,8 +875,8 @@ tilda_terminal_class_init (gpointer g_class, 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); @@ -890,7 +885,7 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_string ("web-browser", - "Terminal's web browser command", + _("Terminal's web browser command"), NULL, NULL, G_PARAM_READWRITE); @@ -900,8 +895,8 @@ tilda_terminal_class_init (gpointer g_class, 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, @@ -912,8 +907,8 @@ tilda_terminal_class_init (gpointer g_class, 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, @@ -924,8 +919,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_int ("backspace-binding", - "Terminal's backspace binding", - "Get/Set terminal's backspace key binding", + _("Terminal's backspace binding"), + NULL, VTE_ERASE_AUTO, VTE_ERASE_DELETE_SEQUENCE, VTE_ERASE_AUTO, @@ -936,8 +931,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_int ("delete-binding", - "Terminal's delete binding", - "Get/Set terminal's delete key binding", + _("Terminal's delete binding"), + NULL, VTE_ERASE_AUTO, VTE_ERASE_DELETE_SEQUENCE, VTE_ERASE_AUTO, @@ -948,8 +943,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_int ("dynamic-title", - "Terminal's dynamic title generation method", - "Get/Set terminal's dynamic title generation method", + _("Terminal's dynamic title generation method"), + NULL, 0, INT_MAX, 0, @@ -960,8 +955,8 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_int ("exit-action", - "Terminal's action upon child exit", - "Get/Set terminal's action upon child exit", + _("Terminal's action upon child exit"), + NULL, 0, INT_MAX, 0, @@ -972,7 +967,7 @@ tilda_terminal_class_init (gpointer g_class, pspec); pspec = g_param_spec_int ("scrollbar-position", - "Terminal's scrollbar position", + _("Terminal's scrollbar position"), NULL, 0, INT_MAX, @@ -984,8 +979,8 @@ tilda_terminal_class_init (gpointer g_class, 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); @@ -994,8 +989,8 @@ tilda_terminal_class_init (gpointer g_class, 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); @@ -1004,7 +999,7 @@ tilda_terminal_class_init (gpointer g_class, 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, @@ -1012,7 +1007,7 @@ tilda_terminal_class_init (gpointer g_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, @@ -1020,7 +1015,7 @@ tilda_terminal_class_init (gpointer g_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, @@ -1028,35 +1023,40 @@ tilda_terminal_class_init (gpointer g_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,