self->number = 0;
self->vte_term = vte_terminal_new ();
+ self->scrollbar = gtk_vscrollbar_new (VTE_TERMINAL(self->vte_term)->adjustment);
+ self->hbox = gtk_hbox_new (FALSE, 0);
}
static void
GObjectConstructParam *construct_properties)
{
GObject *obj;
+ TildaTerminal *self;
/* Invoke parent constructor */
TildaTerminalClass *klass;
* ctor properties have been set.
*
* TODO: This is the place to do DBus-init */
+ self = TILDA_TERMINAL(obj);
+ /* Pack into the hbox */
+ gtk_box_pack_end (GTK_BOX(self->hbox), self->scrollbar, FALSE, FALSE, 0);
+ gtk_box_pack_end (GTK_BOX(self->hbox), self->vte_term, TRUE, TRUE, 0);
+ gtk_widget_show (self->scrollbar);
+
+
+ g_signal_connect (G_OBJECT(self->vte_term), "child-exited",
+ G_CALLBACK(gtk_main_quit), self);
+
+ vte_terminal_fork_command (VTE_TERMINAL(self->vte_term), NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE);
return obj;
}
return type;
}
+#if 0
+
int main (int argc, char *argv[])
{
GObject *tt;
return 0;
}
+#endif
+
/* vim: set ts=4 sts=4 sw=4 noet tw=112: */
#include "tilda-window.h"
+static gboolean
+tilda_window_add_term (TildaWindow *tw)
+{
+ // FIXME: this is totally bad, but it's a good hack for feasability
+ static gint mynumber = 0;
+ TildaTerminal *tt = g_object_new (TILDA_TYPE_TERMINAL, "number", mynumber++, NULL);
+ g_ptr_array_add (tw->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);
+
+ if (gtk_notebook_get_n_pages (GTK_NOTEBOOK(tw->notebook)) > 1)
+ gtk_notebook_set_show_tabs (GTK_NOTEBOOK(tw->notebook), TRUE);
+
+ return TRUE;
+}
+
+static gboolean
+tilda_window_remove_term (TildaWindow *tw, int number)
+{
+ int i;
+
+ for (i=0; i<tw->terms->len; ++i)
+ {
+ TildaTerminal *tt = g_ptr_array_index (tw->terms, i);
+
+ if (tt->number == number)
+ g_print ("Need to remove window %d terminal %d\n", tw->number, tt->number);
+ }
+
+ return TRUE;
+}
+
+/*******************************************************************************
+ * ALL GOBJECT STUFF BELOW PLEASE
+ ******************************************************************************/
+
static GObjectClass *parent_class = NULL;
enum tilda_window_properties {
/* Initialize all properties */
self->window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ self->notebook = gtk_notebook_new ();
self->terms = g_ptr_array_new ();
+ /* Somewhat of a "poison" value, incase we don't set this */
self->number = 0xdeadbeef;
}
GObjectConstructParam *construct_properties)
{
GObject *obj;
+ TildaWindow *self;
/* Invoke parent constructor */
TildaWindowClass *klass;
* ctor properties have been set.
*
* TODO: This is the place to do DBus-init */
+ self = TILDA_WINDOW(obj);
+
+ gtk_container_add (GTK_CONTAINER(self->window), self->notebook);
+ gtk_widget_show (self->notebook);
+
+ tilda_window_add_term (self);
+ gtk_widget_show_all (self->window);
return obj;
}
+static void
+my_unref (gpointer data, gpointer user_data)
+{
+ g_object_unref (G_OBJECT(data));
+}
+
static void
tilda_window_dispose (GObject *obj)
{
* object which might themselves hold a reference to self. Generally,
* the most simple solution is to unref all members on which you own a
* reference.
+ *
+ * NOTE: See the following for how to deal with GtkObject-derived things:
+ * http://library.gnome.org/devel/gtk/unstable/GtkObject.html
*/
+ g_ptr_array_foreach (self->terms, my_unref, NULL);
+ gtk_widget_destroy (self->window);
/* Chain up to the parent class */
G_OBJECT_CLASS (parent_class)->dispose (obj);
* You might not need to do much...
*/
// TODO: g_free() any primitives here
+ g_ptr_array_free (self->terms, TRUE);
/* Chain up to the parent class */
return type;
}
-
int main (int argc, char *argv[])
{
GObject *tw;
g_object_get (G_OBJECT (tw), "number", &test_number, NULL);
g_assert (test_number == 22);
+ gtk_main ();
+
g_object_unref (G_OBJECT (tw));
return 0;