Act on modified status changes
This commit is contained in:
parent
5c53f2c0c8
commit
c4049ad25b
|
@ -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> project_ptr;
|
||||
|
||||
assert(proxy);
|
||||
lash_proxy * me = reinterpret_cast<lash_proxy *>(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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,12 @@ public:
|
|||
bool
|
||||
get_modified_status();
|
||||
|
||||
bool
|
||||
set_modified_status(
|
||||
bool modified_status);
|
||||
|
||||
signal<void> _signal_renamed;
|
||||
signal<void> _signal_modified_status_changed;
|
||||
|
||||
private:
|
||||
project_impl * _impl_ptr;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue