]> git.sur5r.net Git - glabels/commitdiff
2009-09-22 Jim Evins <evins@snaught.com>
authorJim Evins <evins@snaught.com>
Wed, 23 Sep 2009 03:41:02 +0000 (03:41 +0000)
committerJim Evins <evins@snaught.com>
Wed, 23 Sep 2009 03:41:02 +0000 (03:41 +0000)
* 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

39 files changed:
glabels2/ChangeLog
glabels2/po/POTFILES.in
glabels2/src/Makefile.am
glabels2/src/builder-util.c [new file with mode: 0644]
glabels2/src/builder-util.h [new file with mode: 0644]
glabels2/src/combo-util.c [new file with mode: 0644]
glabels2/src/combo-util.h [new file with mode: 0644]
glabels2/src/file-util.c [new file with mode: 0644]
glabels2/src/file-util.h [new file with mode: 0644]
glabels2/src/file.c
glabels2/src/glabels-batch.c
glabels2/src/label.c
glabels2/src/merge-properties-dialog.c
glabels2/src/new-label-dialog.c
glabels2/src/object-editor-bc-page.c
glabels2/src/object-editor-data-page.c
glabels2/src/object-editor-edit-page.c
glabels2/src/object-editor-fill-page.c
glabels2/src/object-editor-image-page.c
glabels2/src/object-editor-line-page.c
glabels2/src/object-editor-lsize-page.c
glabels2/src/object-editor-position-page.c
glabels2/src/object-editor-shadow-page.c
glabels2/src/object-editor-size-page.c
glabels2/src/object-editor-text-page.c
glabels2/src/object-editor.c
glabels2/src/prefs-dialog.c
glabels2/src/prefs-model.c
glabels2/src/print-op-dialog.c
glabels2/src/str-util.c [new file with mode: 0644]
glabels2/src/str-util.h [new file with mode: 0644]
glabels2/src/template-designer.c
glabels2/src/ui-property-bar.c
glabels2/src/util.c [deleted file]
glabels2/src/util.h [deleted file]
glabels2/src/wdgt-media-select.c
glabels2/src/window.c
glabels2/src/xml-label-04.c
glabels2/src/xml-label.c

index 67458b4a2c3cd7d4fdd3a6e6e7bf2c2e59a0cf03..694c9692d0ca1b7733db014716284a273e1c1375 100644 (file)
@@ -1,3 +1,75 @@
+2009-09-22  Jim Evins  <evins@snaught.com>
+
+       * 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  <evins@snaught.com>
 
        * po/POTFILES.in:
index 0638c379529424cd5246623ba669892622fe0a31..e6f46d596a8f67283b567088b000363ff82fa920 100644 (file)
@@ -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
index fa5161b8b6b7bdd758eb37d3ba159da2819e3b51..a1c833cc109cdf0832a799f6dcdd28f929c33460 100644 (file)
@@ -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 (file)
index 0000000..e78c230
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ *  builder-util.c
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#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 (file)
index 0000000..c3e5549
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  builder-util.h
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __BUILDER_UTIL_H__
+#define __BUILDER_UTIL_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+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 (file)
index 0000000..0ca90f1
--- /dev/null
@@ -0,0 +1,148 @@
+/*
+ *  combo-util.c
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "combo-util.h"
+
+#include <libglabels/libglabels.h>
+
+
+/****************************************************************************/
+/* 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 (file)
index 0000000..2205b6f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  combo-util.h
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __COMBO_UTIL_H__
+#define __COMBO_UTIL_H__
+
+#include <glib.h>
+#include <gtk/gtk.h>
+
+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 (file)
index 0000000..684c7fa
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *  file-util.c
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "file-util.h"
+
+#include <string.h>
+
+
+/****************************************************************************/
+/* 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 (file)
index 0000000..50c447c
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ *  file-util.h
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __FILE_UTIL_H__
+#define __FILE_UTIL_H__
+
+#include <glib.h>
+
+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
+ */
index cef0481ec129f7df328f2d5c375d0a1df1f6c0a1..3f0c6336da801ccf69f3e43c17d33917e5b16796 100644 (file)
@@ -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);
index 05e91facfe9729048f9f3355b6fd39d2e7af24b1..ac574326670860309968e2428364d54cbeb62062 100644 (file)
@@ -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);
index 4a6d9f3c36d7f291de544951cb2ed3c625cd0792..659c1107b80affa7f88f6cbad7e3d4bca9d62784 100644 (file)
@@ -25,7 +25,7 @@
 #include <glib/gi18n.h>
 
 #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;
index 909b9d27aaa3aaa6fa198a59baf07c65e0e7e73e..c1c9c3549e87a7685024e25f9d14c91b6508d7ff 100644 (file)
@@ -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);
 
index 8e850c743278991dcdac39ed98c5a449aea127f1..015f099107ea59d8d48d45754bf691bfeab57c78 100644 (file)
@@ -28,7 +28,6 @@
 #include "hig.h"
 #include "wdgt-media-select.h"
 #include "rotate-label-button.h"
-#include "util.h"
 
 #include "debug.h"
 
