[Window] Add all properties
[tilda-gobject.git] / tilda-window.c
1 #include "tilda.h"
2 #include "tilda-window.h"
3 #include "tilda-window-dbus-glue.h"
4
5 static gint
6 tilda_window_find_next_free_terminal_number (TildaWindow *tw)
7 {
8         gint i, j;
9         gboolean found;
10
11         for (i=0; i<INT_MAX; ++i)
12         {
13                 found = FALSE;
14
15                 for (j=0; j<tw->terms->len; ++j)
16                 {
17                         TildaTerminal *tt = g_ptr_array_index (tw->terms, j);
18
19                         if (tt->number == i)
20                         {
21                                 found = TRUE;
22                                 break;
23                         }
24                 }
25
26                 if (!found)
27                         return i;
28         }
29
30         return 0;
31 }
32
33 static gboolean
34 tilda_window_add_term (TildaWindow *tw)
35 {
36         gint number;
37         TildaTerminal *tt;
38
39         number = tilda_window_find_next_free_terminal_number (tw);
40         tt = g_object_new (TILDA_TYPE_TERMINAL,
41                                            "number", number,
42                                            "window-number", tw->number,
43                                            "parent-window", tw,
44                                            NULL);
45         g_ptr_array_add (tw->terms, tt);
46
47         GtkWidget *label = gtk_label_new ("Tilda");
48         gint index = gtk_notebook_prepend_page (GTK_NOTEBOOK(tw->notebook), tt->hbox, label);
49         gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK(tw->notebook), tt->hbox, TRUE, TRUE, GTK_PACK_END);
50         //gtk_notebook_set_current_page (GTK_NOTEBOOK(tw->notebook), index);
51
52         if (gtk_notebook_get_n_pages (GTK_NOTEBOOK(tw->notebook)) > 1)
53                 gtk_notebook_set_show_tabs (GTK_NOTEBOOK(tw->notebook), TRUE);
54
55         return TRUE;
56 }
57
58 /**
59  * Remove the TildaTerminal with the given number from the given
60  * TildaWindow.
61  *
62  * Return: TRUE on success, FALSE otherwise.
63  */
64 gboolean
65 tilda_window_remove_term (TildaWindow *tw, gint terminal_number)
66 {
67         gint i;
68
69         for (i=0; i<tw->terms->len; ++i)
70         {
71                 TildaTerminal *tt = g_ptr_array_index (tw->terms, i);
72
73                 if (tt->number == terminal_number)
74                 {
75                         gint notebook_index = gtk_notebook_page_num (GTK_NOTEBOOK(tw->notebook), tt->hbox);
76
77                         /* Make sure the index was valid */
78                         if (notebook_index == -1)
79                         {
80                                 g_printerr ("DEBUG ERROR: Bad Notebook Tab\n");
81                                 return FALSE;
82                         }
83
84                         /* Actually remove the terminal */
85                         gtk_notebook_remove_page (GTK_NOTEBOOK (tw->notebook), notebook_index);
86
87                         /* We should hide the tabs if there is only one tab left */
88                         if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (tw->notebook)) == 1)
89                                 gtk_notebook_set_show_tabs (GTK_NOTEBOOK (tw->notebook), FALSE);
90
91 #if 0
92                         // FIXME FIXME FIXME: need to actually do the stuff below
93                         /* With no pages left, it's time to leave the program */
94                         if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (tw->notebook)) < 1)
95                                 gtk_main_quit ();
96 #endif
97
98                         /* Remove the term from our lists, then free it */
99                         g_ptr_array_remove_fast (tw->terms, tt);
100                         g_object_unref (G_OBJECT(tt));
101
102                         /* Leave the loop, we're done */
103                         break;
104                 }
105         }
106
107         return TRUE;
108 }
109
110 /**
111  * This sets up the given TildaWindow for the capability of real
112  * transparency, if the X server is capable of it. */
113 static void
114 tilda_window_setup_real_transparency (TildaWindow *self)
115 {
116         GdkScreen *screen;
117         GdkColormap *colormap;
118
119         screen = gtk_widget_get_screen (GTK_WIDGET(self->window));
120         colormap = gdk_screen_get_rgba_colormap (screen);
121
122         /* If possible, set the RGBA colormap so VTE can use real alpha
123          * channels for transparency. */
124         if (colormap != NULL && gdk_screen_is_composited (screen))
125         {
126                 gtk_widget_set_colormap (GTK_WIDGET(self->window), colormap);
127                 self->have_real_transparency = TRUE;
128                 return;
129         }
130
131         self->have_real_transparency = FALSE;
132 }
133
134 static void
135 tilda_window_dbus_register_object (TildaWindow *tw)
136 {
137         gchar *object_path;
138
139         // Register this object with DBus
140         object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d", tw->number);
141         dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tw));
142         g_free (object_path);
143 }
144
145 /*******************************************************************************
146  * ALL GOBJECT STUFF BELOW PLEASE
147  ******************************************************************************/
148
149 static GObjectClass *parent_class = NULL;
150
151 enum tilda_window_properties {
152         TILDA_WINDOW_NUMBER = 1,
153
154         TILDA_WINDOW_KEY,
155
156         TILDA_WINDOW_MIN_HEIGHT,
157         TILDA_WINDOW_MIN_WIDTH,
158         TILDA_WINDOW_MAX_HEIGHT,
159         TILDA_WINDOW_MAX_WIDTH,
160         TILDA_WINDOW_X_POSITION,
161         TILDA_WINDOW_Y_POSITION,
162
163         TILDA_WINDOW_TAB_POSITION,
164         TILDA_WINDOW_ANIMATION_ORIENTATION,
165         TILDA_WINDOW_ANIMATION_DELAY,
166
167         TILDA_WINDOW_KEEP_ABOVE,
168         TILDA_WINDOW_SHOW_IN_TASKBAR,
169         TILDA_WINDOW_PINNED,
170         TILDA_WINDOW_HIDDEN_AT_START,
171         TILDA_WINDOW_CENTERED_HORIZONTALLY,
172         TILDA_WINDOW_CENTERED_VERTICALLY,
173
174         TILDA_WINDOW_HAVE_REAL_TRANSPARENCY,
175 };
176
177 static void
178 tilda_window_instance_init (GTypeInstance *instance,
179                                                         gpointer       g_class)
180 {
181         TildaWindow *self = (TildaWindow *) instance;
182         self->dispose_has_run = FALSE;
183
184         /* Initialize all properties */
185         self->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
186         self->notebook = gtk_notebook_new ();
187         self->terms = g_ptr_array_new ();
188
189         /* Somewhat of a "poison" value, incase we don't set this */
190         self->number = 0xdeadbeef;
191 }
192
193 static void
194 tilda_window_set_property (GObject      *object,
195                                                    guint         property_id,
196                                                    const GValue *value,
197                                                    GParamSpec   *pspec)
198 {
199         TildaWindow *self = (TildaWindow *) object;
200
201         switch (property_id) {
202
203                 case TILDA_WINDOW_NUMBER:
204                         self->number = g_value_get_int (value);
205                         g_print ("window number: %d\n", self->number);
206                         break;
207
208                 case TILDA_WINDOW_KEY:
209                         self->key = g_value_dup_string (value);
210                         g_print ("window key: %s\n", self->key);
211                         break;
212
213                 case TILDA_WINDOW_MIN_HEIGHT:
214                         self->min_height = g_value_get_int (value);
215                         g_print ("window min height: %d\n", self->min_height);
216                         break;
217
218                 case TILDA_WINDOW_MIN_WIDTH:
219                         self->min_width = g_value_get_int (value);
220                         g_print ("window min width: %d\n", self->min_width);
221                         break;
222
223                 case TILDA_WINDOW_MAX_HEIGHT:
224                         self->max_height = g_value_get_int (value);
225                         g_print ("window max height: %d\n", self->max_height);
226                         break;
227
228                 case TILDA_WINDOW_MAX_WIDTH:
229                         self->max_width = g_value_get_int (value);
230                         g_print ("window max width: %d\n", self->max_width);
231                         break;
232
233                 case TILDA_WINDOW_X_POSITION:
234                         self->x_position = g_value_get_int (value);
235                         g_print ("window x position: %d\n", self->x_position);
236                         break;
237
238                 case TILDA_WINDOW_Y_POSITION:
239                         self->y_position = g_value_get_int (value);
240                         g_print ("window y position: %d\n", self->y_position);
241                         break;
242
243                 case TILDA_WINDOW_TAB_POSITION:
244                         self->tab_position = g_value_get_int (value);
245                         g_print ("window tab position: %d\n", self->tab_position);
246                         break;
247
248                 case TILDA_WINDOW_ANIMATION_ORIENTATION:
249                         self->animation_orientation = g_value_get_int (value);
250                         g_print ("window animation orientation: %d\n", self->animation_orientation);
251                         break;
252
253                 case TILDA_WINDOW_ANIMATION_DELAY:
254                         self->animation_delay = g_value_get_int (value);
255                         g_print ("window animation delay: %d\n", self->animation_delay);
256                         break;
257
258                 case TILDA_WINDOW_KEEP_ABOVE:
259                         self->keep_above = g_value_get_boolean (value);
260                         g_print ("window keep above: %d\n", self->keep_above);
261                         break;
262
263                 case TILDA_WINDOW_SHOW_IN_TASKBAR:
264                         self->show_in_taskbar = g_value_get_boolean (value);
265                         g_print ("window show in taskbar: %d\n", self->show_in_taskbar);
266                         break;
267
268                 case TILDA_WINDOW_PINNED:
269                         self->pinned = g_value_get_boolean (value);
270                         g_print ("window pinned: %d\n", self->pinned);
271                         break;
272
273                 case TILDA_WINDOW_HIDDEN_AT_START:
274                         self->hidden_at_start = g_value_get_boolean (value);
275                         g_print ("window hidden at start: %d\n", self->hidden_at_start);
276                         break;
277
278                 case TILDA_WINDOW_CENTERED_HORIZONTALLY:
279                         self->centered_horizontally = g_value_get_boolean (value);
280                         g_print ("window centered horizontally: %d\n", self->centered_horizontally);
281                         break;
282
283                 case TILDA_WINDOW_CENTERED_VERTICALLY:
284                         self->centered_vertically = g_value_get_boolean (value);
285                         g_print ("window centered vertically: %d\n", self->centered_vertically);
286                         break;
287
288                 case TILDA_WINDOW_HAVE_REAL_TRANSPARENCY:
289                         self->have_real_transparency = g_value_get_boolean (value);
290                         g_print ("window have real transp: %d\n", self->have_real_transparency);
291                         break;
292
293                 default:
294                         /* We don't have this property */
295                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
296                         break;
297         }
298 }
299
300 static void
301 tilda_window_get_property (GObject    *object,
302                                                    guint       property_id,
303                                                    GValue     *value,
304                                                    GParamSpec *pspec)
305 {
306         TildaWindow *self = (TildaWindow *) object;
307
308         switch (property_id) {
309
310                 case TILDA_WINDOW_NUMBER:
311                         g_value_set_int (value, self->number);
312                         break;
313
314                 case TILDA_WINDOW_KEY:
315                         g_value_set_string (value, self->key);
316                         break;
317
318                 case TILDA_WINDOW_MIN_HEIGHT:
319                         g_value_set_int (value, self->min_height);
320                         break;
321
322                 case TILDA_WINDOW_MIN_WIDTH:
323                         g_value_set_int (value, self->min_width);
324                         break;
325
326                 case TILDA_WINDOW_MAX_HEIGHT:
327                         g_value_set_int (value, self->max_height);
328                         break;
329
330                 case TILDA_WINDOW_MAX_WIDTH:
331                         g_value_set_int (value, self->max_width);
332                         break;
333
334                 case TILDA_WINDOW_X_POSITION:
335                         g_value_set_int (value, self->x_position);
336                         break;
337
338                 case TILDA_WINDOW_Y_POSITION:
339                         g_value_set_int (value, self->y_position);
340                         break;
341
342                 case TILDA_WINDOW_TAB_POSITION:
343                         g_value_set_int (value, self->tab_position);
344                         break;
345
346                 case TILDA_WINDOW_ANIMATION_ORIENTATION:
347                         g_value_set_int (value, self->animation_orientation);
348                         break;
349
350                 case TILDA_WINDOW_ANIMATION_DELAY:
351                         g_value_set_int (value, self->animation_delay);
352                         break;
353
354                 case TILDA_WINDOW_KEEP_ABOVE:
355                         g_value_set_boolean (value, self->keep_above);
356                         break;
357
358                 case TILDA_WINDOW_SHOW_IN_TASKBAR:
359                         g_value_set_boolean (value, self->show_in_taskbar);
360                         break;
361
362                 case TILDA_WINDOW_PINNED:
363                         g_value_set_boolean (value, self->pinned);
364                         break;
365
366                 case TILDA_WINDOW_HIDDEN_AT_START:
367                         g_value_set_boolean (value, self->hidden_at_start);
368                         break;
369
370                 case TILDA_WINDOW_CENTERED_HORIZONTALLY:
371                         g_value_set_boolean (value, self->centered_horizontally);
372                         break;
373
374                 case TILDA_WINDOW_CENTERED_VERTICALLY:
375                         g_value_set_boolean (value, self->centered_vertically);
376                         break;
377
378                 case TILDA_WINDOW_HAVE_REAL_TRANSPARENCY:
379                         g_value_set_boolean (value, self->have_real_transparency);
380                         break;
381
382                 default:
383                         /* We don't have this property */
384                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
385                         break;
386         }
387 }
388
389 static GObject *
390 tilda_window_constructor (GType                  type,
391                                                   guint                  n_construct_properties,
392                                                   GObjectConstructParam *construct_properties)
393 {
394         GObject *obj;
395         TildaWindow *self;
396
397         /* Invoke parent constructor */
398         TildaWindowClass *klass;
399         klass = TILDA_WINDOW_CLASS (g_type_class_peek (TILDA_TYPE_WINDOW));
400         obj = parent_class->constructor (type,
401                                                                          n_construct_properties,
402                                                                          construct_properties);
403
404         /* Do other stuff here. The object is ready to go now, and all
405          * ctor properties have been set.
406          *
407          * TODO: This is the place to do DBus-init */
408         self = TILDA_WINDOW(obj);
409
410         /* Register this object with DBus */
411         tilda_window_dbus_register_object (self);
412
413         /* Try to set up real transparency */
414         tilda_window_setup_real_transparency (self);
415
416         gtk_container_add (GTK_CONTAINER(self->window), self->notebook);
417         gtk_widget_show (self->notebook);
418
419         tilda_window_add_term (self);
420         tilda_window_add_term (self);
421         gtk_widget_show_all (self->window);
422
423         return obj;
424 }
425
426 static void
427 my_unref (gpointer data, gpointer user_data)
428 {
429         g_object_unref (G_OBJECT(data));
430 }
431
432 static void
433 tilda_window_dispose (GObject *obj)
434 {
435         TildaWindow *self = (TildaWindow *) obj;
436
437         /* We don't want to run dispose twice, so just return immediately */
438         if (self->dispose_has_run)
439                 return;
440
441         /*
442          * In dispose, you are supposed to free all types referenced from this
443          * object which might themselves hold a reference to self. Generally,
444          * the most simple solution is to unref all members on which you own a
445          * reference.
446          *
447          * NOTE: See the following for how to deal with GtkObject-derived things:
448          * http://library.gnome.org/devel/gtk/unstable/GtkObject.html
449          */
450         g_ptr_array_foreach (self->terms, my_unref, NULL);
451         gtk_widget_destroy (self->window);
452
453         /* Chain up to the parent class */
454         G_OBJECT_CLASS (parent_class)->dispose (obj);
455 }
456
457 static void
458 tilda_window_finalize (GObject *obj)
459 {
460         TildaWindow *self = (TildaWindow *) obj;
461
462         /*
463          * Here, complete the object's destruction.
464          * You might not need to do much...
465          */
466         // TODO: g_free() any primitives here
467         g_ptr_array_free (self->terms, TRUE);
468
469
470         /* Chain up to the parent class */
471         G_OBJECT_CLASS (parent_class)->finalize (obj);
472 }
473
474 static void
475 tilda_window_class_init (gpointer g_class,
476                                                  gpointer g_class_data)
477 {
478         GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
479         TildaWindowClass *klass = TILDA_WINDOW_CLASS (g_class);
480         GParamSpec *pspec;
481
482         /* Hook our functions to this type */
483         gobject_class->set_property = tilda_window_set_property;
484         gobject_class->get_property = tilda_window_get_property;
485         gobject_class->dispose = tilda_window_dispose;
486         gobject_class->finalize = tilda_window_finalize;
487         gobject_class->constructor = tilda_window_constructor;
488
489         parent_class = g_type_class_peek_parent (klass);
490
491         /* Install all of the properties */
492         pspec = g_param_spec_int ("number",
493                                                           "Window number",
494                                                           "Set window's number",
495                                                           0,            // min value
496                                                           INT_MAX,      // max value
497                                                           0,            // def value
498                                                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
499
500         g_object_class_install_property (gobject_class,
501                                                                          TILDA_WINDOW_NUMBER,
502                                                                          pspec);
503
504         pspec = g_param_spec_string ("key",
505                                                                  "Window's drop-down keybinding",
506                                                                  NULL,
507                                                                  NULL,
508                                                                  G_PARAM_READWRITE);
509
510         g_object_class_install_property (gobject_class,
511                                                                          TILDA_WINDOW_KEY,
512                                                                          pspec);
513
514         pspec = g_param_spec_int ("min-height",
515                                                           "Window's minimum height",
516                                                           NULL,
517                                                           0,
518                                                           INT_MAX,
519                                                           0,
520                                                           G_PARAM_READWRITE);
521
522         g_object_class_install_property (gobject_class,
523                                                                          TILDA_WINDOW_MIN_HEIGHT,
524                                                                          pspec);
525
526         pspec = g_param_spec_int ("min-width",
527                                                           "Window's minimum width",
528                                                           NULL,
529                                                           0,
530                                                           INT_MAX,
531                                                           0,
532                                                           G_PARAM_READWRITE);
533
534         g_object_class_install_property (gobject_class,
535                                                                          TILDA_WINDOW_MIN_WIDTH,
536                                                                          pspec);
537
538         pspec = g_param_spec_int ("max-height",
539                                                           "Window's maximum height",
540                                                           NULL,
541                                                           0,
542                                                           INT_MAX,
543                                                           0,
544                                                           G_PARAM_READWRITE);
545
546         g_object_class_install_property (gobject_class,
547                                                                          TILDA_WINDOW_MAX_HEIGHT,
548                                                                          pspec);
549
550         pspec = g_param_spec_int ("max-width",
551                                                           "Window's maximum width",
552                                                           NULL,
553                                                           0,
554                                                           INT_MAX,
555                                                           0,
556                                                           G_PARAM_READWRITE);
557
558         g_object_class_install_property (gobject_class,
559                                                                          TILDA_WINDOW_MAX_WIDTH,
560                                                                          pspec);
561
562         pspec = g_param_spec_int ("x-position",
563                                                           "Window's x position",
564                                                           NULL,
565                                                           0,
566                                                           INT_MAX,
567                                                           0,
568                                                           G_PARAM_READWRITE);
569
570         g_object_class_install_property (gobject_class,
571                                                                          TILDA_WINDOW_X_POSITION,
572                                                                          pspec);
573
574         pspec = g_param_spec_int ("y-position",
575                                                           "Window's y position",
576                                                           NULL,
577                                                           0,
578                                                           INT_MAX,
579                                                           0,
580                                                           G_PARAM_READWRITE);
581
582         g_object_class_install_property (gobject_class,
583                                                                          TILDA_WINDOW_Y_POSITION,
584                                                                          pspec);
585
586         pspec = g_param_spec_int ("tab-position",
587                                                           "Window's tab position",
588                                                           NULL,
589                                                           0,
590                                                           INT_MAX,
591                                                           0,
592                                                           G_PARAM_READWRITE);
593
594         g_object_class_install_property (gobject_class,
595                                                                          TILDA_WINDOW_TAB_POSITION,
596                                                                          pspec);
597
598         pspec = g_param_spec_int ("animation-orientation",
599                                                           "Window's animation orientation",
600                                                           NULL,
601                                                           0,
602                                                           INT_MAX,
603                                                           0,
604                                                           G_PARAM_READWRITE);
605
606         g_object_class_install_property (gobject_class,
607                                                                          TILDA_WINDOW_ANIMATION_ORIENTATION,
608                                                                          pspec);
609
610         pspec = g_param_spec_int ("animation-delay",
611                                                           "Amount of time in milliseconds between animation intervals",
612                                                           NULL,
613                                                           0,
614                                                           INT_MAX,
615                                                           0,
616                                                           G_PARAM_READWRITE);
617
618         g_object_class_install_property (gobject_class,
619                                                                          TILDA_WINDOW_ANIMATION_DELAY,
620                                                                          pspec);
621
622         pspec = g_param_spec_boolean ("keep-above",
623                                                                   "Keep this window above all others",
624                                                                   NULL,
625                                                                   FALSE,
626                                                                   G_PARAM_READWRITE);
627
628         g_object_class_install_property (gobject_class,
629                                                                          TILDA_WINDOW_KEEP_ABOVE,
630                                                                          pspec);
631
632         pspec = g_param_spec_boolean ("show-in-taskbar",
633                                                                   "Show this window in the taskbar",
634                                                                   NULL,
635                                                                   FALSE,
636                                                                   G_PARAM_READWRITE);
637
638         g_object_class_install_property (gobject_class,
639                                                                          TILDA_WINDOW_SHOW_IN_TASKBAR,
640                                                                          pspec);
641
642         pspec = g_param_spec_boolean ("pinned",
643                                                                   "Display this window on all workspaces",
644                                                                   NULL,
645                                                                   FALSE,
646                                                                   G_PARAM_READWRITE);
647
648         g_object_class_install_property (gobject_class,
649                                                                          TILDA_WINDOW_PINNED,
650                                                                          pspec);
651
652         pspec = g_param_spec_boolean ("hidden-at-start",
653                                                                   "Hide the window when it is first created",
654                                                                   NULL,
655                                                                   FALSE,
656                                                                   G_PARAM_READWRITE);
657
658         g_object_class_install_property (gobject_class,
659                                                                          TILDA_WINDOW_HIDDEN_AT_START,
660                                                                          pspec);
661
662         pspec = g_param_spec_boolean ("centered-horizontally",
663                                                                   "Center the window horizontally",
664                                                                   NULL,
665                                                                   FALSE,
666                                                                   G_PARAM_READWRITE);
667
668         g_object_class_install_property (gobject_class,
669                                                                          TILDA_WINDOW_CENTERED_HORIZONTALLY,
670                                                                          pspec);
671
672         pspec = g_param_spec_boolean ("centered-vertically",
673                                                                   "Center the window vertically",
674                                                                   NULL,
675                                                                   FALSE,
676                                                                   G_PARAM_READWRITE);
677
678         g_object_class_install_property (gobject_class,
679                                                                          TILDA_WINDOW_CENTERED_VERTICALLY,
680                                                                          pspec);
681
682         pspec = g_param_spec_boolean ("have-real-transparency",
683                                                                   NULL, NULL, FALSE, G_PARAM_READABLE);
684
685         g_object_class_install_property (gobject_class,
686                                                                          TILDA_WINDOW_HAVE_REAL_TRANSPARENCY,
687                                                                          pspec);
688
689         /* TODO: more properties */
690
691         /* Hook the TildaWindow type into DBus */
692         dbus_g_object_type_install_info (tilda_window_get_type(), &dbus_glib_tilda_window_object_info);
693 }
694
695 GType
696 tilda_window_get_type (void)
697 {
698         static GType type = 0;
699
700         if (type == 0)
701         {
702                 static const GTypeInfo info = {
703                         sizeof (TildaWindowClass),
704                         NULL,   /* base_init */
705                         NULL,   /* base_finalize */
706                         tilda_window_class_init,        /* class_init */
707                         NULL,   /* class_finalize */
708                         NULL,   /* class_data */
709                         sizeof (TildaWindow),
710                         0,              /* n_preallocs */
711                         tilda_window_instance_init,     /* instance_init */
712                 };
713
714                 type = g_type_register_static (G_TYPE_OBJECT,
715                                                                            "TildaWindowType",
716                                                                            &info,
717                                                                            0);
718         }
719
720         return type;
721 }
722
723 #if 0
724
725 int main (int argc, char *argv[])
726 {
727         GObject *tw;
728         gint test_number = INT_MIN;
729
730         /* Initialize the GObject type system */
731         g_type_init ();
732         gtk_init (&argc, &argv);
733
734         tw = g_object_new (TILDA_TYPE_WINDOW, "number", 10, NULL);
735         g_object_get (G_OBJECT (tw), "number", &test_number, NULL);
736         g_assert (test_number == 10);
737
738         g_object_unref (G_OBJECT (tw));
739
740         tw = g_object_new (TILDA_TYPE_WINDOW, "number", 22, NULL);
741         g_object_get (G_OBJECT (tw), "number", &test_number, NULL);
742         g_assert (test_number == 22);
743
744         gtk_main ();
745
746         g_object_unref (G_OBJECT (tw));
747
748         return 0;
749 }
750
751 #endif
752
753 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */