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