self->have_real_transparency = FALSE;
}
+/* Center the given TildaWindow in the horizontal axis */
+static void
+tilda_window_center_horizontally (TildaWindow *self)
+{
+ const gint screen_center = gdk_screen_width() / 2;
+ const gint tilda_center = self->width / 2;
+ const gint center_coord = screen_center - tilda_center;
+
+ g_object_set (G_OBJECT(self), "x-position", center_coord, NULL);
+}
+
+/* Center the given TildaWindow in the vertical axis */
+static void
+tilda_window_center_vertically (TildaWindow *self)
+{
+ const gint screen_center = gdk_screen_height() / 2;
+ const gint tilda_center = self->height / 2;
+ const gint center_coord = screen_center - tilda_center;
+
+ g_object_set (G_OBJECT(self), "y-position", center_coord, NULL);
+}
+
static void
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;
case TILDA_WINDOW_CENTERED_HORIZONTALLY:
self->centered_horizontally = g_value_get_boolean (value);
+ if (self->centered_horizontally)
+ tilda_window_center_horizontally (self);
g_print ("window centered horizontally: %d\n", self->centered_horizontally);
break;
case TILDA_WINDOW_CENTERED_VERTICALLY:
self->centered_vertically = g_value_get_boolean (value);
+ if (self->centered_vertically)
+ tilda_window_center_vertically (self);
g_print ("window centered vertically: %d\n", self->centered_vertically);
break;
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;
}