2 #include "tilda-terminal.h"
3 #include "tilda-terminal-dbus-glue.h"
5 // FIXME: temporary helpers for gettext
11 tilda_terminal_dbus_register_object (TildaTerminal *tt)
15 // Register this object with DBus
16 object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d/Terminal%d",
17 tt->window_number, tt->number);
18 dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tt));
23 * Start the current tt->shell in the given TildaTerminal
24 * NOTE: this will kill whatever is running in the terminal,
25 * NOTE: and run the current tt->shell instead :)
26 * Return: TRUE if ok, FALSE otherwise
29 tilda_terminal_start_shell (TildaTerminal *tt)
36 /* Launch a custom command if tt->shell is set (not NULL) */
39 /* Try to parse the user's custom command */
40 ret = g_shell_parse_argv (tt->shell, &argc, &argv, &error);
44 g_printerr (_("Problem parsing custom command: %s\n"), error->message);
45 g_printerr (_("Launching default shell instead\n"));
48 goto launch_default_shell;
51 /* Try to start the user's custom command */
52 ret = vte_terminal_fork_command (VTE_TERMINAL(tt->vte_term),
53 argv[0], /* Command */
54 argv, /* Arg Vector */
55 NULL, /* Env Vector */
56 tt->working_directory, /* Start directory */
57 TRUE, /* Add to lastlog */
58 TRUE, /* Add to utmp */
59 TRUE); /* Add to wtmp */
66 g_printerr (_("Unable to launch custom command: %s\n"), tt->shell);
67 g_printerr (_("Launching default shell instead\n"));
69 goto launch_default_shell;
72 return TRUE; /* SUCCESS: the early way out */
77 ret = vte_terminal_fork_command (VTE_TERMINAL(tt->vte_term),
78 NULL, /* Command -- VTE will figure it out */
79 NULL, /* Arg Vector */
80 NULL, /* Env Vector */
81 tt->working_directory, /* Start Directory */
82 TRUE, /* Add to lastlog */
83 TRUE, /* Add to utmp */
84 TRUE);/* Add to wtmp */
88 g_printerr (_("Unable to launch default shell\n"));
96 * Called when the child process running in the VteTerminal exits.
99 tilda_terminal_child_exited_cb (GtkWidget *widget, gpointer data)
101 TildaTerminal *self = TILDA_TERMINAL(data);
103 /* These can stay here. They don't need to go into a header because
104 * they are only used at this point in the code. */
105 enum exit_actions { HOLD_TERMINAL_OPEN, RESTART_COMMAND, EXIT_TERMINAL };
107 /* Check the user's preference for what to do when the child terminal
108 * is closed. Take the appropriate action */
109 switch (self->exit_action)
112 tilda_window_remove_term (TILDA_WINDOW(self->parent_window), self->number);
114 case RESTART_COMMAND:
115 vte_terminal_feed (VTE_TERMINAL(self->vte_term), "\r\n\r\n", 4);
116 tilda_terminal_start_shell (self);
118 case HOLD_TERMINAL_OPEN:
126 * Called when the child window title changes. Determines if a new
127 * title needs to be put into the notebook's tab label.
130 tilda_terminal_window_title_changed_cb (GtkWidget *widget, gpointer data)
132 TildaTerminal *self = TILDA_TERMINAL(data);
133 TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
135 const gchar *vte_title;
138 enum dynamic_titles { NOT_DISPLAYED, AFTER_INITIAL, BEFORE_INITIAL, REPLACE_INITIAL };
139 label = gtk_notebook_get_tab_label (GTK_NOTEBOOK(parent_window->notebook), self->hbox);
141 /* If we aren't using a dynamic title -- NOT_DISPLAYED -- then just
142 * set it to the static title and exit */
143 if (!self->dynamic_title)
145 gtk_label_set_text (GTK_LABEL(label), self->title);
149 /* Get the title from VTE */
150 vte_title = vte_terminal_get_window_title (VTE_TERMINAL (widget));
152 /* Take the appropriate action */
153 switch (self->dynamic_title)
155 case REPLACE_INITIAL:
156 new_title = g_strdup (vte_title);
160 new_title = g_strdup_printf ("%s - %s", vte_title, self->title);
164 new_title = g_strdup_printf ("%s - %s", self->title, vte_title);
169 g_printerr (_("FIXME: Bad value of self->dynamic_title\n"));
170 new_title = g_strdup(self->title);
174 gtk_label_set_text (GTK_LABEL(label), new_title);
179 * Set the given TildaTerminal to the appropriate transparency level
180 * based on the self->transparency_percent member. */
182 tilda_terminal_set_transparent (TildaTerminal *self)
184 TildaWindow *parent_window = TILDA_WINDOW(self->parent_window);
187 /* Convert the transparency to VTE's format */
188 temp = ((gdouble) self->transparency_percent) / 100.0;
190 if (self->transparency_percent > 0)
192 vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), temp);
193 vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), (1.0 - temp) * 0xffff);
195 /* Use fake transparency if necessary */
196 vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term),
197 !parent_window->have_real_transparency);
201 /* Turn off transparency */
202 vte_terminal_set_background_saturation (VTE_TERMINAL(self->vte_term), 0);
203 vte_terminal_set_opacity (VTE_TERMINAL(self->vte_term), 0xffff);
204 vte_terminal_set_background_transparent (VTE_TERMINAL(self->vte_term), FALSE);
207 /*******************************************************************************
208 * All GObject stuff is below. You probably don't need to change this...
209 ******************************************************************************/
211 static GObjectClass *parent_class = NULL;
213 enum tilda_terminal_properties {
214 TILDA_TERMINAL_NUMBER = 1,
215 TILDA_TERMINAL_WINDOW_NUMBER,
218 /* All non-constructor-only properties */
219 TILDA_TERMINAL_BACKGROUND_IMAGE,
220 TILDA_TERMINAL_SHELL,
222 TILDA_TERMINAL_TITLE,
223 TILDA_TERMINAL_WORKING_DIRECTORY,
224 TILDA_TERMINAL_WEB_BROWSER,
226 TILDA_TERMINAL_SCROLLBACK_LINES,
227 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
229 TILDA_TERMINAL_BACKSPACE_BINDING,
230 TILDA_TERMINAL_DELETE_BINDING,
231 TILDA_TERMINAL_DYNAMIC_TITLE,
232 TILDA_TERMINAL_EXIT_ACTION,
234 TILDA_TERMINAL_SCROLL_BACKGROUND,
235 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
236 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
237 TILDA_TERMINAL_ANTIALIASED,
238 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
239 TILDA_TERMINAL_CURSOR_BLINKS,
240 TILDA_TERMINAL_AUDIBLE_BELL,
241 TILDA_TERMINAL_VISIBLE_BELL,
242 TILDA_TERMINAL_DOUBLE_BUFFERED,
243 TILDA_TERMINAL_MOUSE_AUTOHIDE,
247 tilda_terminal_instance_init (GTypeInstance *instance,
250 TildaTerminal *self = (TildaTerminal *) instance;
252 /* Initialize instance members and allocate any necessary memory here.
253 * NOTE: any constructor-time values will be set later. */
254 self->dispose_has_run = FALSE;
257 self->vte_term = vte_terminal_new ();
258 self->scrollbar = gtk_vscrollbar_new (VTE_TERMINAL(self->vte_term)->adjustment);
259 self->hbox = gtk_hbox_new (FALSE, 0);
263 tilda_terminal_set_property (GObject *object,
268 TildaTerminal *self = (TildaTerminal *) object;
270 switch (property_id) {
272 case TILDA_TERMINAL_NUMBER:
273 self->number = g_value_get_int (value);
274 g_print ("terminal number: %d\n", self->number);
277 case TILDA_TERMINAL_WINDOW_NUMBER:
278 self->window_number = g_value_get_int (value);
279 g_print ("terminal parent window number: %d\n", self->window_number);
282 case TILDA_TERMINAL_TW:
283 self->parent_window = g_value_get_pointer (value);
284 g_print ("terminal parent window: 0x%x\n", self->parent_window);
285 g_print ("terminal parent window number (direct): %d\n", TILDA_WINDOW(self->parent_window)->number);
288 case TILDA_TERMINAL_BACKGROUND_IMAGE:
289 g_free (self->background_image);
290 self->background_image = g_value_dup_string (value);
291 vte_terminal_set_background_image_file (VTE_TERMINAL(self->vte_term), self->background_image);
292 g_print ("terminal back img: %s\n", self->background_image);
295 case TILDA_TERMINAL_SHELL:
296 g_free (self->shell);
297 self->shell = g_value_dup_string (value);
298 tilda_terminal_start_shell (self);
299 g_print ("terminal shell: %s\n", self->shell);
302 case TILDA_TERMINAL_FONT:
304 self->font = g_value_dup_string (value);
305 vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
308 g_print ("terminal font: %s\n", self->font);
311 case TILDA_TERMINAL_TITLE:
312 g_free (self->title);
313 self->title = g_value_dup_string (value);
314 g_print ("terminal title: %s\n", self->title);
317 case TILDA_TERMINAL_WORKING_DIRECTORY:
318 g_free (self->working_directory);
319 self->working_directory = g_value_dup_string (value);
320 g_print ("terminal wrk dir: %s\n", self->working_directory);
323 case TILDA_TERMINAL_WEB_BROWSER:
324 g_free (self->web_browser);
325 self->web_browser = g_value_dup_string (value);
326 g_print ("terminal web browser: %s\n", self->web_browser);
329 case TILDA_TERMINAL_SCROLLBACK_LINES:
330 self->scrollback_lines = g_value_get_int (value);
331 vte_terminal_set_scrollback_lines (VTE_TERMINAL(self->vte_term), self->scrollback_lines);
332 g_print ("terminal scrollback lines: %d\n", self->scrollback_lines);
335 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
336 self->transparency_percent = g_value_get_int (value);
337 tilda_terminal_set_transparent (self);
338 g_print ("terminal transp percent: %d\n", self->transparency_percent);
341 case TILDA_TERMINAL_BACKSPACE_BINDING:
342 self->backspace_binding = g_value_get_int (value);
343 vte_terminal_set_backspace_binding (VTE_TERMINAL(self->vte_term), self->backspace_binding);
344 g_print ("terminal backspace key: %d\n", self->backspace_binding);
347 case TILDA_TERMINAL_DELETE_BINDING:
348 self->delete_binding = g_value_get_int (value);
349 vte_terminal_set_delete_binding (VTE_TERMINAL(self->vte_term), self->delete_binding);
350 g_print ("terminal delete key: %d\n", self->delete_binding);
353 case TILDA_TERMINAL_DYNAMIC_TITLE:
354 self->dynamic_title = g_value_get_int (value);
355 g_print ("terminal dynamic title: %d\n", self->dynamic_title);
358 case TILDA_TERMINAL_EXIT_ACTION:
359 self->exit_action = g_value_get_int (value);
360 g_print ("terminal exit action: %d\n", self->exit_action);
363 case TILDA_TERMINAL_SCROLL_BACKGROUND:
364 self->scroll_background = g_value_get_boolean (value);
365 vte_terminal_set_scroll_background (VTE_TERMINAL(self->vte_term), self->scroll_background);
366 g_print ("terminal scroll background: %d\n", self->scroll_background);
369 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
370 self->scroll_on_output = g_value_get_boolean (value);
371 vte_terminal_set_scroll_on_output (VTE_TERMINAL(self->vte_term), self->scroll_on_output);
372 g_print ("terminal scroll on output: %d\n", self->scroll_on_output);
375 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
376 self->scroll_on_keystroke = g_value_get_boolean (value);
377 vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(self->vte_term), self->scroll_on_keystroke);
378 g_print ("terminal scroll on keystroke: %d\n", self->scroll_on_keystroke);
381 case TILDA_TERMINAL_ANTIALIASED:
382 self->antialiased = g_value_get_boolean (value);
383 vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
386 g_print ("terminal antialiased: %d\n", self->antialiased);
389 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
390 self->allow_bold_text = g_value_get_boolean (value);
391 vte_terminal_set_allow_bold (VTE_TERMINAL(self->vte_term), self->allow_bold_text);
392 g_print ("terminal allow bold text: %d\n", self->allow_bold_text);
395 case TILDA_TERMINAL_CURSOR_BLINKS:
396 self->cursor_blinks = g_value_get_boolean (value);
397 vte_terminal_set_cursor_blinks (VTE_TERMINAL(self->vte_term), self->cursor_blinks);
398 g_print ("terminal cursor blinks: %d\n", self->cursor_blinks);
401 case TILDA_TERMINAL_AUDIBLE_BELL:
402 self->audible_bell = g_value_get_boolean (value);
403 vte_terminal_set_audible_bell (VTE_TERMINAL(self->vte_term), self->audible_bell);
404 g_print ("terminal audible bell: %d\n", self->audible_bell);
407 case TILDA_TERMINAL_VISIBLE_BELL:
408 self->visible_bell = g_value_get_boolean (value);
409 vte_terminal_set_visible_bell (VTE_TERMINAL(self->vte_term), self->visible_bell);
410 g_print ("terminal visible bell: %d\n", self->visible_bell);
413 case TILDA_TERMINAL_DOUBLE_BUFFERED:
414 self->double_buffered = g_value_get_boolean (value);
415 gtk_widget_set_double_buffered (GTK_WIDGET(self->vte_term), self->double_buffered);
416 g_print ("terminal double buffered: %d\n", self->double_buffered);
419 case TILDA_TERMINAL_MOUSE_AUTOHIDE:
420 self->mouse_autohide = g_value_get_boolean (value);
421 vte_terminal_set_mouse_autohide (VTE_TERMINAL(self->vte_term), self->mouse_autohide);
422 g_print ("terminal mouse autohide: %d\n", self->mouse_autohide);
426 /* We don't have this property... */
427 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
433 tilda_terminal_get_property (GObject *object,
438 TildaTerminal *self = (TildaTerminal *) object;
440 switch (property_id) {
442 case TILDA_TERMINAL_NUMBER:
443 g_value_set_int (value, self->number);
446 case TILDA_TERMINAL_WINDOW_NUMBER:
447 g_value_set_int (value, self->window_number);
450 case TILDA_TERMINAL_TW:
451 g_value_set_pointer (value, self->parent_window);
454 case TILDA_TERMINAL_BACKGROUND_IMAGE:
455 g_value_set_string (value, self->background_image);
458 case TILDA_TERMINAL_SHELL:
459 g_value_set_string (value, self->shell);
462 case TILDA_TERMINAL_FONT:
463 g_value_set_string (value, self->font);
466 case TILDA_TERMINAL_TITLE:
467 g_value_set_string (value, self->title);
470 case TILDA_TERMINAL_WORKING_DIRECTORY:
471 g_value_set_string (value, self->working_directory);
474 case TILDA_TERMINAL_WEB_BROWSER:
475 g_value_set_string (value, self->web_browser);
478 case TILDA_TERMINAL_SCROLLBACK_LINES:
479 g_value_set_int (value, self->scrollback_lines);
482 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
483 g_value_set_int (value, self->transparency_percent);
486 case TILDA_TERMINAL_BACKSPACE_BINDING:
487 g_value_set_int (value, self->backspace_binding);
490 case TILDA_TERMINAL_DELETE_BINDING:
491 g_value_set_int (value, self->delete_binding);
494 case TILDA_TERMINAL_DYNAMIC_TITLE:
495 g_value_set_int (value, self->dynamic_title);
498 case TILDA_TERMINAL_EXIT_ACTION:
499 g_value_set_int (value, self->exit_action);
502 case TILDA_TERMINAL_SCROLL_BACKGROUND:
503 g_value_set_boolean (value, self->scroll_background);
506 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
507 g_value_set_boolean (value, self->scroll_on_output);
510 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
511 g_value_set_boolean (value, self->scroll_on_keystroke);
514 case TILDA_TERMINAL_ANTIALIASED:
515 g_value_set_boolean (value, self->antialiased);
518 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
519 g_value_set_boolean (value, self->allow_bold_text);
522 case TILDA_TERMINAL_CURSOR_BLINKS:
523 g_value_set_boolean (value, self->cursor_blinks);
526 case TILDA_TERMINAL_AUDIBLE_BELL:
527 g_value_set_boolean (value, self->audible_bell);
530 case TILDA_TERMINAL_VISIBLE_BELL:
531 g_value_set_boolean (value, self->visible_bell);
534 case TILDA_TERMINAL_DOUBLE_BUFFERED:
535 g_value_set_boolean (value, self->double_buffered);
538 case TILDA_TERMINAL_MOUSE_AUTOHIDE:
539 g_value_set_boolean (value, self->mouse_autohide);
542 /* We don't have this property... */
543 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
549 tilda_terminal_constructor (GType type,
550 guint n_construct_properties,
551 GObjectConstructParam *construct_properties)
556 /* Invoke parent constructor */
557 TildaTerminalClass *klass;
558 klass = TILDA_TERMINAL_CLASS (g_type_class_peek (TILDA_TYPE_TERMINAL));
559 obj = parent_class->constructor (type,
560 n_construct_properties,
561 construct_properties);
563 /* Do other stuff here. The object is ready to go now, and all
564 * ctor properties have been set.
566 * TODO: This is the place to do DBus-init */
567 self = TILDA_TERMINAL(obj);
569 /* Pack into the hbox */
570 gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0);
571 gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0);
572 gtk_widget_show (self->scrollbar);
575 /* Connect Signals */
576 g_signal_connect (G_OBJECT(self->vte_term), "child-exited",
577 G_CALLBACK(tilda_terminal_child_exited_cb), self);
578 g_signal_connect (G_OBJECT(self->vte_term), "eof",
579 G_CALLBACK(tilda_terminal_child_exited_cb), self);
580 g_signal_connect (G_OBJECT(self->vte_term), "window-title-changed",
581 G_CALLBACK(tilda_terminal_window_title_changed_cb), self);
583 tilda_terminal_start_shell (self);
584 tilda_terminal_dbus_register_object (self);
590 tilda_terminal_dispose (GObject *obj)
592 TildaTerminal *self = (TildaTerminal *) obj;
594 /* We don't want to run dispose twice, so just return immediately */
595 if (self->dispose_has_run)
598 self->dispose_has_run = TRUE;
601 * In dispose, you are supposed to free all types referenced from this
602 * object which might themselves hold a reference to self. Generally,
603 * the most simple solution is to unref all members on which you own a
607 /* Chain up to the parent class */
608 G_OBJECT_CLASS (parent_class)->dispose (obj);
612 tilda_terminal_finalize (GObject *obj)
614 TildaTerminal *self = (TildaTerminal *) obj;
617 * Here, complete object destruction.
618 * You might not need to do much...
621 // TODO: g_free() any primitives here
622 g_free (self->background_image);
623 g_free (self->shell);
625 g_free (self->title);
626 g_free (self->working_directory);
629 /* Chain up to the parent class */
630 G_OBJECT_CLASS (parent_class)->finalize (obj);
634 tilda_terminal_class_init (gpointer g_class,
635 gpointer g_class_data)
637 GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
638 TildaTerminalClass *klass = TILDA_TERMINAL_CLASS (g_class);
641 /* Hook our functions to this type */
642 gobject_class->set_property = tilda_terminal_set_property;
643 gobject_class->get_property = tilda_terminal_get_property;
644 gobject_class->dispose = tilda_terminal_dispose;
645 gobject_class->finalize = tilda_terminal_finalize;
646 gobject_class->constructor = tilda_terminal_constructor;
648 parent_class = g_type_class_peek_parent (klass);
650 /* Hook the TildaTerminal type into DBus */
651 dbus_g_object_type_install_info (tilda_terminal_get_type(), &dbus_glib_tilda_terminal_object_info);
653 /* Install all of the properties */
654 pspec = g_param_spec_int ("number",
656 "Set terminal's number",
658 INT_MAX, // max value
660 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
662 g_object_class_install_property (gobject_class,
663 TILDA_TERMINAL_NUMBER,
666 pspec = g_param_spec_int ("window-number",
667 "Number of the window to which this terminal belongs",
668 "Set the number of the parent window",
672 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
674 g_object_class_install_property (gobject_class,
675 TILDA_TERMINAL_WINDOW_NUMBER,
678 pspec = g_param_spec_pointer ("parent-window",
679 "Pointer to terminal's parent TildaWindow",
680 "Set the pointer to the terminal's parent TildaWindow",
681 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
683 g_object_class_install_property (gobject_class,
687 pspec = g_param_spec_string ("background-image",
688 "Terminal's background image",
689 "Get/Set terminal's background image",
693 g_object_class_install_property (gobject_class,
694 TILDA_TERMINAL_BACKGROUND_IMAGE,
697 pspec = g_param_spec_string ("shell",
699 "Get/Set terminal's shell",
703 g_object_class_install_property (gobject_class,
704 TILDA_TERMINAL_SHELL,
707 pspec = g_param_spec_string ("font",
709 "Get/Set terminal's font",
713 g_object_class_install_property (gobject_class,
717 pspec = g_param_spec_string ("title",
719 "Get/Set terminal's title",
723 g_object_class_install_property (gobject_class,
724 TILDA_TERMINAL_TITLE,
727 pspec = g_param_spec_string ("working-directory",
728 "Terminal's initial working directory",
729 "Get/Set terminal's initial working directory",
733 g_object_class_install_property (gobject_class,
734 TILDA_TERMINAL_WORKING_DIRECTORY,
737 pspec = g_param_spec_string ("web-browser",
738 "Terminal's web browser command",
743 g_object_class_install_property (gobject_class,
744 TILDA_TERMINAL_WEB_BROWSER,
747 pspec = g_param_spec_int ("scrollback-lines",
748 "Terminal's scrollback amount (lines)",
749 "Get/Set terminal's scrollback amount",
751 INT_MAX, // TODO: artificially limit this?
755 g_object_class_install_property (gobject_class,
756 TILDA_TERMINAL_SCROLLBACK_LINES,
759 pspec = g_param_spec_int ("transparency-percent",
760 "Terminal's transparency (percent)",
761 "Get/Set terminal's transparency",
767 g_object_class_install_property (gobject_class,
768 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
771 pspec = g_param_spec_int ("backspace-binding",
772 "Terminal's backspace binding",
773 "Get/Set terminal's backspace key binding",
775 VTE_ERASE_DELETE_SEQUENCE,
779 g_object_class_install_property (gobject_class,
780 TILDA_TERMINAL_BACKSPACE_BINDING,
783 pspec = g_param_spec_int ("delete-binding",
784 "Terminal's delete binding",
785 "Get/Set terminal's delete key binding",
787 VTE_ERASE_DELETE_SEQUENCE,
791 g_object_class_install_property (gobject_class,
792 TILDA_TERMINAL_DELETE_BINDING,
795 pspec = g_param_spec_int ("dynamic-title",
796 "Terminal's dynamic title generation method",
797 "Get/Set terminal's dynamic title generation method",
803 g_object_class_install_property (gobject_class,
804 TILDA_TERMINAL_DYNAMIC_TITLE,
807 pspec = g_param_spec_int ("exit-action",
808 "Terminal's action upon child exit",
809 "Get/Set terminal's action upon child exit",
815 g_object_class_install_property (gobject_class,
816 TILDA_TERMINAL_EXIT_ACTION,
819 pspec = g_param_spec_boolean ("scroll-background",
820 "Controls terminal's scrolling behavior",
821 "Get/Set terminal's scrolling behavior",
825 g_object_class_install_property (gobject_class,
826 TILDA_TERMINAL_SCROLL_BACKGROUND,
829 pspec = g_param_spec_boolean ("scroll-on-output",
830 "Controls terminal's scrolling behavior on output",
831 "Get/Set terminal's scrolling behavior on output",
835 g_object_class_install_property (gobject_class,
836 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
839 pspec = g_param_spec_boolean ("scroll-on-keystroke",
840 "Controls the terminal's scrolling behavior on keystroke",
841 NULL, FALSE, G_PARAM_READWRITE);
843 g_object_class_install_property (gobject_class,
844 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
847 pspec = g_param_spec_boolean ("antialiased",
848 "Attempt to antialias fonts",
849 NULL, FALSE, G_PARAM_READWRITE);
851 g_object_class_install_property (gobject_class,
852 TILDA_TERMINAL_ANTIALIASED,
855 pspec = g_param_spec_boolean ("allow-bold-text",
857 NULL, FALSE, G_PARAM_READWRITE);
859 g_object_class_install_property (gobject_class,
860 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
863 pspec = g_param_spec_boolean ("cursor-blinks",
864 NULL, NULL, FALSE, G_PARAM_READWRITE);
866 g_object_class_install_property (gobject_class,
867 TILDA_TERMINAL_CURSOR_BLINKS,
870 pspec = g_param_spec_boolean ("audible-bell",
871 NULL, NULL, FALSE, G_PARAM_READWRITE);
873 g_object_class_install_property (gobject_class,
874 TILDA_TERMINAL_AUDIBLE_BELL,
877 pspec = g_param_spec_boolean ("visible-bell",
878 NULL, NULL, FALSE, G_PARAM_READWRITE);
880 g_object_class_install_property (gobject_class,
881 TILDA_TERMINAL_VISIBLE_BELL,
884 pspec = g_param_spec_boolean ("double-buffered",
885 NULL, NULL, FALSE, G_PARAM_READWRITE);
887 g_object_class_install_property (gobject_class,
888 TILDA_TERMINAL_DOUBLE_BUFFERED,
891 pspec = g_param_spec_boolean ("mouse-autohide",
892 NULL, NULL, FALSE, G_PARAM_READWRITE);
894 g_object_class_install_property (gobject_class,
895 TILDA_TERMINAL_MOUSE_AUTOHIDE,
900 tilda_terminal_get_type (void)
902 static GType type = 0;
906 static const GTypeInfo info = {
907 sizeof (TildaTerminalClass),
908 NULL, /* base_init */
909 NULL, /* base_finalize */
910 tilda_terminal_class_init, /* class_init */
911 NULL, /* class_finalize */
912 NULL, /* class_data */
913 sizeof (TildaTerminal),
915 tilda_terminal_instance_init, /* instance_init */
918 type = g_type_register_static (G_TYPE_OBJECT,
929 int main (int argc, char *argv[])
932 gint test_number = INT_MIN;
933 gchar *test_string = NULL;
935 /* Initialize the GObject type system */
937 gtk_init (&argc, &argv);
939 tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 10, NULL);
940 g_object_get (G_OBJECT (tt), "number", &test_number, NULL);
941 g_assert (test_number == 10);
943 g_object_unref (G_OBJECT (tt));
945 tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 22, NULL);
946 g_object_get (G_OBJECT (tt), "number", &test_number, NULL);
947 g_assert (test_number == 22);
949 g_object_set (G_OBJECT (tt), "font", "hello I'm a font");
950 g_object_set (G_OBJECT (tt), "font", "Bitstream Vera Sans Mono 13");
952 g_object_get (G_OBJECT (tt), "font", &test_string, NULL);
953 g_print ("Read Font: %s\n", test_string);
954 // NOTE: you MUST free the string!!!!
955 g_free (test_string);
957 g_object_set (G_OBJECT (tt), "transparency-percent", 50);
959 g_object_unref (G_OBJECT (tt));
966 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */