-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
-
/*
- * (GLABELS) Label and Business Card Creation program for GNOME
- *
- * wdgt_media_select.c: media selection widget module
+ * wdgt-media-select.c
+ * Copyright (C) 2001-2009 Jim Evins <evins@snaught.com>.
*
- * Copyright (C) 2001-2006 Jim Evins <evins@snaught.com>.
+ * This file is part of gLabels.
*
- * This program is free software; you can redistribute it and/or modify
+ * 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 2 of the License, or
+ * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
- * This program is distributed in the hope that it will be useful,
+ * 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 this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * along with gLabels. If not, see <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include "wdgt-media-select.h"
#include <glib/gi18n.h>
-#include <glade/glade-xml.h>
-#include <gtk/gtknotebook.h>
-#include <gtk/gtkcombobox.h>
-#include <gtk/gtktreeview.h>
-#include <gtk/gtktreeselection.h>
-#include <gtk/gtkliststore.h>
-#include <gtk/gtkcellrenderertext.h>
-#include <gtk/gtkcellrendererpixbuf.h>
-#include <gtk/gtkstock.h>
+#include <gtk/gtk.h>
#include <string.h>
+#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"
-#include <libglabels/db.h>
#include "debug.h"
+
/*===========================================*/
/* Private types */
/*===========================================*/
struct _glWdgtMediaSelectPrivate {
+ GtkBuilder *builder;
+
GtkWidget *notebook;
guint current_page_num;
typedef void (*glWdgtMediaSelectSignal) (GObject * object, gpointer data);
+
/*===========================================*/
/* Private globals */
/*===========================================*/
static gint wdgt_media_select_signals[LAST_SIGNAL] = { 0 };
+
/*===========================================*/
/* Local function prototypes */
/*===========================================*/
static void load_search_all_list (GtkListStore *store,
GtkTreeSelection *selection,
GList *list);
-\f
+
+
/****************************************************************************/
/* Boilerplate Object stuff. */
/****************************************************************************/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
static void
gl_wdgt_media_select_init (glWdgtMediaSelect *media_select)
{
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
static void
gl_wdgt_media_select_finalize (GObject *object)
{
g_return_if_fail (object != NULL);
g_return_if_fail (GL_IS_WDGT_MEDIA_SELECT (object));
+ if (media_select->priv->builder)
+ {
+ g_object_unref (media_select->priv->builder);
+ }
g_object_unref (media_select->priv->recent_store);
g_object_unref (media_select->priv->search_all_store);
g_free (media_select->priv);
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
GtkWidget *
gl_wdgt_media_select_new (void)
{
return GTK_WIDGET (media_select);
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Construct composite widget. */
/*--------------------------------------------------------------------------*/
static void
gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select)
{
- GladeXML *gui;
+ GtkBuilder *builder;
+ static gchar *object_ids[] = { "wdgt_media_select_hbox", NULL };
+ GError *error = NULL;
GtkWidget *hbox;
GList *brands = NULL;
GList *page_sizes = NULL;
g_return_if_fail (GL_IS_WDGT_MEDIA_SELECT (media_select));
g_return_if_fail (media_select->priv != NULL);
- gui = glade_xml_new (GLABELS_GLADE_DIR "wdgt-media-select.glade",
- "wdgt_media_select_hbox", NULL);
+ builder = gtk_builder_new ();
+ gtk_builder_add_objects_from_file (builder,
+ GLABELS_BUILDER_DIR "wdgt-media-select.builder",
+ object_ids,
+ &error);
+ if (error) {
+ g_critical ("%s\n\ngLabels may not be installed correctly!", error->message);
+ g_error_free (error);
+ return;
+ }
+
+ gl_builder_util_get_widgets (builder,
+ "wdgt_media_select_hbox", &hbox,
+ "notebook", &media_select->priv->notebook,
+
+ "recent_tab_vbox", &media_select->priv->recent_tab_vbox,
+
+ "recent_treeview", &media_select->priv->recent_treeview,
+ "search_all_tab_vbox", &media_select->priv->search_all_tab_vbox,
+ "brand_combo", &media_select->priv->brand_combo,
+ "page_size_combo", &media_select->priv->page_size_combo,
+ "category_combo", &media_select->priv->category_combo,
+ "search_all_treeview", &media_select->priv->search_all_treeview,
+ NULL);
- if (!gui) {
- g_critical ("Could not open wdgt-media-select.glade. gLabels may not be installed correctly!");
- return;
- }
-
- hbox = glade_xml_get_widget (gui, "wdgt_media_select_hbox");
gtk_container_add (GTK_CONTAINER (media_select), hbox);
-
- media_select->priv->notebook =
- glade_xml_get_widget (gui, "notebook");
-
- media_select->priv->recent_tab_vbox =
- glade_xml_get_widget (gui, "recent_tab_vbox");
- media_select->priv->recent_treeview =
- glade_xml_get_widget (gui, "recent_treeview");
-
- media_select->priv->search_all_tab_vbox =
- glade_xml_get_widget (gui, "search_all_tab_vbox");
- media_select->priv->brand_combo =
- glade_xml_get_widget (gui, "brand_combo");
- media_select->priv->page_size_combo =
- glade_xml_get_widget (gui, "page_size_combo");
- media_select->priv->category_combo =
- glade_xml_get_widget (gui, "category_combo");
- media_select->priv->search_all_treeview =
- glade_xml_get_widget (gui, "search_all_treeview");
-
- g_object_unref (gui);
+ media_select->priv->builder = builder;
media_select->priv->recent_page_num =
gtk_notebook_page_num (GTK_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 */
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. modify widget due to change in selection */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. modify widget due to change in selection */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. modify widget due to change in selection */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/****************************************************************************/
/* query selected label template name. */
/****************************************************************************/
return name;
}
+
/****************************************************************************/
/* set selected label template name. */
/****************************************************************************/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/****************************************************************************/
/* query current filter parameters. */
/****************************************************************************/
g_free (category_name);
}
+
/****************************************************************************/
/* set filter parameters. */
/****************************************************************************/
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);
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Get a description of the layout and number of labels. */
/*--------------------------------------------------------------------------*/
return string;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Get label size description. */
/*--------------------------------------------------------------------------*/
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);
return string;
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Load list store from template name list. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
/*--------------------------------------------------------------------------*/
/* PRIVATE. Load list store from template name list. */
/*--------------------------------------------------------------------------*/
gl_debug (DEBUG_MEDIA_SELECT, "END");
}
+
+
+/*
+ * Local Variables: -- emacs
+ * mode: C -- emacs
+ * c-basic-offset: 8 -- emacs
+ * tab-width: 8 -- emacs
+ * indent-tabs-mode: nil -- emacs
+ * End: -- emacs
+ */