enum tilda_terminal_properties {
TILDA_TERMINAL_NUMBER = 1,
TILDA_TERMINAL_WINDOW_NUMBER,
+ TILDA_TERMINAL_TW,
/* All non-constructor-only properties */
TILDA_TERMINAL_BACKGROUND_IMAGE,
g_print ("terminal parent window number: %d\n", self->window_number);
break;
+ case TILDA_TERMINAL_TW:
+ self->parent_window = g_value_get_pointer (value);
+ g_print ("terminal parent window: 0x%x\n", self->parent_window);
+ g_print ("terminal parent window number (direct): %d\n", TILDA_WINDOW(self->parent_window)->number);
+ break;
+
case TILDA_TERMINAL_BACKGROUND_IMAGE:
g_free (self->background_image);
self->background_image = g_value_dup_string (value);
g_value_set_int (value, self->window_number);
break;
+ case TILDA_TERMINAL_TW:
+ g_value_set_pointer (value, self->parent_window);
+ break;
+
case TILDA_TERMINAL_BACKGROUND_IMAGE:
g_value_set_string (value, self->background_image);
break;
TILDA_TERMINAL_WINDOW_NUMBER,
pspec);
+ pspec = g_param_spec_pointer ("parent-window",
+ "Pointer to terminal's parent TildaWindow",
+ "Set the pointer to the terminal's parent TildaWindow",
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ g_object_class_install_property (gobject_class,
+ TILDA_TERMINAL_TW,
+ pspec);
+
pspec = g_param_spec_string ("background-image",
"Terminal's background image",
"Get/Set terminal's background image",
#include "tilda-terminal.h"
DBusGConnection *dbus_connection;
+GPtrArray *windows;
static void
tilda_initialize_dbus ()
g_object_unref (driver_proxy);
}
+static gint
+tilda_find_next_free_window_number ()
+{
+ gint i, j;
+ gboolean found;
+
+ for (i=0; i<INT_MAX; ++i)
+ {
+ found = FALSE;
+
+ for (j=0; j<windows->len; ++j)
+ {
+ TildaWindow *tw = g_ptr_array_index (windows, j);
+
+ if (tw->number == i)
+ {
+ found = TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+ return i;
+ }
+
+ return 0;
+}
+
+static TildaWindow *
+tilda_add_window ()
+{
+ TildaWindow *ret;
+ gint number;
+
+ number = tilda_find_next_free_window_number ();
+ ret = g_object_new (TILDA_TYPE_WINDOW, "number", number, NULL);
+
+ g_ptr_array_add (windows, ret);
+
+ g_print ("Adding window: 0x%x (number %d of %d)\n", ret, ret->number, windows->len);
+ return ret;
+}
+
+static void
+tilda_del_window (gint number)
+{
+ gint i;
+ TildaWindow *win;
+
+ for (i=0; i<windows->len; ++i)
+ {
+ win = g_ptr_array_index (windows, i);
+
+ if (win->number == number)
+ {
+ g_print ("Deleting window 0x%x (number %d)\n", win, win->number);
+ g_ptr_array_remove_index (windows, i);
+ g_object_unref (G_OBJECT(win));
+ break;
+ }
+ }
+}
+
int main (int argc, char *argv[])
{
TildaWindow *tw;
/* Start our connection to DBus */
tilda_initialize_dbus ();
+ /* Initialize the array of windows */
+ windows = g_ptr_array_new ();
+
/* Create a TildaWindow, run it, and exit when it does, basically.
*
* This is nothing like what the real main() will be, but it's
* a good start for testing and integration of more of TildaWindow
* and TildaTerminal. */
- tw = g_object_new (TILDA_TYPE_WINDOW, "number", 0, NULL);
+ tw = tilda_add_window ();
+ tw = tilda_add_window ();
+ tw = tilda_add_window ();
- gtk_main ();
+ tilda_del_window (1);
+
+ tw = tilda_add_window ();
- g_object_unref (G_OBJECT (tw));
+ gtk_main ();
return 0;
}