34 #include <graphviz/gvc.h>
35 #include <graphviz/gvplugin.h>
36 #include <graphviz/gvplugin_device.h>
37 #include <graphviz/types.h>
46 #include <X11/Xutil.h>
63 #define GLADE_HOOKUP_OBJECT(component,widget,name) \
64 g_object_set_data_full (G_OBJECT (component), name, \
65 gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
73 #define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
74 g_object_set_data (G_OBJECT (component), name, widget)
88 GtkWidget *parent, *found_widget;
92 if (GTK_IS_MENU (widget))
93 parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
95 parent = widget->parent;
98 parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
"GladeParentKey");
106 found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),widget_name);
109 g_warning (
"Widget not found: %s", widget_name);
123 GtkWidget *drawingarea;
125 window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
126 gtk_window_set_title (GTK_WINDOW (window),
"Tree Graph");
128 drawingarea = gtk_drawing_area_new ();
129 gtk_widget_show (drawingarea);
130 gtk_widget_set_size_request (drawingarea, 800, 800);
131 gtk_container_add (GTK_CONTAINER (window), drawingarea);
133 g_signal_connect ((gpointer) window,
"delete_event",G_CALLBACK (
WindowDeleteEvent),NULL);
141 gtk_widget_set_events (drawingarea, GDK_ENTER_NOTIFY_MASK |GDK_EXPOSURE_MASK | GDK_LEAVE_NOTIFY_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK | GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK);
159 GtkWidget*window=(GtkWidget*)data;
160 GtkWidget*drawingarea =
lookup_widget (window,
"drawingarea");
163 gdk_window_invalidate_rect(drawingarea->window,&drawingarea->allocation,FALSE);
179 const char *display_name = NULL;
183 gtk_init (NULL, NULL);
185 dpy = XOpenDisplay(display_name);
187 fprintf(stderr,
"Failed to open XLIB display: %s\n",
191 scr = DefaultScreen(dpy);
193 firstjob->device_dpi.x = DisplayWidth(dpy, scr) * 25.4 / DisplayWidthMM(dpy, scr);
194 firstjob->device_dpi.y = DisplayHeight(dpy, scr) * 25.4 / DisplayHeightMM(dpy, scr);
196 firstjob->device_sets_dpi = TRUE;
209 GtkWidget *window, *drawingarea;
211 for (job = firstjob; job; job = job->next_active)
215 g_object_set_data(G_OBJECT(window),
"job", (gpointer) job);
218 g_object_set_data(G_OBJECT(drawingarea),
"job", (gpointer) job);
220 g_timeout_add(50,
Redraw,window);
222 gtk_widget_show (window);
237 GVDEVICE_DOES_TRUECOLOR | GVDEVICE_EVENTS ,
246 {0, NULL, 0, NULL, NULL}
250 static gvplugin_api_t
apis[] = {
gvplugin_library_t gvplugin_xgtk_LTX_library
Libgvc plug-in library object, the name of this variable is very specific (its specification is in th...
gboolean Redraw(gpointer data)
Redraw main window.
#define GLADE_HOOKUP_OBJECT(component, widget, name)
Hookup object to widget with call to g_object_set_data_full.
static gvplugin_api_t apis[]
Libgvc api descriptor, type and gvplugin_installed_t structure.
gboolean WindowDeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
static void gtk_finalize(GVJ_t *firstjob)
End point for the plug-in engine.
GtkWidget * lookup_widget(GtkWidget *widget, const gchar *widget_name)
Obtain a widget from a lower point in the widget structure.
gboolean DrawingareaExposeEvent(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean DrawingareaScrollEvent(GtkWidget *widget, GdkEventScroll *event, gpointer user_data)
GtkWidget * create_window(void)
Create a GTK window.
gboolean DrawingareaButtonPressEvent(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
static gvdevice_engine_t device_engine_xgtk
Libgvc plug-in render engine description.
static void gtk_initialize(GVJ_t *firstjob)
Start point for the plug-in.
static gvdevice_features_t device_features_xgtk
Libgvc plug-in render feature descriptor.
gboolean DrawingareaConfigureEvent(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
gboolean DrawingareaMotionNotifyEvent(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
gvplugin_installed_t gvdevice_types_xgtk[]
Libgvc plug-in descriptor, name. engine and features, must be null terminated.
#define GLADE_HOOKUP_OBJECT_NO_REF(component, widget, name)
Hookup object to widget with call to g_object_set_data.
Callback header, only function prototypes.