Graphviz 13.0.0~dev.20241220.2304
Loading...
Searching...
No Matches
gui.c
Go to the documentation of this file.
1/*************************************************************************
2 * Copyright (c) 2011 AT&T Intellectual Property
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * https://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors: Details at https://graphviz.org
9 *************************************************************************/
10
11#include <assert.h>
12#include <stdio.h>
13#include <stdlib.h>
14#include "gui.h"
15#include <glade/glade.h>
16#include <gdk/gdkkeysyms.h>
17#include <gdk/gdk.h>
18#include "viewport.h"
19#include <util/alloc.h>
20#include <util/strview.h>
21
22GladeXML *xml; //global libglade vars
23
24void Color_Widget_bg(char *colorstring, GtkWidget * widget)
25{
26 GdkColor color;
27 gdk_color_parse(colorstring, &color);
28 gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &color);
29 gtk_widget_modify_base(widget, GTK_STATE_NORMAL, &color);
30}
31
33 //dlgOpenGraph , GtkDialog
34 gtk_entry_set_text((GtkEntry *)
35 glade_xml_get_widget(xml, "entryGraphFileName"),
37}
38
40{
41 GtkMessageDialog *Dlg = (GtkMessageDialog *)gtk_message_dialog_new(NULL,
42 GTK_DIALOG_MODAL,
43 GTK_MESSAGE_WARNING,
44 GTK_BUTTONS_OK, "%s", str);
45
46 gtk_dialog_run((GtkDialog *) Dlg);
47 gtk_object_destroy((GtkObject *) Dlg);
48}
49
50
51
52/*
53Generic Open File dialog, if a file is selected and return value is 1, else 0
54file name is copied to char* filename,which should be allocated before using the function
55*/
56int openfiledlg(char **filename) {
57 assert(filename != NULL);
58
59 GtkWidget *dialog;
60 int rv;
61
62 dialog = gtk_file_chooser_dialog_new("Open File",
63 NULL,
64 GTK_FILE_CHOOSER_ACTION_OPEN,
65 GTK_STOCK_CANCEL,
66 GTK_RESPONSE_CANCEL,
67 GTK_STOCK_OPEN,
68 GTK_RESPONSE_ACCEPT, NULL);
69
70 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
71 *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
72 rv = 1;
73 } else
74 rv = 0;
75
76 gtk_widget_destroy(dialog);
77 return rv;
78}
79
80int savefiledlg(char **filename) {
81 assert(filename != NULL);
82
83 GtkWidget *dialog;
84 int rv;
85
86 dialog = gtk_file_chooser_dialog_new("Save File",
87 NULL,
88 GTK_FILE_CHOOSER_ACTION_OPEN,
89 GTK_STOCK_CANCEL,
90 GTK_RESPONSE_CANCEL,
91 GTK_STOCK_OPEN,
92 GTK_RESPONSE_ACCEPT, NULL);
93
94 if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) {
95 *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
96 rv = 1;
97 } else
98 rv = 0;
99
100 gtk_widget_destroy(dialog);
101 return rv;
102}
103
104void append_textview(GtkTextView * textv, const char *s, size_t bytes)
105{
106
107 GtkTextIter endit;
108 GtkTextBuffer *gtkbuf;
109 /*get text view buffer */
110 gtkbuf = gtk_text_view_get_buffer(textv);
111 /*set iterator to the end of the buffer */
112 gtk_text_buffer_get_end_iter(gtkbuf, &endit);
113 /* insert buf to the end */
114 gtk_text_buffer_insert(gtkbuf, &endit, s, (int)bytes);
115
116}
Memory allocation wrappers that exit on failure.
node NULL
Definition grammar.y:163
int openfiledlg(char **filename)
Definition gui.c:56
int savefiledlg(char **filename)
Definition gui.c:80
void load_graph_properties(void)
Definition gui.c:32
void Color_Widget_bg(char *colorstring, GtkWidget *widget)
Definition gui.c:24
void show_gui_warning(char *str)
Definition gui.c:39
GladeXML * xml
Definition gui.c:22
void append_textview(GtkTextView *textv, const char *s, size_t bytes)
Definition gui.c:104
static void color(Agraph_t *g)
Definition gvcolor.c:129
textitem scanner parser str
Definition htmlparse.y:224
ViewInfo * view
Definition viewport.c:37
topview * Topview
Definition smyrnadefs.h:313
char * GraphFileName
Definition smyrnadefs.h:146
graph_data Graphdata
Definition smyrnadefs.h:233
Non-owning string references.
Definition grammar.c:93