Skip to content

Commit cd443ce

Browse files
committed
Merge pull request #64 from diegorubin/feature-#62-move-task
Feature #62 move task
2 parents 47ed81a + d3a147e commit cd443ce

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

src/win_main.cc

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,16 @@ void WinMain::hide_task_buttons()
364364
lblPomodoros->set_text("");
365365
}
366366

367+
void WinMain::move_task(string list)
368+
{
369+
Task *task = get_current_task();
370+
task->set_list(list);
371+
task->save();
372+
373+
load_lists();
374+
load_tasks();
375+
}
376+
367377
void WinMain::execute(string hook)
368378
{
369379
if(currentTask) {
@@ -676,6 +686,24 @@ WinMain::TasksView::TasksView(BaseObjectType* cobject,
676686
: Gtk::TreeView(cobject),
677687
m_refGlade(refGlade)
678688
{
689+
Gtk::MenuItem* item;
690+
691+
std::list<TaskList*> lists = TaskList::all();
692+
while(!lists.empty()){
693+
item = Gtk::manage(new Gtk::MenuItem(lists.front()->get_name(), true));
694+
item->signal_activate().connect(
695+
sigc::mem_fun(*this, &TasksView::on_menu_move_task));
696+
menu.append(*item);
697+
lists.pop_front();
698+
}
699+
700+
menu.accelerate(*this);
701+
menu.show_all();
702+
703+
#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
704+
signal_button_press_event()
705+
.connect(sigc::mem_fun(*this, &TasksView::on_button_press_event), false);
706+
#endif
679707
}
680708

681709
void WinMain::TasksView::set_win_main_ref(WinMain *win_main)
@@ -688,3 +716,24 @@ void WinMain::TasksView::on_drag_end(const Glib::RefPtr< Gdk::DragContext >& con
688716
win_main->update_positions();
689717
}
690718

719+
void WinMain::TasksView::on_menu_move_task()
720+
{
721+
win_main->move_task(menu.get_active()->get_label());
722+
}
723+
724+
bool WinMain::TasksView::on_button_press_event(GdkEventButton* event)
725+
{
726+
bool return_value = false;
727+
728+
//Call base class, to allow normal handling,
729+
//such as allowing the row to be selected by the right-click:
730+
return_value = TreeView::on_button_press_event(event);
731+
732+
//Then do our custom stuff:
733+
if( (event->type == GDK_BUTTON_PRESS) && (event->button == 3) )
734+
{
735+
menu.popup(event->button, event->time);
736+
}
737+
738+
return return_value;
739+
}

src/win_main.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ class WinMain: public Gtk::Window
8080
void set_win_main_ref(WinMain *win_main);
8181
Glib::RefPtr<Gtk::Builder> m_refGlade;
8282
virtual void on_drag_end(const Glib::RefPtr< Gdk::DragContext >& context);
83+
virtual void on_menu_move_task();
84+
virtual bool on_button_press_event(GdkEventButton *ev);
85+
8386
WinMain *win_main;
87+
Gtk::Menu menu;
8488
};
8589

8690
// attributes
@@ -160,6 +164,7 @@ class WinMain: public Gtk::Window
160164
void set_notification(string notification);
161165
Glib::ustring get_current_list();
162166
void update_positions();
167+
void move_task(string list);
163168

164169
void show_task_buttons();
165170
void hide_task_buttons();

0 commit comments

Comments
 (0)