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_term (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.
692 * TODO: This is the place to do DBus-init */
693 self = TILDA_TERMINAL(obj);
695 /* Pack into the hbox */
696 gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0);
697 gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0);
698 gtk_widget_show (self->scrollbar);
699 gtk_widget_show (self->vte_term);
700 gtk_widget_show (self->hbox);
702 /* Match URL's, etc */
703 ret = vte_terminal_match_add (VTE_TERMINAL(self->vte_term), DINGUS1);
704 vte_terminal_match_set_cursor_type (VTE_TERMINAL(self->vte_term), ret, GDK_HAND2);
705 ret = vte_terminal_match_add(VTE_TERMINAL(self->vte_term), DINGUS2);
706 vte_terminal_match_set_cursor_type (VTE_TERMINAL(self->vte_term), ret, GDK_HAND2);
708 /* Connect Signals */
709 g_signal_connect (G_OBJECT(self->vte_term), "child-exited",
710 G_CALLBACK(tilda_terminal_child_exited_cb), self);
711 g_signal_connect (G_OBJECT(self->vte_term), "eof",
712 G_CALLBACK(tilda_terminal_child_exited_cb), self);
713 g_signal_connect (G_OBJECT(self->vte_term), "window-title-changed",
714 G_CALLBACK(tilda_terminal_window_title_changed_cb), self);
715 g_signal_connect (G_OBJECT(self->vte_term), "button-press-event",
716 G_CALLBACK(tilda_terminal_button_press_cb), self);
718 tilda_terminal_start_shell (self);
719 tilda_terminal_dbus_register_object (self);
725 tilda_terminal_dispose (GObject *obj)
729 TildaTerminal *self = (TildaTerminal *) obj;
731 /* We don't want to run dispose twice, so just return immediately */
732 if (self->dispose_has_run)
735 self->dispose_has_run = TRUE;
738 * In dispose, you are supposed to free all types referenced from this
739 * object which might themselves hold a reference to self. Generally,
740 * the most simple solution is to unref all members on which you own a
744 /* Chain up to the parent class */
745 G_OBJECT_CLASS (parent_class)->dispose (obj);
749 tilda_terminal_finalize (GObject *obj)
753 TildaTerminal *self = (TildaTerminal *) obj;
756 * Here, complete object destruction.
757 * You might not need to do much...
760 // TODO: g_free() any primitives here
761 g_free (self->background_image);
762 g_free (self->shell);
764 g_free (self->title);
765 g_free (self->working_directory);
768 /* Chain up to the parent class */
769 G_OBJECT_CLASS (parent_class)->finalize (obj);
773 tilda_terminal_class_init (gpointer g_class,
774 gpointer g_class_data)
778 GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
779 TildaTerminalClass *klass = TILDA_TERMINAL_CLASS (g_class);
782 /* Hook our functions to this type */
783 gobject_class->set_property = tilda_terminal_set_property;
784 gobject_class->get_property = tilda_terminal_get_property;
785 gobject_class->dispose = tilda_terminal_dispose;
786 gobject_class->finalize = tilda_terminal_finalize;
787 gobject_class->constructor = tilda_terminal_constructor;
789 parent_class = g_type_class_peek_parent (klass);
791 /* Hook the TildaTerminal type into DBus */
792 dbus_g_object_type_install_info (tilda_terminal_get_type(), &dbus_glib_tilda_terminal_object_info);
794 /* Install all of the properties */
795 pspec = g_param_spec_int ("number",
797 "Set terminal's number",
799 INT_MAX, // max value
801 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
803 g_object_class_install_property (gobject_class,
804 TILDA_TERMINAL_NUMBER,
807 pspec = g_param_spec_pointer ("parent-window",
808 "Pointer to terminal's parent TildaWindow",
809 "Set the pointer to the terminal's parent TildaWindow",
810 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
812 g_object_class_install_property (gobject_class,
813 TILDA_TERMINAL_PARENT_WINDOW,
816 pspec = g_param_spec_string ("background-image",
817 "Terminal's background image",
818 "Get/Set terminal's background image",
822 g_object_class_install_property (gobject_class,
823 TILDA_TERMINAL_BACKGROUND_IMAGE,
826 pspec = g_param_spec_string ("shell",
828 "Get/Set terminal's shell",
832 g_object_class_install_property (gobject_class,
833 TILDA_TERMINAL_SHELL,
836 pspec = g_param_spec_string ("font",
838 "Get/Set terminal's font",
842 g_object_class_install_property (gobject_class,
846 pspec = g_param_spec_string ("title",
848 "Get/Set terminal's title",
852 g_object_class_install_property (gobject_class,
853 TILDA_TERMINAL_TITLE,
856 pspec = g_param_spec_string ("working-directory",
857 "Terminal's initial working directory",
858 "Get/Set terminal's initial working directory",
862 g_object_class_install_property (gobject_class,
863 TILDA_TERMINAL_WORKING_DIRECTORY,
866 pspec = g_param_spec_string ("web-browser",
867 "Terminal's web browser command",
872 g_object_class_install_property (gobject_class,
873 TILDA_TERMINAL_WEB_BROWSER,
876 pspec = g_param_spec_int ("scrollback-lines",
877 "Terminal's scrollback amount (lines)",
878 "Get/Set terminal's scrollback amount",
880 INT_MAX, // TODO: artificially limit this?
884 g_object_class_install_property (gobject_class,
885 TILDA_TERMINAL_SCROLLBACK_LINES,
888 pspec = g_param_spec_int ("transparency-percent",
889 "Terminal's transparency (percent)",
890 "Get/Set terminal's transparency",
896 g_object_class_install_property (gobject_class,
897 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
900 pspec = g_param_spec_int ("backspace-binding",
901 "Terminal's backspace binding",
902 "Get/Set terminal's backspace key binding",
904 VTE_ERASE_DELETE_SEQUENCE,
908 g_object_class_install_property (gobject_class,
909 TILDA_TERMINAL_BACKSPACE_BINDING,
912 pspec = g_param_spec_int ("delete-binding",
913 "Terminal's delete binding",
914 "Get/Set terminal's delete key binding",
916 VTE_ERASE_DELETE_SEQUENCE,
920 g_object_class_install_property (gobject_class,
921 TILDA_TERMINAL_DELETE_BINDING,
924 pspec = g_param_spec_int ("dynamic-title",
925 "Terminal's dynamic title generation method",
926 "Get/Set terminal's dynamic title generation method",
932 g_object_class_install_property (gobject_class,
933 TILDA_TERMINAL_DYNAMIC_TITLE,
936 pspec = g_param_spec_int ("exit-action",
937 "Terminal's action upon child exit",
938 "Get/Set terminal's action upon child exit",
944 g_object_class_install_property (gobject_class,
945 TILDA_TERMINAL_EXIT_ACTION,
948 pspec = g_param_spec_int ("scrollbar-position",
949 "Terminal's scrollbar position",
956 g_object_class_install_property (gobject_class,
957 TILDA_TERMINAL_SCROLLBAR_POSITION,
960 pspec = g_param_spec_boolean ("scroll-background",
961 "Controls terminal's scrolling behavior",
962 "Get/Set terminal's scrolling behavior",
966 g_object_class_install_property (gobject_class,
967 TILDA_TERMINAL_SCROLL_BACKGROUND,
970 pspec = g_param_spec_boolean ("scroll-on-output",
971 "Controls terminal's scrolling behavior on output",
972 "Get/Set terminal's scrolling behavior on output",
976 g_object_class_install_property (gobject_class,
977 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
980 pspec = g_param_spec_boolean ("scroll-on-keystroke",
981 "Controls the terminal's scrolling behavior on keystroke",
982 NULL, FALSE, G_PARAM_READWRITE);
984 g_object_class_install_property (gobject_class,
985 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
988 pspec = g_param_spec_boolean ("antialiased",
989 "Attempt to antialias fonts",
990 NULL, FALSE, G_PARAM_READWRITE);
992 g_object_class_install_property (gobject_class,
993 TILDA_TERMINAL_ANTIALIASED,
996 pspec = g_param_spec_boolean ("allow-bold-text",
998 NULL, FALSE, G_PARAM_READWRITE);
1000 g_object_class_install_property (gobject_class,
1001 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
1004 pspec = g_param_spec_boolean ("cursor-blinks",
1005 NULL, NULL, FALSE, G_PARAM_READWRITE);
1007 g_object_class_install_property (gobject_class,
1008 TILDA_TERMINAL_CURSOR_BLINKS,
1011 pspec = g_param_spec_boolean ("audible-bell",
1012 NULL, NULL, FALSE, G_PARAM_READWRITE);
1014 g_object_class_install_property (gobject_class,
1015 TILDA_TERMINAL_AUDIBLE_BELL,
1018 pspec = g_param_spec_boolean ("visible-bell",
1019 NULL, NULL, FALSE, G_PARAM_READWRITE);
1021 g_object_class_install_property (gobject_class,
1022 TILDA_TERMINAL_VISIBLE_BELL,
1025 pspec = g_param_spec_boolean ("double-buffered",
1026 NULL, 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 NULL, NULL, FALSE, G_PARAM_READWRITE);
1035 g_object_class_install_property (gobject_class,
1036 TILDA_TERMINAL_MOUSE_AUTOHIDE,
1041 tilda_terminal_get_type (void)
1043 static GType type = 0;
1047 static const GTypeInfo info = {
1048 sizeof (TildaTerminalClass),
1049 NULL, /* base_init */
1050 NULL, /* base_finalize */
1051 tilda_terminal_class_init, /* class_init */
1052 NULL, /* class_finalize */
1053 NULL, /* class_data */
1054 sizeof (TildaTerminal),
1055 0, /* n_preallocs */
1056 tilda_terminal_instance_init, /* instance_init */
1059 type = g_type_register_static (G_TYPE_OBJECT,
1060 "TildaTerminalType",
1068 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */