GOBJ_CFLAGS=`pkg-config --cflags gobject-2.0`
GOBJ_LIBS=`pkg-config --libs gobject-2.0`
-ALL_CFLAGS=`pkg-config --cflags gtk+-2.0 vte`
-ALL_LIBS=`pkg-config --libs gtk+-2.0 vte`
+ALL_CFLAGS=`pkg-config --cflags gtk+-2.0 vte dbus-glib-1`
+ALL_LIBS=`pkg-config --libs gtk+-2.0 vte dbus-glib-1`
.PHONY: all memcheck clean
$(GCC) $(CFLAGS) -c -o $@ $< $(ALL_CFLAGS)
tilda-window.o: tilda-window.c tilda-window.h
+ dbus-binding-tool --mode=glib-server --prefix=tilda_window tilda-window.xml > tilda-window-dbus-glue.h
$(GCC) $(CFLAGS) -c -o $@ $< $(ALL_CFLAGS)
tilda-terminal.o: tilda-terminal.c tilda-terminal.h
+ dbus-binding-tool --mode=glib-server --prefix=tilda_terminal tilda-terminal.xml > tilda-terminal-dbus-glue.h
$(GCC) $(CFLAGS) -c -o $@ $< $(ALL_CFLAGS)
memcheck: tilda
rm -f tilda-window
rm -f tilda-terminal
rm -f tilda
-
+ rm -f tilda-window-dbus-glue.h
+ rm -f tilda-terminal-dbus-glue.h
+
+boost-font:
+ @echo "Only run this when tilda is running, it attempts to send a message"
+ @echo "to the running tilda process to boost the font size"
+ dbus-send --print-reply \
+ --dest=net.sourceforge.Tilda /net/sourceforge/Tilda/Window0/Terminal0 \
+ org.freedesktop.DBus.Properties.Set \
+ string:'' \
+ string:font \
+ variant:string:'Bitstream Vera Sans Mono 14'
+
+shrink-font:
+ @echo "Only run this when tilda is running, it attempts to send a message"
+ @echo "to the running tilda process to shrink the font size"
+ dbus-send --print-reply \
+ --dest=net.sourceforge.Tilda /net/sourceforge/Tilda/Window0/Terminal0 \
+ org.freedesktop.DBus.Properties.Set \
+ string:'' \
+ string:font \
+ variant:string:'Bitstream Vera Sans Mono 10'
+#include "tilda.h"
#include "tilda-terminal.h"
+#include "tilda-terminal-dbus-glue.h"
+
+static void
+tilda_terminal_dbus_register_object (TildaTerminal *tt)
+{
+ gchar *object_path;
+
+ // Register this object with DBus
+ object_path = g_strdup_printf ("/net/sourceforge/Tilda/Window%d/Terminal%d",
+ tt->window_number, tt->number);
+ dbus_g_connection_register_g_object (dbus_connection, object_path, G_OBJECT(tt));
+ g_free (object_path);
+}
static GObjectClass *parent_class = NULL;
enum tilda_terminal_properties {
TILDA_TERMINAL_NUMBER = 1,
+ TILDA_TERMINAL_WINDOW_NUMBER,
/* All non-constructor-only properties */
TILDA_TERMINAL_BACKGROUND_IMAGE,
g_print ("terminal number: %d\n", self->number);
break;
+ case TILDA_TERMINAL_WINDOW_NUMBER:
+ self->window_number = g_value_get_int (value);
+ g_print ("terminal parent window number: %d\n", self->window_number);
+ break;
+
case TILDA_TERMINAL_BACKGROUND_IMAGE:
g_free (self->background_image);
self->background_image = g_value_dup_string (value);
case TILDA_TERMINAL_FONT:
g_free (self->font);
self->font = g_value_dup_string (value);
+ vte_terminal_set_font_from_string (VTE_TERMINAL(self->vte_term), self->font);
g_print ("terminal font: %s\n", self->font);
break;
g_value_set_int (value, self->number);
break;
+ case TILDA_TERMINAL_WINDOW_NUMBER:
+ g_value_set_int (value, self->window_number);
+ break;
+
case TILDA_TERMINAL_BACKGROUND_IMAGE:
g_value_set_string (value, self->background_image);
break;
vte_terminal_fork_command (VTE_TERMINAL(self->vte_term), NULL, NULL, NULL, NULL, FALSE, FALSE, FALSE);
+ tilda_terminal_dbus_register_object (self);
+
return obj;
}
parent_class = g_type_class_peek_parent (klass);
+ /* Hook the TildaTerminal type into DBus */
+ dbus_g_object_type_install_info (tilda_terminal_get_type(), &dbus_glib_tilda_terminal_object_info);
+
/* Install all of the properties */
pspec = g_param_spec_int ("number",
"Terminal number",
TILDA_TERMINAL_NUMBER,
pspec);
+ pspec = g_param_spec_int ("window-number",
+ "Number of the window to which this terminal belongs",
+ "Set the number of the parent window",
+ 0,
+ INT_MAX,
+ 0x0000beef,
+ G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
+
+ g_object_class_install_property (gobject_class,
+ TILDA_TERMINAL_WINDOW_NUMBER,
+ pspec);
+
pspec = g_param_spec_string ("background-image",
"Terminal's background image",
"Get/Set terminal's background image",
#include <gtk/gtk.h>
#include <vte/vte.h>
+#include "tilda-window.h"
+
#define TILDA_TYPE_TERMINAL (tilda_terminal_get_type())
#define TILDA_TERMINAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TILDA_TYPE_TERMINAL, TildaTerminal))
gboolean dispose_has_run;
/* Instance Members */
- // FIXME: ADD THESE BACK
- // TildaWindow *tw;
+ gint window_number;
+ //TildaWindow *tw;
GtkWidget *vte_term;
GtkWidget *scrollbar;
GtkWidget *hbox;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/net/sourceforge/Tilda/Window/Terminal">
+
+ <interface name="net.sourceforge.Tilda.Window.Terminal">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="tilda_terminal" />
+
+ </interface>
+</node>
+
+<!-- vim: set ts=2 sts=2 sw=2 noet: -->
+#include "tilda.h"
#include "tilda-window.h"
+#include "tilda-window-dbus-glue.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);
+ TildaTerminal *tt = g_object_new (TILDA_TYPE_TERMINAL,
+ "number", mynumber++,
+ "window-number", tw->number,
+ NULL);
g_ptr_array_add (tw->terms, tt);
GtkWidget *label = gtk_label_new ("Tilda");
return TRUE;
}
+static void
+tilda_window_dbus_register_object (TildaWindow *tw)
+{
+ 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));
+ g_free (object_path);
+}
+
/*******************************************************************************
* ALL GOBJECT STUFF BELOW PLEASE
******************************************************************************/
* TODO: This is the place to do DBus-init */
self = TILDA_WINDOW(obj);
+ /* Register this object with DBus */
+ tilda_window_dbus_register_object (self);
+
gtk_container_add (GTK_CONTAINER(self->window), self->notebook);
gtk_widget_show (self->notebook);
pspec);
/* TODO: more properties */
+
+ /* Hook the TildaWindow type into DBus */
+ dbus_g_object_type_install_info (tilda_window_get_type(), &dbus_glib_tilda_window_object_info);
}
GType
--- /dev/null
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<node name="/net/sourceforge/Tilda/Window">
+
+ <interface name="net.sourceforge.Tilda.Window">
+ <annotation name="org.freedesktop.DBus.GLib.CSymbol" value="tilda_window" />
+
+ </interface>
+</node>
+
+<!-- vim: set ts=2 sts=2 sw=2 noet: -->
#include <glib.h>
+#include "tilda.h"
#include "tilda-window.h"
#include "tilda-terminal.h"
+DBusGConnection *dbus_connection;
+
+static void
+tilda_initialize_dbus ()
+{
+ const gchar service_name[] = "net.sourceforge.Tilda";
+ GError *error = NULL;
+ DBusGProxy *driver_proxy;
+ int request_ret;
+
+ // Initialize the DBus connection
+ dbus_connection = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+ if (dbus_connection == NULL)
+ {
+ g_warning ("Unable to connect to dbus: %s", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ // Register the service name
+ driver_proxy = dbus_g_proxy_new_for_name (dbus_connection,
+ DBUS_SERVICE_DBUS,
+ DBUS_PATH_DBUS,
+ DBUS_INTERFACE_DBUS);
+
+ if (!org_freedesktop_DBus_request_name (driver_proxy, service_name, 0, &request_ret, &error))
+ {
+ // FIXME: for whatever reason, this is wrong. The error message doesn't appear
+ // FIXME: when we were unable to register the service. Perhaps there's a more
+ // FIXME: GLib-y way of doing this?
+ g_warning ("Unable to register service: %s", error->message);
+ g_error_free (error);
+ }
+
+ g_object_unref (driver_proxy);
+}
+
int main (int argc, char *argv[])
{
TildaWindow *tw;
/* Initialize GTK+ (and the GObject system) */
gtk_init (&argc, &argv);
+ /* Start our connection to DBus */
+ tilda_initialize_dbus ();
+
/* Create a TildaWindow, run it, and exit when it does, basically.
*
* This is nothing like what the real main() will be, but it's
--- /dev/null
+#ifndef TILDA_H
+#define TILDA_H
+
+#include <dbus/dbus-glib-bindings.h>
+
+/* Project-global variables */
+extern DBusGConnection *dbus_connection;
+
+#endif /* TILDA_H */
+
+/* vim: set ts=4 sts=4 sw=4 noet tw=112: */
+