From cadff706e7f5896ed9d65bd638beab1536a6e982 Mon Sep 17 00:00:00 2001 From: Arnavion Date: Sat, 11 Jun 2016 15:46:32 -0700 Subject: [PATCH] Use unsigned int consistently for ignore type, and use IG_* constants instead of numeric literals. --- src/common/ignore.c | 4 ++-- src/common/ignore.h | 4 ++-- src/fe-gtk/ignoregui.c | 38 +++++++++++++++++++++++++++----------- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/common/ignore.c b/src/common/ignore.c index 6085b657..639b9947 100644 --- a/src/common/ignore.c +++ b/src/common/ignore.c @@ -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; diff --git a/src/common/ignore.h b/src/common/ignore.h index 674e6285..5aefafe5 100644 --- a/src/common/ignore.h +++ b/src/common/ignore.h @@ -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); diff --git a/src/fe-gtk/ignoregui.c b/src/fe-gtk/ignoregui.c index 07840e8b..f0ae8b28 100644 --- a/src/fe-gtk/ignoregui.c +++ b/src/fe-gtk/ignoregui.c @@ -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, ¬i, - 4, &ctcp, 5, &dcc, 6, &invi, 7, &unig, -1); + gtk_tree_model_get ( + model, iter, + CHAN_COLUMN, &chan, + PRIV_COLUMN, &priv, + NOTICE_COLUMN, ¬i, + 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);