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>
|
||||
* gnoemoe/dialogs/gm-scripts-dialog.c: added theme
|
||||
* gnoemoe/dialogs/gm-world-properties-dialog.c: added logging
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
#include "gm-iuserlist.h"
|
||||
#include "gm-marshal.h"
|
||||
|
||||
static void gm_iuserlist_base_init(gpointer object_class);
|
||||
|
||||
GType
|
||||
gm_iuserlist_get_type() {
|
||||
|
@ -7,7 +10,7 @@ gm_iuserlist_get_type() {
|
|||
if (iuserlist_type == 0) {
|
||||
static const GTypeInfo iuserlist_info = {
|
||||
sizeof (GmIUserlistInterface),
|
||||
NULL, /* base_init */
|
||||
gm_iuserlist_base_init, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
NULL, /* class_init */
|
||||
NULL, /* class_finalize */
|
||||
|
@ -24,6 +27,61 @@ gm_iuserlist_get_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 *
|
||||
gm_iuserlist_get_menu(GmIUserlist *self, gint id) {
|
||||
GmIUserlistInterface *iface;
|
||||
|
@ -47,11 +105,7 @@ gm_iuserlist_supports_status(GmIUserlist *self) {
|
|||
|
||||
iface = GM_IUSERLIST_GET_INTERFACE(self);
|
||||
|
||||
if (iface->supports_status) {
|
||||
return (* iface->supports_status) (self);
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
return (iface->get_status != NULL);
|
||||
}
|
||||
|
||||
gchar *
|
||||
|
@ -83,3 +137,48 @@ gm_iuserlist_get_name(GmIUserlist *self, gint id) {
|
|||
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;
|
||||
|
||||
GList *(* get_menu) (GmIUserlist *self, gint id);
|
||||
gboolean (* supports_status) (GmIUserlist *self);
|
||||
gchar *(* get_status) (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();
|
||||
|
@ -31,6 +41,11 @@ GType gm_iuserlist_get_type();
|
|||
GList *gm_iuserlist_get_menu(GmIUserlist *self, gint id);
|
||||
gboolean gm_iuserlist_supports_status(GmIUserlist *self);
|
||||
gchar *gm_iuserlist_get_status(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__ */
|
||||
|
|
|
@ -100,7 +100,8 @@ gm_mcp_icecrew_playerdb_class_init(GmMcpIcecrewPlayerdbClass *klass) {
|
|||
pklass->name = "dns-nl-icecrew-playerdb";
|
||||
pklass->handle_simple = &gm_mcp_icecrew_playerdb_handle_simple;
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -346,7 +347,7 @@ gm_mcp_icecrew_playerdb_handle_multi(GmMcpPackage *package,
|
|||
if ((ppi = gm_mcp_icecrew_playerdb_find(playerdb, i))) {
|
||||
gm_mcp_icecrew_playerdb_remove_player(playerdb, i);
|
||||
}
|
||||
|
||||
|
||||
ppi = gm_mcp_icecrew_playerdb_add_player(playerdb, i);
|
||||
|
||||
for (counter = 0; counter < g_list_length(l); ++counter) {
|
||||
|
|
|
@ -25,9 +25,9 @@
|
|||
static GmKeyValuePair default_states[] = {
|
||||
{"away+idle", "ice-userlist/away+idle.svg"},
|
||||
{"busy+idle", "ice-userlist/busy+idle.svg"},
|
||||
{"avail+idle", "ice-userlist/avail+idle.svg"},
|
||||
{"away", "ice-userlist/away.svg"},
|
||||
{"busy", "ice-userlist/busy.svg"},
|
||||
{"avail+idle", "ice-userlist/avail+idle.svg"},
|
||||
{NULL, NULL}
|
||||
};
|
||||
|
||||
|
@ -50,7 +50,7 @@ struct _GmMcpIcecrewUserlistPrivate {
|
|||
|
||||
gchar *rank_dir;
|
||||
gchar *state_dir;
|
||||
|
||||
gchar **property_names;
|
||||
GList *menu;
|
||||
|
||||
gboolean initializing;
|
||||
|
@ -65,19 +65,34 @@ static gchar *gm_mcp_icecrew_userlist_overrides[] = {
|
|||
NULL
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
|
||||
enum {
|
||||
PLAYER_ADDED,
|
||||
PLAYER_REMOVED,
|
||||
NAME_CHANGED,
|
||||
STATE_CHANGED,
|
||||
RANK_CHANGED,
|
||||
NUM_SIGNALS
|
||||
P_NAME,
|
||||
P_RANK,
|
||||
P_STATE,
|
||||
P_STATE_MSG
|
||||
};
|
||||
|
||||
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 guint gm_mcp_icecrew_userlist_signals[NUM_SIGNALS] = {0};
|
||||
|
||||
G_DEFINE_TYPE_EXTENDED(GmMcpIcecrewUserlist, gm_mcp_icecrew_userlist, \
|
||||
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);
|
||||
gboolean gm_mcp_icecrew_userlist_supports_status(GmIUserlist *userlist);
|
||||
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_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
|
||||
gm_mcp_icecrew_userlist_iface_init(
|
||||
GmIUserlistInterface *iface) {
|
||||
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_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
|
||||
|
@ -187,69 +210,11 @@ gm_mcp_icecrew_userlist_class_init(GmMcpIcecrewUserlistClass *klass) {
|
|||
|
||||
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->depends = gm_mcp_icecrew_userlist_depends;
|
||||
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->handle_multi = &gm_mcp_icecrew_userlist_handle_multi;
|
||||
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;
|
||||
GmKeyValuePair *map;
|
||||
|
||||
if (path == NULL || icons == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (item = icons; item; item = item->next) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -285,15 +254,23 @@ gm_mcp_icecrew_userlist_find_icon_names(GList *icons, gchar const *path) {
|
|||
|
||||
guint
|
||||
gm_mcp_icecrew_userlist_find_path(GList *icons, gchar const *name,
|
||||
gchar **path) {
|
||||
gchar const **path) {
|
||||
GList *item;
|
||||
GmKeyValuePair *map;
|
||||
guint position = 0;
|
||||
|
||||
if (name == NULL) {
|
||||
if (path != NULL) {
|
||||
*path = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
for (item = icons; item; item = item->next) {
|
||||
map = (GmKeyValuePair *)(item->data);
|
||||
|
||||
if (strcmp(map->key, name) == 0) {
|
||||
if (map->key != NULL && strcmp(map->key, name) == 0) {
|
||||
if (path != NULL) {
|
||||
*path = map->value;
|
||||
}
|
||||
|
@ -316,6 +293,10 @@ gm_mcp_icecrew_userlist_remove_datatag(GmMcpIcecrewUserlist *package,
|
|||
GList *item;
|
||||
GmKeyValuePair *map;
|
||||
|
||||
if (datatag == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (item = package->priv->key_datatags; item; item = item->next) {
|
||||
map = (GmKeyValuePair *)(item->data);
|
||||
|
||||
|
@ -337,10 +318,14 @@ gm_mcp_icecrew_userlist_find_key(GmMcpIcecrewUserlist *package,
|
|||
GList *item;
|
||||
GmKeyValuePair *map;
|
||||
|
||||
if (datatag == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
for (item = package->priv->key_datatags; item; item = item->next) {
|
||||
map = (GmKeyValuePair *)(item->data);
|
||||
|
||||
if (strcmp(map->value, datatag) == 0) {
|
||||
if (map->value != NULL && strcmp(map->value, datatag) == 0) {
|
||||
return map->key;
|
||||
}
|
||||
}
|
||||
|
@ -352,9 +337,13 @@ gchar const *
|
|||
gm_mcp_icecrew_userlist_find_name(gchar const *name,
|
||||
GmKeyValuePair def[]) {
|
||||
GmKeyValuePair *pair = def;
|
||||
|
||||
|
||||
if (name == NULL) {
|
||||
return 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;
|
||||
}
|
||||
|
||||
|
@ -403,7 +392,7 @@ gm_mcp_icecrew_userlist_init(GmMcpIcecrewUserlist *obj) {
|
|||
obj->priv->state_fetch = NULL;
|
||||
|
||||
gm_mcp_icecrew_userlist_init_states(obj);
|
||||
gm_mcp_icecrew_userlist_init_ranks(obj);
|
||||
gm_mcp_icecrew_userlist_init_ranks(obj);
|
||||
}
|
||||
|
||||
GmMcpIcecrewUserlist *
|
||||
|
@ -433,7 +422,11 @@ gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package,
|
|||
gint i;
|
||||
GmKeyValuePair *map;
|
||||
gchar *name, *pathd, *dir;
|
||||
|
||||
|
||||
if (path == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
alter = rank ? &(package->priv->rank_alternatives) :
|
||||
&(package->priv->state_alternatives);
|
||||
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);
|
||||
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);
|
||||
i = 0;
|
||||
|
||||
while (item && (n == 0 || i < n)) {
|
||||
map = (GmKeyValuePair *)(item->data);
|
||||
++i;
|
||||
if (name != NULL) {
|
||||
while (item && (n == 0 || i < n)) {
|
||||
map = (GmKeyValuePair *)(item->data);
|
||||
++i;
|
||||
|
||||
if (strcmp(map->key, name) == 0) {
|
||||
item = item->next;
|
||||
*alter = g_list_remove(*alter, map);
|
||||
gm_mcp_icecrew_userlist_pair_free(map);
|
||||
} else {
|
||||
break;
|
||||
if (map->key != NULL && strcmp(map->key, name) == 0) {
|
||||
item = item->next;
|
||||
*alter = g_list_remove(*alter, map);
|
||||
gm_mcp_icecrew_userlist_pair_free(map);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -468,40 +463,19 @@ gm_mcp_icecrew_userlist_remove_alternatives(GmMcpIcecrewUserlist *package,
|
|||
}
|
||||
}
|
||||
|
||||
gchar *
|
||||
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 *
|
||||
gchar const *
|
||||
gm_mcp_icecrew_userlist_icon_path(GmMcpIcecrewUserlist *package,
|
||||
GmPlayerdbPlayerInfo *ppi) {
|
||||
GmPlayerdbPlayerInfo *ppi, gboolean use_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_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 {
|
||||
gm_mcp_icecrew_userlist_find_path(package->priv->state_icons,
|
||||
state, &icon_path);
|
||||
|
@ -514,33 +488,13 @@ gm_mcp_icecrew_userlist_icon_path(GmMcpIcecrewUserlist *package,
|
|||
void
|
||||
gm_mcp_icecrew_userlist_update_rank_icon(GmPlayerdbPlayerInfo *ppi,
|
||||
gpointer user_data) {
|
||||
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(user_data);
|
||||
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);
|
||||
}
|
||||
g_signal_emit_by_name(user_data, "rank-changed", ppi->id);
|
||||
}
|
||||
|
||||
void
|
||||
gm_mcp_icecrew_userlist_update_state_icon(GmPlayerdbPlayerInfo *ppi,
|
||||
gpointer user_data) {
|
||||
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(user_data);
|
||||
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);
|
||||
g_signal_emit_by_name(user_data, "state-changed", ppi->id);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -570,12 +524,14 @@ gm_mcp_icecrew_userlist_new_rank_state_icon(GmMcpIcecrewUserlist *package,
|
|||
for (tmp = names; tmp; tmp = tmp->next) {
|
||||
if (rank) {
|
||||
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),
|
||||
gm_mcp_icecrew_userlist_update_rank_icon, package);
|
||||
} else {
|
||||
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),
|
||||
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);
|
||||
|
||||
/* 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();
|
||||
result = gnome_vfs_get_file_info(map->value, finfo,
|
||||
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) {
|
||||
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);
|
||||
itermap->value = g_strdup(path);
|
||||
break;
|
||||
|
@ -837,7 +795,7 @@ gm_mcp_icecrew_userlist_menu_item_subst(GmMcpIcecrewUserlist *package,
|
|||
|
||||
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);
|
||||
result = g_string_append(result, tmp);
|
||||
g_free(tmp);
|
||||
|
@ -900,6 +858,7 @@ gm_mcp_icecrew_userlist_get_menu_item(GmMcpIcecrewUserlist *package,
|
|||
return result;
|
||||
}
|
||||
|
||||
/* Interface */
|
||||
GList *
|
||||
gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
||||
GmMcpIcecrewUserlist *object = GM_MCP_ICECREW_USERLIST(userlist);
|
||||
|
@ -917,11 +876,6 @@ gm_mcp_icecrew_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
|||
return result;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gm_mcp_icecrew_userlist_supports_status(GmIUserlist *userlist) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gchar const *
|
||||
gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id) {
|
||||
GmMcpIcecrewPlayerdb *playerdb = GM_MCP_ICECREW_PLAYERDB(
|
||||
|
@ -929,7 +883,51 @@ gm_mcp_icecrew_userlist_get_name(GmIUserlist *userlist, gint id) {
|
|||
"dns-nl-icecrew-playerdb"));
|
||||
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 *
|
||||
|
@ -938,23 +936,29 @@ gm_mcp_icecrew_userlist_get_status(GmIUserlist *userlist, gint id) {
|
|||
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, "P_STATE");
|
||||
gchar const *msg = gm_playerdb_player_info_get_prop(info, "P_STATE_MSG");
|
||||
GmMcpIcecrewUserlist *package = GM_MCP_ICECREW_USERLIST(userlist);
|
||||
|
||||
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;
|
||||
|
||||
if (state == NULL || strcmp(state, "avail") == 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (strstr(state, "away") != 0) {
|
||||
if (strstr(state, "away") != NULL) {
|
||||
caption = _("Away");
|
||||
} else if (strstr(state, "busy") != 0) {
|
||||
} else if (strstr(state, "busy") != NULL) {
|
||||
caption = _("Busy");
|
||||
} else if (strstr(state, "idle") != NULL) {
|
||||
caption = _("Idle");
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (msg == NULL) {
|
||||
if (msg == NULL || *msg == '\0') {
|
||||
return strdup(caption);
|
||||
} else {
|
||||
return g_strconcat(caption, ": ", msg, NULL);
|
||||
|
@ -1011,9 +1015,9 @@ gm_mcp_icecrew_userlist_handle_ranks_states(GmMcpIcecrewUserlist *package,
|
|||
}
|
||||
|
||||
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: "
|
||||
"duplicate %s, ignored!", name);
|
||||
continue;
|
||||
|
@ -1138,13 +1142,24 @@ gm_mcp_icecrew_userlist_set_session(GmMcpPackage *package, GObject *session) {
|
|||
GmMcpPackage *playerdb;
|
||||
GmMcpIcecrewUserlist *userlist = GM_MCP_ICECREW_USERLIST(package);
|
||||
GmMcpSession *ses;
|
||||
|
||||
gdouble version;
|
||||
|
||||
parent_class->set_session(package, session);
|
||||
ses = GM_MCP_SESSION(session);
|
||||
|
||||
playerdb = gm_mcp_session_find_package(ses, "dns-nl-icecrew-playerdb");
|
||||
|
||||
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)),
|
||||
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);
|
||||
if (!g_file_test(userlist->priv->state_dir, G_FILE_TEST_EXISTS))
|
||||
mkdir(userlist->priv->state_dir, 0755);
|
||||
|
||||
|
||||
g_free(icons_dir);
|
||||
|
||||
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) {
|
||||
gboolean was_away, was_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_idle = (strstr(old, "idle") != NULL);
|
||||
|
@ -1209,57 +1225,37 @@ gm_mcp_icecrew_userlist_process_state_changed(GmMcpIcecrewUserlist *userlist,
|
|||
void
|
||||
on_gm_mcp_icecrew_userlist_add(GmMcpIcecrewPlayerdb *playerdb,
|
||||
GmPlayerdbPlayerInfo *ppi, GmMcpIcecrewUserlist *userlist) {
|
||||
gchar *sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
||||
gchar const *name = gm_playerdb_player_info_get_prop(ppi, "P_NAME");
|
||||
gchar const *icon_path = gm_mcp_icecrew_userlist_icon_path(userlist, ppi);
|
||||
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_ADDED],
|
||||
0, ppi->id, icon_path, sort);
|
||||
g_signal_emit_by_name(userlist, "player-added", ppi->id);
|
||||
gm_mcp_icecrew_userlist_process_triggers(userlist, name, TCT_USER_ONLINE);
|
||||
|
||||
g_free(sort);
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_mcp_icecrew_userlist_set(GmMcpIcecrewPlayerdb *playerdb,
|
||||
GmPlayerdbPlayerInfo *ppi, gchar const *key, gchar const *value,
|
||||
gchar const *old, GmMcpIcecrewUserlist *userlist) {
|
||||
gchar *sort = NULL;
|
||||
|
||||
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);
|
||||
if (strcmp(key, userlist->priv->property_names[P_STATE]) == 0) {
|
||||
g_signal_emit_by_name(userlist, "state-changed", ppi->id);
|
||||
|
||||
gm_mcp_icecrew_userlist_process_state_changed(userlist, ppi, value,
|
||||
old);
|
||||
} else if (strcmp(key, "P_RANK") == 0) {
|
||||
sort = gm_mcp_icecrew_userlist_sort_string(userlist, ppi);
|
||||
|
||||
g_signal_emit(userlist, gm_mcp_icecrew_userlist_signals[RANK_CHANGED],
|
||||
0, ppi->id, gm_mcp_icecrew_userlist_icon_path(userlist, ppi),
|
||||
sort);
|
||||
} 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);
|
||||
} else if (strcmp(key, userlist->priv->property_names[P_RANK]) == 0) {
|
||||
g_signal_emit_by_name(userlist, "rank-changed", ppi->id);
|
||||
} else if (strcmp(key, userlist->priv->property_names[P_NAME]) == 0) {
|
||||
g_signal_emit_by_name(userlist, "name-changed", ppi->id);
|
||||
} else if (strcmp(key, userlist->priv->property_names[P_STATE_MSG]) == 0) {
|
||||
g_signal_emit_by_name(userlist, "state-changed", ppi->id);
|
||||
}
|
||||
|
||||
g_free(sort);
|
||||
}
|
||||
|
||||
void
|
||||
on_gm_mcp_icecrew_userlist_delete(GmMcpIcecrewPlayerdb *playerdb,
|
||||
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],
|
||||
0, ppi->id);
|
||||
g_signal_emit_by_name(userlist, "player-removed", ppi->id);
|
||||
gm_mcp_icecrew_userlist_process_triggers(userlist, name, TCT_USER_OFFLINE);
|
||||
}
|
||||
|
|
|
@ -51,17 +51,6 @@ typedef struct _GmMcpIcecrewUserlistClass GmMcpIcecrewUserlistClass;
|
|||
|
||||
struct _GmMcpIcecrewUserlistClass {
|
||||
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;
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gm-mcp-package.h"
|
||||
#include "gm-mcp-userlist-view.h"
|
||||
#include "gm-iuserlist.h"
|
||||
#include "widgets/gm-world-view.h"
|
||||
#include "gm-pixbuf.h"
|
||||
#include "gm-app.h"
|
||||
#include "gm-debug.h"
|
||||
|
||||
#define GM_USERLIST_ICON_SIZE 22
|
||||
|
||||
enum {
|
||||
GM_USERLIST_ICON,
|
||||
GM_USERLIST_NAME,
|
||||
GM_USERLIST_CAPTION,
|
||||
GM_USERLIST_ID,
|
||||
GM_USERLIST_SORT,
|
||||
GM_USERLIST_RANK_PRIORITY,
|
||||
GM_USERLIST_STATE_PRIORITY,
|
||||
GM_USERLIST_N_COLUMNS
|
||||
};
|
||||
|
||||
|
@ -23,33 +26,68 @@ typedef struct _GmMcpUserlistView {
|
|||
GtkTreeModel *model;
|
||||
GtkListStore *store;
|
||||
GtkTreeView *tree_view;
|
||||
GtkWidget *label;
|
||||
GtkScrolledWindow *scrolled_window;
|
||||
GtkWidget *popup_menu;
|
||||
gboolean initializing;
|
||||
GmUserlistSortType sort_type;
|
||||
gboolean show_object;
|
||||
gboolean show_status;
|
||||
gboolean use_state_icon;
|
||||
|
||||
gint num_players;
|
||||
gint num_active;
|
||||
} GmMcpUserlistView;
|
||||
|
||||
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,
|
||||
gchar const *icon, gchar const *sort,
|
||||
GmMcpUserlistView *view);
|
||||
static void on_gm_mcp_userlist_view_player_removed(GmMcpPackage *package, gint id,
|
||||
GmMcpUserlistView *view);
|
||||
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,
|
||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view);
|
||||
GmMcpUserlistView *view);
|
||||
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,
|
||||
GmMcpUserlistView *view);
|
||||
static gboolean on_gm_mcp_userlist_view_button_press(GtkWidget *widget,
|
||||
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 *
|
||||
gm_mcp_userlist_view_model_create(GmMcpUserlistView *view) {
|
||||
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(
|
||||
store));
|
||||
|
||||
|
@ -62,7 +100,125 @@ gm_mcp_userlist_view_model_create(GmMcpUserlistView *view) {
|
|||
void
|
||||
on_gm_mcp_userlist_view_style_set(GtkWidget *widget, GtkStyle *prev,
|
||||
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 *
|
||||
|
@ -96,11 +252,13 @@ gm_mcp_userlist_view_create_userlist(GmMcpUserlistView *view) {
|
|||
|
||||
renderer = gtk_cell_renderer_text_new();
|
||||
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_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);
|
||||
|
||||
|
@ -123,6 +281,7 @@ gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent) {
|
|||
GmMcpUserlistView *view;
|
||||
GtkPaned *paned;
|
||||
GtkWidget *vbox, *child;
|
||||
GmOptions *options;
|
||||
|
||||
if (!GM_IS_WORLD_VIEW(parent)) {
|
||||
return;
|
||||
|
@ -131,18 +290,22 @@ gm_mcp_userlist_view_new(GmMcpPackage *package, GObject *parent) {
|
|||
view = g_new0(GmMcpUserlistView, 1);
|
||||
view->view = GM_WORLD_VIEW(parent);
|
||||
view->package = package;
|
||||
|
||||
|
||||
paned = GTK_PANED(gm_world_view_hpaned(view->view));
|
||||
vbox = gtk_paned_get_child2(paned);
|
||||
|
||||
if (vbox == NULL) {
|
||||
vbox = gtk_vbox_new(FALSE, 6);
|
||||
vbox = gtk_vbox_new(FALSE, 3);
|
||||
gtk_paned_pack2(paned, vbox, FALSE, TRUE);
|
||||
}
|
||||
|
||||
|
||||
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), gm_mcp_userlist_view_create_label(view),
|
||||
FALSE, FALSE, 0);
|
||||
|
||||
gtk_widget_show_all(vbox);
|
||||
|
||||
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_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,
|
||||
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 */
|
||||
static void
|
||||
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)) {
|
||||
gtk_widget_destroy(GTK_WIDGET(view->scrolled_window));
|
||||
gtk_widget_destroy(view->label);
|
||||
|
||||
vbox = gtk_paned_get_child2(GTK_PANED(gm_world_view_hpaned(
|
||||
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);
|
||||
}
|
||||
|
||||
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
|
||||
gm_mcp_userlist_view_find(GmMcpUserlistView *view, gint id, GtkTreeIter *iter) {
|
||||
GtkTreeModel *model = GTK_TREE_MODEL(view->store);
|
||||
|
@ -209,49 +562,12 @@ gm_mcp_userlist_view_find(GmMcpUserlistView *view, gint id, GtkTreeIter *iter) {
|
|||
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
|
||||
on_gm_mcp_userlist_view_player_added(GmMcpPackage *package, gint id,
|
||||
gchar const *icon, gchar const *sort,
|
||||
GmMcpUserlistView *view) {
|
||||
GtkTreeIter iter;
|
||||
gchar *name;
|
||||
GmIUserlist *userlist = GM_IUSERLIST(package);
|
||||
|
||||
if (gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||
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;
|
||||
}
|
||||
|
||||
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_set(view->store, &iter, GM_USERLIST_ID, id, GM_USERLIST_ICON,
|
||||
gm_pixbuf_get_at_size(icon, GM_USERLIST_ICON_SIZE,
|
||||
GM_USERLIST_ICON_SIZE), GM_USERLIST_NAME, name, GM_USERLIST_SORT,
|
||||
sort, -1);
|
||||
gtk_list_store_insert_with_values(view->store, &iter,
|
||||
gtk_tree_model_iter_n_children(GTK_TREE_MODEL(view->store), NULL),
|
||||
GM_USERLIST_ID, id,
|
||||
GM_USERLIST_ICON, gm_pixbuf_get_at_size(
|
||||
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);
|
||||
|
||||
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
|
||||
on_gm_mcp_userlist_view_player_removed(GmMcpPackage *package, gint id,
|
||||
GmMcpUserlistView *view) {
|
||||
GtkTreeIter iter;
|
||||
|
||||
|
||||
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||
gm_debug_msg(DEBUG_MCP, "GmMcpUserlistView.OnPlayerRemoved: player %d "
|
||||
"is not in the list, can't be removed!", id);
|
||||
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);
|
||||
}
|
||||
|
||||
static void
|
||||
on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
||||
gchar const *sort, GmMcpUserlistView *view) {
|
||||
GmMcpUserlistView *view) {
|
||||
GtkTreeIter iter;
|
||||
gchar *name;
|
||||
|
||||
|
@ -296,19 +636,19 @@ on_gm_mcp_userlist_view_name_changed(GmMcpPackage *package, gint id,
|
|||
return;
|
||||
}
|
||||
|
||||
name = gm_mcp_userlist_view_get_name(view, package, id);
|
||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_NAME, name, -1);
|
||||
g_free(name);
|
||||
name = gm_mcp_userlist_view_get_name(view, id);
|
||||
|
||||
if (sort) {
|
||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_SORT, sort, -1);
|
||||
if (name != NULL) {
|
||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_CAPTION, name, -1);
|
||||
g_free(name);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_gm_mcp_userlist_view_rank_changed(GmMcpPackage *package, gint id,
|
||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view) {
|
||||
GmMcpUserlistView *view) {
|
||||
GtkTreeIter iter;
|
||||
gchar const *icon;
|
||||
|
||||
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||
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;
|
||||
}
|
||||
|
||||
icon = gm_iuserlist_get_icon(GM_IUSERLIST(package),
|
||||
id, view->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);
|
||||
|
||||
if (sort) {
|
||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_SORT, sort, -1);
|
||||
}
|
||||
GM_USERLIST_ICON_SIZE),
|
||||
GM_USERLIST_RANK_PRIORITY, gm_iuserlist_get_rank_priority(
|
||||
GM_IUSERLIST(package), id),
|
||||
-1);
|
||||
}
|
||||
|
||||
static void
|
||||
on_gm_mcp_userlist_view_state_changed(GmMcpPackage *package, gint id,
|
||||
gchar const *icon, gchar const *sort, GmMcpUserlistView *view) {
|
||||
GmMcpUserlistView *view) {
|
||||
GtkTreeIter iter;
|
||||
gchar *name;
|
||||
gchar const *icon;
|
||||
gboolean active;
|
||||
|
||||
if (!gm_mcp_userlist_view_find(view, id, &iter)) {
|
||||
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;
|
||||
}
|
||||
|
||||
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,
|
||||
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);
|
||||
|
||||
if (sort) {
|
||||
gtk_list_store_set(view->store, &iter, GM_USERLIST_SORT, sort, -1);
|
||||
}
|
||||
|
||||
if (gm_mcp_userlist_view_player_active(view, &iter) != active) {
|
||||
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
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
#ifndef __GM_MCP_USERLIST_VIEW_H__
|
||||
#define __GM_MCP_USERLIST_VIEW_H__
|
||||
|
||||
|
||||
typedef enum _PlayerStateMask {
|
||||
USERLIST_STATE_IDLE = 1 << 0,
|
||||
USERLIST_STATE_BUSY = 1 << 1,
|
||||
|
@ -14,4 +18,15 @@ typedef enum _UserlistEvent {
|
|||
USERLIST_EVENT_AWAY_OFF = 1 << 5
|
||||
} 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);
|
||||
|
||||
|
||||
#endif /* __GM_MCP_USERLIST_VIEW_H__ */
|
||||
|
|
|
@ -49,19 +49,14 @@ struct _GmMcpVmooUserlistPrivate {
|
|||
gboolean initializing;
|
||||
};
|
||||
|
||||
/* Signals */
|
||||
/* Signals
|
||||
|
||||
enum {
|
||||
PLAYER_ADDED,
|
||||
PLAYER_REMOVED,
|
||||
NAME_CHANGED,
|
||||
STATE_CHANGED,
|
||||
RANK_CHANGED,
|
||||
NUM_SIGNALS
|
||||
};
|
||||
};*/
|
||||
|
||||
//static guint gm_mcp_vmoo_userlist_signals[NUM_SIGNALS] = {0};
|
||||
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, \
|
||||
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);
|
||||
|
||||
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_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
|
||||
gm_mcp_vmoo_userlist_iface_init(
|
||||
GmIUserlistInterface *iface) {
|
||||
iface->get_menu = gm_mcp_vmoo_userlist_get_menu;
|
||||
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
|
||||
|
@ -151,65 +156,6 @@ gm_mcp_vmoo_userlist_class_init(GmMcpVmooUserlistClass *klass) {
|
|||
|
||||
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->handle_simple = &gm_mcp_vmoo_userlist_handle_simple;
|
||||
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 *
|
||||
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;
|
||||
guint index = ui->icon;
|
||||
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)) {
|
||||
return NULL;
|
||||
} else {
|
||||
switch (ui->state) {
|
||||
case U_NORMAL:
|
||||
field = (gchar *)(g_list_nth_data(package->priv->icons,
|
||||
index - 1));
|
||||
if (!use_state || ui->state == U_NORMAL) {
|
||||
field = (gchar *)(g_list_nth_data(package->priv->icons,
|
||||
index - 1));
|
||||
|
||||
pair = icon_mapping;
|
||||
|
||||
while (!(pair->key == NULL && pair->value == NULL)) {
|
||||
if (strcasecmp(pair->key, field) == 0) {
|
||||
return pair->value;
|
||||
}
|
||||
|
||||
++pair;
|
||||
pair = icon_mapping;
|
||||
|
||||
while (!(pair->key == NULL && pair->value == NULL)) {
|
||||
if (strcasecmp(pair->key, field) == 0) {
|
||||
return pair->value;
|
||||
}
|
||||
|
||||
break;
|
||||
case U_IDLE:
|
||||
return "userlist/idle.svg";
|
||||
break;
|
||||
case U_AWAY:
|
||||
return "userlist/away.svg";
|
||||
break;
|
||||
case U_IDLEAWAY:
|
||||
return "userlist/idleaway.svg";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
++pair;
|
||||
}
|
||||
} else {
|
||||
switch (ui->state) {
|
||||
case U_IDLE:
|
||||
return "userlist/idle.svg";
|
||||
break;
|
||||
case U_AWAY:
|
||||
return "userlist/away.svg";
|
||||
break;
|
||||
case U_IDLEAWAY:
|
||||
return "userlist/idleaway.svg";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -525,12 +472,58 @@ gm_mcp_vmoo_userlist_get_menu(GmIUserlist *userlist, gint id) {
|
|||
|
||||
gchar const *
|
||||
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);
|
||||
|
||||
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
|
||||
gm_mcp_vmoo_userlist_remove_user(GmMcpVmooUserlist *package, gint nr) {
|
||||
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,
|
||||
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);
|
||||
g_signal_emit_by_name(package, "player-removed", nr);
|
||||
}
|
||||
|
||||
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");
|
||||
gchar *name = gm_mcp_vmoo_userlist_get_string(package, v, STRING, "name");
|
||||
gint icon = gm_mcp_vmoo_userlist_get_int(package, v, INT, "icon");
|
||||
gchar *sort;
|
||||
|
||||
UserInfo *ui;
|
||||
|
||||
|
@ -591,13 +560,9 @@ gm_mcp_vmoo_userlist_handle_user_update(GmMcpVmooUserlist *package, MOOVar *v) {
|
|||
ui->icon = icon;
|
||||
ui->nr = nr;
|
||||
|
||||
//
|
||||
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,
|
||||
nr, gm_mcp_vmoo_userlist_get_icon(package, ui), sort);
|
||||
g_free(sort);
|
||||
|
||||
|
||||
g_signal_emit_by_name(package, "player-added", nr);
|
||||
gm_mcp_vmoo_userlist_process_triggers(package, ui->name,
|
||||
TCT_USER_ONLINE);
|
||||
} else {
|
||||
|
@ -605,20 +570,14 @@ gm_mcp_vmoo_userlist_handle_user_update(GmMcpVmooUserlist *package, MOOVar *v) {
|
|||
g_free(ui->name);
|
||||
ui->name = name;
|
||||
|
||||
sort = gm_mcp_vmoo_userlist_sort_string(package, ui);
|
||||
g_signal_emit(package, gm_mcp_vmoo_userlist_signals[NAME_CHANGED],
|
||||
0, nr, sort);
|
||||
g_free(sort);
|
||||
g_signal_emit_by_name(package, "name-changed", nr);
|
||||
} else {
|
||||
g_free(name);
|
||||
}
|
||||
if (ui->icon != (guint)icon) {
|
||||
ui->icon = (guint)icon;
|
||||
|
||||
sort = gm_mcp_vmoo_userlist_sort_string(package, ui);
|
||||
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);
|
||||
g_signal_emit_by_name(package, "rank-changed", nr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -683,7 +642,6 @@ gm_mcp_vmoo_userlist_handle_state(GmMcpVmooUserlist *package, MOOVar *v,
|
|||
UserState state, gboolean onOff) {
|
||||
MOOVar *nr;
|
||||
UserInfo *u;
|
||||
gchar *sort;
|
||||
GmTriggerConditionType condition = 0;
|
||||
|
||||
if (v->type != LIST) {
|
||||
|
@ -732,18 +690,12 @@ gm_mcp_vmoo_userlist_handle_state(GmMcpVmooUserlist *package, MOOVar *v,
|
|||
break;
|
||||
}
|
||||
|
||||
sort = gm_mcp_vmoo_userlist_sort_string(package, u);
|
||||
|
||||
g_signal_emit(package,
|
||||
gm_mcp_vmoo_userlist_signals[STATE_CHANGED], 0,
|
||||
nr->i, gm_mcp_vmoo_userlist_get_icon(package, u), sort);
|
||||
g_signal_emit_by_name(package, "state-changed", u->nr);
|
||||
|
||||
if (condition != 0) {
|
||||
gm_mcp_vmoo_userlist_process_triggers(package, u->name,
|
||||
condition);
|
||||
}
|
||||
|
||||
g_free(sort);
|
||||
} else {
|
||||
gm_debug_msg(DEBUG_MCP, "User %d does not exist!", nr->i);
|
||||
}
|
||||
|
|
|
@ -46,17 +46,6 @@ typedef struct _GmMcpVmooUserlistClass GmMcpVmooUserlistClass;
|
|||
|
||||
struct _GmMcpVmooUserlistClass {
|
||||
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;
|
||||
|
|
|
@ -12,9 +12,9 @@ gm_mcp_get_version(gdouble client_min, gdouble client_max, gdouble server_min,
|
|||
gdouble server_max) {
|
||||
if (client_max >= server_min && server_max >= client_min) {
|
||||
if (client_max < server_max) {
|
||||
return server_max;
|
||||
} else {
|
||||
return client_max;
|
||||
} else {
|
||||
return server_max;
|
||||
}
|
||||
} else {
|
||||
return 0.0;
|
||||
|
|
Reference in New Issue