Skip to content

Commit

Permalink
Add a duplicate action button, you can duplicate a action and move it…
Browse files Browse the repository at this point in the history
… to another app now!
  • Loading branch information
tzraeq committed Jul 14, 2017
1 parent f7c1614 commit 1c0a060
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 2 deletions.
37 changes: 37 additions & 0 deletions actions.cc
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ Actions::Actions() :
Gtk::Button *button_add, *button_add_app, *button_add_group;
widgets->get_widget("button_add_action", button_add);
widgets->get_widget("button_delete_action", button_delete);
widgets->get_widget("button_dup_action", button_dup);
widgets->get_widget("button_record", button_record);
widgets->get_widget("button_add_app", button_add_app);
widgets->get_widget("button_add_group", button_add_group);
Expand All @@ -141,6 +142,7 @@ Actions::Actions() :
widgets->get_widget("vpaned_apps", vpaned_apps);
button_record->signal_clicked().connect(sigc::mem_fun(*this, &Actions::on_button_record));
button_delete->signal_clicked().connect(sigc::mem_fun(*this, &Actions::on_button_delete));
button_dup->signal_clicked().connect(sigc::mem_fun(*this, &Actions::on_button_dup));
button_add->signal_clicked().connect(sigc::mem_fun(*this, &Actions::on_button_new));
button_add_app->signal_clicked().connect(sigc::mem_fun(*this, &Actions::on_add_app));
button_add_group->signal_clicked().connect(sigc::mem_fun(*this, &Actions::on_add_group));
Expand Down Expand Up @@ -511,6 +513,40 @@ void Actions::on_button_delete() {
update_counts();
}

void Actions::on_button_dup() {
editing_new = true;
Unique *before = 0;
Glib::ustring name;
if (tv.get_selection()->count_selected_rows()) {
std::vector<Gtk::TreePath> paths = tv.get_selection()->get_selected_rows();
Gtk::TreeIter i = tm->get_iter(paths[paths.size()-1]);
//i++;
//if (i != tm->children().end())
before = (*i)[cols.id];
name = (*i)[cols.name];
}

RStrokeInfo src = action_list->get_info(before);

Gtk::TreeModel::Row row = *(tm->append());
StrokeInfo si;
si.action = src->action;
si.strokes = src->strokes;
Unique *id = action_list->add(si);
row[cols.id] = id;
action_list->set_name(id,name);
//std::string name;
/*if (action_list != actions.get_root())
name = action_list->name + " ";
name += Glib::ustring::compose(_("Gesture %1"), action_list->order_size());
action_list->set_name(id, name);*/

update_row(row);
focus(id, 1, true);
update_actions();
update_counts();
}

void Actions::on_cell_data_apps(Gtk::CellRenderer* cell, const Gtk::TreeModel::iterator& iter) {
ActionListDiff *as = (*iter)[ca.actions];
Gtk::CellRendererText *renderer = dynamic_cast<Gtk::CellRendererText *>(cell);
Expand Down Expand Up @@ -789,6 +825,7 @@ void Actions::on_selection_changed() {
int n = tv.get_selection()->count_selected_rows();
button_record->set_sensitive(n == 1);
button_delete->set_sensitive(n >= 1);
button_dup->set_sensitive(n >= 1);
bool resettable = false;
if (n) {
std::vector<Gtk::TreePath> paths = tv.get_selection()->get_selected_rows();
Expand Down
3 changes: 2 additions & 1 deletion actions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class Actions {
public:
Actions();
private:
void on_button_dup();
void on_button_delete();
void on_button_new();
void on_button_record();
Expand Down Expand Up @@ -138,7 +139,7 @@ class Actions {

Glib::RefPtr<Gtk::ListStore> type_store;

Gtk::Button *button_record, *button_delete, *button_remove_app, *button_reset_actions;
Gtk::Button *button_record, *button_delete, *button_remove_app, *button_reset_actions, *button_dup;
Gtk::CheckButton *check_show_deleted;
Gtk::Expander *expander_apps;
Gtk::VPaned *vpaned_apps;
Expand Down
20 changes: 19 additions & 1 deletion gui.glade
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,24 @@ Van Diep Duong (Vietnamese)</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_dup_action">
<property name="label" translatable="yes">_Duplicate Action(s)</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="use_action_appearance">False</property>
<property name="image">image4</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkButton" id="button_hide1">
<property name="label" translatable="yes">_Hide</property>
Expand All @@ -829,7 +847,7 @@ Van Diep Duong (Vietnamese)</property>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">3</property>
<property name="position">4</property>
<property name="secondary">True</property>
</packing>
</child>
Expand Down
3 changes: 3 additions & 0 deletions po/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,9 @@ msgstr "添加动作"
msgid "_Delete Action(s)"
msgstr "删除动作"

msgid "_Duplicate Action(s)"
msgstr "复制动作"

msgid "_Hide"
msgstr "隐藏(_H)"

Expand Down

0 comments on commit 1c0a060

Please sign in to comment.