[glabels] Yet another new "New Label Dialog"
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels] Yet another new "New Label Dialog"
- Date: Sun, 21 Mar 2010 05:20:56 +0000 (UTC)
commit 0a83046c78acea94d80fe2aea239a220445410ab
Author: Jim Evins <evins snaught com>
Date: Sun Mar 21 01:14:35 2010 -0400
Yet another new "New Label Dialog"
Re-designed the "New label dialog" again. This time as a "wizard" or
GtkAssistant. This is an attempt to keep the easy navigation of the
2.2.x dialog, to keep the added meta data and preview of the latest
incarnation, and to maintain a compact dialog that should work on fairly
small displays such on netbooks (probably not hand-helds still).
data/builder/Makefile.am | 1 +
data/builder/media-select.builder | 229 +++++++++
data/builder/new-label-dialog.builder | 628 +++++++++++++++----------
po/POTFILES.in | 10 +-
src/Makefile.am | 10 +-
src/file.c | 115 ++---
src/media-combo-menu-item.c | 178 -------
src/media-combo-menu-item.h | 75 ---
src/media-combo-menu.c | 332 -------------
src/media-combo-menu.h | 83 ----
src/media-combo.c | 345 --------------
src/media-combo.h | 84 ----
src/media-select.c | 847 +++++++++++++++++++++++++++++++++
src/media-select.h | 87 ++++
src/new-label-dialog.c | 275 ++++++++----
src/new-label-dialog.h | 6 +-
src/rotate-label-button.c | 261 ----------
src/rotate-label-button.h | 83 ----
18 files changed, 1779 insertions(+), 1870 deletions(-)
---
diff --git a/data/builder/Makefile.am b/data/builder/Makefile.am
index 4b48a69..1c8744d 100644
--- a/data/builder/Makefile.am
+++ b/data/builder/Makefile.am
@@ -5,6 +5,7 @@ builderdir = $(datadir)/$(GLABELS_BRANCH)/builder/
builder_DATA = \
property-bar.builder \
print-op-dialog-custom-widget.builder \
+ media-select.builder \
new-label-dialog.builder \
merge-properties-dialog.builder \
template-designer.builder \
diff --git a/data/builder/media-select.builder b/data/builder/media-select.builder
new file mode 100644
index 0000000..9cb814f
--- /dev/null
+++ b/data/builder/media-select.builder
@@ -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="tab_hborder">0</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/new-label-dialog.builder b/data/builder/new-label-dialog.builder
index e591410..9f3f5d0 100644
--- a/data/builder/new-label-dialog.builder
+++ b/data/builder/new-label-dialog.builder
@@ -9,356 +9,474 @@
<property name="border_width">6</property>
<property name="spacing">18</property>
<child>
- <object class="GtkVBox" id="vbox1">
+ <object class="GtkNotebook" id="notebook2">
<property name="visible">True</property>
- <property name="orientation">vertical</property>
- <property name="spacing">6</property>
+ <property name="can_focus">True</property>
<child>
- <object class="GtkFrame" id="frame1">
+ <object class="GtkVBox" id="template_page_vbox">
<property name="visible">True</property>
- <property name="label_xalign">0</property>
- <property name="shadow_type">none</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label19">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Choose label or card product from hundreds of predefined templates. You may also
+define your own templates.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="combo_hbox">
+ <property name="visible">True</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ <child type="tab">
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">page 1</property>
+ </object>
+ <packing>
+ <property name="tab_fill">False</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkVBox" id="rotate_page_vbox">
+ <property name="visible">True</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label10">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Select orientation of label content.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
- <object class="GtkAlignment" id="alignment1">
+ <object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
- <property name="left_padding">12</property>
+ <property name="homogeneous">True</property>
<child>
- <object class="GtkTable" id="table2">
+ <object class="GtkVBox" id="vbox1">
<property name="visible">True</property>
- <property name="n_rows">2</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkLabel" id="label6">
+ <object class="GtkHBox" id="normal_preview_hbox">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Template:</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="x_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="combo_hbox">
+ <object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
- <placeholder/>
+ <object class="GtkRadioButton" id="normal_radio">
+ <property name="label" translatable="yes">Normal</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
+ <property name="expand">False</property>
+ <property name="fill">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="GtkVBox" id="vbox2">
+ <property name="visible">True</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkLabel" id="label12">
+ <object class="GtkHBox" id="rotated_preview_hbox">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Orientation:</property>
+ <child>
+ <placeholder/>
+ </child>
</object>
<packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkHBox" id="rotate_hbox">
+ <object class="GtkHBox" id="hbox5">
<property name="visible">True</property>
<child>
- <placeholder/>
+ <object class="GtkRadioButton" id="rotated_radio">
+ <property name="label" translatable="yes">Rotated</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">normal_radio</property>
+ </object>
+ <packing>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
</child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
- </child>
- <child type="label">
- <object class="GtkLabel" id="label9">
- <property name="visible">True</property>
- <property name="label" translatable="yes"><b>Select media</b></property>
- <property name="use_markup">True</property>
- </object>
+ <packing>
+ <property name="fill">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>
+ <property name="position">1</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkNotebook" id="notebook1">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <child>
- <object class="GtkVBox" id="preview_vbox">
- <property name="visible">True</property>
- <property name="border_width">3</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
- </object>
- </child>
<child type="tab">
- <object class="GtkLabel" id="label13">
+ <object class="GtkLabel" id="label9">
<property name="visible">True</property>
- <property name="label" translatable="yes">Preview</property>
+ <property name="label" translatable="yes">page 2</property>
</object>
<packing>
+ <property name="position">1</property>
<property name="tab_fill">False</property>
</packing>
</child>
<child>
- <object class="GtkVBox" id="vbox2">
+ <object class="GtkVBox" id="confirm_page_vbox">
<property name="visible">True</property>
- <property name="border_width">9</property>
+ <property name="border_width">6</property>
<property name="orientation">vertical</property>
+ <property name="spacing">12</property>
<child>
- <object class="GtkTable" id="table1">
+ <object class="GtkLabel" id="label11">
<property name="visible">True</property>
- <property name="n_rows">7</property>
- <property name="n_columns">2</property>
- <property name="column_spacing">12</property>
- <property name="row_spacing">6</property>
- <child>
- <object class="GtkLabel" id="label1">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Description:</property>
- </object>
- <packing>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label2">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Page size:</property>
- </object>
- <packing>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label3">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Label size:</property>
- </object>
- <packing>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label4">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Layout:</property>
- </object>
- <packing>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label7">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">Similar products:</property>
- </object>
- <packing>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="desc_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">2</property>
- <property name="bottom_attach">3</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="page_size_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label_size_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">4</property>
- <property name="bottom_attach">5</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="layout_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">5</property>
- <property name="bottom_attach">6</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="vendor_label">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- </object>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label8">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Part #:</property>
- </object>
- <packing>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
- <property name="x_options">GTK_FILL</property>
- </packing>
- </child>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Please review and confirm your selection.</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkHBox" id="hbox3">
+ <property name="visible">True</property>
+ <property name="spacing">24</property>
<child>
- <object class="GtkLabel" id="part_label">
+ <object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
- <property name="xalign">0</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkVBox" id="preview_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>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">1</property>
- <property name="bottom_attach">2</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkScrolledWindow" id="scrolledwindow1">
- <property name="height_request">77</property>
+ <object class="GtkTable" id="table1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="hscrollbar_policy">never</property>
- <property name="vscrollbar_policy">automatic</property>
- <property name="shadow_type">in</property>
+ <property name="n_rows">7</property>
+ <property name="n_columns">2</property>
+ <property name="column_spacing">12</property>
+ <property name="row_spacing">6</property>
+ <child>
+ <object class="GtkLabel" id="label1">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Description:</property>
+ </object>
+ <packing>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label2">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Page size:</property>
+ </object>
+ <packing>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label3">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Label size:</property>
+ </object>
+ <packing>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
<child>
- <object class="GtkViewport" id="viewport1">
+ <object class="GtkLabel" id="label4">
<property name="visible">True</property>
- <property name="resize_mode">queue</property>
- <property name="shadow_type">none</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Layout:</property>
+ </object>
+ <packing>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label7">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">Similar products:</property>
+ </object>
+ <packing>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options">GTK_FILL</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="desc_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">2</property>
+ <property name="bottom_attach">3</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="page_size_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">3</property>
+ <property name="bottom_attach">4</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label_size_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">4</property>
+ <property name="bottom_attach">5</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="layout_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">5</property>
+ <property name="bottom_attach">6</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="vendor_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label8">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Part #:</property>
+ </object>
+ <packing>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="part_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ </object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">1</property>
+ <property name="bottom_attach">2</property>
+ <property name="y_options"></property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow1">
+ <property name="height_request">77</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="vscrollbar_policy">automatic</property>
<child>
- <object class="GtkLabel" id="similar_label">
+ <object class="GtkViewport" id="viewport1">
<property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="yalign">0</property>
- <property name="label" translatable="yes">1
+ <property name="resize_mode">queue</property>
+ <property name="shadow_type">etched-in</property>
+ <child>
+ <object class="GtkLabel" id="similar_label">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="yalign">0</property>
+ <property name="label" translatable="yes">1
2
3
4</property>
+ </object>
+ </child>
</object>
</child>
</object>
+ <packing>
+ <property name="left_attach">1</property>
+ <property name="right_attach">2</property>
+ <property name="top_attach">6</property>
+ <property name="bottom_attach">7</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="xalign">0</property>
+ <property name="label" translatable="yes">Vendor:</property>
+ </object>
+ <packing>
+ <property name="x_options">GTK_FILL</property>
+ <property name="y_options"></property>
+ </packing>
</child>
</object>
<packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">6</property>
- <property name="bottom_attach">7</property>
- <property name="y_options"></property>
- </packing>
- </child>
- <child>
- <object class="GtkLabel" id="label5">
- <property name="visible">True</property>
- <property name="xalign">0</property>
- <property name="label" translatable="yes">Vendor:</property>
- </object>
- <packing>
- <property name="x_options">GTK_FILL</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>
+ <property name="position">1</property>
</packing>
</child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
</packing>
</child>
<child type="tab">
- <object class="GtkLabel" id="label14">
+ <object class="GtkLabel" id="label18">
<property name="visible">True</property>
- <property name="label" translatable="yes">Information</property>
+ <property name="label" translatable="yes">page 3</property>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">2</property>
<property name="tab_fill">False</property>
</packing>
</child>
- <child>
- <placeholder/>
- </child>
- <child type="tab">
- <placeholder/>
- </child>
</object>
<packing>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 1c35ca9..24ce7cd 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -81,12 +81,8 @@ src/label-text.c
src/label-text.h
#src/marshal.c
#src/marshal.h
-src/media-combo.c
-src/media-combo.h
-src/media-combo-menu.c
-src/media-combo-menu.h
-src/media-combo-menu-item.c
-src/media-combo-menu-item.h
+src/media-select.c
+src/media-select.h
src/merge.c
src/merge.h
src/merge-evolution.c
@@ -141,8 +137,6 @@ src/message-bar.c
src/message-bar.h
src/recent.c
src/recent.h
-src/rotate-label-button.c
-src/rotate-label-button.h
src/stock.c
src/stock.h
src/str-util.c
diff --git a/src/Makefile.am b/src/Makefile.am
index 49e6e0e..9c9f5f1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -162,12 +162,8 @@ glabels_3_SOURCES = \
mini-preview-pixbuf.h \
mini-preview-pixbuf-cache.c \
mini-preview-pixbuf-cache.h \
- media-combo.c \
- media-combo.h \
- media-combo-menu.c \
- media-combo-menu.h \
- media-combo-menu-item.c \
- media-combo-menu-item.h \
+ media-select.c \
+ media-select.h \
message-bar.c \
message-bar.h \
template-history.c \
@@ -178,8 +174,6 @@ glabels_3_SOURCES = \
mini-preview.h \
mini-label-preview.c \
mini-label-preview.h \
- rotate-label-button.c \
- rotate-label-button.h \
wdgt-chain-button.c \
wdgt-chain-button.h \
field-button.c \
diff --git a/src/file.c b/src/file.c
index ca04e5f..2b49053 100644
--- a/src/file.c
+++ b/src/file.c
@@ -54,12 +54,10 @@ static gchar *save_path = NULL;
/*===========================================*/
/* Local function prototypes. */
/*===========================================*/
-static void new_response (GtkDialog *dialog,
- gint response,
+static void new_complete (GtkDialog *dialog,
gpointer user_data);
-static void properties_response (GtkDialog *dialog,
- gint response,
+static void properties_complete (GtkDialog *dialog,
gpointer user_data);
static void open_response (GtkDialog *chooser,
@@ -87,8 +85,7 @@ gl_file_new (glWindow *window)
g_object_set_data (G_OBJECT (dialog), "parent_window", window);
- g_signal_connect (G_OBJECT(dialog), "response",
- G_CALLBACK (new_response), dialog);
+ g_signal_connect (G_OBJECT(dialog), "complete", G_CALLBACK (new_complete), dialog);
if (page_size != NULL) {
gl_new_label_dialog_set_filter_parameters (GL_NEW_LABEL_DIALOG (dialog),
@@ -112,8 +109,7 @@ gl_file_new (glWindow *window)
/* PRIVATE. New "ok" button callback. */
/*---------------------------------------------------------------------------*/
static void
-new_response (GtkDialog *dialog,
- gint response,
+new_complete (GtkDialog *dialog,
gpointer user_data)
{
lglTemplate *template;
@@ -123,48 +119,38 @@ new_response (GtkDialog *dialog,
gl_debug (DEBUG_FILE, "START");
- switch (response) {
-
- case GTK_RESPONSE_OK:
+ gl_new_label_dialog_get_filter_parameters (GL_NEW_LABEL_DIALOG (dialog),
+ &page_size,
+ &category);
- gl_new_label_dialog_get_filter_parameters (GL_NEW_LABEL_DIALOG (dialog),
- &page_size,
- &category);
+ if (sheet_name != NULL)
+ {
+ g_free (sheet_name);
+ }
- if (sheet_name != NULL)
- g_free (sheet_name);
- sheet_name =
- gl_new_label_dialog_get_template_name (GL_NEW_LABEL_DIALOG (dialog));
+ sheet_name = gl_new_label_dialog_get_template_name (GL_NEW_LABEL_DIALOG (dialog));
- rotate_flag =
- gl_new_label_dialog_get_rotate_state (GL_NEW_LABEL_DIALOG (dialog));
+ rotate_flag = gl_new_label_dialog_get_rotate_state (GL_NEW_LABEL_DIALOG (dialog));
- template = lgl_db_lookup_template_from_name (sheet_name);
+ template = lgl_db_lookup_template_from_name (sheet_name);
- label = GL_LABEL(gl_label_new ());
- gl_label_set_template (label, template, FALSE);
- gl_label_set_rotate_flag (label, rotate_flag, FALSE);
+ label = GL_LABEL(gl_label_new ());
+ gl_label_set_template (label, template, FALSE);
+ gl_label_set_rotate_flag (label, rotate_flag, FALSE);
- lgl_template_free (template);
+ lgl_template_free (template);
- window =
- GL_WINDOW (g_object_get_data (G_OBJECT (dialog),
- "parent_window"));
- if ( gl_window_is_empty (window) ) {
- gl_window_set_label (window, label);
- } else {
- new_window = gl_window_new_from_label (label);
- gtk_widget_show_all (new_window);
- }
+ window = GL_WINDOW (g_object_get_data (G_OBJECT (dialog), "parent_window"));
+ if ( gl_window_is_empty (window) )
+ {
+ gl_window_set_label (window, label);
+ }
+ else
+ {
+ new_window = gl_window_new_from_label (label);
+ gtk_widget_show_all (new_window);
+ }
- break;
-
- default:
- break;
- }
-
- gtk_widget_destroy (GTK_WIDGET (dialog));
-
gl_debug (DEBUG_FILE, "END");
}
@@ -191,8 +177,7 @@ gl_file_properties (glLabel *label,
g_object_set_data (G_OBJECT (dialog), "label", label);
- g_signal_connect (G_OBJECT(dialog), "response",
- G_CALLBACK (properties_response), dialog);
+ g_signal_connect (G_OBJECT(dialog), "complete", G_CALLBACK (properties_complete), dialog);
template = gl_label_get_template (label);
rotate_flag = gl_label_get_rotate_flag (label);
@@ -221,45 +206,33 @@ gl_file_properties (glLabel *label,
/* PRIVATE. Properties "ok" button callback. */
/*---------------------------------------------------------------------------*/
static void
-properties_response (GtkDialog *dialog,
- gint response,
- gpointer user_data)
+properties_complete (GtkDialog *dialog,
+ gpointer user_data)
{
lglTemplate *template;
glLabel *label;
gl_debug (DEBUG_FILE, "START");
- switch (response) {
-
- case GTK_RESPONSE_OK:
-
- gl_new_label_dialog_get_filter_parameters (GL_NEW_LABEL_DIALOG (dialog),
- &page_size,
- &category);
+ gl_new_label_dialog_get_filter_parameters (GL_NEW_LABEL_DIALOG (dialog),
+ &page_size,
+ &category);
- if (sheet_name != NULL)
- g_free (sheet_name);
- sheet_name =
- gl_new_label_dialog_get_template_name (GL_NEW_LABEL_DIALOG (dialog));
-
- rotate_flag =
- gl_new_label_dialog_get_rotate_state (GL_NEW_LABEL_DIALOG (dialog));
-
- template = lgl_db_lookup_template_from_name (sheet_name);
+ if (sheet_name != NULL)
+ {
+ g_free (sheet_name);
+ }
- label = GL_LABEL(g_object_get_data (G_OBJECT (dialog), "label"));
+ sheet_name = gl_new_label_dialog_get_template_name (GL_NEW_LABEL_DIALOG (dialog));
- gl_label_set_template (label, template, TRUE);
- gl_label_set_rotate_flag (label, rotate_flag, TRUE);
+ rotate_flag = gl_new_label_dialog_get_rotate_state (GL_NEW_LABEL_DIALOG (dialog));
- break;
+ template = lgl_db_lookup_template_from_name (sheet_name);
- default:
- break;
- }
+ label = GL_LABEL(g_object_get_data (G_OBJECT (dialog), "label"));
- gtk_widget_destroy (GTK_WIDGET (dialog));
+ gl_label_set_template (label, template, TRUE);
+ gl_label_set_rotate_flag (label, rotate_flag, TRUE);
gl_debug (DEBUG_FILE, "END");
}
diff --git a/src/media-select.c b/src/media-select.c
new file mode 100644
index 0000000..ae7860a
--- /dev/null
+++ b/src/media-select.c
@@ -0,0 +1,847 @@
+/*
+ * 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.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 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)
+{
+ gchar *builder_filename;
+ 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 ();
+ builder_filename = g_build_filename (GLABELS_DATA_DIR, "builder", "media-select.builder", NULL);
+ gtk_builder_add_objects_from_file (builder, builder_filename, object_ids, &error);
+ g_free (builder_filename);
+ 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. Load list store from template name list. */
+/*--------------------------------------------------------------------------*/
+static void
+load_recent_list (glMediaSelect *this,
+ GtkListStore *store,
+ GtkTreeSelection *selection,
+ GList *list)
+{
+ GList *p;
+ GtkTreeIter iter;
+ lglUnits units;
+ lglTemplate *template;
+ lglTemplateFrame *frame;
+ GdkPixbuf *pixbuf;
+ gchar *size;
+ gchar *layout;
+ gchar *description;
+
+ gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+ gtk_list_store_clear (store);
+
+
+ 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;
+ }
+
+ if (list)
+ {
+
+ units = gl_prefs_model_get_units (gl_prefs);
+
+ 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);
+ frame = (lglTemplateFrame *)template->frames->data;
+ pixbuf = gl_mini_preview_pixbuf_cache_get_pixbuf (p->data);
+
+ size = lgl_template_frame_get_size_description (frame, units);
+ layout = lgl_template_frame_get_layout_description (frame);
+ 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
+ {
+ 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;
+ lglUnits units;
+ lglTemplate *template;
+ lglTemplateFrame *frame;
+ GdkPixbuf *pixbuf;
+ gchar *size;
+ gchar *layout;
+ gchar *description;
+
+ gl_debug (DEBUG_MEDIA_SELECT, "START");
+
+ gtk_list_store_clear (store);
+
+ 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;
+ }
+
+ if (list)
+ {
+
+ units = gl_prefs_model_get_units (gl_prefs);
+
+ 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);
+ frame = (lglTemplateFrame *)template->frames->data;
+ pixbuf = gl_mini_preview_pixbuf_cache_get_pixbuf (p->data);
+
+ size = lgl_template_frame_get_size_description (frame, units);
+ layout = lgl_template_frame_get_layout_description (frame);
+ 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
+ {
+ 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
index 0000000..603eeb8
--- /dev/null
+++ b/src/media-select.h
@@ -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/new-label-dialog.c b/src/new-label-dialog.c
index 4662148..b6a9259 100644
--- a/src/new-label-dialog.c
+++ b/src/new-label-dialog.c
@@ -25,19 +25,21 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include "hig.h"
+#include "marshal.h"
#include "builder-util.h"
#include "prefs.h"
-#include "template-history.h"
+#include "media-select.h"
+#include "mini-label-preview.h"
#include "mini-preview.h"
-#include "media-combo.h"
-#include "rotate-label-button.h"
#include "debug.h"
-#define MINI_PREVIEW_MIN_HEIGHT 300
-#define MINI_PREVIEW_MIN_WIDTH 256
+#define LABEL_PREVIEW_WIDTH 96
+#define LABEL_PREVIEW_HEIGHT 96
+
+#define MINI_PREVIEW_MIN_WIDTH 300
+#define MINI_PREVIEW_MIN_HEIGHT 360
/*===========================================*/
@@ -48,10 +50,21 @@ struct _glNewLabelDialogPrivate {
GtkBuilder *builder;
- GtkWidget *preview_vbox;
+ GtkWidget *template_page_vbox;
GtkWidget *combo_hbox;
- GtkWidget *rotate_hbox;
+ GtkWidget *combo;
+ GtkWidget *rotate_page_vbox;
+ GtkWidget *normal_radio;
+ GtkWidget *rotated_radio;
+ GtkWidget *normal_preview_hbox;
+ GtkWidget *rotated_preview_hbox;
+ GtkWidget *normal_preview;
+ GtkWidget *rotated_preview;
+
+ GtkWidget *confirm_page_vbox;
+ GtkWidget *preview_vbox;
+ GtkWidget *preview;
GtkWidget *desc_label;
GtkWidget *page_size_label;
GtkWidget *label_size_label;
@@ -59,10 +72,18 @@ struct _glNewLabelDialogPrivate {
GtkWidget *vendor_label;
GtkWidget *part_label;
GtkWidget *similar_label;
+};
- GtkWidget *preview;
- GtkWidget *combo;
- GtkWidget *rotate_button;
+/* Page numbers for traversing GtkAssistant */
+enum {
+ TEMPLATE_PAGE_NUM = 0,
+ ROTATE_PAGE_NUM,
+ CONFIRM_PAGE_NUM
+};
+
+enum {
+ COMPLETE,
+ LAST_SIGNAL
};
@@ -70,6 +91,8 @@ struct _glNewLabelDialogPrivate {
/* Private globals */
/*===========================================*/
+static gint signals[LAST_SIGNAL] = { 0 };
+
/*===========================================*/
/* Local function prototypes */
@@ -77,6 +100,13 @@ struct _glNewLabelDialogPrivate {
static void gl_new_label_dialog_finalize (GObject *object);
+static void cancel_cb (glNewLabelDialog *this);
+static void apply_cb (glNewLabelDialog *this);
+static void close_cb (glNewLabelDialog *this);
+
+static gint forward_page_function (gint current_page,
+ glNewLabelDialog *this);
+
static void combo_changed_cb (glNewLabelDialog *this);
static void rotate_toggled_cb (glNewLabelDialog *this);
@@ -89,7 +119,7 @@ static void set_info (glNewLabelDialog *this,
/*****************************************************************************/
/* Boilerplate object stuff. */
/*****************************************************************************/
-G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_DIALOG);
+G_DEFINE_TYPE (glNewLabelDialog, gl_new_label_dialog, GTK_TYPE_ASSISTANT);
/*****************************************************************************/
@@ -105,6 +135,16 @@ gl_new_label_dialog_class_init (glNewLabelDialogClass *class)
gl_new_label_dialog_parent_class = g_type_class_peek_parent (class);
object_class->finalize = gl_new_label_dialog_finalize;
+
+ signals[COMPLETE] =
+ g_signal_new ("complete",
+ G_OBJECT_CLASS_TYPE(object_class),
+ G_SIGNAL_RUN_LAST,
+ G_STRUCT_OFFSET (glNewLabelDialogClass, complete),
+ NULL, NULL,
+ gl_marshal_VOID__VOID,
+ G_TYPE_NONE, 0);
+
}
@@ -115,12 +155,16 @@ static void
gl_new_label_dialog_init (glNewLabelDialog *this)
{
GtkWidget *vbox;
+ gchar *logo_filename;
+ GdkPixbuf *logo;
GtkBuilder *builder;
gchar *builder_filename;
- static gchar *object_ids[] = { "new_label_dialog_hbox", NULL };
+ static gchar *object_ids[] = { "template_page_vbox",
+ "rotate_page_vbox",
+ "confirm_page_vbox",
+ NULL };
GError *error = NULL;
GtkWidget *new_label_dialog_hbox;
- gchar *name;
gl_debug (DEBUG_FILE, "START");
@@ -128,19 +172,9 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
this->priv = g_new0 (glNewLabelDialogPrivate, 1);
- gtk_container_set_border_width (GTK_CONTAINER (this), GL_HIG_PAD1);
-
- gtk_dialog_set_has_separator (GTK_DIALOG (this), FALSE);
- gtk_dialog_add_buttons (GTK_DIALOG (this),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_OK,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (this), GTK_RESPONSE_OK);
- gtk_window_set_destroy_with_parent (GTK_WINDOW (this), TRUE);
- gtk_window_set_modal (GTK_WINDOW (this), TRUE);
-
- vbox = gtk_dialog_get_content_area (GTK_DIALOG (this));
-
+ logo_filename = g_build_filename (GLABELS_ICON_DIR, GLABELS_ICON, NULL);
+ logo = gdk_pixbuf_new_from_file (logo_filename, NULL);
+ g_free (logo_filename);
builder = gtk_builder_new ();
builder_filename = g_build_filename (GLABELS_DATA_DIR, "builder", "new-label-dialog.builder", NULL);
@@ -153,10 +187,15 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
}
gl_builder_util_get_widgets (builder,
- "new_label_dialog_hbox", &new_label_dialog_hbox,
- "preview_vbox", &this->priv->preview_vbox,
+ "template_page_vbox", &this->priv->template_page_vbox,
"combo_hbox", &this->priv->combo_hbox,
- "rotate_hbox", &this->priv->rotate_hbox,
+ "rotate_page_vbox", &this->priv->rotate_page_vbox,
+ "normal_radio", &this->priv->normal_radio,
+ "rotated_radio", &this->priv->rotated_radio,
+ "normal_preview_hbox", &this->priv->normal_preview_hbox,
+ "rotated_preview_hbox", &this->priv->rotated_preview_hbox,
+ "confirm_page_vbox", &this->priv->confirm_page_vbox,
+ "preview_vbox", &this->priv->preview_vbox,
"desc_label", &this->priv->desc_label,
"page_size_label", &this->priv->page_size_label,
"label_size_label", &this->priv->label_size_label,
@@ -166,29 +205,47 @@ gl_new_label_dialog_init (glNewLabelDialog *this)
"similar_label", &this->priv->similar_label,
NULL);
- gtk_container_add (GTK_CONTAINER (vbox), new_label_dialog_hbox);
this->priv->builder = builder;
+ gtk_assistant_append_page (GTK_ASSISTANT (this), this->priv->template_page_vbox);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->template_page_vbox, _("Select Product"));
+ gtk_assistant_set_page_header_image (GTK_ASSISTANT (this), this->priv->template_page_vbox, logo);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (this), this->priv->template_page_vbox, GTK_ASSISTANT_PAGE_INTRO);
+
+ this->priv->combo = gl_media_select_new ();
+ gtk_container_add (GTK_CONTAINER (this->priv->combo_hbox), this->priv->combo);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (this), this->priv->rotate_page_vbox);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->rotate_page_vbox, _("Choose Orientation"));
+ gtk_assistant_set_page_header_image (GTK_ASSISTANT (this), this->priv->rotate_page_vbox, logo);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (this), this->priv->rotate_page_vbox, TRUE);
+
+ this->priv->normal_preview = gl_mini_label_preview_new (LABEL_PREVIEW_WIDTH, LABEL_PREVIEW_HEIGHT);
+ gtk_container_add (GTK_CONTAINER (this->priv->normal_preview_hbox), this->priv->normal_preview);
+ this->priv->rotated_preview = gl_mini_label_preview_new (LABEL_PREVIEW_WIDTH, LABEL_PREVIEW_HEIGHT);
+ gtk_container_add (GTK_CONTAINER (this->priv->rotated_preview_hbox), this->priv->rotated_preview);
+
+ gtk_assistant_append_page (GTK_ASSISTANT (this), this->priv->confirm_page_vbox);
+ gtk_assistant_set_page_title (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, _("Review"));
+ gtk_assistant_set_page_header_image (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, logo);
+ gtk_assistant_set_page_type (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, GTK_ASSISTANT_PAGE_CONFIRM);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (this), this->priv->confirm_page_vbox, TRUE);
+
this->priv->preview = gl_mini_preview_new (MINI_PREVIEW_MIN_HEIGHT, MINI_PREVIEW_MIN_WIDTH);
gl_mini_preview_set_draw_arrow (GL_MINI_PREVIEW (this->priv->preview), TRUE);
gl_mini_preview_set_rotate (GL_MINI_PREVIEW (this->priv->preview), FALSE);
gtk_container_add (GTK_CONTAINER (this->priv->preview_vbox), this->priv->preview);
- this->priv->combo = gl_media_combo_new ();
- gtk_container_add (GTK_CONTAINER (this->priv->combo_hbox), this->priv->combo);
+ gtk_assistant_set_forward_page_func (GTK_ASSISTANT (this), (GtkAssistantPageFunc)forward_page_function, this, NULL);
- this->priv->rotate_button = gl_rotate_label_button_new ();
- gtk_container_add (GTK_CONTAINER (this->priv->rotate_hbox), this->priv->rotate_button);
+ g_signal_connect_swapped (G_OBJECT(this), "cancel", G_CALLBACK(cancel_cb), this);
+ g_signal_connect_swapped (G_OBJECT(this), "apply", G_CALLBACK(apply_cb), this);
+ g_signal_connect_swapped (G_OBJECT(this), "close", G_CALLBACK(close_cb), this);
- g_signal_connect_swapped (G_OBJECT (this->priv->combo), "changed",
- G_CALLBACK (combo_changed_cb), this);
- g_signal_connect_swapped (G_OBJECT (this->priv->rotate_button), "changed",
- G_CALLBACK (rotate_toggled_cb), this);
+ g_signal_connect_swapped (G_OBJECT (this->priv->combo), "changed", G_CALLBACK (combo_changed_cb), this);
+ g_signal_connect_swapped (G_OBJECT (this->priv->normal_radio), "toggled", G_CALLBACK (rotate_toggled_cb), this);
+ g_signal_connect_swapped (G_OBJECT (this->priv->rotated_radio), "toggled", G_CALLBACK (rotate_toggled_cb), this);
- name = get_default_name ();
- gl_media_combo_set_name (GL_MEDIA_COMBO (this->priv->combo), name);
- gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (this->priv->rotate_button), name);
- g_free (name);
combo_changed_cb (this);
gl_debug (DEBUG_FILE, "END");
@@ -237,6 +294,84 @@ gl_new_label_dialog_new (GtkWindow *win)
}
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. Handle non-linear forward traversal. */
+/*--------------------------------------------------------------------------*/
+static gint
+forward_page_function (gint current_page,
+ glNewLabelDialog *this)
+{
+ gchar *name;
+ lglTemplate *template;
+ const lglTemplateFrame *frame;
+ gdouble w, h;
+
+ switch (current_page)
+ {
+ case TEMPLATE_PAGE_NUM:
+ name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
+ if ( name != NULL )
+ {
+ template = lgl_db_lookup_template_from_name (name);
+ frame = (lglTemplateFrame *)template->frames->data;
+ lgl_template_frame_get_size (frame, &w, &h);
+
+ if ( w == h )
+ {
+ /* Skip rotate page for square and circular labels. */
+ return CONFIRM_PAGE_NUM;
+ }
+ }
+ return ROTATE_PAGE_NUM;
+
+ case ROTATE_PAGE_NUM:
+ return CONFIRM_PAGE_NUM;
+
+ case CONFIRM_PAGE_NUM:
+ default:
+ return -1;
+ }
+
+ return -1;
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. cancel callback. */
+/*--------------------------------------------------------------------------*/
+static void
+cancel_cb (glNewLabelDialog *this)
+{
+
+ gtk_widget_destroy (GTK_WIDGET(this));
+
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. apply callback */
+/*--------------------------------------------------------------------------*/
+static void
+apply_cb (glNewLabelDialog *this)
+{
+
+ g_signal_emit (G_OBJECT (this), signals[COMPLETE], 0);
+
+}
+
+
+/*--------------------------------------------------------------------------*/
+/* PRIVATE. close callback */
+/*--------------------------------------------------------------------------*/
+static void
+close_cb (glNewLabelDialog *this)
+{
+
+ gtk_widget_destroy (GTK_WIDGET(this));
+
+}
+
+
/*---------------------------------------------------------------------------*/
/* PRIVATE. Template changed callback. */
/*---------------------------------------------------------------------------*/
@@ -247,12 +382,17 @@ combo_changed_cb (glNewLabelDialog *this)
gl_debug (DEBUG_FILE, "START");
- name = gl_media_combo_get_name (GL_MEDIA_COMBO (this->priv->combo));
+ name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
+
+ gl_mini_label_preview_set_by_name (GL_MINI_LABEL_PREVIEW (this->priv->normal_preview), name, FALSE);
+ gl_mini_label_preview_set_by_name (GL_MINI_LABEL_PREVIEW (this->priv->rotated_preview), name, TRUE);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->normal_radio), TRUE);
gl_mini_preview_set_by_name (GL_MINI_PREVIEW (this->priv->preview), name);
- gl_rotate_label_button_set_template_name (GL_ROTATE_LABEL_BUTTON (this->priv->rotate_button), name);
set_info (this, name);
+ gtk_assistant_set_page_complete (GTK_ASSISTANT (this), this->priv->template_page_vbox, (name != NULL));
+
g_free (name);
gl_debug (DEBUG_FILE, "END");
@@ -269,7 +409,7 @@ rotate_toggled_cb (glNewLabelDialog *this)
gl_debug (DEBUG_FILE, "START");
- state = gl_rotate_label_button_get_state (GL_ROTATE_LABEL_BUTTON (this->priv->rotate_button));
+ state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio));
gl_mini_preview_set_rotate (GL_MINI_PREVIEW (this->priv->preview), state);
gl_debug (DEBUG_FILE, "END");
@@ -277,41 +417,6 @@ rotate_toggled_cb (glNewLabelDialog *this)
/*---------------------------------------------------------------------------*/
-/* PRIVATE. Get default template name. */
-/*---------------------------------------------------------------------------*/
-static gchar *
-get_default_name (void)
-{
- gchar *name = NULL;
- GList *list;
-
- list = gl_template_history_model_get_name_list (gl_template_history);
-
- if ( list )
- {
- name = g_strdup (list->data);
- gl_template_history_model_free_name_list (list);
- }
- else
- {
- gchar *page_size;
-
- page_size = gl_prefs_model_get_default_page_size (gl_prefs);
- list = lgl_db_get_template_name_list_all (NULL, page_size, NULL);
- g_free (page_size);
-
- if ( list )
- {
- name = g_strdup (list->data);
- lgl_db_free_template_name_list (list);
- }
- }
-
- return name;
-}
-
-
-/*---------------------------------------------------------------------------*/
/* PRIVATE. Set information labels. */
/*---------------------------------------------------------------------------*/
static void
@@ -406,7 +511,7 @@ gl_new_label_dialog_get_template_name (glNewLabelDialog *this)
{
gchar *name;
- name = gl_media_combo_get_name (GL_MEDIA_COMBO (this->priv->combo));
+ name = gl_media_select_get_name (GL_MEDIA_SELECT (this->priv->combo));
return name;
}
@@ -420,7 +525,7 @@ gl_new_label_dialog_set_template_name (glNewLabelDialog *this,
gchar *name)
{
gl_mini_preview_set_by_name (GL_MINI_PREVIEW (this->priv->preview), name);
- gl_media_combo_set_name (GL_MEDIA_COMBO (this->priv->combo), name);
+ gl_media_select_set_name (GL_MEDIA_SELECT (this->priv->combo), name);
set_info (this, name);
}
@@ -453,7 +558,7 @@ gl_new_label_dialog_set_filter_parameters (glNewLabelDialog *this,
gboolean
gl_new_label_dialog_get_rotate_state (glNewLabelDialog *this)
{
- return gl_rotate_label_button_get_state (GL_ROTATE_LABEL_BUTTON (this->priv->rotate_button));
+ return gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio));
}
@@ -464,7 +569,7 @@ void
gl_new_label_dialog_set_rotate_state (glNewLabelDialog *this,
gboolean state)
{
- gl_rotate_label_button_set_state (GL_ROTATE_LABEL_BUTTON (this->priv->rotate_button), state);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (this->priv->rotated_radio), state);
gl_mini_preview_set_rotate (GL_MINI_PREVIEW (this->priv->preview), state);
}
diff --git a/src/new-label-dialog.h b/src/new-label-dialog.h
index 2029a9f..ccfd27f 100644
--- a/src/new-label-dialog.h
+++ b/src/new-label-dialog.h
@@ -45,7 +45,7 @@ typedef struct _glNewLabelDialogPrivate glNewLabelDialogPrivate;
struct _glNewLabelDialog
{
- GtkDialog parent_instance;
+ GtkAssistant parent_instance;
glNewLabelDialogPrivate *priv;
@@ -53,7 +53,9 @@ struct _glNewLabelDialog
struct _glNewLabelDialogClass
{
- GtkDialogClass parent_class;
+ GtkAssistantClass parent_class;
+
+ void (*complete) (glNewLabelDialog *this, gpointer user_data);
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]