X-Git-Url: https://irasnyder.com/gitweb/?a=blobdiff_plain;f=tilda-terminal.c;h=14567dab471d15d6622f47c345131a745b0ed476;hb=2b17e21d2ac627242479945521f7a8e65c51d5b5;hp=87b081ab797074c976ece298cc528019d22c6c89;hpb=8fe1ca3c55522a06dcab51a43db38cef97f3c9d8;p=tilda-gobject.git diff --git a/tilda-terminal.c b/tilda-terminal.c index 87b081a..14567da 100644 --- a/tilda-terminal.c +++ b/tilda-terminal.c @@ -2,23 +2,51 @@ #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_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]" + 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, @@ -28,6 +56,9 @@ tilda_terminal_dbus_register_object (TildaTerminal *tt) static gboolean tilda_terminal_start_shell (TildaTerminal *tt) { + debug_enter (); + debug_assert (TILDA_IS_TERMINAL(tt)); + gint ret; gint argc; gchar **argv; @@ -96,8 +127,12 @@ launch_default_shell: * Called when the child process running in the VteTerminal exits. */ static void -child_exited_cb (GtkWidget *widget, gpointer data) +tilda_terminal_child_exited_cb (GtkWidget *widget, gpointer data) { + debug_enter (); + debug_assert (GTK_IS_WIDGET(widget)); + debug_assert (TILDA_IS_TERMINAL(data)); + TildaTerminal *self = TILDA_TERMINAL(data); /* These can stay here. They don't need to go into a header because @@ -109,7 +144,7 @@ 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); @@ -122,6 +157,199 @@ child_exited_cb (GtkWidget *widget, gpointer data) } } +/** + * Called when the child window title changes. Determines if a new + * title needs to be put into the notebook's tab label. + */ +static void +tilda_terminal_window_title_changed_cb (GtkWidget *widget, gpointer data) +{ + debug_enter (); + debug_assert (GTK_IS_WIDGET(widget)); + debug_assert (TILDA_IS_TERMINAL(data)); + + 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; + } + + /* Get the title from VTE */ + vte_title = vte_terminal_get_window_title (VTE_TERMINAL (widget)); + + /* Take the appropriate action */ + switch (self->dynamic_title) + { + case REPLACE_INITIAL: + new_title = g_strdup (vte_title); + break; + + case 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); + break; + + default: + debug_printf ("ERROR: Bad value of self->dynamic_title\n"); + case NOT_DISPLAYED: + new_title = g_strdup(self->title); + break; + } + + gtk_label_set_text (GTK_LABEL(label), new_title); + g_free (new_title); +} + +/** + * Gets called whenever there is a button-press event in the VteTerminal. It + * is used to open the user's web browser, for example. + */ +static gint +tilda_terminal_button_press_cb (GtkWidget *widget, + GdkEventButton *event, + gpointer data) +{ + debug_enter (); + debug_assert (GTK_IS_WIDGET(widget)); + debug_assert (TILDA_IS_TERMINAL(data)); + debug_printf ("event->button = %d\n", event->button); + + GError *error = NULL; + TildaTerminal *self = TILDA_TERMINAL(data); + VteTerminal *terminal = VTE_TERMINAL(self->vte_term); + gint tag, xpad, ypad; + gchar *match, *cmd, *web_browser_cmd; + gboolean ret = FALSE; + + switch (event->button) + { + case 3: /* Right Click */ + // FIXME: need to add this + //popup_menu (tt->tw, tt); + g_print ("FIXME: popup_menu() here\n"); + break; + + case 2: /* Middle Click */ + break; + + case 1: /* Left Click */ + vte_terminal_get_padding (terminal, &xpad, &ypad); + match = vte_terminal_match_check (terminal, + (event->x - ypad) / terminal->char_width, + (event->y - ypad) / terminal->char_height, + &tag); + + /* Check if we can launch a web browser, and do so if possible */ + if ((event->state & GDK_CONTROL_MASK) && match != NULL) + { + web_browser_cmd = g_strescape (self->web_browser, NULL); + cmd = g_strdup_printf ("%s %s", web_browser_cmd, match); + + debug_printf ("Got a Ctrl+Left-Click -- match: '%s' tag: %d\n", match, tag); + debug_printf ("Launching command: '%s'\n", cmd); + + ret = g_spawn_command_line_async(cmd, &error); + + /* Check that the command launched */ + if (!ret) + { + g_printerr (_("Failed to launch web browser command: `%s'\n"), cmd); + g_printerr (_("Error message: %s\n"), error->message); + } + + /* Free allocated memory */ + g_free (web_browser_cmd); + g_free (cmd); + } + + /* Always free match if it is non NULL */ + g_free (match); + break; + + default: + break; + } + + return FALSE; +} + +/** + * Set the given TildaTerminal to the appropriate transparency level + * based on the self->transparency_percent member. */ +static void +tilda_terminal_set_transparent (TildaTerminal *self) +{ + debug_enter (); + debug_assert (TILDA_IS_TERMINAL(self)); + + TildaWindow *parent_window = TILDA_WINDOW(self->parent_window); + gdouble temp; + + /* Convert the transparency to VTE's format */ + temp = ((gdouble) self->transparency_percent) / 100.0; + + if (self->transparency_percent > 0) + { + vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), temp); + vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), (1.0 - temp) * 0xffff); + + /* Use fake transparency if necessary */ + vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term), + !parent_window->have_real_transparency); + return; + } + + /* Turn off transparency */ + vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), 0); + vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), 0xffff); + vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term), FALSE); +} + +/** + * Set the scrollbar position of the given TildaTerminal to + * the value in self->scrollbar_position. + */ +static void +tilda_terminal_set_scrollbar_position (TildaTerminal *self) +{ + debug_enter (); + debug_assert (TILDA_IS_TERMINAL(self)); + + enum scrollbar_positions { DISABLED, LEFT, RIGHT }; + switch (self->scrollbar_position) + { + case LEFT: + gtk_box_reorder_child (GTK_BOX(self->hbox), self->scrollbar, 0); + gtk_widget_show (self->scrollbar); + break; + + case RIGHT: + 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: + gtk_widget_hide (self->scrollbar); + break; + } +} + /******************************************************************************* * All GObject stuff is below. You probably don't need to change this... ******************************************************************************/ @@ -130,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, @@ -139,6 +366,7 @@ enum tilda_terminal_properties { TILDA_TERMINAL_FONT, TILDA_TERMINAL_TITLE, TILDA_TERMINAL_WORKING_DIRECTORY, + TILDA_TERMINAL_WEB_BROWSER, TILDA_TERMINAL_SCROLLBACK_LINES, TILDA_TERMINAL_TRANSPARENCY_PERCENT, @@ -147,6 +375,7 @@ enum tilda_terminal_properties { TILDA_TERMINAL_DELETE_BINDING, TILDA_TERMINAL_DYNAMIC_TITLE, TILDA_TERMINAL_EXIT_ACTION, + TILDA_TERMINAL_SCROLLBAR_POSITION, TILDA_TERMINAL_SCROLL_BACKGROUND, TILDA_TERMINAL_SCROLL_ON_OUTPUT, @@ -164,6 +393,8 @@ static void tilda_terminal_instance_init (GTypeInstance *instance, gpointer g_class) { + debug_enter (); + TildaTerminal *self = (TildaTerminal *) instance; /* Initialize instance members and allocate any necessary memory here. @@ -188,32 +419,26 @@ tilda_terminal_set_property (GObject *object, case TILDA_TERMINAL_NUMBER: self->number = g_value_get_int (value); - g_print ("terminal number: %d\n", self->number); - break; - - case TILDA_TERMINAL_WINDOW_NUMBER: - self->window_number = g_value_get_int (value); - g_print ("terminal parent window number: %d\n", self->window_number); + debug_printf ("terminal number: %d\n", self->number); break; - case TILDA_TERMINAL_TW: + case TILDA_TERMINAL_PARENT_WINDOW: self->parent_window = g_value_get_pointer (value); - g_print ("terminal parent window: 0x%x\n", self->parent_window); - g_print ("terminal parent window number (direct): %d\n", TILDA_WINDOW(self->parent_window)->number); + debug_printf ("terminal parent window: 0x%x\n", self->parent_window); break; case TILDA_TERMINAL_BACKGROUND_IMAGE: g_free (self->background_image); self->background_image = g_value_dup_string (value); vte_terminal_set_background_image_file (VTE_TERMINAL(self->vte_term), self->background_image); - g_print ("terminal back img: %s\n", self->background_image); + debug_printf ("terminal back img: %s\n", self->background_image); break; case TILDA_TERMINAL_SHELL: g_free (self->shell); self->shell = g_value_dup_string (value); tilda_terminal_start_shell (self); - g_print ("terminal shell: %s\n", self->shell); + debug_printf ("terminal shell: %s\n", self->shell); break; case TILDA_TERMINAL_FONT: @@ -222,70 +447,83 @@ tilda_terminal_set_property (GObject *object, vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term), self->font, self->antialiased); - g_print ("terminal font: %s\n", self->font); + debug_printf ("terminal font: %s\n", self->font); break; case TILDA_TERMINAL_TITLE: g_free (self->title); self->title = g_value_dup_string (value); - g_print ("terminal title: %s\n", self->title); + debug_printf ("terminal title: %s\n", self->title); break; case TILDA_TERMINAL_WORKING_DIRECTORY: g_free (self->working_directory); self->working_directory = g_value_dup_string (value); - g_print ("terminal wrk dir: %s\n", self->working_directory); + debug_printf ("terminal wrk dir: %s\n", self->working_directory); + break; + + case TILDA_TERMINAL_WEB_BROWSER: + g_free (self->web_browser); + self->web_browser = g_value_dup_string (value); + debug_printf ("terminal web browser: %s\n", self->web_browser); break; case TILDA_TERMINAL_SCROLLBACK_LINES: self->scrollback_lines = g_value_get_int (value); vte_terminal_set_scrollback_lines (VTE_TERMINAL(self->vte_term), self->scrollback_lines); - g_print ("terminal scrollback lines: %d\n", self->scrollback_lines); + debug_printf ("terminal scrollback lines: %d\n", self->scrollback_lines); break; case TILDA_TERMINAL_TRANSPARENCY_PERCENT: self->transparency_percent = g_value_get_int (value); - g_print ("terminal transp percent: %d\n", self->transparency_percent); + tilda_terminal_set_transparent (self); + debug_printf ("terminal transp percent: %d\n", self->transparency_percent); break; case TILDA_TERMINAL_BACKSPACE_BINDING: self->backspace_binding = g_value_get_int (value); vte_terminal_set_backspace_binding (VTE_TERMINAL(self->vte_term), self->backspace_binding); - g_print ("terminal backspace key: %d\n", 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); vte_terminal_set_delete_binding (VTE_TERMINAL(self->vte_term), self->delete_binding); - g_print ("terminal delete key: %d\n", 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); - g_print ("terminal dynamic title: %d\n", self->dynamic_title); + debug_printf ("terminal dynamic title: %d\n", self->dynamic_title); break; case TILDA_TERMINAL_EXIT_ACTION: self->exit_action = g_value_get_int (value); - g_print ("terminal exit action: %d\n", self->exit_action); + debug_printf ("terminal exit action: %d\n", self->exit_action); + break; + + case TILDA_TERMINAL_SCROLLBAR_POSITION: + self->scrollbar_position = g_value_get_int (value); + tilda_terminal_set_scrollbar_position (self); + debug_printf ("terminal scrollbar position: %d\n", self->scrollbar_position); break; case TILDA_TERMINAL_SCROLL_BACKGROUND: self->scroll_background = g_value_get_boolean (value); vte_terminal_set_scroll_background (VTE_TERMINAL(self->vte_term), self->scroll_background); - g_print ("terminal scroll background: %d\n", self->scroll_background); + debug_printf ("terminal scroll background: %d\n", self->scroll_background); break; case TILDA_TERMINAL_SCROLL_ON_OUTPUT: self->scroll_on_output = g_value_get_boolean (value); vte_terminal_set_scroll_on_output (VTE_TERMINAL(self->vte_term), self->scroll_on_output); - g_print ("terminal scroll on output: %d\n", self->scroll_on_output); + debug_printf ("terminal scroll on output: %d\n", self->scroll_on_output); break; case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE: self->scroll_on_keystroke = g_value_get_boolean (value); vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(self->vte_term), self->scroll_on_keystroke); - g_print ("terminal scroll on keystroke: %d\n", self->scroll_on_keystroke); + debug_printf ("terminal scroll on keystroke: %d\n", self->scroll_on_keystroke); break; case TILDA_TERMINAL_ANTIALIASED: @@ -293,43 +531,43 @@ tilda_terminal_set_property (GObject *object, vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term), self->font, self->antialiased); - g_print ("terminal antialiased: %d\n", self->antialiased); + debug_printf ("terminal antialiased: %d\n", self->antialiased); break; case TILDA_TERMINAL_ALLOW_BOLD_TEXT: self->allow_bold_text = g_value_get_boolean (value); vte_terminal_set_allow_bold (VTE_TERMINAL(self->vte_term), self->allow_bold_text); - g_print ("terminal allow bold text: %d\n", self->allow_bold_text); + debug_printf ("terminal allow bold text: %d\n", self->allow_bold_text); break; case TILDA_TERMINAL_CURSOR_BLINKS: self->cursor_blinks = g_value_get_boolean (value); vte_terminal_set_cursor_blinks (VTE_TERMINAL(self->vte_term), self->cursor_blinks); - g_print ("terminal cursor blinks: %d\n", self->cursor_blinks); + debug_printf ("terminal cursor blinks: %d\n", self->cursor_blinks); break; case TILDA_TERMINAL_AUDIBLE_BELL: self->audible_bell = g_value_get_boolean (value); vte_terminal_set_audible_bell (VTE_TERMINAL(self->vte_term), self->audible_bell); - g_print ("terminal audible bell: %d\n", self->audible_bell); + debug_printf ("terminal audible bell: %d\n", self->audible_bell); break; case TILDA_TERMINAL_VISIBLE_BELL: self->visible_bell = g_value_get_boolean (value); vte_terminal_set_visible_bell (VTE_TERMINAL(self->vte_term), self->visible_bell); - g_print ("terminal visible bell: %d\n", self->visible_bell); + debug_printf ("terminal visible bell: %d\n", self->visible_bell); break; case TILDA_TERMINAL_DOUBLE_BUFFERED: self->double_buffered = g_value_get_boolean (value); gtk_widget_set_double_buffered (GTK_WIDGET(self->vte_term), self->double_buffered); - g_print ("terminal double buffered: %d\n", self->double_buffered); + debug_printf ("terminal double buffered: %d\n", self->double_buffered); break; case TILDA_TERMINAL_MOUSE_AUTOHIDE: self->mouse_autohide = g_value_get_boolean (value); vte_terminal_set_mouse_autohide (VTE_TERMINAL(self->vte_term), self->mouse_autohide); - g_print ("terminal mouse autohide: %d\n", self->mouse_autohide); + debug_printf ("terminal mouse autohide: %d\n", self->mouse_autohide); break; default: @@ -353,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; @@ -381,6 +615,10 @@ tilda_terminal_get_property (GObject *object, g_value_set_string (value, self->working_directory); break; + case TILDA_TERMINAL_WEB_BROWSER: + g_value_set_string (value, self->web_browser); + break; + case TILDA_TERMINAL_SCROLLBACK_LINES: g_value_set_int (value, self->scrollback_lines); break; @@ -405,6 +643,10 @@ tilda_terminal_get_property (GObject *object, g_value_set_int (value, self->exit_action); break; + case TILDA_TERMINAL_SCROLLBAR_POSITION: + g_value_set_int (value, self->scrollbar_position); + break; + case TILDA_TERMINAL_SCROLL_BACKGROUND: g_value_set_boolean (value, self->scroll_background); break; @@ -456,8 +698,11 @@ tilda_terminal_constructor (GType type, guint n_construct_properties, GObjectConstructParam *construct_properties) { + debug_enter (); + GObject *obj; TildaTerminal *self; + gint ret; /* Invoke parent constructor */ TildaTerminalClass *klass; @@ -467,22 +712,31 @@ 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 */ gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0); gtk_widget_show (self->scrollbar); + gtk_widget_show (self->vte_term); + gtk_widget_show (self->hbox); + /* Match URL's, etc */ + ret = vte_terminal_match_add (VTE_TERMINAL(self->vte_term), DINGUS1); + vte_terminal_match_set_cursor_type (VTE_TERMINAL(self->vte_term), ret, GDK_HAND2); + ret = vte_terminal_match_add(VTE_TERMINAL(self->vte_term), DINGUS2); + vte_terminal_match_set_cursor_type (VTE_TERMINAL(self->vte_term), ret, GDK_HAND2); /* Connect Signals */ g_signal_connect (G_OBJECT(self->vte_term), "child-exited", - G_CALLBACK(child_exited_cb), self); + G_CALLBACK(tilda_terminal_child_exited_cb), self); g_signal_connect (G_OBJECT(self->vte_term), "eof", - G_CALLBACK(child_exited_cb), self); + G_CALLBACK(tilda_terminal_child_exited_cb), self); + g_signal_connect (G_OBJECT(self->vte_term), "window-title-changed", + G_CALLBACK(tilda_terminal_window_title_changed_cb), self); + g_signal_connect (G_OBJECT(self->vte_term), "button-press-event", + G_CALLBACK(tilda_terminal_button_press_cb), self); tilda_terminal_start_shell (self); tilda_terminal_dbus_register_object (self); @@ -493,6 +747,8 @@ tilda_terminal_constructor (GType type, static void tilda_terminal_dispose (GObject *obj) { + debug_enter (); + TildaTerminal *self = (TildaTerminal *) obj; /* We don't want to run dispose twice, so just return immediately */ @@ -515,14 +771,14 @@ tilda_terminal_dispose (GObject *obj) static void tilda_terminal_finalize (GObject *obj) { + debug_enter (); + TildaTerminal *self = (TildaTerminal *) 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); @@ -538,6 +794,8 @@ static void tilda_terminal_class_init (gpointer g_class, gpointer g_class_data) { + debug_enter (); + GObjectClass *gobject_class = G_OBJECT_CLASS (g_class); TildaTerminalClass *klass = TILDA_TERMINAL_CLASS (g_class); GParamSpec *pspec; @@ -556,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 @@ -567,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); @@ -599,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); @@ -609,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); @@ -619,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); @@ -629,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); @@ -638,9 +884,19 @@ tilda_terminal_class_init (gpointer g_class, TILDA_TERMINAL_WORKING_DIRECTORY, pspec); + pspec = g_param_spec_string ("web-browser", + _("Terminal's web browser command"), + NULL, + NULL, + G_PARAM_READWRITE); + + g_object_class_install_property (gobject_class, + TILDA_TERMINAL_WEB_BROWSER, + 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, @@ -651,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, @@ -663,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, @@ -675,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, @@ -687,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, @@ -699,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, @@ -710,9 +966,21 @@ tilda_terminal_class_init (gpointer g_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); + + 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); @@ -721,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); @@ -731,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, @@ -739,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, @@ -747,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, @@ -755,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, @@ -818,43 +1091,4 @@ tilda_terminal_get_type (void) return type; } -#if 0 - -int main (int argc, char *argv[]) -{ - GObject *tt; - gint test_number = INT_MIN; - gchar *test_string = NULL; - - /* Initialize the GObject type system */ - g_type_init (); - gtk_init (&argc, &argv); - - tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 10, NULL); - g_object_get (G_OBJECT (tt), "number", &test_number, NULL); - g_assert (test_number == 10); - - g_object_unref (G_OBJECT (tt)); - - tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 22, NULL); - g_object_get (G_OBJECT (tt), "number", &test_number, NULL); - g_assert (test_number == 22); - - g_object_set (G_OBJECT (tt), "font", "hello I'm a font"); - g_object_set (G_OBJECT (tt), "font", "Bitstream Vera Sans Mono 13"); - - g_object_get (G_OBJECT (tt), "font", &test_string, NULL); - g_print ("Read Font: %s\n", test_string); - // NOTE: you MUST free the string!!!! - g_free (test_string); - - g_object_set (G_OBJECT (tt), "transparency-percent", 50); - - g_object_unref (G_OBJECT (tt)); - - return 0; -} - -#endif - /* vim: set ts=4 sts=4 sw=4 noet tw=112: */