]> git.sur5r.net Git - glabels/commitdiff
Refactored MediaSelect code
authorJim Evins <evins@snaught.com>
Fri, 18 Dec 2009 04:21:33 +0000 (23:21 -0500)
committerJim Evins <evins@snaught.com>
Fri, 18 Dec 2009 04:29:27 +0000 (23:29 -0500)
- Renamed glWdgtMediaSelect to glMediaSelect
- Created new glMessageBar widget derived from GtkInfoBar -- API is modelled
  after GtkMessageDialog.  Used this new widget to provide notification
  of empty search results in the 2 glMediaSelect tabs.
- Simple code formatting changes.

12 files changed:
data/builder/Makefile.am
data/builder/media-select.builder [new file with mode: 0644]
data/builder/wdgt-media-select.builder [deleted file]
po/POTFILES.in
src/Makefile.am
src/media-select.c [new file with mode: 0644]
src/media-select.h [new file with mode: 0644]
src/message-bar.c [new file with mode: 0644]
src/message-bar.h [new file with mode: 0644]
src/new-label-dialog.c
src/wdgt-media-select.c [deleted file]
src/wdgt-media-select.h [deleted file]

index 9279a65b2c7e6faa1ae48f2372694adacb890a78..970e28f38614b7d13a0d8112c28a3339837c7bc5 100644 (file)
@@ -5,7 +5,7 @@ builderdir = $(datadir)/glabels/builder/
 builder_DATA = \
        property-bar.builder            \
        print-op-dialog-custom-widget.builder   \
-       wdgt-media-select.builder       \
+       media-select.builder            \
        merge-properties-dialog.builder \
        template-designer.builder       \
        prefs-dialog.builder            \
diff --git a/data/builder/media-select.builder b/data/builder/media-select.builder
new file mode 100644 (file)
index 0000000..707057a
--- /dev/null
@@ -0,0 +1,229 @@
+<?xml version="1.0"?>
+<interface>
+  <requires lib="gtk+" version="2.16"/>
+  <!-- interface-naming-policy toplevel-contextual -->
+  <object class="GtkWindow" id="window1">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">window1</property>
+    <child>
+      <object class="GtkHBox" id="media_select_hbox">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkNotebook" id="notebook">
+            <property name="visible">True</property>
+            <property name="border_width">12</property>
+            <child>
+              <object class="GtkVBox" id="recent_tab_vbox">
+                <property name="height_request">320</property>
+                <property name="visible">True</property>
+                <property name="border_width">6</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkVBox" id="recent_info_vbox">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow2">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="recent_treeview">
+                        <property name="visible">True</property>
+                        <property name="headers_visible">False</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+              </object>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="recent_tab_label">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Recent templates</property>
+              </object>
+              <packing>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkVBox" id="search_all_tab_vbox">
+                <property name="visible">True</property>
+                <property name="border_width">6</property>
+                <property name="orientation">vertical</property>
+                <child>
+                  <object class="GtkHBox" id="hbox6">
+                    <property name="visible">True</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkHBox" id="hbox9">
+                        <property name="visible">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label14">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Brand:</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkComboBox" id="brand_combo">
+                            <property name="visible">True</property>
+                            <property name="focus_on_click">False</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="fill">False</property>
+                        <property name="position">0</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hbox7">
+                        <property name="visible">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label12">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Page size:</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkComboBox" id="page_size_combo">
+                            <property name="visible">True</property>
+                            <property name="focus_on_click">False</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">1</property>
+                      </packing>
+                    </child>
+                    <child>
+                      <object class="GtkHBox" id="hbox8">
+                        <property name="visible">True</property>
+                        <property name="spacing">6</property>
+                        <child>
+                          <object class="GtkLabel" id="label13">
+                            <property name="visible">True</property>
+                            <property name="label" translatable="yes">Category:</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="fill">False</property>
+                            <property name="position">0</property>
+                          </packing>
+                        </child>
+                        <child>
+                          <object class="GtkComboBox" id="category_combo">
+                            <property name="visible">True</property>
+                            <property name="focus_on_click">False</property>
+                          </object>
+                          <packing>
+                            <property name="expand">False</property>
+                            <property name="position">1</property>
+                          </packing>
+                        </child>
+                      </object>
+                      <packing>
+                        <property name="expand">False</property>
+                        <property name="position">2</property>
+                      </packing>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="padding">6</property>
+                    <property name="position">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkVBox" id="search_all_info_vbox">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <child>
+                      <placeholder/>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="expand">False</property>
+                    <property name="fill">False</property>
+                    <property name="position">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkScrolledWindow" id="scrolledwindow1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hscrollbar_policy">automatic</property>
+                    <property name="vscrollbar_policy">automatic</property>
+                    <property name="shadow_type">in</property>
+                    <child>
+                      <object class="GtkTreeView" id="search_all_treeview">
+                        <property name="visible">True</property>
+                        <property name="headers_visible">False</property>
+                      </object>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="position">2</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">1</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="search_all_tabLlabel">
+                <property name="visible">True</property>
+                <property name="label" translatable="yes">Search all templates</property>
+              </object>
+              <packing>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
+          </object>
+          <packing>
+            <property name="position">0</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/data/builder/wdgt-media-select.builder b/data/builder/wdgt-media-select.builder
deleted file mode 100644 (file)
index 80ab2f1..0000000
+++ /dev/null
@@ -1,202 +0,0 @@
-<?xml version="1.0"?>
-<interface>
-  <requires lib="gtk+" version="2.16"/>
-  <!-- interface-naming-policy toplevel-contextual -->
-  <object class="GtkWindow" id="window1">
-    <property name="visible">True</property>
-    <property name="title" translatable="yes">window1</property>
-    <child>
-      <object class="GtkHBox" id="wdgt_media_select_hbox">
-        <property name="visible">True</property>
-        <child>
-          <object class="GtkNotebook" id="notebook">
-            <property name="visible">True</property>
-            <property name="border_width">12</property>
-            <child>
-              <object class="GtkVBox" id="recent_tab_vbox">
-                <property name="visible">True</property>
-                <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow2">
-                    <property name="width_request">480</property>
-                    <property name="height_request">320</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="border_width">12</property>
-                    <property name="hscrollbar_policy">automatic</property>
-                    <property name="vscrollbar_policy">automatic</property>
-                    <property name="shadow_type">in</property>
-                    <child>
-                      <object class="GtkTreeView" id="recent_treeview">
-                        <property name="visible">True</property>
-                        <property name="headers_visible">False</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-              </object>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="recent_tab_label">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Recent templates</property>
-              </object>
-              <packing>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkVBox" id="search_all_tab_vbox">
-                <property name="visible">True</property>
-                <child>
-                  <object class="GtkHBox" id="hbox6">
-                    <property name="visible">True</property>
-                    <property name="border_width">12</property>
-                    <property name="spacing">12</property>
-                    <child>
-                      <object class="GtkHBox" id="hbox9">
-                        <property name="visible">True</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkLabel" id="label14">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Brand:</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkComboBox" id="brand_combo">
-                            <property name="visible">True</property>
-                            <property name="focus_on_click">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="fill">False</property>
-                        <property name="position">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="hbox7">
-                        <property name="visible">True</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkLabel" id="label12">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Page size:</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkComboBox" id="page_size_combo">
-                            <property name="visible">True</property>
-                            <property name="focus_on_click">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkHBox" id="hbox8">
-                        <property name="visible">True</property>
-                        <property name="spacing">6</property>
-                        <child>
-                          <object class="GtkLabel" id="label13">
-                            <property name="visible">True</property>
-                            <property name="label" translatable="yes">Category:</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="fill">False</property>
-                            <property name="position">0</property>
-                          </packing>
-                        </child>
-                        <child>
-                          <object class="GtkComboBox" id="category_combo">
-                            <property name="visible">True</property>
-                            <property name="focus_on_click">False</property>
-                          </object>
-                          <packing>
-                            <property name="expand">False</property>
-                            <property name="position">1</property>
-                          </packing>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="expand">False</property>
-                        <property name="position">2</property>
-                      </packing>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="expand">False</property>
-                    <property name="position">0</property>
-                  </packing>
-                </child>
-                <child>
-                  <object class="GtkScrolledWindow" id="scrolledwindow1">
-                    <property name="width_request">480</property>
-                    <property name="height_request">320</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">True</property>
-                    <property name="border_width">12</property>
-                    <property name="hscrollbar_policy">automatic</property>
-                    <property name="vscrollbar_policy">automatic</property>
-                    <property name="shadow_type">in</property>
-                    <child>
-                      <object class="GtkTreeView" id="search_all_treeview">
-                        <property name="visible">True</property>
-                        <property name="headers_visible">False</property>
-                      </object>
-                    </child>
-                  </object>
-                  <packing>
-                    <property name="position">1</property>
-                  </packing>
-                </child>
-              </object>
-              <packing>
-                <property name="position">1</property>
-              </packing>
-            </child>
-            <child type="tab">
-              <object class="GtkLabel" id="search_all_tabLlabel">
-                <property name="visible">True</property>
-                <property name="label" translatable="yes">Search all templates</property>
-              </object>
-              <packing>
-                <property name="position">1</property>
-                <property name="tab_fill">False</property>
-              </packing>
-            </child>
-          </object>
-          <packing>
-            <property name="position">0</property>
-          </packing>
-        </child>
-      </object>
-    </child>
-  </object>
-</interface>
index 4f6bb28623dc429893a374286885a3c4dc309c1b..ba80596405ad7ac4d08561fb6eb41f729f635ed9 100644 (file)
@@ -81,6 +81,8 @@ src/label-text.c
 src/label-text.h
 #src/marshal.c
 #src/marshal.h
+src/media-select.c
+src/media-select.h
 src/merge.c
 src/merge.h
 src/merge-evolution.c
@@ -131,6 +133,8 @@ src/print-op.c
 src/print-op-dialog.c
 src/print-op-dialog.h
 src/print-op.h
+src/message-bar.c
+src/message-bar.h
 src/recent.c
 src/recent.h
 src/rotate-label-button.c
@@ -177,8 +181,6 @@ src/warning-handler.c
 src/warning-handler.h
 src/wdgt-chain-button.c
 src/wdgt-chain-button.h
-src/wdgt-media-select.c
-src/wdgt-media-select.h
 src/window.c
 src/window.h
 src/xml-label-04.c
index fe1c3378f71f5a54ca0b72484ea51e065090726c..401ae623e5de7efb5de49d9e47f9e92aacd4471d 100644 (file)
@@ -163,8 +163,10 @@ glabels_SOURCES =                  \
        mini-preview-pixbuf.h           \
        mini-preview-pixbuf-cache.c     \
        mini-preview-pixbuf-cache.h     \
