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