[Window] Add more hardcoded settings for testing
[tilda-gobject.git] / tilda-window.c
index 95d5cea..929a934 100644 (file)
@@ -161,25 +161,40 @@ tilda_window_keybinding_cb (const gchar *keystr, gpointer data)
 {
        TildaWindow *self = TILDA_WINDOW(data);
        TildaTerminal *tt;
-       g_print ("tilda_window_keybinding_cb() called! -- window %d\n", self->number);
 
        // FIXME: this doesn't handle animation!
 
        switch (self->state)
        {
-               case WINDOW_UP:
-                       /* Pull Down */
-                       tomboy_window_present_hardcore (GTK_WINDOW(self->window));
-                       self->state = WINDOW_DOWN;
-
-                       // Focusing the term here works perfectly, near as I can tell
+               case WINDOW_UP: /* Pull the window up */
+
+                       /* Bugfix: having this here keeps the tilda window from being
+                        * hidden if you turn off "stick", pull it down on workspace 1,
+                        * switch to workspace 2, then pull it up and back down. Without
+                        * this, something in metacity (at least) hides the window. Stupid. */
+                       gtk_window_deiconify (GTK_WINDOW(self->window));
+
+                       /* Re-set the window properties that do not linger after hiding the
+                        * window. I know this looks stupid, but it keeps all of the state-
+                        * changing code in the place it belongs: the property-setting code. */
+                       g_object_set (G_OBJECT(self),
+                                       "keep-above", self->keep_above,
+                                       "stick", self->stick,
+                                       NULL);
+                       gtk_window_present_with_time (GTK_WINDOW(self->window),
+                                                                                 tomboy_keybinder_get_current_event_time());
+
+                       /* Focusing the term here works perfectly, near as I can tell */
                        tt = tilda_window_find_current_terminal (self);
                        gtk_widget_grab_focus (GTK_WIDGET(tt->vte_term));
+
+                       self->state = WINDOW_DOWN;
                        break;
 
-               case WINDOW_DOWN:
-                       /* Pull Up */
+               case WINDOW_DOWN: /* Pull the window up */
+
                        gtk_widget_hide (GTK_WIDGET(self->window));
+
                        self->state = WINDOW_UP;
                        break;
 
@@ -270,7 +285,7 @@ enum tilda_window_properties {
 
        TILDA_WINDOW_KEEP_ABOVE,
        TILDA_WINDOW_SKIP_TASKBAR_HINT,
-       TILDA_WINDOW_PINNED,
+       TILDA_WINDOW_STICK,
        TILDA_WINDOW_HIDDEN_AT_START,
        TILDA_WINDOW_CENTERED_HORIZONTALLY,
        TILDA_WINDOW_CENTERED_VERTICALLY,
@@ -344,6 +359,7 @@ tilda_window_set_property (GObject      *object,
 
                case TILDA_WINDOW_TAB_POSITION:
                        self->tab_position = g_value_get_int (value);
+                       gtk_notebook_set_tab_pos (GTK_NOTEBOOK(self->notebook), self->tab_position);
                        g_print ("window tab position: %d\n", self->tab_position);
                        break;
 
@@ -359,6 +375,7 @@ tilda_window_set_property (GObject      *object,
 
                case TILDA_WINDOW_KEEP_ABOVE:
                        self->keep_above = g_value_get_boolean (value);
+                       gtk_window_set_keep_above (GTK_WINDOW(self->window), self->keep_above);
                        g_print ("window keep above: %d\n", self->keep_above);
                        break;
 
@@ -368,9 +385,13 @@ tilda_window_set_property (GObject      *object,
                        g_print ("window skip taskbar hint: %d\n", self->skip_taskbar_hint);
                        break;
 
-               case TILDA_WINDOW_PINNED:
-                       self->pinned = g_value_get_boolean (value);
-                       g_print ("window pinned: %d\n", self->pinned);
+               case TILDA_WINDOW_STICK:
+                       self->stick = g_value_get_boolean (value);
+
+                       /* This is moderately ugly, but GTK+ does it this way... */
+                       self->stick ? gtk_window_stick (GTK_WINDOW(self->window))
+                                               : gtk_window_unstick (GTK_WINDOW(self->window));
+                       g_print ("window stick: %d\n", self->stick);
                        break;
 
                case TILDA_WINDOW_HIDDEN_AT_START:
@@ -454,8 +475,8 @@ tilda_window_get_property (GObject    *object,
                        g_value_set_boolean (value, self->skip_taskbar_hint);
                        break;
 
-               case TILDA_WINDOW_PINNED:
-                       g_value_set_boolean (value, self->pinned);
+               case TILDA_WINDOW_STICK:
+                       g_value_set_boolean (value, self->stick);
                        break;
 
                case TILDA_WINDOW_HIDDEN_AT_START:
@@ -515,13 +536,24 @@ tilda_window_constructor (GType                  type,
        g_object_set (G_OBJECT(self), "key", "F2", NULL);
        g_object_set (G_OBJECT(self), "x-position", 0, "y-position", 0, NULL);
        g_object_set (G_OBJECT(self), "height", 400, "width", 1680, NULL);
+       g_object_set (G_OBJECT(self), "keep-above", TRUE, "stick", TRUE, NULL);
+       g_object_set (G_OBJECT(self), "hidden-at-start", FALSE, NULL);
 
        gtk_window_set_decorated (GTK_WINDOW(self->window), FALSE);
 
+       // FIXME: It should be configurable how many terms we add at startup
        tilda_window_add_term (self);
        tilda_window_add_term (self);
-       gtk_widget_show_all (self->window);
-       self->state = WINDOW_DOWN;
+
+       /* Show us if we're ready. If not, just remain hidden. All sub-widgets must
+        * be gtk_widget_show()n by this point. */
+       if (!self->hidden_at_start)
+       {
+               gtk_widget_show (self->window);
+               self->state = WINDOW_DOWN;
+       }
+       else
+               self->state = WINDOW_UP;
 
        return obj;
 }
@@ -718,14 +750,14 @@ tilda_window_class_init (gpointer g_class,
                                                                         TILDA_WINDOW_SKIP_TASKBAR_HINT,
                                                                         pspec);
 
-       pspec = g_param_spec_boolean ("pinned",
+       pspec = g_param_spec_boolean ("stick",
                                                                  "Display this window on all workspaces",
                                                                  NULL,
                                                                  FALSE,
                                                                  G_PARAM_READWRITE);
 
        g_object_class_install_property (gobject_class,
-                                                                        TILDA_WINDOW_PINNED,
+                                                                        TILDA_WINDOW_STICK,
                                                                         pspec);
 
        pspec = g_param_spec_boolean ("hidden-at-start",