Add type column to banlist
This commit is contained in:
parent
7863bc71f8
commit
8b7ddbee59
|
@ -57,7 +57,7 @@ static void supports_quiet (banlist_info *, int);
|
||||||
static mode_info modes[MODE_CT] = {
|
static mode_info modes[MODE_CT] = {
|
||||||
{
|
{
|
||||||
N_("Bans"),
|
N_("Bans"),
|
||||||
"(b) ",
|
N_("Ban"),
|
||||||
'b',
|
'b',
|
||||||
RPL_BANLIST,
|
RPL_BANLIST,
|
||||||
RPL_ENDOFBANLIST,
|
RPL_ENDOFBANLIST,
|
||||||
|
@ -66,7 +66,7 @@ static mode_info modes[MODE_CT] = {
|
||||||
}
|
}
|
||||||
,{
|
,{
|
||||||
N_("Exempts"),
|
N_("Exempts"),
|
||||||
"(e) ",
|
N_("Exempt"),
|
||||||
'e',
|
'e',
|
||||||
RPL_EXCEPTLIST,
|
RPL_EXCEPTLIST,
|
||||||
RPL_ENDOFEXCEPTLIST,
|
RPL_ENDOFEXCEPTLIST,
|
||||||
|
@ -75,7 +75,7 @@ static mode_info modes[MODE_CT] = {
|
||||||
}
|
}
|
||||||
,{
|
,{
|
||||||
N_("Invites"),
|
N_("Invites"),
|
||||||
"(I) ",
|
N_("Invite"),
|
||||||
'I',
|
'I',
|
||||||
RPL_INVITELIST,
|
RPL_INVITELIST,
|
||||||
RPL_ENDOFINVITELIST,
|
RPL_ENDOFINVITELIST,
|
||||||
|
@ -84,7 +84,7 @@ static mode_info modes[MODE_CT] = {
|
||||||
}
|
}
|
||||||
,{
|
,{
|
||||||
N_("Quiets"),
|
N_("Quiets"),
|
||||||
"(q) ",
|
N_("Quiet"),
|
||||||
'q',
|
'q',
|
||||||
RPL_QUIETLIST,
|
RPL_QUIETLIST,
|
||||||
RPL_ENDOFQUIETLIST,
|
RPL_ENDOFQUIETLIST,
|
||||||
|
@ -96,6 +96,7 @@ static mode_info modes[MODE_CT] = {
|
||||||
/* model for the banlist tree */
|
/* model for the banlist tree */
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
TYPE_COLUMN,
|
||||||
MASK_COLUMN,
|
MASK_COLUMN,
|
||||||
FROM_COLUMN,
|
FROM_COLUMN,
|
||||||
DATE_COLUMN,
|
DATE_COLUMN,
|
||||||
|
@ -215,7 +216,6 @@ fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rp
|
||||||
int i;
|
int i;
|
||||||
GtkListStore *store;
|
GtkListStore *store;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
char buf[512];
|
|
||||||
|
|
||||||
if (!banl)
|
if (!banl)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -233,8 +233,8 @@ fe_add_ban_list (struct session *sess, char *mask, char *who, char *when, int rp
|
||||||
store = get_store (sess);
|
store = get_store (sess);
|
||||||
gtk_list_store_append (store, &iter);
|
gtk_list_store_append (store, &iter);
|
||||||
|
|
||||||
g_snprintf (buf, sizeof buf, "%s%s", modes[i].tag, mask);
|
gtk_list_store_set (store, &iter, TYPE_COLUMN, modes[i].type, MASK_COLUMN, mask,
|
||||||
gtk_list_store_set (store, &iter, 0, buf, 1, who, 2, when, -1);
|
FROM_COLUMN, who, DATE_COLUMN, when, -1);
|
||||||
|
|
||||||
banl->line_ct++;
|
banl->line_ct++;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -407,8 +407,8 @@ banlist_unban_inner (gpointer none, banlist_info *banl, int mode_num)
|
||||||
GtkTreeSelection *sel;
|
GtkTreeSelection *sel;
|
||||||
GtkTreeIter iter;
|
GtkTreeIter iter;
|
||||||
char tbuf[2048];
|
char tbuf[2048];
|
||||||
char **masks, *mask;
|
char **masks, *mask, *type;
|
||||||
int num_sel, taglen, i;
|
int num_sel, i;
|
||||||
|
|
||||||
|
|
||||||
/* grab the list of selected items */
|
/* grab the list of selected items */
|
||||||
|
@ -418,7 +418,6 @@ banlist_unban_inner (gpointer none, banlist_info *banl, int mode_num)
|
||||||
if (!gtk_tree_model_get_iter_first (model, &iter))
|
if (!gtk_tree_model_get_iter_first (model, &iter))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
taglen = strlen (modes[mode_num].tag);
|
|
||||||
masks = g_malloc (sizeof (char *) * banl->line_ct);
|
masks = g_malloc (sizeof (char *) * banl->line_ct);
|
||||||
num_sel = 0;
|
num_sel = 0;
|
||||||
do
|
do
|
||||||
|
@ -426,15 +425,16 @@ banlist_unban_inner (gpointer none, banlist_info *banl, int mode_num)
|
||||||
if (gtk_tree_selection_iter_is_selected (sel, &iter))
|
if (gtk_tree_selection_iter_is_selected (sel, &iter))
|
||||||
{
|
{
|
||||||
/* Get the mask part of this selected line */
|
/* Get the mask part of this selected line */
|
||||||
gtk_tree_model_get (model, &iter, MASK_COLUMN, &mask, -1);
|
gtk_tree_model_get (model, &iter, TYPE_COLUMN, &type, MASK_COLUMN, &mask, -1);
|
||||||
|
|
||||||
/* If it's the wrong type of mask, just continue */
|
/* If it's the wrong type of mask, just continue */
|
||||||
if (strncmp (modes[mode_num].tag, mask, taglen) != 0)
|
if (strcmp (modes[mode_num].type, type) != 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
/* Otherwise add it to our array of mask pointers */
|
/* Otherwise add it to our array of mask pointers */
|
||||||
masks[num_sel++] = g_strdup (mask + taglen);
|
masks[num_sel++] = g_strdup (mask);
|
||||||
g_free (mask);
|
g_free (mask);
|
||||||
|
g_free (type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (gtk_tree_model_iter_next (model, &iter));
|
while (gtk_tree_model_iter_next (model, &iter));
|
||||||
|
@ -643,13 +643,14 @@ banlist_treeview_new (GtkWidget *box, banlist_info *banl)
|
||||||
GtkTreeSortable *sortable;
|
GtkTreeSortable *sortable;
|
||||||
|
|
||||||
store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
|
store = gtk_list_store_new (N_COLUMNS, G_TYPE_STRING, G_TYPE_STRING,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING, G_TYPE_STRING);
|
||||||
g_return_val_if_fail (store != NULL, NULL);
|
g_return_val_if_fail (store != NULL, NULL);
|
||||||
|
|
||||||
sortable = GTK_TREE_SORTABLE (store);
|
sortable = GTK_TREE_SORTABLE (store);
|
||||||
gtk_tree_sortable_set_sort_func (sortable, 2, banlist_date_sort, GINT_TO_POINTER (2), NULL);
|
gtk_tree_sortable_set_sort_func (sortable, 2, banlist_date_sort, GINT_TO_POINTER (2), NULL);
|
||||||
|
|
||||||
view = gtkutil_treeview_new (box, GTK_TREE_MODEL (store), NULL,
|
view = gtkutil_treeview_new (box, GTK_TREE_MODEL (store), NULL,
|
||||||
|
TYPE_COLUMN, _("Type"),
|
||||||
MASK_COLUMN, _("Mask"),
|
MASK_COLUMN, _("Mask"),
|
||||||
FROM_COLUMN, _("From"),
|
FROM_COLUMN, _("From"),
|
||||||
DATE_COLUMN, _("Date"), -1);
|
DATE_COLUMN, _("Date"), -1);
|
||||||
|
@ -661,6 +662,10 @@ banlist_treeview_new (GtkWidget *box, banlist_info *banl)
|
||||||
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
gtk_tree_view_column_set_sizing (col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
|
||||||
gtk_tree_view_column_set_resizable (col, TRUE);
|
gtk_tree_view_column_set_resizable (col, TRUE);
|
||||||
|
|
||||||
|
col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), TYPE_COLUMN);
|
||||||
|
gtk_tree_view_column_set_alignment (col, 0.5);
|
||||||
|
gtk_tree_view_column_set_sort_column_id (col, TYPE_COLUMN);
|
||||||
|
|
||||||
col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), FROM_COLUMN);
|
col = gtk_tree_view_get_column (GTK_TREE_VIEW (view), FROM_COLUMN);
|
||||||
gtk_tree_view_column_set_alignment (col, 0.5);
|
gtk_tree_view_column_set_alignment (col, 0.5);
|
||||||
gtk_tree_view_column_set_sort_column_id (col, FROM_COLUMN);
|
gtk_tree_view_column_set_sort_column_id (col, FROM_COLUMN);
|
||||||
|
|
|
@ -28,7 +28,7 @@ typedef struct banlist_info_s banlist_info;
|
||||||
|
|
||||||
typedef struct mode_info_s {
|
typedef struct mode_info_s {
|
||||||
char *name; /* Checkbox name, e.g. "Bans" */
|
char *name; /* Checkbox name, e.g. "Bans" */
|
||||||
char *tag; /* Prefix line with this, e.g. "(EX) " for MODE_EXEMPT */
|
char *type; /* Type for type column, e.g. "Ban" */
|
||||||
char letter; /* /mode-command letter, e.g. 'b' for MODE_BAN */
|
char letter; /* /mode-command letter, e.g. 'b' for MODE_BAN */
|
||||||
int code; /* rfc RPL_foo code, e.g. 367 for RPL_BANLIST */
|
int code; /* rfc RPL_foo code, e.g. 367 for RPL_BANLIST */
|
||||||
int endcode; /* rfc RPL_ENDOFfoo code, e.g. 368 for RPL_ENDOFBANLIST */
|
int endcode; /* rfc RPL_ENDOFfoo code, e.g. 368 for RPL_ENDOFBANLIST */
|
||||||
|
|
Loading…
Reference in New Issue