4 #include "tilda-window.h"
5 #include "tilda-terminal.h"
7 DBusGConnection *dbus_connection;
11 tilda_initialize_dbus ()
15 static const gchar service_name[] = "net.sourceforge.Tilda";
17 DBusGProxy *driver_proxy;
20 // Initialize the DBus connection
21 dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
22 if (dbus_connection == NULL)
24 g_warning ("Unable to connect to dbus: %s", error->message);
29 // Register the service name
30 driver_proxy = dbus_g_proxy_new_for_name (dbus_connection,
35 if (!org_freedesktop_DBus_request_name (driver_proxy, service_name, 0, &request_ret, &error))
37 // FIXME: for whatever reason, this is wrong. The error message doesn't appear
38 // FIXME: when we were unable to register the service. Perhaps there's a more
39 // FIXME: GLib-y way of doing this?
40 g_warning ("Unable to register service: %s", error->message);
44 g_object_unref (driver_proxy);
48 tilda_find_next_free_window_number ()
55 for (i=0; i<INT_MAX; ++i)
59 for (j=0; j<windows->len; ++j)
61 TildaWindow *tw = g_ptr_array_index (windows, j);
85 number = tilda_find_next_free_window_number ();
86 ret = g_object_new (TILDA_TYPE_WINDOW, "number", number, NULL);
88 g_ptr_array_add (windows, ret);
90 debug_printf ("Adding window: 0x%x (number %d of %d)\n", ret, ret->number, windows->len-1);
95 tilda_del_window (gint number)
102 for (i=0; i<windows->len; ++i)
104 win = g_ptr_array_index (windows, i);
106 if (win->number == number)
108 debug_printf ("Deleting window 0x%x (number %d of %d)\n", win, win->number, windows->len-1);
109 g_ptr_array_remove_index (windows, i);
110 g_object_unref (G_OBJECT(win));
116 int main (int argc, char *argv[])
122 /* Initialize GTK+ (and the GObject system) */
123 gtk_init (&argc, &argv);
125 /* Initialize the keybinder */
126 tomboy_keybinder_init ();
128 /* Start our connection to DBus */
129 tilda_initialize_dbus ();
131 /* Initialize the array of windows */
132 windows = g_ptr_array_new ();
134 /* Create a TildaWindow, run it, and exit when it does, basically.
136 * This is nothing like what the real main() will be, but it's
137 * a good start for testing and integration of more of TildaWindow
138 * and TildaTerminal. */
139 tw = tilda_add_window ();
141 debug_printf ("Starting gtk_main()!\n");
143 debug_printf ("Out of gtk_main(), going down\n");
148 /* vim: set ts=4 sts=4 sw=4 noet tw=112: */