Blob Blame Raw
diff -up easystroke-0.6.0/actions.cc.duplicate easystroke-0.6.0/actions.cc
--- easystroke-0.6.0/actions.cc.duplicate	2019-10-18 15:08:04.421676670 -0400
+++ easystroke-0.6.0/actions.cc	2019-10-18 15:09:32.488770556 -0400
@@ -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);
@@ -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));
@@ -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);
@@ -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();
diff -up easystroke-0.6.0/actions.h.duplicate easystroke-0.6.0/actions.h
--- easystroke-0.6.0/actions.h.duplicate	2019-10-18 15:09:45.161496325 -0400
+++ easystroke-0.6.0/actions.h	2019-10-18 15:10:18.465790648 -0400
@@ -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();
@@ -138,7 +139,7 @@ private:
 
 	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;
diff -up easystroke-0.6.0/gui.glade.duplicate easystroke-0.6.0/gui.glade
--- easystroke-0.6.0/gui.glade.duplicate	2019-10-18 15:10:29.107565163 -0400
+++ easystroke-0.6.0/gui.glade	2019-10-18 15:11:17.402542478 -0400
@@ -816,6 +816,24 @@ Van Diep Duong (Vietnamese)</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">4</property>
+                  </packing>
+                </child>
+                <child>
                   <object class="GtkButton" id="button_hide1">
                     <property name="label" translatable="yes">_Hide</property>
                     <property name="use_action_appearance">False</property>
diff -up easystroke-0.6.0/po/zh_CN.po.duplicate easystroke-0.6.0/po/zh_CN.po
--- easystroke-0.6.0/po/zh_CN.po.duplicate	2019-10-18 15:11:34.192187095 -0400
+++ easystroke-0.6.0/po/zh_CN.po	2019-10-18 15:11:58.286677111 -0400
@@ -341,6 +341,9 @@ msgstr "添加动作"
 msgid "_Delete Action(s)"
 msgstr "删除动作"
 
+msgid "_Duplicate Action(s)"
+msgstr "复制动作"
+
 msgid "_Hide"
 msgstr "隐藏(_H)"