static void prefs_display_header_delete_cb(GtkButton *btn, gpointer clist_data)
{
    GtkCList *clist = GTK_CLIST(clist_data);
    DisplayHeaderProp *dp;
    gint row;

    if (!clist->selection) return;
    row = GPOINTER_TO_INT(clist->selection->data);

    dp = gtk_clist_get_row_data(clist, row);
    display_header_prop_free(dp);
    gtk_clist_remove(clist, row);
    prefs_common.disphdr_list =
        g_slist_remove(prefs_common.disphdr_list, dp);
}
Пример #2
0
static void prefs_display_header_delete_cb(GtkButton *btn, gpointer list_view_data)
{
	GtkTreeView *list_view = GTK_TREE_VIEW(list_view_data);
	DisplayHeaderProp *dp;
	GtkListStore *store = GTK_LIST_STORE(gtk_tree_view_get_model(list_view));
	GtkTreeSelection *selection = gtk_tree_view_get_selection(list_view);
	GtkTreeIter iter;

	if (!gtk_tree_selection_get_selected(selection, NULL, &iter))
		return;

	gtk_tree_model_get(GTK_TREE_MODEL(store), &iter, PREFS_HDR_DATA, &dp, -1);
	if (!dp) 
		return;

	prefs_common.disphdr_list =
		g_slist_remove(prefs_common.disphdr_list, dp);
	display_header_prop_free(dp);
	gtk_list_store_remove(store, &iter);
}
Пример #3
0
void prefs_display_header_read_config(void)
{
	gchar *rcpath;
	FILE *fp;
	gchar buf[PREFSBUFSIZE];
	DisplayHeaderProp *dp;

	debug_print("Reading configuration for displaying headers...\n");

	rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S,
			     DISPLAY_HEADER_RC, NULL);
	if ((fp = claws_fopen(rcpath, "rb")) == NULL) {
		if (ENOENT != errno) FILE_OP_ERROR(rcpath, "claws_fopen");
		g_free(rcpath);
		prefs_common.disphdr_list = NULL;
		prefs_display_header_set_default();
		return;
	}
	g_free(rcpath);

	/* remove all previous headers list */
	while (prefs_common.disphdr_list != NULL) {
		dp = (DisplayHeaderProp *)prefs_common.disphdr_list->data;
		display_header_prop_free(dp);
		prefs_common.disphdr_list =
			g_slist_remove(prefs_common.disphdr_list, dp);
	}

	while (claws_fgets(buf, sizeof(buf), fp) != NULL) {
		g_strdelimit(buf, "\r\n", '\0');
		dp = display_header_prop_read_str(buf);
		if (dp)
			prefs_common.disphdr_list =
				g_slist_append(prefs_common.disphdr_list, dp);
	}

	claws_fclose(fp);
}