2 #include "tilda-terminal.h"
3 #include "tilda-terminal-dbus-glue.h"
5 #define DINGUS1 "(((news|telnet|nttp|file|http|ftp|https)://)|(www|ftp)[-A-Za-z0-9]*\\.)[-A-Za-z0-9\\.]+(:[0-9]*)?"
6 #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_\\$\\.\\+\\!\\*\\(\\),;:@&=\\?/~\\#\\%]*[^]'\\.}>\\) ,\\\"]"
10 tilda_terminal_dbus_register_object (TildaTerminal *tt)
13 debug_assert (TILDA_IS_TERMINAL(tt));
15 TildaWindow *parent_window = TILDA_WINDOW(tt->parent_window);
18 // Register this object with DBus
19 object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d/Terminal%d",
20 parent_window->number, tt->number);
21 dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tt));
26 * Start the current tt->shell in the given TildaTerminal
27 * NOTE: this will kill whatever is running in the terminal,
28 * NOTE: and run the current tt->shell instead :)
29 * Return: TRUE if ok, FALSE otherwise
32 tilda_terminal_start_shell (TildaTerminal *tt)
35 debug_assert (TILDA_IS_TERMINAL(tt));
42 /* Launch a custom command if tt->shell is set (not NULL) */
45 /* Try to parse the user's custom command */
46 ret = g_shell_parse_argv (tt->shell, &argc, &argv, &error);
50 g_printerr (_("Problem parsing custom command: %s\n"), error->message);
51 g_printerr (_("Launching default shell instead\n"));
54 goto launch_default_shell;
57 /* Try to start the user's custom command */
58 ret = vte_terminal_fork_command (VTE_TERMINAL(tt->vte_term),
59 argv[0], /* Command */
60 argv, /* Arg Vector */
61 NULL, /* Env Vector */
62 tt->working_directory, /* Start directory */
63 TRUE, /* Add to lastlog */
64 TRUE, /* Add to utmp */
65 TRUE); /* Add to wtmp */
72 g_printerr (_("Unable to launch custom command: %s\n"), tt->shell);
73 g_printerr (_("Launching default shell instead\n"));
75 goto launch_default_shell;
78 return TRUE; /* SUCCESS: the early way out */
83 ret = vte_terminal_fork_command (VTE_TERMINAL(tt->vte_term),
84 NULL, /* Command -- VTE will figure it out */
85 NULL, /* Arg Vector */
86 NULL, /* Env Vector */
87 tt->working_directory, /* Start Directory */
88 TRUE, /* Add to lastlog */
89 TRUE, /* Add to utmp */
90 TRUE);/* Add to wtmp */
94 g_printerr (_("Unable to launch default shell\n"));
102 * Called when the child process running in the VteTerminal exits.
105 tilda_terminal_child_exited_cb (GtkWidget *widget, gpointer data)
108 debug_assert (GTK_IS_WIDGET(widget));
109 debug_assert (TILDA_IS_TERMINAL(data));
111 TildaTerminal *self = TILDA_TERMINAL(data);
113 /* These can stay here. They don't need to go into a header because
114 * they are only used at this point in the code. */
115 enum exit_actions { HOLD_TERMINAL_OPEN, RESTART_COMMAND, EXIT_TERMINAL };
117 /* Check the user's preference for what to do when the child terminal
118 * is closed. Take the appropriate action */
119 switch (self->exit_action)
122 tilda_window_remove_terminal (TILDA_WINDOW(self->parent_window), self->number);
124 case RESTART_COMMAND:
125 vte_terminal_feed (VTE_TERMINAL(self->vte_term), "\r\n\r\n", 4);
126 tilda_terminal_start_shell (self);
128 case HOLD_TERMINAL_OPEN:
136 * Called when the child window title changes. Determines if a new
137 * title needs to be put into the notebook's tab label.
140 tilda_terminal_window_title_changed_cb (GtkWidget *widget, gpointer data)
143 debug_assert (GTK_IS_WIDGET(widget));
144 debug_assert (TILDA_IS_TERMINAL(data));
146 TildaTerminal *self = TILDA_TERMINAL(data);
147 TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
149 const gchar *vte_title;
152 enum dynamic_titles { NOT_DISPLAYED, AFTER_INITIAL, BEFORE_INITIAL, REPLACE_INITIAL };
153 label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(parent_window->notebook), self->hbox);
155 /* If we aren't using a dynamic title -- NOT_DISPLAYED -- then just
156 * set it to the static title and exit */
157 if (!self->dynamic_title)
159 gtk_label_set_text (GTK_LABEL(label), self->title);
163 /* Get the title from VTE */
164 vte_title = vte_terminal_get_window_title (VTE_TERMINAL (widget));
166 /* Take the appropriate action */
167 switch (self->dynamic_title)
169 case REPLACE_INITIAL:
170 new_title = g_strdup (vte_title);
174 new_title = g_strdup_printf ("%s - %s", vte_title, self->title);
178 new_title = g_strdup_printf ("%s - %s", self->title, vte_title);
182 debug_printf ("ERROR: Bad value of self->dynamic_title\n");
184 new_title = g_strdup(self->title);
188 gtk_label_set_text (GTK_LABEL(label), new_title);
193 * Gets called whenever there is a button-press event in the VteTerminal. It
194 * is used to open the user's web browser, for example.
197 tilda_terminal_button_press_cb (GtkWidget *widget,
198 GdkEventButton *event,
202 debug_assert (GTK_IS_WIDGET(widget));
203 debug_assert (TILDA_IS_TERMINAL(data));
204 debug_printf ("event->button = %d\n", event->button);
206 GError *error = NULL;
207 TildaTerminal *self = TILDA_TERMINAL(data);
208 VteTerminal *terminal = VTE_TERMINAL(self->vte_term);
209 gint tag, xpad, ypad;
210 gchar *match, *cmd, *web_browser_cmd;
211 gboolean ret = FALSE;
213 switch (event->button)
215 case 3: /* Right Click */
216 // FIXME: need to add this
217 //popup_menu (tt->tw, tt);
218 g_print ("FIXME: popup_menu() here\n");
221 case 2: /* Middle Click */
224 case 1: /* Left Click */
225 vte_terminal_get_padding (terminal, &xpad, &ypad);
226 match = vte_terminal_match_check (terminal,
227 (event->x - ypad) / terminal->char_width,
228 (event->y - ypad) / terminal->char_height,
231 /* Check if we can launch a web browser, and do so if possible */
232 if ((event->state & GDK_CONTROL_MASK) && match != NULL)
234 web_browser_cmd = g_strescape (self->web_browser, NULL);
235 cmd = g_strdup_printf ("%s %s", web_browser_cmd, match);
237 debug_printf ("Got a Ctrl+Left-Click -- match: '%s' tag: %d\n", match, tag);
238 debug_printf ("Launching command: '%s'\n", cmd);
240 ret = g_spawn_command_line_async(cmd, &error);
242 /* Check that the command launched */
245 g_printerr (_("Failed to launch web browser command: `%s'\n"), cmd);
246 g_printerr (_("Error message: %s\n"), error->message);
249 /* Free allocated memory */
250 g_free (web_browser_cmd);
254 /* Always free match if it is non NULL */
266 * Set the given TildaTerminal to the appropriate transparency level
267 * based on the self->transparency_percent member. */
269 tilda_terminal_set_transparent (TildaTerminal *self)
272 debug_assert (TILDA_IS_TERMINAL(self));
274 TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
277 /* Convert the transparency to VTE's format */
278 temp = ((gdouble) self->transparency_percent) / 100.0;
280 if (self->transparency_percent > 0)
282 vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), temp);
283 vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), (1.0 - temp) * 0xffff);
285 /* Use fake transparency if necessary */
286 vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term),
287 !parent_window->have_real_transparency);
291 /* Turn off transparency */
292 vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), 0);
293 vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), 0xffff);
294 vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term), FALSE);
298 * Set the scrollbar position of the given TildaTerminal to
299 * the value in self->scrollbar_position.
302 tilda_terminal_set_scrollbar_position (TildaTerminal *self)
305 debug_assert (TILDA_IS_TERMINAL(self));
307 enum scrollbar_positions { DISABLED, LEFT, RIGHT };
308 switch (self->scrollbar_position)
311 gtk_box_reorder_child (GTK_BOX(self->hbox), self->scrollbar, 0);
312 gtk_widget_show (self->scrollbar);
316 gtk_box_reorder_child (GTK_BOX(self->hbox), self->scrollbar, 1);
317 gtk_widget_show (self->scrollbar);
321 debug_printf ("ERROR: Bad scrollbar position\n");
323 gtk_widget_hide (self->scrollbar);
328 /*******************************************************************************
329 * All GObject stuff is below. You probably don't need to change this...
330 ******************************************************************************/
332 static GObjectClass *parent_class = NULL;
334 enum tilda_terminal_properties {
335 TILDA_TERMINAL_NUMBER = 1,
336 TILDA_TERMINAL_PARENT_WINDOW,
338 /* All non-constructor-only properties */
339 TILDA_TERMINAL_BACKGROUND_IMAGE,
340 TILDA_TERMINAL_SHELL,
342 TILDA_TERMINAL_TITLE,
343 TILDA_TERMINAL_WORKING_DIRECTORY,
344 TILDA_TERMINAL_WEB_BROWSER,
346 TILDA_TERMINAL_SCROLLBACK_LINES,
347 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
349 TILDA_TERMINAL_BACKSPACE_BINDING,
350 TILDA_TERMINAL_DELETE_BINDING,
351 TILDA_TERMINAL_DYNAMIC_TITLE,
352 TILDA_TERMINAL_EXIT_ACTION,
353 TILDA_TERMINAL_SCROLLBAR_POSITION,
355 TILDA_TERMINAL_SCROLL_BACKGROUND,
356 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
357 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
358 TILDA_TERMINAL_ANTIALIASED,
359 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
360 TILDA_TERMINAL_CURSOR_BLINKS,
361 TILDA_TERMINAL_AUDIBLE_BELL,
362 TILDA_TERMINAL_VISIBLE_BELL,
363 TILDA_TERMINAL_DOUBLE_BUFFERED,
364 TILDA_TERMINAL_MOUSE_AUTOHIDE,
368 tilda_terminal_instance_init (GTypeInstance *instance,
373 TildaTerminal *self = (TildaTerminal *) instance;
375 /* Initialize instance members and allocate any necessary memory here.
376 * NOTE: any constructor-time values will be set later. */
377 self->dispose_has_run = FALSE;
380 self->vte_term = vte_terminal_new ();
381 self->scrollbar = gtk_vscrollbar_new (VTE_TERMINAL(self->vte_term)->adjustment);
382 self->hbox = gtk_hbox_new (FALSE, 0);
386 tilda_terminal_set_property (GObject *object,
391 TildaTerminal *self = (TildaTerminal *) object;
393 switch (property_id) {
395 case TILDA_TERMINAL_NUMBER:
396 self->number = g_value_get_int (value);
397 debug_printf ("terminal number: %d\n", self->number);
400 case TILDA_TERMINAL_PARENT_WINDOW:
401 self->parent_window = g_value_get_pointer (value);
402 debug_printf ("terminal parent window: 0x%x\n", self->parent_window);
405 case TILDA_TERMINAL_BACKGROUND_IMAGE:
406 g_free (self->background_image);
407 self->background_image = g_value_dup_string (value);
408 vte_terminal_set_background_image_file (VTE_TERMINAL(self->vte_term), self->background_image);
409 debug_printf ("terminal back img: %s\n", self->background_image);
412 case TILDA_TERMINAL_SHELL:
413 g_free (self->shell);
414 self->shell = g_value_dup_string (value);
415 tilda_terminal_start_shell (self);
416 debug_printf ("terminal shell: %s\n", self->shell);
419 case TILDA_TERMINAL_FONT:
421 self->font = g_value_dup_string (value);
422 vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
425 debug_printf ("terminal font: %s\n", self->font);
428 case TILDA_TERMINAL_TITLE:
429 g_free (self->title);
430 self->title = g_value_dup_string (value);
431 debug_printf ("terminal title: %s\n", self->title);
434 case TILDA_TERMINAL_WORKING_DIRECTORY:
435 g_free (self->working_directory);
436 self->working_directory = g_value_dup_string (value);
437 debug_printf ("terminal wrk dir: %s\n", self->working_directory);
440 case TILDA_TERMINAL_WEB_BROWSER:
441 g_free (self->web_browser);
442 self->web_browser = g_value_dup_string (value);
443 debug_printf ("terminal web browser: %s\n", self->web_browser);
446 case TILDA_TERMINAL_SCROLLBACK_LINES:
447 self->scrollback_lines = g_value_get_int (value);
448 vte_terminal_set_scrollback_lines (VTE_TERMINAL(self->vte_term), self->scrollback_lines);
449 debug_printf ("terminal scrollback lines: %d\n", self->scrollback_lines);
452 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
453 self->transparency_percent = g_value_get_int (value);
454 tilda_terminal_set_transparent (self);
455 debug_printf ("terminal transp percent: %d\n", self->transparency_percent);
458 case TILDA_TERMINAL_BACKSPACE_BINDING:
459 self->backspace_binding = g_value_get_int (value);
460 vte_terminal_set_backspace_binding (VTE_TERMINAL(self->vte_term), self->backspace_binding);
461 debug_printf ("terminal backspace key: %d\n", self->backspace_binding);
464 case TILDA_TERMINAL_DELETE_BINDING:
465 self->delete_binding = g_value_get_int (value);
466 vte_terminal_set_delete_binding (VTE_TERMINAL(self->vte_term), self->delete_binding);
467 debug_printf ("terminal delete key: %d\n", self->delete_binding);
470 case TILDA_TERMINAL_DYNAMIC_TITLE:
471 self->dynamic_title = g_value_get_int (value);
472 debug_printf ("terminal dynamic title: %d\n", self->dynamic_title);
475 case TILDA_TERMINAL_EXIT_ACTION:
476 self->exit_action = g_value_get_int (value);
477 debug_printf ("terminal exit action: %d\n", self->exit_action);
480 case TILDA_TERMINAL_SCROLLBAR_POSITION:
481 self->scrollbar_position = g_value_get_int (value);
482 tilda_terminal_set_scrollbar_position (self);
483 debug_printf ("terminal scrollbar position: %d\n", self->scrollbar_position);
486 case TILDA_TERMINAL_SCROLL_BACKGROUND:
487 self->scroll_background = g_value_get_boolean (value);
488 vte_terminal_set_scroll_background (VTE_TERMINAL(self->vte_term), self->scroll_background);
489 debug_printf ("terminal scroll background: %d\n", self->scroll_background);
492 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
493 self->scroll_on_output = g_value_get_boolean (value);
494 vte_terminal_set_scroll_on_output (VTE_TERMINAL(self->vte_term), self->scroll_on_output);
495 debug_printf ("terminal scroll on output: %d\n", self->scroll_on_output);
498 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
499 self->scroll_on_keystroke = g_value_get_boolean (value);
500 vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(self->vte_term), self->scroll_on_keystroke);
501 debug_printf ("terminal scroll on keystroke: %d\n", self->scroll_on_keystroke);
504 case TILDA_TERMINAL_ANTIALIASED:
505 self->antialiased = g_value_get_boolean (value);
506 vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
509 debug_printf ("terminal antialiased: %d\n", self->antialiased);
512 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
513 self->allow_bold_text = g_value_get_boolean (value);
514 vte_terminal_set_allow_bold (VTE_TERMINAL(self->vte_term), self->allow_bold_text);
515 debug_printf ("terminal allow bold text: %d\n", self->allow_bold_text);
518 case TILDA_TERMINAL_CURSOR_BLINKS:
519 self->cursor_blinks = g_value_get_boolean (value);
520 vte_terminal_set_cursor_blinks (VTE_TERMINAL(self->vte_term), self->cursor_blinks);
521 debug_printf ("terminal cursor blinks: %d\n", self->cursor_blinks);
524 case TILDA_TERMINAL_AUDIBLE_BELL:
525 self->audible_bell = g_value_get_boolean (value);
526 vte_terminal_set_audible_bell (VTE_TERMINAL(self->vte_term), self->audible_bell);
527 debug_printf ("terminal audible bell: %d\n", self->audible_bell);
530 case TILDA_TERMINAL_VISIBLE_BELL:
531 self->visible_bell = g_value_get_boolean (value);
532 vte_terminal_set_visible_bell (VTE_TERMINAL(self->vte_term), self->visible_bell);
533 debug_printf ("terminal visible bell: %d\n", self->visible_bell);
536 case TILDA_TERMINAL_DOUBLE_BUFFERED:
537 self->double_buffered = g_value_get_boolean (value);
538 gtk_widget_set_double_buffered (GTK_WIDGET(self->vte_term), self->double_buffered);
539 debug_printf ("terminal double buffered: %d\n", self->double_buffered);
542 case TILDA_TERMINAL_MOUSE_AUTOHIDE:
543 self->mouse_autohide = g_value_get_boolean (value);
544 vte_terminal_set_mouse_autohide (VTE_TERMINAL(self->vte_term), self->mouse_autohide);
545 debug_printf ("terminal mouse autohide: %d\n", self->mouse_autohide);
549 /* We don't have this property... */
550 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
556 tilda_terminal_get_property (GObject *object,
561 TildaTerminal *self = (TildaTerminal *) object;
563 switch (property_id) {
565 case TILDA_TERMINAL_NUMBER:
566 g_value_set_int (value, self->number);
569 case TILDA_TERMINAL_PARENT_WINDOW:
570 g_value_set_pointer (value, self->parent_window);
573 case TILDA_TERMINAL_BACKGROUND_IMAGE:
574 g_value_set_string (value, self->background_image);
577 case TILDA_TERMINAL_SHELL:
578 g_value_set_string (value, self->shell);
581 case TILDA_TERMINAL_FONT:
582 g_value_set_string (value, self->font);
585 case TILDA_TERMINAL_TITLE:
586 g_value_set_string (value, self->title);
589 case TILDA_TERMINAL_WORKING_DIRECTORY:
590 g_value_set_string (value, self->working_directory);
593 case TILDA_TERMINAL_WEB_BROWSER:
594 g_value_set_string (value, self->web_browser);
597 case TILDA_TERMINAL_SCROLLBACK_LINES:
598 g_value_set_int (value, self->scrollback_lines);
601 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
602 g_value_set_int (value, self->transparency_percent);
605 case TILDA_TERMINAL_BACKSPACE_BINDING:
606 g_value_set_int (value, self->backspace_binding);
609 case TILDA_TERMINAL_DELETE_BINDING:
610 g_value_set_int (value, self->delete_binding);
613 case TILDA_TERMINAL_DYNAMIC_TITLE:
614 g_value_set_int (value, self->dynamic_title);
617 case TILDA_TERMINAL_EXIT_ACTION:
618 g_value_set_int (value, self->exit_action);
621 case TILDA_TERMINAL_SCROLLBAR_POSITION:
622 g_value_set_int (value, self->scrollbar_position);
625 case TILDA_TERMINAL_SCROLL_BACKGROUND:
626 g_value_set_boolean (value, self->scroll_background);
629 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
630 g_value_set_boolean (value, self->scroll_on_output);
633 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
634 g_value_set_boolean (value, self->scroll_on_keystroke);
637 case TILDA_TERMINAL_ANTIALIASED:
638 g_value_set_boolean (value, self->antialiased);
641 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
642 g_value_set_boolean (value, self->allow_bold_text);
645 case TILDA_TERMINAL_CURSOR_BLINKS:
646 g_value_set_boolean (value, self->cursor_blinks);
649 case TILDA_TERMINAL_AUDIBLE_BELL:
650 g_value_set_boolean (value, self->audible_bell);
653 case TILDA_TERMINAL_VISIBLE_BELL:
654 g_value_set_boolean (value, self->visible_bell);
657 case TILDA_TERMINAL_DOUBLE_BUFFERED:
658 g_value_set_boolean (value, self->double_buffered);
661 case TILDA_TERMINAL_MOUSE_AUTOHIDE:
662 g_value_set_boolean (value, self->mouse_autohide);
665 /* We don't have this property... */
666 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
672 tilda_terminal_constructor (GType type,
673 guint n_construct_properties,
674 GObjectConstructParam *construct_properties)
682 /* Invoke parent constructor */
683 TildaTerminalClass *klass;
684 klass = TILDA_TERMINAL_CLASS (g_type_class_peek (TILDA_TYPE_TERMINAL));
685 obj = parent_class->constructor (type,
686 n_construct_properties,
687 construct_properties);
689 /* Do other stuff here. The object is ready to go now, and all
690 * ctor properties have been set. */
691 self = TILDA_TERMINAL(obj);
693 /* Pack into the hbox */
694 gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0);
695 gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0);
696 gtk_widget_show (self->scrollbar);
697 gtk_widget_show (self->vte_term);
698 gtk_widget_show (self->hbox);
700 /* Match URL's, etc */
701 ret = vte_terminal_match_add (VTE_TERMINAL(self->vte_term), DINGUS1);
702 vte_terminal_match_set_cursor_type (VTE_TERMINAL(self->vte_term), ret, GDK_HAND2);
703 ret = vte_terminal_match_add(VTE_TERMINAL(self->vte_term), DINGUS2);
704 vte_terminal_match_set_cursor_type (VTE_TERMINAL(self->vte_term), ret, GDK_HAND2);
706 /* Connect Signals */
707 g_signal_connect (G_OBJECT(self->vte_term), "child-exited",
708 G_CALLBACK(tilda_terminal_child_exited_cb), self);
709 g_signal_connect (G_OBJECT(self->vte_term), "eof",
710 G_CALLBACK(tilda_terminal_child_exited_cb), self);
711 g_signal_connect (G_OBJECT(self->vte_term), "window-title-changed",
712 G_CALLBACK(tilda_terminal_window_title_changed_cb), self);
713 g_signal_connect (G_OBJECT(self->vte_term), "button-press-event",
714 G_CALLBACK(tilda_terminal_button_press_cb), self);
716 tilda_terminal_start_shell (self);
717 tilda_terminal_dbus_register_object (self);
723 tilda_terminal_dispose (GObject *obj)
727 TildaTerminal *self = (TildaTerminal *) obj;
729 /* We don't want to run dispose twice, so just return immediately */
730 if (self->dispose_has_run)
733 self->dispose_has_run = TRUE;
736 * In dispose, you are supposed to free all types referenced from this
737 * object which might themselves hold a reference to self. Generally,
738 * the most simple solution is to unref all members on which you own a
742 /* Chain up to the parent class */
743 G_OBJECT_CLASS (parent_class)->dispose (obj);
747 tilda_terminal_finalize (GObject *obj)
751 TildaTerminal *self = (TildaTerminal *) obj;
754 * Here, complete object destruction.
755 * You might not need to do much...
757 g_free (self->background_image);
758 g_free (self->shell);
760 g_free (self->title);
761 g_free (self->working_directory);
764 /* Chain up to the parent class */
765 G_OBJECT_CLASS (parent_class)->finalize (obj);
769 tilda_terminal_class_init (gpointer g_class,
770 gpointer g_class_data)
774 GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
775 TildaTerminalClass *klass = TILDA_TERMINAL_CLASS (g_class);
778 /* Hook our functions to this type */
779 gobject_class->set_property = tilda_terminal_set_property;
780 gobject_class->get_property = tilda_terminal_get_property;
781 gobject_class->dispose = tilda_terminal_dispose;
782 gobject_class->finalize = tilda_terminal_finalize;
783 gobject_class->constructor = tilda_terminal_constructor;
785 parent_class = g_type_class_peek_parent (klass);
787 /* Hook the TildaTerminal type into DBus */
788 dbus_g_object_type_install_info (tilda_terminal_get_type(), &dbus_glib_tilda_terminal_object_info);
790 /* Install all of the properties */
791 pspec = g_param_spec_int ("number",
792 _("Terminal number"),
795 INT_MAX, // max value
797 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
799 g_object_class_install_property (gobject_class,
800 TILDA_TERMINAL_NUMBER,
803 pspec = g_param_spec_pointer ("parent-window",
804 _("Pointer to terminal's parent TildaWindow"),
806 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
808 g_object_class_install_property (gobject_class,
809 TILDA_TERMINAL_PARENT_WINDOW,
812 pspec = g_param_spec_string ("background-image",
813 _("Terminal's background image"),
818 g_object_class_install_property (gobject_class,
819 TILDA_TERMINAL_BACKGROUND_IMAGE,
822 pspec = g_param_spec_string ("shell",
823 _("Terminal's shell"),
828 g_object_class_install_property (gobject_class,
829 TILDA_TERMINAL_SHELL,
832 pspec = g_param_spec_string ("font",
833 _("Terminal's font"),
838 g_object_class_install_property (gobject_class,
842 pspec = g_param_spec_string ("title",
843 _("Terminal's title"),
848 g_object_class_install_property (gobject_class,
849 TILDA_TERMINAL_TITLE,
852 pspec = g_param_spec_string ("working-directory",
853 _("Terminal's initial working directory"),
858 g_object_class_install_property (gobject_class,
859 TILDA_TERMINAL_WORKING_DIRECTORY,
862 pspec = g_param_spec_string ("web-browser",
863 _("Terminal's web browser command"),
868 g_object_class_install_property (gobject_class,
869 TILDA_TERMINAL_WEB_BROWSER,
872 pspec = g_param_spec_int ("scrollback-lines",
873 _("Terminal's scrollback amount (lines)"),
876 INT_MAX, // TODO: artificially limit this?
880 g_object_class_install_property (gobject_class,
881 TILDA_TERMINAL_SCROLLBACK_LINES,
884 pspec = g_param_spec_int ("transparency-percent",
885 _("Terminal's transparency (percent)"),
892 g_object_class_install_property (gobject_class,
893 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
896 pspec = g_param_spec_int ("backspace-binding",
897 _("Terminal's backspace binding"),
900 VTE_ERASE_DELETE_SEQUENCE,
904 g_object_class_install_property (gobject_class,
905 TILDA_TERMINAL_BACKSPACE_BINDING,
908 pspec = g_param_spec_int ("delete-binding",
909 _("Terminal's delete binding"),
912 VTE_ERASE_DELETE_SEQUENCE,
916 g_object_class_install_property (gobject_class,
917 TILDA_TERMINAL_DELETE_BINDING,
920 pspec = g_param_spec_int ("dynamic-title",
921 _("Terminal's dynamic title generation method"),
928 g_object_class_install_property (gobject_class,
929 TILDA_TERMINAL_DYNAMIC_TITLE,
932 pspec = g_param_spec_int ("exit-action",
933 _("Terminal's action upon child exit"),
940 g_object_class_install_property (gobject_class,
941 TILDA_TERMINAL_EXIT_ACTION,
944 pspec = g_param_spec_int ("scrollbar-position",
945 _("Terminal's scrollbar position"),
952 g_object_class_install_property (gobject_class,
953 TILDA_TERMINAL_SCROLLBAR_POSITION,
956 pspec = g_param_spec_boolean ("scroll-background",
957 _("Controls terminal's scrolling behavior"),
962 g_object_class_install_property (gobject_class,
963 TILDA_TERMINAL_SCROLL_BACKGROUND,
966 pspec = g_param_spec_boolean ("scroll-on-output",
967 _("Controls terminal's scrolling behavior on output"),
972 g_object_class_install_property (gobject_class,
973 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
976 pspec = g_param_spec_boolean ("scroll-on-keystroke",
977 _("Controls the terminal's scrolling behavior on keystroke"),
978 NULL, FALSE, G_PARAM_READWRITE);
980 g_object_class_install_property (gobject_class,
981 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
984 pspec = g_param_spec_boolean ("antialiased",
985 _("Attempt to antialias fonts"),
986 NULL, FALSE, G_PARAM_READWRITE);
988 g_object_class_install_property (gobject_class,
989 TILDA_TERMINAL_ANTIALIASED,
992 pspec = g_param_spec_boolean ("allow-bold-text",
993 _("Allow bold text"),
994 NULL, FALSE, G_PARAM_READWRITE);
996 g_object_class_install_property (gobject_class,
997 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
1000 pspec = g_param_spec_boolean ("cursor-blinks",
1001 _("Enable cursor blinking"),
1002 NULL, FALSE, G_PARAM_READWRITE);
1004 g_object_class_install_property (gobject_class,
1005 TILDA_TERMINAL_CURSOR_BLINKS,
1008 pspec = g_param_spec_boolean ("audible-bell",
1009 _("Enable the audible bell"),
1010 NULL, FALSE, G_PARAM_READWRITE);
1012 g_object_class_install_property (gobject_class,
1013 TILDA_TERMINAL_AUDIBLE_BELL,
1016 pspec = g_param_spec_boolean ("visible-bell",
1017 _("Enable the visible bell"),
1018 NULL, FALSE, G_PARAM_READWRITE);
1020 g_object_class_install_property (gobject_class,
1021 TILDA_TERMINAL_VISIBLE_BELL,
1024 pspec = g_param_spec_boolean ("double-buffered",
1025 _("Double buffer the terminal"),
1026 NULL, FALSE, G_PARAM_READWRITE);
1028 g_object_class_install_property (gobject_class,
1029 TILDA_TERMINAL_DOUBLE_BUFFERED,
1032 pspec = g_param_spec_boolean ("mouse-autohide",
1033 _("Hide the mouse cursor while typing"),
1034 NULL, FALSE, G_PARAM_READWRITE);
1036 g_object_class_install_property (gobject_class,
1037 TILDA_TERMINAL_MOUSE_AUTOHIDE,
1042 tilda_terminal_get_type (void)
1044 static GType type = 0;
1048 static const GTypeInfo info = {
1049 sizeof (TildaTerminalClass),
1050 NULL, /* base_init */
1051 NULL, /* base_finalize */
1052 tilda_terminal_class_init, /* class_init */
1053 NULL, /* class_finalize */
1054 NULL, /* class_data */
1055 sizeof (TildaTerminal),
1056 0, /* n_preallocs */
1057 tilda_terminal_instance_init, /* instance_init */
1060 type = g_type_register_static (G_TYPE_OBJECT,
1061 "TildaTerminalType",
1069 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */