From afa4a2a62381d2502254a8928216f11509aa1b7d Mon Sep 17 00:00:00 2001 From: Jim Evins Date: Wed, 23 Sep 2009 03:41:02 +0000 Subject: [PATCH] 2009-09-22 Jim Evins * po/POTFILES.in: * src/Makefile.am: * src/builder-util.c: * src/builder-util.h: * src/combo-util.c: * src/combo-util.h: * src/file-util.c: * src/file-util.h: * src/str-util.c: * src/str-util.h: Split "catch all" util module into separate modules for different domains of utilities. * src/file.c: (gl_file_open_real), (save_as_response): * src/glabels-batch.c: (main): * src/label.c: (gl_label_get_short_name): * src/merge-properties-dialog.c: (gl_merge_properties_dialog_init), (gl_merge_properties_dialog_construct): * src/new-label-dialog.c: * src/object-editor-bc-page.c: (gl_object_editor_prepare_bc_page), (gl_object_editor_set_bc_style), (gl_object_editor_set_bc_color): * src/object-editor-data-page.c: (gl_object_editor_prepare_data_page), (gl_object_editor_set_data): * src/object-editor-edit-page.c: (gl_object_editor_prepare_edit_page): * src/object-editor-fill-page.c: (gl_object_editor_prepare_fill_page), (gl_object_editor_set_fill_color): * src/object-editor-image-page.c: (gl_object_editor_prepare_image_page), (gl_object_editor_set_image): * src/object-editor-line-page.c: (gl_object_editor_prepare_line_page), (gl_object_editor_set_line_color): * src/object-editor-lsize-page.c: (gl_object_editor_prepare_lsize_page): * src/object-editor-position-page.c: (gl_object_editor_prepare_position_page): * src/object-editor-shadow-page.c: (gl_object_editor_prepare_shadow_page), (gl_object_editor_set_shadow_color): * src/object-editor-size-page.c: (gl_object_editor_prepare_size_page): * src/object-editor-text-page.c: (gl_object_editor_prepare_text_page), (gl_object_editor_set_text_color): * src/object-editor.c: (gl_object_editor_init), (gl_object_editor_set_key_names): * src/prefs-dialog.c: (gl_prefs_dialog_construct), (construct_locale_page), (construct_object_page): * src/prefs-model.c: (gl_prefs_model_save_settings), (gl_prefs_model_load_settings): * src/print-op-dialog.c: (create_custom_widget_cb): * src/template-designer.c: (construct_start_page), (construct_name_page), (construct_pg_size_page), (construct_shape_page), (construct_rect_size_page), (construct_round_size_page), (construct_cd_size_page), (construct_nlayouts_page), (construct_layout_page), (construct_finish_page): * src/ui-property-bar.c: (gl_ui_property_bar_construct): * src/wdgt-media-select.c: (gl_wdgt_media_select_construct), (gl_wdgt_media_select_set_filter_parameters), (get_label_size_desc): * src/window.c: (gl_window_new_from_file): * src/xml-label-04.c: (xml04_parse_text_props): * src/xml-label.c: (xml_parse_object_text), (xml_parse_toplevel_span), (xml_create_object_text), (xml_create_toplevel_span): Reconciled all references to old utils module with new domain specific utilities modules. git-svn-id: https://glabels.svn.sourceforge.net/svnroot/glabels/trunk@895 f5e0f49d-192f-0410-a22d-a8d8700d0965 --- glabels2/ChangeLog | 72 +++++ glabels2/po/POTFILES.in | 10 +- glabels2/src/Makefile.am | 16 +- glabels2/src/builder-util.c | 65 ++++ glabels2/src/builder-util.h | 46 +++ glabels2/src/combo-util.c | 148 +++++++++ glabels2/src/combo-util.h | 50 +++ glabels2/src/file-util.c | 101 ++++++ glabels2/src/file-util.h | 46 +++ glabels2/src/file.c | 6 +- glabels2/src/glabels-batch.c | 4 +- glabels2/src/label.c | 4 +- glabels2/src/merge-properties-dialog.c | 15 +- glabels2/src/new-label-dialog.c | 1 - glabels2/src/object-editor-bc-page.c | 21 +- glabels2/src/object-editor-data-page.c | 11 +- glabels2/src/object-editor-edit-page.c | 4 +- glabels2/src/object-editor-fill-page.c | 11 +- glabels2/src/object-editor-image-page.c | 11 +- glabels2/src/object-editor-line-page.c | 11 +- glabels2/src/object-editor-lsize-page.c | 4 +- glabels2/src/object-editor-position-page.c | 4 +- glabels2/src/object-editor-shadow-page.c | 11 +- glabels2/src/object-editor-size-page.c | 4 +- glabels2/src/object-editor-text-page.c | 14 +- glabels2/src/object-editor.c | 19 +- glabels2/src/prefs-dialog.c | 8 +- glabels2/src/prefs-model.c | 14 +- glabels2/src/print-op-dialog.c | 4 +- glabels2/src/str-util.c | 142 +++++++++ glabels2/src/str-util.h | 50 +++ glabels2/src/template-designer.c | 29 +- glabels2/src/ui-property-bar.c | 4 +- glabels2/src/util.c | 354 --------------------- glabels2/src/util.h | 68 ---- glabels2/src/wdgt-media-select.c | 46 +-- glabels2/src/window.c | 4 +- glabels2/src/xml-label-04.c | 6 +- glabels2/src/xml-label.c | 10 +- 39 files changed, 885 insertions(+), 563 deletions(-) create mode 100644 glabels2/src/builder-util.c create mode 100644 glabels2/src/builder-util.h create mode 100644 glabels2/src/combo-util.c create mode 100644 glabels2/src/combo-util.h create mode 100644 glabels2/src/file-util.c create mode 100644 glabels2/src/file-util.h create mode 100644 glabels2/src/str-util.c create mode 100644 glabels2/src/str-util.h delete mode 100644 glabels2/src/util.c delete mode 100644 glabels2/src/util.h diff --git a/glabels2/ChangeLog b/glabels2/ChangeLog index 67458b4a..694c9692 100644 --- a/glabels2/ChangeLog +++ b/glabels2/ChangeLog @@ -1,3 +1,75 @@ +2009-09-22 Jim Evins + + * po/POTFILES.in: + * src/Makefile.am: + * src/builder-util.c: + * src/builder-util.h: + * src/combo-util.c: + * src/combo-util.h: + * src/file-util.c: + * src/file-util.h: + * src/str-util.c: + * src/str-util.h: + Split "catch all" util module into separate modules for different + domains of utilities. + * src/file.c: (gl_file_open_real), (save_as_response): + * src/glabels-batch.c: (main): + * src/label.c: (gl_label_get_short_name): + * src/merge-properties-dialog.c: (gl_merge_properties_dialog_init), + (gl_merge_properties_dialog_construct): + * src/new-label-dialog.c: + * src/object-editor-bc-page.c: (gl_object_editor_prepare_bc_page), + (gl_object_editor_set_bc_style), (gl_object_editor_set_bc_color): + * src/object-editor-data-page.c: + (gl_object_editor_prepare_data_page), (gl_object_editor_set_data): + * src/object-editor-edit-page.c: + (gl_object_editor_prepare_edit_page): + * src/object-editor-fill-page.c: + (gl_object_editor_prepare_fill_page), + (gl_object_editor_set_fill_color): + * src/object-editor-image-page.c: + (gl_object_editor_prepare_image_page), + (gl_object_editor_set_image): + * src/object-editor-line-page.c: + (gl_object_editor_prepare_line_page), + (gl_object_editor_set_line_color): + * src/object-editor-lsize-page.c: + (gl_object_editor_prepare_lsize_page): + * src/object-editor-position-page.c: + (gl_object_editor_prepare_position_page): + * src/object-editor-shadow-page.c: + (gl_object_editor_prepare_shadow_page), + (gl_object_editor_set_shadow_color): + * src/object-editor-size-page.c: + (gl_object_editor_prepare_size_page): + * src/object-editor-text-page.c: + (gl_object_editor_prepare_text_page), + (gl_object_editor_set_text_color): + * src/object-editor.c: (gl_object_editor_init), + (gl_object_editor_set_key_names): + * src/prefs-dialog.c: (gl_prefs_dialog_construct), + (construct_locale_page), (construct_object_page): + * src/prefs-model.c: (gl_prefs_model_save_settings), + (gl_prefs_model_load_settings): + * src/print-op-dialog.c: (create_custom_widget_cb): + * src/template-designer.c: (construct_start_page), + (construct_name_page), (construct_pg_size_page), + (construct_shape_page), (construct_rect_size_page), + (construct_round_size_page), (construct_cd_size_page), + (construct_nlayouts_page), (construct_layout_page), + (construct_finish_page): + * src/ui-property-bar.c: (gl_ui_property_bar_construct): + * src/wdgt-media-select.c: (gl_wdgt_media_select_construct), + (gl_wdgt_media_select_set_filter_parameters), + (get_label_size_desc): + * src/window.c: (gl_window_new_from_file): + * src/xml-label-04.c: (xml04_parse_text_props): + * src/xml-label.c: (xml_parse_object_text), + (xml_parse_toplevel_span), (xml_create_object_text), + (xml_create_toplevel_span): + Reconciled all references to old utils module with new domain + specific utilities modules. + 2009-09-22 Jim Evins * po/POTFILES.in: diff --git a/glabels2/po/POTFILES.in b/glabels2/po/POTFILES.in index 0638c379..e6f46d59 100644 --- a/glabels2/po/POTFILES.in +++ b/glabels2/po/POTFILES.in @@ -10,6 +10,8 @@ src/bc-iec18004.c src/bc-iec18004.h src/bc-postnet.c src/bc-postnet.h +src/builder-util.c +src/builder-util.h src/cairo-ellipse-path.c src/cairo-ellipse-path.h src/cairo-label-path.c @@ -30,12 +32,16 @@ src/color-combo-menu.h src/color.h src/color-swatch.c src/color-swatch.h +src/combo-util.c +src/combo-util.h src/critical-error-handler.c src/critical-error-handler.h src/debug.c src/debug.h src/file.c src/file.h +src/file-util.c +src/file-util.h src/font-combo.c src/font-combo.h src/font-combo-menu.c @@ -123,6 +129,8 @@ src/rotate-label-button.c src/rotate-label-button.h src/stock.c src/stock.h +src/str-util.c +src/str-util.h src/template-designer.c src/template-designer.h src/text-node.c @@ -137,8 +145,6 @@ src/ui-sidebar.c src/ui-sidebar.h src/ui-util.c src/ui-util.h -src/util.c -src/util.h src/view-barcode.c src/view-barcode.h src/view-box.c diff --git a/glabels2/src/Makefile.am b/glabels2/src/Makefile.am index fa5161b8..a1c833cc 100644 --- a/glabels2/src/Makefile.am +++ b/glabels2/src/Makefile.am @@ -68,6 +68,8 @@ glabels_SOURCES = \ ui-sidebar.c \ file.h \ file.c \ + file-util.h \ + file-util.c \ new-label-dialog.h \ new-label-dialog.c \ recent.h \ @@ -207,8 +209,12 @@ glabels_SOURCES = \ cairo-markup-path.h \ cairo-ellipse-path.c \ cairo-ellipse-path.h \ - util.c \ - util.h \ + combo-util.c \ + combo-util.h \ + builder-util.c \ + builder-util.h \ + str-util.c \ + str-util.h \ color.c \ color.h \ debug.c \ @@ -218,6 +224,8 @@ glabels_SOURCES = \ glabels_batch_SOURCES = \ glabels-batch.c \ + file-util.h \ + file-util.c \ print.c \ print.h \ print-op.c \ @@ -272,8 +280,8 @@ glabels_batch_SOURCES = \ prefs-model.h \ font-util.c \ font-util.h \ - util.c \ - util.h \ + str-util.c \ + str-util.h \ color.c \ color.h \ debug.c \ diff --git a/glabels2/src/builder-util.c b/glabels2/src/builder-util.c new file mode 100644 index 00000000..e78c2303 --- /dev/null +++ b/glabels2/src/builder-util.c @@ -0,0 +1,65 @@ +/* + * builder-util.c + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#include + +#include "builder-util.h" + + +/****************************************************************************/ +/* Get widgets from GtkBuilder "en masse." */ +/****************************************************************************/ +void gl_builder_util_get_widgets (GtkBuilder *builder, + gchar *first_name, + ...) +{ + va_list args; + gchar *name; + GtkWidget **p_widget; + + va_start (args, first_name); + + for ( name = first_name; name; name = va_arg (args, gchar *) ) + { + p_widget = va_arg (args, GtkWidget **); + + *p_widget = GTK_WIDGET (gtk_builder_get_object (builder, name)); + + if (!*p_widget) + { + g_critical ("Could not load widget \"%s\".\n\ngLabels may not be installed correctly!", + name); + break; + } + } + + va_end (args); +} + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/builder-util.h b/glabels2/src/builder-util.h new file mode 100644 index 00000000..c3e55493 --- /dev/null +++ b/glabels2/src/builder-util.h @@ -0,0 +1,46 @@ +/* + * builder-util.h + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#ifndef __BUILDER_UTIL_H__ +#define __BUILDER_UTIL_H__ + +#include +#include + +G_BEGIN_DECLS + +void gl_builder_util_get_widgets (GtkBuilder *builder, + gchar *first_name, + ...); + +G_END_DECLS + +#endif /* __BUILDER_UTIL_H__ */ + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/combo-util.c b/glabels2/src/combo-util.c new file mode 100644 index 00000000..0ca90f1f --- /dev/null +++ b/glabels2/src/combo-util.c @@ -0,0 +1,148 @@ +/* + * combo-util.c + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#include + +#include "combo-util.h" + +#include + + +/****************************************************************************/ +/* Convienience function to set strings in a text combo_box from a GList */ +/****************************************************************************/ +void +gl_combo_util_set_strings (GtkComboBox *combo, + GList *list) +{ + GtkTreeModel *model; + GList *p; + + g_return_if_fail (list); + + model = gtk_combo_box_get_model(combo); + gtk_list_store_clear (GTK_LIST_STORE (model)); + + for (p=list; p!=NULL; p=p->next) { + if (p->data) { + gtk_combo_box_append_text (combo, p->data); + } + } +} + + +/*---------------------------------------------------------------------------*/ +/* PRIVATE. gl_combo_util_set_active_text support. */ +/*---------------------------------------------------------------------------*/ + +typedef struct { + const gchar *text; + GtkTreeIter iter; + gboolean found; +} TextSearchData; + +static gboolean +search_text_func (GtkTreeModel *model, + GtkTreePath *path, + GtkTreeIter *iter, + gpointer data) +{ + TextSearchData *search_data = (TextSearchData *)data; + gchar *text = NULL; + + gtk_tree_model_get (model, iter, 0, &text, -1); + + if (strcmp (text,search_data->text) == 0) { + search_data->found = TRUE; + search_data->iter = *iter; + } + + g_free (text); + + return FALSE; +} + + +/****************************************************************************/ +/* Convienience function to set active text in a text combo_box from text */ +/****************************************************************************/ +void +gl_combo_util_set_active_text (GtkComboBox *combo, + const gchar *text) +{ + GtkTreeModel *model = gtk_combo_box_get_model(combo); + + g_return_if_fail (GTK_IS_LIST_STORE (model)); + + if (!text) { + + gtk_combo_box_set_active (combo, -1); + + } else { + TextSearchData search_data; + + search_data.text = text; + search_data.found = FALSE; + + gtk_tree_model_foreach (model, search_text_func, &search_data); + if (search_data.found) { + gtk_combo_box_set_active_iter (combo, + &search_data.iter); + } else { + gtk_combo_box_set_active (combo, -1); + } + + } + +} + + +/****************************************************************************/ +/* Convienience function to add a simple text model to an existing */ +/* combo_box. This is needed since combo_boxes created with glade do not */ +/* use the gtk_combo_box_new_text() constructor. */ +/****************************************************************************/ +void +gl_combo_util_add_text_model (GtkComboBox *combo) +{ + GtkCellRenderer *cell; + GtkListStore *store; + + store = gtk_list_store_new (1, G_TYPE_STRING); + gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); + g_object_unref (store); + + cell = gtk_cell_renderer_text_new (); + gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); + gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, + "text", 0, + NULL); +} + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/combo-util.h b/glabels2/src/combo-util.h new file mode 100644 index 00000000..2205b6f2 --- /dev/null +++ b/glabels2/src/combo-util.h @@ -0,0 +1,50 @@ +/* + * combo-util.h + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#ifndef __COMBO_UTIL_H__ +#define __COMBO_UTIL_H__ + +#include +#include + +G_BEGIN_DECLS + +void gl_combo_util_set_strings (GtkComboBox *combo, + GList *list); + +void gl_combo_util_set_active_text (GtkComboBox *combo, + const gchar *text); + +void gl_combo_util_add_text_model (GtkComboBox *combo); + +G_END_DECLS + +#endif /* __COMBO_UTIL_H__ */ + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/file-util.c b/glabels2/src/file-util.c new file mode 100644 index 00000000..684c7faa --- /dev/null +++ b/glabels2/src/file-util.c @@ -0,0 +1,101 @@ +/* + * file-util.c + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#include + +#include "file-util.h" + +#include + + +/****************************************************************************/ +/* Append ".glabels" extension to filename if needed. */ +/****************************************************************************/ +gchar * +gl_file_util_add_extension (const gchar *orig_filename) +{ + gchar *new_filename, *extension; + + extension = strrchr (orig_filename, '.'); + if (extension == NULL) { + new_filename = g_strconcat (orig_filename, ".glabels", NULL); + } else { + if (g_strcasecmp (extension, ".glabels") != 0) { + new_filename = + g_strconcat (orig_filename, ".glabels", NULL); + } else { + new_filename = g_strdup (orig_filename); + } + } + + return new_filename; +} + + +/****************************************************************************/ +/* Remove ".glabels" extension from filename if needed. */ +/****************************************************************************/ +gchar * +gl_file_util_remove_extension (const gchar *orig_filename) +{ + gchar *new_filename, *extension; + + new_filename = g_strdup (orig_filename); + + extension = strrchr (new_filename, '.'); + if (extension != NULL) { + if (g_strcasecmp (extension, ".glabels") == 0) { + *extension = 0; /* truncate string, rm extension */ + } + } + + return new_filename; +} + + +/****************************************************************************/ +/* Make sure we have an absolute path to filename. */ +/****************************************************************************/ +gchar * +gl_file_util_make_absolute (const gchar *filename) +{ + gchar *pwd, *absolute_filename; + + if (g_path_is_absolute (filename)) { + absolute_filename = g_strdup (filename); + } else { + pwd = g_get_current_dir (); + absolute_filename = g_build_filename (pwd, filename, NULL); + g_free (pwd); + } + + return absolute_filename; +} + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/file-util.h b/glabels2/src/file-util.h new file mode 100644 index 00000000..50c447c1 --- /dev/null +++ b/glabels2/src/file-util.h @@ -0,0 +1,46 @@ +/* + * file-util.h + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#ifndef __FILE_UTIL_H__ +#define __FILE_UTIL_H__ + +#include + +G_BEGIN_DECLS + +gchar *gl_file_util_add_extension (const gchar *orig_filename); +gchar *gl_file_util_remove_extension (const gchar *orig_filename); + +gchar *gl_file_util_make_absolute (const gchar *filename); + +G_END_DECLS + +#endif /* __FILE_UTIL_H__ */ + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/file.c b/glabels2/src/file.c index cef0481e..3f0c6336 100644 --- a/glabels2/src/file.c +++ b/glabels2/src/file.c @@ -28,7 +28,7 @@ #include "xml-label.h" #include "recent.h" -#include "util.h" +#include "file-util.h" #include "window.h" #include "new-label-dialog.h" #include "libglabels/libglabels.h" @@ -420,7 +420,7 @@ gl_file_open_real (const gchar *filename, gl_debug (DEBUG_FILE, "START"); - abs_filename = gl_util_make_absolute (filename); + abs_filename = gl_file_util_make_absolute (filename); label = gl_xml_label_open (abs_filename, &status); if (!label) { GtkWidget *dialog; @@ -651,7 +651,7 @@ save_as_response (GtkDialog *chooser, } else { - full_filename = gl_util_add_extension (raw_filename); + full_filename = gl_file_util_add_extension (raw_filename); filename = g_filename_to_utf8 (full_filename, -1, NULL, NULL, NULL); diff --git a/glabels2/src/glabels-batch.c b/glabels2/src/glabels-batch.c index 05e91fac..ac574326 100644 --- a/glabels2/src/glabels-batch.c +++ b/glabels2/src/glabels-batch.c @@ -29,7 +29,7 @@ #include "xml-label.h" #include "print.h" #include "print-op.h" -#include "util.h" +#include "file-util.h" #include "prefs.h" #include "debug.h" @@ -147,7 +147,7 @@ main (int argc, char **argv) (char *)p->data ); } } - abs_fn = gl_util_make_absolute ( output ); + abs_fn = gl_file_util_make_absolute ( output ); frame = (lglTemplateFrame *)label->template->frames->data; print_op = gl_print_op_new (label); diff --git a/glabels2/src/label.c b/glabels2/src/label.c index 4a6d9f3c..659c1107 100644 --- a/glabels2/src/label.c +++ b/glabels2/src/label.c @@ -25,7 +25,7 @@ #include #include "prefs.h" -#include "util.h" +#include "file-util.h" #include "marshal.h" #include "debug.h" @@ -551,7 +551,7 @@ gl_label_get_short_name (glLabel *label) gchar *temp_name, *short_name; temp_name = g_path_get_basename ( label->priv->filename ); - short_name = gl_util_remove_extension (temp_name); + short_name = gl_file_util_remove_extension (temp_name); g_free (temp_name); return short_name; diff --git a/glabels2/src/merge-properties-dialog.c b/glabels2/src/merge-properties-dialog.c index 909b9d27..c1c9c354 100644 --- a/glabels2/src/merge-properties-dialog.c +++ b/glabels2/src/merge-properties-dialog.c @@ -28,7 +28,8 @@ #include "label.h" #include "merge.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "hig.h" #include "debug.h" @@ -171,7 +172,7 @@ gl_merge_properties_dialog_init (glMergePropertiesDialog *dialog) return; } - gl_util_get_builder_widgets (builder, + gl_builder_util_get_widgets (builder, "merge_properties_vbox", &vbox, "type_combo", &dialog->priv->type_combo, "location_vbox", &dialog->priv->location_vbox, @@ -183,7 +184,7 @@ gl_merge_properties_dialog_init (glMergePropertiesDialog *dialog) gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), vbox); dialog->priv->builder = builder; - gl_util_combo_box_add_text_model (GTK_COMBO_BOX (dialog->priv->type_combo)); + gl_combo_util_add_text_model (GTK_COMBO_BOX (dialog->priv->type_combo)); gl_debug (DEBUG_MERGE, "END"); @@ -289,11 +290,11 @@ gl_merge_properties_dialog_construct (glMergePropertiesDialog *dialog, gl_debug (DEBUG_MERGE, " \"%s\"", p->data); } } - gl_util_combo_box_set_strings (GTK_COMBO_BOX (dialog->priv->type_combo), - texts); + gl_combo_util_set_strings (GTK_COMBO_BOX (dialog->priv->type_combo), + texts); gl_merge_free_descriptions (&texts); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (dialog->priv->type_combo), - description); + gl_combo_util_set_active_text (GTK_COMBO_BOX (dialog->priv->type_combo), + description); g_signal_connect (G_OBJECT (dialog->priv->type_combo), "changed", G_CALLBACK (type_changed_cb), dialog); diff --git a/glabels2/src/new-label-dialog.c b/glabels2/src/new-label-dialog.c index 8e850c74..015f0991 100644 --- a/glabels2/src/new-label-dialog.c +++ b/glabels2/src/new-label-dialog.c @@ -28,7 +28,6 @@ #include "hig.h" #include "wdgt-media-select.h" #include "rotate-label-button.h" -#include "util.h" #include "debug.h" diff --git a/glabels2/src/object-editor-bc-page.c b/glabels2/src/object-editor-bc-page.c index 017cc0b5..3d6f155b 100644 --- a/glabels2/src/object-editor-bc-page.c +++ b/glabels2/src/object-editor-bc-page.c @@ -29,7 +29,8 @@ #include "prefs.h" #include "color-combo.h" #include "color.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -70,7 +71,7 @@ gl_object_editor_prepare_bc_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "bc_page_vbox", &editor->priv->bc_page_vbox, "bc_style_combo", &editor->priv->bc_style_combo, "bc_text_check", &editor->priv->bc_text_check, @@ -94,13 +95,13 @@ gl_object_editor_prepare_bc_page (glObjectEditor *editor) editor->priv->bc_color_combo, FALSE, FALSE, 0); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_style_combo)); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_style_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->bc_key_combo)); /* Load barcode styles */ styles = gl_barcode_get_styles_list (); - gl_util_combo_box_set_strings (GTK_COMBO_BOX(editor->priv->bc_style_combo), - styles); + gl_combo_util_set_strings (GTK_COMBO_BOX(editor->priv->bc_style_combo), + styles); gl_barcode_free_styles_list (styles); /* Modify widgets */ @@ -232,8 +233,8 @@ gl_object_editor_set_bc_style (glObjectEditor *editor, style_string = gl_barcode_id_to_name (id); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo), - style_string); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_style_combo), + style_string); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->bc_text_check), text_flag); @@ -349,8 +350,8 @@ gl_object_editor_set_bc_color (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->bc_color_combo, FALSE); gtk_widget_set_sensitive (editor->priv->bc_key_combo, TRUE); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->bc_key_combo), - color_node->key); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->bc_key_combo), + color_node->key); } editor->priv->stop_signals = FALSE; diff --git a/glabels2/src/object-editor-data-page.c b/glabels2/src/object-editor-data-page.c index 0d6b1e3a..728a36d7 100644 --- a/glabels2/src/object-editor-data-page.c +++ b/glabels2/src/object-editor-data-page.c @@ -28,7 +28,8 @@ #include #include "prefs.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -66,7 +67,7 @@ gl_object_editor_prepare_data_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "data_page_vbox", &editor->priv->data_page_vbox, "data_literal_radio", &editor->priv->data_literal_radio, "data_key_radio", &editor->priv->data_key_radio, @@ -74,7 +75,7 @@ gl_object_editor_prepare_data_page (glObjectEditor *editor) "data_key_combo", &editor->priv->data_key_combo, NULL); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->data_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->data_key_combo)); /* Un-hide */ gtk_widget_show_all (editor->priv->data_page_vbox); @@ -187,8 +188,8 @@ gl_object_editor_set_data (glObjectEditor *editor, !editor->priv->data_format_fixed_flag); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->data_key_combo), - text_node->data); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->data_key_combo), + text_node->data); } diff --git a/glabels2/src/object-editor-edit-page.c b/glabels2/src/object-editor-edit-page.c index 2d91cb03..0e52015a 100644 --- a/glabels2/src/object-editor-edit-page.c +++ b/glabels2/src/object-editor-edit-page.c @@ -29,7 +29,7 @@ #include "prefs.h" #include "color.h" #include "wdgt-merge-menu.h" -#include "util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -69,7 +69,7 @@ gl_object_editor_prepare_edit_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "edit_page_vbox", &editor->priv->edit_page_vbox, "edit_text_view", &editor->priv->edit_text_view, "edit_insert_field_button", &editor->priv->edit_insert_field_button, diff --git a/glabels2/src/object-editor-fill-page.c b/glabels2/src/object-editor-fill-page.c index 5c9e3817..b1143d2c 100644 --- a/glabels2/src/object-editor-fill-page.c +++ b/glabels2/src/object-editor-fill-page.c @@ -29,7 +29,8 @@ #include "prefs.h" #include "color-combo.h" #include "color.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -67,7 +68,7 @@ gl_object_editor_prepare_fill_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "fill_page_vbox", &editor->priv->fill_page_vbox, "fill_color_hbox", &editor->priv->fill_color_hbox, "fill_key_combo", &editor->priv->fill_key_combo, @@ -82,7 +83,7 @@ gl_object_editor_prepare_fill_page (glObjectEditor *editor) editor->priv->fill_color_combo, FALSE, FALSE, 0); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->fill_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->fill_key_combo)); /* Modify widgets based on configuration */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->fill_color_radio), TRUE); @@ -152,8 +153,8 @@ gl_object_editor_set_fill_color (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->fill_color_combo, FALSE); gtk_widget_set_sensitive (editor->priv->fill_key_combo, TRUE); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->fill_key_combo), - color_node->key); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->fill_key_combo), + color_node->key); } editor->priv->stop_signals = FALSE; diff --git a/glabels2/src/object-editor-image-page.c b/glabels2/src/object-editor-image-page.c index 10a525c2..de649ab4 100644 --- a/glabels2/src/object-editor-image-page.c +++ b/glabels2/src/object-editor-image-page.c @@ -27,7 +27,8 @@ #include #include "prefs.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -74,7 +75,7 @@ gl_object_editor_prepare_image_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "img_page_vbox", &editor->priv->img_page_vbox, "img_file_radio", &editor->priv->img_file_radio, "img_key_radio", &editor->priv->img_key_radio, @@ -82,7 +83,7 @@ gl_object_editor_prepare_image_page (glObjectEditor *editor) "img_key_combo", &editor->priv->img_key_combo, NULL); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->img_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->img_key_combo)); /* Modify file button properties. */ add_image_filters_to_chooser (GTK_FILE_CHOOSER (editor->priv->img_file_button)); @@ -177,8 +178,8 @@ gl_object_editor_set_image (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->img_file_button, FALSE); gtk_widget_set_sensitive (editor->priv->img_key_combo, TRUE); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->img_key_combo), - text_node->data); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->img_key_combo), + text_node->data); } editor->priv->stop_signals = FALSE; diff --git a/glabels2/src/object-editor-line-page.c b/glabels2/src/object-editor-line-page.c index 48f3d3a4..a7c2f582 100644 --- a/glabels2/src/object-editor-line-page.c +++ b/glabels2/src/object-editor-line-page.c @@ -29,7 +29,8 @@ #include "prefs.h" #include "color-combo.h" #include "color.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -66,7 +67,7 @@ gl_object_editor_prepare_line_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "line_page_vbox", &editor->priv->line_page_vbox, "line_width_spin", &editor->priv->line_width_spin, "line_color_hbox", &editor->priv->line_color_hbox, @@ -82,7 +83,7 @@ gl_object_editor_prepare_line_page (glObjectEditor *editor) editor->priv->line_color_combo, FALSE, FALSE, 0); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->line_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->line_key_combo)); /* Modify widgets based on configuration */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->line_color_radio), TRUE); @@ -199,8 +200,8 @@ gl_object_editor_set_line_color (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->line_color_combo, FALSE); gtk_widget_set_sensitive (editor->priv->line_key_combo, TRUE); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->line_key_combo), - color_node->key); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->line_key_combo), + color_node->key); } editor->priv->stop_signals = FALSE; diff --git a/glabels2/src/object-editor-lsize-page.c b/glabels2/src/object-editor-lsize-page.c index 9be84131..a832f094 100644 --- a/glabels2/src/object-editor-lsize-page.c +++ b/glabels2/src/object-editor-lsize-page.c @@ -27,7 +27,7 @@ #include #include "prefs.h" -#include "util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -72,7 +72,7 @@ gl_object_editor_prepare_lsize_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "lsize_page_vbox", &editor->priv->lsize_page_vbox, "lsize_r_spin", &editor->priv->lsize_r_spin, "lsize_theta_spin", &editor->priv->lsize_theta_spin, diff --git a/glabels2/src/object-editor-position-page.c b/glabels2/src/object-editor-position-page.c index e80e23ce..6ea9a869 100644 --- a/glabels2/src/object-editor-position-page.c +++ b/glabels2/src/object-editor-position-page.c @@ -27,7 +27,7 @@ #include #include "prefs.h" -#include "util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -67,7 +67,7 @@ gl_object_editor_prepare_position_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "pos_page_vbox", &editor->priv->pos_page_vbox, "pos_x_spin", &editor->priv->pos_x_spin, "pos_y_spin", &editor->priv->pos_y_spin, diff --git a/glabels2/src/object-editor-shadow-page.c b/glabels2/src/object-editor-shadow-page.c index 79409132..4a3cc2e2 100644 --- a/glabels2/src/object-editor-shadow-page.c +++ b/glabels2/src/object-editor-shadow-page.c @@ -29,7 +29,8 @@ #include "prefs.h" #include "color-combo.h" #include "color.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -72,7 +73,7 @@ gl_object_editor_prepare_shadow_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "shadow_page_vbox", &editor->priv->shadow_page_vbox, "shadow_enable_check", &editor->priv->shadow_enable_check, "shadow_controls_table", &editor->priv->shadow_controls_table, @@ -93,7 +94,7 @@ gl_object_editor_prepare_shadow_page (glObjectEditor *editor) gtk_container_add (GTK_CONTAINER (editor->priv->shadow_color_hbox), editor->priv->shadow_color_combo); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->shadow_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->shadow_key_combo)); /* Get configuration information */ units_string = gl_prefs_get_units_string (); @@ -236,8 +237,8 @@ gl_object_editor_set_shadow_color (glObjectEditor *editor, gtk_widget_set_sensitive (editor->priv->shadow_color_combo, FALSE); gtk_widget_set_sensitive (editor->priv->shadow_key_combo, TRUE); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->shadow_key_combo), - color_node->key); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->shadow_key_combo), + color_node->key); } editor->priv->stop_signals = FALSE; diff --git a/glabels2/src/object-editor-size-page.c b/glabels2/src/object-editor-size-page.c index f652cbfd..c6821ea1 100644 --- a/glabels2/src/object-editor-size-page.c +++ b/glabels2/src/object-editor-size-page.c @@ -28,7 +28,7 @@ #include "prefs.h" #include "wdgt-chain-button.h" -#include "util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -74,7 +74,7 @@ gl_object_editor_prepare_size_page (glObjectEditor *editor, gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "size_page_vbox", &editor->priv->size_page_vbox, "size_w_spin", &editor->priv->size_w_spin, "size_h_spin", &editor->priv->size_h_spin, diff --git a/glabels2/src/object-editor-text-page.c b/glabels2/src/object-editor-text-page.c index d53d9b71..615668ea 100644 --- a/glabels2/src/object-editor-text-page.c +++ b/glabels2/src/object-editor-text-page.c @@ -31,7 +31,8 @@ #include "color.h" #include "font-combo.h" #include "font-util.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -71,7 +72,7 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) gl_debug (DEBUG_EDITOR, "START"); /* Extract widgets from XML tree. */ - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "text_page_vbox", &editor->priv->text_page_vbox, "text_family_hbox", &editor->priv->text_family_hbox, "text_size_spin", &editor->priv->text_size_spin, @@ -100,7 +101,7 @@ gl_object_editor_prepare_text_page (glObjectEditor *editor) editor->priv->text_color_combo, FALSE, FALSE, 0); - gl_util_combo_box_add_text_model ( GTK_COMBO_BOX(editor->priv->text_color_key_combo)); + gl_combo_util_add_text_model ( GTK_COMBO_BOX(editor->priv->text_color_key_combo)); /* Modify widgets */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_radio), TRUE); @@ -465,21 +466,20 @@ gl_object_editor_set_text_color (glObjectEditor *editor, } if (!text_color_node->field_flag) { + gl_debug (DEBUG_EDITOR, "color field false"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_radio), TRUE); gtk_widget_set_sensitive (editor->priv->text_color_combo, TRUE); - gl_debug (DEBUG_EDITOR, "color field false 0"); gtk_widget_set_sensitive (editor->priv->text_color_key_combo, FALSE); } else { + gl_debug (DEBUG_EDITOR, "color field true"); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->text_color_key_radio), TRUE); gtk_widget_set_sensitive (editor->priv->text_color_combo, FALSE); gtk_widget_set_sensitive (editor->priv->text_color_key_combo, TRUE); - gl_debug (DEBUG_EDITOR, "color field true 1"); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (editor->priv->text_color_key_combo), ""); - gl_debug (DEBUG_EDITOR, "color field true 2"); + gl_combo_util_set_active_text (GTK_COMBO_BOX (editor->priv->text_color_key_combo), ""); } editor->priv->stop_signals = FALSE; diff --git a/glabels2/src/object-editor.c b/glabels2/src/object-editor.c index 49b5e42f..3edf5815 100644 --- a/glabels2/src/object-editor.c +++ b/glabels2/src/object-editor.c @@ -32,7 +32,8 @@ #include "wdgt-chain-button.h" #include "wdgt-merge-menu.h" #include "marshal.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "object-editor-private.h" @@ -141,7 +142,7 @@ gl_object_editor_init (glObjectEditor *editor) return; } - gl_util_get_builder_widgets (editor->priv->builder, + gl_builder_util_get_widgets (editor->priv->builder, "editor_vbox", &editor->priv->editor_vbox, "title_image", &editor->priv->title_image, "title_label", &editor->priv->title_label, @@ -525,7 +526,7 @@ gl_object_editor_set_key_names (glObjectEditor *editor, combo = editor->priv->img_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } menu = editor->priv->edit_insert_field_menu; @@ -535,32 +536,32 @@ gl_object_editor_set_key_names (glObjectEditor *editor, combo = editor->priv->data_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } combo = editor->priv->fill_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } combo = editor->priv->text_color_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } combo = editor->priv->line_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } combo = editor->priv->bc_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } combo = editor->priv->shadow_key_combo; if (combo) { - gl_util_combo_box_set_strings (GTK_COMBO_BOX (combo), keys); + gl_combo_util_set_strings (GTK_COMBO_BOX (combo), keys); } gl_merge_free_key_list (&keys); diff --git a/glabels2/src/prefs-dialog.c b/glabels2/src/prefs-dialog.c index 97c0546b..c2d44e1c 100644 --- a/glabels2/src/prefs-dialog.c +++ b/glabels2/src/prefs-dialog.c @@ -31,7 +31,7 @@ #include "color.h" #include "font-combo.h" #include "font-util.h" -#include "util.h" +#include "builder-util.h" #include "debug.h" @@ -235,7 +235,7 @@ gl_prefs_dialog_construct (glPrefsDialog *dialog) g_return_if_fail (GL_IS_PREFS_DIALOG (dialog)); g_return_if_fail (dialog->priv != NULL); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "prefs_notebook", ¬ebook, NULL); gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, FALSE, FALSE, 0); @@ -285,7 +285,7 @@ static void construct_locale_page (glPrefsDialog *dialog) { - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "units_points_radio", &dialog->priv->units_points_radio, "units_inches_radio", &dialog->priv->units_inches_radio, "units_mm_radio", &dialog->priv->units_mm_radio, @@ -317,7 +317,7 @@ construct_locale_page (glPrefsDialog *dialog) static void construct_object_page (glPrefsDialog *dialog) { - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "text_family_hbox", &dialog->priv->text_family_hbox, "text_size_spin", &dialog->priv->text_size_spin, "text_bold_toggle", &dialog->priv->text_bold_toggle, diff --git a/glabels2/src/prefs-model.c b/glabels2/src/prefs-model.c index a2748247..1ec1c0bd 100644 --- a/glabels2/src/prefs-model.c +++ b/glabels2/src/prefs-model.c @@ -28,7 +28,7 @@ #include #include "marshal.h" -#include "util.h" +#include "str-util.h" #include "color.h" #include "debug.h" @@ -81,9 +81,9 @@ #define DEFAULT_FONT_FAMILY "Sans" #define DEFAULT_FONT_SIZE 14.0 -#define DEFAULT_FONT_WEIGHT_STRING gl_util_weight_to_string (PANGO_WEIGHT_NORMAL) +#define DEFAULT_FONT_WEIGHT_STRING gl_str_util_weight_to_string (PANGO_WEIGHT_NORMAL) #define DEFAULT_FONT_ITALIC_FLAG FALSE -#define DEFAULT_TEXT_ALIGN_STRING gl_util_align_to_string (PANGO_ALIGN_LEFT) +#define DEFAULT_TEXT_ALIGN_STRING gl_str_util_align_to_string (PANGO_ALIGN_LEFT) #define DEFAULT_TEXT_COLOR GL_COLOR (0,0,0) #define DEFAULT_TEXT_LINE_SPACING 1.0 @@ -273,7 +273,7 @@ gl_prefs_model_save_settings (glPrefsModel *prefs_model) gconf_client_set_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_FONT_WEIGHT, - gl_util_weight_to_string(prefs_model->default_font_weight), + gl_str_util_weight_to_string(prefs_model->default_font_weight), NULL); gconf_client_set_int (prefs_model->gconf_client, @@ -283,7 +283,7 @@ gl_prefs_model_save_settings (glPrefsModel *prefs_model) gconf_client_set_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT, - gl_util_align_to_string(prefs_model->default_text_alignment), + gl_str_util_align_to_string(prefs_model->default_text_alignment), NULL); gconf_client_set_float (prefs_model->gconf_client, @@ -430,7 +430,7 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) get_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_FONT_WEIGHT, DEFAULT_FONT_WEIGHT_STRING); - prefs_model->default_font_weight = gl_util_string_to_weight( string ); + prefs_model->default_font_weight = gl_str_util_string_to_weight( string ); g_free( string ); prefs_model->default_text_color = @@ -442,7 +442,7 @@ gl_prefs_model_load_settings (glPrefsModel *prefs_model) get_string (prefs_model->gconf_client, BASE_KEY PREF_DEFAULT_TEXT_ALIGNMENT, DEFAULT_TEXT_ALIGN_STRING); - prefs_model->default_text_alignment = gl_util_string_to_align( string ); + prefs_model->default_text_alignment = gl_str_util_string_to_align( string ); g_free( string ); prefs_model->default_text_line_spacing = diff --git a/glabels2/src/print-op-dialog.c b/glabels2/src/print-op-dialog.c index b1889b1c..bae96d5c 100644 --- a/glabels2/src/print-op-dialog.c +++ b/glabels2/src/print-op-dialog.c @@ -30,7 +30,7 @@ #include "mini-preview.h" #include "label.h" -#include "util.h" +#include "builder-util.h" #include "pixmaps/collate.xpm" #include "pixmaps/nocollate.xpm" @@ -260,7 +260,7 @@ create_custom_widget_cb (GtkPrintOperation *operation, return NULL; } - gl_util_get_builder_widgets (builder, + gl_builder_util_get_widgets (builder, "print_custom_widget_hbox", &hbox, "simple_frame", &op->priv->simple_frame, "simple_sheets_radio", &op->priv->simple_sheets_radio, diff --git a/glabels2/src/str-util.c b/glabels2/src/str-util.c new file mode 100644 index 00000000..d48ec007 --- /dev/null +++ b/glabels2/src/str-util.c @@ -0,0 +1,142 @@ +/* + * str-util.c + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#include + +#include "str-util.h" + +#include +#include + +#define FRAC_EPSILON 0.00005 + + +/****************************************************************************/ +/* Create fractional representation of number, if possible. */ +/****************************************************************************/ +gchar * +gl_str_util_fraction_to_string (gdouble x) +{ + static gdouble denom[] = { 1., 2., 3., 4., 8., 16., 32., 0. }; + gint i; + gdouble product, remainder; + gint n, d; + + for ( i=0; denom[i] != 0.0; i++ ) { + product = x * denom[i]; + remainder = fabs(product - ((gint)(product+0.5))); + if ( remainder < FRAC_EPSILON ) break; + } + + if ( denom[i] == 0.0 ) { + /* None of our denominators work. */ + return g_strdup_printf ("%.5g", x); + } + if ( denom[i] == 1.0 ) { + /* Simple integer. */ + return g_strdup_printf ("%d", (gint)x); + } + n = (gint)( x * denom[i] + 0.5 ); + d = (gint)denom[i]; + if ( n > d ) { + return g_strdup_printf ("%d_%d/%d", (n/d), (n%d), d); + } else { + return g_strdup_printf ("%d/%d", (n%d), d); + } +} + + +/****************************************************************************/ +/* Utilities to deal with PangoAlignment types. */ +/****************************************************************************/ +const gchar * +gl_str_util_align_to_string (PangoAlignment align) +{ + switch (align) { + case PANGO_ALIGN_LEFT: + return "Left"; + case PANGO_ALIGN_CENTER: + return "Center"; + case PANGO_ALIGN_RIGHT: + return "Right"; + default: + return "?"; + } +} + + +PangoAlignment +gl_str_util_string_to_align (const gchar *string) +{ + + if (g_strcasecmp (string, "Left") == 0) { + return PANGO_ALIGN_LEFT; + } else if (g_strcasecmp (string, "Center") == 0) { + return PANGO_ALIGN_CENTER; + } else if (g_strcasecmp (string, "Right") == 0) { + return PANGO_ALIGN_RIGHT; + } else { + return PANGO_ALIGN_LEFT; + } + +} + + +/****************************************************************************/ +/* Utilities to deal with PangoWeight types */ +/****************************************************************************/ +const gchar * +gl_str_util_weight_to_string (PangoWeight weight) +{ + switch (weight) { + case PANGO_WEIGHT_NORMAL: + return "Regular"; + case PANGO_WEIGHT_BOLD: + return "Bold"; + default: + return "?"; + } +} + + +PangoWeight +gl_str_util_string_to_weight (const gchar *string) +{ + + if (g_strcasecmp (string, "Regular") == 0) { + return PANGO_WEIGHT_NORMAL; + } else if (g_strcasecmp (string, "Bold") == 0) { + return PANGO_WEIGHT_BOLD; + } else { + return PANGO_WEIGHT_NORMAL; + } + +} + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/str-util.h b/glabels2/src/str-util.h new file mode 100644 index 00000000..0253392b --- /dev/null +++ b/glabels2/src/str-util.h @@ -0,0 +1,50 @@ +/* + * str-util.h + * Copyright (C) 2001-2009 Jim Evins . + * + * This file is part of gLabels. + * + * gLabels is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * gLabels is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with gLabels. If not, see . + */ + +#ifndef __STR_UTIL_H__ +#define __STR_UTIL_H__ + +#include +#include + +G_BEGIN_DECLS + +gchar *gl_str_util_fraction_to_string (gdouble x); + +const gchar *gl_str_util_align_to_string (PangoAlignment align); +PangoAlignment gl_str_util_string_to_align (const gchar *string); + +const gchar *gl_str_util_weight_to_string (PangoWeight weight); +PangoWeight gl_str_util_string_to_weight (const gchar *string); + +G_END_DECLS + +#endif /* __STR_UTIL_H__ */ + + + +/* + * Local Variables: -- emacs + * mode: C -- emacs + * c-basic-offset: 8 -- emacs + * tab-width: 8 -- emacs + * indent-tabs-mode: nil -- emacs + * End: -- emacs + */ diff --git a/glabels2/src/template-designer.c b/glabels2/src/template-designer.c index 5f5ced8b..d5d6453f 100644 --- a/glabels2/src/template-designer.c +++ b/glabels2/src/template-designer.c @@ -32,7 +32,8 @@ #include "mini-preview.h" #include "mini-preview-pixbuf-cache.h" #include "print-op-dialog.h" -#include "util.h" +#include "combo-util.h" +#include "builder-util.h" #include "debug.h" @@ -443,7 +444,7 @@ construct_start_page (glTemplateDesigner *dialog, { gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "start_page", &dialog->priv->start_page, NULL); @@ -476,7 +477,7 @@ construct_name_page (glTemplateDesigner *dialog, { gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "name_page", &dialog->priv->name_page, "brand_entry", &dialog->priv->brand_entry, "part_num_entry", &dialog->priv->part_num_entry, @@ -522,7 +523,7 @@ construct_pg_size_page (glTemplateDesigner *dialog, gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "pg_size_page", &dialog->priv->pg_size_page, "pg_size_combo", &dialog->priv->pg_size_combo, "pg_w_spin", &dialog->priv->pg_w_spin, @@ -532,7 +533,7 @@ construct_pg_size_page (glTemplateDesigner *dialog, NULL); - gl_util_combo_box_add_text_model (GTK_COMBO_BOX (dialog->priv->pg_size_combo)); + gl_combo_util_add_text_model (GTK_COMBO_BOX (dialog->priv->pg_size_combo)); gtk_assistant_append_page (GTK_ASSISTANT (dialog), dialog->priv->pg_size_page); @@ -549,11 +550,11 @@ construct_pg_size_page (glTemplateDesigner *dialog, /* Load page size combo */ page_sizes = lgl_db_get_paper_name_list (); - gl_util_combo_box_set_strings (GTK_COMBO_BOX (dialog->priv->pg_size_combo), page_sizes); + gl_combo_util_set_strings (GTK_COMBO_BOX (dialog->priv->pg_size_combo), page_sizes); lgl_db_free_paper_name_list (page_sizes); default_page_size_id = gl_prefs_get_page_size (); default_page_size_name = lgl_db_lookup_paper_name_from_id (default_page_size_id); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (dialog->priv->pg_size_combo), default_page_size_name); + gl_combo_util_set_active_text (GTK_COMBO_BOX (dialog->priv->pg_size_combo), default_page_size_name); g_free (default_page_size_name); /* Apply units to spinbuttons and units labels. */ @@ -592,7 +593,7 @@ construct_shape_page (glTemplateDesigner *dialog, { gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "shape_page", &dialog->priv->shape_page, "shape_rect_radio", &dialog->priv->shape_rect_radio, "shape_round_radio", &dialog->priv->shape_round_radio, @@ -628,7 +629,7 @@ construct_rect_size_page (glTemplateDesigner *dialog, gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "rect_size_page", &dialog->priv->rect_size_page, "rect_image", &dialog->priv->rect_image, "rect_w_spin", &dialog->priv->rect_w_spin, @@ -730,7 +731,7 @@ construct_round_size_page (glTemplateDesigner *dialog, gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "round_size_page", &dialog->priv->round_size_page, "round_image", &dialog->priv->round_image, "round_r_spin", &dialog->priv->round_r_spin, @@ -802,7 +803,7 @@ construct_cd_size_page (glTemplateDesigner *dialog, gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "cd_size_page", &dialog->priv->cd_size_page, "cd_image", &dialog->priv->cd_image, "cd_radius_spin", &dialog->priv->cd_radius_spin, @@ -900,7 +901,7 @@ construct_nlayouts_page (glTemplateDesigner *dialog, gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "nlayouts_page", &dialog->priv->nlayouts_page, "nlayouts_image1", &dialog->priv->nlayouts_image1, "nlayouts_image2", &dialog->priv->nlayouts_image2, @@ -944,7 +945,7 @@ construct_layout_page (glTemplateDesigner *dialog, { gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "layout_page", &dialog->priv->layout_page, "layout1_head_label", &dialog->priv->layout1_head_label, "layout1_nx_spin", &dialog->priv->layout1_nx_spin, @@ -1072,7 +1073,7 @@ construct_finish_page (glTemplateDesigner *dialog, { gl_debug (DEBUG_TEMPLATE, "START"); - gl_util_get_builder_widgets (dialog->priv->builder, + gl_builder_util_get_widgets (dialog->priv->builder, "finish_page", &dialog->priv->finish_page, NULL); diff --git a/glabels2/src/ui-property-bar.c b/glabels2/src/ui-property-bar.c index cc15b352..30ae6cbf 100644 --- a/glabels2/src/ui-property-bar.c +++ b/glabels2/src/ui-property-bar.c @@ -26,7 +26,7 @@ #include #include -#include "util.h" +#include "builder-util.h" #include "font-combo.h" #include "color-combo-button.h" #include "stock-pixmaps/stockpixbufs.h" @@ -251,7 +251,7 @@ gl_ui_property_bar_construct (glUIPropertyBar *this) return; } - gl_util_get_builder_widgets (builder, + gl_builder_util_get_widgets (builder, "property_toolbar", &this->priv->tool_bar, "font_family_eventbox", &this->priv->font_family_eventbox, "font_size_spin", &this->priv->font_size_spin, diff --git a/glabels2/src/util.c b/glabels2/src/util.c deleted file mode 100644 index 4441f1c0..00000000 --- a/glabels2/src/util.c +++ /dev/null @@ -1,354 +0,0 @@ -/* - * util.c - * Copyright (C) 2001-2009 Jim Evins . - * - * This file is part of gLabels. - * - * gLabels is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * gLabels is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with gLabels. If not, see . - */ - -#include - -#include "util.h" - -#include -#include -#include -#include - -#include - -#define FRAC_EPSILON 0.00005 - - -/****************************************************************************/ -/* Append ".glabels" extension to filename if needed. */ -/****************************************************************************/ -gchar * -gl_util_add_extension (const gchar *orig_filename) -{ - gchar *new_filename, *extension; - - extension = strrchr (orig_filename, '.'); - if (extension == NULL) { - new_filename = g_strconcat (orig_filename, ".glabels", NULL); - } else { - if (g_strcasecmp (extension, ".glabels") != 0) { - new_filename = - g_strconcat (orig_filename, ".glabels", NULL); - } else { - new_filename = g_strdup (orig_filename); - } - } - - return new_filename; -} - - -/****************************************************************************/ -/* Remove ".glabels" extension from filename if needed. */ -/****************************************************************************/ -gchar * -gl_util_remove_extension (const gchar *orig_filename) -{ - gchar *new_filename, *extension; - - new_filename = g_strdup (orig_filename); - - extension = strrchr (new_filename, '.'); - if (extension != NULL) { - if (g_strcasecmp (extension, ".glabels") == 0) { - *extension = 0; /* truncate string, rm extension */ - } - } - - return new_filename; -} - - -/****************************************************************************/ -/* Make sure we have an absolute path to filename. */ -/****************************************************************************/ -gchar * -gl_util_make_absolute (const gchar *filename) -{ - gchar *pwd, *absolute_filename; - - if (g_path_is_absolute (filename)) { - absolute_filename = g_strdup (filename); - } else { - pwd = g_get_current_dir (); - absolute_filename = g_build_filename (pwd, filename, NULL); - g_free (pwd); - } - - return absolute_filename; -} - - -/****************************************************************************/ -/* Create fractional representation of number, if possible. */ -/****************************************************************************/ -gchar * -gl_util_fraction (gdouble x) -{ - static gdouble denom[] = { 1., 2., 3., 4., 8., 16., 32., 0. }; - gint i; - gdouble product, remainder; - gint n, d; - - for ( i=0; denom[i] != 0.0; i++ ) { - product = x * denom[i]; - remainder = fabs(product - ((gint)(product+0.5))); - if ( remainder < FRAC_EPSILON ) break; - } - - if ( denom[i] == 0.0 ) { - /* None of our denominators work. */ - return g_strdup_printf ("%.5g", x); - } - if ( denom[i] == 1.0 ) { - /* Simple integer. */ - return g_strdup_printf ("%d", (gint)x); - } - n = (gint)( x * denom[i] + 0.5 ); - d = (gint)denom[i]; - if ( n > d ) { - return g_strdup_printf ("%d_%d/%d", (n/d), (n%d), d); - } else { - return g_strdup_printf ("%d/%d", (n%d), d); - } -} - - -/****************************************************************************/ -/* Utilities to deal with PangoAlignment types. */ -/****************************************************************************/ -const gchar * -gl_util_align_to_string (PangoAlignment align) -{ - switch (align) { - case PANGO_ALIGN_LEFT: - return "Left"; - case PANGO_ALIGN_CENTER: - return "Center"; - case PANGO_ALIGN_RIGHT: - return "Right"; - default: - return "?"; - } -} - - -PangoAlignment -gl_util_string_to_align (const gchar *string) -{ - - if (g_strcasecmp (string, "Left") == 0) { - return PANGO_ALIGN_LEFT; - } else if (g_strcasecmp (string, "Center") == 0) { - return PANGO_ALIGN_CENTER; - } else if (g_strcasecmp (string, "Right") == 0) { - return PANGO_ALIGN_RIGHT; - } else { - return PANGO_ALIGN_LEFT; - } - -} - - -/****************************************************************************/ -/* Utilities to deal with PangoWeight types */ -/****************************************************************************/ -const gchar * -gl_util_weight_to_string (PangoWeight weight) -{ - switch (weight) { - case PANGO_WEIGHT_NORMAL: - return "Regular"; - case PANGO_WEIGHT_BOLD: - return "Bold"; - default: - return "?"; - } -} - - -PangoWeight -gl_util_string_to_weight (const gchar *string) -{ - - if (g_strcasecmp (string, "Regular") == 0) { - return PANGO_WEIGHT_NORMAL; - } else if (g_strcasecmp (string, "Bold") == 0) { - return PANGO_WEIGHT_BOLD; - } else { - return PANGO_WEIGHT_NORMAL; - } - -} - - -/****************************************************************************/ -/* Convienience function to set strings in a text combo_box from a GList */ -/****************************************************************************/ -void -gl_util_combo_box_set_strings (GtkComboBox *combo, - GList *list) -{ - GtkTreeModel *model; - GList *p; - - g_return_if_fail (list); - - model = gtk_combo_box_get_model(combo); - gtk_list_store_clear (GTK_LIST_STORE (model)); - - for (p=list; p!=NULL; p=p->next) { - if (p->data) { - gtk_combo_box_append_text (combo, p->data); - } - } -} - - -/*---------------------------------------------------------------------------*/ -/* PRIVATE. gl_util_combo_box_set_active_text support. */ -/*---------------------------------------------------------------------------*/ - -typedef struct { - const gchar *text; - GtkTreeIter iter; - gboolean found; -} TextSearchData; - -static gboolean -search_text_func (GtkTreeModel *model, - GtkTreePath *path, - GtkTreeIter *iter, - gpointer data) -{ - TextSearchData *search_data = (TextSearchData *)data; - gchar *text = NULL; - - gtk_tree_model_get (model, iter, 0, &text, -1); - - if (strcmp (text,search_data->text) == 0) { - search_data->found = TRUE; - search_data->iter = *iter; - } - - g_free (text); - - return FALSE; -} - - -/****************************************************************************/ -/* Convienience function to set active text in a text combo_box from text */ -/****************************************************************************/ -void -gl_util_combo_box_set_active_text (GtkComboBox *combo, - const gchar *text) -{ - GtkTreeModel *model = gtk_combo_box_get_model(combo); - - g_return_if_fail (GTK_IS_LIST_STORE (model)); - - if (!text) { - - gtk_combo_box_set_active (combo, -1); - - } else { - TextSearchData search_data; - - search_data.text = text; - search_data.found = FALSE; - - gtk_tree_model_foreach (model, search_text_func, &search_data); - if (search_data.found) { - gtk_combo_box_set_active_iter (combo, - &search_data.iter); - } else { - gtk_combo_box_set_active (combo, -1); - } - - } - -} - - -/****************************************************************************/ -/* Convienience function to add a simple text model to an existing */ -/* combo_box. This is needed since combo_boxes created with glade do not */ -/* use the gtk_combo_box_new_text() constructor. */ -/****************************************************************************/ -void -gl_util_combo_box_add_text_model (GtkComboBox *combo) -{ - GtkCellRenderer *cell; - GtkListStore *store; - - store = gtk_list_store_new (1, G_TYPE_STRING); - gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); - g_object_unref (store); - - cell = gtk_cell_renderer_text_new (); - gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), cell, TRUE); - gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo), cell, - "text", 0, - NULL); -} - - -/****************************************************************************/ -/* Get widgets from GtkBuilder "en masse." */ -/****************************************************************************/ -void gl_util_get_builder_widgets (GtkBuilder *builder, - gchar *first_name, - ...) -{ - va_list args; - gchar *name; - GtkWidget **p_widget; - - va_start (args, first_name); - - for ( name = first_name; name; name = va_arg (args, gchar *) ) - { - p_widget = va_arg (args, GtkWidget **); - - *p_widget = GTK_WIDGET (gtk_builder_get_object (builder, name)); - - if (!*p_widget) - { - g_critical ("Could not load widget \"%s\".\n\ngLabels may not be installed correctly!", - name); - break; - } - } - - va_end (args); -} - - - -/* - * Local Variables: -- emacs - * mode: C -- emacs - * c-basic-offset: 8 -- emacs - * tab-width: 8 -- emacs - * indent-tabs-mode: nil -- emacs - * End: -- emacs - */ diff --git a/glabels2/src/util.h b/glabels2/src/util.h deleted file mode 100644 index e3c4a15f..00000000 --- a/glabels2/src/util.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * util.h - * Copyright (C) 2001-2009 Jim Evins . - * - * This file is part of gLabels. - * - * gLabels is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * gLabels is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with gLabels. If not, see . - */ - -#ifndef __UTIL_H__ -#define __UTIL_H__ - -#include -#include -#include - -G_BEGIN_DECLS - -gchar *gl_util_add_extension (const gchar *orig_filename); -gchar *gl_util_remove_extension (const gchar *orig_filename); - -gchar *gl_util_make_absolute (const gchar *filename); - -gchar *gl_util_fraction (gdouble x); - -const gchar *gl_util_align_to_string (PangoAlignment align); -PangoAlignment gl_util_string_to_align (const gchar *string); - -const gchar *gl_util_weight_to_string (PangoWeight weight); -PangoWeight gl_util_string_to_weight (const gchar *string); - -void gl_util_combo_box_set_strings (GtkComboBox *combo, - GList *list); -void gl_util_combo_box_set_active_text (GtkComboBox *combo, - const gchar *text); -void gl_util_combo_box_add_text_model (GtkComboBox *combo); - -GdkPixbuf *gl_util_cairo_convert_to_pixbuf (cairo_surface_t *surface); - -void gl_util_get_builder_widgets (GtkBuilder *builder, - gchar *first_name, - ...); - -G_END_DECLS - -#endif /* __UTIL_H__ */ - - - -/* - * Local Variables: -- emacs - * mode: C -- emacs - * c-basic-offset: 8 -- emacs - * tab-width: 8 -- emacs - * indent-tabs-mode: nil -- emacs - * End: -- emacs - */ diff --git a/glabels2/src/wdgt-media-select.c b/glabels2/src/wdgt-media-select.c index 89102605..0ad67804 100644 --- a/glabels2/src/wdgt-media-select.c +++ b/glabels2/src/wdgt-media-select.c @@ -29,7 +29,9 @@ #include #include "mini-preview-pixbuf-cache.h" #include "prefs.h" -#include "util.h" +#include "str-util.h" +#include "combo-util.h" +#include "builder-util.h" #include "color.h" #include "marshal.h" @@ -234,7 +236,7 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) return; } - gl_util_get_builder_widgets (builder, + gl_builder_util_get_widgets (builder, "wdgt_media_select_hbox", &hbox, "notebook", &media_select->priv->notebook, @@ -283,30 +285,30 @@ gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select) page_size_name = lgl_db_lookup_paper_name_from_id (page_size_id); /* Brand selection control */ - gl_util_combo_box_add_text_model (GTK_COMBO_BOX (media_select->priv->brand_combo)); + gl_combo_util_add_text_model (GTK_COMBO_BOX (media_select->priv->brand_combo)); brands = lgl_db_get_brand_list (NULL, NULL); brands = g_list_prepend (brands, g_strdup (_("Any"))); - gl_util_combo_box_set_strings (GTK_COMBO_BOX (media_select->priv->brand_combo), brands); + gl_combo_util_set_strings (GTK_COMBO_BOX (media_select->priv->brand_combo), brands); lgl_db_free_brand_list (brands); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (media_select->priv->brand_combo), - _("Any")); + gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->brand_combo), + _("Any")); /* Page size selection control */ - gl_util_combo_box_add_text_model (GTK_COMBO_BOX (media_select->priv->page_size_combo)); + gl_combo_util_add_text_model (GTK_COMBO_BOX (media_select->priv->page_size_combo)); page_sizes = lgl_db_get_paper_name_list (); page_sizes = g_list_prepend (page_sizes, g_strdup (_("Any"))); - gl_util_combo_box_set_strings (GTK_COMBO_BOX (media_select->priv->page_size_combo), page_sizes); + gl_combo_util_set_strings (GTK_COMBO_BOX (media_select->priv->page_size_combo), page_sizes); lgl_db_free_paper_name_list (page_sizes); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo), - page_size_name); + gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo), + page_size_name); /* Category selection control */ - gl_util_combo_box_add_text_model (GTK_COMBO_BOX (media_select->priv->category_combo)); + gl_combo_util_add_text_model (GTK_COMBO_BOX (media_select->priv->category_combo)); categories = lgl_db_get_category_name_list (); categories = g_list_prepend (categories, g_strdup (_("Any"))); - gl_util_combo_box_set_strings (GTK_COMBO_BOX (media_select->priv->category_combo), categories); - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (media_select->priv->category_combo), - _("Any")); + gl_combo_util_set_strings (GTK_COMBO_BOX (media_select->priv->category_combo), categories); + gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->category_combo), + _("Any")); lgl_db_free_category_name_list (categories); /* Search all treeview */ @@ -616,8 +618,8 @@ gl_wdgt_media_select_set_filter_parameters (glWdgtMediaSelect *media_select, page_size_name = g_strdup (_("Any")); } - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo), - page_size_name); + gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo), + page_size_name); category_name = lgl_db_lookup_category_name_from_id (category_id); if (category_name == NULL) @@ -625,8 +627,8 @@ gl_wdgt_media_select_set_filter_parameters (glWdgtMediaSelect *media_select, category_name = g_strdup (_("Any")); } - gl_util_combo_box_set_active_text (GTK_COMBO_BOX (media_select->priv->category_combo), - category_name); + gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->category_combo), + category_name); g_free (page_size_name); g_free (category_name); @@ -677,8 +679,8 @@ get_label_size_desc (const lglTemplate *template) if ( units == LGL_UNITS_INCH ) { gchar *xstr, *ystr; - xstr = gl_util_fraction (frame->rect.w*units_per_point); - ystr = gl_util_fraction (frame->rect.h*units_per_point); + xstr = gl_str_util_fraction_to_string (frame->rect.w*units_per_point); + ystr = gl_str_util_fraction_to_string (frame->rect.h*units_per_point); string = g_strdup_printf (_("%s x %s %s"), xstr, ystr, units_string); g_free (xstr); @@ -694,7 +696,7 @@ get_label_size_desc (const lglTemplate *template) if ( units == LGL_UNITS_INCH ) { gchar *dstr; - dstr = gl_util_fraction (2.0*frame->round.r*units_per_point); + dstr = gl_str_util_fraction_to_string (2.0*frame->round.r*units_per_point); string = g_strdup_printf (_("%s %s diameter"), dstr, units_string); g_free (dstr); @@ -708,7 +710,7 @@ get_label_size_desc (const lglTemplate *template) if ( units == LGL_UNITS_INCH ) { gchar *dstr; - dstr = gl_util_fraction (2.0*frame->cd.r1*units_per_point); + dstr = gl_str_util_fraction_to_string (2.0*frame->cd.r1*units_per_point); string = g_strdup_printf (_("%s %s diameter"), dstr, units_string); g_free (dstr); diff --git a/glabels2/src/window.c b/glabels2/src/window.c index a44c2fe4..0960d32e 100644 --- a/glabels2/src/window.c +++ b/glabels2/src/window.c @@ -27,7 +27,7 @@ #include "ui.h" #include "ui-commands.h" -#include "util.h" +#include "file-util.h" #include "xml-label.h" #include "prefs.h" #include "file.h" @@ -300,7 +300,7 @@ gl_window_new_from_file (const gchar *filename) window = GL_WINDOW (gl_window_new ()); - abs_filename = gl_util_make_absolute (filename); + abs_filename = gl_file_util_make_absolute (filename); label = gl_xml_label_open (abs_filename, &status); g_free (abs_filename); diff --git a/glabels2/src/xml-label-04.c b/glabels2/src/xml-label-04.c index 03e9f922..7fe639d1 100644 --- a/glabels2/src/xml-label-04.c +++ b/glabels2/src/xml-label-04.c @@ -31,7 +31,7 @@ #include "label-ellipse.h" #include "label-image.h" #include "label-barcode.h" -#include "util.h" +#include "str-util.h" #include "debug.h" @@ -211,12 +211,12 @@ xml04_parse_text_props (xmlNodePtr object_node, font_family = xmlGetProp (object_node, (xmlChar *)"font_family"); font_size = lgl_xml_get_prop_double (object_node, "font_size", 0); string = xmlGetProp (object_node, (xmlChar *)"font_weight"); - font_weight = gl_util_string_to_weight ((gchar *)string); + font_weight = gl_str_util_string_to_weight ((gchar *)string); xmlFree (string); font_italic_flag = lgl_xml_get_prop_boolean (object_node, "font_italic", FALSE); string = xmlGetProp (object_node, (xmlChar *)"justify"); - align = gl_util_string_to_align ((gchar *)string); + align = gl_str_util_string_to_align ((gchar *)string); xmlFree (string); color_node = gl_color_node_new_default (); diff --git a/glabels2/src/xml-label.c b/glabels2/src/xml-label.c index d1d53423..12aec421 100644 --- a/glabels2/src/xml-label.c +++ b/glabels2/src/xml-label.c @@ -39,7 +39,7 @@ #include "label-image.h" #include "label-barcode.h" #include "xml-label-04.h" -#include "util.h" +#include "str-util.h" #include "debug.h" @@ -441,7 +441,7 @@ xml_parse_object_text (xmlNodePtr node, /* justify attr */ string = lgl_xml_get_prop_string (node, "justify", NULL); - align = gl_util_string_to_align (string); + align = gl_str_util_string_to_align (string); g_free (string); gl_label_object_set_text_alignment (GL_LABEL_OBJECT(object), align); @@ -929,7 +929,7 @@ xml_parse_toplevel_span (xmlNodePtr node, /* Font weight attr */ string = lgl_xml_get_prop_string (node, "font_weight", NULL); - font_weight = gl_util_string_to_weight (string); + font_weight = gl_str_util_string_to_weight (string); g_free (string); gl_label_object_set_font_weight (object, font_weight); @@ -1253,7 +1253,7 @@ xml_create_object_text (xmlNodePtr root, /* justify attr */ align = gl_label_object_get_text_alignment (object); - lgl_xml_set_prop_string (node, "justify", gl_util_align_to_string (align)); + lgl_xml_set_prop_string (node, "justify", gl_str_util_align_to_string (align)); /* auto_shrink attr */ auto_shrink = gl_label_text_get_auto_shrink (GL_LABEL_TEXT (object)); @@ -1728,7 +1728,7 @@ xml_create_toplevel_span (xmlNodePtr root, align = gl_label_object_get_text_alignment (GL_LABEL_OBJECT(object_text)); lgl_xml_set_prop_string (node, "font_family", font_family); lgl_xml_set_prop_double (node, "font_size", font_size); - lgl_xml_set_prop_string (node, "font_weight", gl_util_weight_to_string (font_weight)); + lgl_xml_set_prop_string (node, "font_weight", gl_str_util_weight_to_string (font_weight)); lgl_xml_set_prop_boolean (node, "font_italic", font_italic_flag); lgl_xml_set_prop_double (node, "line_spacing", text_line_spacing); -- 2.39.5