-#include <string.h>
+#include <string.h> /* for strcmp() */
+#include <gdk/gdkx.h> /* for gdk_x11_window_set_user_time() */
#include "tilda.h"
#include "tilda-window.h"
}
static gint
-tilda_window_find_next_free_terminal_number (TildaWindow *tw)
+tilda_window_find_next_free_terminal_number (TildaWindow *self)
{
debug_enter ();
- debug_assert (TILDA_IS_WINDOW(tw));
+ debug_assert (TILDA_IS_WINDOW(self));
gint i, j;
gboolean found;
{
found = FALSE;
- for (j=0; j<tw->terms->len; ++j)
+ for (j=0; j<self->terms->len; ++j)
{
- TildaTerminal *tt = g_ptr_array_index (tw->terms, j);
+ TildaTerminal *tt = g_ptr_array_index (self->terms, j);
if (tt->number == i)
{
return 0;
}
-static gboolean
-tilda_window_add_term (TildaWindow *tw)
+/**
+ * Clean up and remove self completely from the program
+ *
+ * Should only be used by DBus...
+ */
+gboolean
+tilda_window_close (TildaWindow *self)
+{
+ debug_enter ();
+ debug_assert (TILDA_IS_WINDOW(self));
+
+ tilda_del_window (self->number);
+
+ return TRUE;
+}
+
+gboolean
+tilda_window_add_terminal (TildaWindow *self)
{
debug_enter ();
- debug_assert (TILDA_IS_WINDOW(tw));
+ debug_assert (TILDA_IS_WINDOW(self));
gint number;
TildaTerminal *tt;
- number = tilda_window_find_next_free_terminal_number (tw);
+ number = tilda_window_find_next_free_terminal_number (self);
tt = g_object_new (TILDA_TYPE_TERMINAL,
"number", number,
- "parent-window", tw,
+ "parent-window", self,
NULL);
- g_ptr_array_add (tw->terms, tt);
+ g_ptr_array_add (self->terms, tt);
GtkWidget *label = gtk_label_new ("Tilda");
- gint index = gtk_notebook_prepend_page (GTK_NOTEBOOK(tw->notebook), tt->hbox, label);
- gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK(tw->notebook), tt->hbox, TRUE, TRUE, GTK_PACK_END);
- gtk_notebook_set_current_page (GTK_NOTEBOOK(tw->notebook), index);
+ gint index = gtk_notebook_prepend_page (GTK_NOTEBOOK(self->notebook), tt->hbox, label);
+ gtk_notebook_set_tab_label_packing (GTK_NOTEBOOK(self->notebook), tt->hbox, TRUE, TRUE, GTK_PACK_END);
+ gtk_notebook_set_current_page (GTK_NOTEBOOK(self->notebook), index);
+
+ if (gtk_notebook_get_n_pages (GTK_NOTEBOOK(self->notebook)) > 1)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK(self->notebook), TRUE);
- if (gtk_notebook_get_n_pages (GTK_NOTEBOOK(tw->notebook)) > 1)
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK(tw->notebook), TRUE);
+ /* Focus the VTE Terminal */
+ gtk_widget_grab_focus (tt->vte_term);
return TRUE;
}
* Return: TRUE on success, FALSE otherwise.
*/
gboolean
-tilda_window_remove_term (TildaWindow *tw, gint terminal_number)
+tilda_window_remove_terminal (TildaWindow *self, gint terminal_number)
{
debug_enter ();
- debug_assert (TILDA_IS_WINDOW(tw));
+ debug_assert (TILDA_IS_WINDOW(self));
debug_assert (terminal_number >= 0);
gint i;
- for (i=0; i<tw->terms->len; ++i)
+ for (i=0; i<self->terms->len; ++i)
{
- TildaTerminal *tt = g_ptr_array_index (tw->terms, i);
+ TildaTerminal *tt = g_ptr_array_index (self->terms, i);
if (tt->number == terminal_number)
{
- gint notebook_index = gtk_notebook_page_num (GTK_NOTEBOOK(tw->notebook), tt->hbox);
+ gint notebook_index = gtk_notebook_page_num (GTK_NOTEBOOK(self->notebook), tt->hbox);
/* Make sure the index was valid */
if (notebook_index == -1)
}
/* Actually remove the terminal */
- gtk_notebook_remove_page (GTK_NOTEBOOK (tw->notebook), notebook_index);
+ gtk_notebook_remove_page (GTK_NOTEBOOK (self->notebook), notebook_index);
/* We should hide the tabs if there is only one tab left */
- if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (tw->notebook)) == 1)
- gtk_notebook_set_show_tabs (GTK_NOTEBOOK (tw->notebook), FALSE);
+ if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->notebook)) == 1)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK (self->notebook), FALSE);
/* Remove the term from our lists, then free it */
- g_ptr_array_remove_fast (tw->terms, tt);
+ g_ptr_array_remove_fast (self->terms, tt);
g_object_unref (G_OBJECT(tt));
/* With no pages left, it's time to remove this window */
- if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (tw->notebook)) < 1)
+ if (gtk_notebook_get_n_pages (GTK_NOTEBOOK (self->notebook)) < 1)
{
- debug_printf ("no terminals left, closing window %d\n", tw->number);
- tilda_del_window (tw->number);
+ debug_printf ("no terminals left, closing window %d\n", self->number);
+ tilda_del_window (self->number);
}
/* Leave the loop, we're done */
TildaWindow *self = TILDA_WINDOW(data);
TildaTerminal *tt;
- // FIXME: this doesn't handle animation!
+ /* This call sets the X11 window property _NET_WM_USER_TIME, which GTK+ normally
+ * sets for us. However, because this callback is activated via a global keybinding,
+ * we see the event before GDK / GTK+ does. Therefore, to get the focus, we must
+ * set the property ourselves. */
+ gdk_x11_window_set_user_time (GTK_WIDGET(self->window)->window,
+ tomboy_keybinder_get_current_event_time());
switch (self->state)
{
"keep-above", self->keep_above,
"stick", self->stick,
NULL);
- gtk_window_present_with_time (GTK_WINDOW(self->window),
- tomboy_keybinder_get_current_event_time());
+ gtk_widget_show (GTK_WIDGET(self->window));
/* Focusing the term here works perfectly, near as I can tell */
tt = tilda_window_find_current_terminal (self);
}
static void
-tilda_window_dbus_register_object (TildaWindow *tw)
+tilda_window_dbus_register_object (TildaWindow *self)
{
debug_enter ();
- debug_assert (TILDA_IS_WINDOW(tw));
+ debug_assert (TILDA_IS_WINDOW(self));
gchar *object_path;
// Register this object with DBus
- object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d", tw->number);
- dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tw));
+ object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d", self->number);
+ dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(self));
g_free (object_path);
}
tilda_window_setup_real_transparency (self);
gtk_container_add (GTK_CONTAINER(self->window), self->notebook);
+ g_object_set (G_OBJECT(self->notebook), "can-focus", FALSE, NULL);
gtk_widget_show (self->notebook);
// FIXME: Remove these, and replace with reads from the config system
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);
+ tilda_window_add_terminal (self);
+ tilda_window_add_terminal (self);
/* Show us if we're ready. If not, just remain hidden. All sub-widgets must
* be gtk_widget_show()n by this point. */