(purple) NotifyMessage dialog
First of the NotifyUiOps― not sure if the others are used for anything useful in our use-case, I'll implement as I run into them.
This commit is contained in:
parent
2415be542e
commit
91ab9d8fb7
|
@ -33,6 +33,7 @@ APP_MIME_SIG = application/x-vnd.caya.purple
|
|||
# Also note that spaces in folder names do not work well with this Makefile.
|
||||
SRCS = \
|
||||
protocols/purple/PurpleApp.cpp \
|
||||
protocols/purple/PurpleDialog.cpp \
|
||||
protocols/purple/PurpleProtocol.cpp \
|
||||
|
||||
# Specify the resource definition files to use. Full or relative paths can be
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <glib.h>
|
||||
#include <libpurple/status.h>
|
||||
|
||||
#include <Alert.h>
|
||||
#include <Directory.h>
|
||||
#include <MessageRunner.h>
|
||||
#include <Path.h>
|
||||
|
@ -916,11 +917,30 @@ static PurpleRequestUiOps _ui_op_request =
|
|||
};
|
||||
|
||||
|
||||
static PurpleNotifyUiOps _ui_op_notify =
|
||||
{
|
||||
ui_op_notify_message,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
||||
void
|
||||
init_ui_ops()
|
||||
{
|
||||
purple_eventloop_set_ui_ops(&_ui_op_eventloops);
|
||||
purple_request_set_ui_ops(&_ui_op_request);
|
||||
purple_notify_set_ui_ops(&_ui_op_notify);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1275,6 +1295,25 @@ ui_op_request_action_with_icon(const char* title, const char* primary,
|
|||
}
|
||||
|
||||
|
||||
static void*
|
||||
ui_op_notify_message(PurpleNotifyMsgType type, const char* title,
|
||||
const char* primary, const char* secondary)
|
||||
{
|
||||
BString text = primary;
|
||||
text << "\n" << secondary;
|
||||
|
||||
BAlert* alert = new BAlert(title, text.String(), "OK");
|
||||
|
||||
if (type == PURPLE_NOTIFY_MSG_WARNING)
|
||||
alert->SetType(B_WARNING_ALERT);
|
||||
else if (type == PURPLE_NOTIFY_MSG_ERROR)
|
||||
alert->SetType(B_STOP_ALERT);
|
||||
|
||||
alert->Go(NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
is_own_user(PurpleAccount* account, const char* name)
|
||||
{
|
||||
|
|
|
@ -200,6 +200,11 @@ private:
|
|||
void* user_data, size_t action_count,
|
||||
va_list actions);
|
||||
|
||||
// Notify ui ops
|
||||
static void* ui_op_notify_message(PurpleNotifyMsgType type,
|
||||
const char* title, const char* primary,
|
||||
const char* secondary);
|
||||
|
||||
// Util
|
||||
bool is_own_user(PurpleAccount* account, const char* name);
|
||||
|
||||
|
|
|
@ -38,8 +38,8 @@ PurpleDialog::MessageReceived(BMessage* msg)
|
|||
int32 id;
|
||||
if (msg->FindInt32("index", &id) != B_OK) break;
|
||||
|
||||
PurpleRequestActionCb cb = fActions.ItemAt(0)->callback.action;
|
||||
cb(fUserData, fActions.ItemAt(0)->index);
|
||||
PurpleRequestActionCb cb = fActions.ItemAt(id)->callback.action;
|
||||
cb(fUserData, fActions.ItemAt(id)->index);
|
||||
Quit();
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,6 @@
|
|||
|
||||
const uint32 ACTION_BUTTON = 'PDab';
|
||||
|
||||
|
||||
struct RequestAction
|
||||
{
|
||||
BString name;
|
||||
|
|
Ŝarĝante…
Reference in New Issue