31 window1 = GTK_WINDOW(menuitem);
32 job = g_object_get_data(G_OBJECT(window1),
"job");
43 ui_open_graph(GtkWindow *window1, gchar *filename)
48 job = g_object_get_data(G_OBJECT(window1),
"job");
49 dialog = gtk_file_chooser_dialog_new(
50 "Open graph", window1, GTK_FILE_CHOOSER_ACTION_OPEN,
51 "Cancel", GTK_RESPONSE_CANCEL,
52 "Open", GTK_RESPONSE_ACCEPT,
55 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
56 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
57 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
58 gtk_widget_destroy(dialog);
64 g_object_set_data_full(G_OBJECT(window1),
65 "activefilename", filename, (GDestroyNotify)g_free);
76 window1 = GTK_WINDOW(menuitem);
77 filename = g_object_get_data(G_OBJECT(window1),
"activefilename");
78 ui_open_graph(window1, filename);
82 ui_save_graph(GtkWindow *window1, gchar *filename)
87 job = (
GVJ_t *)g_object_get_data(G_OBJECT(window1),
"job");
89 dialog = gtk_file_chooser_dialog_new(
90 "Save graph as", window1, GTK_FILE_CHOOSER_ACTION_SAVE,
91 "Cancel", GTK_RESPONSE_CANCEL,
92 "Save", GTK_RESPONSE_ACCEPT,
94 filename = g_object_get_data(G_OBJECT(window1),
"activefilename");
96 gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog), filename);
97 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT)
98 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
99 gtk_widget_destroy(dialog);
102 g_object_set_data_full(G_OBJECT(window1),
103 "activefilename", filename, (GDestroyNotify)g_free);
114 window1 = GTK_WINDOW(menuitem);
115 filename = (gchar *)g_object_get_data(G_OBJECT(window1),
"activefilename");
116 ui_save_graph(window1, filename);
126 window1 = GTK_WINDOW(menuitem);
127 ui_save_graph(window1,
NULL);
135 gtk_widget_destroy(GTK_WIDGET(gtk_widget_get_toplevel(GTK_WIDGET(menuitem))));
177 static gchar *authors[] = {
181 "special thanks to Michael Lawrence",
183 GtkWindow *window = GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(menuitem)));
184 gtk_show_about_dialog(window,
186 "program-name",
"DotEdit",
188 "copyright",
"(C) 2011 AT&T Intellectual Procerty.",
189 "license",
"Eclipse Public License v1.0.",
190 "website",
"http://www.graphviz.org",
191 "comments",
"Visualize and edit graphs of nodes and edges",
197 load_store_with_attrs(GtkListStore *model,
GVJ_t *job)
206 gtk_list_store_clear(model);
209 for (i = 0; i < attrs_len; i+=3) {
210 gtk_list_store_append(model, &iter);
211 gtk_list_store_set(model, &iter, 0, attrs[i], 1, g_strdup(attrs[i+1]), -1);
220 GdkEventExpose *event,
226 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
227 cr = gdk_cairo_create(widget->window);
233 job->
width = widget->allocation.width;
234 job->
height = widget->allocation.height;
249 load_store_with_attrs(GTK_LIST_STORE(g_object_get_data(G_OBJECT(widget),
"attr_store")), job);
257 GdkEventMotion *event,
262 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
265 gtk_widget_queue_draw(widget);
278 GdkEventMotion *event,
289 GdkEventExpose *event,
296 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
297 cr = gdk_cairo_create(widget->window);
303 job->
width = widget->allocation.width;
304 job->
height = widget->allocation.height;
329 GdkEventConfigure *event,
341 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
343 zoom_to_fit =
MIN((
double) event->width / (
double) job->
width,
344 (
double) event->height / (
double) job->
height);
345 if (zoom_to_fit < 1.0)
346 job->
zoom *= zoom_to_fit;
349 zoom_to_fit =
MIN((
double) event->width / (
double) job->
width,
350 (
double) event->height / (
double) job->
height);
351 job->
zoom *= zoom_to_fit;
353 if (event->width > job->
width || event->height > job->
height)
355 job->
width =
event->width;
356 job->
height =
event->height;
365 GdkEventButton *event,
371 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
372 pointer.
x =
event->x;
373 pointer.
y =
event->y;
376 load_store_with_attrs(GTK_LIST_STORE(g_object_get_data(G_OBJECT(widget),
"attr_store")), job);
383 GdkEventButton *event,
389 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
390 pointer.
x =
event->x;
391 pointer.
y =
event->y;
406 job = (
GVJ_t *)g_object_get_data(G_OBJECT(widget),
"job");
407 pointer.
x = ((GdkEventScroll *)event)->x;
408 pointer.
y = ((GdkEventScroll *)event)->y;
409 switch (((GdkEventScroll *)event)->direction) {
413 case GDK_SCROLL_DOWN:
416 case GDK_SCROLL_LEFT:
417 case GDK_SCROLL_RIGHT:
420 gtk_widget_queue_draw(widget);
427 GdkEventButton *event,
432 fprintf(stderr,
"will delete selected object\n");
void on_paste1_activate(GtkMenuItem *menuitem, gpointer user_data)
void(* button_press)(GVJ_t *job, int button, pointf pointer)
gboolean on_button1_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
void(* refresh)(GVJ_t *job)
gboolean on_drawingarea1_button_release_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
void on_save1_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_save_as1_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_quit1_activate(GtkMenuItem *menuitem, gpointer user_data)
gboolean on_drawingarea1_scroll_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
void on_about1_activate(GtkMenuItem *menuitem, gpointer user_data)
void(* button_release)(GVJ_t *job, int button, pointf pointer)
void on_cut1_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_delete1_activate(GtkMenuItem *menuitem, gpointer user_data)
gboolean on_drawingarea1_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)
void on_new1_activate(GtkMenuItem *menuitem, gpointer user_data)
void on_copy1_activate(GtkMenuItem *menuitem, gpointer user_data)
gboolean on_drawingarea1_configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer user_data)
void on_open1_activate(GtkMenuItem *menuitem, gpointer user_data)
void(* render)(GVJ_t *job, const char *format, const char *filename)
gv_argvlist_t selected_obj_attributes
void(* read)(GVJ_t *job, const char *filename, const char *layout)
boolean has_been_rendered
gboolean on_drawingarea2_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean on_drawingarea1_button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
void(* motion)(GVJ_t *job, pointf pointer)
gboolean on_drawingarea1_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer user_data)
gboolean on_window1_delete_event(GtkWidget *widget, GdkEvent *event, gpointer user_data)
gvdevice_callbacks_t * callbacks
gboolean on_drawingarea2_motion_notify_event(GtkWidget *widget, GdkEventMotion *event, gpointer user_data)