aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-26 19:26:13 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-26 19:26:13 +0000
commitae1be2021ab1a28979c3e5e73ba8d03a32a2ac1d (patch)
tree88b31c6e4ba39ba5a8ffdcdb223c63b930e2b529
parentc320ebb2fdea399de080f4f4be1d93288ed8872c (diff)
downloadpaludis-ae1be2021ab1a28979c3e5e73ba8d03a32a2ac1d.tar.gz
paludis-ae1be2021ab1a28979c3e5e73ba8d03a32a2ac1d.tar.xz
Commit crude popup menu code. Not sanely usable yet...
-rw-r--r--src/gtkpaludis/browse_tree.cc61
-rw-r--r--src/gtkpaludis/browse_tree.hh5
2 files changed, 63 insertions, 3 deletions
diff --git a/src/gtkpaludis/browse_tree.cc b/src/gtkpaludis/browse_tree.cc
index 2a91ec2..6355b05 100644
--- a/src/gtkpaludis/browse_tree.cc
+++ b/src/gtkpaludis/browse_tree.cc
@@ -19,8 +19,13 @@
#include "browse_tree.hh"
#include "information_tree.hh"
+
#include <gtkmm/treestore.h>
+#include <gtkmm/menu.h>
+#include <gtkmm/messagedialog.h>
+
#include <paludis/default_environment.hh>
+#include <paludis/syncer.hh>
using namespace paludis;
@@ -47,6 +52,10 @@ namespace
virtual void display(InformationTree * const information_tree) const = 0;
+ virtual void sync() const
+ {
+ }
+
virtual void need_children(
Glib::RefPtr<Gtk::TreeStore> model,
const BrowseTreeColumns & columns,
@@ -254,6 +263,15 @@ namespace
{
information_tree->show_repository(_r);
}
+
+ virtual void sync() const
+ {
+ Repository::ConstPointer repo(
+ DefaultEnvironment::get_instance()->package_database()->fetch_repository(_r));
+ if (repo->get_interface<repo_syncable>())
+ repo->get_interface<repo_syncable>()->sync();
+ }
+
};
}
@@ -288,6 +306,8 @@ namespace paludis
BrowseTreeColumns columns;
Glib::RefPtr<Gtk::TreeStore> model;
+ Gtk::Menu popup_menu;
+
Implementation(InformationTree * const i) :
information_tree(i)
{
@@ -322,7 +342,12 @@ BrowseTree::BrowseTree(InformationTree * const information_tree) :
}
append_column("Item", _imp->columns.col_item);
- get_selection()->signal_changed().connect(sigc::mem_fun(*this, &BrowseTree::on_treeview_changed));
+ get_selection()->signal_changed().connect(sigc::mem_fun(*this, &BrowseTree::on_changed));
+
+ /* popup menu */
+ _imp->popup_menu.items().push_back(Gtk::Menu_Helpers::MenuElem("_Sync",
+ sigc::mem_fun(*this, &BrowseTree::on_menu_sync)));
+ _imp->popup_menu.accelerate(*this);
}
BrowseTree::~BrowseTree()
@@ -330,7 +355,7 @@ BrowseTree::~BrowseTree()
}
void
-BrowseTree::on_treeview_changed()
+BrowseTree::on_changed()
{
Gtk::TreeModel::iterator i(get_selection()->get_selected());
if (i)
@@ -343,3 +368,35 @@ BrowseTree::on_treeview_changed()
}
}
+void
+BrowseTree::on_menu_sync()
+{
+ Glib::RefPtr<Gtk::TreeView::Selection> selection(get_selection());
+ if (selection)
+ {
+ Gtk::TreeModel::iterator i(selection->get_selected());
+ if (i)
+ try
+ {
+ BrowseTreeDisplayData::Pointer((*i)[_imp->columns.col_data])->sync();
+ }
+ catch (const SyncFailedError & e)
+ {
+ Gtk::MessageDialog dialog("Sync failed", false, Gtk::MESSAGE_ERROR);
+ dialog.set_secondary_text(e.message());
+ dialog.run();
+ }
+ }
+}
+
+bool
+BrowseTree::on_button_press_event(GdkEventButton * event)
+{
+ bool result(TreeView::on_button_press_event(event));
+
+ if (event->type == GDK_BUTTON_PRESS && event->button == 3)
+ _imp->popup_menu.popup(event->button, event->time);
+
+ return result;
+}
+
diff --git a/src/gtkpaludis/browse_tree.hh b/src/gtkpaludis/browse_tree.hh
index 14cd87f..91f4892 100644
--- a/src/gtkpaludis/browse_tree.hh
+++ b/src/gtkpaludis/browse_tree.hh
@@ -35,7 +35,10 @@ namespace paludis
BrowseTree(InformationTree * const);
~BrowseTree();
- virtual void on_treeview_changed();
+ virtual void on_changed();
+ virtual void on_menu_sync();
+
+ virtual bool on_button_press_event(GdkEventButton *);
};
}