summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuca Bruno <lethalman88@gmail.com>2008-12-26 13:25:03 +0100
committerLuca Bruno <lethalman88@gmail.com>2008-12-26 13:25:03 +0100
commit9b521d2b8bc5663c4d39fa8a053fb7ae76497346 (patch)
tree1691e531bea25f2b5639b5a69077cbacf3f3bb9f
parent4bf222dc2cca5a9db1e90905e385132c60ecd3ef (diff)
downloadaptitude-9b521d2b8bc5663c4d39fa8a053fb7ae76497346.tar.gz
Use EditColumns column itself as Expander column.
This will both cleanup the code and remove extra unused space in treeviews (like Dependencies). * src/gtk/info.cc (InfoTab::disp_package): removed expander references * src/gtk/entityview.cc (EntityView::EditColumnsDialog::hidden_property, set_hidden, get_hidden): added (EntityView::EditColumnsDialog::add_column_to_list): return if col has been hidden (EntityView::column_drop_handler): enforce "..." column to be the first (EntityView::init): removed Expander column, hide EditColumns in the columns editor for real (EntityView::set_model): cleaned up has_expandable_rows trick * src/gtk/entityview.h (EntityView::get_expander_column): removed (EntityView::EditColumns): column added
-rw-r--r--src/gtk/entityview.cc61
-rw-r--r--src/gtk/entityview.h3
-rw-r--r--src/gtk/info.cc1
3 files changed, 42 insertions, 23 deletions
diff --git a/src/gtk/entityview.cc b/src/gtk/entityview.cc
index 97a92da9..f800243d 100644
--- a/src/gtk/entityview.cc
+++ b/src/gtk/entityview.cc
@@ -181,6 +181,7 @@ namespace gui
{
static const Glib::Quark description_property;
static const Glib::Quark edit_name_property;
+ static const Glib::Quark hidden_property;
static void ustring_destroy_notify(gpointer data)
{
@@ -260,6 +261,36 @@ namespace gui
}
+ /** \brief Do not add the column to the editor.
+ *
+ * The column will not be displayed in the "edit columns" dialog box.
+ *
+ * \param col The column to modify.
+ * \param hidden true to hide the column from the columns editor, false otherwise.
+ */
+ static void set_hidden(Gtk::TreeViewColumn *col,
+ bool hidden)
+ {
+ col->set_data(hidden_property, reinterpret_cast<gpointer>(hidden));
+ }
+
+ /** \brief Retrieve the hiding of a column that was set by set_hidden(),
+ * and false otherwise.
+ *
+ * \param col The column whose description should be retrieved.
+ *
+ * \return The hiding of col, if one was set using
+ * set_hidden(), and false otherwise.
+ */
+ static bool get_hidden(Gtk::TreeViewColumn *col)
+ {
+ gpointer rval = col->get_data(hidden_property);
+
+ if(rval == NULL)
+ return false;
+ else
+ return reinterpret_cast<glong>(rval);
+ }
class ModelColumns : public Gtk::TreeModel::ColumnRecord
{
@@ -386,6 +417,9 @@ namespace gui
*/
void add_column_to_list(Gtk::TreeViewColumn * col) const
{
+ if (get_hidden(col))
+ return;
+
Glib::ustring name = get_edit_name(col);
if(name.empty())
name = col->get_title();
@@ -427,6 +461,7 @@ namespace gui
const Glib::Quark EntityView::EditColumnsDialog::description_property("aptitude-visible-columns-editor-column-description-property");
const Glib::Quark EntityView::EditColumnsDialog::edit_name_property("aptitude-visible-columns-editor-column-edit-name-property");
+ const Glib::Quark EntityView::EditColumnsDialog::hidden_property("aptitude-visible-columns-editor-column-hidden-property");
// \todo Perhaps "Edit Columns..." should be available without going
// through the menu, so it's useful in tabs that have more than one
@@ -489,21 +524,14 @@ namespace gui
cache_reloaded.connect(sigc::mem_fun(*this, &EntityView::on_cache_reloaded));
{
- Gtk::TreeViewColumn *EditColumnsColumn = new Gtk::TreeViewColumn("...");
- EditColumnsColumn->signal_clicked().connect(sigc::mem_fun(*this, &EntityView::show_edit_columns_dialog));
- EditColumnsColumn->set_clickable(true);
+ EditColumns = manage(new Gtk::TreeViewColumn("..."));
+ EditColumns->signal_clicked().connect(sigc::mem_fun(*this, &EntityView::show_edit_columns_dialog));
+ EditColumns->set_clickable(true);
// Don't let the properties of this column be edited.
- EditColumnsDialog::set_edit_name(EditColumnsColumn, "");
- tree->append_column(*EditColumnsColumn);
+ EditColumnsDialog::set_hidden(EditColumns, true);
+ tree->append_column(*EditColumns);
}
- // Put in a dummy column for the expanders, so everything else
- // lines up.
- Expander = manage(new Gtk::TreeViewColumn(""));
- setup_column_properties(Expander, 24);
- Expander->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
- tree->append_column(*Expander);
-
{
// \todo should the selected status icon have a dropdown menu?
// And how best to achieve that?
@@ -775,7 +803,7 @@ namespace gui
Gtk::TreeViewColumn *next_column)
{
// Ensure that the expander column is always first.
- if(column == Expander || next_column == Expander)
+ if(column == EditColumns || next_column == EditColumns)
return false;
return true;
@@ -820,13 +848,6 @@ namespace gui
sigc::mem_fun(this, &EntityView::compare_rows_by_version));
revstore.clear();
- bool has_expandable_rows = false;
- model->foreach_iter(sigc::bind(sigc::ptr_fun(post_process_model),
- model,
- get_columns(),
- get_reverse_store(),
- &has_expandable_rows));
- Expander->set_visible(has_expandable_rows);
get_treeview()->set_model(model);
}
}
diff --git a/src/gtk/entityview.h b/src/gtk/entityview.h
index 52005c1c..a42a9d76 100644
--- a/src/gtk/entityview.h
+++ b/src/gtk/entityview.h
@@ -179,7 +179,7 @@ namespace gui
void on_cache_closed();
void on_cache_reloaded();
- Gtk::TreeViewColumn * Expander;
+ Gtk::TreeViewColumn * EditColumns;
Gtk::TreeViewColumn * Status;
Gtk::TreeViewColumn * AutomaticallyInstalled;
Gtk::TreeViewColumn * Name;
@@ -256,7 +256,6 @@ namespace gui
void refresh_view(const std::set<pkgCache::PkgIterator> *changed_packages);
EntityTreeView * get_treeview() const { return tree; };
const EntityColumns * get_columns() const { return &cols; };
- Gtk::TreeViewColumn *get_expander_column() const { return Expander; }
Gtk::TreeViewColumn *get_status_column() const { return Status; }
Gtk::TreeViewColumn *get_name_column() const { return Name; }
Gtk::TreeViewColumn *get_version_column() const { return Version; }
diff --git a/src/gtk/info.cc b/src/gtk/info.cc
index 2d10ae97..f6184ba5 100644
--- a/src/gtk/info.cc
+++ b/src/gtk/info.cc
@@ -657,7 +657,6 @@ namespace gui
pDependsView = ref_ptr<EntityView>(new EntityView(get_xml(), "main_info_dependsview",
_("Package information: dependency list")));
pDependsView->set_model(make_depends_tree(pDependsView->get_columns(), ver));
- pDependsView->get_expander_column()->set_fixed_width(48);
pDependsView->get_name_column()->set_fixed_width(280);
pDependsView->get_automatically_installed_column()->set_visible(false);
Gtk::TreeModel::Children dependsChildren = pDependsView->get_treeview()->get_model()->children();