-       wdgt-media-select.c             \
-       wdgt-media-select.h             \
+       media-select.c                  \
+       media-select.h                  \
+       message-bar.c                   \
+       message-bar.h                   \
        template-history.c              \
        template-history.h              \
        template-history-model.c        \
diff --git a/src/media-select.c b/src/media-select.c
new file mode 100644 (file)
index 0000000..5f1eecd
--- /dev/null
@@ -0,0 +1,934 @@
+/*
+ *  media-select.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 "media-select.h"
+
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+#include <string.h>
+
+#include <libglabels/libglabels.h>
+#include "mini-preview-pixbuf-cache.h"
+#include "prefs.h"
+#include "message-bar.h"
+#include "template-history.h"
+#include "str-util.h"
+#include "combo-util.h"
+#include "builder-util.h"
+#include "color.h"
+#include "marshal.h"
+
+#include "debug.h"
+
+
+#define HISTORY_SIZE 5
+
+/*===========================================*/
+/* Private types                             */
+/*===========================================*/
+
+enum {
+       NAME_COLUMN,
+       PREVIEW_COLUMN,
+       PREVIEW_COLUMN_STOCK,
+       PREVIEW_COLUMN_STOCK_SIZE,
+       DESCRIPTION_COLUMN,
+       N_COLUMNS
+};
+
+struct _glMediaSelectPrivate {
+
+        GtkBuilder   *builder;
+
+        GtkWidget    *notebook;
+        guint         current_page_num;
+
+        gint          recent_page_num;
+        GtkWidget    *recent_tab_vbox;
+        GtkWidget    *recent_info_vbox;
+        GtkWidget    *recent_info_bar;
+        GtkWidget    *recent_treeview;
+        GtkListStore *recent_store;
+
+        gint          search_all_page_num;
+        GtkWidget    *search_all_tab_vbox;
+        GtkWidget    *search_all_info_vbox;
+        GtkWidget    *search_all_info_bar;
+        GtkWidget    *brand_combo;
+        GtkWidget    *page_size_combo;
+        GtkWidget    *category_combo;
+        GtkWidget    *search_all_treeview;
+        GtkListStore *search_all_store;
+
+        /* Prevent recursion */
+       gboolean    stop_signals;
+};
+
+enum {
+        CHANGED,
+        LAST_SIGNAL
+};
+
+
+/*===========================================*/
+/* Private globals                           */
+/*===========================================*/
+
+static gint media_select_signals[LAST_SIGNAL] = { 0 };
+
+
+/*===========================================*/
+/* Local function prototypes                 */
+/*===========================================*/
+
+static void   gl_media_select_finalize   (GObject                *object);
+
+static void   gl_media_select_construct  (glMediaSelect          *this);
+
+static void   filter_changed_cb          (GtkComboBox            *combo,
+                                          gpointer                user_data);
+
+static void   selection_changed_cb       (GtkTreeSelection       *selection,
+                                          gpointer                user_data);
+
+static void   page_changed_cb            (GtkNotebook            *notebook,
+                                          GtkNotebookPage        *page,
+                                          guint                   page_num,
+                                          gpointer                user_data);
+
+static gchar *get_layout_desc            (const lglTemplate      *template);
+
+static gchar *get_label_size_desc        (const lglTemplate      *template);
+
+static void   load_recent_list           (glMediaSelect          *this,
+                                          GtkListStore           *store,
+                                          GtkTreeSelection       *selection,
+                                          GList                  *list);
+
+static void   load_search_all_list       (glMediaSelect          *this,
+                                          GtkListStore           *store,
+                                          GtkTreeSelection       *selection,
+                                          GList                  *list);
+
+
+/****************************************************************************/
+/* Boilerplate Object stuff.                                                */
+/****************************************************************************/
+G_DEFINE_TYPE (glMediaSelect, gl_media_select, GTK_TYPE_VBOX);
+
+
+static void
+gl_media_select_class_init (glMediaSelectClass *class)
+{
+        GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        gl_media_select_parent_class = g_type_class_peek_parent (class);
+
+        object_class->finalize = gl_media_select_finalize;
+
+        media_select_signals[CHANGED] =
+            g_signal_new ("changed",
+                          G_OBJECT_CLASS_TYPE(object_class),
+                          G_SIGNAL_RUN_LAST,
+                          G_STRUCT_OFFSET (glMediaSelectClass, changed),
+                          NULL, NULL,
+                          gl_marshal_VOID__VOID,
+                          G_TYPE_NONE, 0);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+static void
+gl_media_select_init (glMediaSelect *this)
+{
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        this->priv = g_new0 (glMediaSelectPrivate, 1);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+static void
+gl_media_select_finalize (GObject *object)
+{
+        glMediaSelect *this = GL_MEDIA_SELECT (object);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        g_return_if_fail (object != NULL);
+        g_return_if_fail (GL_IS_MEDIA_SELECT (object));
+
+        if (this->priv->builder)
+        {
+                g_object_unref (this->priv->builder);
+        }
+        g_object_unref (this->priv->recent_store);
+        g_object_unref (this->priv->search_all_store);
+        g_free (this->priv);
+
+        G_OBJECT_CLASS (gl_media_select_parent_class)->finalize (object);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+GtkWidget *
+gl_media_select_new (void)
+{
+        glMediaSelect *this;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        this = g_object_new (gl_media_select_get_type (), NULL);
+
+        gl_media_select_construct (this);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+
+        return GTK_WIDGET (this);
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Construct composite widget.                                    */
+/*--------------------------------------------------------------------------*/
+static void
+gl_media_select_construct (glMediaSelect *this)
+{
+        GtkBuilder        *builder;
+        static gchar      *object_ids[] = { "media_select_hbox", NULL };
+        GError            *error = NULL;
+        GtkWidget         *hbox;
+        GList             *recent_list = NULL;
+        GList             *brands = NULL;
+        GList             *page_sizes = NULL;
+        GList             *categories = NULL;
+        GList             *search_all_names = NULL;
+        const gchar       *page_size_id;
+        gchar             *page_size_name;
+        GtkCellRenderer   *renderer;
+        GtkTreeViewColumn *column;
+        GtkTreeSelection  *recent_selection;
+        GtkTreeSelection  *search_all_selection;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        g_return_if_fail (GL_IS_MEDIA_SELECT (this));
+        g_return_if_fail (this->priv != NULL);
+
+        builder = gtk_builder_new ();
+        gtk_builder_add_objects_from_file (builder,
+                                           GLABELS_BUILDER_DIR "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,
+                                     "media_select_hbox",      &hbox,
+                                     "notebook",               &this->priv->notebook,
+                                     "recent_tab_vbox",        &this->priv->recent_tab_vbox,
+                                     "recent_info_vbox",       &this->priv->recent_info_vbox,
+                                     "recent_treeview",        &this->priv->recent_treeview,
+                                     "search_all_tab_vbox",    &this->priv->search_all_tab_vbox,
+                                     "brand_combo",            &this->priv->brand_combo,
+                                     "page_size_combo",        &this->priv->page_size_combo,
+                                     "category_combo",         &this->priv->category_combo,
+                                     "search_all_info_vbox",   &this->priv->search_all_info_vbox,
+                                     "search_all_treeview",    &this->priv->search_all_treeview,
+                                     NULL);
+
+        gtk_container_add (GTK_CONTAINER (this), hbox);
+        this->priv->builder = builder;
+
+        this->priv->recent_page_num =
+                gtk_notebook_page_num (GTK_NOTEBOOK (this->priv->notebook),
+                                       this->priv->recent_tab_vbox);
+        this->priv->search_all_page_num =
+                gtk_notebook_page_num (GTK_NOTEBOOK (this->priv->notebook),
+                                       this->priv->search_all_tab_vbox);
+
+        gtk_widget_show_all (GTK_WIDGET (this));
+
+        /* Recent templates treeview */
+        this->priv->recent_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
+        gtk_tree_view_set_model (GTK_TREE_VIEW (this->priv->recent_treeview),
+                                 GTK_TREE_MODEL (this->priv->recent_store));
+        renderer = gtk_cell_renderer_pixbuf_new ();
+        column = gtk_tree_view_column_new_with_attributes ("", renderer,
+                                                           "pixbuf", PREVIEW_COLUMN,
+                                                           "stock-id", PREVIEW_COLUMN_STOCK,
+                                                           "stock-size", PREVIEW_COLUMN_STOCK_SIZE,
+                                                           NULL);
+        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (this->priv->recent_treeview), column);
+        renderer = gtk_cell_renderer_text_new ();
+        column = gtk_tree_view_column_new_with_attributes ("", renderer,
+                                                           "markup", DESCRIPTION_COLUMN,
+                                                           NULL);
+        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (this->priv->recent_treeview), column);
+        recent_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (this->priv->recent_treeview));
+        recent_list = gl_template_history_model_get_name_list (gl_template_history);
+        load_recent_list (this, this->priv->recent_store, recent_selection, recent_list);
+
+        page_size_id = gl_prefs_model_get_default_page_size (gl_prefs);
+        page_size_name = lgl_db_lookup_paper_name_from_id (page_size_id);
+
+        /* Brand selection control */
+        gl_combo_util_add_text_model (GTK_COMBO_BOX (this->priv->brand_combo));
+        brands = lgl_db_get_brand_list (NULL, NULL);
+        brands = g_list_prepend (brands, g_strdup (_("Any")));
+        gl_combo_util_set_strings (GTK_COMBO_BOX (this->priv->brand_combo), brands);
+        lgl_db_free_brand_list (brands);
+        gl_combo_util_set_active_text (GTK_COMBO_BOX (this->priv->brand_combo),
+                                       _("Any"));
+
+        /* Page size selection control */
+        gl_combo_util_add_text_model (GTK_COMBO_BOX (this->priv->page_size_combo));
+        page_sizes = lgl_db_get_paper_name_list ();
+        page_sizes = g_list_prepend (page_sizes, g_strdup (_("Any")));
+        gl_combo_util_set_strings (GTK_COMBO_BOX (this->priv->page_size_combo), page_sizes);
+        lgl_db_free_paper_name_list (page_sizes);
+        gl_combo_util_set_active_text (GTK_COMBO_BOX (this->priv->page_size_combo),
+                                       page_size_name);
+
+        /* Category selection control */
+        gl_combo_util_add_text_model (GTK_COMBO_BOX (this->priv->category_combo));
+        categories = lgl_db_get_category_name_list ();
+        categories = g_list_prepend (categories, g_strdup (_("Any")));
+        gl_combo_util_set_strings (GTK_COMBO_BOX (this->priv->category_combo), categories);
+        gl_combo_util_set_active_text (GTK_COMBO_BOX (this->priv->category_combo),
+                                       _("Any"));
+        lgl_db_free_category_name_list (categories);
+
+        /* Search all treeview */
+        this->priv->search_all_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
+        gtk_tree_view_set_model (GTK_TREE_VIEW (this->priv->search_all_treeview),
+                                 GTK_TREE_MODEL (this->priv->search_all_store));
+        renderer = gtk_cell_renderer_pixbuf_new ();
+        column = gtk_tree_view_column_new_with_attributes ("", renderer,
+                                                           "pixbuf", PREVIEW_COLUMN,
+                                                           "stock-id", PREVIEW_COLUMN_STOCK,
+                                                           "stock-size", PREVIEW_COLUMN_STOCK_SIZE,
+                                                           NULL);
+        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (this->priv->search_all_treeview), column);
+        renderer = gtk_cell_renderer_text_new ();
+        column = gtk_tree_view_column_new_with_attributes ("", renderer,
+                                                           "markup", DESCRIPTION_COLUMN,
+                                                           NULL);
+        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
+        gtk_tree_view_append_column (GTK_TREE_VIEW (this->priv->search_all_treeview), column);
+        search_all_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (this->priv->search_all_treeview));
+        search_all_names = lgl_db_get_template_name_list_all (NULL, page_size_id, NULL);
+        load_search_all_list (this, this->priv->search_all_store, search_all_selection, search_all_names);
+        lgl_db_free_template_name_list (search_all_names);
+
+        /* Connect signals to controls */
+        g_signal_connect (G_OBJECT (this->priv->brand_combo), "changed",
+                          G_CALLBACK (filter_changed_cb),
+                          this);
+        g_signal_connect (G_OBJECT (this->priv->page_size_combo), "changed",
+                          G_CALLBACK (filter_changed_cb),
+                          this);
+        g_signal_connect (G_OBJECT (this->priv->category_combo), "changed",
+                          G_CALLBACK (filter_changed_cb),
+                          this);
+        g_signal_connect (G_OBJECT (recent_selection), "changed",
+                          G_CALLBACK (selection_changed_cb),
+                          this);
+        g_signal_connect (G_OBJECT (search_all_selection), "changed",
+                          G_CALLBACK (selection_changed_cb),
+                          this);
+        g_signal_connect (G_OBJECT (this->priv->notebook), "switch-page",
+                          G_CALLBACK (page_changed_cb),
+                          this);
+
+        g_free (page_size_name);
+
+        if ( recent_list )
+        {
+                gtk_notebook_set_current_page (GTK_NOTEBOOK (this->priv->notebook),
+                                               this->priv->recent_page_num);
+        }
+        else
+        {
+                gtk_notebook_set_current_page (GTK_NOTEBOOK (this->priv->notebook),
+                                               this->priv->search_all_page_num);
+        }
+        gl_template_history_model_free_name_list (recent_list);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  modify widget due to change in selection                       */
+/*--------------------------------------------------------------------------*/
+static void
+filter_changed_cb (GtkComboBox *combo,
+                   gpointer     user_data)
+{
+        glMediaSelect     *this = GL_MEDIA_SELECT (user_data);
+        gchar             *brand;
+        gchar             *page_size_name, *page_size_id;
+        gchar             *category_name, *category_id;
+        GList             *search_all_names;
+        GtkTreeSelection  *selection;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+
+       this->priv->stop_signals = TRUE;
+
+        /* Update template selections for new filter settings */
+        brand = gtk_combo_box_get_active_text (GTK_COMBO_BOX (this->priv->brand_combo));
+        page_size_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (this->priv->page_size_combo));
+        category_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (this->priv->category_combo));
+        if ( brand && strlen(brand) &&
+             page_size_name && strlen(page_size_name) &&
+             category_name && strlen(category_name) )
+        {
+                gl_debug (DEBUG_MEDIA_SELECT, "brand = \"%s\"", brand);
+                gl_debug (DEBUG_MEDIA_SELECT, "page_size_name = \"%s\"", page_size_name);
+                gl_debug (DEBUG_MEDIA_SELECT, "category_name = \"%s\"", category_name);
+                if (!g_utf8_collate (brand, _("Any")))
+                {
+                        g_free (brand);
+                        brand = NULL;
+                }
+                page_size_id = lgl_db_lookup_paper_id_from_name (page_size_name);
+                category_id = lgl_db_lookup_category_id_from_name (category_name);
+                gl_debug (DEBUG_MEDIA_SELECT, "page_size_id = \"%s\"", page_size_id);
+                gl_debug (DEBUG_MEDIA_SELECT, "category_id = \"%s\"", category_id);
+                search_all_names = lgl_db_get_template_name_list_all (brand, page_size_id, category_id);
+                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (this->priv->search_all_treeview));
+                load_search_all_list (this, this->priv->search_all_store, selection, search_all_names);
+                lgl_db_free_template_name_list (search_all_names);
+                g_free (page_size_id);
+                g_free (category_id);
+
+                /* Emit our "changed" signal */
+                g_signal_emit (G_OBJECT (user_data),
+                               media_select_signals[CHANGED], 0);
+        }
+        g_free (brand);
+        g_free (page_size_name);
+        g_free (category_name);
+
+
+       this->priv->stop_signals = FALSE;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  modify widget due to change in selection                       */
+/*--------------------------------------------------------------------------*/
+static void
+selection_changed_cb (GtkTreeSelection       *selection,
+                      gpointer                user_data)
+{
+        glMediaSelect *this = GL_MEDIA_SELECT (user_data);
+
+       if (this->priv->stop_signals) return;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        /* Emit our "changed" signal */
+        g_signal_emit (G_OBJECT (user_data),
+                       media_select_signals[CHANGED], 0);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  modify widget due to change in selection                       */
+/*--------------------------------------------------------------------------*/
+static void
+page_changed_cb (GtkNotebook            *notebook,
+                 GtkNotebookPage        *page,
+                 guint                   page_num,
+                 gpointer                user_data)
+{
+        glMediaSelect *this = GL_MEDIA_SELECT (user_data);
+
+       if (this->priv->stop_signals) return;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        /*
+         * Store new current page, because this signal is emitted before the actual page change.
+         */
+       this->priv->current_page_num = page_num;
+
+        /* Emit our "changed" signal */
+        g_signal_emit (G_OBJECT (user_data),
+                       media_select_signals[CHANGED], 0);
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+/****************************************************************************/
+/* query selected label template name.                                      */
+/****************************************************************************/
+gchar *
+gl_media_select_get_name (glMediaSelect *this)
+{
+        gint               page_num;
+        GtkTreeSelection  *selection;
+        GtkTreeIter        iter;
+        GtkTreeModel      *model;        
+        gchar             *name;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        page_num = this->priv->current_page_num;
+        if (page_num == this->priv->recent_page_num)
+        {
+                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (this->priv->recent_treeview));
+        }
+        else if (page_num == this->priv->search_all_page_num)
+        {
+                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (this->priv->search_all_treeview));
+        }
+        else
+        {
+                g_print ("notebook page = %d\n", page_num);
+                g_assert_not_reached ();
+        }
+
+        if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_NONE)
+        {
+                name = NULL;
+        }
+        else
+        {
+                gtk_tree_selection_get_selected (selection, &model, &iter);
+                gtk_tree_model_get (model, &iter, NAME_COLUMN, &name, -1);
+        }
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+        return name;
+}
+
+
+/****************************************************************************/
+/* set selected label template name.                                        */
+/****************************************************************************/
+void
+gl_media_select_set_name (glMediaSelect *this,
+                          gchar         *name)
+{
+        GtkTreeSelection  *selection;
+        GtkTreeModel      *model;
+        GtkTreeIter        iter;
+        GtkTreePath       *path;
+        gchar             *name_i;
+        gboolean           flag;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (this->priv->search_all_treeview));
+        g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
+
+        model = GTK_TREE_MODEL (this->priv->search_all_store);
+
+        for ( flag = gtk_tree_model_get_iter_first (model, &iter);
+              flag;
+              flag = gtk_tree_model_iter_next(model, &iter) )
+        {
+                gtk_tree_model_get (model, &iter, NAME_COLUMN, &name_i, -1); 
+                if (strcasecmp(name, name_i) == 0)
+                {
+                        gtk_tree_selection_select_iter (selection, &iter);
+                        path = gtk_tree_model_get_path (model, &iter);
+                        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (this->priv->search_all_treeview),
+                                                      path,
+                                                      NULL,
+                                                      TRUE, 0.5, 0.0);
+                        gtk_tree_path_free (path);
+                        break;
+                }
+        }
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+/****************************************************************************/
+/* query current filter parameters.                                         */
+/****************************************************************************/
+void
+gl_media_select_get_filter_parameters (glMediaSelect  *this,
+                                       gchar         **page_size_id,
+                                       gchar         **category_id)
+{
+        gchar *page_size_name, *category_name;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "");
+
+        g_free (*page_size_id);
+        g_free (*category_id);
+
+        page_size_name =
+                gtk_combo_box_get_active_text (GTK_COMBO_BOX (this->priv->page_size_combo));
+
+        *page_size_id = lgl_db_lookup_paper_id_from_name (page_size_name);
+
+        category_name =
+                gtk_combo_box_get_active_text (GTK_COMBO_BOX (this->priv->category_combo));
+
+        *category_id = lgl_db_lookup_category_id_from_name (category_name);
+
+        g_free (page_size_name);
+        g_free (category_name);
+}
+
+
+/****************************************************************************/
+/* set filter parameters.                                                   */
+/****************************************************************************/
+void
+gl_media_select_set_filter_parameters (glMediaSelect  *this,
+                                       const gchar    *page_size_id,
+                                       const gchar    *category_id)
+{
+        gchar *page_size_name;
+        gchar *category_name;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        page_size_name = lgl_db_lookup_paper_name_from_id (page_size_id);
+        if (page_size_name == NULL)
+        {
+                page_size_name = g_strdup (_("Any"));
+        }
+
+        gl_combo_util_set_active_text (GTK_COMBO_BOX (this->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_combo_util_set_active_text (GTK_COMBO_BOX (this->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.          */
+/*--------------------------------------------------------------------------*/
+static gchar *
+get_layout_desc (const lglTemplate *template)
+{
+        const lglTemplateFrame *frame;
+        gint                    n_labels;
+        gchar                  *string;
+
+        frame = (lglTemplateFrame *)template->frames->data;
+
+        n_labels = lgl_template_frame_get_n_labels (frame);
+
+        string = g_strdup_printf (_("%d per sheet"), n_labels);
+
+        return string;
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Get label size description.                                    */ 
+/*--------------------------------------------------------------------------*/
+static gchar *
+get_label_size_desc (const lglTemplate *template)
+{
+        lglUnits                   units;
+        const gchar               *units_string;
+        gdouble                    units_per_point;
+        const lglTemplateFrame    *frame;
+        gchar                     *string = NULL;
+
+        units           = gl_prefs_model_get_units (gl_prefs);
+        units_string    = lgl_units_get_name (units);
+        units_per_point = lgl_units_get_units_per_point (units);
+
+        frame = (lglTemplateFrame *)template->frames->data;
+
+        switch (frame->shape) {
+        case LGL_TEMPLATE_FRAME_SHAPE_RECT:
+                if ( units == LGL_UNITS_INCH ) {
+                        gchar *xstr, *ystr;
+
+                        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 × %s %s",
+                                                  xstr, ystr, units_string);
+                        g_free (xstr);
+                        g_free (ystr);
+                } else {
+                        string = g_strdup_printf ("%.5g × %.5g %s",
+                                                  frame->rect.w*units_per_point,
+                                                  frame->rect.h*units_per_point,
+                                                  units_string);
+                }
+                break;
+        case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
+                if ( units == LGL_UNITS_INCH ) {
+                        gchar *dstr;
+
+                        dstr = gl_str_util_fraction_to_string (2.0*frame->round.r*units_per_point);
+                        string = g_strdup_printf ("%s %s %s",
+                                                  dstr, units_string,
+                                                  _("diameter"));
+                        g_free (dstr);
+                } else {
+                        string = g_strdup_printf ("%.5g %s %s",
+                                                  2.0*frame->round.r*units_per_point,
+                                                  units_string,
+                                                  _("diameter"));
+                }
+                break;
+        case LGL_TEMPLATE_FRAME_SHAPE_CD:
+                if ( units == LGL_UNITS_INCH ) {
+                        gchar *dstr;
+
+                        dstr = gl_str_util_fraction_to_string (2.0*frame->cd.r1*units_per_point);
+                        string = g_strdup_printf ("%s %s %s",
+                                                  dstr, units_string,
+                                                  _("diameter"));
+                        g_free (dstr);
+                } else {
+                        string = g_strdup_printf ("%.5g %s %s",
+                                                  2.0*frame->cd.r1*units_per_point,
+                                                  units_string,
+                                                  _("diameter"));
+                }
+                break;
+        default:
+                break;
+        }
+
+        return string;
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Load list store from template name list.                       */
+/*--------------------------------------------------------------------------*/
+static void
+load_recent_list (glMediaSelect      *this,
+                  GtkListStore       *store,
+                  GtkTreeSelection   *selection,
+                  GList              *list)
+{
+        GList       *p;
+        GtkTreeIter  iter;
+        lglTemplate *template;
+        GdkPixbuf   *pixbuf;
+        gchar       *size;
+        gchar       *layout;
+        gchar       *description;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        gtk_list_store_clear (store);
+
+        if (list)
+        {
+
+                for ( p=list; p!=NULL; p=p->next )
+                {
+
+                        gl_debug (DEBUG_MEDIA_SELECT, "p->data = \"%s\"", p->data);
+
+                        template = lgl_db_lookup_template_from_name (p->data);
+                        pixbuf = gl_mini_preview_pixbuf_cache_get_pixbuf (p->data);
+
+                        size = get_label_size_desc (template);
+                        layout = get_layout_desc (template);
+                        description = g_strdup_printf ("<b>%s: %s</b>\n%s\n%s",
+                                                       (gchar *)p->data,
+                                                       template->description,
+                                                       size,
+                                                       layout);
+                        g_free (size);
+                        g_free (layout);
+
+                        lgl_template_free (template);
+
+                        gtk_list_store_append (store, &iter);
+                        gtk_list_store_set (store, &iter,
+                                            NAME_COLUMN, p->data,
+                                            PREVIEW_COLUMN, pixbuf,
+                                            DESCRIPTION_COLUMN, description,
+                                            -1);
+
+                        g_object_unref (G_OBJECT (pixbuf));
+                        g_free (description);
+                }
+
+                gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+                gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+                gtk_tree_selection_select_iter (selection, &iter);
+
+                if ( this->priv->recent_info_bar )
+                {
+                        gtk_container_remove (GTK_CONTAINER (this->priv->recent_info_vbox),
+                                              this->priv->recent_info_bar);
+                        this->priv->recent_info_bar = NULL;
+                }
+        }
+        else
+        {
+                this->priv->recent_info_bar = gl_message_bar_new (GTK_MESSAGE_INFO,
+                                                                          GTK_BUTTONS_NONE,
+                                                                          "%s", _("No recent templates found."));
+                gl_message_bar_format_secondary_text (GL_MESSAGE_BAR (this->priv->recent_info_bar),
+                                                      "%s", _("Try selecting a template from the \"Search all templates\" page."));
+
+                gtk_box_pack_start (GTK_BOX (this->priv->recent_info_vbox),
+                                    this->priv->recent_info_bar,
+                                    FALSE, FALSE, 0);
+                gtk_widget_show_all (this->priv->recent_info_bar);
+
+                gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
+
+        }
+
+        gl_debug (DEBUG_MEDIA_SELECT, "END");
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE.  Load list store from template name list.                       */
+/*--------------------------------------------------------------------------*/
+static void
+load_search_all_list (glMediaSelect      *this,
+                      GtkListStore       *store,
+                      GtkTreeSelection   *selection,
+                      GList              *list)
+{
+        GList       *p;
+        GtkTreeIter  iter;
+        lglTemplate *template;
+        GdkPixbuf   *pixbuf;
+        gchar       *size;
+        gchar       *layout;
+        gchar       *description;
+
+        gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+        gtk_list_store_clear (store);
+
+        if (list)
+        {
+
+                for ( p=list; p!=NULL; p=p->next )
+                {
+
+                        gl_debug (DEBUG_MEDIA_SELECT, "p->data = \"%s\"", p->data);
+
+                        template = lgl_db_lookup_template_from_name (p->data);
+                        pixbuf = gl_mini_preview_pixbuf_cache_get_pixbuf (p->data);
+
+                        size = get_label_size_desc (template);
+                        layout = get_layout_desc (template);
+                        description = g_strdup_printf ("<b>%s: %s</b>\n%s\n%s",
+                                                       (gchar *)p->data,
+                                                       template->description,
+                                                       size,
+                                                       layout);
+                        g_free (size);
+                        g_free (layout);
+
+                        lgl_template_free (template);
+
+                        gtk_list_store_append (store, &iter);
+                        gtk_list_store_set (store, &iter,
+                                            NAME_COLUMN, p->data,
+                                            PREVIEW_COLUMN, pixbuf,
+                                            DESCRIPTION_COLUMN, description,
+                                            -1);
+
+                        g_object_unref (G_OBJECT (pixbuf));
+                        g_free (description);
+                }
+
+                gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
+                gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
+                gtk_tree_selection_select_iter (selection, &iter);
+
+                if ( this->priv->search_all_info_bar )
+                {
+                        gtk_container_remove (GTK_CONTAINER (this->priv->search_all_info_vbox),
+                                              this->priv->search_all_info_bar);
+                        this->priv->search_all_info_bar = NULL;
+                }
+        }
+        else
+        {
+                this->priv->search_all_info_bar = gl_message_bar_new (GTK_MESSAGE_INFO,
+                                                                              GTK_BUTTONS_NONE,
+                                                                              "%s", _("No match."));
+                gl_message_bar_format_secondary_text (GL_MESSAGE_BAR (this->priv->search_all_info_bar),
+                                                      "%s", _("Try selecting a different brand, page size or category."));
+
+                gtk_box_pack_start (GTK_BOX (this->priv->search_all_info_vbox),
+                                    this->priv->search_all_info_bar,
+                                    FALSE, FALSE, 0);
+                gtk_widget_show_all (this->priv->search_all_info_bar);
+
+                gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
+
+        }
+
+        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
+ */
diff --git a/src/media-select.h b/src/media-select.h
new file mode 100644 (file)
index 0000000..6d086ea
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  media-select.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 __MEDIA_SELECT_H__
+#define __MEDIA_SELECT_H__
+
+#include <gtk/gtk.h>
+
+
+G_BEGIN_DECLS
+
+#define GL_TYPE_MEDIA_SELECT (gl_media_select_get_type ())
+#define GL_MEDIA_SELECT(obj) \
+        (G_TYPE_CHECK_INSTANCE_CAST((obj), GL_TYPE_MEDIA_SELECT, glMediaSelect ))
+#define GL_MEDIA_SELECT_CLASS(klass) \
+        (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_MEDIA_SELECT, glMediaSelectClass))
+#define GL_IS_MEDIA_SELECT(obj) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_MEDIA_SELECT))
+#define GL_IS_MEDIA_SELECT_CLASS(klass) \
+        (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_MEDIA_SELECT))
+
+typedef struct _glMediaSelect         glMediaSelect;
+typedef struct _glMediaSelectClass    glMediaSelectClass;
+
+typedef struct _glMediaSelectPrivate  glMediaSelectPrivate;
+
+struct _glMediaSelect {
+        GtkVBox                    parent_widget;
+
+        glMediaSelectPrivate  *priv;
+};
+
+struct _glMediaSelectClass {
+        GtkVBoxClass               parent_class;
+
+        void (*changed) (glMediaSelect * media_select, gpointer user_data);
+};
+
+
+GType      gl_media_select_get_type      (void) G_GNUC_CONST;
+
+GtkWidget *gl_media_select_new           (void);
+
+gchar     *gl_media_select_get_name      (glMediaSelect *this);
+
+void       gl_media_select_set_name      (glMediaSelect *this,
+                                          gchar         *name);
+
+void       gl_media_select_get_filter_parameters (glMediaSelect *this,
+                                                  gchar        **page_size_id,
+                                                  gchar        **category_id);
+
+void       gl_media_select_set_filter_parameters (glMediaSelect *this,
+                                                  const gchar   *page_size_id,
+                                                  const gchar   *category_id);
+
+G_END_DECLS
+
+#endif
+
+
+
+/*
+ * 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/src/message-bar.c b/src/message-bar.c
new file mode 100644 (file)
index 0000000..507afac
--- /dev/null
@@ -0,0 +1,248 @@
+/*
+ *  message-bar.c
+ *  Copyright (C) 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 "message-bar.h"
+
+#include "debug.h"
+
+
+/*===========================================*/
+/* Private data types                        */
+/*===========================================*/
+
+struct _glMessageBarPrivate {
+
+        GtkWidget *icon;
+        GtkWidget *label;
+
+        gchar     *primary_text;
+        gchar     *secondary_text;
+};
+
+
+/*===========================================*/
+/* Private globals                           */
+/*===========================================*/
+
+
+/*===========================================*/
+/* Local function prototypes                 */
+/*===========================================*/
+
+static void       gl_message_bar_finalize       (GObject               *object);
+
+static void       gl_message_bar_construct      (glMessageBar          *this,
+                                                 GtkMessageType         type,
+                                                 GtkButtonsType         buttons,
+                                                 const gchar           *message_format,
+                                                 va_list                args);
+
+
+/*****************************************************************************/
+/* Boilerplate object stuff.                                                 */
+/*****************************************************************************/
+G_DEFINE_TYPE (glMessageBar, gl_message_bar, GTK_TYPE_INFO_BAR);
+
+
+/*****************************************************************************/
+/* Class Init Function.                                                      */
+/*****************************************************************************/
+static void
+gl_message_bar_class_init (glMessageBarClass *class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
+
+       gl_message_bar_parent_class = g_type_class_peek_parent (class);
+
+       object_class->finalize = gl_message_bar_finalize;       
+}
+
+
+/*****************************************************************************/
+/* Object Instance Init Function.                                            */
+/*****************************************************************************/
+static void
+gl_message_bar_init (glMessageBar *dialog)
+{
+       g_return_if_fail (GL_IS_MESSAGE_BAR (dialog));
+
+       dialog->priv = g_new0 (glMessageBarPrivate, 1);
+}
+
+
+/*****************************************************************************/
+/* Finalize Function.                                                        */
+/*****************************************************************************/
+static void 
+gl_message_bar_finalize (GObject *object)
+{
+       glMessageBar* dialog = GL_MESSAGE_BAR (object);;
+       
+       g_return_if_fail (object != NULL);
+       g_return_if_fail (GL_IS_MESSAGE_BAR (dialog));
+       g_return_if_fail (dialog->priv != NULL);
+
+       g_free (dialog->priv->primary_text);
+       g_free (dialog->priv->secondary_text);
+       g_free (dialog->priv);
+
+       G_OBJECT_CLASS (gl_message_bar_parent_class)->finalize (object);
+}
+
+
+/*****************************************************************************/
+/* NEW message bar.                                                          */
+/*****************************************************************************/
+GtkWidget *
+gl_message_bar_new (GtkMessageType  type,
+                    GtkButtonsType  buttons,
+                    const gchar    *message_format,
+                    ...)
+{
+       GtkWidget *widget;
+        va_list    args;
+
+       widget = GTK_WIDGET (g_object_new (GL_TYPE_MESSAGE_BAR, NULL));
+        
+        va_start (args, message_format);
+        gl_message_bar_construct (GL_MESSAGE_BAR (widget), type, buttons, message_format, args);
+        va_end (args);
+
+       return widget;
+}
+
+
+/*****************************************************************************/
+/* Construct message bar.                                                    */
+/*****************************************************************************/
+static void
+gl_message_bar_construct (glMessageBar    *this,
+                          GtkMessageType   type,
+                          GtkButtonsType   buttons,
+                          const gchar     *message_format,
+                          va_list          args)
+{
+        GtkWidget *hbox;
+
+        gtk_info_bar_set_message_type (GTK_INFO_BAR (this), type);
+
+        this->priv->icon = gtk_image_new ();
+        switch (type)
+        {
+        case GTK_MESSAGE_INFO:
+                gtk_image_set_from_stock (GTK_IMAGE (this->priv->icon),
+                                          GTK_STOCK_DIALOG_INFO, GTK_ICON_SIZE_DIALOG);
+                break;
+        case GTK_MESSAGE_WARNING:
+                gtk_image_set_from_stock (GTK_IMAGE (this->priv->icon),
+                                          GTK_STOCK_DIALOG_WARNING, GTK_ICON_SIZE_DIALOG);
+                break;
+        case GTK_MESSAGE_QUESTION:
+                gtk_image_set_from_stock (GTK_IMAGE (this->priv->icon),
+                                          GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG);
+                break;
+        case GTK_MESSAGE_ERROR:
+                gtk_image_set_from_stock (GTK_IMAGE (this->priv->icon),
+                                          GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_DIALOG);
+                break;
+        default:
+                break;
+        }
+
+        this->priv->primary_text = g_strdup_vprintf (message_format, args);
+        this->priv->label = gtk_label_new (this->priv->primary_text);
+
+        hbox = gtk_info_bar_get_content_area (GTK_INFO_BAR (this));
+        gtk_box_pack_start (GTK_BOX (hbox), this->priv->icon, FALSE, FALSE, 0);
+        gtk_box_pack_start (GTK_BOX (hbox), this->priv->label, FALSE, FALSE, 0);
+
+        switch (buttons)
+        {
+        case GTK_BUTTONS_OK:
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+                break;
+        case GTK_BUTTONS_CLOSE:
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_CLOSE, GTK_RESPONSE_ACCEPT);
+                break;
+        case GTK_BUTTONS_CANCEL:
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+                break;
+        case GTK_BUTTONS_YES_NO:
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_YES, GTK_RESPONSE_ACCEPT);
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_NO, GTK_RESPONSE_REJECT);
+                break;
+        case GTK_BUTTONS_OK_CANCEL:
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_OK, GTK_RESPONSE_ACCEPT);
+                gtk_info_bar_add_button (GTK_INFO_BAR (this),
+                                         GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT);
+                break;
+        default:
+                break;
+        }
+}
+
+
+/*****************************************************************************/
+/* Set secondary text.                                                       */
+/*****************************************************************************/
+void
+gl_message_bar_format_secondary_text (glMessageBar   *this,
+                                      const gchar    *message_format,
+                                      ...)
+{
+        va_list    args;
+        gchar     *markup;
+
+        g_free (this->priv->secondary_text);
+
+        va_start (args, message_format);
+        this->priv->secondary_text = g_strdup_vprintf (message_format, args);
+        va_end (args);
+
+        markup = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n%s",
+                                  this->priv->primary_text,
+                                  this->priv->secondary_text);
+
+        gtk_label_set_markup (GTK_LABEL (this->priv->label), markup);
+
+        g_free (markup);
+}
+
+
+
+
+
+
+/*
+ * 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/src/message-bar.h b/src/message-bar.h
new file mode 100644 (file)
index 0000000..6bc5209
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ *  message-bar.h
+ *  Copyright (C) 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 __MESSAGE_BAR_H__
+#define __MESSAGE_BAR_H__
+
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GL_TYPE_MESSAGE_BAR            (gl_message_bar_get_type ())
+#define GL_MESSAGE_BAR(obj) \
+        (G_TYPE_CHECK_INSTANCE_CAST ((obj), GL_TYPE_MESSAGE_BAR, glMessageBar))
+#define GL_MESSAGE_BAR_CLASS(klass) \
+        (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_MESSAGE_BAR, glMessageBarClass))
+#define GL_IS_MESSAGE_BAR(obj) \
+        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_MESSAGE_BAR))
+#define GL_IS_MESSAGE_BAR_CLASS(klass) \
+        (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_MESSAGE_BAR))
+#define GL_MESSAGE_BAR_GET_CLASS(obj) \
+        (G_TYPE_INSTANCE_GET_CLASS ((obj), GL_TYPE_MESSAGE_BAR, glMessageBarClass))
+
+
+typedef struct _glMessageBar         glMessageBar;
+typedef struct _glMessageBarClass    glMessageBarClass;
+
+typedef struct _glMessageBarPrivate  glMessageBarPrivate;
+
+struct _glMessageBar
+{
+       GtkInfoBar           parent_instance;
+
+       glMessageBarPrivate *priv;
+
+};
+
+struct  _glMessageBarClass
+{
+       GtkInfoBarClass      parent_class;
+};
+
+
+GType      gl_message_bar_get_type                (void) G_GNUC_CONST;
+
+GtkWidget *gl_message_bar_new                     (GtkMessageType  type,
+                                                   GtkButtonsType  buttons,
+                                                   const gchar    *message_format,
+                                                   ...);
+
+void       gl_message_bar_format_secondary_text   (glMessageBar   *this,
+                                                   const gchar    *message_format,
+                                                   ...);
+
+
+
+
+G_END_DECLS
+
+#endif
+
+
+
+/*
+ * Local Variables:       -- emacs
+ * mode: C                -- emacs
+ * c-basic-offset: 8      -- emacs
+ * tab-width: 8           -- emacs
+ * indent-tabs-mode: nil  -- emacs
+ * End:                   -- emacs
+ */
index c77e8cb55917043f17fe653b0ff04ba09c999b8b..f01d0fb6a0c627e3c45902a591efcdf5ceccab2c 100644 (file)
@@ -26,7 +26,7 @@
 #include <gtk/gtk.h>
 
 #include "hig.h"
-#include "wdgt-media-select.h"
+#include "media-select.h"
 #include "rotate-label-button.h"
 
 #include "debug.h"
@@ -53,10 +53,10 @@ struct _glNewLabelDialogPrivate {
 /* Local function prototypes                 */
 /*===========================================*/
 
-static void       gl_new_label_dialog_finalize        (GObject               *object);
+static void       gl_new_label_dialog_finalize        (GObject           *object);
 
-static void       template_changed_cb                 (glWdgtMediaSelect     *select,
-                                                      gpointer               data);
+static void       template_changed_cb                 (glMediaSelect     *select,
+                                                      gpointer           data);
 
 
 /*****************************************************************************/
@@ -118,7 +118,7 @@ gl_new_label_dialog_init (glNewLabelDialog *dialog)
         gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_NONE);
        gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, GL_HIG_PAD1);
 
