[dia] normalise whitespace
- From: Zander <zbrown src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dia] normalise whitespace
- Date: Mon, 15 Jul 2019 12:34:35 +0000 (UTC)
commit d1cc54c71b35e8793467aef761a43f16a13a177d
Author: Zander Brown <zbrown gnome org>
Date: Fri Jul 5 22:33:27 2019 +0100
normalise whitespace
app/app_procs.c | 864 +++++++++++++++++++++++++++++---------------------------
app/app_procs.h | 10 +-
app/menus.c | 241 ++++++++--------
app/menus.h | 37 +--
4 files changed, 589 insertions(+), 563 deletions(-)
---
diff --git a/app/app_procs.c b/app/app_procs.c
index d4c48408..54ab4742 100644
--- a/app/app_procs.c
+++ b/app/app_procs.c
@@ -64,21 +64,23 @@
#include "diaerror.h"
#include "widgets.h"
-static gboolean
-handle_initial_diagram(const char *input_file_name,
- const char *export_file_name,
- const char *export_file_format,
- const char *size,
- char *show_layers,
- const char *outdir);
-
-static void create_user_dirs(void);
-static PluginInitResult internal_plugin_init(PluginInfo *info);
-static gboolean handle_all_diagrams(GSList *files, char *export_file_name,
- char *export_file_format, char *size, char *show_layers,
- const gchar *input_directory, const gchar *output_directory);
-static void print_credits(void);
-static void print_filters_list (gboolean verbose);
+static gboolean handle_initial_diagram (const char *input_file_name,
+ const char *export_file_name,
+ const char *export_file_format,
+ const char *size,
+ char *show_layers,
+ const char *outdir);
+static void create_user_dirs (void);
+static PluginInitResult internal_plugin_init (PluginInfo *info);
+static gboolean handle_all_diagrams (GSList *files,
+ char *export_file_name,
+ char *export_file_format,
+ char *size,
+ char *show_layers,
+ const char *input_directory,
+ const char *output_directory);
+static void print_credits (void);
+static void print_filters_list (gboolean verbose);
static gboolean dia_is_interactive = FALSE;
@@ -115,7 +117,10 @@ build_output_file_name(const char *infname, const char *format, const char *outd
* 4. XX-YY, every number between XX-YY
*/
static void
-show_layers_parse_numbers(DiagramData *diagdata, gboolean *visible_layers, gint n_layers, const char *str)
+show_layers_parse_numbers (DiagramData *diagdata,
+ gboolean *visible_layers,
+ gint n_layers,
+ const char *str)
{
char *p;
unsigned long int low = 0;
@@ -129,133 +134,145 @@ show_layers_parse_numbers(DiagramData *diagdata, gboolean *visible_layers, gint
if (*str == '-') {
str++;
low = 0;
- high = strtoul(str, &p, 10)+1;
+ high = strtoul (str, &p, 10) + 1;
/* This must be a number (otherwise we would have called parse_name) */
- g_assert(p != str);
- }
- else {
+ g_assert (p != str);
+ } else {
/* Case 1, 3 or 4 */
- low = strtoul(str, &p, 10);
- high = low+1; /* Assume case 1 */
- g_assert(p != str);
- if (*p == '-')
- {
- /* Case 3 or 4 */
- str = p + 1;
- if (*str == '\0') /* Case 3 */
- high = n_layers;
- else
- {
- high = strtoul(str, &p, 10)+1;
- g_assert(p != str);
- }
+ low = strtoul (str, &p, 10);
+ high = low + 1; /* Assume case 1 */
+ g_assert (p != str);
+ if (*p == '-') {
+ /* Case 3 or 4 */
+ str = p + 1;
+ if (*str == '\0') {/* Case 3 */
+ high = n_layers;
+ } else {
+ high = strtoul (str, &p, 10) + 1;
+ g_assert (p != str);
}
+ }
}
- if ( high <= low ) {
+ if (high <= low) {
/* This is not an errror */
- g_print(_("Warning: invalid layer range %lu - %lu\n"), low, high-1 );
+ g_warning (_("invalid layer range %lu - %lu"), low, high - 1);
return;
}
if (high > n_layers)
high = n_layers;
/* Set the visible layers */
- for ( i = low; i < high; i++ )
- {
- Layer *lay = (Layer *)g_ptr_array_index(diagdata->layers, i);
+ for ( i = low; i < high; i++ ) {
+ Layer *lay = (Layer *) g_ptr_array_index (diagdata->layers, i);
- if (visible_layers[i] == TRUE)
- g_print(_("Warning: Layer %lu (%s) selected more than once.\n"), i, lay->name);
- visible_layers[i] = TRUE;
+ if (visible_layers[i] == TRUE) {
+ g_warning (_("Layer %lu (%s) selected more than once."), i, lay->name);
}
+ visible_layers[i] = TRUE;
+ }
}
static void
-show_layers_parse_word(DiagramData *diagdata, gboolean *visible_layers, gint n_layers, const char *str)
+show_layers_parse_word (DiagramData *diagdata,
+ gboolean *visible_layers,
+ gint n_layers,
+ const char *str)
{
GPtrArray *layers = diagdata->layers;
gboolean found = FALSE;
/* Apply --show-layers=LAYER,LAYER,... switch. 13.3.2004 sampo iki fi */
if (layers) {
- int len,k = 0;
+ int len, k = 0;
Layer *lay;
char *p;
for (k = 0; k < layers->len; k++) {
- lay = (Layer *)g_ptr_array_index(layers, k);
+ lay = (Layer *) g_ptr_array_index (layers, k);
if (lay->name) {
- len = strlen(lay->name);
- if ((p = strstr(str, lay->name)) != NULL) {
- if (((p == str) || (p[-1] == ',')) /* zap false positives */
- && ((p[len] == 0) || (p[len] == ','))){
- found = TRUE;
- if (visible_layers[k] == TRUE)
- g_print(_("Warning: Layer %d (%s) selected more than once.\n"), k, lay->name);
- visible_layers[k] = TRUE;
- }
- }
+ len = strlen (lay->name);
+ if ((p = strstr (str, lay->name)) != NULL) {
+ if (((p == str) || (p[-1] == ',')) /* zap false positives */
+ && ((p[len] == 0) || (p[len] == ','))){
+ found = TRUE;
+ if (visible_layers[k] == TRUE) {
+ g_warning (_("Layer %d (%s) selected more than once."), k, lay->name);
+ }
+ visible_layers[k] = TRUE;
+ }
+ }
}
}
}
- if (found == FALSE)
- g_print(_("Warning: There is no layer named %s.\n"), str);
+ if (found == FALSE) {
+ g_warning (_("There is no layer named %s."), str);
+ }
}
static void
-show_layers_parse_string(DiagramData *diagdata, gboolean *visible_layers, gint n_layers, const char *str)
+show_layers_parse_string (DiagramData *diagdata,
+ gboolean *visible_layers,
+ gint n_layers,
+ const char *str)
{
gchar **pp;
int i;
- pp = g_strsplit(str, ",", 100);
+ pp = g_strsplit (str, ",", 100);
for (i = 0; pp[i]; i++) {
gchar *p = pp[i];
/* Skip the empty string */
- if (strlen(p) == 0)
+ if (strlen(p) == 0) {
continue;
+ }
/* If the string is only numbers and '-' chars, it is parsed as a
* number range. Otherwise it is parsed as a layer name.
*/
- if (strlen(p) != strspn(p, "0123456789-") )
- show_layers_parse_word(diagdata, visible_layers, n_layers, p);
- else
- show_layers_parse_numbers(diagdata, visible_layers, n_layers, p);
+ if (strlen (p) != strspn (p, "0123456789-")) {
+ show_layers_parse_word (diagdata, visible_layers, n_layers, p);
+ } else {
+ show_layers_parse_numbers (diagdata, visible_layers, n_layers, p);
+ }
}
- g_strfreev(pp);
+ g_strfreev (pp);
}
static void
-handle_show_layers(DiagramData *diagdata, const char *show_layers)
+handle_show_layers (DiagramData *diagdata,
+ const char *show_layers)
{
gboolean *visible_layers;
Layer *layer;
int i;
- visible_layers = g_malloc(diagdata->layers->len * sizeof(gboolean));
+ visible_layers = g_new (gboolean, diagdata->layers->len);
/* Assume all layers are non-visible */
- for (i=0;i<diagdata->layers->len;i++)
+ for (i = 0; i < diagdata->layers->len; i++) {
visible_layers[i] = FALSE;
+ }
/* Split the layer-range by commas */
- show_layers_parse_string(diagdata, visible_layers, diagdata->layers->len,
- show_layers);
+ show_layers_parse_string (diagdata,
+ visible_layers,
+ diagdata->layers->len,
+ show_layers);
/* Set the visibility of the layers */
- for (i=0;i<diagdata->layers->len;i++) {
- layer = g_ptr_array_index(diagdata->layers, i);
+ for (i = 0; i < diagdata->layers->len; i++) {
+ layer = g_ptr_array_index (diagdata->layers, i);
- if (visible_layers[i] == TRUE)
+ if (visible_layers[i] == TRUE) {
layer->visible = TRUE;
- else
+ } else {
layer->visible = FALSE;
+ }
}
g_free(visible_layers);
}
@@ -268,51 +285,54 @@ const char *argv0 = NULL;
* size might be NULL.
*/
static gboolean
-do_convert(const char *infname,
- const char *outfname, DiaExportFilter *ef,
- const char *size,
- char *show_layers)
+do_convert (const char *infname,
+ const char *outfname,
+ DiaExportFilter *ef,
+ const char *size,
+ char *show_layers)
{
DiaImportFilter *inf;
- DiagramData *diagdata = NULL;
- DiaContext *ctx;
+ DiagramData *diagdata = NULL;
+ DiaContext *ctx;
- inf = filter_guess_import_filter(infname);
- if (!inf)
+ inf = filter_guess_import_filter (infname);
+ if (!inf) {
inf = &dia_import_filter;
+ }
if (ef == NULL) {
- ef = filter_guess_export_filter(outfname);
+ ef = filter_guess_export_filter (outfname);
if (!ef) {
- g_critical(_("%s error: don't know how to export into %s\n"),
- argv0,outfname);
- exit(1);
+ g_critical (_("%s error: don't know how to export into %s\n"),
+ argv0, outfname);
+ exit (1);
}
}
dia_is_interactive = FALSE;
- if (0==strcmp(infname,outfname)) {
- g_critical(_("%s error: input and output filenames are identical: %s"),
- argv0, infname);
- exit(1);
+ if (0 == strcmp (infname,outfname)) {
+ g_critical (_("%s error: input and output filenames are identical: %s"),
+ argv0, infname);
+ exit (1);
}
diagdata = g_object_new (DIA_TYPE_DIAGRAM_DATA, NULL);
- ctx = dia_context_new(_("Import"));
+ ctx = dia_context_new (_("Import"));
- if (!inf->import_func(infname, diagdata, ctx, inf->user_data)) {
- g_critical(_("%s error: need valid input file %s\n"),
- argv0, infname);
- exit(1);
+ if (!inf->import_func (infname, diagdata, ctx, inf->user_data)) {
+ g_critical (_("%s error: need valid input file %s\n"),
+ argv0, infname);
+ exit (1);
}
/* Apply --show-layers */
- if (show_layers)
+ if (show_layers) {
handle_show_layers(diagdata, show_layers);
+ }
/* recalculate before export */
- data_update_extents(diagdata);
+ data_update_extents (diagdata);
/* Do our best in providing the size to the filter, but don't abuse user_data
* too much for it. It _must not_ be changed after initialization and there
@@ -320,30 +340,30 @@ do_convert(const char *infname,
*/
if (size) {
g_warning ("--size parameter unsupported for %s filter",
- ef->unique_name ? ef->unique_name : "selected");
- ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
+ ef->unique_name ? ef->unique_name : "selected");
+ ef->export_func (diagdata, ctx, outfname, infname, ef->user_data);
+ } else {
+ ef->export_func (diagdata, ctx, outfname, infname, ef->user_data);
}
- else
- ef->export_func(diagdata, ctx, outfname, infname, ef->user_data);
- /* if (!quiet) */ fprintf(stdout,
- _("%s --> %s\n"),
- infname,outfname);
- g_object_unref(diagdata);
- dia_context_release(ctx);
+ /* if (!quiet) */
+ fprintf (stdout, _("%s --> %s\n"), infname, outfname);
+ g_object_unref (diagdata);
+ dia_context_release (ctx);
return TRUE;
}
-void debug_break(void); /* shut gcc up */
+void debug_break (void); /* shut gcc up */
int debug_break_dont_optimize = 1;
void
-debug_break(void)
+debug_break (void)
{
- if (debug_break_dont_optimize > 0)
+ if (debug_break_dont_optimize > 0) {
debug_break_dont_optimize -= 1;
+ }
}
static void
-dump_dependencies(void)
+dump_dependencies (void)
{
#ifdef __GNUC__
g_print ("Compiler: GCC " __VERSION__ "\n");
@@ -352,14 +372,6 @@ dump_dependencies(void)
#else
g_print ("Compiler: unknown\n");
#endif
- /* some flags/defines which may be interesting */
- g_print (" with : "
-#ifdef G_THREADS_ENABLED
- "threads "
-#endif
- "cairo "
- "pangocairo "
- "\n");
/* print out all those dependies, both compile and runtime if possible
* Note: this is not meant to be complete but does only include libaries
@@ -380,42 +392,28 @@ dump_dependencies(void)
libxml_rt_version = xmlGetGlobalState()->xmlParserVersion;
#endif
libxml_rt_version = xmlParserVersion;
- if (atoi(libxml_rt_version))
+ if (atoi (libxml_rt_version)) {
g_print ("libxml : %d.%d.%d (%s)\n",
- atoi(libxml_rt_version) / 10000, atoi(libxml_rt_version) / 100 % 100, atoi(libxml_rt_version)
% 100,
- LIBXML_DOTTED_VERSION);
- else /* may include "extra" */
+ atoi (libxml_rt_version) / 10000,
+ atoi (libxml_rt_version) / 100 % 100,
+ atoi (libxml_rt_version) % 100,
+ LIBXML_DOTTED_VERSION);
+ } else { /* may include "extra" */
g_print ("libxml : %s (%s)\n", libxml_rt_version ? libxml_rt_version : "??", LIBXML_DOTTED_VERSION);
+ }
}
g_print ("glib : %d.%d.%d (%d.%d.%d)\n",
glib_major_version, glib_minor_version, glib_micro_version,
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
-#ifdef PANGO_VERSION_ENCODE
g_print ("pango : %s (%d.%d.%d)\n", pango_version_string(), PANGO_VERSION_MAJOR, PANGO_VERSION_MINOR,
PANGO_VERSION_MICRO);
-#else
- g_print ("pango : version not available (>= 1.14.x)\n"); /* Pango did not provide such */
-#endif
g_print ("cairo : %s (%s)\n", cairo_version_string(), CAIRO_VERSION_STRING);
-#if 0
- {
- gchar linkedname[1024];
- gint len = 0;
-
- /* relying on PREFIX is wrong */
- if ((len = readlink (PREFIX "/lib/libpango-1.0.so", linkedname, 1023)) > 0) {
- /* man 2 readlink : does not append a NUL character */
- linkedname[len] = '\0';
- g_print ("%s/%s\n", PREFIX, linkedname);
- }
- }
-#endif
g_print ("gtk+ : %d.%d.%d (%d.%d.%d)\n",
gtk_major_version, gtk_minor_version, gtk_micro_version,
GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
}
gboolean
-app_is_interactive(void)
+app_is_interactive (void)
{
return dia_is_interactive;
}
@@ -427,12 +425,12 @@ app_is_interactive(void)
* even more arguments, but create a more general system.
*/
static gboolean
-handle_initial_diagram(const char *in_file_name,
- const char *out_file_name,
- const char *export_file_format,
- const char *size,
- char* show_layers,
- const char *outdir) {
+handle_initial_diagram (const char *in_file_name,
+ const char *out_file_name,
+ const char *export_file_format,
+ const char *size,
+ char *show_layers,
+ const char *outdir) {
Diagram *diagram = NULL;
gboolean made_conversions = FALSE;
@@ -441,41 +439,51 @@ handle_initial_diagram(const char *in_file_name,
DiaExportFilter *ef = NULL;
/* First try guessing based on extension */
- export_file_name = build_output_file_name(in_file_name, export_file_format, outdir);
+ export_file_name = build_output_file_name (in_file_name,
+ export_file_format,
+ outdir);
- ef = filter_guess_export_filter(export_file_name);
+ ef = filter_guess_export_filter (export_file_name);
if (ef == NULL) {
- ef = filter_export_get_by_name(export_file_format);
+ ef = filter_export_get_by_name (export_file_format);
if (ef == NULL) {
- g_critical(_("Can't find output format/filter %s\n"), export_file_format);
- return FALSE;
+ g_critical (_("Can't find output format/filter %s"),
+ export_file_format);
+ return FALSE;
}
g_free (export_file_name);
- export_file_name = build_output_file_name(in_file_name, ef->extensions[0], outdir);
+ export_file_name = build_output_file_name (in_file_name,
+ ef->extensions[0],
+ outdir);
}
- made_conversions |= do_convert(in_file_name,
- (out_file_name != NULL?out_file_name:export_file_name),
- ef, size, show_layers);
- g_free(export_file_name);
+ made_conversions |= do_convert (in_file_name,
+ (out_file_name != NULL ? out_file_name : export_file_name),
+ ef,
+ size,
+ show_layers);
+ g_free (export_file_name);
} else if (out_file_name) {
DiaExportFilter *ef = NULL;
- made_conversions |= do_convert(in_file_name, out_file_name, ef,
- size, show_layers);
+ made_conversions |= do_convert (in_file_name,
+ out_file_name,
+ ef,
+ size,
+ show_layers);
} else {
- if (g_file_test(in_file_name, G_FILE_TEST_EXISTS)) {
+ if (g_file_test (in_file_name, G_FILE_TEST_EXISTS)) {
diagram = diagram_load (in_file_name, NULL);
} else {
diagram = new_diagram (in_file_name);
}
if (diagram != NULL) {
- diagram_update_extents(diagram);
- if (app_is_interactive()) {
- layer_dialog_set_diagram(diagram);
+ diagram_update_extents (diagram);
+ if (app_is_interactive ()) {
+ layer_dialog_set_diagram (diagram);
/* the display initial diagram holds two references */
- new_display(diagram);
+ new_display (diagram);
} else {
- g_object_unref(diagram);
+ g_object_unref (diagram);
}
}
}
@@ -494,9 +502,9 @@ static const gchar *output_directory = NULL;
static gboolean
_check_option_input_directory (const gchar *option_name,
- const gchar *value,
- gpointer data,
- GError **error)
+ const gchar *value,
+ gpointer data,
+ GError **error)
{
gchar *directory = g_filename_from_utf8 (value, -1, NULL, NULL, NULL);
@@ -511,9 +519,9 @@ _check_option_input_directory (const gchar *option_name,
}
static gboolean
_check_option_output_directory (const gchar *option_name,
- const gchar *value,
- gpointer data,
- GError **error)
+ const gchar *value,
+ gpointer data,
+ GError **error)
{
gchar *directory = g_filename_from_utf8 (value, -1, NULL, NULL, NULL);
@@ -539,13 +547,13 @@ _setup_textdomains (void)
g_free (localedir);
}
#else
- bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
#endif
#if defined ENABLE_NLS && defined HAVE_BIND_TEXTDOMAIN_CODESET
bind_textdomain_codeset(GETTEXT_PACKAGE,"UTF-8");
#endif
- textdomain(GETTEXT_PACKAGE);
+ textdomain (GETTEXT_PACKAGE);
}
void
@@ -620,7 +628,7 @@ app_init (int argc, char **argv)
setlocale(LC_NUMERIC, "C");
_setup_textdomains ();
- context = g_option_context_new(_("[FILE...]"));
+ context = g_option_context_new (_("[FILE...]"));
g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
/* avoid to add it a second time */
g_option_context_add_group (context, gtk_get_option_group (FALSE));
@@ -629,10 +637,10 @@ app_init (int argc, char **argv)
if (!g_option_context_parse (context, &argc, &argv, &error)) {
if (error) { /* IMO !error here is a bug upstream, triggered e.g. with --gdk-debug=updates */
- g_print ("%s", error->message);
- g_error_free (error);
+ g_print ("%s", error->message);
+ g_error_free (error);
} else {
- g_print (_("Invalid option?"));
+ g_print (_("Invalid option?"));
}
g_option_context_free(context);
@@ -641,52 +649,55 @@ app_init (int argc, char **argv)
/* second level check of command line options, existance of input files etc. */
if (filenames) {
while (filenames[i] != NULL) {
- gchar *filename;
- gchar *testpath;
-
- if (g_str_has_prefix (filenames[i], "file://")) {
- filename = g_filename_from_uri (filenames[i], NULL, NULL);
- if (!g_utf8_validate(filename, -1, NULL)) {
- gchar *tfn = filename;
- filename = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
- g_free(tfn);
- }
- } else
- filename = g_filename_to_utf8 (filenames[i], -1, NULL, NULL, NULL);
-
- if (!filename) {
- g_print (_("Filename conversion failed: %s\n"), filenames[i]);
- continue;
- }
-
- if (g_path_is_absolute(filename))
- testpath = filename;
- else
- testpath = g_build_filename(input_directory ? input_directory : ".", filename, NULL);
-
- /* we still have a problem here, if GLib's file name encoding would not be utf-8 */
- if (g_file_test (testpath, G_FILE_TEST_IS_REGULAR))
- files = g_slist_append(files, filename);
- else {
- g_print (_("Missing input: %s\n"), filename);
- g_free (filename);
- }
- if (filename != testpath)
- g_free (testpath);
- ++i;
+ gchar *filename;
+ gchar *testpath;
+
+ if (g_str_has_prefix (filenames[i], "file://")) {
+ filename = g_filename_from_uri (filenames[i], NULL, NULL);
+ if (!g_utf8_validate (filename, -1, NULL)) {
+ gchar *tfn = filename;
+ filename = g_filename_to_utf8 (filename, -1, NULL, NULL, NULL);
+ g_free (tfn);
+ }
+ } else {
+ filename = g_filename_to_utf8 (filenames[i], -1, NULL, NULL, NULL);
+ }
+
+ if (!filename) {
+ g_print (_("Filename conversion failed: %s\n"), filenames[i]);
+ continue;
+ }
+
+ if (g_path_is_absolute (filename)) {
+ testpath = filename;
+ } else {
+ testpath = g_build_filename (input_directory ? input_directory : ".", filename, NULL);
+ }
+
+ /* we still have a problem here, if GLib's file name encoding would not be utf-8 */
+ if (g_file_test (testpath, G_FILE_TEST_IS_REGULAR)) {
+ files = g_slist_append (files, filename);
+ } else {
+ g_print (_("Missing input: %s\n"), filename);
+ g_free (filename);
+ }
+ if (filename != testpath) {
+ g_free (testpath);
+ }
+ ++i;
}
}
/* given some files to output (or something;)), we are not starting up the UI */
- if (export_file_name || export_file_format || size || credits || version || list_filters)
+ if (export_file_name || export_file_format || size || credits || version || list_filters) {
dia_is_interactive = FALSE;
-
+ }
}
if (argv && dia_is_interactive) {
GdkPixbuf *pixbuf;
g_set_application_name (_("Dia Diagram Editor"));
- gtk_init(&argc, &argv);
+ gtk_init (&argc, &argv);
/* GTK: (Defunct with GtkApplication)
* gtk_icon_theme_add_resource_path (gtk_icon_theme_get_default (),
@@ -700,15 +711,15 @@ app_init (int argc, char **argv)
gtk_window_set_default_icon (pixbuf);
g_object_unref (pixbuf);
}
- }
- else {
+ } else {
/*
* On Windows there is no command line without display so that gtk_init is harmless.
* On X11 we need gtk_init_check() to avoid exit() just because there is no display
* running outside of X11.
*/
- if (!gtk_init_check(&argc, &argv))
+ if (!gtk_init_check(&argc, &argv)) {
dia_log_message ("Running without display");
+ }
}
if (version) {
@@ -716,51 +727,54 @@ app_init (int argc, char **argv)
gchar *ver_locale;
#if (defined __TIME__) && (defined __DATE__)
/* TRANSLATOR: 2nd and 3rd %s are time and date respectively. */
- ver_utf8 = g_strdup_printf(_("Dia version %s, compiled %s %s\n"), VERSION, __TIME__, __DATE__);
+ ver_utf8 = g_strdup_printf (_("Dia version %s, compiled %s %s\n"), VERSION, __TIME__, __DATE__);
#else
- ver_utf8 = g_strdup_printf(_("Dia version %s\n"), VERSION);
+ ver_utf8 = g_strdup_printf (_("Dia version %s\n"), VERSION);
#endif
- ver_locale = g_locale_from_utf8(ver_utf8, -1, NULL, NULL, NULL);
- printf("%s\n", ver_locale);
- g_free(ver_locale);
- g_free(ver_utf8);
- if (verbose)
- dump_dependencies();
- exit(0);
+ ver_locale = g_locale_from_utf8 (ver_utf8, -1, NULL, NULL, NULL);
+ printf ("%s\n", ver_locale);
+ g_free (ver_locale);
+ g_free (ver_utf8);
+ if (verbose) {
+ dump_dependencies ();
+ }
+ exit (0);
}
- if (!dia_is_interactive)
+ if (!dia_is_interactive) {
log_to_stderr = TRUE;
+ }
- libdia_init ( (dia_is_interactive ? DIA_INTERACTIVE : 0)
- | (log_to_stderr ? DIA_MESSAGE_STDERR : 0)
- | (verbose ? DIA_VERBOSE : 0) );
+ libdia_init ( (dia_is_interactive ? DIA_INTERACTIVE : 0)
+ |(log_to_stderr ? DIA_MESSAGE_STDERR : 0)
+ |(verbose ? DIA_VERBOSE : 0));
if (credits) {
- print_credits();
- exit(0);
+ print_credits ();
+ exit (0);
}
if (dia_is_interactive) {
- create_user_dirs();
+ create_user_dirs ();
- if (!nosplash)
- app_splash_init("");
+ if (!nosplash) {
+ app_splash_init ("");
+ }
/* Init cursors: */
- default_cursor = gdk_cursor_new(GDK_LEFT_PTR);
- ddisplay_set_all_cursor(default_cursor);
+ default_cursor = gdk_cursor_new (GDK_LEFT_PTR);
+ ddisplay_set_all_cursor (default_cursor);
}
- dia_register_plugins();
- dia_register_builtin_plugin(internal_plugin_init);
+ dia_register_plugins ();
+ dia_register_builtin_plugin (internal_plugin_init);
if (list_filters) {
print_filters_list (verbose);
exit (0);
}
- load_all_sheets(); /* new mechanism */
+ load_all_sheets (); /* new mechanism */
dia_log_message ("object defaults");
{
@@ -768,92 +782,99 @@ app_init (int argc, char **argv)
dia_object_defaults_load (NULL, TRUE /* prefs.object_defaults_create_lazy */, ctx);
dia_context_release (ctx);
}
- debug_break();
-
- if (object_get_type("Standard - Box") == NULL) {
- message_error(_("Couldn't find standard objects when looking for "
- "object-libs; exiting...\n"));
- g_critical( _("Couldn't find standard objects when looking for "
- "object-libs in '%s'; exiting...\n"), dia_get_lib_directory());
- exit(1);
+ debug_break ();
+
+ if (object_get_type ("Standard - Box") == NULL) {
+ message_error (_("Couldn't find standard objects when looking for "
+ "object-libs; exiting..."));
+ g_critical (_("Couldn't find standard objects when looking for "
+ "object-libs in '%s'; exiting..."),
+ dia_get_lib_directory());
+ exit (1);
}
- persistence_load();
+ persistence_load ();
/** Must load prefs after persistence */
- prefs_init();
+ prefs_init ();
if (dia_is_interactive) {
/* further initialization *before* reading files */
- active_tool = create_modify_tool();
+ active_tool = create_modify_tool ();
dia_log_message ("ui creation");
if (use_integrated_ui) {
- create_integrated_ui();
+ create_integrated_ui ();
} else {
- create_toolbox();
+ create_toolbox ();
/* for the integrated ui case it is integrated */
- persistence_register_window_create("layer_window",
- (NullaryFunc*)&layer_dialog_create);
+ persistence_register_window_create ("layer_window",
+ (NullaryFunc*) &layer_dialog_create);
}
/*fill recent file menu */
- recent_file_history_init();
+ recent_file_history_init ();
/* Set up autosave to check every 5 minutes */
- g_timeout_add_seconds(5*60, autosave_check_autosave, NULL);
+ g_timeout_add_seconds (5 * 60, autosave_check_autosave, NULL);
#if 0 /* do we really open these automatically in the next session? */
persistence_register_window_create("diagram_tree",
&diagram_tree_show);
#endif
- persistence_register_window_create("sheets_main_dialog",
- (NullaryFunc*)&sheets_dialog_create);
+ persistence_register_window_create ("sheets_main_dialog",
+ (NullaryFunc*) &sheets_dialog_create);
/* In current setup, we can't find the autosaved files. */
/*autosave_restore_documents();*/
}
dia_log_message ("diagrams");
- made_conversions = handle_all_diagrams(files, export_file_name,
- export_file_format, size, show_layers,
- input_directory, output_directory);
+ made_conversions = handle_all_diagrams (files,
+ export_file_name,
+ export_file_format,
+ size,
+ show_layers,
+ input_directory,
+ output_directory);
if (dia_is_interactive && files == NULL && !nonew) {
if (use_integrated_ui) {
GList * list;
- file_new_callback(NULL);
- list = dia_open_diagrams();
+ file_new_callback (NULL);
+ list = dia_open_diagrams ();
if (list) {
Diagram * diagram = list->data;
- diagram_update_extents(diagram);
+ diagram_update_extents (diagram);
diagram->is_default = TRUE;
}
} else {
- gchar *filename = g_filename_from_utf8(_("Diagram1.dia"), -1, NULL, NULL, NULL);
+ gchar *filename = g_filename_from_utf8 (_("Diagram1.dia"), -1, NULL, NULL, NULL);
Diagram *diagram = new_diagram (filename);
- g_free(filename);
+ g_free (filename);
if (diagram != NULL) {
- diagram_update_extents(diagram);
+ diagram_update_extents (diagram);
diagram->is_default = TRUE;
/* I think this is done in diagram_init() with a call to
* layer_dialog_update_diagram_list() */
- layer_dialog_set_diagram(diagram);
- new_display(diagram);
+ layer_dialog_set_diagram (diagram);
+ new_display (diagram);
}
}
}
- g_slist_free(files);
- if (made_conversions) exit(0);
+ g_slist_free (files);
+ if (made_conversions) {
+ exit (0);
+ }
- dynobj_refresh_init();
+ dynobj_refresh_init ();
dia_log_message ("initialized");
}
gboolean
-app_exit(void)
+app_exit (void)
{
GList *list;
GSList *slist;
@@ -866,14 +887,14 @@ app_exit(void)
static gboolean app_exit_once = FALSE;
if (app_exit_once) {
- g_error(_("This shouldn't happen. Please file a bug report at https://gitlab.gnome.org/GNOME/dia\n"
- "describing how you caused this message to appear.\n"));
+ g_error (_("This shouldn't happen. Please file a bug report at "
+ "https://gitlab.gnome.org/GNOME/dia "
+ "describing how you caused this message to appear."));
return FALSE;
}
if (diagram_modified_exists()) {
- if (is_integrated_ui ())
- {
+ if (is_integrated_ui ()) {
GtkWidget *dialog;
int result;
exit_dialog_item_array_t *items = NULL;
@@ -881,15 +902,13 @@ app_exit(void)
Diagram * diagram;
dialog = exit_dialog_make (GTK_WINDOW (interface_get_toolbox_shell ()),
- _("Exiting Dia"));
+ _("Exiting Dia"));
- list = dia_open_diagrams();
- while (list)
- {
+ list = dia_open_diagrams ();
+ while (list) {
diagram = list->data;
- if (diagram_is_modified (diagram))
- {
+ if (diagram_is_modified (diagram)) {
const gchar * name = diagram_get_name (diagram);
const gchar * path = diagram->filename;
exit_dialog_add_item (dialog, name, path, diagram);
@@ -902,84 +921,77 @@ app_exit(void)
gtk_widget_destroy (dialog);
- if (result == EXIT_DIALOG_EXIT_CANCEL)
- {
+ if (result == EXIT_DIALOG_EXIT_CANCEL) {
return FALSE;
- }
- else if (result == EXIT_DIALOG_EXIT_SAVE_SELECTED)
- {
- DiaContext *ctx = dia_context_new(_("Save"));
+ } else if (result == EXIT_DIALOG_EXIT_SAVE_SELECTED) {
+ DiaContext *ctx = dia_context_new(_("Save"));
int i;
- for (i = 0 ; i < items->array_size ; i++) {
- gchar *filename;
-
- diagram = items->array[i].data;
- filename = g_filename_from_utf8 (diagram->filename, -1, NULL, NULL, NULL);
- diagram_update_extents (diagram);
- dia_context_set_filename (ctx, filename);
- if (!diagram_save (diagram, filename, ctx)) {
- exit_dialog_free_items (items);
- dia_context_release (ctx);
- return FALSE;
- } else {
- dia_context_reset (ctx);
- }
- g_free (filename);
- }
- dia_context_release (ctx);
- exit_dialog_free_items (items);
- }
- else if (result == EXIT_DIALOG_EXIT_NO_SAVE)
- {
- list = dia_open_diagrams();
+ for (i = 0; i < items->array_size; i++) {
+ gchar *filename;
+
+ diagram = items->array[i].data;
+ filename = g_filename_from_utf8 (diagram->filename, -1, NULL, NULL, NULL);
+ diagram_update_extents (diagram);
+ dia_context_set_filename (ctx, filename);
+ if (!diagram_save (diagram, filename, ctx)) {
+ exit_dialog_free_items (items);
+ dia_context_release (ctx);
+ return FALSE;
+ } else {
+ dia_context_reset (ctx);
+ }
+ g_free (filename);
+ }
+ dia_context_release (ctx);
+ exit_dialog_free_items (items);
+ } else if (result == EXIT_DIALOG_EXIT_NO_SAVE) {
+ list = dia_open_diagrams ();
while (list) {
diagram = list->data;
- /* slight hack: don't ask again */
+ /* slight hack: don't ask again */
diagram_set_modified (diagram, FALSE);
- undo_clear(diagram->undo);
+ undo_clear (diagram->undo);
list = g_list_next (list);
- }
+ }
}
- }
- else
- {
- GtkWidget *dialog;
- GtkWidget *button;
- dialog = gtk_message_dialog_new(
- NULL, GTK_DIALOG_MODAL,
- GTK_MESSAGE_QUESTION,
- GTK_BUTTONS_NONE, /* no standard buttons */
- _("Quitting without saving modified diagrams"));
- gtk_message_dialog_format_secondary_text(GTK_MESSAGE_DIALOG(dialog),
- _("Modified diagrams exist. "
- "Are you sure you want to quit Dia "
- "without saving them?"));
-
- gtk_window_set_title (GTK_WINDOW(dialog), _("Quit Dia"));
-
- button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
- gtk_dialog_add_action_widget (GTK_DIALOG(dialog), button, GTK_RESPONSE_CANCEL);
- gtk_widget_set_can_default (GTK_WIDGET (button), TRUE);
- gtk_dialog_set_default_response (GTK_DIALOG(dialog), GTK_RESPONSE_CANCEL);
-
- button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
- gtk_dialog_add_action_widget (GTK_DIALOG(dialog), button, GTK_RESPONSE_OK);
-
- gtk_widget_show_all (dialog);
-
- if (gtk_dialog_run(GTK_DIALOG(dialog)) != GTK_RESPONSE_OK) {
- gtk_widget_destroy(dialog);
- return FALSE;
- }
- gtk_widget_destroy(dialog);
+ } else {
+ GtkWidget *dialog;
+ GtkWidget *button;
+ dialog = gtk_message_dialog_new (NULL,
+ GTK_DIALOG_MODAL,
+ GTK_MESSAGE_QUESTION,
+ GTK_BUTTONS_NONE, /* no standard buttons */
+ _("Quitting without saving modified diagrams"));
+ gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
+ _("Modified diagrams exist. "
+ "Are you sure you want to "
+ "quit Dia without saving them?"));
+
+ gtk_window_set_title (GTK_WINDOW (dialog), _("Quit Dia"));
+
+ button = gtk_button_new_from_stock (GTK_STOCK_CANCEL);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_CANCEL);
+ gtk_widget_set_can_default (GTK_WIDGET (button), TRUE);
+ gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+ button = gtk_button_new_from_stock (GTK_STOCK_QUIT);
+ gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK);
+
+ gtk_widget_show_all (dialog);
+
+ if (gtk_dialog_run (GTK_DIALOG (dialog)) != GTK_RESPONSE_OK) {
+ gtk_widget_destroy (dialog);
+ return FALSE;
+ }
+ gtk_widget_destroy (dialog);
}
}
- prefs_save();
+ prefs_save ();
- persistence_save();
+ persistence_save ();
- dynobj_refresh_finish();
+ dynobj_refresh_finish ();
{
DiaContext *ctx = dia_context_new (_("Exit"));
@@ -988,26 +1000,27 @@ app_exit(void)
}
/* Free loads of stuff (toolbox) */
- list = dia_open_diagrams();
- while (list!=NULL) {
- Diagram *dia = (Diagram *)list->data;
- list = g_list_next(list);
+ list = dia_open_diagrams ();
+ while (list != NULL) {
+ Diagram *dia = (Diagram *) list->data;
+ list = g_list_next (list);
slist = dia->displays;
- while (slist!=NULL) {
- DDisplay *ddisp = (DDisplay *)slist->data;
- slist = g_slist_next(slist);
+ while (slist != NULL) {
+ DDisplay *ddisp = (DDisplay *) slist->data;
+ slist = g_slist_next (slist);
- gtk_widget_destroy(ddisp->shell);
+ gtk_widget_destroy (ddisp->shell);
}
/* The diagram is freed when the last display is destroyed */
}
/* save pluginrc */
- if (dia_is_interactive)
- dia_pluginrc_write();
+ if (dia_is_interactive) {
+ dia_pluginrc_write ();
+ }
- gtk_main_quit();
+ gtk_main_quit ();
/* This printf seems to prevent a race condition with unrefs. */
/* Yuck. -Lars */
@@ -1018,7 +1031,8 @@ app_exit(void)
return TRUE;
}
-static void create_user_dirs(void)
+static void
+create_user_dirs (void)
{
gchar *dir, *subdir;
@@ -1026,73 +1040,84 @@ static void create_user_dirs(void)
/* not necessary to quit the program with g_error, everywhere else
* dia_config_filename appears to be used. Spit out a warning ...
*/
- if (!g_get_home_dir())
- {
- g_warning(_("Could not create per-user Dia configuration directory"));
+ if (!g_get_home_dir ()) {
+ g_warning (_("Could not create per-user Dia configuration directory"));
return; /* ... and return. Probably removes my one and only FAQ. --HB */
}
#endif
- dir = g_strconcat(g_get_home_dir(), G_DIR_SEPARATOR_S ".dia", NULL);
- if (g_mkdir(dir, 0755) && errno != EEXIST) {
+ dir = g_strconcat (g_get_home_dir (), G_DIR_SEPARATOR_S ".dia", NULL);
+ if (g_mkdir (dir, 0755) && errno != EEXIST) {
#ifndef G_OS_WIN32
- g_critical(_("Could not create per-user Dia configuration directory"));
- exit(1);
+ g_critical (_("Could not create per-user Dia configuration directory"));
+ exit (1);
#else /* HB: it this really a reason to exit the program on *nix ? */
- g_warning(_("Could not create per-user Dia configuration directory. Please make "
- "sure that the environment variable HOME points to an existing directory."));
+ g_warning (_("Could not create per-user Dia configuration directory. Please make "
+ "sure that the environment variable HOME points to an existing directory."));
#endif
}
/* it is no big deal if these directories can't be created */
- subdir = g_strconcat(dir, G_DIR_SEPARATOR_S "objects", NULL);
- g_mkdir(subdir, 0755);
- g_free(subdir);
- subdir = g_strconcat(dir, G_DIR_SEPARATOR_S "shapes", NULL);
- g_mkdir(subdir, 0755);
- g_free(subdir);
- subdir = g_strconcat(dir, G_DIR_SEPARATOR_S "sheets", NULL);
- g_mkdir(subdir, 0755);
- g_free(subdir);
-
- g_free(dir);
+ subdir = g_strconcat (dir, G_DIR_SEPARATOR_S "objects", NULL);
+ g_mkdir (subdir, 0755);
+ g_free (subdir);
+ subdir = g_strconcat (dir, G_DIR_SEPARATOR_S "shapes", NULL);
+ g_mkdir (subdir, 0755);
+ g_free (subdir);
+ subdir = g_strconcat (dir, G_DIR_SEPARATOR_S "sheets", NULL);
+ g_mkdir (subdir, 0755);
+ g_free (subdir);
+
+ g_free (dir);
}
static PluginInitResult
-internal_plugin_init(PluginInfo *info)
+internal_plugin_init (PluginInfo *info)
{
- if (!dia_plugin_info_init(info, "Internal",
- _("Objects and filters internal to Dia"),
- NULL, NULL))
+ if (!dia_plugin_info_init (info,
+ "Internal",
+ _("Objects and filters internal to Dia"),
+ NULL,
+ NULL)) {
return DIA_PLUGIN_INIT_ERROR;
+ }
/* register the group object type */
- object_register_type(&group_type);
+ object_register_type (&group_type);
/* register import filters */
- filter_register_import(&dia_import_filter);
+ filter_register_import (&dia_import_filter);
/* register export filters */
/* Standard Dia format */
- filter_register_export(&dia_export_filter);
+ filter_register_export (&dia_export_filter);
return DIA_PLUGIN_INIT_OK;
}
static gboolean
-handle_all_diagrams(GSList *files, char *export_file_name,
- char *export_file_format, char *size, char *show_layers,
- const gchar *input_directory, const gchar *output_directory)
+handle_all_diagrams (GSList *files,
+ char *export_file_name,
+ char *export_file_format,
+ char *size,
+ char *show_layers,
+ const char *input_directory,
+ const char *output_directory)
{
GSList *node = NULL;
gboolean made_conversions = FALSE;
for (node = files; node; node = node->next) {
- gchar *inpath = input_directory ? g_build_filename(input_directory, node->data, NULL) : node->data;
+ gchar *inpath = input_directory ? g_build_filename (input_directory, node->data, NULL) : node->data;
made_conversions |=
- handle_initial_diagram(inpath, export_file_name,
- export_file_format, size, show_layers, output_directory);
- if (inpath != node->data)
- g_free(inpath);
+ handle_initial_diagram (inpath,
+ export_file_name,
+ export_file_format,
+ size,
+ show_layers,
+ output_directory);
+ if (inpath != node->data) {
+ g_free (inpath);
+ }
}
return made_conversions;
}
@@ -1107,30 +1132,30 @@ handle_all_diagrams(GSList *files, char *export_file_name,
one maintainer).
*/
static void
-print_credits(void)
+print_credits (void)
{
int i;
- const gint nauthors = (sizeof(authors) / sizeof(authors[0])) - 1;
- const gint ndocumentors = (sizeof(documentors) / sizeof(documentors[0])) - 1;
+ const gint nauthors = (sizeof (authors) / sizeof (authors[0])) - 1;
+ const gint ndocumentors = (sizeof (documentors) / sizeof (documentors[0])) - 1;
- g_print(_("The original author of Dia was:\n\n"));
+ g_print (_("The original author of Dia was:\n\n"));
for (i = 0; i < NUMBER_OF_ORIG_AUTHORS; i++) {
- g_print("%s\n", authors[i]);
+ g_print ("%s\n", authors[i]);
}
- g_print(_("\nThe current maintainers of Dia are:\n\n"));
+ g_print (_("\nThe current maintainers of Dia are:\n\n"));
for (i = NUMBER_OF_ORIG_AUTHORS; i < NUMBER_OF_ORIG_AUTHORS + NUMBER_OF_MAINTAINERS; i++) {
- g_print("%s\n", authors[i]);
+ g_print ("%s\n", authors[i]);
}
- g_print(_("\nOther authors are:\n\n"));
+ g_print (_("\nOther authors are:\n\n"));
for (i = NUMBER_OF_ORIG_AUTHORS + NUMBER_OF_MAINTAINERS; i < nauthors; i++) {
- g_print("%s\n", authors[i]);
+ g_print ("%s\n", authors[i]);
}
- g_print(_("\nDia is documented by:\n\n"));
+ g_print (_("\nDia is documented by:\n\n"));
for (i = 0; i < ndocumentors; i++) {
- g_print("%s\n", documentors[i]);
+ g_print ("%s\n", documentors[i]);
}
}
@@ -1170,22 +1195,25 @@ print_filters_list (gboolean verbose)
g_print ("%s\n", _("Available Export Filters (for --filter)"));
g_print ("%10s%20s %s\n",
- /* Translators: be brief or mess up the table for --list-filters */
- _("Extension"),
- _("Identifier"),
- _("Description"));
- by_extension = g_array_new (FALSE, FALSE, sizeof(PairExtensionFilter));
- for (list = filter_get_export_filters(); list != NULL; list = list->next) {
+ /* Translators: be brief or mess up the table for --list-filters */
+ _("Extension"),
+ _("Identifier"),
+ _("Description"));
+ by_extension = g_array_new (FALSE, FALSE, sizeof (PairExtensionFilter));
+ for (list = filter_get_export_filters (); list != NULL; list = list->next) {
const DiaExportFilter *ef = list->data;
- if (!ef->extensions)
+ if (!ef->extensions) {
continue;
+ }
+
for (j = 0; ef->extensions[j] != NULL; ++j) {
PairExtensionFilter pair = { ef->extensions[j], ef };
g_array_append_val (by_extension, pair);
- if (!verbose)
- break; /* additional extensions don't provide significant information */
+ if (!verbose) {
+ break; /* additional extensions don't provide significant information */
+ }
}
}
g_array_sort (by_extension, _cmp_filter);
@@ -1193,9 +1221,9 @@ print_filters_list (gboolean verbose)
PairExtensionFilter *pair = &g_array_index (by_extension, PairExtensionFilter, j);
g_print ("%10s%20s %s\n",
- pair->ext,
- pair->ef->unique_name ? pair->ef->unique_name : "",
- pair->ef->description);
+ pair->ext,
+ pair->ef->unique_name ? pair->ef->unique_name : "",
+ pair->ef->description);
}
g_array_free (by_extension, TRUE);
}
diff --git a/app/app_procs.h b/app/app_procs.h
index 48f56098..d1d311c7 100644
--- a/app/app_procs.h
+++ b/app/app_procs.h
@@ -20,16 +20,16 @@
#include <glib.h>
-void app_init(int argc, char **argv);
+void app_init (int argc, char **argv);
/** Exit the application, but asking the user for confirmation
* if there are changed diagrams.
* Returns TRUE if the application exits.
*/
-gboolean app_exit(void);
+gboolean app_exit (void);
-void app_splash_init(const gchar* name);
-void app_splash_done(void);
+void app_splash_init (const gchar* name);
+void app_splash_done (void);
-gboolean app_is_interactive(void);
+gboolean app_is_interactive (void);
#endif /* APP_PROCS_H */
diff --git a/app/menus.c b/app/menus.c
index 7401b3d9..f9b91df4 100644
--- a/app/menus.c
+++ b/app/menus.c
@@ -62,8 +62,7 @@
static void plugin_callback (GtkWidget *widget, gpointer data);
-static GtkWidget *
-create_integrated_ui_toolbar (void);
+static GtkWidget *create_integrated_ui_toolbar (void);
static void add_plugin_actions (GtkUIManager *ui_manager, const char *base_path);
@@ -307,48 +306,36 @@ _dia_translate (const gchar* term, gpointer data)
/* first try our own ... */
trans = dgettext (GETTEXT_PACKAGE, term);
/* ... than gtk */
- if (term == trans)
+ if (term == trans) {
trans = dgettext ("gtk20", term);
-#if 0
- /* FIXME: final fallback */
- if (term == trans) { /* FIXME: translation to be updated */
- gchar* kludge = g_strdup_printf ("/%s", term);
- trans = dgettext (GETTEXT_PACKAGE, kludge);
- if (kludge == trans)
- trans = term;
- else
- ++trans;
- g_free (kludge);
}
- if (term == trans)
- trans = g_strdup_printf ("XXX: %s", term);
-#endif
}
return trans;
}
static void
-tool_menu_select(GtkWidget *w, gpointer data) {
+tool_menu_select (GtkWidget *w,
+ gpointer data) {
ToolButtonData *tooldata = (ToolButtonData *) data;
if (tooldata == NULL) {
- g_warning(_("NULL tooldata in tool_menu_select"));
+ g_warning (_("NULL tooldata in tool_menu_select"));
return;
}
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tooldata->widget),TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (tooldata->widget), TRUE);
}
static void
-load_accels(void)
+load_accels (void)
{
gchar *accelfilename;
/* load accelerators and prepare to later save them */
- accelfilename = dia_config_filename("menurc");
+ accelfilename = dia_config_filename ("menurc");
if (accelfilename) {
- gtk_accel_map_load(accelfilename);
- g_free(accelfilename);
+ gtk_accel_map_load (accelfilename);
+ g_free (accelfilename);
}
}
@@ -357,11 +344,10 @@ load_accels(void)
* @param param Display to synchronize to.
*/
void
-integrated_ui_toolbar_object_snap_synchronize_to_display(gpointer param)
+integrated_ui_toolbar_object_snap_synchronize_to_display (gpointer param)
{
DDisplay *ddisp = param;
- if (ddisp && ddisp->common_toolbar)
- {
+ if (ddisp && ddisp->common_toolbar) {
GtkToggleButton *b = g_object_get_data (G_OBJECT (ddisp->common_toolbar),
DIA_INTEGRATED_TOOLBAR_OBJECT_SNAP);
gboolean active = ddisp->mainpoint_magnetism? TRUE : FALSE;
@@ -375,11 +361,11 @@ integrated_ui_toolbar_object_snap_synchronize_to_display(gpointer param)
* @param not_used
*/
static void
-integrated_ui_toolbar_object_snap_toggle(GtkToggleButton *b, gpointer *not_used)
+integrated_ui_toolbar_object_snap_toggle (GtkToggleButton *b,
+ gpointer *not_used)
{
DDisplay *ddisp = ddisplay_active ();
- if (ddisp)
- {
+ if (ddisp) {
ddisplay_set_snap_to_objects (ddisp, gtk_toggle_button_get_active (b));
}
}
@@ -389,11 +375,10 @@ integrated_ui_toolbar_object_snap_toggle(GtkToggleButton *b, gpointer *not_used)
* @param param Display to synchronize to.
*/
void
-integrated_ui_toolbar_grid_snap_synchronize_to_display(gpointer param)
+integrated_ui_toolbar_grid_snap_synchronize_to_display (gpointer param)
{
DDisplay *ddisp = param;
- if (ddisp && ddisp->common_toolbar)
- {
+ if (ddisp && ddisp->common_toolbar) {
GtkToggleButton *b = g_object_get_data (G_OBJECT (ddisp->common_toolbar),
DIA_INTEGRATED_TOOLBAR_SNAP_GRID);
gboolean active = ddisp->grid.snap? TRUE : FALSE;
@@ -407,11 +392,10 @@ integrated_ui_toolbar_grid_snap_synchronize_to_display(gpointer param)
* @param not_used
*/
static void
-integrated_ui_toolbar_grid_snap_toggle(GtkToggleButton *b, gpointer *not_used)
+integrated_ui_toolbar_grid_snap_toggle (GtkToggleButton *b, gpointer *not_used)
{
DDisplay *ddisp = ddisplay_active ();
- if (ddisp)
- {
+ if (ddisp) {
ddisplay_set_snap_to_grid (ddisp, gtk_toggle_button_get_active (b));
}
}
@@ -421,18 +405,17 @@ integrated_ui_toolbar_grid_snap_toggle(GtkToggleButton *b, gpointer *not_used)
* @param toolbar Integrated UI toolbar.
* @param text Current zoom percentage for the active window
*/
-void integrated_ui_toolbar_set_zoom_text (GtkToolbar *toolbar, const gchar * text)
+void
+integrated_ui_toolbar_set_zoom_text (GtkToolbar *toolbar, const gchar * text)
{
- if (toolbar)
- {
+ if (toolbar) {
GtkComboBox *combo_entry = g_object_get_data (G_OBJECT (toolbar),
DIA_INTEGRATED_TOOLBAR_ZOOM_COMBO);
- if (combo_entry)
- {
- GtkWidget * entry = gtk_bin_get_child (GTK_BIN (combo_entry));
+ if (combo_entry) {
+ GtkWidget * entry = gtk_bin_get_child (GTK_BIN (combo_entry));
- gtk_entry_set_text (GTK_ENTRY (entry), text);
+ gtk_entry_set_text (GTK_ENTRY (entry), text);
}
}
}
@@ -443,33 +426,33 @@ void integrated_ui_toolbar_set_zoom_text (GtkToolbar *toolbar, const gchar * tex
* @param toolbar The toolbar to add the widget to.
* @param w The widget to add to the toolbar.
*/
-static void integrated_ui_toolbar_add_custom_item (GtkToolbar *toolbar, GtkWidget *w)
+static void
+integrated_ui_toolbar_add_custom_item (GtkToolbar *toolbar, GtkWidget *w)
{
- GtkToolItem *tool_item;
- GtkWidget *c; /* container */
-
- tool_item = gtk_tool_item_new ();
- c = gtk_vbox_new (FALSE, 0);
- gtk_container_add (GTK_CONTAINER (tool_item), c);
- gtk_box_set_homogeneous (GTK_BOX (c), TRUE); /* Centers the button */
- gtk_box_pack_start (GTK_BOX (c), w, FALSE, FALSE, 0);
- gtk_toolbar_insert (toolbar, tool_item, -1);
- gtk_widget_show (GTK_WIDGET (tool_item));
- gtk_widget_show (c);
- gtk_widget_show (w);
+ GtkToolItem *tool_item;
+ GtkWidget *c; /* container */
+
+ tool_item = gtk_tool_item_new ();
+ c = gtk_vbox_new (FALSE, 0);
+ gtk_container_add (GTK_CONTAINER (tool_item), c);
+ gtk_box_set_homogeneous (GTK_BOX (c), TRUE); /* Centers the button */
+ gtk_box_pack_start (GTK_BOX (c), w, FALSE, FALSE, 0);
+ gtk_toolbar_insert (toolbar, tool_item, -1);
+ gtk_widget_show (GTK_WIDGET (tool_item));
+ gtk_widget_show (c);
+ gtk_widget_show (w);
}
static void
integrated_ui_toolbar_zoom_activate (GtkWidget *item,
gpointer user_data)
{
- const gchar *text = gtk_entry_get_text (GTK_ENTRY (item));
- float zoom_percent;
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (item));
+ float zoom_percent;
- if (sscanf (text, "%f", &zoom_percent) == 1)
- {
- view_zoom_set (10.0 * zoom_percent);
- }
+ if (sscanf (text, "%f", &zoom_percent) == 1) {
+ view_zoom_set (10.0 * zoom_percent);
+ }
}
/* "DiaZoomCombo" probably could work for both UI cases */
@@ -477,29 +460,28 @@ static void
integrated_ui_toolbar_zoom_combo_selection_changed (GtkComboBox *combo,
gpointer user_data)
{
- /*
- * We call gtk_combo_get_get_active() so that typing in the combo entry
- * doesn't get handled as a selection change
- */
- if (gtk_combo_box_get_active (combo) != -1)
- {
- float zoom_percent;
- gchar *text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
- if (sscanf (text, "%f", &zoom_percent) == 1)
- {
- view_zoom_set (zoom_percent * 10.0);
- }
- else if (g_ascii_strcasecmp (text, ZOOM_FIT) == 0)
- {
- view_show_all_callback (NULL);
- }
-
- g_free (text);
+ /*
+ * We call gtk_combo_get_get_active() so that typing in the combo entry
+ * doesn't get handled as a selection change
+ */
+ if (gtk_combo_box_get_active (combo) != -1) {
+ float zoom_percent;
+ gchar *text = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo));
+ if (sscanf (text, "%f", &zoom_percent) == 1) {
+ view_zoom_set (zoom_percent * 10.0);
+ } else if (g_ascii_strcasecmp (text, ZOOM_FIT) == 0) {
+ view_show_all_callback (NULL);
}
+
+ g_free (text);
+ }
}
static guint
-ensure_menu_path (GtkUIManager *ui_manager, GtkActionGroup *actions, const gchar *path, gboolean end)
+ensure_menu_path (GtkUIManager *ui_manager,
+ GtkActionGroup *actions,
+ const gchar *path,
+ gboolean end)
{
guint id = gtk_ui_manager_new_merge_id (ui_manager);
@@ -519,14 +501,18 @@ ensure_menu_path (GtkUIManager *ui_manager, GtkActionGroup *actions, const gchar
ensure_menu_path (ui_manager, actions, subpath, FALSE);
action = gtk_action_new (action_name, sep + 1, NULL, NULL);
- if (!gtk_action_group_get_action (actions, action_name))
+ if (!gtk_action_group_get_action (actions, action_name)) {
gtk_action_group_add_action (actions, action);
+ }
g_object_unref (G_OBJECT (action));
- gtk_ui_manager_add_ui (ui_manager, id, subpath,
- action_name, action_name,
- end ? GTK_UI_MANAGER_SEPARATOR : GTK_UI_MANAGER_MENU,
- FALSE); /* FALSE=add-to-end */
+ gtk_ui_manager_add_ui (ui_manager,
+ id,
+ subpath,
+ action_name,
+ action_name,
+ end ? GTK_UI_MANAGER_SEPARATOR : GTK_UI_MANAGER_MENU,
+ FALSE); /* FALSE=add-to-end */
} else {
g_warning ("ensure_menu_path() invalid menu path: %s.", subpath ? subpath : "NULL");
}
@@ -554,8 +540,7 @@ create_integrated_ui_toolbar (void)
g_error_free (error);
error = NULL;
toolbar = GTK_TOOLBAR (gtk_toolbar_new ());
- }
- else {
+ } else {
toolbar = GTK_TOOLBAR(gtk_ui_manager_get_widget (_ui_manager, "/Toolbar"));
}
g_free (uifile);
@@ -590,8 +575,7 @@ create_integrated_ui_toolbar (void)
gtk_entry_set_width_chars (GTK_ENTRY (w), 6);
g_signal_connect (G_OBJECT (w), "activate",
- G_CALLBACK(integrated_ui_toolbar_zoom_activate),
- NULL);
+ G_CALLBACK (integrated_ui_toolbar_zoom_activate), NULL);
/* Seperator */
sep = gtk_separator_tool_item_new ();
@@ -603,7 +587,8 @@ create_integrated_ui_toolbar (void)
"dia-grid-off");
g_signal_connect (G_OBJECT (w), "toggled",
- G_CALLBACK (integrated_ui_toolbar_grid_snap_toggle), toolbar);
+ G_CALLBACK (integrated_ui_toolbar_grid_snap_toggle),
+ toolbar);
gtk_widget_set_tooltip_text (w, _("Toggles snap-to-grid."));
g_object_set_data (G_OBJECT (toolbar),
DIA_INTEGRATED_TOOLBAR_SNAP_GRID,
@@ -614,7 +599,8 @@ create_integrated_ui_toolbar (void)
w = dia_toggle_button_new_with_icon_names ("dia-mainpoints-on",
"dia-mainpoints-off");
g_signal_connect (G_OBJECT (w), "toggled",
- G_CALLBACK (integrated_ui_toolbar_object_snap_toggle), toolbar);
+ G_CALLBACK (integrated_ui_toolbar_object_snap_toggle),
+ toolbar);
gtk_widget_set_tooltip_text (w, _("Toggles object snapping."));
g_object_set_data (G_OBJECT (toolbar),
DIA_INTEGRATED_TOOLBAR_OBJECT_SNAP,
@@ -640,15 +626,18 @@ create_or_ref_tool_actions (void)
GtkAction *action;
int i;
- if (tool_actions)
+ if (tool_actions) {
return g_object_ref (tool_actions);
+ }
actions = gtk_action_group_new ("tool-actions");
gtk_action_group_set_translation_domain (actions, NULL);
gtk_action_group_set_translate_func (actions, _dia_translate, NULL, NULL);
- gtk_action_group_add_actions (actions, tool_entries,
- G_N_ELEMENTS (tool_entries), NULL);
+ gtk_action_group_add_actions (actions,
+ tool_entries,
+ G_N_ELEMENTS (tool_entries),
+ NULL);
icon_factory = gtk_icon_factory_new ();
@@ -656,23 +645,22 @@ create_or_ref_tool_actions (void)
action = gtk_action_group_get_action (actions, tool_data[i].action_name);
if (action != NULL) {
g_signal_connect (G_OBJECT (action), "activate",
- G_CALLBACK (tool_menu_select),
- &tool_data[i].callback_data);
+ G_CALLBACK (tool_menu_select),
+ &tool_data[i].callback_data);
gtk_action_set_tooltip (action, _(tool_data[i].tool_desc));
{
GdkPixbuf *pb = tool_get_pixbuf (&tool_data[i]);
- GtkIconSet *is = gtk_icon_set_new_from_pixbuf (pb);
+ GtkIconSet *is = gtk_icon_set_new_from_pixbuf (pb);
- /* not sure if the action name is unique enough */
- gtk_icon_factory_add (icon_factory, tool_data[i].action_name, is);
- gtk_action_set_stock_id (action, tool_data[i].action_name);
+ /* not sure if the action name is unique enough */
+ gtk_icon_factory_add (icon_factory, tool_data[i].action_name, is);
+ gtk_action_set_stock_id (action, tool_data[i].action_name);
- g_object_unref (pb);
+ g_object_unref (pb);
}
- }
- else {
+ } else {
g_warning ("couldn't find tool menu item %s", tool_data[i].action_name);
}
}
@@ -799,6 +787,23 @@ build_ui_filename (const gchar* name)
return uifile;
}
+GtkBuilder *
+builder_new_from_file (const char *filename)
+{
+ GError *error = NULL;
+ gchar *uifile;
+ GtkBuilder *builder;
+
+ builder = gtk_builder_new ();
+ uifile = build_ui_filename (filename);
+ if (!gtk_builder_add_from_file (builder, uifile, &error)) {
+ g_warning ("Couldn't load builder file: %s", error->message);
+ g_error_free (error);
+ }
+ g_free (uifile);
+ return builder;
+}
+
/*!
* Not sure why this service is not provided by GTK+.
* We are passing tooltips into the actions (especially recent file menu).
@@ -809,24 +814,16 @@ _ui_manager_connect_proxy (GtkUIManager *manager,
GtkAction *action,
GtkWidget *proxy)
{
- if (GTK_IS_MENU_ITEM (proxy))
- {
- gchar *tooltip;
-
- g_object_get (action, "tooltip", &tooltip, NULL);
-
- if (tooltip)
- {
- gtk_widget_set_tooltip_text (proxy, tooltip);
- g_free (tooltip);
- }
- else
- {
- const gchar *name = gtk_action_get_name (action);
-
- dia_log_message ("Action '%s' missing tooltip\n", name);
- }
+ if (GTK_IS_MENU_ITEM (proxy)) {
+ gchar *tooltip;
+
+ g_object_get (action, "tooltip", &tooltip, NULL);
+
+ if (tooltip) {
+ gtk_widget_set_tooltip_text (proxy, tooltip);
+ g_free (tooltip);
}
+ }
}
static GtkActionGroup *
@@ -872,14 +869,14 @@ _action_start (GtkActionGroup *action_group,
GtkAction *action,
gpointer user_data)
{
- dia_log_message ("Start '%s'\n", gtk_action_get_name (action));
+ dia_log_message ("Start '%s'", gtk_action_get_name (action));
}
static void
_action_done (GtkActionGroup *action_group,
GtkAction *action,
gpointer user_data)
{
- dia_log_message ("Done '%s'\n", gtk_action_get_name (action));
+ dia_log_message ("Done '%s'", gtk_action_get_name (action));
}
static void
diff --git a/app/menus.h b/app/menus.h
index d300bc6b..d8fed263 100644
--- a/app/menus.h
+++ b/app/menus.h
@@ -29,35 +29,36 @@ struct zoom_pair { const gchar *string; const gint value; };
extern const struct zoom_pair zooms[10];
-void
-integrated_ui_toolbar_set_zoom_text (GtkToolbar *toolbar, const gchar * text);
-
-void
-integrated_ui_toolbar_grid_snap_synchronize_to_display (gpointer ddisp);
-
-void
-integrated_ui_toolbar_object_snap_synchronize_to_display (gpointer ddisp);
+void integrated_ui_toolbar_set_zoom_text (GtkToolbar *toolbar,
+ const gchar *text);
+void integrated_ui_toolbar_grid_snap_synchronize_to_display (gpointer ddisp);
+void integrated_ui_toolbar_object_snap_synchronize_to_display (gpointer ddisp);
/* TODO: rename: menus_get_integrated_ui_menubar() */
-void menus_get_integrated_ui_menubar (GtkWidget **menubar, GtkWidget **toolbar,
- GtkAccelGroup **accel);
-void menus_get_toolbox_menubar (GtkWidget **menubar, GtkAccelGroup **accel);
+void menus_get_integrated_ui_menubar (GtkWidget **menubar,
+ GtkWidget **toolbar,
+ GtkAccelGroup **accel);
+void menus_get_toolbox_menubar (GtkWidget **menubar,
+ GtkAccelGroup **accel);
GtkWidget * menus_get_display_popup (void);
GtkAccelGroup * menus_get_display_accels (void);
-GtkWidget * menus_create_display_menubar (GtkUIManager **ui_manager, GtkActionGroup **actions);
+GtkWidget * menus_create_display_menubar (GtkUIManager **ui_manager,
+ GtkActionGroup **actions);
-GtkActionGroup *menus_get_tool_actions (void);
-GtkActionGroup *menus_get_display_actions (void);
+GtkActionGroup *menus_get_tool_actions (void);
+GtkActionGroup *menus_get_display_actions (void);
-GtkAction * menus_get_action (const gchar *name);
-GtkWidget * menus_get_widget (const gchar *name);
-void menus_set_recent (GtkActionGroup *actions);
-void menus_clear_recent (void);
+GtkAction * menus_get_action (const gchar *name);
+GtkWidget * menus_get_widget (const gchar *name);
+void menus_set_recent (GtkActionGroup *actions);
+void menus_clear_recent (void);
#define VIEW_MAIN_TOOLBAR_ACTION "ViewMainToolbar"
#define VIEW_MAIN_STATUSBAR_ACTION "ViewMainStatusbar"
#define VIEW_LAYERS_ACTION "ViewLayers"
+GtkBuilder *builder_new_from_file (const char *filename);
+
#endif /* MENUS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]