self->have_real_transparency = FALSE;
}
+static void
+tilda_window_keybinding_cb (const gchar *keystr, gpointer data)
+{
+ TildaWindow *self = TILDA_WINDOW(data);
+ 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;
+ break;
+
+ case WINDOW_DOWN:
+ /* Pull Up */
+ gtk_widget_hide (GTK_WIDGET(self->window));
+ self->state = WINDOW_UP;
+ break;
+
+ default:
+ g_printerr ("FIXME: the window is in a bad state!\n");
+
+ /* Pretend we're down, for good measure.... */
+ self->state = WINDOW_DOWN;
+ break;
+ }
+}
+
+/**
+ * Attempt to bind the new_key to show this window.
+ *
+ * Return: TRUE if successful, FALSE otherwise.
+ */
+static gboolean
+tilda_window_try_to_bind_key (TildaWindow *self, const gchar *new_key)
+{
+ gboolean ret = FALSE;
+
+ /* Make sure the new key is not null in any way */
+ if (new_key == NULL || strcmp("", new_key) == 0)
+ return FALSE;
+
+ /* Unbind if we were set */
+ if (self->key)
+ tomboy_keybinder_unbind (self->key, tilda_window_keybinding_cb, self);
+
+ ret = tomboy_keybinder_bind (new_key, tilda_window_keybinding_cb, self);
+
+ /* If it was successful, update the self->key variable and be done with it */
+ if (ret)
+ {
+ g_free (self->key);
+ self->key = g_strdup (new_key);
+ return TRUE;
+ }
+
+ g_printerr ("Keybinding unsuccessful. Reverting to original key\n");
+
+ /* Not successful, so rebind the old key, and return FALSE */
+ if (self->key != NULL && strcmp("",self->key) != 0)
+ {
+ ret = tomboy_keybinder_bind (self->key, tilda_window_keybinding_cb, self);
+
+ /* Check that it went ok */
+ if (!ret)
+ g_printerr ("Unable to bind original key as well! Oh shit...\n");
+ }
+ else
+ g_printerr ("No original key to revert to!\n");
+
+ return FALSE;
+}
+
static void
tilda_window_dbus_register_object (TildaWindow *tw)
{
/* Somewhat of a "poison" value, incase we don't set this */
self->number = 0xdeadbeef;
+
+ self->state = WINDOW_UP;
}
static void
break;
case TILDA_WINDOW_KEY:
- self->key = g_value_dup_string (value);
+ tilda_window_try_to_bind_key (self, g_value_get_string (value));
g_print ("window key: %s\n", self->key);
break;
tilda_window_add_term (self);
tilda_window_add_term (self);
gtk_widget_show_all (self->window);
+ self->state = WINDOW_DOWN;
return obj;
}