Use unsigned int consistently for ignore type, and use IG_* constants instead of numeric literals.

This commit is contained in:
Arnavion 2016-06-11 15:46:32 -07:00
parent a031a24cfd
commit cadff706e7
3 changed files with 31 additions and 15 deletions

View File

@ -77,7 +77,7 @@ ignore_exists (char *mask)
*/
int
ignore_add (char *mask, int type, gboolean overwrite)
ignore_add (char *mask, unsigned int type, gboolean overwrite)
{
struct ignore *ig = NULL;
int change_only = FALSE;
@ -200,7 +200,7 @@ ignore_del (char *mask, struct ignore *ig)
/* check if a msg should be ignored by browsing our ignore list */
int
ignore_check (char *host, int type)
ignore_check (char *host, unsigned int type)
{
struct ignore *ig;
GSList *list = ignore_list;

View File

@ -44,10 +44,10 @@ struct ignore
};
struct ignore *ignore_exists (char *mask);
int ignore_add (char *mask, int type, gboolean overwrite);
int ignore_add (char *mask, unsigned int type, gboolean overwrite);
void ignore_showlist (session *sess);
int ignore_del (char *mask, struct ignore *ig);
int ignore_check (char *mask, int type);
int ignore_check (char *mask, unsigned int type);
void ignore_load (void);
void ignore_save (void);
void ignore_gui_open (void);

View File

@ -58,14 +58,22 @@ get_store (void)
return gtk_tree_view_get_model (g_object_get_data (G_OBJECT (ignorewin), "view"));
}
static int
static unsigned int
ignore_get_flags (GtkTreeModel *model, GtkTreeIter *iter)
{
gboolean chan, priv, noti, ctcp, dcc, invi, unig;
int flags = 0;
unsigned int flags = 0;
gtk_tree_model_get (model, iter, 1, &chan, 2, &priv, 3, &noti,
4, &ctcp, 5, &dcc, 6, &invi, 7, &unig, -1);
gtk_tree_model_get (
model, iter,
CHAN_COLUMN, &chan,
PRIV_COLUMN, &priv,
NOTICE_COLUMN, &noti,
CTCP_COLUMN, &ctcp,
DCC_COLUMN, &dcc,
INVITE_COLUMN, &invi,
UNIGNORE_COLUMN, &unig,
-1);
if (chan)
flags |= IG_CHAN;
if (priv)
@ -89,11 +97,11 @@ mask_edited (GtkCellRendererText *render, gchar *path, gchar *new, gpointer dat)
GtkListStore *store = GTK_LIST_STORE (get_store ());
GtkTreeIter iter;
char *old;
int flags;
unsigned int flags;
gtkutil_treemodel_string_to_iter (GTK_TREE_MODEL (store), path, &iter);
gtk_tree_model_get (GTK_TREE_MODEL (store), &iter, 0, &old, -1);
if (!strcmp (old, new)) /* no change */
;
else if (ignore_exists (new)) /* duplicate, ignore */
@ -109,7 +117,6 @@ mask_edited (GtkCellRendererText *render, gchar *path, gchar *new, gpointer dat)
gtk_list_store_set (store, &iter, MASK_COLUMN, new, -1);
}
g_free (old);
}
static void
@ -120,7 +127,7 @@ option_toggled (GtkCellRendererToggle *render, gchar *path, gpointer data)
int col_id = GPOINTER_TO_INT (data);
gboolean active;
char *mask;
int flags;
unsigned int flags;
gtkutil_treemodel_string_to_iter (GTK_TREE_MODEL (store), path, &iter);
@ -233,7 +240,7 @@ ignore_store_new (int cancel, char *mask, gpointer data)
GtkListStore *store = GTK_LIST_STORE (get_store ());
GtkTreeIter iter;
GtkTreePath *path;
int flags = IG_CHAN | IG_PRIV | IG_NOTI | IG_CTCP | IG_DCC | IG_INVI;
unsigned int flags = IG_CHAN | IG_PRIV | IG_NOTI | IG_CTCP | IG_DCC | IG_INVI;
if (cancel)
return;
@ -248,8 +255,17 @@ ignore_store_new (int cancel, char *mask, gpointer data)
gtk_list_store_append (store, &iter);
/* ignore everything by default */
gtk_list_store_set (store, &iter, 0, mask, 1, TRUE, 2, TRUE, 3, TRUE,
4, TRUE, 5, TRUE, 6, TRUE, 7, FALSE, -1);
gtk_list_store_set (
store, &iter,
MASK_COLUMN, mask,
CHAN_COLUMN, TRUE,
PRIV_COLUMN, TRUE,
NOTICE_COLUMN, TRUE,
CTCP_COLUMN, TRUE,
DCC_COLUMN, TRUE,
INVITE_COLUMN, TRUE,
UNIGNORE_COLUMN, FALSE,
-1);
/* make sure the new row is visible and selected */
path = gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter);
gtk_tree_view_scroll_to_cell (view, path, NULL, TRUE, 1.0, 0.0);