+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:
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
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
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
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
ui-sidebar.c \
file.h \
file.c \
+ file-util.h \
+ file-util.c \
new-label-dialog.h \
new-label-dialog.c \
recent.h \
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 \
glabels_batch_SOURCES = \
glabels-batch.c \
+ file-util.h \
+ file-util.c \
print.c \
print.h \
print-op.c \
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 \
--- /dev/null
+/*
+ * 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
+ */
--- /dev/null
+/*
+ * 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
+ */
--- /dev/null
+/*
+ * 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
+ */
--- /dev/null
+/*
+ * 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
+ */
--- /dev/null
+/*
+ * 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
+ */
--- /dev/null
+/*
+ * 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
+ */
#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"
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;
} 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);
#include "xml-label.h"
#include "print.h"
#include "print-op.h"
-#include "util.h"
+#include "file-util.h"
#include "prefs.h"
#include "debug.h"
(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);
#include <glib/gi18n.h>
#include "prefs.h"
-#include "util.h"
+#include "file-util.h"
#include "marshal.h"
#include "debug.h"
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;
#include "label.h"
#include "merge.h"
-#include "util.h"
+#include "combo-util.h"
+#include "builder-util.h"
#include "hig.h"
#include "debug.h"
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,
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");
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);
#include "hig.h"
#include "wdgt-media-select.h"
#include "rotate-label-button.h"
-#include "util.h"
#include "debug.h"
#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"
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,
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 */
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);
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;
#include <math.h>
#include "prefs.h"
-#include "util.h"
+#include "combo-util.h"
+#include "builder-util.h"
#include "object-editor-private.h"
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,
"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);
!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);
}
#include "prefs.h"
#include "color.h"
#include "wdgt-merge-menu.h"
-#include "util.h"
+#include "builder-util.h"
#include "object-editor-private.h"
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,
#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"
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,
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);
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;
#include <math.h>
#include "prefs.h"
-#include "util.h"
+#include "combo-util.h"
+#include "builder-util.h"
#include "object-editor-private.h"
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,
"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));
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;
#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"
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,
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);
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;
#include <math.h>
#include "prefs.h"
-#include "util.h"
+#include "builder-util.h"
#include "object-editor-private.h"
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,
#include <math.h>
#include "prefs.h"
-#include "util.h"
+#include "builder-util.h"
#include "object-editor-private.h"
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,
#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"
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,
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 ();
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;
#include "prefs.h"
#include "wdgt-chain-button.h"
-#include "util.h"
+#include "builder-util.h"
#include "object-editor-private.h"
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,
#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"
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,
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);
}
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;
#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"
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,
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;
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);
#include "color.h"
#include "font-combo.h"
#include "font-util.h"
-#include "util.h"
+#include "builder-util.h"
#include "debug.h"
g_return_if_fail (GL_IS_PREFS_DIALOG (dialog));
g_return_if_fail (dialog->priv != NULL);
- gl_util_get_builder_widgets (dialog->priv->builder,
+ gl_builder_util_get_widgets (dialog->priv->builder,
"prefs_notebook", ¬ebook,
NULL);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), notebook, FALSE, FALSE, 0);
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,
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,
#include <libglabels/libglabels.h>
#include "marshal.h"
-#include "util.h"
+#include "str-util.h"
#include "color.h"
#include "debug.h"
#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
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,
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,
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 =
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 =
#include "mini-preview.h"
#include "label.h"
-#include "util.h"
+#include "builder-util.h"
#include "pixmaps/collate.xpm"
#include "pixmaps/nocollate.xpm"
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,
--- /dev/null
+/*
+ * 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
+ */
--- /dev/null
+/*
+ * 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
+ */
#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"
{
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);
{
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,
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,
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);
/* 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. */
{
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,
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,
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,
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,
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,
{
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,
{
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);
#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"
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,
+++ /dev/null
-/*
- * 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
- */
+++ /dev/null
-/*
- * 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
- */
#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"
return;
}
- gl_util_get_builder_widgets (builder,
+ gl_builder_util_get_widgets (builder,
"wdgt_media_select_hbox", &hbox,
"notebook", &media_select->priv->notebook,
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 */
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)
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);
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);
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);
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);
#include "ui.h"
#include "ui-commands.h"
-#include "util.h"
+#include "file-util.h"
#include "xml-label.h"
#include "prefs.h"
#include "file.h"
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);
#include "label-ellipse.h"
#include "label-image.h"
#include "label-barcode.h"
-#include "util.h"
+#include "str-util.h"
#include "debug.h"
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 ();
#include "label-image.h"
#include "label-barcode.h"
#include "xml-label-04.h"
-#include "util.h"
+#include "str-util.h"
#include "debug.h"
/* 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);
/* 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);
/* 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));
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);