gnoemoe/mcp/gm-mcp-icecrew-playerdb.c: max version to 1.1
gnoemoe/mcp/gm-mcp.c: fixed version check gnoemoe/mcp/gm-mcp-userlist-view.[ch]: added status message, fixed sorting, added number of players gnoemoe/mcp/gm-mcp-vmoo-userlist.[ch]: gnoemoe/mcp/gm-mcp-icecrew-userlist.[ch]: implement iuserlist gnoemoe/mcp/gm-iuserlist.[ch]: added signals, added functions
This commit is contained in:
parent
1170564bae
commit
65d460b3ee
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
|
* gnoemoe/mcp/gm-mcp-icecrew-playerdb.c: max version to 1.1
|
||||||
|
* gnoemoe/mcp/gm-mcp.c: fixed version check
|
||||||
|
* gnoemoe/mcp/gm-mcp-userlist-view.[ch]: added status message, fixed
|
||||||
|
sorting, added number of players
|
||||||
|
* gnoemoe/mcp/gm-mcp-vmoo-userlist.[ch]:
|
||||||
|
* gnoemoe/mcp/gm-mcp-icecrew-userlist.[ch]:
|
||||||
|
implement iuserlist
|
||||||
|
* gnoemoe/mcp/gm-iuserlist.[ch]: added signals, added functions
|
||||||
|
|
||||||
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
2006-07-04 Jesse van den Kieboom <jesse@icecrew.nl>
|
||||||
* gnoemoe/dialogs/gm-scripts-dialog.c: added theme
|
* gnoemoe/dialogs/gm-scripts-dialog.c: added theme
|
||||||
* gnoemoe/dialogs/gm-world-properties-dialog.c: added logging
|
* gnoemoe/dialogs/gm-world-properties-dialog.c: added logging
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#include "gm-iuserlist.h"
|
#include "gm-iuserlist.h"
|
||||||
|
#include "gm-marshal.h"
|
||||||
|
|
||||||
|
static void gm_iuserlist_base_init(gpointer object_class);
|
||||||
|
|
||||||
GType
|
GType
|
||||||
gm_iuserlist_get_type() {
|
gm_iuserlist_get_type() {
|
||||||
|
@ -7,7 +10,7 @@ gm_iuserlist_get_type() {
|
||||||
if (iuserlist_type == 0) {
|
if (iuserlist_type == 0) {
|
||||||
static const GTypeInfo iuserlist_info = {
|
static const GTypeInfo iuserlist_info = {
|
||||||
sizeof (GmIUserlistInterface),
|
sizeof (GmIUserlistInterface),
|
||||||
NULL, /* base_init */
|
gm_iuserlist_base_init, /* base_init */
|
||||||
NULL, /* base_finalize */
|
NULL, /* base_finalize */
|
||||||
NULL, /* class_init */
|
NULL, /* class_init */
|
||||||
NULL, /* class_finalize */
|
NULL, /* class_finalize */
|
||||||
|
@ -24,6 +27,61 @@ gm_iuserlist_get_type() {
|
||||||
return iuserlist_type;
|
return iuserlist_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_iuserlist_base_init(gpointer object_class) {
|
||||||
|
static gboolean initialized = FALSE;
|
||||||
|
|
||||||
|
if (!initialized) {
|
||||||
|
g_signal_new("player_added",
|
||||||
|
G_OBJECT_CLASS_TYPE(object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(GmIUserlistInterface, player_added),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
g_signal_new("player_removed",
|
||||||
|
G_OBJECT_CLASS_TYPE(object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(GmIUserlistInterface, player_removed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
g_signal_new("name_changed",
|
||||||
|
G_OBJECT_CLASS_TYPE(object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(GmIUserlistInterface, name_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
g_signal_new("state_changed",
|
||||||
|
G_OBJECT_CLASS_TYPE(object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(GmIUserlistInterface, state_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
g_signal_new("rank_changed",
|
||||||
|
G_OBJECT_CLASS_TYPE(object_class),
|
||||||
|
G_SIGNAL_RUN_LAST,
|
||||||
|
G_STRUCT_OFFSET(GmIUserlistInterface, rank_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__INT,
|
||||||
|
G_TYPE_NONE,
|
||||||
|
1,
|
||||||
|
G_TYPE_INT);
|
||||||
|
|
||||||
|
initialized = TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
GList *
|
GList *
|
||||||
gm_iuserlist_get_menu(GmIUserlist *self, gint id) {
|
gm_iuserlist_get_menu(GmIUserlist *self, gint id) {
|
||||||
GmIUserlistInterface *iface;
|
GmIUserlistInterface *iface;
|
||||||
|
@ -47,11 +105,7 @@ gm_iuserlist_supports_status(GmIUserlist *self) {
|
||||||
|
|
||||||
iface = GM_IUSERLIST_GET_INTERFACE(self);
|
iface = GM_IUSERLIST_GET_INTERFACE(self);
|
||||||
|
|
||||||
if (iface->supports_status) {
|
return (iface->get_status != NULL);
|
||||||
return (* iface->supports_status) (self);
|
|
||||||
} else {
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
|
@ -83,3 +137,48 @@ gm_iuserlist_get_name(GmIUserlist *self, gint id) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar const *
|
||||||
|
gm_iuserlist_get_icon(GmIUserlist *self, gint id, gboolean use_state) {
|
||||||
|
GmIUserlistInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GM_IS_IUSERLIST(self), NULL);
|
||||||
|
|
||||||
|
iface = GM_IUSERLIST_GET_INTERFACE(self);
|
||||||
|
|
||||||
|
if (iface->get_icon) {
|
||||||
|
return (* iface->get_icon) (self, id, use_state);
|
||||||
|
} else {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_iuserlist_get_rank_priority(GmIUserlist *self, gint id) {
|
||||||
|
GmIUserlistInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GM_IS_IUSERLIST(self), 0);
|
||||||
|
|
||||||
|
iface = GM_IUSERLIST_GET_INTERFACE(self);
|
||||||
|
|
||||||
|
if (iface->get_rank_priority) {
|
||||||
|
return (* iface->get_rank_priority) (self, id);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_iuserlist_get_state_priority(GmIUserlist *self, gint id) {
|
||||||
|
GmIUserlistInterface *iface;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GM_IS_IUSERLIST(self), 0);
|
||||||
|
|
||||||
|
iface = GM_IUSERLIST_GET_INTERFACE(self);
|
||||||
|
|
||||||
|
if (iface->get_state_priority) {
|
||||||
|
return (* iface->get_state_priority) (self, id);
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -21,9 +21,19 @@ struct _GmIUserlistInterface {
|
||||||
GTypeInterface parent;
|
GTypeInterface parent;
|
||||||
|
|
||||||
GList *(* get_menu) (GmIUserlist *self, gint id);
|
GList *(* get_menu) (GmIUserlist *self, gint id);
|
||||||
gboolean (* supports_status) (GmIUserlist *self);
|
|
||||||
gchar *(* get_status) (GmIUserlist *self, gint id);
|
gchar *(* get_status) (GmIUserlist *self, gint id);
|
||||||
|
|
||||||
gchar const *(* get_name) (GmIUserlist *self, gint id);
|
gchar const *(* get_name) (GmIUserlist *self, gint id);
|
||||||
|
gchar const *(* get_icon) (GmIUserlist *self, gint id, gboolean use_state);
|
||||||
|
gint (* get_rank_priority) (GmIUserlist *self, gint id);
|
||||||
|
gint (* get_state_priority) (GmIUserlist *self, gint id);
|
||||||
|
|
||||||
|
/* Signals */
|
||||||
|
void (* player_added) (GmIUserlist *obj, gint id);
|
||||||
|
void (* player_removed) (GmIUserlist *obj, gint id);
|
||||||
|
void (* name_changed) (GmIUserlist *obj, gint id);
|
||||||
|
void (* state_changed) (GmIUserlist *obj, gint id);
|
||||||
|
void (* rank_changed) (GmIUserlist *obj, gint id);
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gm_iuserlist_get_type();
|
GType gm_iuserlist_get_type();
|
||||||
|
@ -31,6 +41,11 @@ GType gm_iuserlist_get_type();
|
||||||
GList *gm_iuserlist_get_menu(GmIUserlist *self, gint id);
|
GList *gm_iuserlist_get_menu(GmIUserlist *self, gint id);
|
||||||
gboolean gm_iuserlist_supports_status(GmIUserlist *self);
|
gboolean gm_iuserlist_supports_status(GmIUserlist *self);
|
||||||
gchar *gm_iuserlist_get_status(GmIUserlist *self, gint id);
|
gchar *gm_iuserlist_get_status(GmIUserlist *self, gint id);
|
||||||
|
|
||||||
gchar const *gm_iuserlist_get_name(GmIUserlist *self, gint id);
|
gchar const *gm_iuserlist_get_name(GmIUserlist *self, gint id);
|
||||||
|
gchar const *gm_iuserlist_get_icon(GmIUserlist *self, gint id,
|
||||||
|
gboolean use_state);
|
||||||
|
gint gm_iuserlist_get_rank_priority(GmIUserlist *self, gint id);
|
||||||
|
gint gm_iuserlist_get_state_priority(GmIUserlist *self, gint id);
|
||||||
|
|
||||||
#endif /* __GM_IUSERLIST_H__ */
|
#endif /* __GM_IUSERLIST_H__ */
|
||||||
|
|
|
@ -100,7 +100,8 @@ gm_mcp_icecrew_playerdb_class_init(GmMcpIcecrewPlayerdbClass *klass) {
|
||||||
pklass->name = "dns-nl-icecrew-playerdb";
|
pklass->name = "dns-nl-icecrew-playerdb";
|
||||||
pklass->handle_simple = &gm_mcp_icecrew_playerdb_handle_simple;
|
pklass->handle_simple = &gm_mcp_icecrew_playerdb_handle_simple;
|
||||||
pklass->handle_multi = &gm_mcp_icecrew_playerdb_handle_multi;
|
pklass->handle_multi = &gm_mcp_icecrew_playerdb_handle_multi;
|
||||||
|
pklass->min_version = 1.0;
|
||||||
|
pklass->max_version = 1.1;
|
||||||
g_type_class_add_private(object_class, sizeof(GmMcpIcecrewPlayerdbPrivate));
|
g_type_class_add_private(object_class, sizeof(GmMcpIcecrewPlayerdbPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +347,7 @@ gm_mcp_icecrew_playerdb_handle_multi(GmMcpPackage *package,
|
||||||
if ((ppi = gm_mcp_icecrew_playerdb_find(playerdb, i))) {
|
if ((ppi = gm_mcp_icecrew_playerdb_find(playerdb, i))) {
|
||||||
gm_mcp_icecrew_playerdb_remove_player(playerdb, i);
|
gm_mcp_icecrew_playerdb_remove_player(playerdb, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
ppi = gm_mcp_icecrew_playerdb_add_player(playerdb, i);
|
ppi = gm_mcp_icecrew_playerdb_add_player(playerdb, i);
|
||||||
|
|
||||||
for (counter = 0; counter < g_list_length(l); ++counter) {
|
for (counter = 0; counter < g_list_length(l); ++counter) {
|
||||||
|
|
|
@ -25,9 +25,9 @@
|
||||||
static GmKeyValuePair default_states[] = {
|
static GmKeyValuePair default_states[] = {
|
||||||
{"away+idle", "ice-userlist/away+idle.svg"},
|
{"away+idle", "ice-userlist/away+idle.svg"},
|
||||||
{"busy+idle", "ice-userlist/busy+idle.svg"},
|
{"busy+idle", "ice-userlist/busy+idle.svg"},
|
||||||
|
{"avail+idle", "ice-userlist/avail+idle.svg"},
|
||||||
{"away", "ice-userlist/away.svg"},
|
{"away", "ice-userlist/away.svg"},
|
||||||
{"busy", "ice-userlist/busy.svg"},
|
{"busy", "ice-userlist/busy.svg"},
|
||||||
{"avail+idle", "ice-userlist/avail+idle.svg"},
|
|
||||||
{NULL, NULL}
|
{NULL, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ struct _GmMcpIcecrewUserlistPrivate {
|
||||||
|
|
||||||
gchar *rank_dir;
|
gchar *rank_dir;
|
||||||
gchar *state_dir;
|
gchar *state_dir;
|
||||||
|
gchar **property_names;
|
||||||
GList *menu;
|
GList *menu;
|
||||||
|
|
||||||
gboolean initializing;
|
gboolean initializing;
|
||||||
|
@ -65,19 +65,34 @@ static gchar *gm_mcp_icecrew_userlist_overrides[] = {
|
||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Signals */
|
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PLAYER_ADDED,
|
P_NAME,
|
||||||
PLAYER_REMOVED,
|
P_RANK,
|
||||||
NAME_CHANGED,
|
P_STATE,
|
||||||
STATE_CHANGED,
|
P_STATE_MSG
|
||||||
RANK_CHANGED,
|
|
||||||
NUM_SIGNALS
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static gchar *gm_mcp_icecrew_userlist_property_names0[] = {
|
||||||
|
"P_NAME",
|
||||||
|
"P_RANK",
|
||||||
|
"P_STATE",
|
||||||
|
"P_STATE_MSG"
|
||||||
|
};
|
||||||
|
static gchar *gm_mcp_icecrew_userlist_property_names1[] = {
|
||||||
|
"name",
|
||||||
|
"rank",
|
||||||
|
"state",
|
||||||
|
"state_msg"
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Signals
|
||||||
|
|
||||||
|
enum {
|
||||||
|
NUM_SIGNALS
|
||||||
|
}; */
|
||||||
|
|
||||||
|
//static guint gm_mcp_icecrew_userlist_signals[NUM_SIGNALS] = {0};
|
||||||
static void gm_mcp_icecrew_userlist_iface_init(GmIUserlistInterface *iface);
|
static void gm_mcp_icecrew_userlist_iface_init(GmIUserlistInterface *iface);
|
||||||
static guint gm_mcp_icecrew_userlist_signals[NUM_SIGNALS] = {0};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED(GmMcpIcecrewUserlist, gm_mcp_icecrew_userlist, \
|
G_DEFINE_TYPE_EXTENDED(GmMcpIcecrewUserlist, gm_mcp_icecrew_userlist, \
|
||||||
GM_TYPE_MCP_PACKAGE, 0, G_IMPLEMENT_INTERFACE(GM_TYPE_IUSERLIST, \
|
GM_TYPE_MCP_PACKAGE, 0, G_IMPLEMENT_INTERFACE(GM_TYPE_IUSERLIST, \
|
||||||
|
@ -109,15 +124,23 @@ void gm_mcp_icecrew_userlist_fetch_progress(GmFetchHandle *g,
|
||||||
GList *gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id);
|
GList *gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id);
|
||||||
gboolean gm_mcp_icecrew_userlist_supports_status(GmIUserlist *userlist);
|
gboolean gm_mcp_icecrew_userlist_supports_status(GmIUserlist *userlist);
|
||||||
gchar *gm_mcp_icecrew_userlist_get_status(GmIUserlist *userlist, gint id);
|
gchar *gm_mcp_icecrew_userlist_get_status(GmIUserlist *userlist, gint id);
|
||||||
|
|
||||||
gchar const *gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id);
|
gchar const *gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id);
|
||||||
|
gchar const *gm_mcp_icecrew_userlist_get_icon(GmIUserlist *userlist, gint id,
|
||||||
|
gboolean use_state);
|
||||||
|
gint gm_mcp_icecrew_userlist_get_rank_priority(GmIUserlist *userlist, gint id);
|
||||||
|
gint gm_mcp_icecrew_userlist_get_state_priority(GmIUserlist *userlist, gint id);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gm_mcp_icecrew_userlist_iface_init(
|
gm_mcp_icecrew_userlist_iface_init(
|
||||||
GmIUserlistInterface *iface) {
|
GmIUserlistInterface *iface) {
|
||||||
iface->get_menu = gm_mcp_icecrew_userlist_get_menu;
|
iface->get_menu = gm_mcp_icecrew_userlist_get_menu;
|
||||||
iface->supports_status = gm_mcp_icecrew_userlist_supports_status;
|
|
||||||
iface->get_status = gm_mcp_icecrew_userlist_get_status;
|
iface->get_status = gm_mcp_icecrew_userlist_get_status;
|
||||||
|
|
||||||
iface->get_name = gm_mcp_icecrew_userlist_get_name;
|
iface->get_name = gm_mcp_icecrew_userlist_get_name;
|
||||||
|
iface->get_icon = gm_mcp_icecrew_userlist_get_icon;
|
||||||
|
iface->get_rank_priority = gm_mcp_icecrew_userlist_get_rank_priority;
|
||||||
|
iface->get_state_priority = gm_mcp_icecrew_userlist_get_state_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -187,69 +210,11 @@ gm_mcp_icecrew_userlist_class_init(GmMcpIcecrewUserlistClass *klass) {
|
||||||
|
|
||||||
object_class->finalize = gm_mcp_icecrew_userlist_finalize;
|
object_class->finalize = gm_mcp_icecrew_userlist_finalize;
|
||||||
|
|
||||||
gm_mcp_icecrew_userlist_signals[PLAYER_ADDED] =
|
|
||||||
g_signal_new("player_added",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpIcecrewUserlistClass, player_added),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
3,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
gm_mcp_icecrew_userlist_signals[PLAYER_REMOVED] =
|
|
||||||
g_signal_new("player_removed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpIcecrewUserlistClass, player_removed),
|
|
||||||
NULL, NULL,
|
|
||||||
g_cclosure_marshal_VOID__INT,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
1,
|
|
||||||
G_TYPE_INT);
|
|
||||||
gm_mcp_icecrew_userlist_signals[NAME_CHANGED] =
|
|
||||||
g_signal_new("name_changed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpIcecrewUserlistClass, name_changed),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
2,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
gm_mcp_icecrew_userlist_signals[STATE_CHANGED] =
|
|
||||||
g_signal_new("state_changed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpIcecrewUserlistClass, state_changed),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
3,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
|
|
||||||
gm_mcp_icecrew_userlist_signals[RANK_CHANGED] =
|
|
||||||
g_signal_new("rank_changed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpIcecrewUserlistClass, rank_changed),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
3,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
|
|
||||||
pklass->name = "dns-nl-icecrew-userlist";
|
pklass->name = "dns-nl-icecrew-userlist";
|
||||||
pklass->depends = gm_mcp_icecrew_userlist_depends;
|
pklass->depends = gm_mcp_icecrew_userlist_depends;
|
||||||
pklass->overrides = gm_mcp_icecrew_userlist_overrides;
|
pklass->overrides = gm_mcp_icecrew_userlist_overrides;
|
||||||
|
pklass->min_version = 1.0;
|
||||||
|
pklass->max_version = 1.1;
|
||||||
pklass->set_session = &gm_mcp_icecrew_userlist_set_session;
|
pklass->set_session = &gm_mcp_icecrew_userlist_set_session;
|
||||||
pklass->handle_multi = &gm_mcp_icecrew_userlist_handle_multi;
|
pklass->handle_multi = &gm_mcp_icecrew_userlist_handle_multi;
|
||||||
pklass->create_view = &gm_mcp_icecrew_userlist_create_view;
|
pklass->create_view = &gm_mcp_icecrew_userlist_create_view;
|
||||||
|
@ -272,10 +237,14 @@ gm_mcp_icecrew_userlist_find_icon_names(GList *icons, gchar const *path) {
|
||||||
GList *item, *res = NULL;
|
GList *item, *res = NULL;
|
||||||
GmKeyValuePair *map;
|
GmKeyValuePair *map;
|
||||||
|
|
||||||
|
if (path == NULL || icons == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (item = icons; item; item = item->next) {
|
for (item = icons; item; item = item->next) {
|
||||||
map = (GmKeyValuePair *)(item->data);
|
map = (GmKeyValuePair *)(item->data);
|
||||||
|
|
||||||
if (strcmp(map->value, path) == 0) {
|
if (map->value != NULL && strcmp(map->value, path) == 0) {
|
||||||
res = g_list_append(res, map->key);
|
res = g_list_append(res, map->key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,15 +254,23 @@ gm_mcp_icecrew_userlist_find_icon_names(GList *icons, gchar const *path) {
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gm_mcp_icecrew_userlist_find_path(GList *icons, gchar const *name,
|
gm_mcp_icecrew_userlist_find_path(GList *icons, gchar const *name,
|
||||||
gchar **path) {
|
gchar const **path) {
|
||||||
GList *item;
|
GList *item;
|
||||||
GmKeyValuePair *map;
|
GmKeyValuePair *map;
|
||||||
guint position = 0;
|
guint position = 0;
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
if (path != NULL) {
|
||||||
|
*path = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
for (item = icons; item; item = item->next) {
|
for (item = icons; item; item = item->next) {
|
||||||
map = (GmKeyValuePair *)(item->data);
|
map = (GmKeyValuePair *)(item->data);
|
||||||
|
|
||||||
if (strcmp(map->key, name) == 0) {
|
if (map->key != NULL && strcmp(map->key, name) == 0) {
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
*path = map->value;
|
*path = map->value;
|
||||||
}
|
}
|
||||||
|
@ -316,6 +293,10 @@ gm_mcp_icecrew_userlist_remove_datatag(GmMcpIcecrewUserlist *package,
|
||||||
GList *item;
|
GList *item;
|
||||||
GmKeyValuePair *map;
|
GmKeyValuePair *map;
|
||||||
|
|
||||||
|
if (datatag == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (item = package->priv->key_datatags; item; item = item->next) {
|
for (item = package->priv->key_datatags; item; item = item->next) {
|
||||||
map = (GmKeyValuePair *)(item->data);
|
map = (GmKeyValuePair *)(item->data);
|
||||||
|
|
||||||
|
@ -337,10 +318,14 @@ gm_mcp_icecrew_userlist_find_key(GmMcpIcecrewUserlist *package,
|
||||||
GList *item;
|
GList *item;
|
||||||
GmKeyValuePair *map;
|
GmKeyValuePair *map;
|
||||||
|
|
||||||
|
if (datatag == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
for (item = package->priv->key_datatags; item; item = item->next) {
|
for (item = package->priv->key_datatags; item; item = item->next) {
|
||||||
map = (GmKeyValuePair *)(item->data);
|
map = (GmKeyValuePair *)(item->data);
|
||||||
|
|
||||||
if (strcmp(map->value, datatag) == 0) {
|
if (map->value != NULL && strcmp(map->value, datatag) == 0) {
|
||||||
return map->key;
|
return map->key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -352,9 +337,13 @@ gchar const *
|
||||||
gm_mcp_icecrew_userlist_find_name(gchar const *name,
|
gm_mcp_icecrew_userlist_find_name(gchar const *name,
|
||||||
GmKeyValuePair def[]) {
|
GmKeyValuePair def[]) {
|
||||||
GmKeyValuePair *pair = def;
|
GmKeyValuePair *pair = def;
|
||||||
|
|
||||||
|
if (name == NULL) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
while (!(pair->key == NULL && pair->value == NULL)) {
|
while (!(pair->key == NULL && pair->value == NULL)) {
|
||||||
if (strcmp(pair->key, name) == 0) {
|
if (pair->key != NULL && strcmp(pair->key, name) == 0) {
|
||||||
return pair->value;
|
return pair->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +392,7 @@ gm_mcp_icecrew_userlist_init(GmMcpIcecrewUserlist *obj) {
|
||||||
obj->priv->state_fetch = NULL;
|
obj->priv->state_fetch = NULL;
|
||||||
|
|
||||||
gm_mcp_icecrew_userlist_init_states(obj);
|
gm_mcp_icecrew_userlist_init_states(obj);
|
||||||
gm_mcp_icecrew_userlist_init_ranks(obj);
|
gm_mcp_icecrew_userlist_init_ranks(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
GmMcpIcecrewUserlist *
|
GmMcpIcecrewUserlist *
|
||||||
|
@ -433,7 +422,11 @@ gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package,
|
||||||
gint i;
|
gint i;
|
||||||
GmKeyValuePair *map;
|
GmKeyValuePair *map;
|
||||||
gchar *name, *pathd, *dir;
|
gchar *name, *pathd, *dir;
|
||||||
|
|
||||||
|
if (path == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
alter = rank ? &(package->priv->rank_alternatives) :
|
alter = rank ? &(package->priv->rank_alternatives) :
|
||||||
&(package->priv->state_alternatives);
|
&(package->priv->state_alternatives);
|
||||||
dir = rank ? package->priv->rank_dir : package->priv->state_dir;
|
dir = rank ? package->priv->rank_dir : package->priv->state_dir;
|
||||||
|
@ -442,20 +435,22 @@ gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package,
|
||||||
map = (GmKeyValuePair *)(item->data);
|
map = (GmKeyValuePair *)(item->data);
|
||||||
pathd = gm_mcp_icecrew_userlist_remote_to_local_path(map->value, dir);
|
pathd = gm_mcp_icecrew_userlist_remote_to_local_path(map->value, dir);
|
||||||
|
|
||||||
if (strcmp(pathd, path) == 0) {
|
if (pathd != NULL && strcmp(pathd, path) == 0) {
|
||||||
name = g_strdup(map->key);
|
name = g_strdup(map->key);
|
||||||
i = 0;
|
i = 0;
|
||||||
|
|
||||||
while (item && (n == 0 || i < n)) {
|
if (name != NULL) {
|
||||||
map = (GmKeyValuePair *)(item->data);
|
while (item && (n == 0 || i < n)) {
|
||||||
++i;
|
map = (GmKeyValuePair *)(item->data);
|
||||||
|
++i;
|
||||||
|
|
||||||
if (strcmp(map->key, name) == 0) {
|
if (map->key != NULL && strcmp(map->key, name) == 0) {
|
||||||
item = item->next;
|
item = item->next;
|
||||||
*alter = g_list_remove(*alter, map);
|
*alter = g_list_remove(*alter, map);
|
||||||
gm_mcp_icecrew_userlist_pair_free(map);
|
gm_mcp_icecrew_userlist_pair_free(map);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,40 +463,19 @@ gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar const *
|
||||||
gm_mcp_icecrew_userlist_sort_string(GmMcpIcecrewUserlist *package,
|
|
||||||
GmPlayerdbPlayerInfo *ppi) {
|
|
||||||
/* Find the appropriate icon */
|
|
||||||
gchar const *state = gm_playerdb_player_info_get_prop(ppi, "P_STATE");
|
|
||||||
gchar const *rank = gm_playerdb_player_info_get_prop(ppi, "P_RANK");
|
|
||||||
gchar const *name = gm_playerdb_player_info_get_prop(ppi, "P_NAME");
|
|
||||||
gint sortid;
|
|
||||||
|
|
||||||
/* Sort on icon, and then on name */
|
|
||||||
if (strcmp(state, "avail") == 0) {
|
|
||||||
sortid = g_list_length(package->priv->rank_icons) -
|
|
||||||
gm_mcp_icecrew_userlist_find_path(package->priv->rank_icons,
|
|
||||||
rank, NULL) - 1;
|
|
||||||
} else {
|
|
||||||
sortid = (g_list_length(package->priv->state_icons) -
|
|
||||||
gm_mcp_icecrew_userlist_find_path(package->priv->state_icons,
|
|
||||||
state, NULL) - 1) + g_list_length(package->priv->rank_icons);
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_strdup_printf("%.2d%s", sortid, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gm_mcp_icecrew_userlist_icon_path(GmMcpIcecrewUserlist *package,
|
gm_mcp_icecrew_userlist_icon_path(GmMcpIcecrewUserlist *package,
|
||||||
GmPlayerdbPlayerInfo *ppi) {
|
GmPlayerdbPlayerInfo *ppi, gboolean use_state) {
|
||||||
gchar const *state;
|
gchar const *state;
|
||||||
gchar *icon_path = NULL;
|
gchar const *icon_path = NULL;
|
||||||
|
|
||||||
state = gm_playerdb_player_info_get_prop(ppi, "P_STATE");
|
state = gm_playerdb_player_info_get_prop(ppi,
|
||||||
|
package->priv->property_names[P_STATE]);
|
||||||
|
|
||||||
if (state && strcmp(state, "avail") == 0) {
|
if (!use_state || (state != NULL && strcmp(state, "avail") == 0)) {
|
||||||
gm_mcp_icecrew_userlist_find_path(package->priv->rank_icons,
|
gm_mcp_icecrew_userlist_find_path(package->priv->rank_icons,
|
||||||
gm_playerdb_player_info_get_prop(ppi, "P_RANK"), &icon_path);
|
gm_playerdb_player_info_get_prop(ppi,
|
||||||
|
package->priv->property_names[P_RANK]), &icon_path);
|
||||||
} else {
|
} else {
|
||||||
gm_mcp_icecrew_userlist_find_path(package->priv->state_icons,
|
gm_mcp_icecrew_userlist_find_path(package->priv->state_icons,
|
||||||
state, &icon_path);
|
state, &icon_path);
|
||||||
|
@ -514,33 +488,13 @@ gm_mcp_icecrew_userlist_icon_path(GmMcpIcecrewUserlist *package,
|
||||||
void
|
void
|
||||||
gm_mcp_icecrew_userlist_update_rank_icon(GmPlayerdbPlayerInfo *ppi,
|
gm_mcp_icecrew_userlist_update_rank_icon(GmPlayerdbPlayerInfo *ppi,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(user_data);
|
g_signal_emit_by_name(user_data, "rank-changed", ppi->id);
|
||||||
gchar const *state;
|
|
||||||
gchar *icon_path;
|
|
||||||
|
|
||||||
state = gm_playerdb_player_info_get_prop(ppi, "P_STATE");
|
|
||||||
gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist.UpdateRankIcon: %s", state);
|
|
||||||
|
|
||||||
if (state && strcmp(state, "avail") == 0) {
|
|
||||||
gm_mcp_icecrew_userlist_find_path(package->priv->rank_icons,
|
|
||||||
gm_playerdb_player_info_get_prop(ppi, "P_RANK"), &icon_path);
|
|
||||||
|
|
||||||
g_signal_emit(package, gm_mcp_icecrew_userlist_signals[RANK_CHANGED],
|
|
||||||
0, ppi->id, icon_path, NULL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_mcp_icecrew_userlist_update_state_icon(GmPlayerdbPlayerInfo *ppi,
|
gm_mcp_icecrew_userlist_update_state_icon(GmPlayerdbPlayerInfo *ppi,
|
||||||
gpointer user_data) {
|
gpointer user_data) {
|
||||||
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(user_data);
|
g_signal_emit_by_name(user_data, "state-changed", ppi->id);
|
||||||
gchar *icon_path;
|
|
||||||
|
|
||||||
gm_mcp_icecrew_userlist_find_path(package->priv->state_icons,
|
|
||||||
gm_playerdb_player_info_get_prop(ppi, "P_STATE"), &icon_path);
|
|
||||||
|
|
||||||
g_signal_emit(package, gm_mcp_icecrew_userlist_signals[STATE_CHANGED],
|
|
||||||
0, ppi->id, icon_path, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -570,12 +524,14 @@ gm_mcp_icecrew_userlist_new_rank_state_icon(GmMcpIcecrewUserlist *package,
|
||||||
for (tmp = names; tmp; tmp = tmp->next) {
|
for (tmp = names; tmp; tmp = tmp->next) {
|
||||||
if (rank) {
|
if (rank) {
|
||||||
gm_mcp_icecrew_playerdb_find_players_with(
|
gm_mcp_icecrew_playerdb_find_players_with(
|
||||||
GM_MCP_ICECREW_PLAYERDB(playerdb), "P_RANK",
|
GM_MCP_ICECREW_PLAYERDB(playerdb),
|
||||||
|
package->priv->property_names[P_RANK],
|
||||||
(gchar *)(tmp->data),
|
(gchar *)(tmp->data),
|
||||||
gm_mcp_icecrew_userlist_update_rank_icon, package);
|
gm_mcp_icecrew_userlist_update_rank_icon, package);
|
||||||
} else {
|
} else {
|
||||||
gm_mcp_icecrew_playerdb_find_players_with(
|
gm_mcp_icecrew_playerdb_find_players_with(
|
||||||
GM_MCP_ICECREW_PLAYERDB(playerdb), "P_STATE",
|
GM_MCP_ICECREW_PLAYERDB(playerdb),
|
||||||
|
package->priv->property_names[P_STATE],
|
||||||
(gchar *)(tmp->data),
|
(gchar *)(tmp->data),
|
||||||
gm_mcp_icecrew_userlist_update_state_icon, package);
|
gm_mcp_icecrew_userlist_update_state_icon, package);
|
||||||
}
|
}
|
||||||
|
@ -635,7 +591,8 @@ gm_mcp_icecrew_userlist_fetch_next_alternatives(GmMcpIcecrewUserlist *package,
|
||||||
"checking: %s", map->value);
|
"checking: %s", map->value);
|
||||||
|
|
||||||
/* Skip alternatives with names we've already stored to be fetched */
|
/* Skip alternatives with names we've already stored to be fetched */
|
||||||
if (prev_name == NULL || strcmp(map->key, prev_name) != 0) {
|
if (prev_name == NULL || (map->key != NULL &&
|
||||||
|
strcmp(map->key, prev_name) != 0)) {
|
||||||
finfo = gnome_vfs_file_info_new();
|
finfo = gnome_vfs_file_info_new();
|
||||||
result = gnome_vfs_get_file_info(map->value, finfo,
|
result = gnome_vfs_get_file_info(map->value, finfo,
|
||||||
GNOME_VFS_FILE_INFO_DEFAULT);
|
GNOME_VFS_FILE_INFO_DEFAULT);
|
||||||
|
@ -670,7 +627,8 @@ gm_mcp_icecrew_userlist_fetch_next_alternatives(GmMcpIcecrewUserlist *package,
|
||||||
package->priv->state_icons; iter; iter = iter->next) {
|
package->priv->state_icons; iter; iter = iter->next) {
|
||||||
itermap = (GmKeyValuePair *)(iter->data);
|
itermap = (GmKeyValuePair *)(iter->data);
|
||||||
|
|
||||||
if (strcmp(itermap->key, map->key) == 0) {
|
if (itermap->key != NULL &&
|
||||||
|
strcmp(itermap->key, map->key) == 0) {
|
||||||
g_free(itermap->value);
|
g_free(itermap->value);
|
||||||
itermap->value = g_strdup(path);
|
itermap->value = g_strdup(path);
|
||||||
break;
|
break;
|
||||||
|
@ -837,7 +795,7 @@ gm_mcp_icecrew_userlist_menu_item_subst(GmMcpIcecrewUserlist *package,
|
||||||
|
|
||||||
prop = g_strndup(tmp, subst - tmp);
|
prop = g_strndup(tmp, subst - tmp);
|
||||||
|
|
||||||
if (strcmp(prop, "ID") == 0) {
|
if (strcmp(prop, "ID") == 0 || strcmp(prop, "id") == 0) {
|
||||||
tmp = g_strdup_printf("#%d", info->id);
|
tmp = g_strdup_printf("#%d", info->id);
|
||||||
result = g_string_append(result, tmp);
|
result = g_string_append(result, tmp);
|
||||||
g_free(tmp);
|
g_free(tmp);
|
||||||
|
@ -900,6 +858,7 @@ gm_mcp_icecrew_userlist_get_menu_item(GmMcpIcecrewUserlist *package,
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Interface */
|
||||||
GList *
|
GList *
|
||||||
gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
||||||
GmMcpIcecrewUserlist *object = GM_MCP_ICECREW_USERLIST(userlist);
|
GmMcpIcecrewUserlist *object = GM_MCP_ICECREW_USERLIST(userlist);
|
||||||
|
@ -917,11 +876,6 @@ gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
|
||||||
gm_mcp_icecrew_userlist_supports_status(GmIUserlist *userlist) {
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar const *
|
gchar const *
|
||||||
gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id) {
|
gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id) {
|
||||||
GmMcpIcecrewPlayerdb *playerdb = GM_MCP_ICECREW_PLAYERDB(
|
GmMcpIcecrewPlayerdb *playerdb = GM_MCP_ICECREW_PLAYERDB(
|
||||||
|
@ -929,7 +883,51 @@ gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id) {
|
||||||
"dns-nl-icecrew-playerdb"));
|
"dns-nl-icecrew-playerdb"));
|
||||||
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
||||||
|
|
||||||
return gm_playerdb_player_info_get_prop(info, "P_NAME");
|
return gm_playerdb_player_info_get_prop(info,
|
||||||
|
GM_MCP_ICECREW_USERLIST(userlist)->priv->property_names[P_NAME]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
gchar const *
|
||||||
|
gm_mcp_icecrew_userlist_get_icon(GmIUserlist *userlist, gint id,
|
||||||
|
gboolean use_state) {
|
||||||
|
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(userlist);
|
||||||
|
GmMcpIcecrewPlayerdb *playerdb = GM_MCP_ICECREW_PLAYERDB(
|
||||||
|
gm_mcp_session_find_package(GM_MCP_PACKAGE_SESSION(package),
|
||||||
|
"dns-nl-icecrew-playerdb"));
|
||||||
|
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
||||||
|
|
||||||
|
return gm_mcp_icecrew_userlist_icon_path(package, info, use_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_mcp_icecrew_userlist_get_rank_priority(GmIUserlist *userlist, gint id) {
|
||||||
|
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(userlist);
|
||||||
|
GmMcpIcecrewPlayerdb *playerdb = GM_MCP_ICECREW_PLAYERDB(
|
||||||
|
gm_mcp_session_find_package(GM_MCP_PACKAGE_SESSION(userlist),
|
||||||
|
"dns-nl-icecrew-playerdb"));
|
||||||
|
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
||||||
|
gchar const *rank = gm_playerdb_player_info_get_prop(info,
|
||||||
|
package->priv->property_names[P_RANK]);
|
||||||
|
|
||||||
|
return g_list_length(package->priv->rank_icons) -
|
||||||
|
gm_mcp_icecrew_userlist_find_path(package->priv->rank_icons,
|
||||||
|
rank, NULL) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_mcp_icecrew_userlist_get_state_priority(GmIUserlist *userlist, gint id) {
|
||||||
|
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(userlist);
|
||||||
|
GmMcpIcecrewPlayerdb *playerdb = GM_MCP_ICECREW_PLAYERDB(
|
||||||
|
gm_mcp_session_find_package(GM_MCP_PACKAGE_SESSION(userlist),
|
||||||
|
"dns-nl-icecrew-playerdb"));
|
||||||
|
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
||||||
|
gchar const *state = gm_playerdb_player_info_get_prop(info,
|
||||||
|
package->priv->property_names[P_STATE]);
|
||||||
|
|
||||||
|
return g_list_length(package->priv->state_icons) -
|
||||||
|
gm_mcp_icecrew_userlist_find_path(package->priv->state_icons,
|
||||||
|
state, NULL) + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar *
|
gchar *
|
||||||
|
@ -938,23 +936,29 @@ gm_mcp_icecrew_userlist_get_status(GmIUserlist *userlist, gint id) {
|
||||||
gm_mcp_session_find_package(GM_MCP_PACKAGE_SESSION(userlist),
|
gm_mcp_session_find_package(GM_MCP_PACKAGE_SESSION(userlist),
|
||||||
"dns-nl-icecrew-playerdb"));
|
"dns-nl-icecrew-playerdb"));
|
||||||
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
GmPlayerdbPlayerInfo *info = gm_mcp_icecrew_playerdb_find(playerdb, id);
|
||||||
gchar const *state = gm_playerdb_player_info_get_prop(info, "P_STATE");
|
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(userlist);
|
||||||
gchar const *msg = gm_playerdb_player_info_get_prop(info, "P_STATE_MSG");
|
|
||||||
|
gchar const *state = gm_playerdb_player_info_get_prop(info,
|
||||||
|
package->priv->property_names[P_STATE]);
|
||||||
|
gchar const *msg = gm_playerdb_player_info_get_prop(info,
|
||||||
|
package->priv->property_names[P_STATE_MSG]);
|
||||||
gchar const *caption;
|
gchar const *caption;
|
||||||
|
|
||||||
if (state == NULL || strcmp(state, "avail") == 0) {
|
if (state == NULL || strcmp(state, "avail") == 0) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strstr(state, "away") != 0) {
|
if (strstr(state, "away") != NULL) {
|
||||||
caption = _("Away");
|
caption = _("Away");
|
||||||
} else if (strstr(state, "busy") != 0) {
|
} else if (strstr(state, "busy") != NULL) {
|
||||||
caption = _("Busy");
|
caption = _("Busy");
|
||||||
|
} else if (strstr(state, "idle") != NULL) {
|
||||||
|
caption = _("Idle");
|
||||||
} else {
|
} else {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg == NULL) {
|
if (msg == NULL || *msg == '\0') {
|
||||||
return strdup(caption);
|
return strdup(caption);
|
||||||
} else {
|
} else {
|
||||||
return g_strconcat(caption, ": ", msg, NULL);
|
return g_strconcat(caption, ": ", msg, NULL);
|
||||||
|
@ -1011,9 +1015,9 @@ gm_mcp_icecrew_userlist_handle_ranks_states(GmMcpIcecrewUserlist *package,
|
||||||
}
|
}
|
||||||
|
|
||||||
name = (gchar *)(data->data);
|
name = (gchar *)(data->data);
|
||||||
gm_mcp_icecrew_userlist_find_path(new_list, name, &path);
|
gm_mcp_icecrew_userlist_find_path(new_list, name, &cpath);
|
||||||
|
|
||||||
if (path) {
|
if (cpath) {
|
||||||
gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist.HandleRanksStates: "
|
gm_debug_msg(DEBUG_MCP, "GmMcpIcecrewUserlist.HandleRanksStates: "
|
||||||
"duplicate %s, ignored!", name);
|
"duplicate %s, ignored!", name);
|
||||||
continue;
|
continue;
|
||||||
|
@ -1138,13 +1142,24 @@ gm_mcp_icecrew_userlist_set_session(GmMcpPackage *package, GObject *session) {
|
||||||
GmMcpPackage *playerdb;
|
GmMcpPackage *playerdb;
|
||||||
GmMcpIcecrewUserlist *userlist = GM_MCP_ICECREW_USERLIST(package);
|
GmMcpIcecrewUserlist *userlist = GM_MCP_ICECREW_USERLIST(package);
|
||||||
GmMcpSession *ses;
|
GmMcpSession *ses;
|
||||||
|
gdouble version;
|
||||||
|
|
||||||
parent_class->set_session(package, session);
|
parent_class->set_session(package, session);
|
||||||
ses = GM_MCP_SESSION(session);
|
ses = GM_MCP_SESSION(session);
|
||||||
|
|
||||||
playerdb = gm_mcp_session_find_package(ses, "dns-nl-icecrew-playerdb");
|
playerdb = gm_mcp_session_find_package(ses, "dns-nl-icecrew-playerdb");
|
||||||
|
|
||||||
g_return_if_fail(playerdb != NULL);
|
g_return_if_fail(playerdb != NULL);
|
||||||
|
|
||||||
|
version = gm_mcp_package_get_version(GM_MCP_PACKAGE(playerdb));
|
||||||
|
|
||||||
|
if (version == 1.1) {
|
||||||
|
userlist->priv->property_names =
|
||||||
|
gm_mcp_icecrew_userlist_property_names1;
|
||||||
|
} else {
|
||||||
|
userlist->priv->property_names =
|
||||||
|
gm_mcp_icecrew_userlist_property_names0;
|
||||||
|
}
|
||||||
|
|
||||||
icons_dir = g_strconcat(gm_world_path(GM_MCP_SESSION_WORLD(ses)),
|
icons_dir = g_strconcat(gm_world_path(GM_MCP_SESSION_WORLD(ses)),
|
||||||
G_DIR_SEPARATOR_S, "icons", NULL);
|
G_DIR_SEPARATOR_S, "icons", NULL);
|
||||||
|
@ -1159,7 +1174,7 @@ gm_mcp_icecrew_userlist_set_session(GmMcpPackage *package, GObject *session) {
|
||||||
mkdir(userlist->priv->rank_dir, 0755);
|
mkdir(userlist->priv->rank_dir, 0755);
|
||||||
if (!g_file_test(userlist->priv->state_dir, G_FILE_TEST_EXISTS))
|
if (!g_file_test(userlist->priv->state_dir, G_FILE_TEST_EXISTS))
|
||||||
mkdir(userlist->priv->state_dir, 0755);
|
mkdir(userlist->priv->state_dir, 0755);
|
||||||
|
|
||||||
g_free(icons_dir);
|
g_free(icons_dir);
|
||||||
|
|
||||||
g_signal_connect(playerdb, "add",
|
g_signal_connect(playerdb, "add",
|
||||||
|
@ -1180,7 +1195,8 @@ gm_mcp_icecrew_userlist_process_state_changed(GmMcpIcecrewUserlist *userlist,
|
||||||
GmPlayerdbPlayerInfo *ppi, gchar const *value, gchar const *old) {
|
GmPlayerdbPlayerInfo *ppi, gchar const *value, gchar const *old) {
|
||||||
gboolean was_away, was_idle;
|
gboolean was_away, was_idle;
|
||||||
gboolean is_away, is_idle;
|
gboolean is_away, is_idle;
|
||||||
gchar const *name = gm_playerdb_player_info_get_prop(ppi, "P_NAME");
|
gchar const *name = gm_playerdb_player_info_get_prop(ppi,
|
||||||
|
userlist->priv->property_names[P_NAME]);
|
||||||
|
|
||||||
was_away = (strstr(old, "away") != NULL || strstr(old, "busy") != NULL);
|
was_away = (strstr(old, "away") != NULL || strstr(old, "busy") != NULL);
|
||||||
was_idle = (strstr(old, "idle") != NULL);
|
was_idle = (strstr(old, "idle") != NULL);
|
||||||
|
@ -1209,57 +1225,37 @@ gm_mcp_icecrew_userlist_process_state_changed(GmMcpIcecrewUserlist *userlist,
|
||||||
void
|
void
|
||||||
on_gm_mcp_icecrew_userlist_add(GmMcpIcecrewPlayerdb *playerdb,
|
on_gm_mcp_icecrew_userlist_add(GmMcpIcecrewPlayerdb *playerdb,
|
||||||
GmPlayerdbPlayerInfo *ppi, GmMcpIcecrewUserlist *userlist) {
|
GmPlayerdbPlayerInfo *ppi, GmMcpIcecrewUserlist *userlist) {
|
||||||
gchar *sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
gchar const *name = gm_playerdb_player_info_get_prop(ppi,
|
||||||
gchar const *name = gm_playerdb_player_info_get_prop(ppi, "P_NAME");
|
userlist->priv->property_names[P_NAME]);
|
||||||
gchar const *icon_path = gm_mcp_icecrew_userlist_icon_path(userlist, ppi);
|
|
||||||
|
|
||||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[PLAYER_ADDED],
|
g_signal_emit_by_name(userlist, "player-added", ppi->id);
|
||||||
0, ppi->id, icon_path, sort);
|
|
||||||
gm_mcp_icecrew_userlist_process_triggers(userlist, name, TCT_USER_ONLINE);
|
gm_mcp_icecrew_userlist_process_triggers(userlist, name, TCT_USER_ONLINE);
|
||||||
|
|
||||||
g_free(sort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_gm_mcp_icecrew_userlist_set(GmMcpIcecrewPlayerdb *playerdb,
|
on_gm_mcp_icecrew_userlist_set(GmMcpIcecrewPlayerdb *playerdb,
|
||||||
GmPlayerdbPlayerInfo *ppi, gchar const *key, gchar const *value,
|
GmPlayerdbPlayerInfo *ppi, gchar const *key, gchar const *value,
|
||||||
gchar const *old, GmMcpIcecrewUserlist *userlist) {
|
gchar const *old, GmMcpIcecrewUserlist *userlist) {
|
||||||
gchar *sort = NULL;
|
if (strcmp(key, userlist->priv->property_names[P_STATE]) == 0) {
|
||||||
|
g_signal_emit_by_name(userlist, "state-changed", ppi->id);
|
||||||
if (strcmp(key, "P_STATE") == 0) {
|
|
||||||
sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
|
||||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[STATE_CHANGED],
|
|
||||||
0, ppi->id, gm_mcp_icecrew_userlist_icon_path(userlist, ppi),
|
|
||||||
sort);
|
|
||||||
|
|
||||||
gm_mcp_icecrew_userlist_process_state_changed(userlist, ppi, value,
|
gm_mcp_icecrew_userlist_process_state_changed(userlist, ppi, value,
|
||||||
old);
|
old);
|
||||||
} else if (strcmp(key, "P_RANK") == 0) {
|
} else if (strcmp(key, userlist->priv->property_names[P_RANK]) == 0) {
|
||||||
sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
g_signal_emit_by_name(userlist, "rank-changed", ppi->id);
|
||||||
|
} else if (strcmp(key, userlist->priv->property_names[P_NAME]) == 0) {
|
||||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[RANK_CHANGED],
|
g_signal_emit_by_name(userlist, "name-changed", ppi->id);
|
||||||
0, ppi->id, gm_mcp_icecrew_userlist_icon_path(userlist, ppi),
|
} else if (strcmp(key, userlist->priv->property_names[P_STATE_MSG]) == 0) {
|
||||||
sort);
|
g_signal_emit_by_name(userlist, "state-changed", ppi->id);
|
||||||
} else if (strcmp(key, "P_NAME") == 0) {
|
|
||||||
sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
|
||||||
|
|
||||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[NAME_CHANGED],
|
|
||||||
0, ppi->id, sort);
|
|
||||||
} else if (strcmp(key, "P_STATE_MSG") == 0) {
|
|
||||||
sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
|
||||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[NAME_CHANGED],
|
|
||||||
0, ppi->id, sort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(sort);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
on_gm_mcp_icecrew_userlist_delete(GmMcpIcecrewPlayerdb *playerdb,
|
on_gm_mcp_icecrew_userlist_delete(GmMcpIcecrewPlayerdb *playerdb,
|
||||||
GmPlayerdbPlayerInfo *ppi, GmMcpIcecrewUserlist *userlist) {
|
GmPlayerdbPlayerInfo *ppi, GmMcpIcecrewUserlist *userlist) {
|
||||||
gchar const *name = gm_playerdb_player_info_get_prop(ppi, "P_NAME");
|
gchar const *name = gm_playerdb_player_info_get_prop(ppi,
|
||||||
|
userlist->priv->property_names[P_NAME]);
|
||||||
|
|
||||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[PLAYER_REMOVED],
|
g_signal_emit_by_name(userlist, "player-removed", ppi->id);
|
||||||
0, ppi->id);
|
|
||||||
gm_mcp_icecrew_userlist_process_triggers(userlist, name, TCT_USER_OFFLINE);
|
gm_mcp_icecrew_userlist_process_triggers(userlist, name, TCT_USER_OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,17 +51,6 @@ typedef struct _GmMcpIcecrewUserlistClass GmMcpIcecrewUserlistClass;
|
||||||
|
|
||||||
struct _GmMcpIcecrewUserlistClass {
|
struct _GmMcpIcecrewUserlistClass {
|
||||||
GmMcpPackageClass parent_class;
|
GmMcpPackageClass parent_class;
|
||||||
|
|
||||||
/* Signals */
|
|
||||||
void (* player_added) (GmMcpIcecrewUserlist *obj, gint id,
|
|
||||||
gchar const *icon, gchar const *sort);
|
|
||||||
void (* player_removed) (GmMcpIcecrewUserlist *obj, gint id);
|
|
||||||
void (* name_changed) (GmMcpIcecrewUserlist *obj, gint id,
|
|
||||||
gchar const *sort);
|
|
||||||
void (* state_changed) (GmMcpIcecrewUserlist *obj, gint id,
|
|
||||||
gchar const *icon, gchar const *sort);
|
|
||||||
void (* rank_changed) (GmMcpIcecrewUserlist *obj, gint id,
|
|
||||||
gchar const *icon, gchar const *sort);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gm_mcp_icecrew_userlist_get_type(void) G_GNUC_CONST;
|
GType gm_mcp_icecrew_userlist_get_type(void) G_GNUC_CONST;
|
||||||
|
|
|
@ -1,19 +1,22 @@
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "gm-mcp-package.h"
|
#include "gm-mcp-package.h"
|
||||||
#include "gm-mcp-userlist-view.h"
|
#include "gm-mcp-userlist-view.h"
|
||||||
#include "gm-iuserlist.h"
|
#include "gm-iuserlist.h"
|
||||||
#include "widgets/gm-world-view.h"
|
#include "widgets/gm-world-view.h"
|
||||||
#include "gm-pixbuf.h"
|
#include "gm-pixbuf.h"
|
||||||
|
#include "gm-app.h"
|
||||||
#include "gm-debug.h"
|
#include "gm-debug.h"
|
||||||
|
|
||||||
#define GM_USERLIST_ICON_SIZE 22
|
#define GM_USERLIST_ICON_SIZE 22
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
GM_USERLIST_ICON,
|
GM_USERLIST_ICON,
|
||||||
GM_USERLIST_NAME,
|
GM_USERLIST_CAPTION,
|
||||||
GM_USERLIST_ID,
|
GM_USERLIST_ID,
|
||||||
GM_USERLIST_SORT,
|
GM_USERLIST_RANK_PRIORITY,
|
||||||
|
GM_USERLIST_STATE_PRIORITY,
|
||||||
GM_USERLIST_N_COLUMNS
|
GM_USERLIST_N_COLUMNS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -23,33 +26,68 @@ typedef struct _GmMcpUserlistView {
|
||||||
GtkTreeModel *model;
|
GtkTreeModel *model;
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GtkTreeView *tree_view;
|
GtkTreeView *tree_view;
|
||||||
|
GtkWidget *label;
|
||||||
GtkScrolledWindow *scrolled_window;
|
GtkScrolledWindow *scrolled_window;
|
||||||
GtkWidget *popup_menu;
|
GtkWidget *popup_menu;
|
||||||
gboolean initializing;
|
gboolean initializing;
|
||||||
|
GmUserlistSortType sort_type;
|
||||||
|
gboolean show_object;
|
||||||
|
gboolean show_status;
|
||||||
|
gboolean use_state_icon;
|
||||||
|
|
||||||
|
gint num_players;
|
||||||
|
gint num_active;
|
||||||
} GmMcpUserlistView;
|
} GmMcpUserlistView;
|
||||||
|
|
||||||
static void on_gm_mcp_userlist_view_weak_notify(gpointer data, GObject *obj);
|
static void on_gm_mcp_userlist_view_weak_notify(gpointer data, GObject *obj);
|
||||||
|
|
||||||
static void on_gm_mcp_userlist_view_player_added(GmMcpPackage *package, gint id,
|
static void on_gm_mcp_userlist_view_player_added(GmMcpPackage *package, gint id,
|
||||||
gchar const *icon, gchar const *sort,
|
|
||||||
GmMcpUserlistView *view);
|
GmMcpUserlistView *view);
|
||||||
static void on_gm_mcp_userlist_view_player_removed(GmMcpPackage *package, gint id,
|
static void on_gm_mcp_userlist_view_player_removed(GmMcpPackage *package, gint id,
|
||||||
GmMcpUserlistView *view);
|
GmMcpUserlistView *view);
|
||||||
static void on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
static void on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
||||||
gchar const *sort, GmMcpUserlistView *view);
|
GmMcpUserlistView *view);
|
||||||
static void on_gm_mcp_userlist_view_rank_changed(GmMcpPackage *package, gint id,
|
static void on_gm_mcp_userlist_view_rank_changed(GmMcpPackage *package, gint id,
|
||||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view);
|
GmMcpUserlistView *view);
|
||||||
static void on_gm_mcp_userlist_view_state_changed(GmMcpPackage *package, gint id,
|
static void on_gm_mcp_userlist_view_state_changed(GmMcpPackage *package, gint id,
|
||||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view);
|
GmMcpUserlistView *view);
|
||||||
|
|
||||||
static gboolean on_gm_mcp_userlist_view_popup_menu(GtkWidget *widget,
|
static gboolean on_gm_mcp_userlist_view_popup_menu(GtkWidget *widget,
|
||||||
GmMcpUserlistView *view);
|
GmMcpUserlistView *view);
|
||||||
static gboolean on_gm_mcp_userlist_view_button_press(GtkWidget *widget,
|
static gboolean on_gm_mcp_userlist_view_button_press(GtkWidget *widget,
|
||||||
GdkEventButton *event, GmMcpUserlistView *view);
|
GdkEventButton *event, GmMcpUserlistView *view);
|
||||||
|
|
||||||
|
static void on_gm_mcp_userlist_view_option_changed(GmOptions *options,
|
||||||
|
gchar const *key, GmMcpUserlistView *view);
|
||||||
|
|
||||||
|
typedef struct _SortInfo {
|
||||||
|
gchar *name;
|
||||||
|
gint rank_priority;
|
||||||
|
gint state_priority;
|
||||||
|
} SortInfo;
|
||||||
|
|
||||||
|
static gint gm_mcp_userlist_view_sort_state_rank_name(SortInfo *info1,
|
||||||
|
SortInfo *info2);
|
||||||
|
static gint gm_mcp_userlist_view_sort_rank_name(SortInfo *info1,
|
||||||
|
SortInfo *info2);
|
||||||
|
static gint gm_mcp_userlist_view_sort_state_name(SortInfo *info1,
|
||||||
|
SortInfo *info2);
|
||||||
|
static gint gm_mcp_userlist_view_sort_name(SortInfo *info1,
|
||||||
|
SortInfo *info2);
|
||||||
|
|
||||||
|
typedef gint (*GmUserlistCompareFunc) (SortInfo *info1, SortInfo *info2);
|
||||||
|
|
||||||
|
static GmUserlistCompareFunc compare_functions[] = {
|
||||||
|
gm_mcp_userlist_view_sort_state_rank_name,
|
||||||
|
gm_mcp_userlist_view_sort_rank_name,
|
||||||
|
gm_mcp_userlist_view_sort_state_name,
|
||||||
|
gm_mcp_userlist_view_sort_name
|
||||||
|
};
|
||||||
|
|
||||||
GtkTreeModel *
|
GtkTreeModel *
|
||||||
gm_mcp_userlist_view_model_create(GmMcpUserlistView *view) {
|
gm_mcp_userlist_view_model_create(GmMcpUserlistView *view) {
|
||||||
GtkListStore *store = gtk_list_store_new(GM_USERLIST_N_COLUMNS,
|
GtkListStore *store = gtk_list_store_new(GM_USERLIST_N_COLUMNS,
|
||||||
GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_STRING);
|
GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT);
|
||||||
GtkTreeModel *model = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(
|
GtkTreeModel *model = gtk_tree_model_sort_new_with_model(GTK_TREE_MODEL(
|
||||||
store));
|
store));
|
||||||
|
|
||||||
|
@ -62,7 +100,125 @@ gm_mcp_userlist_view_model_create(GmMcpUserlistView *view) {
|
||||||
void
|
void
|
||||||
on_gm_mcp_userlist_view_style_set(GtkWidget *widget, GtkStyle *prev,
|
on_gm_mcp_userlist_view_style_set(GtkWidget *widget, GtkStyle *prev,
|
||||||
GmMcpUserlistView *view) {
|
GmMcpUserlistView *view) {
|
||||||
pango_font_description_set_size(widget->style->font_desc, 8 * PANGO_SCALE);
|
pango_font_description_set_size(widget->style->font_desc, 10 * PANGO_SCALE);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_userlist_view_strcmp_safe(gchar const *str1, gchar const *str2) {
|
||||||
|
gchar *u1, *u2;
|
||||||
|
gint result;
|
||||||
|
|
||||||
|
if (str1 == NULL || str2 == NULL) {
|
||||||
|
if (str1 == NULL && str2 == NULL) {
|
||||||
|
result = 0;
|
||||||
|
} else if (str1 == NULL) {
|
||||||
|
result = -1;
|
||||||
|
} else {
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
u1 = g_utf8_casefold(str1, -1);
|
||||||
|
u2 = g_utf8_casefold(str2, -1);
|
||||||
|
|
||||||
|
result = g_utf8_collate(u1, u2);
|
||||||
|
|
||||||
|
g_free(u1);
|
||||||
|
g_free(u2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gm_mcp_userlist_view_sort_state_rank_name(SortInfo *info1, SortInfo *info2) {
|
||||||
|
// Sort by 'icon' (so first by state, then if state is avail sort by rank
|
||||||
|
// and then by name, otherwise sort by name)
|
||||||
|
if (info1->state_priority == info2->state_priority) {
|
||||||
|
// The same state, if state is 0 then go by rank and then name,
|
||||||
|
// otherwise go by name
|
||||||
|
if (info1->state_priority == 0) {
|
||||||
|
if (info1->rank_priority == info2->rank_priority) {
|
||||||
|
return gm_userlist_view_strcmp_safe(info1->name, info2->name);
|
||||||
|
} else {
|
||||||
|
return info1->rank_priority - info2->rank_priority;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return gm_userlist_view_strcmp_safe(info1->name, info2->name);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return info1->state_priority - info2->state_priority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gm_mcp_userlist_view_sort_rank_name(SortInfo *info1, SortInfo *info2) {
|
||||||
|
// First sort by rank, then sort by name
|
||||||
|
if (info1->rank_priority == info2->rank_priority) {
|
||||||
|
return gm_userlist_view_strcmp_safe(info1->name, info2->name);
|
||||||
|
} else {
|
||||||
|
return info1->rank_priority - info2->rank_priority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gm_mcp_userlist_view_sort_state_name(SortInfo *info1, SortInfo *info2) {
|
||||||
|
// First sort by state, then sort by name
|
||||||
|
if (info1->state_priority == info2->state_priority) {
|
||||||
|
return gm_userlist_view_strcmp_safe(info1->name, info2->name);
|
||||||
|
} else {
|
||||||
|
return info1->state_priority - info2->state_priority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
gm_mcp_userlist_view_sort_name(SortInfo *info1, SortInfo *info2) {
|
||||||
|
// Sort by name
|
||||||
|
return gm_userlist_view_strcmp_safe(info1->name, info2->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_mcp_userlist_view_sort_func(GtkTreeModel *model, GtkTreeIter *a,
|
||||||
|
GtkTreeIter *b, GmMcpUserlistView *view) {
|
||||||
|
/* a < b => -1
|
||||||
|
a == b => 0
|
||||||
|
a > b => 1 */
|
||||||
|
SortInfo info1, info2;
|
||||||
|
gint result;
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, a,
|
||||||
|
GM_USERLIST_RANK_PRIORITY, &(info1.rank_priority),
|
||||||
|
GM_USERLIST_STATE_PRIORITY, &(info1.state_priority),
|
||||||
|
GM_USERLIST_CAPTION, &(info1.name), -1);
|
||||||
|
gtk_tree_model_get(model, b,
|
||||||
|
GM_USERLIST_RANK_PRIORITY, &(info2.rank_priority),
|
||||||
|
GM_USERLIST_STATE_PRIORITY, &(info2.state_priority),
|
||||||
|
GM_USERLIST_CAPTION, &(info2.name), -1);
|
||||||
|
|
||||||
|
result = (* compare_functions[view->sort_type]) (&info1, &info2);
|
||||||
|
|
||||||
|
g_free(info1.name);
|
||||||
|
g_free(info2.name);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_mcp_userlist_view_update_label(GmMcpUserlistView *view) {
|
||||||
|
gchar *label;
|
||||||
|
|
||||||
|
label = g_strdup_printf(_("Players: %d, active: %d"), view->num_players,
|
||||||
|
view->num_active);
|
||||||
|
|
||||||
|
gtk_label_set_label(GTK_LABEL(view->label), label);
|
||||||
|
g_free(label);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gm_mcp_userlist_view_create_label(GmMcpUserlistView *view) {
|
||||||
|
view->label = gtk_label_new(NULL);
|
||||||
|
gm_mcp_userlist_view_update_label(view);
|
||||||
|
|
||||||
|
return view->label;
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *
|
GtkWidget *
|
||||||
|
@ -96,11 +252,13 @@ gm_mcp_userlist_view_create_userlist(GmMcpUserlistView *view) {
|
||||||
|
|
||||||
renderer = gtk_cell_renderer_text_new();
|
renderer = gtk_cell_renderer_text_new();
|
||||||
column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer,
|
column = gtk_tree_view_column_new_with_attributes(_("Name"), renderer,
|
||||||
"markup", GM_USERLIST_NAME, NULL);
|
"markup", GM_USERLIST_CAPTION, NULL);
|
||||||
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
|
gtk_tree_view_append_column(GTK_TREE_VIEW(tree_view), column);
|
||||||
|
|
||||||
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
|
gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(model),
|
||||||
GM_USERLIST_SORT, GTK_SORT_ASCENDING);
|
GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID, GTK_SORT_ASCENDING);
|
||||||
|
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(model),
|
||||||
|
(GtkTreeIterCompareFunc)gm_mcp_userlist_view_sort_func, view, NULL);
|
||||||
|
|
||||||
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(tree_view), GTK_CAN_FOCUS);
|
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(tree_view), GTK_CAN_FOCUS);
|
||||||
|
|
||||||
|
@ -123,6 +281,7 @@ gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent) {
|
||||||
GmMcpUserlistView *view;
|
GmMcpUserlistView *view;
|
||||||
GtkPaned *paned;
|
GtkPaned *paned;
|
||||||
GtkWidget *vbox, *child;
|
GtkWidget *vbox, *child;
|
||||||
|
GmOptions *options;
|
||||||
|
|
||||||
if (!GM_IS_WORLD_VIEW(parent)) {
|
if (!GM_IS_WORLD_VIEW(parent)) {
|
||||||
return;
|
return;
|
||||||
|
@ -131,18 +290,22 @@ gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent) {
|
||||||
view = g_new0(GmMcpUserlistView, 1);
|
view = g_new0(GmMcpUserlistView, 1);
|
||||||
view->view = GM_WORLD_VIEW(parent);
|
view->view = GM_WORLD_VIEW(parent);
|
||||||
view->package = package;
|
view->package = package;
|
||||||
|
|
||||||
paned = GTK_PANED(gm_world_view_hpaned(view->view));
|
paned = GTK_PANED(gm_world_view_hpaned(view->view));
|
||||||
vbox = gtk_paned_get_child2(paned);
|
vbox = gtk_paned_get_child2(paned);
|
||||||
|
|
||||||
if (vbox == NULL) {
|
if (vbox == NULL) {
|
||||||
vbox = gtk_vbox_new(FALSE, 6);
|
vbox = gtk_vbox_new(FALSE, 3);
|
||||||
gtk_paned_pack2(paned, vbox, FALSE, TRUE);
|
gtk_paned_pack2(paned, vbox, FALSE, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
child = gm_mcp_userlist_view_create_userlist(view);
|
child = gm_mcp_userlist_view_create_userlist(view);
|
||||||
|
|
||||||
gtk_box_pack_end(GTK_BOX(vbox), child, TRUE, TRUE, 0);
|
gtk_box_pack_end(GTK_BOX(vbox), child, TRUE, TRUE, 0);
|
||||||
|
|
||||||
|
gtk_box_pack_end(GTK_BOX(vbox), gm_mcp_userlist_view_create_label(view),
|
||||||
|
FALSE, FALSE, 0);
|
||||||
|
|
||||||
gtk_widget_show_all(vbox);
|
gtk_widget_show_all(vbox);
|
||||||
|
|
||||||
g_signal_connect(view->tree_view, "popup-menu",
|
g_signal_connect(view->tree_view, "popup-menu",
|
||||||
|
@ -161,10 +324,177 @@ gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent) {
|
||||||
g_signal_connect(package, "rank_changed",
|
g_signal_connect(package, "rank_changed",
|
||||||
G_CALLBACK(on_gm_mcp_userlist_view_rank_changed), view);
|
G_CALLBACK(on_gm_mcp_userlist_view_rank_changed), view);
|
||||||
|
|
||||||
|
// Userlist options
|
||||||
|
options = gm_app_options(gm_app_instance());
|
||||||
|
view->show_object = gm_options_get_int(options,
|
||||||
|
"userlist_show_object_number");
|
||||||
|
view->sort_type = gm_options_get_int(options, "userlist_sort_type");
|
||||||
|
view->show_status = gm_options_get_int(options, "userlist_show_status");
|
||||||
|
view->use_state_icon = gm_options_get_int(options,
|
||||||
|
"userlist_use_state_icon");
|
||||||
|
|
||||||
|
g_signal_connect(options, "option-changed",
|
||||||
|
G_CALLBACK(on_gm_mcp_userlist_view_option_changed), view);
|
||||||
|
|
||||||
g_object_weak_ref(G_OBJECT(package), on_gm_mcp_userlist_view_weak_notify,
|
g_object_weak_ref(G_OBJECT(package), on_gm_mcp_userlist_view_weak_notify,
|
||||||
view);
|
view);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
gm_mcp_userlist_view_get_name(GmMcpUserlistView *view, gint id) {
|
||||||
|
gchar const *name;
|
||||||
|
gchar *text;
|
||||||
|
gchar *escape_name;
|
||||||
|
gchar *status;
|
||||||
|
gchar *escape;
|
||||||
|
gchar *result;
|
||||||
|
gchar *color;
|
||||||
|
GdkColor col;
|
||||||
|
|
||||||
|
name = gm_iuserlist_get_name(GM_IUSERLIST(view->package), id);
|
||||||
|
|
||||||
|
if (view->show_object) {
|
||||||
|
text = g_strdup_printf("%s (#%d)", name, id);
|
||||||
|
} else {
|
||||||
|
text = g_strdup(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!view->show_status ||
|
||||||
|
!gm_iuserlist_supports_status(GM_IUSERLIST(view->package))) {
|
||||||
|
result = text;
|
||||||
|
} else {
|
||||||
|
status = gm_iuserlist_get_status(GM_IUSERLIST(view->package), id);
|
||||||
|
col = GTK_WIDGET(view->tree_view)->style->text_aa[GTK_STATE_NORMAL];
|
||||||
|
color = g_strdup_printf("#%04X%04X%04X", col.red, col.green,
|
||||||
|
col.blue);
|
||||||
|
|
||||||
|
if (status) {
|
||||||
|
escape = g_markup_escape_text(status, -1);
|
||||||
|
escape_name = g_markup_escape_text(text, -1);
|
||||||
|
|
||||||
|
result = g_strconcat("<small>", escape_name,
|
||||||
|
"\n<small><span color=\"", color, "\">",
|
||||||
|
escape, "</span></small></small>", NULL);
|
||||||
|
|
||||||
|
g_free(status);
|
||||||
|
g_free(escape);
|
||||||
|
g_free(escape_name);
|
||||||
|
} else {
|
||||||
|
escape = g_markup_escape_text(text, -1);
|
||||||
|
result = g_strconcat("<small>", escape, "\n<small><span color=\"",
|
||||||
|
color, "\">", _("Available"), "</span></small></small>",
|
||||||
|
NULL);
|
||||||
|
g_free(escape);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free(text);
|
||||||
|
g_free(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_mcp_userlist_view_update_sort_type(GmMcpUserlistView *view,
|
||||||
|
GmUserlistSortType sort_type) {
|
||||||
|
if (sort_type == view->sort_type) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sort_type < 0 || sort_type >= GM_USERLIST_SORT_TYPE_NUM) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->sort_type = sort_type;
|
||||||
|
|
||||||
|
gtk_tree_model_sort_reset_default_sort_func(GTK_TREE_MODEL_SORT(
|
||||||
|
view->model));
|
||||||
|
gtk_tree_sortable_set_default_sort_func(GTK_TREE_SORTABLE(view->model),
|
||||||
|
(GtkTreeIterCompareFunc)gm_mcp_userlist_view_sort_func, view, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_mcp_userlist_view_update_names(GmMcpUserlistView *view) {
|
||||||
|
GtkTreeModel *model = GTK_TREE_MODEL(view->store);
|
||||||
|
gint iterid;
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gchar *name;
|
||||||
|
|
||||||
|
if (gtk_tree_model_get_iter_first(model, &iter)) {
|
||||||
|
do {
|
||||||
|
gtk_tree_model_get(model, &iter, GM_USERLIST_ID, &iterid, -1);
|
||||||
|
name = gm_mcp_userlist_view_get_name(view, iterid);
|
||||||
|
|
||||||
|
gtk_list_store_set(view->store, &iter, GM_USERLIST_CAPTION, name,
|
||||||
|
-1);
|
||||||
|
g_free(name);
|
||||||
|
} while (gtk_tree_model_iter_next(model, &iter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_mcp_userlist_view_update_show_object_number(GmMcpUserlistView *view,
|
||||||
|
gboolean show_object) {
|
||||||
|
if (view->show_object == show_object) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->show_object = show_object;
|
||||||
|
|
||||||
|
gm_mcp_userlist_view_update_names(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_mcp_userlist_view_update_show_status(GmMcpUserlistView *view,
|
||||||
|
gboolean show_status) {
|
||||||
|
if (view->show_status == show_status) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->show_status = show_status;
|
||||||
|
gm_mcp_userlist_view_update_names(view);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gm_mcp_userlist_view_update_use_state_icon(GmMcpUserlistView *view,
|
||||||
|
gboolean use_state_icon) {
|
||||||
|
gchar const *icon;
|
||||||
|
GtkTreeModel *model = GTK_TREE_MODEL(view->store);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gint iterid;
|
||||||
|
|
||||||
|
if (view->use_state_icon == use_state_icon) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
view->use_state_icon = use_state_icon;
|
||||||
|
|
||||||
|
// Update icons for all players
|
||||||
|
if (gtk_tree_model_get_iter_first(model, &iter)) {
|
||||||
|
do {
|
||||||
|
gtk_tree_model_get(model, &iter, GM_USERLIST_ID, &iterid, -1);
|
||||||
|
icon = gm_iuserlist_get_icon(GM_IUSERLIST(view->package), iterid,
|
||||||
|
use_state_icon);
|
||||||
|
|
||||||
|
gtk_list_store_set(view->store, &iter, GM_USERLIST_ICON,
|
||||||
|
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
||||||
|
GM_USERLIST_ICON_SIZE), -1);
|
||||||
|
} while (gtk_tree_model_iter_next(model, &iter));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
gm_mcp_userlist_view_player_active(GmMcpUserlistView *view, GtkTreeIter *iter) {
|
||||||
|
gint state;
|
||||||
|
|
||||||
|
gtk_tree_model_get(GTK_TREE_MODEL(view->store), iter,
|
||||||
|
GM_USERLIST_STATE_PRIORITY, &state, -1);
|
||||||
|
|
||||||
|
GM_DEBUG("Active? %d", state);
|
||||||
|
|
||||||
|
return (state == 0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Callbacks */
|
/* Callbacks */
|
||||||
static void
|
static void
|
||||||
on_gm_mcp_userlist_view_weak_notify(gpointer data, GObject *obj) {
|
on_gm_mcp_userlist_view_weak_notify(gpointer data, GObject *obj) {
|
||||||
|
@ -174,6 +504,8 @@ on_gm_mcp_userlist_view_weak_notify(gpointer data, GObject *obj) {
|
||||||
|
|
||||||
if (GM_IS_WORLD_VIEW(view->view)) {
|
if (GM_IS_WORLD_VIEW(view->view)) {
|
||||||
gtk_widget_destroy(GTK_WIDGET(view->scrolled_window));
|
gtk_widget_destroy(GTK_WIDGET(view->scrolled_window));
|
||||||
|
gtk_widget_destroy(view->label);
|
||||||
|
|
||||||
vbox = gtk_paned_get_child2(GTK_PANED(gm_world_view_hpaned(
|
vbox = gtk_paned_get_child2(GTK_PANED(gm_world_view_hpaned(
|
||||||
view->view)));
|
view->view)));
|
||||||
|
|
||||||
|
@ -188,9 +520,30 @@ on_gm_mcp_userlist_view_weak_notify(gpointer data, GObject *obj) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_signal_handlers_disconnect_by_func(gm_app_options(gm_app_instance()),
|
||||||
|
G_CALLBACK(on_gm_mcp_userlist_view_option_changed), view);
|
||||||
|
|
||||||
g_free(data);
|
g_free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
on_gm_mcp_userlist_view_option_changed(GmOptions *options, gchar const *key,
|
||||||
|
GmMcpUserlistView *view) {
|
||||||
|
if (strcmp(key, "userlist_sort_type") == 0) {
|
||||||
|
gm_mcp_userlist_view_update_sort_type(view,
|
||||||
|
gm_options_get_int(options, "userlist_sort_type"));
|
||||||
|
} else if (strcmp(key, "userlist_show_status") == 0) {
|
||||||
|
gm_mcp_userlist_view_update_show_status(view,
|
||||||
|
gm_options_get_int(options, "userlist_show_status"));
|
||||||
|
} else if (strcmp(key, "userlist_use_state_icon") == 0) {
|
||||||
|
gm_mcp_userlist_view_update_use_state_icon(view,
|
||||||
|
gm_options_get_int(options, "userlist_use_state_icon"));
|
||||||
|
} else if (strcmp(key, "userlist_show_object_number") == 0) {
|
||||||
|
gm_mcp_userlist_view_update_show_object_number(view,
|
||||||
|
gm_options_get_int(options, "userlist_show_object_number"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gm_mcp_userlist_view_find(GmMcpUserlistView *view, gint id, GtkTreeIter *iter) {
|
gm_mcp_userlist_view_find(GmMcpUserlistView *view, gint id, GtkTreeIter *iter) {
|
||||||
GtkTreeModel *model = GTK_TREE_MODEL(view->store);
|
GtkTreeModel *model = GTK_TREE_MODEL(view->store);
|
||||||
|
@ -209,49 +562,12 @@ gm_mcp_userlist_view_find(GmMcpUserlistView *view, gint id, GtkTreeIter *iter) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gchar *
|
|
||||||
gm_mcp_userlist_view_get_name(GmMcpUserlistView *view, GmMcpPackage *package,
|
|
||||||
gint id) {
|
|
||||||
gchar const *name;
|
|
||||||
gchar *status;
|
|
||||||
gchar *escape;
|
|
||||||
gchar *result;
|
|
||||||
gchar *color;
|
|
||||||
GdkColor col;
|
|
||||||
|
|
||||||
name = gm_iuserlist_get_name(GM_IUSERLIST(package), id);
|
|
||||||
|
|
||||||
if (!gm_iuserlist_supports_status(GM_IUSERLIST(package))) {
|
|
||||||
return g_strdup(name);
|
|
||||||
} else {
|
|
||||||
status = gm_iuserlist_get_status(GM_IUSERLIST(package), id);
|
|
||||||
|
|
||||||
if (status) {
|
|
||||||
col = GTK_WIDGET(view->tree_view)->style->text[GTK_STATE_INSENSITIVE];
|
|
||||||
color = g_strdup_printf("#%04X%04X%04X", col.red, col.green,
|
|
||||||
col.blue);
|
|
||||||
|
|
||||||
escape = g_markup_escape_text(status, -1);
|
|
||||||
result = g_strconcat(name, "\n<small><span color=\"", color, "\">",
|
|
||||||
escape, "</span></small>", NULL);
|
|
||||||
|
|
||||||
g_free(color);
|
|
||||||
g_free(status);
|
|
||||||
g_free(escape);
|
|
||||||
} else {
|
|
||||||
result = g_strdup(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_gm_mcp_userlist_view_player_added(GmMcpPackage *package, gint id,
|
on_gm_mcp_userlist_view_player_added(GmMcpPackage *package, gint id,
|
||||||
gchar const *icon, gchar const *sort,
|
|
||||||
GmMcpUserlistView *view) {
|
GmMcpUserlistView *view) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
GmIUserlist *userlist = GM_IUSERLIST(package);
|
||||||
|
|
||||||
if (gm_mcp_userlist_view_find(view, id, &iter)) {
|
if (gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||||
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnPlayerAdded: player %d "
|
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnPlayerAdded: player %d "
|
||||||
|
@ -259,34 +575,58 @@ on_gm_mcp_userlist_view_player_added(GmMcpPackage *package, gint id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = gm_mcp_userlist_view_get_name(view, package, id);
|
name = gm_mcp_userlist_view_get_name(view, id);
|
||||||
|
|
||||||
gtk_list_store_append(view->store, &iter);
|
gtk_list_store_insert_with_values(view->store, &iter,
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_ID, id, GM_USERLIST_ICON,
|
gtk_tree_model_iter_n_children(GTK_TREE_MODEL(view->store), NULL),
|
||||||
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
GM_USERLIST_ID, id,
|
||||||
GM_USERLIST_ICON_SIZE), GM_USERLIST_NAME, name, GM_USERLIST_SORT,
|
GM_USERLIST_ICON, gm_pixbuf_get_at_size(
|
||||||
sort, -1);
|
gm_iuserlist_get_icon(userlist, id, view->use_state_icon),
|
||||||
|
GM_USERLIST_ICON_SIZE, GM_USERLIST_ICON_SIZE),
|
||||||
|
GM_USERLIST_CAPTION, name,
|
||||||
|
GM_USERLIST_RANK_PRIORITY,
|
||||||
|
gm_iuserlist_get_rank_priority(userlist, id),
|
||||||
|
GM_USERLIST_STATE_PRIORITY,
|
||||||
|
gm_iuserlist_get_state_priority(userlist, id),
|
||||||
|
-1);
|
||||||
|
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
|
view->num_players = view->num_players + 1;
|
||||||
|
|
||||||
|
if (gm_mcp_userlist_view_player_active(view, &iter)) {
|
||||||
|
view->num_active = view->num_active + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gm_mcp_userlist_view_update_label(view);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_gm_mcp_userlist_view_player_removed(GmMcpPackage *package, gint id,
|
on_gm_mcp_userlist_view_player_removed(GmMcpPackage *package, gint id,
|
||||||
GmMcpUserlistView *view) {
|
GmMcpUserlistView *view) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
|
||||||
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||||
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnPlayerRemoved: player %d "
|
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnPlayerRemoved: player %d "
|
||||||
"is not in the list, can't be removed!", id);
|
"is not in the list, can't be removed!", id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view->num_players = view->num_players - 1;
|
||||||
|
|
||||||
|
if (gm_mcp_userlist_view_player_active(view, &iter)) {
|
||||||
|
view->num_active = view->num_active - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gm_mcp_userlist_view_update_label(view);
|
||||||
|
|
||||||
gtk_list_store_remove(view->store, &iter);
|
gtk_list_store_remove(view->store, &iter);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
||||||
gchar const *sort, GmMcpUserlistView *view) {
|
GmMcpUserlistView *view) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
|
||||||
|
@ -296,19 +636,19 @@ on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = gm_mcp_userlist_view_get_name(view, package, id);
|
name = gm_mcp_userlist_view_get_name(view, id);
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_NAME, name, -1);
|
|
||||||
g_free(name);
|
|
||||||
|
|
||||||
if (sort) {
|
if (name != NULL) {
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_SORT, sort, -1);
|
gtk_list_store_set(view->store, &iter, GM_USERLIST_CAPTION, name, -1);
|
||||||
|
g_free(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_gm_mcp_userlist_view_rank_changed(GmMcpPackage *package, gint id,
|
on_gm_mcp_userlist_view_rank_changed(GmMcpPackage *package, gint id,
|
||||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view) {
|
GmMcpUserlistView *view) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
|
gchar const *icon;
|
||||||
|
|
||||||
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||||
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnRankChanged: player %d "
|
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnRankChanged: player %d "
|
||||||
|
@ -316,20 +656,24 @@ on_gm_mcp_userlist_view_rank_changed(GmMcpPackage *package, gint id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
icon = gm_iuserlist_get_icon(GM_IUSERLIST(package),
|
||||||
|
id, view->use_state_icon);
|
||||||
|
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_ICON,
|
gtk_list_store_set(view->store, &iter, GM_USERLIST_ICON,
|
||||||
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
||||||
GM_USERLIST_ICON_SIZE), -1);
|
GM_USERLIST_ICON_SIZE),
|
||||||
|
GM_USERLIST_RANK_PRIORITY, gm_iuserlist_get_rank_priority(
|
||||||
if (sort) {
|
GM_IUSERLIST(package), id),
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_SORT, sort, -1);
|
-1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
on_gm_mcp_userlist_view_state_changed(GmMcpPackage *package, gint id,
|
on_gm_mcp_userlist_view_state_changed(GmMcpPackage *package, gint id,
|
||||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view) {
|
GmMcpUserlistView *view) {
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
|
gchar const *icon;
|
||||||
|
gboolean active;
|
||||||
|
|
||||||
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||||
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnStateChanged: player %d "
|
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnStateChanged: player %d "
|
||||||
|
@ -337,17 +681,33 @@ on_gm_mcp_userlist_view_state_changed(GmMcpPackage *package, gint id,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
name = gm_mcp_userlist_view_get_name(view, package, id);
|
active = gm_mcp_userlist_view_player_active(view, &iter);
|
||||||
|
|
||||||
|
name = gm_mcp_userlist_view_get_name(view, id);
|
||||||
|
icon = gm_iuserlist_get_icon(GM_IUSERLIST(package), id,
|
||||||
|
view->use_state_icon);
|
||||||
|
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_ICON,
|
gtk_list_store_set(view->store, &iter, GM_USERLIST_ICON,
|
||||||
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
||||||
GM_USERLIST_ICON_SIZE), GM_USERLIST_NAME, name, -1);
|
GM_USERLIST_ICON_SIZE),
|
||||||
|
GM_USERLIST_CAPTION, name,
|
||||||
|
GM_USERLIST_STATE_PRIORITY, gm_iuserlist_get_state_priority(
|
||||||
|
GM_IUSERLIST(package), id),
|
||||||
|
-1);
|
||||||
|
|
||||||
g_free(name);
|
g_free(name);
|
||||||
|
|
||||||
if (sort) {
|
if (gm_mcp_userlist_view_player_active(view, &iter) != active) {
|
||||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_SORT, sort, -1);
|
if (active) {
|
||||||
}
|
// no longer active
|
||||||
|
view->num_active = view->num_active - 1;
|
||||||
|
} else {
|
||||||
|
// now active
|
||||||
|
view->num_active = view->num_active + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gm_mcp_userlist_view_update_label(view);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
|
@ -1,3 +1,7 @@
|
||||||
|
#ifndef __GM_MCP_USERLIST_VIEW_H__
|
||||||
|
#define __GM_MCP_USERLIST_VIEW_H__
|
||||||
|
|
||||||
|
|
||||||
typedef enum _PlayerStateMask {
|
typedef enum _PlayerStateMask {
|
||||||
USERLIST_STATE_IDLE = 1 << 0,
|
USERLIST_STATE_IDLE = 1 << 0,
|
||||||
USERLIST_STATE_BUSY = 1 << 1,
|
USERLIST_STATE_BUSY = 1 << 1,
|
||||||
|
@ -14,4 +18,15 @@ typedef enum _UserlistEvent {
|
||||||
USERLIST_EVENT_AWAY_OFF = 1 << 5
|
USERLIST_EVENT_AWAY_OFF = 1 << 5
|
||||||
} UserlistEvent;
|
} UserlistEvent;
|
||||||
|
|
||||||
|
typedef enum _GmUserlistSortType {
|
||||||
|
GM_USERLIST_SORT_TYPE_STATE_RANK_NAME,
|
||||||
|
GM_USERLIST_SORT_TYPE_RANK_NAME,
|
||||||
|
GM_USERLIST_SORT_TYPE_STATE_NAME,
|
||||||
|
GM_USERLIST_SORT_TYPE_NAME,
|
||||||
|
GM_USERLIST_SORT_TYPE_NUM
|
||||||
|
} GmUserlistSortType;
|
||||||
|
|
||||||
void gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent);
|
void gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GM_MCP_USERLIST_VIEW_H__ */
|
||||||
|
|
|
@ -49,19 +49,14 @@ struct _GmMcpVmooUserlistPrivate {
|
||||||
gboolean initializing;
|
gboolean initializing;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Signals */
|
/* Signals
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
PLAYER_ADDED,
|
|
||||||
PLAYER_REMOVED,
|
|
||||||
NAME_CHANGED,
|
|
||||||
STATE_CHANGED,
|
|
||||||
RANK_CHANGED,
|
|
||||||
NUM_SIGNALS
|
NUM_SIGNALS
|
||||||
};
|
};*/
|
||||||
|
|
||||||
|
//static guint gm_mcp_vmoo_userlist_signals[NUM_SIGNALS] = {0};
|
||||||
static void gm_mcp_vmoo_userlist_iface_init(GmIUserlistInterface *iface);
|
static void gm_mcp_vmoo_userlist_iface_init(GmIUserlistInterface *iface);
|
||||||
static guint gm_mcp_vmoo_userlist_signals[NUM_SIGNALS] = {0};
|
|
||||||
|
|
||||||
G_DEFINE_TYPE_EXTENDED(GmMcpVmooUserlist, gm_mcp_vmoo_userlist, \
|
G_DEFINE_TYPE_EXTENDED(GmMcpVmooUserlist, gm_mcp_vmoo_userlist, \
|
||||||
GM_TYPE_MCP_PACKAGE, 0, G_IMPLEMENT_INTERFACE(GM_TYPE_IUSERLIST, \
|
GM_TYPE_MCP_PACKAGE, 0, G_IMPLEMENT_INTERFACE(GM_TYPE_IUSERLIST, \
|
||||||
|
@ -77,13 +72,23 @@ void gm_mcp_vmoo_userlist_create_view(GmMcpPackage *package,
|
||||||
GObject *parent);
|
GObject *parent);
|
||||||
|
|
||||||
GList *gm_mcp_vmoo_userlist_get_menu(GmIUserlist *userlist, gint id);
|
GList *gm_mcp_vmoo_userlist_get_menu(GmIUserlist *userlist, gint id);
|
||||||
|
|
||||||
gchar const *gm_mcp_vmoo_userlist_get_name(GmIUserlist *userlist, gint id);
|
gchar const *gm_mcp_vmoo_userlist_get_name(GmIUserlist *userlist, gint id);
|
||||||
|
gchar const *gm_mcp_vmoo_userlist_get_icon(GmIUserlist *userlist, gint id,
|
||||||
|
gboolean use_state);
|
||||||
|
gchar *gm_mcp_vmoo_userlist_get_status(GmIUserlist *userlist, gint id);
|
||||||
|
gint gm_mcp_vmoo_userlist_get_rank_priority(GmIUserlist *userlist, gint id);
|
||||||
|
gint gm_mcp_vmoo_userlist_get_state_priority(GmIUserlist *userlist, gint id);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gm_mcp_vmoo_userlist_iface_init(
|
gm_mcp_vmoo_userlist_iface_init(
|
||||||
GmIUserlistInterface *iface) {
|
GmIUserlistInterface *iface) {
|
||||||
iface->get_menu = gm_mcp_vmoo_userlist_get_menu;
|
iface->get_menu = gm_mcp_vmoo_userlist_get_menu;
|
||||||
iface->get_name = gm_mcp_vmoo_userlist_get_name;
|
iface->get_name = gm_mcp_vmoo_userlist_get_name;
|
||||||
|
iface->get_status = gm_mcp_vmoo_userlist_get_status;
|
||||||
|
iface->get_icon = gm_mcp_vmoo_userlist_get_icon;
|
||||||
|
iface->get_rank_priority = gm_mcp_vmoo_userlist_get_rank_priority;
|
||||||
|
iface->get_state_priority = gm_mcp_vmoo_userlist_get_state_priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -151,65 +156,6 @@ gm_mcp_vmoo_userlist_class_init(GmMcpVmooUserlistClass *klass) {
|
||||||
|
|
||||||
object_class->finalize = gm_mcp_vmoo_userlist_finalize;
|
object_class->finalize = gm_mcp_vmoo_userlist_finalize;
|
||||||
|
|
||||||
gm_mcp_vmoo_userlist_signals[PLAYER_ADDED] =
|
|
||||||
g_signal_new("player_added",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpVmooUserlistClass, player_added),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
3,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
gm_mcp_vmoo_userlist_signals[PLAYER_REMOVED] =
|
|
||||||
g_signal_new("player_removed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpVmooUserlistClass, player_removed),
|
|
||||||
NULL, NULL,
|
|
||||||
g_cclosure_marshal_VOID__INT,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
1,
|
|
||||||
G_TYPE_INT);
|
|
||||||
gm_mcp_vmoo_userlist_signals[NAME_CHANGED] =
|
|
||||||
g_signal_new("name_changed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpVmooUserlistClass, name_changed),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
2,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
gm_mcp_vmoo_userlist_signals[STATE_CHANGED] =
|
|
||||||
g_signal_new("state_changed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpVmooUserlistClass, state_changed),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
3,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
|
|
||||||
gm_mcp_vmoo_userlist_signals[RANK_CHANGED] =
|
|
||||||
g_signal_new("rank_changed",
|
|
||||||
G_OBJECT_CLASS_TYPE(object_class),
|
|
||||||
G_SIGNAL_RUN_LAST,
|
|
||||||
G_STRUCT_OFFSET(GmMcpVmooUserlistClass, rank_changed),
|
|
||||||
NULL, NULL,
|
|
||||||
gm_marshal_VOID__INT_STRING_STRING,
|
|
||||||
G_TYPE_NONE,
|
|
||||||
3,
|
|
||||||
G_TYPE_INT,
|
|
||||||
G_TYPE_STRING,
|
|
||||||
G_TYPE_STRING);
|
|
||||||
|
|
||||||
pklass->name = "dns-com-vmoo-userlist";
|
pklass->name = "dns-com-vmoo-userlist";
|
||||||
pklass->handle_simple = &gm_mcp_vmoo_userlist_handle_simple;
|
pklass->handle_simple = &gm_mcp_vmoo_userlist_handle_simple;
|
||||||
pklass->handle_multi = &gm_mcp_vmoo_userlist_handle_multi;
|
pklass->handle_multi = &gm_mcp_vmoo_userlist_handle_multi;
|
||||||
|
@ -281,7 +227,8 @@ gm_mcp_vmoo_userlist_handle_fields(GmMcpVmooUserlist *package, MOOVar *list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gchar const *
|
gchar const *
|
||||||
gm_mcp_vmoo_userlist_get_icon(GmMcpVmooUserlist *package, UserInfo *ui) {
|
gm_mcp_vmoo_userlist_icon_path(GmMcpVmooUserlist *package, UserInfo *ui,
|
||||||
|
gboolean use_state) {
|
||||||
gchar *field;
|
gchar *field;
|
||||||
guint index = ui->icon;
|
guint index = ui->icon;
|
||||||
GmKeyValuePair const *pair;
|
GmKeyValuePair const *pair;
|
||||||
|
@ -289,33 +236,33 @@ gm_mcp_vmoo_userlist_get_icon(GmMcpVmooUserlist *package, UserInfo *ui) {
|
||||||
if (index < 1 || index > g_list_length(package->priv->icons)) {
|
if (index < 1 || index > g_list_length(package->priv->icons)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
switch (ui->state) {
|
if (!use_state || ui->state == U_NORMAL) {
|
||||||
case U_NORMAL:
|
field = (gchar *)(g_list_nth_data(package->priv->icons,
|
||||||
field = (gchar *)(g_list_nth_data(package->priv->icons,
|
index - 1));
|
||||||
index - 1));
|
|
||||||
|
|
||||||
pair = icon_mapping;
|
pair = icon_mapping;
|
||||||
|
|
||||||
while (!(pair->key == NULL && pair->value == NULL)) {
|
while (!(pair->key == NULL && pair->value == NULL)) {
|
||||||
if (strcasecmp(pair->key, field) == 0) {
|
if (strcasecmp(pair->key, field) == 0) {
|
||||||
return pair->value;
|
return pair->value;
|
||||||
}
|
|
||||||
|
|
||||||
++pair;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
++pair;
|
||||||
case U_IDLE:
|
}
|
||||||
return "userlist/idle.svg";
|
} else {
|
||||||
break;
|
switch (ui->state) {
|
||||||
case U_AWAY:
|
case U_IDLE:
|
||||||
return "userlist/away.svg";
|
return "userlist/idle.svg";
|
||||||
break;
|
break;
|
||||||
case U_IDLEAWAY:
|
case U_AWAY:
|
||||||
return "userlist/idleaway.svg";
|
return "userlist/away.svg";
|
||||||
break;
|
break;
|
||||||
default:
|
case U_IDLEAWAY:
|
||||||
break;
|
return "userlist/idleaway.svg";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -525,12 +472,58 @@ gm_mcp_vmoo_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
||||||
|
|
||||||
gchar const *
|
gchar const *
|
||||||
gm_mcp_vmoo_userlist_get_name(GmIUserlist *userlist, gint id) {
|
gm_mcp_vmoo_userlist_get_name(GmIUserlist *userlist, gint id) {
|
||||||
GmMcpVmooUserlist *package = (GmMcpVmooUserlist *)(userlist);
|
GmMcpVmooUserlist *package = GM_MCP_VMOO_USERLIST(userlist);
|
||||||
UserInfo *info = gm_mcp_vmoo_userlist_find_user(package, id);
|
UserInfo *info = gm_mcp_vmoo_userlist_find_user(package, id);
|
||||||
|
|
||||||
return info->name;
|
return info->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gchar *
|
||||||
|
gm_mcp_vmoo_userlist_get_status(GmIUserlist *userlist, gint id) {
|
||||||
|
GmMcpVmooUserlist *package = GM_MCP_VMOO_USERLIST(userlist);
|
||||||
|
UserInfo *info = gm_mcp_vmoo_userlist_find_user(package, id);
|
||||||
|
|
||||||
|
switch (info->state) {
|
||||||
|
case U_AWAY:
|
||||||
|
return g_strdup(_("Away"));
|
||||||
|
break;
|
||||||
|
case U_IDLE:
|
||||||
|
return g_strdup(_("Idle"));
|
||||||
|
break;
|
||||||
|
case U_IDLEAWAY:
|
||||||
|
return g_strdup(_("Idle and away"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gchar const *
|
||||||
|
gm_mcp_vmoo_userlist_get_icon(GmIUserlist *userlist, gint id,
|
||||||
|
gboolean use_state) {
|
||||||
|
GmMcpVmooUserlist *package = GM_MCP_VMOO_USERLIST(userlist);
|
||||||
|
UserInfo *info = gm_mcp_vmoo_userlist_find_user(package, id);
|
||||||
|
|
||||||
|
return gm_mcp_vmoo_userlist_icon_path(package, info, use_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_mcp_vmoo_userlist_get_rank_priority(GmIUserlist *userlist, gint id) {
|
||||||
|
GmMcpVmooUserlist *package = GM_MCP_VMOO_USERLIST(userlist);
|
||||||
|
UserInfo *info = gm_mcp_vmoo_userlist_find_user(package, id);
|
||||||
|
|
||||||
|
return g_list_length(package->priv->icons) - info->icon;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gm_mcp_vmoo_userlist_get_state_priority(GmIUserlist *userlist, gint id) {
|
||||||
|
GmMcpVmooUserlist *package = GM_MCP_VMOO_USERLIST(userlist);
|
||||||
|
UserInfo *info = gm_mcp_vmoo_userlist_find_user(package, id);
|
||||||
|
|
||||||
|
return info->state;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gm_mcp_vmoo_userlist_remove_user(GmMcpVmooUserlist *package, gint nr) {
|
gm_mcp_vmoo_userlist_remove_user(GmMcpVmooUserlist *package, gint nr) {
|
||||||
GList *elem;
|
GList *elem;
|
||||||
|
@ -548,30 +541,7 @@ gm_mcp_vmoo_userlist_remove_user(GmMcpVmooUserlist *package, gint nr) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
g_signal_emit(package, gm_mcp_vmoo_userlist_signals[PLAYER_REMOVED], 0,
|
g_signal_emit_by_name(package, "player-removed", nr);
|
||||||
nr);
|
|
||||||
}
|
|
||||||
|
|
||||||
gchar *
|
|
||||||
gm_mcp_vmoo_userlist_sort_string(GmMcpVmooUserlist *package, UserInfo *ui) {
|
|
||||||
guint sortid = 0;
|
|
||||||
|
|
||||||
switch (ui->state) {
|
|
||||||
case U_NORMAL:
|
|
||||||
sortid = g_list_length(package->priv->icons) - ui->icon;
|
|
||||||
break;
|
|
||||||
case U_AWAY:
|
|
||||||
sortid = g_list_length(package->priv->icons) + 1;
|
|
||||||
break;
|
|
||||||
case U_IDLE:
|
|
||||||
sortid = g_list_length(package->priv->icons) + 2;
|
|
||||||
break;
|
|
||||||
case U_IDLEAWAY:
|
|
||||||
sortid = g_list_length(package->priv->icons) + 3;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return g_strdup_printf("%.2d%s", sortid, ui->name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -579,7 +549,6 @@ gm_mcp_vmoo_userlist_handle_user_update(GmMcpVmooUserlist *package, MOOVar *v) {
|
||||||
gint nr = gm_mcp_vmoo_userlist_get_int(package, v, OBJECT, "object");
|
gint nr = gm_mcp_vmoo_userlist_get_int(package, v, OBJECT, "object");
|
||||||
gchar *name = gm_mcp_vmoo_userlist_get_string(package, v, STRING, "name");
|
gchar *name = gm_mcp_vmoo_userlist_get_string(package, v, STRING, "name");
|
||||||
gint icon = gm_mcp_vmoo_userlist_get_int(package, v, INT, "icon");
|
gint icon = gm_mcp_vmoo_userlist_get_int(package, v, INT, "icon");
|
||||||
gchar *sort;
|
|
||||||
|
|
||||||
UserInfo *ui;
|
UserInfo *ui;
|
||||||
|
|
||||||
|
@ -591,13 +560,9 @@ gm_mcp_vmoo_userlist_handle_user_update(GmMcpVmooUserlist *package, MOOVar *v) {
|
||||||
ui->icon = icon;
|
ui->icon = icon;
|
||||||
ui->nr = nr;
|
ui->nr = nr;
|
||||||
|
|
||||||
//
|
|
||||||
package->priv->users = g_list_append(package->priv->users, ui);
|
package->priv->users = g_list_append(package->priv->users, ui);
|
||||||
sort = gm_mcp_vmoo_userlist_sort_string(package, ui);
|
|
||||||
g_signal_emit(package, gm_mcp_vmoo_userlist_signals[PLAYER_ADDED], 0,
|
g_signal_emit_by_name(package, "player-added", nr);
|
||||||
nr, gm_mcp_vmoo_userlist_get_icon(package, ui), sort);
|
|
||||||
g_free(sort);
|
|
||||||
|
|
||||||
gm_mcp_vmoo_userlist_process_triggers(package, ui->name,
|
gm_mcp_vmoo_userlist_process_triggers(package, ui->name,
|
||||||
TCT_USER_ONLINE);
|
TCT_USER_ONLINE);
|
||||||
} else {
|
} else {
|
||||||
|
@ -605,20 +570,14 @@ gm_mcp_vmoo_userlist_handle_user_update(GmMcpVmooUserlist *package, MOOVar *v) {
|
||||||
g_free(ui->name);
|
g_free(ui->name);
|
||||||
ui->name = name;
|
ui->name = name;
|
||||||
|
|
||||||
sort = gm_mcp_vmoo_userlist_sort_string(package, ui);
|
g_signal_emit_by_name(package, "name-changed", nr);
|
||||||
g_signal_emit(package, gm_mcp_vmoo_userlist_signals[NAME_CHANGED],
|
|
||||||
0, nr, sort);
|
|
||||||
g_free(sort);
|
|
||||||
} else {
|
} else {
|
||||||
g_free(name);
|
g_free(name);
|
||||||
}
|
}
|
||||||
if (ui->icon != (guint)icon) {
|
if (ui->icon != (guint)icon) {
|
||||||
ui->icon = (guint)icon;
|
ui->icon = (guint)icon;
|
||||||
|
|
||||||
sort = gm_mcp_vmoo_userlist_sort_string(package, ui);
|
g_signal_emit_by_name(package, "rank-changed", nr);
|
||||||
g_signal_emit(package, gm_mcp_vmoo_userlist_signals[RANK_CHANGED],
|
|
||||||
0, nr, gm_mcp_vmoo_userlist_get_icon(package, ui), sort);
|
|
||||||
g_free(sort);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -683,7 +642,6 @@ gm_mcp_vmoo_userlist_handle_state(GmMcpVmooUserlist *package, MOOVar *v,
|
||||||
UserState state, gboolean onOff) {
|
UserState state, gboolean onOff) {
|
||||||
MOOVar *nr;
|
MOOVar *nr;
|
||||||
UserInfo *u;
|
UserInfo *u;
|
||||||
gchar *sort;
|
|
||||||
GmTriggerConditionType condition = 0;
|
GmTriggerConditionType condition = 0;
|
||||||
|
|
||||||
if (v->type != LIST) {
|
if (v->type != LIST) {
|
||||||
|
@ -732,18 +690,12 @@ gm_mcp_vmoo_userlist_handle_state(GmMcpVmooUserlist *package, MOOVar *v,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
sort = gm_mcp_vmoo_userlist_sort_string(package, u);
|
g_signal_emit_by_name(package, "state-changed", u->nr);
|
||||||
|
|
||||||
g_signal_emit(package,
|
|
||||||
gm_mcp_vmoo_userlist_signals[STATE_CHANGED], 0,
|
|
||||||
nr->i, gm_mcp_vmoo_userlist_get_icon(package, u), sort);
|
|
||||||
|
|
||||||
if (condition != 0) {
|
if (condition != 0) {
|
||||||
gm_mcp_vmoo_userlist_process_triggers(package, u->name,
|
gm_mcp_vmoo_userlist_process_triggers(package, u->name,
|
||||||
condition);
|
condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free(sort);
|
|
||||||
} else {
|
} else {
|
||||||
gm_debug_msg(DEBUG_MCP, "User %d does not exist!", nr->i);
|
gm_debug_msg(DEBUG_MCP, "User %d does not exist!", nr->i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,17 +46,6 @@ typedef struct _GmMcpVmooUserlistClass GmMcpVmooUserlistClass;
|
||||||
|
|
||||||
struct _GmMcpVmooUserlistClass {
|
struct _GmMcpVmooUserlistClass {
|
||||||
GmMcpPackageClass parent_class;
|
GmMcpPackageClass parent_class;
|
||||||
|
|
||||||
/* Signals */
|
|
||||||
void (* player_added) (GmMcpVmooUserlist *obj, gint id,
|
|
||||||
gchar const *icon, gchar const *sort);
|
|
||||||
void (* player_removed) (GmMcpVmooUserlist *obj, gint id);
|
|
||||||
void (* name_changed) (GmMcpVmooUserlist *obj, gint id,
|
|
||||||
gchar const *sort);
|
|
||||||
void (* state_changed) (GmMcpVmooUserlist *obj, gint id,
|
|
||||||
gchar const *icon, gchar const *sort);
|
|
||||||
void (* rank_changed) (GmMcpVmooUserlist *obj, gint id,
|
|
||||||
gchar const *icon, gchar const *sort);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
GType gm_mcp_vmoo_userlist_get_type(void) G_GNUC_CONST;
|
GType gm_mcp_vmoo_userlist_get_type(void) G_GNUC_CONST;
|
||||||
|
|
|
@ -12,9 +12,9 @@ gm_mcp_get_version(gdouble client_min, gdouble client_max, gdouble server_min,
|
||||||
gdouble server_max) {
|
gdouble server_max) {
|
||||||
if (client_max >= server_min && server_max >= client_min) {
|
if (client_max >= server_min && server_max >= client_min) {
|
||||||
if (client_max < server_max) {
|
if (client_max < server_max) {
|
||||||
return server_max;
|
|
||||||
} else {
|
|
||||||
return client_max;
|
return client_max;
|
||||||
|
} else {
|
||||||
|
return server_max;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
Reference in New Issue