X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=synfig-studio%2Ftrunk%2Fsrc%2Fgtkmm%2Fdock_history.cpp;h=c8fc3da8bd49ef673ff6cdc802a7232620047e80;hb=56c8824c217f4d4bf3202f7100c8d582e63d3abe;hp=3aeaa11efd419a9a47bdfa62b751e0c3efcbf690;hpb=8ef042c40521681cea99944097c4f90a5ac6cf74;p=synfig.git
diff --git a/synfig-studio/trunk/src/gtkmm/dock_history.cpp b/synfig-studio/trunk/src/gtkmm/dock_history.cpp
index 3aeaa11..c8fc3da 100644
--- a/synfig-studio/trunk/src/gtkmm/dock_history.cpp
+++ b/synfig-studio/trunk/src/gtkmm/dock_history.cpp
@@ -6,7 +6,7 @@
**
** \legal
** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
-** Copyright (c) 2007 Chris Moore
+** Copyright (c) 2007, 2008 Chris Moore
**
** This package is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
@@ -95,6 +95,17 @@ Dock_History::Dock_History():
)
);
action_group->add(Gtk::Action::create(
+ "clear-undo-and-redo",
+ Gtk::Stock::CLEAR,
+ _("Clear Undo and Redo Stacks"),
+ _("Clear the undo and redo stacks")
+ ),
+ sigc::mem_fun(
+ *this,
+ &Dock_History::clear_undo_and_redo
+ )
+ );
+ action_group->add(Gtk::Action::create(
"undo",
Gtk::StockID("gtk-undo"),
_("Undo"),
@@ -111,7 +122,7 @@ Dock_History::Dock_History():
sigc::ptr_fun(studio::App::redo)
);
- action_group->add( Gtk::Action::create("toolbar-history", "History") );
+ action_group->add( Gtk::Action::create("toolbar-history", _("History")) );
App::ui_manager()->insert_action_group(action_group);
Glib::ustring ui_info =
@@ -121,6 +132,7 @@ Dock_History::Dock_History():
" "
" "
" "
+ " "
" "
""
;
@@ -185,7 +197,7 @@ Dock_History::create_action_tree()
action_tree->append_column(*column);
}
/*{
- Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("Canvas") );
+ Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Canvas")) );
Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
text_cr->property_foreground()=Glib::ustring("#7f7f7f");
@@ -201,19 +213,19 @@ Dock_History::create_action_tree()
Gtk::CellRendererText* cell_renderer_jump=Gtk::manage(new Gtk::CellRendererText());
column->pack_start(*cell_renderer_jump,true);
- cell_renderer_jump->property_text()="(JMP)";
+ cell_renderer_jump->property_text()=_("(JMP)");
cell_renderer_jump->property_foreground()="#003a7f";
column->set_resizable();
column->set_clickable();
- column->set_sort_column_id(COLUMNID_JUMP);
+ column->set_sort_column(COLUMNID_JUMP);
action_tree->append_column(*column);
//column->clicked();
}
{
- Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column("Action") );
+ Gtk::TreeView::Column* column = Gtk::manage( new Gtk::TreeView::Column(_("Action")) );
Gtk::CellRendererText *text_cr=Gtk::manage(new Gtk::CellRendererText());
text_cr->property_foreground()=Glib::ustring("#7f7f7f");
@@ -228,6 +240,9 @@ Dock_History::create_action_tree()
action_tree->append_column(*column);
}
+ action_tree->set_enable_search(true);
+ action_tree->set_search_column(history_tree_model.name);
+ action_tree->set_search_equal_func(sigc::ptr_fun(&studio::HistoryTreeStore::search_func));
action_tree->set_rules_hint();
// action_tree->signal_row_activated().connect(sigc::mem_fun(*this,&Dock_History::on_row_activate));
@@ -257,17 +272,26 @@ Dock_History::create_action_tree()
void
Dock_History::clear_undo()
{
- if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
- {
+ if(selected_instance && App::dialog_yes_no(_("Clear History"),
+ _("You will not be able to undo any changes that you have made!\nAre you sure you want to clear the undo stack?")))
selected_instance->clear_undo_stack();
- }
}
void
Dock_History::clear_redo()
{
- if(selected_instance && App::dialog_yes_no(_("Clear History"), _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
+ if(selected_instance && App::dialog_yes_no(_("Clear History"),
+ _("You will not be able to redo any changes that you have made!\nAre you sure you want to clear the redo stack?")))
+ selected_instance->clear_redo_stack();
+}
+
+void
+Dock_History::clear_undo_and_redo()
+{
+ if(selected_instance && App::dialog_yes_no(_("Clear History"),
+ _("You will not be able to undo or redo any changes that you have made!\nAre you sure you want to clear the undo and redo stacks?")))
{
+ selected_instance->clear_undo_stack();
selected_instance->clear_redo_stack();
}
}
@@ -282,18 +306,53 @@ Dock_History::update_undo_redo()
action_group->get_action("clear-undo")->set_sensitive(instance->get_undo_status());
action_group->get_action("redo")->set_sensitive(instance->get_redo_status());
action_group->get_action("clear-redo")->set_sensitive(instance->get_redo_status());
+ action_group->get_action("clear-undo-and-redo")->set_sensitive(instance->get_undo_status() || instance->get_redo_status());
}
}
void
+Dock_History::on_undo_tree_changed()
+{
+ Gtk::TreeModel::Children children(selected_instance->history_tree_store()->children());
+
+ if (!children.size())
+ return;
+
+ studio::HistoryTreeStore::Model model;
+
+ Gtk::TreeModel::Children::iterator iter, prev = children.end();
+ for (iter = children.begin(); iter != children.end(); prev = iter++)
+ if ((*iter)[model.is_redo])
+ {
+ if (prev == children.end())
+ action_tree->get_selection()->unselect_all();
+ else
+ {
+ action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5);
+ action_tree->get_selection()->select(prev);
+ }
+ return;
+ }
+
+ action_tree->scroll_to_row(Gtk::TreePath(prev), 0.5);
+ action_tree->get_selection()->select(prev);
+}
+
+void
Dock_History::set_selected_instance_(etl::handle instance)
{
if(studio::App::shutdown_in_progress)
return;
+ if (on_undo_tree_changed_connection)
+ on_undo_tree_changed_connection.disconnect();
+
selected_instance=instance;
if(instance)
{
+ on_undo_tree_changed_connection = selected_instance->history_tree_store()->signal_undo_tree_changed().connect(
+ sigc::mem_fun(*this,&Dock_History::on_undo_tree_changed));
+
action_tree->set_model(instance->history_tree_store());
action_tree->show();
update_undo_redo();