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