index 017cc0b5210ced30a686e7a361d9229d919f55cf..3d6f155b23a6b10b2d044582a8893090cf99ece6 100644 (file)
@@ -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;
index 0d6b1e3ac88bd259cc6f72ee77265f92f71c0687..728a36d7aed7c19fcad644e2981ffa2a384bce55 100644 (file)
@@ -28,7 +28,8 @@
 #include <math.h>
 
 #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);
         }
                                                                                 
 
index 2d91cb03e18a10e9b36287fce97fc1915c8c7c0f..0e52015a6a75cfa6b8dc11e5e21644ca74f53a74 100644 (file)
@@ -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,
index 5c9e381792392daadc1cc157022869d7cea8372e..b1143d2c4fe97c3a351d3c099aa528ea572712e9 100644 (file)
@@ -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;
index 10a525c288ab7a3b7f3167f46c1e07dde692cd12..de649ab4e72230859032945ed950ba9f8aa0d49d 100644 (file)
@@ -27,7 +27,8 @@
 #include <math.h>
 
 #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;
index 48f3d3a4deb821647e2b3f977580220698198424..a7c2f582903d98b039409072e761cafe31030a0c 100644 (file)
@@ -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;
index 9be84131670bd7ac7f4635232f1b0b01048afcbb..a832f09423043fc7de6172ea5694316f0dcdf6cd 100644 (file)
@@ -27,7 +27,7 @@
 #include <math.h>
 
 #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,
index e80e23ceeb489ab847b8f22acb46c82ad8d1178a..6ea9a8693b96047acd8c1d4e86f1e360ef3aa5e4 100644 (file)
@@ -27,7 +27,7 @@
 #include <math.h>
 
 #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,
index 7940913236ab30d7bed129b91b5e3f10f1d1575f..4a3cc2e2417e669918590347b1eac58bd52275e8 100644 (file)
@@ -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;
index f652cbfde01c6d92039303cd9a3ee1a538183d70..c6821ea16dfa6520bb763de023122d9898a3e78c 100644 (file)
@@ -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,
index d53d9b7142ca5a621a4d3d5bba6ba18b3039dbaf..615668eaebfd4cd36c1bdbea852681057ab9aa83 100644 (file)
@@ -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;
index 49b5e42f1483f8899a3985e69cb5b8ba397e706f..3edf5815aaa81999f43d50db2b72be4a508f6bd2 100644 (file)
@@ -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);
index 97c0546bd4213d7af347feeedb0f24bdb72cd22e..c2d44e1cbd007986ce71267563b26c956e70e107 100644 (file)
@@ -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", &notebook,
                                      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,
index a274824788e1d88b08f1c375aa603135d8381f54..1ec1c0bdb457da32d5c24b0ed81a85740200d238 100644 (file)
@@ -28,7 +28,7 @@
 
 #include <libglabels/libglabels.h>
 #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 =
index b1889b1c231fdd6ed0754305e42b77b7986b4443..bae96d5c61e961e9d4ae78f802c2b6a9585f4a2b 100644 (file)
@@ -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 (file)
index 0000000..d48ec00
--- /dev/null
@@ -0,0 +1,142 @@
+/*
+ *  str-util.c
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <config.h>
+
+#include "str-util.h"
+
+#include <string.h>
+#include <math.h>
+
+#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 (file)
index 0000000..0253392
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ *  str-util.h
+ *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
+ *
+ *  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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __STR_UTIL_H__
+#define __STR_UTIL_H__
+
+#include <glib.h>
+#include <pango/pango.h>
+
+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
+ */
index 5f5ced8ba48f97a602c1d026d833f3f6792e09cd..d5d6453fad9a10cffca74ee9021addbf7556455e 100644 (file)
@@ -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);
 
index cc15b352d773edc3e5824f4e97575e772e4e5ca1..30ae6cbf08615228847934aba8702ab2690d8d96 100644 (file)
@@ -26,7 +26,7 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
-#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 (file)
index 4441f1c..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/*
- *  util.c
- *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
- *
- *  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 <http://www.gnu.org/licenses/>.
- */
-
-#include <config.h>
-
-#include "util.h"
-
-#include <string.h>
-#include <glib.h>
-#include <math.h>
-#include <gtk/gtk.h>
-
-#include <libglabels/libglabels.h>
-
-#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 (file)
index e3c4a15..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *  util.h
- *  Copyright (C) 2001-2009  Jim Evins <evins@snaught.com>.
- *
- *  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 <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __UTIL_H__
-#define __UTIL_H__
-
-#include <glib.h>
-#include <gtk/gtk.h>
-#include <pango/pango.h>
-
-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
- */
index 89102605002e75c3d662952386a096b8f71474cc..0ad67804513679f37daa009b098cafb6871015fc 100644 (file)
@@ -29,7 +29,9 @@
 #include <libglabels/libglabels.h>
 #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);
index a44c2fe45682d8f25aa25fba1407b07605ba1916..0960d32e5972534145a31320420bb0f237a1a9e9 100644 (file)
@@ -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);
 
index 03e9f922ecb659e643c94a6e6a57fbeed0a72d75..7fe639d1ff8ccdfb4d3f3603d98222459a6d54b6 100644 (file)
@@ -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 ();
index d1d53423d4dfd1850eba97375d4b7acf15a1b352..12aec42136e994c85246f80835e6b2ca766684bf 100644 (file)
@@ -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);