-       dialog->priv->media_select = gl_wdgt_media_select_new ();
+       dialog->priv->media_select = gl_media_select_new ();
         gtk_container_add (GTK_CONTAINER (frame), dialog->priv->media_select);
 
         label = gtk_label_new (_("<b>Label orientation</b>"));
@@ -132,7 +132,7 @@ gl_new_label_dialog_init (glNewLabelDialog *dialog)
         gtk_container_add (GTK_CONTAINER (frame), dialog->priv->rotate_label);
 
        /* Sync template name from media select with rotate widget. */
-       name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
+       name = gl_media_select_get_name (GL_MEDIA_SELECT (dialog->priv->media_select));
        gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
                                                   name);
 
@@ -188,15 +188,15 @@ gl_new_label_dialog_new (GtkWindow    *win)
 /* PRIVATE.  New template changed callback.                                  */
 /*---------------------------------------------------------------------------*/
 static void
-template_changed_cb (glWdgtMediaSelect *select,
-                    gpointer           data)
+template_changed_cb (glMediaSelect *select,
+                    gpointer       data)
 {
        glNewLabelDialog  *dialog = GL_NEW_LABEL_DIALOG (data);
        gchar             *name;
 
        gl_debug (DEBUG_FILE, "START");
 
-       name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (select));
+       name = gl_media_select_get_name (GL_MEDIA_SELECT (select));
 
        gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (dialog->priv->rotate_label),
                                                   name);
