Some problems in banlist.c are fixed

This commit is contained in:
RichardHitt 2014-06-17 17:16:45 -07:00 committed by TingPing
parent 81ff1b0029
commit d78e995e06
2 changed files with 7 additions and 8 deletions

View File

@ -239,6 +239,9 @@ banlist_sensitize (banlist_info *banl)
int checkable, i; int checkable, i;
gboolean is_op = FALSE; gboolean is_op = FALSE;
if (banl->sess->me == NULL)
return;
/* FIXME: More access levels than these can unban */ /* FIXME: More access levels than these can unban */
if (banl->sess->me->op || banl->sess->me->hop) if (banl->sess->me->op || banl->sess->me->hop)
is_op = TRUE; is_op = TRUE;
@ -283,7 +286,7 @@ banlist_sensitize (banlist_info *banl)
else else
{ {
gtk_widget_set_sensitive (banl->but_clear, FALSE); gtk_widget_set_sensitive (banl->but_clear, FALSE);
gtk_widget_set_sensitive (banl->but_crop, TRUE); gtk_widget_set_sensitive (banl->but_crop, banl->line_ct == banl->select_ct? FALSE: TRUE);
gtk_widget_set_sensitive (banl->but_remove, TRUE); gtk_widget_set_sensitive (banl->but_remove, TRUE);
} }
} }
@ -410,7 +413,7 @@ banlist_select_changed (GtkWidget *item, banlist_info *banl)
else else
{ {
list = gtk_tree_selection_get_selected_rows (GTK_TREE_SELECTION (item), NULL); list = gtk_tree_selection_get_selected_rows (GTK_TREE_SELECTION (item), NULL);
banl->select_ct = list? 1: 0; banl->select_ct = g_list_length (list);
g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL); g_list_foreach (list, (GFunc) gtk_tree_path_free, NULL);
g_list_free (list); g_list_free (list);
} }
@ -426,7 +429,6 @@ banlist_do_refresh (banlist_info *banl)
session *sess = banl->sess; session *sess = banl->sess;
char tbuf[256]; char tbuf[256];
int i; int i;
char *tbufp;
banlist_sensitize (banl); banlist_sensitize (banl);
@ -444,16 +446,14 @@ banlist_do_refresh (banlist_info *banl)
banl->pending = banl->checked; banl->pending = banl->checked;
if (banl->pending) if (banl->pending)
{ {
tbufp = tbuf + g_snprintf (tbuf, sizeof tbuf, "quote mode %s +", sess->channel);
for (i = 0; i < MODE_CT; i++) for (i = 0; i < MODE_CT; i++)
if (banl->pending & 1<<i) if (banl->pending & 1<<i)
{ {
*tbufp++ = modes[i].letter; g_snprintf (tbuf, sizeof tbuf, "quote mode %s +%c", sess->channel, modes[i].letter);
}
*tbufp = 0;
handle_command (sess, tbuf, FALSE); handle_command (sess, tbuf, FALSE);
} }
} }
}
else else
{ {
fe_message (_("Not connected."), FE_MSG_ERROR); fe_message (_("Not connected."), FE_MSG_ERROR);

View File

@ -53,7 +53,6 @@ typedef struct banlist_info_s {
int current; /* index of currently processing mode */ int current; /* index of currently processing mode */
int line_ct; /* count of presented lines */ int line_ct; /* count of presented lines */
int select_ct; /* count of selected lines */ int select_ct; /* count of selected lines */
/* Not really; 1 if any are selected otherwise 0 */
GtkWidget *window; GtkWidget *window;
GtkWidget *treeview; GtkWidget *treeview;
GtkWidget *checkboxes[MODE_CT]; GtkWidget *checkboxes[MODE_CT];