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);
178 /*******************************************************************************
179 * All GObject stuff is below. You probably don't need to change this...
180 ******************************************************************************/
182 static GObjectClass *parent_class = NULL;
184 enum tilda_terminal_properties {
185 TILDA_TERMINAL_NUMBER = 1,
186 TILDA_TERMINAL_WINDOW_NUMBER,
189 /* All non-constructor-only properties */
190 TILDA_TERMINAL_BACKGROUND_IMAGE,
191 TILDA_TERMINAL_SHELL,
193 TILDA_TERMINAL_TITLE,
194 TILDA_TERMINAL_WORKING_DIRECTORY,
196 TILDA_TERMINAL_SCROLLBACK_LINES,
197 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
199 TILDA_TERMINAL_BACKSPACE_BINDING,
200 TILDA_TERMINAL_DELETE_BINDING,
201 TILDA_TERMINAL_DYNAMIC_TITLE,
202 TILDA_TERMINAL_EXIT_ACTION,
204 TILDA_TERMINAL_SCROLL_BACKGROUND,
205 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
206 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
207 TILDA_TERMINAL_ANTIALIASED,
208 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
209 TILDA_TERMINAL_CURSOR_BLINKS,
210 TILDA_TERMINAL_AUDIBLE_BELL,
211 TILDA_TERMINAL_VISIBLE_BELL,
212 TILDA_TERMINAL_DOUBLE_BUFFERED,
213 TILDA_TERMINAL_MOUSE_AUTOHIDE,
217 tilda_terminal_instance_init (GTypeInstance *instance,
220 TildaTerminal *self = (TildaTerminal *) instance;
222 /* Initialize instance members and allocate any necessary memory here.
223 * NOTE: any constructor-time values will be set later. */
224 self->dispose_has_run = FALSE;
227 self->vte_term = vte_terminal_new ();
228 self->scrollbar = gtk_vscrollbar_new (VTE_TERMINAL(self->vte_term)->adjustment);
229 self->hbox = gtk_hbox_new (FALSE, 0);
233 tilda_terminal_set_property (GObject *object,
238 TildaTerminal *self = (TildaTerminal *) object;
240 switch (property_id) {
242 case TILDA_TERMINAL_NUMBER:
243 self->number = g_value_get_int (value);
244 g_print ("terminal number: %d\n", self->number);
247 case TILDA_TERMINAL_WINDOW_NUMBER:
248 self->window_number = g_value_get_int (value);
249 g_print ("terminal parent window number: %d\n", self->window_number);
252 case TILDA_TERMINAL_TW:
253 self->parent_window = g_value_get_pointer (value);
254 g_print ("terminal parent window: 0x%x\n", self->parent_window);
255 g_print ("terminal parent window number (direct): %d\n", TILDA_WINDOW(self->parent_window)->number);
258 case TILDA_TERMINAL_BACKGROUND_IMAGE:
259 g_free (self->background_image);
260 self->background_image = g_value_dup_string (value);
261 vte_terminal_set_background_image_file (VTE_TERMINAL(self->vte_term), self->background_image);
262 g_print ("terminal back img: %s\n", self->background_image);
265 case TILDA_TERMINAL_SHELL:
266 g_free (self->shell);
267 self->shell = g_value_dup_string (value);
268 tilda_terminal_start_shell (self);
269 g_print ("terminal shell: %s\n", self->shell);
272 case TILDA_TERMINAL_FONT:
274 self->font = g_value_dup_string (value);
275 vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
278 g_print ("terminal font: %s\n", self->font);
281 case TILDA_TERMINAL_TITLE:
282 g_free (self->title);
283 self->title = g_value_dup_string (value);
284 g_print ("terminal title: %s\n", self->title);
287 case TILDA_TERMINAL_WORKING_DIRECTORY:
288 g_free (self->working_directory);
289 self->working_directory = g_value_dup_string (value);
290 g_print ("terminal wrk dir: %s\n", self->working_directory);
293 case TILDA_TERMINAL_SCROLLBACK_LINES:
294 self->scrollback_lines = g_value_get_int (value);
295 vte_terminal_set_scrollback_lines (VTE_TERMINAL(self->vte_term), self->scrollback_lines);
296 g_print ("terminal scrollback lines: %d\n", self->scrollback_lines);
299 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
300 self->transparency_percent = g_value_get_int (value);
301 g_print ("terminal transp percent: %d\n", self->transparency_percent);
304 case TILDA_TERMINAL_BACKSPACE_BINDING:
305 self->backspace_binding = g_value_get_int (value);
306 vte_terminal_set_backspace_binding (VTE_TERMINAL(self->vte_term), self->backspace_binding);
307 g_print ("terminal backspace key: %d\n", self->backspace_binding);
310 case TILDA_TERMINAL_DELETE_BINDING:
311 self->delete_binding = g_value_get_int (value);
312 vte_terminal_set_delete_binding (VTE_TERMINAL(self->vte_term), self->delete_binding);
313 g_print ("terminal delete key: %d\n", self->delete_binding);
316 case TILDA_TERMINAL_DYNAMIC_TITLE:
317 self->dynamic_title = g_value_get_int (value);
318 g_print ("terminal dynamic title: %d\n", self->dynamic_title);
321 case TILDA_TERMINAL_EXIT_ACTION:
322 self->exit_action = g_value_get_int (value);
323 g_print ("terminal exit action: %d\n", self->exit_action);
326 case TILDA_TERMINAL_SCROLL_BACKGROUND:
327 self->scroll_background = g_value_get_boolean (value);
328 vte_terminal_set_scroll_background (VTE_TERMINAL(self->vte_term), self->scroll_background);
329 g_print ("terminal scroll background: %d\n", self->scroll_background);
332 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
333 self->scroll_on_output = g_value_get_boolean (value);
334 vte_terminal_set_scroll_on_output (VTE_TERMINAL(self->vte_term), self->scroll_on_output);
335 g_print ("terminal scroll on output: %d\n", self->scroll_on_output);
338 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
339 self->scroll_on_keystroke = g_value_get_boolean (value);
340 vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(self->vte_term), self->scroll_on_keystroke);
341 g_print ("terminal scroll on keystroke: %d\n", self->scroll_on_keystroke);
344 case TILDA_TERMINAL_ANTIALIASED:
345 self->antialiased = g_value_get_boolean (value);
346 vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
349 g_print ("terminal antialiased: %d\n", self->antialiased);
352 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
353 self->allow_bold_text = g_value_get_boolean (value);
354 vte_terminal_set_allow_bold (VTE_TERMINAL(self->vte_term), self->allow_bold_text);
355 g_print ("terminal allow bold text: %d\n", self->allow_bold_text);
358 case TILDA_TERMINAL_CURSOR_BLINKS:
359 self->cursor_blinks = g_value_get_boolean (value);
360 vte_terminal_set_cursor_blinks (VTE_TERMINAL(self->vte_term), self->cursor_blinks);
361 g_print ("terminal cursor blinks: %d\n", self->cursor_blinks);
364 case TILDA_TERMINAL_AUDIBLE_BELL:
365 self->audible_bell = g_value_get_boolean (value);
366 vte_terminal_set_audible_bell (VTE_TERMINAL(self->vte_term), self->audible_bell);
367 g_print ("terminal audible bell: %d\n", self->audible_bell);
370 case TILDA_TERMINAL_VISIBLE_BELL:
371 self->visible_bell = g_value_get_boolean (value);
372 vte_terminal_set_visible_bell (VTE_TERMINAL(self->vte_term), self->visible_bell);
373 g_print ("terminal visible bell: %d\n", self->visible_bell);
376 case TILDA_TERMINAL_DOUBLE_BUFFERED:
377 self->double_buffered = g_value_get_boolean (value);
378 gtk_widget_set_double_buffered (GTK_WIDGET(self->vte_term), self->double_buffered);
379 g_print ("terminal double buffered: %d\n", self->double_buffered);
382 case TILDA_TERMINAL_MOUSE_AUTOHIDE:
383 self->mouse_autohide = g_value_get_boolean (value);
384 vte_terminal_set_mouse_autohide (VTE_TERMINAL(self->vte_term), self->mouse_autohide);
385 g_print ("terminal mouse autohide: %d\n", self->mouse_autohide);
389 /* We don't have this property... */
390 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
396 tilda_terminal_get_property (GObject *object,
401 TildaTerminal *self = (TildaTerminal *) object;
403 switch (property_id) {
405 case TILDA_TERMINAL_NUMBER:
406 g_value_set_int (value, self->number);
409 case TILDA_TERMINAL_WINDOW_NUMBER:
410 g_value_set_int (value, self->window_number);
413 case TILDA_TERMINAL_TW:
414 g_value_set_pointer (value, self->parent_window);
417 case TILDA_TERMINAL_BACKGROUND_IMAGE:
418 g_value_set_string (value, self->background_image);
421 case TILDA_TERMINAL_SHELL:
422 g_value_set_string (value, self->shell);
425 case TILDA_TERMINAL_FONT:
426 g_value_set_string (value, self->font);
429 case TILDA_TERMINAL_TITLE:
430 g_value_set_string (value, self->title);
433 case TILDA_TERMINAL_WORKING_DIRECTORY:
434 g_value_set_string (value, self->working_directory);
437 case TILDA_TERMINAL_SCROLLBACK_LINES:
438 g_value_set_int (value, self->scrollback_lines);
441 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
442 g_value_set_int (value, self->transparency_percent);
445 case TILDA_TERMINAL_BACKSPACE_BINDING:
446 g_value_set_int (value, self->backspace_binding);
449 case TILDA_TERMINAL_DELETE_BINDING:
450 g_value_set_int (value, self->delete_binding);
453 case TILDA_TERMINAL_DYNAMIC_TITLE:
454 g_value_set_int (value, self->dynamic_title);
457 case TILDA_TERMINAL_EXIT_ACTION:
458 g_value_set_int (value, self->exit_action);
461 case TILDA_TERMINAL_SCROLL_BACKGROUND:
462 g_value_set_boolean (value, self->scroll_background);
465 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
466 g_value_set_boolean (value, self->scroll_on_output);
469 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
470 g_value_set_boolean (value, self->scroll_on_keystroke);
473 case TILDA_TERMINAL_ANTIALIASED:
474 g_value_set_boolean (value, self->antialiased);
477 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
478 g_value_set_boolean (value, self->allow_bold_text);
481 case TILDA_TERMINAL_CURSOR_BLINKS:
482 g_value_set_boolean (value, self->cursor_blinks);
485 case TILDA_TERMINAL_AUDIBLE_BELL:
486 g_value_set_boolean (value, self->audible_bell);
489 case TILDA_TERMINAL_VISIBLE_BELL:
490 g_value_set_boolean (value, self->visible_bell);
493 case TILDA_TERMINAL_DOUBLE_BUFFERED:
494 g_value_set_boolean (value, self->double_buffered);
497 case TILDA_TERMINAL_MOUSE_AUTOHIDE:
498 g_value_set_boolean (value, self->mouse_autohide);
501 /* We don't have this property... */
502 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
508 tilda_terminal_constructor (GType type,
509 guint n_construct_properties,
510 GObjectConstructParam *construct_properties)
515 /* Invoke parent constructor */
516 TildaTerminalClass *klass;
517 klass = TILDA_TERMINAL_CLASS (g_type_class_peek (TILDA_TYPE_TERMINAL));
518 obj = parent_class->constructor (type,
519 n_construct_properties,
520 construct_properties);
522 /* Do other stuff here. The object is ready to go now, and all
523 * ctor properties have been set.
525 * TODO: This is the place to do DBus-init */
526 self = TILDA_TERMINAL(obj);
528 /* Pack into the hbox */
529 gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0);
530 gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0);
531 gtk_widget_show (self->scrollbar);
534 /* Connect Signals */
535 g_signal_connect (G_OBJECT(self->vte_term), "child-exited",
536 G_CALLBACK(tilda_terminal_child_exited_cb), self);
537 g_signal_connect (G_OBJECT(self->vte_term), "eof",
538 G_CALLBACK(tilda_terminal_child_exited_cb), self);
539 g_signal_connect (G_OBJECT(self->vte_term), "window-title-changed",
540 G_CALLBACK(tilda_terminal_window_title_changed_cb), self);
542 tilda_terminal_start_shell (self);
543 tilda_terminal_dbus_register_object (self);
549 tilda_terminal_dispose (GObject *obj)
551 TildaTerminal *self = (TildaTerminal *) obj;
553 /* We don't want to run dispose twice, so just return immediately */
554 if (self->dispose_has_run)
557 self->dispose_has_run = TRUE;
560 * In dispose, you are supposed to free all types referenced from this
561 * object which might themselves hold a reference to self. Generally,
562 * the most simple solution is to unref all members on which you own a
566 /* Chain up to the parent class */
567 G_OBJECT_CLASS (parent_class)->dispose (obj);
571 tilda_terminal_finalize (GObject *obj)
573 TildaTerminal *self = (TildaTerminal *) obj;
576 * Here, complete object destruction.
577 * You might not need to do much...
580 // TODO: g_free() any primitives here
581 g_free (self->background_image);
582 g_free (self->shell);
584 g_free (self->title);
585 g_free (self->working_directory);
588 /* Chain up to the parent class */
589 G_OBJECT_CLASS (parent_class)->finalize (obj);
593 tilda_terminal_class_init (gpointer g_class,
594 gpointer g_class_data)
596 GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
597 TildaTerminalClass *klass = TILDA_TERMINAL_CLASS (g_class);
600 /* Hook our functions to this type */
601 gobject_class->set_property = tilda_terminal_set_property;
602 gobject_class->get_property = tilda_terminal_get_property;
603 gobject_class->dispose = tilda_terminal_dispose;
604 gobject_class->finalize = tilda_terminal_finalize;
605 gobject_class->constructor = tilda_terminal_constructor;
607 parent_class = g_type_class_peek_parent (klass);
609 /* Hook the TildaTerminal type into DBus */
610 dbus_g_object_type_install_info (tilda_terminal_get_type(), &dbus_glib_tilda_terminal_object_info);
612 /* Install all of the properties */
613 pspec = g_param_spec_int ("number",
615 "Set terminal's number",
617 INT_MAX, // max value
619 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
621 g_object_class_install_property (gobject_class,
622 TILDA_TERMINAL_NUMBER,
625 pspec = g_param_spec_int ("window-number",
626 "Number of the window to which this terminal belongs",
627 "Set the number of the parent window",
631 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
633 g_object_class_install_property (gobject_class,
634 TILDA_TERMINAL_WINDOW_NUMBER,
637 pspec = g_param_spec_pointer ("parent-window",
638 "Pointer to terminal's parent TildaWindow",
639 "Set the pointer to the terminal's parent TildaWindow",
640 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
642 g_object_class_install_property (gobject_class,
646 pspec = g_param_spec_string ("background-image",
647 "Terminal's background image",
648 "Get/Set terminal's background image",
652 g_object_class_install_property (gobject_class,
653 TILDA_TERMINAL_BACKGROUND_IMAGE,
656 pspec = g_param_spec_string ("shell",
658 "Get/Set terminal's shell",
662 g_object_class_install_property (gobject_class,
663 TILDA_TERMINAL_SHELL,
666 pspec = g_param_spec_string ("font",
668 "Get/Set terminal's font",
672 g_object_class_install_property (gobject_class,
676 pspec = g_param_spec_string ("title",
678 "Get/Set terminal's title",
682 g_object_class_install_property (gobject_class,
683 TILDA_TERMINAL_TITLE,
686 pspec = g_param_spec_string ("working-directory",
687 "Terminal's initial working directory",
688 "Get/Set terminal's initial working directory",
692 g_object_class_install_property (gobject_class,
693 TILDA_TERMINAL_WORKING_DIRECTORY,
696 pspec = g_param_spec_int ("scrollback-lines",
697 "Terminal's scrollback amount (lines)",
698 "Get/Set terminal's scrollback amount",
700 INT_MAX, // TODO: artificially limit this?
704 g_object_class_install_property (gobject_class,
705 TILDA_TERMINAL_SCROLLBACK_LINES,
708 pspec = g_param_spec_int ("transparency-percent",
709 "Terminal's transparency (percent)",
710 "Get/Set terminal's transparency",
716 g_object_class_install_property (gobject_class,
717 TILDA_TERMINAL_TRANSPARENCY_PERCENT,
720 pspec = g_param_spec_int ("backspace-binding",
721 "Terminal's backspace binding",
722 "Get/Set terminal's backspace key binding",
724 VTE_ERASE_DELETE_SEQUENCE,
728 g_object_class_install_property (gobject_class,
729 TILDA_TERMINAL_BACKSPACE_BINDING,
732 pspec = g_param_spec_int ("delete-binding",
733 "Terminal's delete binding",
734 "Get/Set terminal's delete key binding",
736 VTE_ERASE_DELETE_SEQUENCE,
740 g_object_class_install_property (gobject_class,
741 TILDA_TERMINAL_DELETE_BINDING,
744 pspec = g_param_spec_int ("dynamic-title",
745 "Terminal's dynamic title generation method",
746 "Get/Set terminal's dynamic title generation method",
752 g_object_class_install_property (gobject_class,
753 TILDA_TERMINAL_DYNAMIC_TITLE,
756 pspec = g_param_spec_int ("exit-action",
757 "Terminal's action upon child exit",
758 "Get/Set terminal's action upon child exit",
764 g_object_class_install_property (gobject_class,
765 TILDA_TERMINAL_EXIT_ACTION,
768 pspec = g_param_spec_boolean ("scroll-background",
769 "Controls terminal's scrolling behavior",
770 "Get/Set terminal's scrolling behavior",
774 g_object_class_install_property (gobject_class,
775 TILDA_TERMINAL_SCROLL_BACKGROUND,
778 pspec = g_param_spec_boolean ("scroll-on-output",
779 "Controls terminal's scrolling behavior on output",
780 "Get/Set terminal's scrolling behavior on output",
784 g_object_class_install_property (gobject_class,
785 TILDA_TERMINAL_SCROLL_ON_OUTPUT,
788 pspec = g_param_spec_boolean ("scroll-on-keystroke",
789 "Controls the terminal's scrolling behavior on keystroke",
790 NULL, FALSE, G_PARAM_READWRITE);
792 g_object_class_install_property (gobject_class,
793 TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
796 pspec = g_param_spec_boolean ("antialiased",
797 "Attempt to antialias fonts",
798 NULL, FALSE, G_PARAM_READWRITE);
800 g_object_class_install_property (gobject_class,
801 TILDA_TERMINAL_ANTIALIASED,
804 pspec = g_param_spec_boolean ("allow-bold-text",
806 NULL, FALSE, G_PARAM_READWRITE);
808 g_object_class_install_property (gobject_class,
809 TILDA_TERMINAL_ALLOW_BOLD_TEXT,
812 pspec = g_param_spec_boolean ("cursor-blinks",
813 NULL, NULL, FALSE, G_PARAM_READWRITE);
815 g_object_class_install_property (gobject_class,
816 TILDA_TERMINAL_CURSOR_BLINKS,
819 pspec = g_param_spec_boolean ("audible-bell",
820 NULL, NULL, FALSE, G_PARAM_READWRITE);
822 g_object_class_install_property (gobject_class,
823 TILDA_TERMINAL_AUDIBLE_BELL,
826 pspec = g_param_spec_boolean ("visible-bell",
827 NULL, NULL, FALSE, G_PARAM_READWRITE);
829 g_object_class_install_property (gobject_class,
830 TILDA_TERMINAL_VISIBLE_BELL,
833 pspec = g_param_spec_boolean ("double-buffered",
834 NULL, NULL, FALSE, G_PARAM_READWRITE);
836 g_object_class_install_property (gobject_class,
837 TILDA_TERMINAL_DOUBLE_BUFFERED,
840 pspec = g_param_spec_boolean ("mouse-autohide",
841 NULL, NULL, FALSE, G_PARAM_READWRITE);
843 g_object_class_install_property (gobject_class,
844 TILDA_TERMINAL_MOUSE_AUTOHIDE,
849 tilda_terminal_get_type (void)
851 static GType type = 0;
855 static const GTypeInfo info = {
856 sizeof (TildaTerminalClass),
857 NULL, /* base_init */
858 NULL, /* base_finalize */
859 tilda_terminal_class_init, /* class_init */
860 NULL, /* class_finalize */
861 NULL, /* class_data */
862 sizeof (TildaTerminal),
864 tilda_terminal_instance_init, /* instance_init */
867 type = g_type_register_static (G_TYPE_OBJECT,
878 int main (int argc, char *argv[])
881 gint test_number = INT_MIN;
882 gchar *test_string = NULL;
884 /* Initialize the GObject type system */
886 gtk_init (&argc, &argv);
888 tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 10, NULL);
889 g_object_get (G_OBJECT (tt), "number", &test_number, NULL);
890 g_assert (test_number == 10);
892 g_object_unref (G_OBJECT (tt));
894 tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 22, NULL);
895 g_object_get (G_OBJECT (tt), "number", &test_number, NULL);
896 g_assert (test_number == 22);
898 g_object_set (G_OBJECT (tt), "font", "hello I'm a font");
899 g_object_set (G_OBJECT (tt), "font", "Bitstream Vera Sans Mono 13");
901 g_object_get (G_OBJECT (tt), "font", &test_string, NULL);
902 g_print ("Read Font: %s\n", test_string);
903 // NOTE: you MUST free the string!!!!
904 g_free (test_string);
906 g_object_set (G_OBJECT (tt), "transparency-percent", 50);
908 g_object_unref (G_OBJECT (tt));
915 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */