Represent LASH availability as sensivity of project list
This commit is contained in:
parent
96c4113e4d
commit
79654bff5c
|
@ -680,6 +680,13 @@ Patchage::dbus_call(
|
|||
return ap;
|
||||
}
|
||||
|
||||
void
|
||||
Patchage::set_lash_availability(
|
||||
bool lash_active)
|
||||
{
|
||||
_project_list->set_lash_availability(lash_active);
|
||||
}
|
||||
|
||||
void
|
||||
Patchage::on_project_added(
|
||||
const std::string& project_name)
|
||||
|
|
|
@ -82,6 +82,8 @@ public:
|
|||
int in_type,
|
||||
...);
|
||||
|
||||
void set_lash_availability(bool lash_active);
|
||||
|
||||
void
|
||||
on_project_added(
|
||||
const std::string& project_name);
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "lash_proxy.hpp"
|
||||
|
||||
#define LASH_SERVICE "org.nongnu.LASH"
|
||||
#define LASH_OBJECT "/"
|
||||
#define LASH_IFACE_CONTROL "org.nongnu.LASH.Control"
|
||||
|
||||
using namespace std;
|
||||
|
@ -35,6 +36,12 @@ lash_proxy::lash_proxy(Patchage* app)
|
|||
dbus_bus_add_match(_app->_dbus_connection, "type='signal',interface='" LASH_IFACE_CONTROL "',member=ProjectNameChanged", NULL);
|
||||
|
||||
dbus_connection_add_filter(_app->_dbus_connection, dbus_message_hook, this, NULL);
|
||||
|
||||
// call any method to update server responding status
|
||||
// this also actiavtes lash object if it not activated already
|
||||
list();
|
||||
|
||||
_app->set_lash_availability(_server_responding);
|
||||
}
|
||||
|
||||
lash_proxy::~lash_proxy()
|
||||
|
@ -94,10 +101,12 @@ lash_proxy::dbus_message_hook(
|
|||
if (old_owner[0] == '\0')
|
||||
{
|
||||
me->info_msg((string)"LASH activated.");
|
||||
me->_app->set_lash_availability(true);
|
||||
}
|
||||
else if (new_owner[0] == '\0')
|
||||
{
|
||||
me->info_msg((string)"LASH deactivated.");
|
||||
me->_app->set_lash_availability(false);
|
||||
}
|
||||
|
||||
return DBUS_HANDLER_RESULT_HANDLED;
|
||||
|
@ -140,3 +149,43 @@ lash_proxy::dbus_message_hook(
|
|||
|
||||
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
|
||||
}
|
||||
|
||||
bool
|
||||
lash_proxy::call(
|
||||
bool response_expected,
|
||||
const char* iface,
|
||||
const char* method,
|
||||
DBusMessage ** reply_ptr_ptr,
|
||||
int in_type,
|
||||
...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, in_type);
|
||||
|
||||
_server_responding = _app->dbus_call(
|
||||
response_expected,
|
||||
LASH_SERVICE,
|
||||
LASH_OBJECT,
|
||||
iface,
|
||||
method,
|
||||
reply_ptr_ptr,
|
||||
in_type,
|
||||
ap);
|
||||
|
||||
va_end(ap);
|
||||
|
||||
return _server_responding;
|
||||
}
|
||||
|
||||
void
|
||||
lash_proxy::list()
|
||||
{
|
||||
DBusMessage* reply_ptr;
|
||||
|
||||
if (!call(true, LASH_IFACE_CONTROL, "GetProjects", &reply_ptr, DBUS_TYPE_INVALID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
dbus_message_unref(reply_ptr);
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ public:
|
|||
lash_proxy(Patchage* app);
|
||||
~lash_proxy();
|
||||
|
||||
void list();
|
||||
|
||||
private:
|
||||
void error_msg(const std::string& msg) const;
|
||||
void info_msg(const std::string& msg) const;
|
||||
|
@ -38,6 +40,15 @@ private:
|
|||
DBusMessage * message,
|
||||
void * proxy);
|
||||
|
||||
bool
|
||||
call(
|
||||
bool response_expected,
|
||||
const char* iface,
|
||||
const char* method,
|
||||
DBusMessage ** reply_ptr_ptr,
|
||||
int in_type,
|
||||
...);
|
||||
|
||||
Patchage* _app;
|
||||
bool _server_responding;
|
||||
};
|
||||
|
|
|
@ -55,6 +55,13 @@ project_list::~project_list()
|
|||
delete _impl_ptr;
|
||||
}
|
||||
|
||||
void
|
||||
project_list::set_lash_availability(
|
||||
bool lash_active)
|
||||
{
|
||||
_impl_ptr->widget->set_sensitive(lash_active);
|
||||
}
|
||||
|
||||
void
|
||||
project_list::project_added(
|
||||
const string& project_name)
|
||||
|
|
|
@ -24,14 +24,16 @@ struct project_list_impl;
|
|||
class project_list
|
||||
{
|
||||
public:
|
||||
project_list(Glib::RefPtr<Gnome::Glade::Xml> xml);
|
||||
~project_list();
|
||||
project_list(Glib::RefPtr<Gnome::Glade::Xml> xml);
|
||||
~project_list();
|
||||
|
||||
void project_added(const string& project_name);
|
||||
void project_closed(const string& project_name);
|
||||
void set_lash_availability(bool lash_active);
|
||||
|
||||
void project_added(const string& project_name);
|
||||
void project_closed(const string& project_name);
|
||||
|
||||
private:
|
||||
project_list_impl * _impl_ptr;
|
||||
project_list_impl * _impl_ptr;
|
||||
};
|
||||
|
||||
#endif // #ifndef PROJECT_LIST_HPP__D786489B_E400_4E92_85C7_2BAE606DE56D__INCLUDED
|
||||
|
|
Loading…
Reference in New Issue