From 8bfb1f29d49928de1870538bfd7c2d2c58ede79a Mon Sep 17 00:00:00 2001 From: Diego Rubin Date: Wed, 1 Jul 2020 09:12:03 -0300 Subject: [PATCH] feature #74 base of new dialog --- data/gnomato.ui | 91 +++++++++- src/Makefile.am | 1 + src/dialog_work_log_entries.cc | 47 +++++ src/dialog_work_log_entries.h | 50 ++++++ src/win_main.cc | 10 ++ src/win_main.h | 319 +++++++++++++++++---------------- 6 files changed, 355 insertions(+), 163 deletions(-) create mode 100644 src/dialog_work_log_entries.cc create mode 100644 src/dialog_work_log_entries.h diff --git a/data/gnomato.ui b/data/gnomato.ui index b42767f..2e73e4f 100644 --- a/data/gnomato.ui +++ b/data/gnomato.ui @@ -1,12 +1,12 @@ - + False 5 dialog - + @@ -135,6 +135,78 @@ btnTaskOk + + DialogWorkLogEntries + False + center + dialog + center + + + + + + DialogWorkLogEntries + False + vertical + 2 + + + False + end + + + gtk-cancel + False + btnWorkLogCancel + True + True + True + True + + + False + True + 0 + + + + + gtk-save + btnWorkLogSave + True + True + True + Save Changes + True + + + True + True + 1 + + + + + False + False + 0 + + + + + + + + + btnWorkLogCancel + + + + True + False + gtk-justify-center + 1 @@ -168,7 +240,7 @@ center-always True dialog - + @@ -468,7 +540,7 @@ False 580 320 - + @@ -544,6 +616,15 @@ True + + + Worklog + False + True + False + False + + @@ -1045,7 +1126,7 @@ Diego Rubin help-about gpl-2-0 - + diff --git a/src/Makefile.am b/src/Makefile.am index 0440270..1c443af 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -15,6 +15,7 @@ gnomato_CPPFLAGS = \ gnomato_SOURCES = main.cc \ win_main.cc \ dialog_preferences.cc \ + dialog_work_log_entries.cc \ dialog_task.cc \ database.cc \ task.cc \ diff --git a/src/dialog_work_log_entries.cc b/src/dialog_work_log_entries.cc new file mode 100644 index 0000000..9381fb3 --- /dev/null +++ b/src/dialog_work_log_entries.cc @@ -0,0 +1,47 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ +/*! + * dialog_preferences.cc + * Copyright (C) Diego Rubin 2020 + * + * Gnomato is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gnomato is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Author: Diego Rubin + * + */ + +#include "dialog_work_log_entries.h" +#include + +DialogWorkLogEntries::DialogWorkLogEntries( + BaseObjectType *cobject, const Glib::RefPtr &refGlade) + : Gtk::Dialog(cobject), m_refGlade(refGlade) { + + // buttons + m_refGlade->get_widget("btnWorkLogSave", btnOk); + m_refGlade->get_widget("btnWorkLogCancel", btnCancel); + + // connect signals + btnCancel->signal_clicked().connect( + sigc::mem_fun(*this, &DialogWorkLogEntries::on_button_cancel_clicked)); + btnOk->signal_clicked().connect( + sigc::mem_fun(*this, &DialogWorkLogEntries::on_button_ok_clicked)); + + show_all(); +} + +DialogWorkLogEntries::~DialogWorkLogEntries() {} + +void DialogWorkLogEntries::on_button_cancel_clicked() { hide(); } + +void DialogWorkLogEntries::on_button_ok_clicked() { hide(); } diff --git a/src/dialog_work_log_entries.h b/src/dialog_work_log_entries.h new file mode 100644 index 0000000..e331430 --- /dev/null +++ b/src/dialog_work_log_entries.h @@ -0,0 +1,50 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 2; tab-width: 2 -*- */ +/*! + * dialog_preferences.h + * Copyright (C) Diego Rubin 2020 + * + * Gnomato is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Gnomato is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + * + * Author: Diego Rubin + * + */ + +#ifndef _WIN_WORK_LOG_ENTRIES_H_ +#define _WIN_WORK_LOG_ENTRIES_H_ + +#include + +using namespace Gtk; + +class DialogWorkLogEntries : public Gtk::Dialog { +public: + DialogWorkLogEntries(BaseObjectType *cobject, + const Glib::RefPtr &refGlade); + + virtual ~DialogWorkLogEntries(); + +protected: +private: + // attributes + Button *btnOk; + Button *btnCancel; + + Glib::RefPtr m_refGlade; + + // callback methods + virtual void on_button_cancel_clicked(); + virtual void on_button_ok_clicked(); +}; + +#endif // WIN_WORK_LOG_ENTRIES diff --git a/src/win_main.cc b/src/win_main.cc index 0bd8b3d..b0cf7f1 100644 --- a/src/win_main.cc +++ b/src/win_main.cc @@ -64,6 +64,7 @@ WinMain::WinMain(BaseObjectType *cobject, m_refGlade->get_widget("mnuNew", mnuNew); m_refGlade->get_widget("mnuQuit", mnuQuit); m_refGlade->get_widget("mnuPreferences", mnuPreferences); + m_refGlade->get_widget("mnuWorkLogEntries", mnuWorkLogEntries); m_refGlade->get_widget("mnuAbout", mnuAbout); m_refGlade->get_widget_derived("trvTasks", trvTasks); @@ -125,6 +126,8 @@ WinMain::WinMain(BaseObjectType *cobject, sigc::mem_fun(*this, &WinMain::on_menu_file_quit)); mnuPreferences->signal_activate().connect( sigc::mem_fun(*this, &WinMain::on_menu_edit_preferences)); + mnuWorkLogEntries->signal_activate().connect( + sigc::mem_fun(*this, &WinMain::on_menu_edit_work_log_entries)); mnuAbout->signal_activate().connect( sigc::mem_fun(*this, &WinMain::on_menu_help_about)); @@ -669,6 +672,13 @@ void WinMain::on_menu_edit_preferences() { configure_interface(); } +void WinMain::on_menu_edit_work_log_entries() { + DialogWorkLogEntries *dlgWorkLogEntries = 0; + + m_refGlade->get_widget_derived("DialogWorkLogEntries", dlgWorkLogEntries); + dlgWorkLogEntries->run(); +} + void WinMain::on_menu_help_about() { m_refGlade->get_widget("winAbout", abtDialog); abtDialog->run(); diff --git a/src/win_main.h b/src/win_main.h index a700fb2..c285f8e 100644 --- a/src/win_main.h +++ b/src/win_main.h @@ -34,6 +34,7 @@ #include "config.h" #include "dialog_preferences.h" #include "dialog_task.h" +#include "dialog_work_log_entries.h" #include "python_executor.h" #include "task.h" #include "task_list.h" @@ -45,164 +46,166 @@ using namespace boost::posix_time; const int MINUTE_IN_SECONDS = 60000; class WinMain : public Gtk::ShortcutsWindow { - public: - WinMain(BaseObjectType* cobject, const Glib::RefPtr& refGlade); - virtual ~WinMain(); - - void on_menu_file_new_task(); - void force_show(); - void load_lists(); - void load_tasks(); - - void set_green_icon(); - void set_red_icon(); - void set_gray_icon(); - - Glib::ustring get_current_time(); - Glib::ustring get_current_task_title(); - Glib::ustring get_cycle(); - - private: - class ModelColumns : public Gtk::TreeModel::ColumnRecord { - public: - ModelColumns() { - add(id); - add(title); - } - Gtk::TreeModelColumn id; - Gtk::TreeModelColumn title; - }; - - class TasksView : public Gtk::TreeView { - - public: - TasksView(BaseObjectType* cobject, - const Glib::RefPtr& refGlade); - - void set_win_main_ref(WinMain* win_main); - Glib::RefPtr m_refGlade; - virtual void on_drag_end(const Glib::RefPtr& context); - virtual void on_menu_move_task(); - virtual bool on_button_press_event(GdkEventButton* ev); - - WinMain* win_main; - Gtk::Menu menu; - }; - - // attributes - bool showed; - bool started; - unsigned int time_elapsed; - unsigned int minutes, seconds; - int cycle_number; - - Config configs; - - Task* currentTask; - std::list lists; - - // For pomodoro - sigc::slot timer; - sigc::connection timeout; - - // For inactive - sigc::slot inactive_timer; - sigc::connection check_inactive; - - Glib::RefPtr m_refGlade; - - // widgets - Button* btnStart; - Button* btnRestart; - Button* btnAddTask; - Button* btnDelTask; - Button* btnFinish; - Button* btnCancelTask; - Button* btnClearList; - - ImageMenuItem* mnuNew; - ImageMenuItem* mnuQuit; - ImageMenuItem* mnuPreferences; - ImageMenuItem* mnuAbout; - - Label* lblDisplay; - Label* lblCycle; - Label* lblTaskTitle; - Label* lblPomodoros; - Label* lblNotification; - - Entry* entFilter; - - Frame* frmWorkOn; - - TasksView* trvTasks; - ModelColumns mdlColumn; - - ComboBoxText* cmbLists; - - Glib::RefPtr systray; - Glib::RefPtr mnuSystray; - - Glib::RefPtr actMenu; - Glib::RefPtr mnuIniciar; - Glib::RefPtr treTasks; - - PythonExecutor* pe; - - // dialogs - DialogTask* dlgTask; - AboutDialog* abtDialog; - - // methods - std::string generate_display(); - std::string generate_cycle(); - void generate_pomodoros(); - void show_task(); - void log_work(string hook); - - void notify(const char* icon, const char* message); - void notify(const char* message); - void notify_with_green_icon(const char* message); - void notify_with_gray_icon(const char* message); - - Task* get_current_task(); - void inc_current_task(); - void execute(string script); - void run_python_script(string script); - void set_notification(string notification); - Glib::ustring get_current_list(); - void update_positions(); - void move_task(string list); - void set_systray(); - void configure_interface(); - - void show_task_buttons(); - void hide_task_buttons(); - - // callback methods - virtual void on_filter_changed(); - virtual void on_systray_activated(); - virtual void on_systray_popup(guint button, guint activate_time); - virtual void on_button_start_clicked(); - virtual void on_button_restart_clicked(); - virtual void on_button_finish_clicked(); - virtual void on_button_cancel_clicked(); - virtual void on_button_clear_list_clicked(); - virtual void on_treeview_tasks_row_activated(const TreeModel::Path& path, - TreeViewColumn* column); - virtual void on_button_del_task_clicked(); - virtual bool on_timeout(int timer_number); - virtual bool on_inactive_timeout(int timer_number); - virtual void on_cursor_changed(); - virtual void on_list_changed(); - - // callback methods - menu - virtual void on_menu_file_quit(); - virtual void on_menu_edit_preferences(); - virtual void on_menu_help_about(); - - // callback methods - window - virtual void on_resize(); +public: + WinMain(BaseObjectType *cobject, const Glib::RefPtr &refGlade); + virtual ~WinMain(); + + void on_menu_file_new_task(); + void force_show(); + void load_lists(); + void load_tasks(); + + void set_green_icon(); + void set_red_icon(); + void set_gray_icon(); + + Glib::ustring get_current_time(); + Glib::ustring get_current_task_title(); + Glib::ustring get_cycle(); + +private: + class ModelColumns : public Gtk::TreeModel::ColumnRecord { + public: + ModelColumns() { + add(id); + add(title); + } + Gtk::TreeModelColumn id; + Gtk::TreeModelColumn title; + }; + + class TasksView : public Gtk::TreeView { + + public: + TasksView(BaseObjectType *cobject, + const Glib::RefPtr &refGlade); + + void set_win_main_ref(WinMain *win_main); + Glib::RefPtr m_refGlade; + virtual void on_drag_end(const Glib::RefPtr &context); + virtual void on_menu_move_task(); + virtual bool on_button_press_event(GdkEventButton *ev); + + WinMain *win_main; + Gtk::Menu menu; + }; + + // attributes + bool showed; + bool started; + unsigned int time_elapsed; + unsigned int minutes, seconds; + int cycle_number; + + Config configs; + + Task *currentTask; + std::list lists; + + // For pomodoro + sigc::slot timer; + sigc::connection timeout; + + // For inactive + sigc::slot inactive_timer; + sigc::connection check_inactive; + + Glib::RefPtr m_refGlade; + + // widgets + Button *btnStart; + Button *btnRestart; + Button *btnAddTask; + Button *btnDelTask; + Button *btnFinish; + Button *btnCancelTask; + Button *btnClearList; + + ImageMenuItem *mnuNew; + ImageMenuItem *mnuQuit; + ImageMenuItem *mnuPreferences; + ImageMenuItem *mnuWorkLogEntries; + ImageMenuItem *mnuAbout; + + Label *lblDisplay; + Label *lblCycle; + Label *lblTaskTitle; + Label *lblPomodoros; + Label *lblNotification; + + Entry *entFilter; + + Frame *frmWorkOn; + + TasksView *trvTasks; + ModelColumns mdlColumn; + + ComboBoxText *cmbLists; + + Glib::RefPtr systray; + Glib::RefPtr mnuSystray; + + Glib::RefPtr actMenu; + Glib::RefPtr mnuIniciar; + Glib::RefPtr treTasks; + + PythonExecutor *pe; + + // dialogs + DialogTask *dlgTask; + AboutDialog *abtDialog; + + // methods + std::string generate_display(); + std::string generate_cycle(); + void generate_pomodoros(); + void show_task(); + void log_work(string hook); + + void notify(const char *icon, const char *message); + void notify(const char *message); + void notify_with_green_icon(const char *message); + void notify_with_gray_icon(const char *message); + + Task *get_current_task(); + void inc_current_task(); + void execute(string script); + void run_python_script(string script); + void set_notification(string notification); + Glib::ustring get_current_list(); + void update_positions(); + void move_task(string list); + void set_systray(); + void configure_interface(); + + void show_task_buttons(); + void hide_task_buttons(); + + // callback methods + virtual void on_filter_changed(); + virtual void on_systray_activated(); + virtual void on_systray_popup(guint button, guint activate_time); + virtual void on_button_start_clicked(); + virtual void on_button_restart_clicked(); + virtual void on_button_finish_clicked(); + virtual void on_button_cancel_clicked(); + virtual void on_button_clear_list_clicked(); + virtual void on_treeview_tasks_row_activated(const TreeModel::Path &path, + TreeViewColumn *column); + virtual void on_button_del_task_clicked(); + virtual bool on_timeout(int timer_number); + virtual bool on_inactive_timeout(int timer_number); + virtual void on_cursor_changed(); + virtual void on_list_changed(); + + // callback methods - menu + virtual void on_menu_file_quit(); + virtual void on_menu_edit_preferences(); + virtual void on_menu_edit_work_log_entries(); + virtual void on_menu_help_about(); + + // callback methods - window + virtual void on_resize(); }; #endif //__WIN_MAIN_H_