@@ -219,7 +219,7 @@ gl_new_label_dialog_get_template_name (glNewLabelDialog *dialog)
 {
        gchar *name;
 
-       name = gl_wdgt_media_select_get_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select));
+       name = gl_media_select_get_name (GL_MEDIA_SELECT (dialog->priv->media_select));
 
        return name;
 }
@@ -232,7 +232,7 @@ void
 gl_new_label_dialog_set_template_name (glNewLabelDialog *dialog,
                                       gchar            *name)
 {
-       gl_wdgt_media_select_set_name (GL_WDGT_MEDIA_SELECT (dialog->priv->media_select), name);
+       gl_media_select_set_name (GL_MEDIA_SELECT (dialog->priv->media_select), name);
 }
 
 
@@ -240,12 +240,12 @@ gl_new_label_dialog_set_template_name (glNewLabelDialog *dialog,
 /* Get current filter parameters.                                            */
 /*****************************************************************************/
 void
-gl_new_label_dialog_get_filter_parameters (glNewLabelDialog *dialog,
-                                          gchar           **page_size_id,
-                                          gchar           **category_id)
+gl_new_label_dialog_get_filter_parameters (glNewLabelDialog  *dialog,
+                                          gchar            **page_size_id,
+                                          gchar            **category_id)
 {
-       gl_wdgt_media_select_get_filter_parameters (
-               GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
+       gl_media_select_get_filter_parameters (
+               GL_MEDIA_SELECT (dialog->priv->media_select),
                page_size_id, category_id);
 }
 
@@ -258,8 +258,8 @@ gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *dialog,
                                           const gchar      *page_size_id,
                                           const gchar      *category_id)
 {
-       gl_wdgt_media_select_set_filter_parameters (
-               GL_WDGT_MEDIA_SELECT (dialog->priv->media_select),
+       gl_media_select_set_filter_parameters (
+               GL_MEDIA_SELECT (dialog->priv->media_select),
                page_size_id, category_id);
 }
 
diff --git a/src/wdgt-media-select.c b/src/wdgt-media-select.c
deleted file mode 100644 (file)
index 0cf1adf..0000000
+++ /dev/null
@@ -1,911 +0,0 @@
-/*
- *  wdgt-media-select.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 "wdgt-media-select.h"
-
-#include <glib/gi18n.h>
-#include <gtk/gtk.h>
-#include <string.h>
-
-#include <libglabels/libglabels.h>
-#include "mini-preview-pixbuf-cache.h"
-#include "prefs.h"
-#include "template-history.h"
-#include "str-util.h"
-#include "combo-util.h"
-#include "builder-util.h"
-#include "color.h"
-#include "marshal.h"
-
-#include "debug.h"
-
-
-#define HISTORY_SIZE 5
-
-/*===========================================*/
-/* Private types                             */
-/*===========================================*/
-
-enum {
-       NAME_COLUMN,
-       PREVIEW_COLUMN,
-       PREVIEW_COLUMN_STOCK,
-       PREVIEW_COLUMN_STOCK_SIZE,
-       DESCRIPTION_COLUMN,
-       N_COLUMNS
-};
-
-struct _glWdgtMediaSelectPrivate {
-
-        GtkBuilder   *builder;
-
-        GtkWidget    *notebook;
-        guint         current_page_num;
-
-        gint          recent_page_num;
-        GtkWidget    *recent_tab_vbox;
-        GtkWidget    *recent_treeview;
-        GtkListStore *recent_store;
-
-        gint          search_all_page_num;
-        GtkWidget    *search_all_tab_vbox;
-        GtkWidget    *brand_combo;
-        GtkWidget    *page_size_combo;
-        GtkWidget    *category_combo;
-        GtkWidget    *search_all_treeview;
-        GtkListStore *search_all_store;
-
-        /* Prevent recursion */
-       gboolean    stop_signals;
-};
-
-enum {
-        CHANGED,
-        LAST_SIGNAL
-};
-
-typedef void (*glWdgtMediaSelectSignal) (GObject * object, gpointer data);
-
-
-/*===========================================*/
-/* Private globals                           */
-/*===========================================*/
-
-static gint wdgt_media_select_signals[LAST_SIGNAL] = { 0 };
-
-
-/*===========================================*/
-/* Local function prototypes                 */
-/*===========================================*/
-
-static void gl_wdgt_media_select_finalize      (GObject                *object);
-
-static void gl_wdgt_media_select_construct     (glWdgtMediaSelect      *media_select);
-
-static void filter_changed_cb                  (GtkComboBox            *combo,
-                                                gpointer                user_data);
-static void selection_changed_cb               (GtkTreeSelection       *selection,
-                                                gpointer                user_data);
-static void page_changed_cb                    (GtkNotebook            *notebook,
-                                                GtkNotebookPage        *page,
-                                                guint                   page_num,
-                                                gpointer                user_data);
-
-static gchar *get_layout_desc                  (const lglTemplate      *template);
-static gchar *get_label_size_desc              (const lglTemplate      *template);
-static void   load_recent_list                 (GtkListStore           *store,
-                                                GtkTreeSelection       *selection,
-                                                GList                  *list);
-static void   load_search_all_list             (GtkListStore           *store,
-                                                GtkTreeSelection       *selection,
-                                                GList                  *list);
-
-
-/****************************************************************************/
-/* Boilerplate Object stuff.                                                */
-/****************************************************************************/
-G_DEFINE_TYPE (glWdgtMediaSelect, gl_wdgt_media_select, GTK_TYPE_VBOX);
-
-
-static void
-gl_wdgt_media_select_class_init (glWdgtMediaSelectClass *class)
-{
-        GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        gl_wdgt_media_select_parent_class = g_type_class_peek_parent (class);
-
-        object_class->finalize = gl_wdgt_media_select_finalize;
-
-        wdgt_media_select_signals[CHANGED] =
-            g_signal_new ("changed",
-                          G_OBJECT_CLASS_TYPE(object_class),
-                          G_SIGNAL_RUN_LAST,
-                          G_STRUCT_OFFSET (glWdgtMediaSelectClass, changed),
-                          NULL, NULL,
-                          gl_marshal_VOID__VOID,
-                          G_TYPE_NONE, 0);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-static void
-gl_wdgt_media_select_init (glWdgtMediaSelect *media_select)
-{
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        media_select->priv = g_new0 (glWdgtMediaSelectPrivate, 1);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-static void
-gl_wdgt_media_select_finalize (GObject *object)
-{
-        glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (object);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        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);
-
-        G_OBJECT_CLASS (gl_wdgt_media_select_parent_class)->finalize (object);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-GtkWidget *
-gl_wdgt_media_select_new (void)
-{
-        glWdgtMediaSelect *media_select;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        media_select = g_object_new (gl_wdgt_media_select_get_type (), NULL);
-
-        gl_wdgt_media_select_construct (media_select);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-
-        return GTK_WIDGET (media_select);
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Construct composite widget.                                    */
-/*--------------------------------------------------------------------------*/
-static void
-gl_wdgt_media_select_construct (glWdgtMediaSelect *media_select)
-{
-        GtkBuilder        *builder;
-        static gchar      *object_ids[] = { "wdgt_media_select_hbox", NULL };
-        GError            *error = NULL;
-        GtkWidget         *hbox;
-        GList             *recent_list = NULL;
-        GList             *brands = NULL;
-        GList             *page_sizes = NULL;
-        GList             *categories = NULL;
-        GList             *search_all_names = NULL;
-        const gchar       *page_size_id;
-        gchar             *page_size_name;
-        GtkCellRenderer   *renderer;
-        GtkTreeViewColumn *column;
-        GtkTreeSelection  *recent_selection;
-        GtkTreeSelection  *search_all_selection;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        g_return_if_fail (GL_IS_WDGT_MEDIA_SELECT (media_select));
-        g_return_if_fail (media_select->priv != 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);
-
-        gtk_container_add (GTK_CONTAINER (media_select), hbox);
-        media_select->priv->builder = builder;
-
-        media_select->priv->recent_page_num =
-                gtk_notebook_page_num (GTK_NOTEBOOK (media_select->priv->notebook),
-                                       media_select->priv->recent_tab_vbox);
-        media_select->priv->search_all_page_num =
-                gtk_notebook_page_num (GTK_NOTEBOOK (media_select->priv->notebook),
-                                       media_select->priv->search_all_tab_vbox);
-
-        /* Recent templates treeview */
-        media_select->priv->recent_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
-        gtk_tree_view_set_model (GTK_TREE_VIEW (media_select->priv->recent_treeview),
-                                 GTK_TREE_MODEL (media_select->priv->recent_store));
-        renderer = gtk_cell_renderer_pixbuf_new ();
-        column = gtk_tree_view_column_new_with_attributes ("", renderer,
-                                                           "pixbuf", PREVIEW_COLUMN,
-                                                           "stock-id", PREVIEW_COLUMN_STOCK,
-                                                           "stock-size", PREVIEW_COLUMN_STOCK_SIZE,
-                                                           NULL);
-        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-        gtk_tree_view_append_column (GTK_TREE_VIEW (media_select->priv->recent_treeview), column);
-        renderer = gtk_cell_renderer_text_new ();
-        column = gtk_tree_view_column_new_with_attributes ("", renderer,
-                                                           "markup", DESCRIPTION_COLUMN,
-                                                           NULL);
-        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-        gtk_tree_view_append_column (GTK_TREE_VIEW (media_select->priv->recent_treeview), column);
-        recent_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (media_select->priv->recent_treeview));
-        recent_list = gl_template_history_model_get_name_list (gl_template_history);
-        load_recent_list (media_select->priv->recent_store, recent_selection, recent_list);
-
-        page_size_id = gl_prefs_model_get_default_page_size (gl_prefs);
-        page_size_name = lgl_db_lookup_paper_name_from_id (page_size_id);
-
-        /* Brand selection control */
-        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_combo_util_set_strings (GTK_COMBO_BOX (media_select->priv->brand_combo), brands);
-        lgl_db_free_brand_list (brands);
-        gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->brand_combo),
-                                       _("Any"));
-
-        /* Page size selection control */
-        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_combo_util_set_strings (GTK_COMBO_BOX (media_select->priv->page_size_combo), page_sizes);
-        lgl_db_free_paper_name_list (page_sizes);
-        gl_combo_util_set_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo),
-                                       page_size_name);
-
-        /* Category selection control */
-        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_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 */
-        media_select->priv->search_all_store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_STRING);
-        gtk_tree_view_set_model (GTK_TREE_VIEW (media_select->priv->search_all_treeview),
-                                 GTK_TREE_MODEL (media_select->priv->search_all_store));
-        renderer = gtk_cell_renderer_pixbuf_new ();
-        column = gtk_tree_view_column_new_with_attributes ("", renderer,
-                                                           "pixbuf", PREVIEW_COLUMN,
-                                                           "stock-id", PREVIEW_COLUMN_STOCK,
-                                                           "stock-size", PREVIEW_COLUMN_STOCK_SIZE,
-                                                           NULL);
-        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-        gtk_tree_view_append_column (GTK_TREE_VIEW (media_select->priv->search_all_treeview), column);
-        renderer = gtk_cell_renderer_text_new ();
-        column = gtk_tree_view_column_new_with_attributes ("", renderer,
-                                                           "markup", DESCRIPTION_COLUMN,
-                                                           NULL);
-        gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
-        gtk_tree_view_append_column (GTK_TREE_VIEW (media_select->priv->search_all_treeview), column);
-        search_all_selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (media_select->priv->search_all_treeview));
-        search_all_names = lgl_db_get_template_name_list_all (NULL, page_size_id, NULL);
-        load_search_all_list (media_select->priv->search_all_store, search_all_selection, search_all_names);
-        lgl_db_free_template_name_list (search_all_names);
-
-        /* Connect signals to controls */
-        g_signal_connect (G_OBJECT (media_select->priv->brand_combo), "changed",
-                          G_CALLBACK (filter_changed_cb),
-                          media_select);
-        g_signal_connect (G_OBJECT (media_select->priv->page_size_combo), "changed",
-                          G_CALLBACK (filter_changed_cb),
-                          media_select);
-        g_signal_connect (G_OBJECT (media_select->priv->category_combo), "changed",
-                          G_CALLBACK (filter_changed_cb),
-                          media_select);
-        g_signal_connect (G_OBJECT (recent_selection), "changed",
-                          G_CALLBACK (selection_changed_cb),
-                          media_select);
-        g_signal_connect (G_OBJECT (search_all_selection), "changed",
-                          G_CALLBACK (selection_changed_cb),
-                          media_select);
-        g_signal_connect (G_OBJECT (media_select->priv->notebook), "switch-page",
-                          G_CALLBACK (page_changed_cb),
-                          media_select);
-
-        g_free (page_size_name);
-
-        gtk_widget_show_all (GTK_WIDGET (media_select));
-        if ( recent_list )
-        {
-                gtk_notebook_set_current_page (GTK_NOTEBOOK (media_select->priv->notebook),
-                                               media_select->priv->recent_page_num);
-        }
-        else
-        {
-                gtk_notebook_set_current_page (GTK_NOTEBOOK (media_select->priv->notebook),
-                                               media_select->priv->search_all_page_num);
-        }
-        gl_template_history_model_free_name_list (recent_list);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  modify widget due to change in selection                       */
-/*--------------------------------------------------------------------------*/
-static void
-filter_changed_cb (GtkComboBox *combo,
-                   gpointer     user_data)
-{
-        glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (user_data);
-        gchar             *brand;
-        gchar             *page_size_name, *page_size_id;
-        gchar             *category_name, *category_id;
-        GList             *search_all_names;
-        GtkTreeSelection  *selection;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-
-       media_select->priv->stop_signals = TRUE;
-
-        /* Update template selections for new filter settings */
-        brand = gtk_combo_box_get_active_text (GTK_COMBO_BOX (media_select->priv->brand_combo));
-        page_size_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo));
-        category_name = gtk_combo_box_get_active_text (GTK_COMBO_BOX (media_select->priv->category_combo));
-        if ( brand && strlen(brand) &&
-             page_size_name && strlen(page_size_name) &&
-             category_name && strlen(category_name) )
-        {
-                gl_debug (DEBUG_MEDIA_SELECT, "brand = \"%s\"", brand);
-                gl_debug (DEBUG_MEDIA_SELECT, "page_size_name = \"%s\"", page_size_name);
-                gl_debug (DEBUG_MEDIA_SELECT, "category_name = \"%s\"", category_name);
-                if (!g_utf8_collate (brand, _("Any")))
-                {
-                        g_free (brand);
-                        brand = NULL;
-                }
-                page_size_id = lgl_db_lookup_paper_id_from_name (page_size_name);
-                category_id = lgl_db_lookup_category_id_from_name (category_name);
-                gl_debug (DEBUG_MEDIA_SELECT, "page_size_id = \"%s\"", page_size_id);
-                gl_debug (DEBUG_MEDIA_SELECT, "category_id = \"%s\"", category_id);
-                search_all_names = lgl_db_get_template_name_list_all (brand, page_size_id, category_id);
-                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (media_select->priv->search_all_treeview));
-                load_search_all_list (media_select->priv->search_all_store, selection, search_all_names);
-                lgl_db_free_template_name_list (search_all_names);
-                g_free (page_size_id);
-                g_free (category_id);
-
-                /* Emit our "changed" signal */
-                g_signal_emit (G_OBJECT (user_data),
-                               wdgt_media_select_signals[CHANGED], 0);
-        }
-        g_free (brand);
-        g_free (page_size_name);
-        g_free (category_name);
-
-
-       media_select->priv->stop_signals = FALSE;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  modify widget due to change in selection                       */
-/*--------------------------------------------------------------------------*/
-static void
-selection_changed_cb (GtkTreeSelection       *selection,
-                      gpointer                user_data)
-{
-        glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (user_data);
-
-       if (media_select->priv->stop_signals) return;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        /* Emit our "changed" signal */
-        g_signal_emit (G_OBJECT (user_data),
-                       wdgt_media_select_signals[CHANGED], 0);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  modify widget due to change in selection                       */
-/*--------------------------------------------------------------------------*/
-static void
-page_changed_cb (GtkNotebook            *notebook,
-                 GtkNotebookPage        *page,
-                 guint                   page_num,
-                 gpointer                user_data)
-{
-        glWdgtMediaSelect *media_select = GL_WDGT_MEDIA_SELECT (user_data);
-
-       if (media_select->priv->stop_signals) return;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        /*
-         * Store new current page, because this signal is emitted before the actual page change.
-         */
-       media_select->priv->current_page_num = page_num;
-
-        /* Emit our "changed" signal */
-        g_signal_emit (G_OBJECT (user_data),
-                       wdgt_media_select_signals[CHANGED], 0);
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-/****************************************************************************/
-/* query selected label template name.                                      */
-/****************************************************************************/
-gchar *
-gl_wdgt_media_select_get_name (glWdgtMediaSelect *media_select)
-{
-        gint               page_num;
-        GtkTreeSelection  *selection;
-        GtkTreeIter        iter;
-        GtkTreeModel      *model;        
-        gchar             *name;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        page_num = media_select->priv->current_page_num;
-        if (page_num == media_select->priv->recent_page_num)
-        {
-                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (media_select->priv->recent_treeview));
-        }
-        else if (page_num == media_select->priv->search_all_page_num)
-        {
-                selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (media_select->priv->search_all_treeview));
-        }
-        else
-        {
-                g_print ("notebook page = %d\n", page_num);
-                g_assert_not_reached ();
-        }
-
-        if (gtk_tree_selection_get_mode (selection) == GTK_SELECTION_NONE)
-        {
-                name = NULL;
-        }
-        else
-        {
-                gtk_tree_selection_get_selected (selection, &model, &iter);
-                gtk_tree_model_get (model, &iter, NAME_COLUMN, &name, -1);
-        }
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-        return name;
-}
-
-
-/****************************************************************************/
-/* set selected label template name.                                        */
-/****************************************************************************/
-void
-gl_wdgt_media_select_set_name (glWdgtMediaSelect *media_select,
-                               gchar             *name)
-{
-        GtkTreeSelection  *selection;
-        GtkTreeModel      *model;
-        GtkTreeIter        iter;
-        GtkTreePath       *path;
-        gchar             *name_i;
-        gboolean           flag;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (media_select->priv->search_all_treeview));
-        g_return_if_fail (GTK_IS_TREE_SELECTION (selection));
-
-        model = GTK_TREE_MODEL (media_select->priv->search_all_store);
-
-        for ( flag = gtk_tree_model_get_iter_first (model, &iter);
-              flag;
-              flag = gtk_tree_model_iter_next(model, &iter) )
-        {
-                gtk_tree_model_get (model, &iter, NAME_COLUMN, &name_i, -1); 
-                if (strcasecmp(name, name_i) == 0)
-                {
-                        gtk_tree_selection_select_iter (selection, &iter);
-                        path = gtk_tree_model_get_path (model, &iter);
-                        gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (media_select->priv->search_all_treeview),
-                                                      path,
-                                                      NULL,
-                                                      TRUE, 0.5, 0.0);
-                        gtk_tree_path_free (path);
-                        break;
-                }
-        }
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-/****************************************************************************/
-/* query current filter parameters.                                         */
-/****************************************************************************/
-void
-gl_wdgt_media_select_get_filter_parameters (glWdgtMediaSelect *media_select,
-                                            gchar            **page_size_id,
-                                            gchar            **category_id)
-{
-        gchar *page_size_name, *category_name;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "");
-
-        g_free (*page_size_id);
-        g_free (*category_id);
-
-        page_size_name =
-                gtk_combo_box_get_active_text (GTK_COMBO_BOX (media_select->priv->page_size_combo));
-
-        *page_size_id = lgl_db_lookup_paper_id_from_name (page_size_name);
-
-        category_name =
-                gtk_combo_box_get_active_text (GTK_COMBO_BOX (media_select->priv->category_combo));
-
-        *category_id = lgl_db_lookup_category_id_from_name (category_name);
-
-        g_free (page_size_name);
-        g_free (category_name);
-}
-
-
-/****************************************************************************/
-/* set filter parameters.                                                   */
-/****************************************************************************/
-void
-gl_wdgt_media_select_set_filter_parameters (glWdgtMediaSelect *media_select,
-                                            const gchar       *page_size_id,
-                                            const gchar       *category_id)
-{
-        gchar *page_size_name;
-        gchar *category_name;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        page_size_name = lgl_db_lookup_paper_name_from_id (page_size_id);
-        if (page_size_name == NULL)
-        {
-                page_size_name = g_strdup (_("Any"));
-        }
-
-        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_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.          */
-/*--------------------------------------------------------------------------*/
-static gchar *
-get_layout_desc (const lglTemplate *template)
-{
-        const lglTemplateFrame *frame;
-        gint                    n_labels;
-        gchar                  *string;
-
-        frame = (lglTemplateFrame *)template->frames->data;
-
-        n_labels = lgl_template_frame_get_n_labels (frame);
-
-        string = g_strdup_printf (_("%d per sheet"), n_labels);
-
-        return string;
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Get label size description.                                    */ 
-/*--------------------------------------------------------------------------*/
-static gchar *
-get_label_size_desc (const lglTemplate *template)
-{
-        lglUnits                   units;
-        const gchar               *units_string;
-        gdouble                    units_per_point;
-        const lglTemplateFrame    *frame;
-        gchar                     *string = NULL;
-
-        units           = gl_prefs_model_get_units (gl_prefs);
-        units_string    = lgl_units_get_name (units);
-        units_per_point = lgl_units_get_units_per_point (units);
-
-        frame = (lglTemplateFrame *)template->frames->data;
-
-        switch (frame->shape) {
-        case LGL_TEMPLATE_FRAME_SHAPE_RECT:
-                if ( units == LGL_UNITS_INCH ) {
-                        gchar *xstr, *ystr;
-
-                        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 × %s %s",
-                                                  xstr, ystr, units_string);
-                        g_free (xstr);
-                        g_free (ystr);
-                } else {
-                        string = g_strdup_printf ("%.5g × %.5g %s",
-                                                  frame->rect.w*units_per_point,
-                                                  frame->rect.h*units_per_point,
-                                                  units_string);
-                }
-                break;
-        case LGL_TEMPLATE_FRAME_SHAPE_ROUND:
-                if ( units == LGL_UNITS_INCH ) {
-                        gchar *dstr;
-
-                        dstr = gl_str_util_fraction_to_string (2.0*frame->round.r*units_per_point);
-                        string = g_strdup_printf ("%s %s %s",
-                                                  dstr, units_string,
-                                                  _("diameter"));
-                        g_free (dstr);
-                } else {
-                        string = g_strdup_printf ("%.5g %s %s",
-                                                  2.0*frame->round.r*units_per_point,
-                                                  units_string,
-                                                  _("diameter"));
-                }
-                break;
-        case LGL_TEMPLATE_FRAME_SHAPE_CD:
-                if ( units == LGL_UNITS_INCH ) {
-                        gchar *dstr;
-
-                        dstr = gl_str_util_fraction_to_string (2.0*frame->cd.r1*units_per_point);
-                        string = g_strdup_printf ("%s %s %s",
-                                                  dstr, units_string,
-                                                  _("diameter"));
-                        g_free (dstr);
-                } else {
-                        string = g_strdup_printf ("%.5g %s %s",
-                                                  2.0*frame->cd.r1*units_per_point,
-                                                  units_string,
-                                                  _("diameter"));
-                }
-                break;
-        default:
-                break;
-        }
-
-        return string;
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Load list store from template name list.                       */
-/*--------------------------------------------------------------------------*/
-static void
-load_recent_list (GtkListStore           *store,
-                  GtkTreeSelection       *selection,
-                  GList                  *list)
-{
-        GList       *p;
-        GtkTreeIter  iter;
-        lglTemplate *template;
-        GdkPixbuf   *pixbuf;
-        gchar       *size;
-        gchar       *layout;
-        gchar       *description;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        gtk_list_store_clear (store);
-
-        if (list)
-        {
-
-                for ( p=list; p!=NULL; p=p->next )
-                {
-
-                        gl_debug (DEBUG_MEDIA_SELECT, "p->data = \"%s\"", p->data);
-
-                        template = lgl_db_lookup_template_from_name (p->data);
-                        pixbuf = gl_mini_preview_pixbuf_cache_get_pixbuf (p->data);
-
-                        size = get_label_size_desc (template);
-                        layout = get_layout_desc (template);
-                        description = g_strdup_printf ("<b>%s: %s</b>\n%s\n%s",
-                                                       (gchar *)p->data,
-                                                       template->description,
-                                                       size,
-                                                       layout);
-                        g_free (size);
-                        g_free (layout);
-
-                        lgl_template_free (template);
-
-                        gtk_list_store_append (store, &iter);
-                        gtk_list_store_set (store, &iter,
-                                            NAME_COLUMN, p->data,
-                                            PREVIEW_COLUMN, pixbuf,
-                                            DESCRIPTION_COLUMN, description,
-                                            -1);
-
-                        g_object_unref (G_OBJECT (pixbuf));
-                        g_free (description);
-                }
-
-                gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
-                gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
-                gtk_tree_selection_select_iter (selection, &iter);
-
-        }
-        else
-        {
-                gchar *text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n%s",
-                                               _("No recent templates found."),
-                                               _("Try selecting a template from the \"Search all templates\" page."));
-                gtk_list_store_append (store, &iter);
-                gtk_list_store_set (store, &iter,
-                                    NAME_COLUMN, "empty",
-                                    PREVIEW_COLUMN_STOCK, GTK_STOCK_DIALOG_WARNING,
-                                    PREVIEW_COLUMN_STOCK_SIZE, GTK_ICON_SIZE_DIALOG,
-                                    DESCRIPTION_COLUMN, text,
-                                    -1);
-                g_free (text);
-
-                gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
-
-        }
-
-        gl_debug (DEBUG_MEDIA_SELECT, "END");
-}
-
-
-/*--------------------------------------------------------------------------*/
-/* PRIVATE.  Load list store from template name list.                       */
-/*--------------------------------------------------------------------------*/
-static void
-load_search_all_list (GtkListStore           *store,
-                      GtkTreeSelection       *selection,
-                      GList                  *list)
-{
-        GList       *p;
-        GtkTreeIter  iter;
-        lglTemplate *template;
-        GdkPixbuf   *pixbuf;
-        gchar       *size;
-        gchar       *layout;
-        gchar       *description;
-
-        gl_debug (DEBUG_MEDIA_SELECT, "START");
-
-        gtk_list_store_clear (store);
-
-        if (list)
-        {
-
-                for ( p=list; p!=NULL; p=p->next )
-                {
-
-                        gl_debug (DEBUG_MEDIA_SELECT, "p->data = \"%s\"", p->data);
-
-                        template = lgl_db_lookup_template_from_name (p->data);
-                        pixbuf = gl_mini_preview_pixbuf_cache_get_pixbuf (p->data);
-
-                        size = get_label_size_desc (template);
-                        layout = get_layout_desc (template);
-                        description = g_strdup_printf ("<b>%s: %s</b>\n%s\n%s",
-                                                       (gchar *)p->data,
-                                                       template->description,
-                                                       size,
-                                                       layout);
-                        g_free (size);
-                        g_free (layout);
-
-                        lgl_template_free (template);
-
-                        gtk_list_store_append (store, &iter);
-                        gtk_list_store_set (store, &iter,
-                                            NAME_COLUMN, p->data,
-                                            PREVIEW_COLUMN, pixbuf,
-                                            DESCRIPTION_COLUMN, description,
-                                            -1);
-
-                        g_object_unref (G_OBJECT (pixbuf));
-                        g_free (description);
-                }
-
-                gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE);
-                gtk_tree_model_get_iter_first (GTK_TREE_MODEL (store), &iter);
-                gtk_tree_selection_select_iter (selection, &iter);
-
-        }
-        else
-        {
-                gchar *text = g_strdup_printf ("<span weight=\"bold\" size=\"larger\">%s</span>\n%s",
-                                               _("No match."),
-                                               _("Try selecting a different brand, page size or category."));
-                gtk_list_store_append (store, &iter);
-                gtk_list_store_set (store, &iter,
-                                    NAME_COLUMN, "empty",
-                                    PREVIEW_COLUMN_STOCK, GTK_STOCK_DIALOG_WARNING,
-                                    PREVIEW_COLUMN_STOCK_SIZE, GTK_ICON_SIZE_DIALOG,
-                                    DESCRIPTION_COLUMN, text,
-                                    -1);
-                g_free (text);
-
-                gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE);
-
-        }
-
-        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
- */
diff --git a/src/wdgt-media-select.h b/src/wdgt-media-select.h
deleted file mode 100644 (file)
index f2c3007..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- *  wdgt-media-select.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 __WDGT_MEDIA_SELECT_H__
-#define __WDGT_MEDIA_SELECT_H__
-
-#include <gtk/gtk.h>
-
-G_BEGIN_DECLS
-
-#define GL_TYPE_WDGT_MEDIA_SELECT (gl_wdgt_media_select_get_type ())
-#define GL_WDGT_MEDIA_SELECT(obj) \
-        (G_TYPE_CHECK_INSTANCE_CAST((obj), GL_TYPE_WDGT_MEDIA_SELECT, glWdgtMediaSelect ))
-#define GL_WDGT_MEDIA_SELECT_CLASS(klass) \
-        (G_TYPE_CHECK_CLASS_CAST ((klass), GL_TYPE_WDGT_MEDIA_SELECT, glWdgtMediaSelectClass))
-#define GL_IS_WDGT_MEDIA_SELECT(obj) \
-        (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GL_TYPE_WDGT_MEDIA_SELECT))
-#define GL_IS_WDGT_MEDIA_SELECT_CLASS(klass) \
-        (G_TYPE_CHECK_CLASS_TYPE ((klass), GL_TYPE_WDGT_MEDIA_SELECT))
-
-typedef struct _glWdgtMediaSelect         glWdgtMediaSelect;
-typedef struct _glWdgtMediaSelectClass    glWdgtMediaSelectClass;
-
-typedef struct _glWdgtMediaSelectPrivate  glWdgtMediaSelectPrivate;
-
-struct _glWdgtMediaSelect {
-        GtkVBox                    parent_widget;
-
-        glWdgtMediaSelectPrivate  *priv;
-};
-
-struct _glWdgtMediaSelectClass {
-        GtkVBoxClass               parent_class;
-
-        void (*changed) (glWdgtMediaSelect * media_select, gpointer user_data);
-};
-
-GType      gl_wdgt_media_select_get_type      (void) G_GNUC_CONST;
-
-GtkWidget *gl_wdgt_media_select_new           (void);
-
-gchar     *gl_wdgt_media_select_get_name      (glWdgtMediaSelect *media_select);
-
-void       gl_wdgt_media_select_set_name      (glWdgtMediaSelect *media_select,
-                                               gchar             *name);
-
-void       gl_wdgt_media_select_get_filter_parameters (glWdgtMediaSelect *media_select,
-                                                       gchar            **page_size_id,
-                                                       gchar            **category_id);
-
-void       gl_wdgt_media_select_set_filter_parameters (glWdgtMediaSelect *media_select,
-                                                       const gchar       *page_size_id,
-                                                       const gchar       *category_id);
-
-G_END_DECLS
-
-#endif
-
-
-
-/*
- * Local Variables:       -- emacs
- * mode: C                -- emacs
- * c-basic-offset: 8      -- emacs
- * tab-width: 8           -- emacs
- * indent-tabs-mode: nil  -- emacs
- * End:                   -- emacs
- */