diff --git a/src/lash_proxy.cpp b/src/lash_proxy.cpp index c9600a00..1c9bd640 100644 --- a/src/lash_proxy.cpp +++ b/src/lash_proxy.cpp @@ -19,6 +19,7 @@ #include "common.hpp" #include "lash_proxy.hpp" #include "session.hpp" +#include "project.hpp" #define LASH_SERVICE "org.nongnu.LASH" #define LASH_OBJECT "/" @@ -39,6 +40,7 @@ lash_proxy::lash_proxy( dbus_bus_add_match(_app->_dbus_connection, "type='signal',interface='" LASH_IFACE_CONTROL "',member=ProjectAdded", NULL); dbus_bus_add_match(_app->_dbus_connection, "type='signal',interface='" LASH_IFACE_CONTROL "',member=ProjectClosed", NULL); dbus_bus_add_match(_app->_dbus_connection, "type='signal',interface='" LASH_IFACE_CONTROL "',member=ProjectNameChanged", NULL); + dbus_bus_add_match(_app->_dbus_connection, "type='signal',interface='" LASH_IFACE_CONTROL "',member=ProjectModifiedStatusChanged", NULL); dbus_connection_add_filter(_app->_dbus_connection, dbus_message_hook, this, NULL); @@ -82,6 +84,8 @@ lash_proxy::dbus_message_hook( const char * object_name; const char * old_owner; const char * new_owner; + dbus_bool_t modified_status; + shared_ptr project_ptr; assert(proxy); lash_proxy * me = reinterpret_cast(proxy); @@ -178,6 +182,30 @@ lash_proxy::dbus_message_hook( return DBUS_HANDLER_RESULT_HANDLED; } + if (dbus_message_is_signal(message, LASH_IFACE_CONTROL, "ProjectModifiedStatusChanged")) + { + if (!dbus_message_get_args( + message, &me->_app->_dbus_error, + DBUS_TYPE_STRING, &project_name, + DBUS_TYPE_BOOLEAN, &modified_status, + DBUS_TYPE_INVALID)) + { + me->error_msg(str(boost::format("dbus_message_get_args() failed to extract ProjectNameChanged signal arguments (%s)") % me->_app->_dbus_error.message)); + dbus_error_free(&me->_app->_dbus_error); + return DBUS_HANDLER_RESULT_HANDLED; + } + + me->info_msg((string)"Project '" + project_name + "' modified status changed to '" + (modified_status ? "true" : "false") + "'."); + + project_ptr = me->_session_ptr->find_project_by_name(project_name); + if (project_ptr) + { + project_ptr->set_modified_status(modified_status); + } + + return DBUS_HANDLER_RESULT_HANDLED; + } + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } diff --git a/src/project.cpp b/src/project.cpp index 6567f2d3..2b8bef50 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -77,3 +77,11 @@ project::get_modified_status() { return _impl_ptr->modified_status; } + +bool +project::set_modified_status( + bool modified_status) +{ + _impl_ptr->modified_status = modified_status; + _signal_modified_status_changed.emit(); +} diff --git a/src/project.hpp b/src/project.hpp index 14843259..149ddbd5 100644 --- a/src/project.hpp +++ b/src/project.hpp @@ -51,7 +51,12 @@ public: bool get_modified_status(); + bool + set_modified_status( + bool modified_status); + signal _signal_renamed; + signal _signal_modified_status_changed; private: project_impl * _impl_ptr; diff --git a/src/project_list.cpp b/src/project_list.cpp index b2df793a..b328ae90 100644 --- a/src/project_list.cpp +++ b/src/project_list.cpp @@ -208,6 +208,7 @@ project_list_impl::project_added( row[_columns.project_ptr] = project_ptr; project_ptr->_signal_renamed.connect(bind(mem_fun(this, &project_list_impl::project_renamed), iter)); + project_ptr->_signal_modified_status_changed.connect(bind(mem_fun(this, &project_list_impl::project_renamed), iter)); } void @@ -245,6 +246,12 @@ project_list_impl::project_renamed( project_ptr = row[_columns.project_ptr]; project_ptr->get_name(project_name); + + if (project_ptr->get_modified_status()) + { + project_name += " *"; + } + row[_columns.name] = project_name; }