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