261949566983674826d9b4b00172d91a3352dc54
[tilda-gobject.git] / tilda-terminal.c
1 #include "tilda.h"
2 #include "tilda-terminal.h"
3 #include "tilda-terminal-dbus-glue.h"
4
5 // FIXME: temporary helpers for gettext
6 // TODO:  remove these
7 #define _(X) X
8 #define N_(X) X
9
10 static void
11 tilda_terminal_dbus_register_object (TildaTerminal *tt)
12 {
13         gchar *object_path;
14
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));
19         g_free (object_path);
20 }
21
22 /**
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
27  */
28 static gboolean
29 tilda_terminal_start_shell (TildaTerminal *tt)
30 {
31         gint ret;
32         gint argc;
33         gchar **argv;
34         GError *error = NULL;
35
36         /* Launch a custom command if tt->shell is set (not NULL) */
37         if (tt->shell)
38         {
39                 /* Try to parse the user's custom command */
40                 ret = g_shell_parse_argv (tt->shell, &argc, &argv, &error);
41
42                 if (ret == FALSE)
43                 {
44                         g_printerr (_("Problem parsing custom command: %s\n"), error->message);
45                         g_printerr (_("Launching default shell instead\n"));
46
47                         g_error_free (error);
48                         goto launch_default_shell;
49                 }
50
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 */
60
61                 g_strfreev (argv);
62
63                 /* Check for error */
64                 if (ret == -1)
65                 {
66                         g_printerr (_("Unable to launch custom command: %s\n"), tt->shell);
67                         g_printerr (_("Launching default shell instead\n"));
68
69                         goto launch_default_shell;
70                 }
71
72                 return TRUE; /* SUCCESS: the early way out */
73         }
74
75 launch_default_shell:
76
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 */
85
86         if (ret == -1)
87         {
88                 g_printerr (_("Unable to launch default shell\n"));
89                 return FALSE;
90         }
91
92         return TRUE;
93 }
94
95 /*******************************************************************************
96  * All GObject stuff is below. You probably don't need to change this...
97  ******************************************************************************/
98
99 static GObjectClass *parent_class = NULL;
100
101 enum tilda_terminal_properties {
102         TILDA_TERMINAL_NUMBER = 1,
103         TILDA_TERMINAL_WINDOW_NUMBER,
104         TILDA_TERMINAL_TW,
105
106         /* All non-constructor-only properties */
107         TILDA_TERMINAL_BACKGROUND_IMAGE,
108         TILDA_TERMINAL_SHELL,
109         TILDA_TERMINAL_FONT,
110         TILDA_TERMINAL_TITLE,
111         TILDA_TERMINAL_WORKING_DIRECTORY,
112
113         TILDA_TERMINAL_SCROLLBACK_LINES,
114         TILDA_TERMINAL_TRANSPARENCY_PERCENT,
115
116         TILDA_TERMINAL_BACKSPACE_BINDING,
117         TILDA_TERMINAL_DELETE_BINDING,
118         TILDA_TERMINAL_DYNAMIC_TITLE,
119         TILDA_TERMINAL_EXIT_ACTION,
120
121         TILDA_TERMINAL_SCROLL_BACKGROUND,
122         TILDA_TERMINAL_SCROLL_ON_OUTPUT,
123         TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
124         TILDA_TERMINAL_ANTIALIASED,
125         TILDA_TERMINAL_ALLOW_BOLD_TEXT,
126         TILDA_TERMINAL_CURSOR_BLINKS,
127         TILDA_TERMINAL_AUDIBLE_BELL,
128         TILDA_TERMINAL_VISIBLE_BELL,
129         TILDA_TERMINAL_DOUBLE_BUFFERED,
130 };
131
132 static void
133 tilda_terminal_instance_init (GTypeInstance *instance,
134                                                           gpointer       g_class)
135 {
136         TildaTerminal *self = (TildaTerminal *) instance;
137
138         /* Initialize instance members and allocate any necessary memory here.
139          * NOTE: any constructor-time values will be set later. */
140         self->dispose_has_run = FALSE;
141         self->number = 0;
142
143         self->vte_term = vte_terminal_new ();
144         self->scrollbar = gtk_vscrollbar_new (VTE_TERMINAL(self->vte_term)->adjustment);
145         self->hbox = gtk_hbox_new (FALSE, 0);
146 }
147
148 static void
149 tilda_terminal_set_property (GObject      *object,
150                                                          guint         property_id,
151                                                          const GValue *value,
152                                                          GParamSpec   *pspec)
153 {
154         TildaTerminal *self = (TildaTerminal *) object;
155
156         switch (property_id) {
157
158                 case TILDA_TERMINAL_NUMBER:
159                         self->number = g_value_get_int (value);
160                         g_print ("terminal number: %d\n", self->number);
161                         break;
162
163                 case TILDA_TERMINAL_WINDOW_NUMBER:
164                         self->window_number = g_value_get_int (value);
165                         g_print ("terminal parent window number: %d\n", self->window_number);
166                         break;
167
168                 case TILDA_TERMINAL_TW:
169                         self->parent_window = g_value_get_pointer (value);
170                         g_print ("terminal parent window: 0x%x\n", self->parent_window);
171                         g_print ("terminal parent window number (direct): %d\n", TILDA_WINDOW(self->parent_window)->number);
172                         break;
173
174                 case TILDA_TERMINAL_BACKGROUND_IMAGE:
175                         g_free (self->background_image);
176                         self->background_image = g_value_dup_string (value);
177                         vte_terminal_set_background_image_file (VTE_TERMINAL(self->vte_term), self->background_image);
178                         g_print ("terminal back img: %s\n", self->background_image);
179                         break;
180
181                 case TILDA_TERMINAL_SHELL:
182                         g_free (self->shell);
183                         self->shell = g_value_dup_string (value);
184                         tilda_terminal_start_shell (self);
185                         g_print ("terminal shell: %s\n", self->shell);
186                         break;
187
188                 case TILDA_TERMINAL_FONT:
189                         g_free (self->font);
190                         self->font = g_value_dup_string (value);
191                         vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
192                                                                                                         self->font,
193                                                                                                         self->antialiased);
194                         g_print ("terminal font: %s\n", self->font);
195                         break;
196
197                 case TILDA_TERMINAL_TITLE:
198                         g_free (self->title);
199                         self->title = g_value_dup_string (value);
200                         g_print ("terminal title: %s\n", self->title);
201                         break;
202
203                 case TILDA_TERMINAL_WORKING_DIRECTORY:
204                         g_free (self->working_directory);
205                         self->working_directory = g_value_dup_string (value);
206                         g_print ("terminal wrk dir: %s\n", self->working_directory);
207                         break;
208
209                 case TILDA_TERMINAL_SCROLLBACK_LINES:
210                         self->scrollback_lines = g_value_get_int (value);
211                         vte_terminal_set_scrollback_lines (VTE_TERMINAL(self->vte_term), self->scrollback_lines);
212                         g_print ("terminal scrollback lines: %d\n", self->scrollback_lines);
213                         break;
214
215                 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
216                         self->transparency_percent = g_value_get_int (value);
217                         g_print ("terminal transp percent: %d\n", self->transparency_percent);
218                         break;
219
220                 case TILDA_TERMINAL_BACKSPACE_BINDING:
221                         self->backspace_binding = g_value_get_int (value);
222                         vte_terminal_set_backspace_binding (VTE_TERMINAL(self->vte_term), self->backspace_binding);
223                         g_print ("terminal backspace key: %d\n", self->backspace_binding);
224                         break;
225
226                 case TILDA_TERMINAL_DELETE_BINDING:
227                         self->delete_binding = g_value_get_int (value);
228                         vte_terminal_set_delete_binding (VTE_TERMINAL(self->vte_term), self->delete_binding);
229                         g_print ("terminal delete key: %d\n", self->delete_binding);
230                         break;
231
232                 case TILDA_TERMINAL_DYNAMIC_TITLE:
233                         self->dynamic_title = g_value_get_int (value);
234                         g_print ("terminal dynamic title: %d\n", self->dynamic_title);
235                         break;
236
237                 case TILDA_TERMINAL_EXIT_ACTION:
238                         self->exit_action = g_value_get_int (value);
239                         g_print ("terminal exit action: %d\n", self->exit_action);
240                         break;
241
242                 case TILDA_TERMINAL_SCROLL_BACKGROUND:
243                         self->scroll_background = g_value_get_boolean (value);
244                         vte_terminal_set_scroll_background (VTE_TERMINAL(self->vte_term), self->scroll_background);
245                         g_print ("terminal scroll background: %d\n", self->scroll_background);
246                         break;
247
248                 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
249                         self->scroll_on_output = g_value_get_boolean (value);
250                         vte_terminal_set_scroll_on_output (VTE_TERMINAL(self->vte_term), self->scroll_on_output);
251                         g_print ("terminal scroll on output: %d\n", self->scroll_on_output);
252                         break;
253
254                 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
255                         self->scroll_on_keystroke = g_value_get_boolean (value);
256                         vte_terminal_set_scroll_on_keystroke (VTE_TERMINAL(self->vte_term), self->scroll_on_keystroke);
257                         g_print ("terminal scroll on keystroke: %d\n", self->scroll_on_keystroke);
258                         break;
259
260                 case TILDA_TERMINAL_ANTIALIASED:
261                         self->antialiased = g_value_get_boolean (value);
262                         vte_terminal_set_font_from_string_full (VTE_TERMINAL(self->vte_term),
263                                                                                                         self->font,
264                                                                                                         self->antialiased);
265                         g_print ("terminal antialiased: %d\n", self->antialiased);
266                         break;
267
268                 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
269                         self->allow_bold_text = g_value_get_boolean (value);
270                         vte_terminal_set_allow_bold (VTE_TERMINAL(self->vte_term), self->allow_bold_text);
271                         g_print ("terminal allow bold text: %d\n", self->allow_bold_text);
272                         break;
273
274                 case TILDA_TERMINAL_CURSOR_BLINKS:
275                         self->cursor_blinks = g_value_get_boolean (value);
276                         vte_terminal_set_cursor_blinks (VTE_TERMINAL(self->vte_term), self->cursor_blinks);
277                         g_print ("terminal cursor blinks: %d\n", self->cursor_blinks);
278                         break;
279
280                 case TILDA_TERMINAL_AUDIBLE_BELL:
281                         self->audible_bell = g_value_get_boolean (value);
282                         vte_terminal_set_audible_bell (VTE_TERMINAL(self->vte_term), self->audible_bell);
283                         g_print ("terminal audible bell: %d\n", self->audible_bell);
284                         break;
285
286                 case TILDA_TERMINAL_VISIBLE_BELL:
287                         self->visible_bell = g_value_get_boolean (value);
288                         vte_terminal_set_visible_bell (VTE_TERMINAL(self->vte_term), self->visible_bell);
289                         g_print ("terminal visible bell: %d\n", self->visible_bell);
290                         break;
291
292                 case TILDA_TERMINAL_DOUBLE_BUFFERED:
293                         self->double_buffered = g_value_get_boolean (value);
294                         gtk_widget_set_double_buffered (GTK_WIDGET(self->vte_term), self->double_buffered);
295                         g_print ("terminal double buffered: %d\n", self->double_buffered);
296                         break;
297
298                 default:
299                         /* We don't have this property... */
300                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
301                         break;
302         }
303 }
304
305 static void
306 tilda_terminal_get_property (GObject    *object,
307                                                          guint       property_id,
308                                                          GValue     *value,
309                                                          GParamSpec *pspec)
310 {
311         TildaTerminal *self = (TildaTerminal *) object;
312
313         switch (property_id) {
314
315                 case TILDA_TERMINAL_NUMBER:
316                         g_value_set_int (value, self->number);
317                         break;
318
319                 case TILDA_TERMINAL_WINDOW_NUMBER:
320                         g_value_set_int (value, self->window_number);
321                         break;
322
323                 case TILDA_TERMINAL_TW:
324                         g_value_set_pointer (value, self->parent_window);
325                         break;
326
327                 case TILDA_TERMINAL_BACKGROUND_IMAGE:
328                         g_value_set_string (value, self->background_image);
329                         break;
330
331                 case TILDA_TERMINAL_SHELL:
332                         g_value_set_string (value, self->shell);
333                         break;
334
335                 case TILDA_TERMINAL_FONT:
336                         g_value_set_string (value, self->font);
337                         break;
338
339                 case TILDA_TERMINAL_TITLE:
340                         g_value_set_string (value, self->title);
341                         break;
342
343                 case TILDA_TERMINAL_WORKING_DIRECTORY:
344                         g_value_set_string (value, self->working_directory);
345                         break;
346
347                 case TILDA_TERMINAL_SCROLLBACK_LINES:
348                         g_value_set_int (value, self->scrollback_lines);
349                         break;
350
351                 case TILDA_TERMINAL_TRANSPARENCY_PERCENT:
352                         g_value_set_int (value, self->transparency_percent);
353                         break;
354
355                 case TILDA_TERMINAL_BACKSPACE_BINDING:
356                         g_value_set_int (value, self->backspace_binding);
357                         break;
358
359                 case TILDA_TERMINAL_DELETE_BINDING:
360                         g_value_set_int (value, self->delete_binding);
361                         break;
362
363                 case TILDA_TERMINAL_DYNAMIC_TITLE:
364                         g_value_set_int (value, self->dynamic_title);
365                         break;
366
367                 case TILDA_TERMINAL_EXIT_ACTION:
368                         g_value_set_int (value, self->exit_action);
369                         break;
370
371                 case TILDA_TERMINAL_SCROLL_BACKGROUND:
372                         g_value_set_boolean (value, self->scroll_background);
373                         break;
374
375                 case TILDA_TERMINAL_SCROLL_ON_OUTPUT:
376                         g_value_set_boolean (value, self->scroll_on_output);
377                         break;
378
379                 case TILDA_TERMINAL_SCROLL_ON_KEYSTROKE:
380                         g_value_set_boolean (value, self->scroll_on_keystroke);
381                         break;
382
383                 case TILDA_TERMINAL_ANTIALIASED:
384                         g_value_set_boolean (value, self->antialiased);
385                         break;
386
387                 case TILDA_TERMINAL_ALLOW_BOLD_TEXT:
388                         g_value_set_boolean (value, self->allow_bold_text);
389                         break;
390
391                 case TILDA_TERMINAL_CURSOR_BLINKS:
392                         g_value_set_boolean (value, self->cursor_blinks);
393                         break;
394
395                 case TILDA_TERMINAL_AUDIBLE_BELL:
396                         g_value_set_boolean (value, self->audible_bell);
397                         break;
398
399                 case TILDA_TERMINAL_VISIBLE_BELL:
400                         g_value_set_boolean (value, self->visible_bell);
401                         break;
402
403                 case TILDA_TERMINAL_DOUBLE_BUFFERED:
404                         g_value_set_boolean (value, self->double_buffered);
405                         break;
406
407                 default:
408                         /* We don't have this property... */
409                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
410                         break;
411         }
412 }
413
414 static GObject *
415 tilda_terminal_constructor (GType                  type,
416                                                         guint                  n_construct_properties,
417                                                         GObjectConstructParam *construct_properties)
418 {
419         GObject *obj;
420         TildaTerminal *self;
421
422         /* Invoke parent constructor */
423         TildaTerminalClass *klass;
424         klass = TILDA_TERMINAL_CLASS (g_type_class_peek (TILDA_TYPE_TERMINAL));
425         obj = parent_class->constructor (type,
426                                                                          n_construct_properties,
427                                                                          construct_properties);
428
429         /* Do other stuff here. The object is ready to go now, and all
430          * ctor properties have been set.
431          *
432          * TODO: This is the place to do DBus-init */
433         self = TILDA_TERMINAL(obj);
434
435         /* Pack into the hbox */
436         gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0);
437         gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0);
438         gtk_widget_show (self->scrollbar);
439
440
441         g_signal_connect (G_OBJECT(self->vte_term), "child-exited",
442                                           G_CALLBACK(gtk_main_quit), self);
443
444         tilda_terminal_start_shell (self);
445         tilda_terminal_dbus_register_object (self);
446
447         return obj;
448 }
449
450 static void
451 tilda_terminal_dispose (GObject *obj)
452 {
453         TildaTerminal *self = (TildaTerminal *) obj;
454
455         /* We don't want to run dispose twice, so just return immediately */
456         if (self->dispose_has_run)
457                 return;
458
459         self->dispose_has_run = TRUE;
460
461         /*
462          * In dispose, you are supposed to free all types referenced from this
463          * object which might themselves hold a reference to self. Generally,
464          * the most simple solution is to unref all members on which you own a
465          * reference.
466          */
467
468         /* Chain up to the parent class */
469         G_OBJECT_CLASS (parent_class)->dispose (obj);
470 }
471
472 static void
473 tilda_terminal_finalize (GObject *obj)
474 {
475         TildaTerminal *self = (TildaTerminal *) obj;
476
477         /*
478          * Here, complete object destruction.
479          * You might not need to do much...
480          */
481
482         // TODO: g_free() any primitives here
483         g_free (self->background_image);
484         g_free (self->shell);
485         g_free (self->font);
486         g_free (self->title);
487         g_free (self->working_directory);
488
489
490         /* Chain up to the parent class */
491         G_OBJECT_CLASS (parent_class)->finalize (obj);
492 }
493
494 static void
495 tilda_terminal_class_init (gpointer g_class,
496                                                    gpointer g_class_data)
497 {
498         GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
499         TildaTerminalClass *klass = TILDA_TERMINAL_CLASS (g_class);
500         GParamSpec *pspec;
501
502         /* Hook our functions to this type */
503         gobject_class->set_property = tilda_terminal_set_property;
504         gobject_class->get_property = tilda_terminal_get_property;
505         gobject_class->dispose = tilda_terminal_dispose;
506         gobject_class->finalize = tilda_terminal_finalize;
507         gobject_class->constructor = tilda_terminal_constructor;
508
509         parent_class = g_type_class_peek_parent (klass);
510
511         /* Hook the TildaTerminal type into DBus */
512         dbus_g_object_type_install_info (tilda_terminal_get_type(), &dbus_glib_tilda_terminal_object_info);
513
514         /* Install all of the properties */
515         pspec = g_param_spec_int ("number",
516                                                           "Terminal number",
517                                                           "Set terminal's number",
518                                                           0,            // min value
519                                                           INT_MAX,      // max value
520                                                           0,            // def value
521                                                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
522
523         g_object_class_install_property (gobject_class,
524                                                                          TILDA_TERMINAL_NUMBER,
525                                                                          pspec);
526
527         pspec = g_param_spec_int ("window-number",
528                                                           "Number of the window to which this terminal belongs",
529                                                           "Set the number of the parent window",
530                                                           0,
531                                                           INT_MAX,
532                                                           0x0000beef,
533                                                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
534
535         g_object_class_install_property (gobject_class,
536                                                                          TILDA_TERMINAL_WINDOW_NUMBER,
537                                                                          pspec);
538
539         pspec = g_param_spec_pointer ("parent-window",
540                                                                   "Pointer to terminal's parent TildaWindow",
541                                                                   "Set the pointer to the terminal's parent TildaWindow",
542                                                                   G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
543
544         g_object_class_install_property (gobject_class,
545                                                                          TILDA_TERMINAL_TW,
546                                                                          pspec);
547
548         pspec = g_param_spec_string ("background-image",
549                                                                  "Terminal's background image",
550                                                                  "Get/Set terminal's background image",
551                                                                  NULL,
552                                                                  G_PARAM_READWRITE);
553
554         g_object_class_install_property (gobject_class,
555                                                                          TILDA_TERMINAL_BACKGROUND_IMAGE,
556                                                                          pspec);
557
558         pspec = g_param_spec_string ("shell",
559                                                                  "Terminal's shell",
560                                                                  "Get/Set terminal's shell",
561                                                                  NULL,
562                                                                  G_PARAM_READWRITE);
563
564         g_object_class_install_property (gobject_class,
565                                                                          TILDA_TERMINAL_SHELL,
566                                                                          pspec);
567
568         pspec = g_param_spec_string ("font",
569                                                                  "Terminal's font",
570                                                                  "Get/Set terminal's font",
571                                                                  NULL,
572                                                                  G_PARAM_READWRITE);
573
574         g_object_class_install_property (gobject_class,
575                                                                          TILDA_TERMINAL_FONT,
576                                                                          pspec);
577
578         pspec = g_param_spec_string ("title",
579                                                                  "Terminal's title",
580                                                                  "Get/Set terminal's title",
581                                                                  NULL,
582                                                                  G_PARAM_READWRITE);
583
584         g_object_class_install_property (gobject_class,
585                                                                          TILDA_TERMINAL_TITLE,
586                                                                          pspec);
587
588         pspec = g_param_spec_string ("working-directory",
589                                                                  "Terminal's initial working directory",
590                                                                  "Get/Set terminal's initial working directory",
591                                                                  NULL,
592                                                                  G_PARAM_READWRITE);
593
594         g_object_class_install_property (gobject_class,
595                                                                          TILDA_TERMINAL_WORKING_DIRECTORY,
596                                                                          pspec);
597
598         pspec = g_param_spec_int ("scrollback-lines",
599                                                           "Terminal's scrollback amount (lines)",
600                                                           "Get/Set terminal's scrollback amount",
601                                                           0,
602                                                           INT_MAX, // TODO: artificially limit this?
603                                                           1000,
604                                                           G_PARAM_READWRITE);
605
606         g_object_class_install_property (gobject_class,
607                                                                          TILDA_TERMINAL_SCROLLBACK_LINES,
608                                                                          pspec);
609
610         pspec = g_param_spec_int ("transparency-percent",
611                                                           "Terminal's transparency (percent)",
612                                                           "Get/Set terminal's transparency",
613                                                           0,
614                                                           100,
615                                                           0,
616                                                           G_PARAM_READWRITE);
617
618         g_object_class_install_property (gobject_class,
619                                                                          TILDA_TERMINAL_TRANSPARENCY_PERCENT,
620                                                                          pspec);
621
622         pspec = g_param_spec_int ("backspace-binding",
623                                                           "Terminal's backspace binding",
624                                                           "Get/Set terminal's backspace key binding",
625                                                           VTE_ERASE_AUTO,
626                                                           VTE_ERASE_DELETE_SEQUENCE,
627                                                           VTE_ERASE_AUTO,
628                                                           G_PARAM_READWRITE);
629
630         g_object_class_install_property (gobject_class,
631                                                                          TILDA_TERMINAL_BACKSPACE_BINDING,
632                                                                          pspec);
633
634         pspec = g_param_spec_int ("delete-binding",
635                                                           "Terminal's delete binding",
636                                                           "Get/Set terminal's delete key binding",
637                                                           VTE_ERASE_AUTO,
638                                                           VTE_ERASE_DELETE_SEQUENCE,
639                                                           VTE_ERASE_AUTO,
640                                                           G_PARAM_READWRITE);
641
642         g_object_class_install_property (gobject_class,
643                                                                          TILDA_TERMINAL_DELETE_BINDING,
644                                                                          pspec);
645
646         pspec = g_param_spec_int ("dynamic-title",
647                                                           "Terminal's dynamic title generation method",
648                                                           "Get/Set terminal's dynamic title generation method",
649                                                           0,
650                                                           INT_MAX,
651                                                           0,
652                                                           G_PARAM_READWRITE);
653
654         g_object_class_install_property (gobject_class,
655                                                                          TILDA_TERMINAL_DYNAMIC_TITLE,
656                                                                          pspec);
657
658         pspec = g_param_spec_int ("exit-action",
659                                                           "Terminal's action upon child exit",
660                                                           "Get/Set terminal's action upon child exit",
661                                                           0,
662                                                           INT_MAX,
663                                                           0,
664                                                           G_PARAM_READWRITE);
665
666         g_object_class_install_property (gobject_class,
667                                                                          TILDA_TERMINAL_EXIT_ACTION,
668                                                                          pspec);
669
670         pspec = g_param_spec_boolean ("scroll-background",
671                                                                   "Controls terminal's scrolling behavior",
672                                                                   "Get/Set terminal's scrolling behavior",
673                                                                   FALSE,
674                                                                   G_PARAM_READWRITE);
675
676         g_object_class_install_property (gobject_class,
677                                                                          TILDA_TERMINAL_SCROLL_BACKGROUND,
678                                                                          pspec);
679
680         pspec = g_param_spec_boolean ("scroll-on-output",
681                                                                   "Controls terminal's scrolling behavior on output",
682                                                                   "Get/Set terminal's scrolling behavior on output",
683                                                                   FALSE,
684                                                                   G_PARAM_READWRITE);
685
686         g_object_class_install_property (gobject_class,
687                                                                          TILDA_TERMINAL_SCROLL_ON_OUTPUT,
688                                                                          pspec);
689
690         pspec = g_param_spec_boolean ("scroll-on-keystroke",
691                                                                   "Controls the terminal's scrolling behavior on keystroke",
692                                                                   NULL, FALSE, G_PARAM_READWRITE);
693
694         g_object_class_install_property (gobject_class,
695                                                                          TILDA_TERMINAL_SCROLL_ON_KEYSTROKE,
696                                                                          pspec);
697
698         pspec = g_param_spec_boolean ("antialiased",
699                                                                   "Attempt to antialias fonts",
700                                                                   NULL, FALSE, G_PARAM_READWRITE);
701
702         g_object_class_install_property (gobject_class,
703                                                                          TILDA_TERMINAL_ANTIALIASED,
704                                                                          pspec);
705
706         pspec = g_param_spec_boolean ("allow-bold-text",
707                                                                   "Allow bold text",
708                                                                   NULL, FALSE, G_PARAM_READWRITE);
709
710         g_object_class_install_property (gobject_class,
711                                                                          TILDA_TERMINAL_ALLOW_BOLD_TEXT,
712                                                                          pspec);
713
714         pspec = g_param_spec_boolean ("cursor-blinks",
715                                                                   NULL, NULL, FALSE, G_PARAM_READWRITE);
716
717         g_object_class_install_property (gobject_class,
718                                                                          TILDA_TERMINAL_CURSOR_BLINKS,
719                                                                          pspec);
720
721         pspec = g_param_spec_boolean ("audible-bell",
722                                                                   NULL, NULL, FALSE, G_PARAM_READWRITE);
723
724         g_object_class_install_property (gobject_class,
725                                                                          TILDA_TERMINAL_AUDIBLE_BELL,
726                                                                          pspec);
727
728         pspec = g_param_spec_boolean ("visible-bell",
729                                                                   NULL, NULL, FALSE, G_PARAM_READWRITE);
730
731         g_object_class_install_property (gobject_class,
732                                                                          TILDA_TERMINAL_VISIBLE_BELL,
733                                                                          pspec);
734
735         pspec = g_param_spec_boolean ("double-buffered",
736                                                                   NULL, NULL, FALSE, G_PARAM_READWRITE);
737
738         g_object_class_install_property (gobject_class,
739                                                                          TILDA_TERMINAL_DOUBLE_BUFFERED,
740                                                                          pspec);
741 }
742
743 GType
744 tilda_terminal_get_type (void)
745 {
746         static GType type = 0;
747
748         if (type == 0)
749         {
750                 static const GTypeInfo info = {
751                         sizeof (TildaTerminalClass),
752                         NULL,   /* base_init */
753                         NULL,   /* base_finalize */
754                         tilda_terminal_class_init,      /* class_init */
755                         NULL,   /* class_finalize */
756                         NULL,   /* class_data */
757                         sizeof (TildaTerminal),
758                         0,              /* n_preallocs */
759                         tilda_terminal_instance_init,   /* instance_init */
760                 };
761
762                 type = g_type_register_static (G_TYPE_OBJECT,
763                                                                            "TildaTerminalType",
764                                                                            &info,
765                                                                            0);
766         }
767
768         return type;
769 }
770
771 #if 0
772
773 int main (int argc, char *argv[])
774 {
775         GObject *tt;
776         gint test_number = INT_MIN;
777         gchar *test_string = NULL;
778
779         /* Initialize the GObject type system */
780         g_type_init ();
781         gtk_init (&argc, &argv);
782
783         tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 10, NULL);
784         g_object_get (G_OBJECT (tt), "number", &test_number, NULL);
785         g_assert (test_number == 10);
786
787         g_object_unref (G_OBJECT (tt));
788
789         tt = g_object_new (TILDA_TYPE_TERMINAL, "number", 22, NULL);
790         g_object_get (G_OBJECT (tt), "number", &test_number, NULL);
791         g_assert (test_number == 22);
792
793         g_object_set (G_OBJECT (tt), "font", "hello I'm a font");
794         g_object_set (G_OBJECT (tt), "font", "Bitstream Vera Sans Mono 13");
795
796         g_object_get (G_OBJECT (tt), "font", &test_string, NULL);
797         g_print ("Read Font: %s\n", test_string);
798         // NOTE: you MUST free the string!!!!
799         g_free (test_string);
800
801         g_object_set (G_OBJECT (tt), "transparency-percent", 50);
802
803         g_object_unref (G_OBJECT (tt));
804
805         return 0;
806 }
807
808 #endif
809
810 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */