[Window] Hide window decorations
[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_keybinding_cb (const gchar *keystr, gpointer data)
136 {
137         TildaWindow *self = TILDA_WINDOW(data);
138         g_print ("tilda_window_keybinding_cb() called! -- window %d\n", self->number);
139
140         // FIXME: this doesn't handle animation!
141
142         switch (self->state)
143         {
144                 case WINDOW_UP:
145                         /* Pull Down */
146                         tomboy_window_present_hardcore (GTK_WINDOW(self->window));
147                         self->state = WINDOW_DOWN;
148                         break;
149
150                 case WINDOW_DOWN:
151                         /* Pull Up */
152                         gtk_widget_hide (GTK_WIDGET(self->window));
153                         self->state = WINDOW_UP;
154                         break;
155
156                 default:
157                         g_printerr ("FIXME: the window is in a bad state!\n");
158
159                         /* Pretend we're down, for good measure.... */
160                         self->state = WINDOW_DOWN;
161                         break;
162         }
163 }
164
165 /**
166  * Attempt to bind the new_key to show this window.
167  *
168  * Return: TRUE if successful, FALSE otherwise.
169  */
170 static gboolean
171 tilda_window_try_to_bind_key (TildaWindow *self, const gchar *new_key)
172 {
173         gboolean ret = FALSE;
174
175         /* Make sure the new key is not null in any way */
176         if (new_key == NULL || strcmp("", new_key) == 0)
177                 return FALSE;
178
179         /* Unbind if we were set */
180         if (self->key)
181                 tomboy_keybinder_unbind (self->key, tilda_window_keybinding_cb, self);
182
183         ret = tomboy_keybinder_bind (new_key, tilda_window_keybinding_cb, self);
184
185         /* If it was successful, update the self->key variable and be done with it */
186         if (ret)
187         {
188                 g_free (self->key);
189                 self->key = g_strdup (new_key);
190                 return TRUE;
191         }
192
193         g_printerr ("Keybinding unsuccessful. Reverting to original key\n");
194
195         /* Not successful, so rebind the old key, and return FALSE */
196         if (self->key != NULL && strcmp("",self->key) != 0)
197         {
198                 ret = tomboy_keybinder_bind (self->key, tilda_window_keybinding_cb, self);
199
200                 /* Check that it went ok */
201                 if (!ret)
202                         g_printerr ("Unable to bind original key as well! Oh shit...\n");
203         }
204         else
205                 g_printerr ("No original key to revert to!\n");
206
207         return FALSE;
208 }
209
210 static void
211 tilda_window_dbus_register_object (TildaWindow *tw)
212 {
213         gchar *object_path;
214
215         // Register this object with DBus
216         object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d", tw->number);
217         dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tw));
218         g_free (object_path);
219 }
220
221 /*******************************************************************************
222  * ALL GOBJECT STUFF BELOW PLEASE
223  ******************************************************************************/
224
225 static GObjectClass *parent_class = NULL;
226
227 enum tilda_window_properties {
228         TILDA_WINDOW_NUMBER = 1,
229
230         TILDA_WINDOW_KEY,
231
232         TILDA_WINDOW_MIN_HEIGHT,
233         TILDA_WINDOW_MIN_WIDTH,
234         TILDA_WINDOW_MAX_HEIGHT,
235         TILDA_WINDOW_MAX_WIDTH,
236         TILDA_WINDOW_X_POSITION,
237         TILDA_WINDOW_Y_POSITION,
238
239         TILDA_WINDOW_TAB_POSITION,
240         TILDA_WINDOW_ANIMATION_ORIENTATION,
241         TILDA_WINDOW_ANIMATION_DELAY,
242
243         TILDA_WINDOW_KEEP_ABOVE,
244         TILDA_WINDOW_SHOW_IN_TASKBAR,
245         TILDA_WINDOW_PINNED,
246         TILDA_WINDOW_HIDDEN_AT_START,
247         TILDA_WINDOW_CENTERED_HORIZONTALLY,
248         TILDA_WINDOW_CENTERED_VERTICALLY,
249
250         TILDA_WINDOW_HAVE_REAL_TRANSPARENCY,
251 };
252
253 static void
254 tilda_window_instance_init (GTypeInstance *instance,
255                                                         gpointer       g_class)
256 {
257         TildaWindow *self = (TildaWindow *) instance;
258         self->dispose_has_run = FALSE;
259
260         /* Initialize all properties */
261         self->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
262         self->notebook = gtk_notebook_new ();
263         self->terms = g_ptr_array_new ();
264
265         /* Somewhat of a "poison" value, incase we don't set this */
266         self->number = 0xdeadbeef;
267
268         self->state = WINDOW_UP;
269 }
270
271 static void
272 tilda_window_set_property (GObject      *object,
273                                                    guint         property_id,
274                                                    const GValue *value,
275                                                    GParamSpec   *pspec)
276 {
277         TildaWindow *self = (TildaWindow *) object;
278
279         switch (property_id) {
280
281                 case TILDA_WINDOW_NUMBER:
282                         self->number = g_value_get_int (value);
283                         g_print ("window number: %d\n", self->number);
284                         break;
285
286                 case TILDA_WINDOW_KEY:
287                         tilda_window_try_to_bind_key (self, g_value_get_string (value));
288                         g_print ("window key: %s\n", self->key);
289                         break;
290
291                 case TILDA_WINDOW_MIN_HEIGHT:
292                         self->min_height = g_value_get_int (value);
293                         g_print ("window min height: %d\n", self->min_height);
294                         break;
295
296                 case TILDA_WINDOW_MIN_WIDTH:
297                         self->min_width = g_value_get_int (value);
298                         g_print ("window min width: %d\n", self->min_width);
299                         break;
300
301                 case TILDA_WINDOW_MAX_HEIGHT:
302                         self->max_height = g_value_get_int (value);
303                         g_print ("window max height: %d\n", self->max_height);
304                         break;
305
306                 case TILDA_WINDOW_MAX_WIDTH:
307                         self->max_width = g_value_get_int (value);
308                         g_print ("window max width: %d\n", self->max_width);
309                         break;
310
311                 case TILDA_WINDOW_X_POSITION:
312                         self->x_position = g_value_get_int (value);
313                         gtk_window_move (GTK_WINDOW(self->window), self->x_position, self->y_position);
314                         g_print ("window x position: %d\n", self->x_position);
315                         break;
316
317                 case TILDA_WINDOW_Y_POSITION:
318                         self->y_position = g_value_get_int (value);
319                         gtk_window_move (GTK_WINDOW(self->window), self->x_position, self->y_position);
320                         g_print ("window y position: %d\n", self->y_position);
321                         break;
322
323                 case TILDA_WINDOW_TAB_POSITION:
324                         self->tab_position = g_value_get_int (value);
325                         g_print ("window tab position: %d\n", self->tab_position);
326                         break;
327
328                 case TILDA_WINDOW_ANIMATION_ORIENTATION:
329                         self->animation_orientation = g_value_get_int (value);
330                         g_print ("window animation orientation: %d\n", self->animation_orientation);
331                         break;
332
333                 case TILDA_WINDOW_ANIMATION_DELAY:
334                         self->animation_delay = g_value_get_int (value);
335                         g_print ("window animation delay: %d\n", self->animation_delay);
336                         break;
337
338                 case TILDA_WINDOW_KEEP_ABOVE:
339                         self->keep_above = g_value_get_boolean (value);
340                         g_print ("window keep above: %d\n", self->keep_above);
341                         break;
342
343                 case TILDA_WINDOW_SHOW_IN_TASKBAR:
344                         self->show_in_taskbar = g_value_get_boolean (value);
345                         g_print ("window show in taskbar: %d\n", self->show_in_taskbar);
346                         break;
347
348                 case TILDA_WINDOW_PINNED:
349                         self->pinned = g_value_get_boolean (value);
350                         g_print ("window pinned: %d\n", self->pinned);
351                         break;
352
353                 case TILDA_WINDOW_HIDDEN_AT_START:
354                         self->hidden_at_start = g_value_get_boolean (value);
355                         g_print ("window hidden at start: %d\n", self->hidden_at_start);
356                         break;
357
358                 case TILDA_WINDOW_CENTERED_HORIZONTALLY:
359                         self->centered_horizontally = g_value_get_boolean (value);
360                         g_print ("window centered horizontally: %d\n", self->centered_horizontally);
361                         break;
362
363                 case TILDA_WINDOW_CENTERED_VERTICALLY:
364                         self->centered_vertically = g_value_get_boolean (value);
365                         g_print ("window centered vertically: %d\n", self->centered_vertically);
366                         break;
367
368                 case TILDA_WINDOW_HAVE_REAL_TRANSPARENCY:
369                         self->have_real_transparency = g_value_get_boolean (value);
370                         g_print ("window have real transp: %d\n", self->have_real_transparency);
371                         break;
372
373                 default:
374                         /* We don't have this property */
375                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
376                         break;
377         }
378 }
379
380 static void
381 tilda_window_get_property (GObject    *object,
382                                                    guint       property_id,
383                                                    GValue     *value,
384                                                    GParamSpec *pspec)
385 {
386         TildaWindow *self = (TildaWindow *) object;
387
388         switch (property_id) {
389
390                 case TILDA_WINDOW_NUMBER:
391                         g_value_set_int (value, self->number);
392                         break;
393
394                 case TILDA_WINDOW_KEY:
395                         g_value_set_string (value, self->key);
396                         break;
397
398                 case TILDA_WINDOW_MIN_HEIGHT:
399                         g_value_set_int (value, self->min_height);
400                         break;
401
402                 case TILDA_WINDOW_MIN_WIDTH:
403                         g_value_set_int (value, self->min_width);
404                         break;
405
406                 case TILDA_WINDOW_MAX_HEIGHT:
407                         g_value_set_int (value, self->max_height);
408                         break;
409
410                 case TILDA_WINDOW_MAX_WIDTH:
411                         g_value_set_int (value, self->max_width);
412                         break;
413
414                 case TILDA_WINDOW_X_POSITION:
415                         g_value_set_int (value, self->x_position);
416                         break;
417
418                 case TILDA_WINDOW_Y_POSITION:
419                         g_value_set_int (value, self->y_position);
420                         break;
421
422                 case TILDA_WINDOW_TAB_POSITION:
423                         g_value_set_int (value, self->tab_position);
424                         break;
425
426                 case TILDA_WINDOW_ANIMATION_ORIENTATION:
427                         g_value_set_int (value, self->animation_orientation);
428                         break;
429
430                 case TILDA_WINDOW_ANIMATION_DELAY:
431                         g_value_set_int (value, self->animation_delay);
432                         break;
433
434                 case TILDA_WINDOW_KEEP_ABOVE:
435                         g_value_set_boolean (value, self->keep_above);
436                         break;
437
438                 case TILDA_WINDOW_SHOW_IN_TASKBAR:
439                         g_value_set_boolean (value, self->show_in_taskbar);
440                         break;
441
442                 case TILDA_WINDOW_PINNED:
443                         g_value_set_boolean (value, self->pinned);
444                         break;
445
446                 case TILDA_WINDOW_HIDDEN_AT_START:
447                         g_value_set_boolean (value, self->hidden_at_start);
448                         break;
449
450                 case TILDA_WINDOW_CENTERED_HORIZONTALLY:
451                         g_value_set_boolean (value, self->centered_horizontally);
452                         break;
453
454                 case TILDA_WINDOW_CENTERED_VERTICALLY:
455                         g_value_set_boolean (value, self->centered_vertically);
456                         break;
457
458                 case TILDA_WINDOW_HAVE_REAL_TRANSPARENCY:
459                         g_value_set_boolean (value, self->have_real_transparency);
460                         break;
461
462                 default:
463                         /* We don't have this property */
464                         G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
465                         break;
466         }
467 }
468
469 static GObject *
470 tilda_window_constructor (GType                  type,
471                                                   guint                  n_construct_properties,
472                                                   GObjectConstructParam *construct_properties)
473 {
474         GObject *obj;
475         TildaWindow *self;
476
477         /* Invoke parent constructor */
478         TildaWindowClass *klass;
479         klass = TILDA_WINDOW_CLASS (g_type_class_peek (TILDA_TYPE_WINDOW));
480         obj = parent_class->constructor (type,
481                                                                          n_construct_properties,
482                                                                          construct_properties);
483
484         /* Do other stuff here. The object is ready to go now, and all
485          * ctor properties have been set.
486          *
487          * TODO: This is the place to do DBus-init */
488         self = TILDA_WINDOW(obj);
489
490         /* Register this object with DBus */
491         tilda_window_dbus_register_object (self);
492
493         /* Try to set up real transparency */
494         tilda_window_setup_real_transparency (self);
495
496         gtk_container_add (GTK_CONTAINER(self->window), self->notebook);
497         gtk_widget_show (self->notebook);
498
499         // FIXME: Remove these, and replace with reads from the config system
500         g_object_set (G_OBJECT(self), "key", "F2", NULL);
501         g_object_set (G_OBJECT(self), "x-position", 0, "y-position", 0, NULL);
502
503         gtk_window_set_decorated (GTK_WINDOW(self->window), FALSE);
504
505         tilda_window_add_term (self);
506         tilda_window_add_term (self);
507         gtk_widget_show_all (self->window);
508         self->state = WINDOW_DOWN;
509
510         return obj;
511 }
512
513 static void
514 my_unref (gpointer data, gpointer user_data)
515 {
516         g_object_unref (G_OBJECT(data));
517 }
518
519 static void
520 tilda_window_dispose (GObject *obj)
521 {
522         TildaWindow *self = (TildaWindow *) obj;
523
524         /* We don't want to run dispose twice, so just return immediately */
525         if (self->dispose_has_run)
526                 return;
527
528         /*
529          * In dispose, you are supposed to free all types referenced from this
530          * object which might themselves hold a reference to self. Generally,
531          * the most simple solution is to unref all members on which you own a
532          * reference.
533          *
534          * NOTE: See the following for how to deal with GtkObject-derived things:
535          * http://library.gnome.org/devel/gtk/unstable/GtkObject.html
536          */
537         g_ptr_array_foreach (self->terms, my_unref, NULL);
538         gtk_widget_destroy (self->window);
539
540         /* Chain up to the parent class */
541         G_OBJECT_CLASS (parent_class)->dispose (obj);
542 }
543
544 static void
545 tilda_window_finalize (GObject *obj)
546 {
547         TildaWindow *self = (TildaWindow *) obj;
548
549         /*
550          * Here, complete the object's destruction.
551          * You might not need to do much...
552          */
553         // TODO: g_free() any primitives here
554         g_ptr_array_free (self->terms, TRUE);
555
556
557         /* Chain up to the parent class */
558         G_OBJECT_CLASS (parent_class)->finalize (obj);
559 }
560
561 static void
562 tilda_window_class_init (gpointer g_class,
563                                                  gpointer g_class_data)
564 {
565         GObjectClass *gobject_class = G_OBJECT_CLASS (g_class);
566         TildaWindowClass *klass = TILDA_WINDOW_CLASS (g_class);
567         GParamSpec *pspec;
568
569         /* Hook our functions to this type */
570         gobject_class->set_property = tilda_window_set_property;
571         gobject_class->get_property = tilda_window_get_property;
572         gobject_class->dispose = tilda_window_dispose;
573         gobject_class->finalize = tilda_window_finalize;
574         gobject_class->constructor = tilda_window_constructor;
575
576         parent_class = g_type_class_peek_parent (klass);
577
578         /* Install all of the properties */
579         pspec = g_param_spec_int ("number",
580                                                           "Window number",
581                                                           "Set window's number",
582                                                           0,            // min value
583                                                           INT_MAX,      // max value
584                                                           0,            // def value
585                                                           G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
586
587         g_object_class_install_property (gobject_class,
588                                                                          TILDA_WINDOW_NUMBER,
589                                                                          pspec);
590
591         pspec = g_param_spec_string ("key",
592                                                                  "Window's drop-down keybinding",
593                                                                  NULL,
594                                                                  NULL,
595                                                                  G_PARAM_READWRITE);
596
597         g_object_class_install_property (gobject_class,
598                                                                          TILDA_WINDOW_KEY,
599                                                                          pspec);
600
601         pspec = g_param_spec_int ("min-height",
602                                                           "Window's minimum height",
603                                                           NULL,
604                                                           0,
605                                                           INT_MAX,
606                                                           0,
607                                                           G_PARAM_READWRITE);
608
609         g_object_class_install_property (gobject_class,
610                                                                          TILDA_WINDOW_MIN_HEIGHT,
611                                                                          pspec);
612
613         pspec = g_param_spec_int ("min-width",
614                                                           "Window's minimum width",
615                                                           NULL,
616                                                           0,
617                                                           INT_MAX,
618                                                           0,
619                                                           G_PARAM_READWRITE);
620
621         g_object_class_install_property (gobject_class,
622                                                                          TILDA_WINDOW_MIN_WIDTH,
623                                                                          pspec);
624
625         pspec = g_param_spec_int ("max-height",
626                                                           "Window's maximum height",
627                                                           NULL,
628                                                           0,
629                                                           INT_MAX,
630                                                           0,
631                                                           G_PARAM_READWRITE);
632
633         g_object_class_install_property (gobject_class,
634                                                                          TILDA_WINDOW_MAX_HEIGHT,
635                                                                          pspec);
636
637         pspec = g_param_spec_int ("max-width",
638                                                           "Window's maximum width",
639                                                           NULL,
640                                                           0,
641                                                           INT_MAX,
642                                                           0,
643                                                           G_PARAM_READWRITE);
644
645         g_object_class_install_property (gobject_class,
646                                                                          TILDA_WINDOW_MAX_WIDTH,
647                                                                          pspec);
648
649         pspec = g_param_spec_int ("x-position",
650                                                           "Window's x position",
651                                                           NULL,
652                                                           0,
653                                                           INT_MAX,
654                                                           0,
655                                                           G_PARAM_READWRITE);
656
657         g_object_class_install_property (gobject_class,
658                                                                          TILDA_WINDOW_X_POSITION,
659                                                                          pspec);
660
661         pspec = g_param_spec_int ("y-position",
662                                                           "Window's y position",
663                                                           NULL,
664                                                           0,
665                                                           INT_MAX,
666                                                           0,
667                                                           G_PARAM_READWRITE);
668
669         g_object_class_install_property (gobject_class,
670                                                                          TILDA_WINDOW_Y_POSITION,
671                                                                          pspec);
672
673         pspec = g_param_spec_int ("tab-position",
674                                                           "Window's tab position",
675                                                           NULL,
676                                                           0,
677                                                           INT_MAX,
678                                                           0,
679                                                           G_PARAM_READWRITE);
680
681         g_object_class_install_property (gobject_class,
682                                                                          TILDA_WINDOW_TAB_POSITION,
683                                                                          pspec);
684
685         pspec = g_param_spec_int ("animation-orientation",
686                                                           "Window's animation orientation",
687                                                           NULL,
688                                                           0,
689                                                           INT_MAX,
690                                                           0,
691                                                           G_PARAM_READWRITE);
692
693         g_object_class_install_property (gobject_class,
694                                                                          TILDA_WINDOW_ANIMATION_ORIENTATION,
695                                                                          pspec);
696
697         pspec = g_param_spec_int ("animation-delay",
698                                                           "Amount of time in milliseconds between animation intervals",
699                                                           NULL,
700                                                           0,
701                                                           INT_MAX,
702                                                           0,
703                                                           G_PARAM_READWRITE);
704
705         g_object_class_install_property (gobject_class,
706                                                                          TILDA_WINDOW_ANIMATION_DELAY,
707                                                                          pspec);
708
709         pspec = g_param_spec_boolean ("keep-above",
710                                                                   "Keep this window above all others",
711                                                                   NULL,
712                                                                   FALSE,
713                                                                   G_PARAM_READWRITE);
714
715         g_object_class_install_property (gobject_class,
716                                                                          TILDA_WINDOW_KEEP_ABOVE,
717                                                                          pspec);
718
719         pspec = g_param_spec_boolean ("show-in-taskbar",
720                                                                   "Show this window in the taskbar",
721                                                                   NULL,
722                                                                   FALSE,
723                                                                   G_PARAM_READWRITE);
724
725         g_object_class_install_property (gobject_class,
726                                                                          TILDA_WINDOW_SHOW_IN_TASKBAR,
727                                                                          pspec);
728
729         pspec = g_param_spec_boolean ("pinned",
730                                                                   "Display this window on all workspaces",
731                                                                   NULL,
732                                                                   FALSE,
733                                                                   G_PARAM_READWRITE);
734
735         g_object_class_install_property (gobject_class,
736                                                                          TILDA_WINDOW_PINNED,
737                                                                          pspec);
738
739         pspec = g_param_spec_boolean ("hidden-at-start",
740                                                                   "Hide the window when it is first created",
741                                                                   NULL,
742                                                                   FALSE,
743                                                                   G_PARAM_READWRITE);
744
745         g_object_class_install_property (gobject_class,
746                                                                          TILDA_WINDOW_HIDDEN_AT_START,
747                                                                          pspec);
748
749         pspec = g_param_spec_boolean ("centered-horizontally",
750                                                                   "Center the window horizontally",
751                                                                   NULL,
752                                                                   FALSE,
753                                                                   G_PARAM_READWRITE);
754
755         g_object_class_install_property (gobject_class,
756                                                                          TILDA_WINDOW_CENTERED_HORIZONTALLY,
757                                                                          pspec);
758
759         pspec = g_param_spec_boolean ("centered-vertically",
760                                                                   "Center the window vertically",
761                                                                   NULL,
762                                                                   FALSE,
763                                                                   G_PARAM_READWRITE);
764
765         g_object_class_install_property (gobject_class,
766                                                                          TILDA_WINDOW_CENTERED_VERTICALLY,
767                                                                          pspec);
768
769         pspec = g_param_spec_boolean ("have-real-transparency",
770                                                                   NULL, NULL, FALSE, G_PARAM_READABLE);
771
772         g_object_class_install_property (gobject_class,
773                                                                          TILDA_WINDOW_HAVE_REAL_TRANSPARENCY,
774                                                                          pspec);
775
776         /* TODO: more properties */
777
778         /* Hook the TildaWindow type into DBus */
779         dbus_g_object_type_install_info (tilda_window_get_type(), &dbus_glib_tilda_window_object_info);
780 }
781
782 GType
783 tilda_window_get_type (void)
784 {
785         static GType type = 0;
786
787         if (type == 0)
788         {
789                 static const GTypeInfo info = {
790                         sizeof (TildaWindowClass),
791                         NULL,   /* base_init */
792                         NULL,   /* base_finalize */
793                         tilda_window_class_init,        /* class_init */
794                         NULL,   /* class_finalize */
795                         NULL,   /* class_data */
796                         sizeof (TildaWindow),
797                         0,              /* n_preallocs */
798                         tilda_window_instance_init,     /* instance_init */
799                 };
800
801                 type = g_type_register_static (G_TYPE_OBJECT,
802                                                                            "TildaWindowType",
803                                                                            &info,
804                                                                            0);
805         }
806
807         return type;
808 }
809
810 #if 0
811
812 int main (int argc, char *argv[])
813 {
814         GObject *tw;
815         gint test_number = INT_MIN;
816
817         /* Initialize the GObject type system */
818         g_type_init ();
819         gtk_init (&argc, &argv);
820
821         tw = g_object_new (TILDA_TYPE_WINDOW, "number", 10, NULL);
822         g_object_get (G_OBJECT (tw), "number", &test_number, NULL);
823         g_assert (test_number == 10);
824
825         g_object_unref (G_OBJECT (tw));
826
827         tw = g_object_new (TILDA_TYPE_WINDOW, "number", 22, NULL);
828         g_object_get (G_OBJECT (tw), "number", &test_number, NULL);
829         g_assert (test_number == 22);
830
831         gtk_main ();
832
833         g_object_unref (G_OBJECT (tw));
834
835         return 0;
836 }
837
838 #endif
839
840 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */