[gnome-contacts] ListPane: moved to template file
- From: Erick Pérez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] ListPane: moved to template file
- Date: Thu, 29 May 2014 20:25:30 +0000 (UTC)
commit 1851e04dd75a14e30ba01d3bbe4395b30d005610
Author: Erick Pérez Castellanos <erick red gmail com>
Date: Sat Apr 26 01:26:35 2014 -0400
ListPane: moved to template file
Next thing is remove Contacts.View setting of Store in its constructor.
src/Makefile.am | 3 +-
src/contacts-list-pane.ui | 103 +++++++++++++++++++++++++++++++++++++++++++
src/contacts-list-pane.vala | 95 ++++++++++++---------------------------
src/contacts.gresource.xml | 1 +
4 files changed, 136 insertions(+), 66 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index e99343f..29b6395 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -59,7 +59,7 @@ gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml)
@GSETTINGS_RULES@
-contact-resources.c: contacts.gresource.xml app-menu.ui contacts-window.ui
+contact-resources.c: contacts.gresource.xml app-menu.ui contacts-window.ui contacts-list-pane.ui
$(AM_V_GEN) $(GLIB_COMPILE_RESOURCES) $(srcdir)/contacts.gresource.xml \
--target=$@ --sourcedir=$(srcdir) --c-name contacts --generate-source
@@ -103,6 +103,7 @@ EXTRA_DIST = \
contacts.gresource.xml \
app-menu.ui \
contacts-window.ui \
+ contacts-list-pane.ui \
$(gsettingsschema_in_files) \
contacts-esd-setup.h \
$(NULL)
diff --git a/src/contacts-list-pane.ui b/src/contacts-list-pane.ui
new file mode 100644
index 0000000..00575c2
--- /dev/null
+++ b/src/contacts-list-pane.ui
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.15.2 on Thu Aug 15 15:33:02 2013 -->
+<interface>
+ <!-- interface-requires gtk+ 3.10 -->
+ <template class="ContactsListPane" parent="GtkFrame">
+ <property name="can_focus">False</property>
+ <property name="hexpand">False</property>
+ <property name="hexpand_set">True</property>
+ <child>
+ <object class="GtkGrid">
+ <property name="orientation">vertical</property>
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkToolbar">
+ <property name="visible">True</property>
+ <property name="icon_size">1</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">False</property>
+ <property name="vexpand-set">False</property>
+ <style>
+ <class name="primary-toolbar"/>
+ </style>
+ <child>
+ <object class="GtkToolItem" id="search_tool_item">
+ <property name="visible">True</property>
+ <child>
+ <object class="GtkSearchEntry" id="filter_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="primary_icon_name">edit-find-symbolic</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">False</property>
+ <property name="placeholder_text" translatable="yes">Type to search</property>
+ </object>
+ </child>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">0</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="scrolled">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="hscrollbar_policy">never</property>
+ <property name="no_show_all">True</property>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkActionBar" id="actions_bar">
+ <property name="visible">False</property>
+ <child>
+ <object class="GtkButton" id="link_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="focus_on_click">False</property>
+ <property name="label" translatable="yes">Link</property>
+ <!-- To translators: Link refers to the verb, from linking contacts together -->
+ <property name="width_request">70</property>
+ <property name="sensitive">False</property>
+ </object>
+ <packing>
+ <property name="pack_type">start</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkButton" id="delete_button">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="focus_on_click">False</property>
+ <property name="label" translatable="yes">Delete</property>
+ <property name="width_request">70</property>
+ <property name="sensitive">False</property>
+ </object>
+ <packing>
+ <property name="pack_type">end</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">2</property>
+ <property name="width">1</property>
+ <property name="height">1</property>
+ </packing>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
\ No newline at end of file
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index fbcc99a..041dbca 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -20,12 +20,28 @@ using Gee;
using Gtk;
using Folks;
+[GtkTemplate (ui = "/org/gnome/contacts/contacts-list-pane.ui")]
public class Contacts.ListPane : Frame {
private Store contacts_store;
+ private View contacts_view;
+
+ [GtkChild]
+ public ToolItem search_tool_item;
+ [GtkChild]
public SearchEntry filter_entry;
- private View contacts_view;
- private Revealer selection_revealer;
+
+ [GtkChild]
+ public Button link_button;
+
+ [GtkChild]
+ public Button delete_button;
+
+ [GtkChild]
+ public ScrolledWindow scrolled;
+
+ [GtkChild]
+ public ActionBar actions_bar;
private uint filter_entry_changed_id;
private bool ignore_selection_change;
@@ -70,93 +86,42 @@ public class Contacts.ListPane : Frame {
}
public ListPane (Store contacts_store) {
+ search_tool_item.set_expand (true);
+ filter_entry.changed.connect (filter_entry_changed);
+
this.contacts_store = contacts_store;
this.contacts_view = new View (contacts_store);
- var toolbar = new Toolbar ();
- toolbar.get_style_context ().add_class (STYLE_CLASS_PRIMARY_TOOLBAR);
- toolbar.set_icon_size (IconSize.MENU);
- toolbar.set_vexpand (false);
- toolbar.set_hexpand (true);
contacts_view.set_show_subset (View.Subset.ALL);
-
- filter_entry = new SearchEntry ();
- filter_entry.set_placeholder_text (_("Type to search"));
- filter_entry.changed.connect (filter_entry_changed);
-
- var search_entry_item = new ToolItem ();
- search_entry_item.is_important = false;
- search_entry_item.set_expand (true);
- search_entry_item.add (filter_entry);
- toolbar.add (search_entry_item);
-
- this.set_hexpand (false);
-
- var scrolled = new ScrolledWindow(null, null);
- scrolled.set_policy (PolicyType.NEVER, PolicyType.AUTOMATIC);
- scrolled.set_vexpand (true);
- scrolled.set_hexpand (true);
- scrolled.set_shadow_type (ShadowType.NONE);
-
- var grid = new Grid ();
- grid.set_orientation (Orientation.VERTICAL);
- this.add (grid);
-
contacts_view.selection_changed.connect( (l, contact) => {
if (!ignore_selection_change)
selection_changed (contact);
});
-
- contacts_view.show_all ();
scrolled.add (contacts_view);
- scrolled.set_no_show_all (true);
- scrolled.show ();
-
- grid.add (toolbar);
- grid.add (scrolled);
-
- selection_revealer = new Revealer ();
- selection_revealer.set_transition_type (RevealerTransitionType.SLIDE_UP);
-
- var selection_toolbar = new Gd.MainToolbar ();
- selection_toolbar.get_style_context ().add_class (STYLE_CLASS_MENUBAR);
- selection_toolbar.get_style_context ().add_class ("contacts-selection-toolbar");
-
- /* To translators: Link refers to the verb, from linking contacts together */
- var link_selected_button = selection_toolbar.add_button (null, _("Link"), true) as Gtk.Button;
- link_selected_button.set_size_request (70, -1);
- link_selected_button.set_sensitive (false);
- var delete_selected_button = selection_toolbar.add_button (null, _("Delete"), false) as Gtk.Button;
- delete_selected_button.set_size_request (70, -1);
- delete_selected_button.set_sensitive (false);
-
- selection_revealer.add (selection_toolbar);
- grid.add (selection_revealer);
-
- this.show_all ();
+ contacts_view.show_all ();
/* contact mark handling */
contacts_view.contacts_marked.connect ((nr_contacts_marked) => {
if (nr_contacts_marked > 0)
- delete_selected_button.set_sensitive (true);
+ delete_button.set_sensitive (true);
else
- delete_selected_button.set_sensitive (false);
+ delete_button.set_sensitive (false);
if (nr_contacts_marked > 1)
- link_selected_button.set_sensitive (true);
+ link_button.set_sensitive (true);
else
- link_selected_button.set_sensitive (false);
+ link_button.set_sensitive (false);
contacts_marked (nr_contacts_marked);
});
- link_selected_button.clicked.connect (() => {
+ link_button.clicked.connect (() => {
var marked_contacts = contacts_view.get_marked_contacts ();
link_contacts (marked_contacts);
});
- delete_selected_button.clicked.connect (() => {
+ delete_button.clicked.connect (() => {
var marked_contacts = contacts_view.get_marked_contacts ();
foreach (var c in marked_contacts) {
c.hide ();
@@ -175,12 +140,12 @@ public class Contacts.ListPane : Frame {
public void show_selection () {
contacts_view.show_selectors ();
- selection_revealer.set_reveal_child (true);
+ actions_bar.show ();
}
public void hide_selection () {
contacts_view.hide_selectors ();
- selection_revealer.set_reveal_child (false);
+ actions_bar.hide ();
}
/* Limiting width hack */
diff --git a/src/contacts.gresource.xml b/src/contacts.gresource.xml
index a28dcaa..c413eca 100644
--- a/src/contacts.gresource.xml
+++ b/src/contacts.gresource.xml
@@ -3,5 +3,6 @@
<gresource prefix="/org/gnome/contacts">
<file compressed="true" preprocess="xml-stripblanks">app-menu.ui</file>
<file compressed="true" preprocess="xml-stripblanks">contacts-window.ui</file>
+ <file compressed="true" preprocess="xml-stripblanks">contacts-list-pane.ui</file>
</gresource>
</gresources>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]