[glabels/vala] Added page size search criteria to new label dialog.
- From: Jim Evins <jimevins src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glabels/vala] Added page size search criteria to new label dialog.
- Date: Mon, 23 Apr 2012 07:06:52 +0000 (UTC)
commit 09a3034266af9869587f914e505210c18a3558f7
Author: Jim Evins <evins snaught com>
Date: Mon Apr 23 03:05:48 2012 -0400
Added page size search criteria to new label dialog.
data/ui/new_label_dialog.ui | 497 ++++++++++++++++++++++++++++++-----------
glabels/new_label_dialog.vala | 85 +++++++-
2 files changed, 443 insertions(+), 139 deletions(-)
---
diff --git a/data/ui/new_label_dialog.ui b/data/ui/new_label_dialog.ui
index ff7306d..9561743 100644
--- a/data/ui/new_label_dialog.ui
+++ b/data/ui/new_label_dialog.ui
@@ -14,46 +14,95 @@
<object class="GtkNotebook" id="notebook">
<property name="visible">True</property>
<property name="can_focus">True</property>
- <property name="tab_pos">left</property>
<child>
<object class="GtkBox" id="recent_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="border_width">6</property>
<property name="orientation">vertical</property>
- <property name="spacing">3</property>
<child>
- <object class="GtkBox" id="recent_info_box">
+ <object class="GtkBox" id="box4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="orientation">vertical</property>
+ <property name="spacing">9</property>
<child>
- <placeholder/>
+ <object class="GtkBox" id="box6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkLabel" id="label5">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes"><big><b>Recent Templates</b></big></property>
+ <property name="use_markup">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</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="shadow_type">in</property>
<child>
- <object class="GtkIconView" id="recent_icon_view">
+ <object class="GtkBox" id="box5">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">browse</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="recent_info_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</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="shadow_type">in</property>
+ <child>
+ <object class="GtkIconView" id="recent_icon_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="selection_mode">browse</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">1</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -72,63 +121,182 @@
<object class="GtkBox" id="search_box">
<property name="visible">True</property>
<property name="can_focus">False</property>
+ <property name="border_width">6</property>
<property name="orientation">vertical</property>
<child>
- <object class="GtkHBox" id="hbox1">
+ <object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="border_width">6</property>
+ <property name="spacing">9</property>
<child>
- <object class="GtkEntry" id="search_entry">
+ <object class="GtkBox" id="box1">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="invisible_char">â</property>
- <property name="invisible_char_set">True</property>
- <property name="secondary_icon_stock">gtk-find</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes"><big><b>Search All Templates</b></big></property>
+ <property name="use_markup">True</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="alignment2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">9</property>
+ <child>
+ <object class="GtkBox" id="box3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkEntry" id="search_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">â</property>
+ <property name="invisible_char_set">True</property>
+ <property name="secondary_icon_stock">gtk-find</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkFrame" id="frame1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label_xalign">0</property>
+ <property name="shadow_type">none</property>
+ <child>
+ <object class="GtkAlignment" id="alignment1">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">12</property>
+ <child>
+ <object class="GtkBox" id="box2">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkRadioButton" id="search_iso_radio">
+ <property name="label" translatable="yes">ISO sizes</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="search_us_radio">
+ <property name="label" translatable="yes">US sizes</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">search_iso_radio</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkRadioButton" id="search_other_radio">
+ <property name="label" translatable="yes">Other</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="use_action_appearance">False</property>
+ <property name="xalign">0</property>
+ <property name="active">True</property>
+ <property name="draw_indicator">True</property>
+ <property name="group">search_iso_radio</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ </child>
+ <child type="label">
+ <object class="GtkLabel" id="frame">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="label" translatable="yes"><b>Page size</b></property>
+ <property name="use_markup">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="pack_type">end</property>
<property name="position">0</property>
</packing>
</child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkBox" id="search_info_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox2">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="border_width">6</property>
- <property name="spacing">10</property>
- <child>
- <placeholder/>
- </child>
<child>
<object class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="spacing">18</property>
+ <child>
+ <object class="GtkBox" id="search_info_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
<child>
<object class="GtkScrolledWindow" id="scrolledwindow1">
<property name="visible">True</property>
@@ -145,7 +313,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">0</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
@@ -159,7 +327,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
- <property name="position">2</property>
+ <property name="position">0</property>
</packing>
</child>
</object>
@@ -186,95 +354,155 @@
<property name="orientation">vertical</property>
<property name="spacing">3</property>
<child>
- <object class="GtkBox" id="custom_info_box">
- <property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="orientation">vertical</property>
- <child>
- <placeholder/>
- </child>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">True</property>
- <property name="position">0</property>
- </packing>
- </child>
- <child>
- <object class="GtkScrolledWindow" id="scrolledwindow3">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="shadow_type">in</property>
- <child>
- <object class="GtkIconView" id="custom_icon_view">
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="selection_mode">browse</property>
- </object>
- </child>
- </object>
- <packing>
- <property name="expand">True</property>
- <property name="fill">True</property>
- <property name="position">1</property>
- </packing>
- </child>
- <child>
- <object class="GtkHBox" id="hbox3">
+ <object class="GtkBox" id="box7">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">9</property>
<child>
- <object class="GtkButton" id="custom_add_button">
- <property name="label">gtk-add</property>
+ <object class="GtkBox" id="box8">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">6</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">12</property>
+ <child>
+ <object class="GtkLabel" id="label6">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="label" translatable="yes"><big><b>Custom Templates</b></big></property>
+ <property name="use_markup">True</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="alignment3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="left_padding">9</property>
+ <property name="right_padding">60</property>
+ <child>
+ <object class="GtkBox" id="box10">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <property name="spacing">9</property>
+ <child>
+ <object class="GtkButton" id="custom_add_button">
+ <property name="label">gtk-add</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="custom_edit_button">
+ <property name="label">gtk-edit</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="custom_delete_button">
+ <property name="label">gtk-delete</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ <property name="use_action_appearance">False</property>
+ <property name="use_stock">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
+ <property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
- <object class="GtkButton" id="custom_edit_button">
- <property name="label">gtk-edit</property>
+ <object class="GtkBox" id="box9">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox" id="custom_info_box">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolledwindow3">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="shadow_type">in</property>
+ <child>
+ <object class="GtkIconView" id="custom_icon_view">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="selection_mode">browse</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
+ <property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
- <child>
- <object class="GtkButton" id="custom_delete_button">
- <property name="label">gtk-delete</property>
- <property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="receives_default">True</property>
- <property name="use_action_appearance">False</property>
- <property name="use_stock">True</property>
- </object>
- <packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">2</property>
- </packing>
- </child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="padding">6</property>
- <property name="position">2</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
</packing>
</child>
</object>
@@ -303,4 +531,11 @@
</object>
</child>
</object>
+ <object class="GtkSizeGroup" id="panel_sizegroup">
+ <widgets>
+ <widget name="box1"/>
+ <widget name="box6"/>
+ <widget name="box8"/>
+ </widgets>
+ </object>
</interface>
diff --git a/glabels/new_label_dialog.vala b/glabels/new_label_dialog.vala
index 8de8b10..762ec70 100644
--- a/glabels/new_label_dialog.vala
+++ b/glabels/new_label_dialog.vala
@@ -20,6 +20,7 @@
using GLib;
+using libglabels;
namespace glabels
{
@@ -40,6 +41,9 @@ namespace glabels
private Gtk.Box search_info_box;
private MessageBar search_info_bar;
private Gtk.Entry search_entry;
+ private Gtk.RadioButton search_iso_radio;
+ private Gtk.RadioButton search_us_radio;
+ private Gtk.RadioButton search_other_radio;
private Gtk.IconView search_icon_view;
private Gtk.Box custom_box;
@@ -75,7 +79,7 @@ namespace glabels
try
{
string file = GLib.Path.build_filename( Config.DATADIR, Config.GLABELS_BRANCH, "ui", "new_label_dialog.ui" );
- string[] objects = { "main_box", null };
+ string[] objects = { "main_box", "panel_sizegroup", null };
builder.add_objects_from_file( file, objects );
}
catch ( Error err )
@@ -97,6 +101,9 @@ namespace glabels
search_box = builder.get_object( "search_box" ) as Gtk.Box;
search_info_box = builder.get_object( "search_info_box" ) as Gtk.Box;
search_entry = builder.get_object( "search_entry" ) as Gtk.Entry;
+ search_iso_radio = builder.get_object( "search_iso_radio" ) as Gtk.RadioButton;
+ search_us_radio = builder.get_object( "search_us_radio" ) as Gtk.RadioButton;
+ search_other_radio = builder.get_object( "search_other_radio" ) as Gtk.RadioButton;
search_icon_view = builder.get_object( "search_icon_view" ) as Gtk.IconView;
/* Custom templates widgets */
@@ -139,6 +146,9 @@ namespace glabels
/* Connect signals. */
search_entry.changed.connect( on_search_entry_changed );
search_entry.icon_release.connect( on_search_entry_clear );
+ search_iso_radio.toggled.connect( on_search_radio_toggled );
+ search_us_radio.toggled.connect( on_search_radio_toggled );
+ search_other_radio.toggled.connect( on_search_radio_toggled );
recent_icon_view.selection_changed.connect( on_recent_icon_view_selection_changed );
recent_icon_view.button_release_event.connect( on_recent_icon_view_button_release_event );
search_icon_view.selection_changed.connect( on_search_icon_view_selection_changed );
@@ -285,23 +295,66 @@ namespace glabels
private bool search_filter_func( Gtk.TreeModel model, Gtk.TreeIter iter )
{
+ Value value;
+ model.get_value( iter, 0, out value );
+ string name = value.get_string();
+
+
+ Template template = Db.lookup_template_from_name( name );
+ Paper paper = Db.lookup_paper_from_id( template.paper_id );
+
+ bool is_iso = false;
+ bool is_us = false;
+
+ if ( paper.pwg_size != null )
+ {
+ is_iso = paper.pwg_size.has_prefix( "iso_" );
+ is_us = paper.pwg_size.has_prefix( "na_" );
+ }
+
+
if ( search_string == "" )
{
- search_filtered_model_empty = false;
- return true;
+ if ( search_iso_radio.get_active() && is_iso )
+ {
+ search_filtered_model_empty = false;
+ return true;
+ }
+ else if ( search_us_radio.get_active() && is_us )
+ {
+ search_filtered_model_empty = false;
+ return true;
+ }
+ else if ( search_other_radio.get_active() && !is_iso && !is_us )
+ {
+ search_filtered_model_empty = false;
+ return true;
+ }
+
+ return false;
}
- Value value;
- model.get_value( iter, 0, out value );
- string name = value.get_string();
string needle = search_string.casefold();
string haystack = name.casefold();
if ( needle in haystack )
{
- search_filtered_model_empty = false;
- return true;
+ if ( search_iso_radio.get_active() && is_iso )
+ {
+ search_filtered_model_empty = false;
+ return true;
+ }
+ else if ( search_us_radio.get_active() && is_us )
+ {
+ search_filtered_model_empty = false;
+ return true;
+ }
+ else if ( search_other_radio.get_active() && !is_iso && !is_us )
+ {
+ search_filtered_model_empty = false;
+ return true;
+ }
}
return false;
@@ -353,6 +406,22 @@ namespace glabels
}
+ private void on_search_radio_toggled()
+ {
+ search_filtered_model_empty = true;
+ search_filtered_model.refilter();
+
+ if ( search_filtered_model_empty )
+ {
+ search_info_bar.show();
+ }
+ else
+ {
+ search_info_bar.hide();
+ }
+ }
+
+
private void on_recent_icon_view_selection_changed()
{
List<Gtk.TreePath> list = recent_icon_view.get_selected_items();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]