Example #1
0
static void
mask_edited (GtkCellRendererText *render, gchar *path, gchar *newStr, gpointer dat)
{
	GtkListStore *store = GTK_LIST_STORE (get_store ());
	GtkTreeIter iter;
	char *old;
	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, newStr))	/* no change */
		;
	else if (ignore_exists (newStr))	/* duplicate, ignore */
		fe_message (_("That mask already exists."), FE_MSG_ERROR);
	else
	{
		/* delete old mask, and add new one with original flags */
		ignore_del (old);
		flags = ignore_get_flags (GTK_TREE_MODEL (store), &iter);
		ignore_add (newStr, flags, TRUE);

		/* update tree */
		gtk_list_store_set (store, &iter, MASK_COLUMN, newStr, -1);
	}
	g_free (old);
	
}
Example #2
0
int
ignore_add (char *mask, int type, gboolean overwrite)
{
	struct ignore *ig = NULL;
	int change_only = FALSE;

	/* first check if it's already ignored */
	ig = ignore_exists (mask);
	if (ig)
		change_only = TRUE;

	if (!change_only)
		ig = g_new (struct ignore, 1);

	ig->mask = g_strdup (mask);

	if (!overwrite && change_only)
		ig->type |= type;
	else
		ig->type = type;

	if (!change_only)
		ignore_list = g_slist_prepend (ignore_list, ig);
	fe_ignore_update (1);

	if (change_only)
		return 2;

	return 1;
}
Example #3
0
static void
ignore_store_new (int cancel, char *mask, gpointer data)
{
	if (cancel)
		return;
	/* check if it already exists */
	if (ignore_exists (mask))
	{
		fe_message (_("That mask already exists."), FE_MSG_ERROR);
		return;
	}

	GtkTreeView *view = static_cast<GtkTreeView *>(g_object_get_data(G_OBJECT(ignorewin), "view"));
	GtkListStore *store = GTK_LIST_STORE(get_store());
	GtkTreeIter iter;
	ignore::ignore_type flags = ignore::IG_DEFAULTS;

	ignore_add (mask, flags, TRUE);

	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);
	/* make sure the new row is visible and selected */
	GtkTreePathPtr path (gtk_tree_model_get_path (GTK_TREE_MODEL (store), &iter));
	gtk_tree_view_scroll_to_cell (view, path.get(), NULL, TRUE, 1.0, 0.0);
	gtk_tree_view_set_cursor (view, path.get(), NULL, FALSE);
}