Exemplo n.º 1
0
void rssyl_new_folder_cb(GtkAction *action,
		gpointer data)
{
	FolderView *folderview = (FolderView*)data;
	FolderItem *item;
	FolderItem *new_item;
	gchar *new_folder, *p, *tmp;
	gint i = 1;

	if (!folderview->selected) return;

	item = folderview_get_selected_item(folderview);
	g_return_if_fail(item != NULL);
	g_return_if_fail(item->folder != NULL);

	new_folder = input_dialog(_("New folder"),
				  _("Input the name of new folder:"),
				  _("NewFolder"));
	if (!new_folder) return;

	p = strchr(new_folder, G_DIR_SEPARATOR);
	if (p) {
		alertpanel_error(_("'%c' can't be used in folder name."),
				 G_DIR_SEPARATOR);
		g_free(new_folder);
		return;
	}

	if (!folder_local_name_ok(new_folder)) {
		g_free(new_folder);
		return;
	}

	/* Find an unused name for new folder */
	/* TODO: Perhaps stop after X attempts? */
	tmp = g_strdup(new_folder);
	while (folder_find_child_item_by_name(item, tmp)) {
		debug_print("RSSyl: Folder '%s' already exists, trying another name\n",
				new_folder);
		g_free(tmp);
		tmp = g_strdup_printf("%s__%d", new_folder, ++i);
	}

	g_free(new_folder);
	new_folder = tmp;

	new_item = folder_create_folder(item, new_folder);
	if (!new_item) {
		alertpanel_error(_("Can't create the folder '%s'."), new_folder);
		g_free(new_folder);
		return;
	}

	g_free(new_folder);

	folder_write_list();
}
Exemplo n.º 2
0
static void prefs_custom_header_list_view_set_row(PrefsAccount *ac)
{
	CustomHeader *ch;
	const gchar *entry_text;
	gchar *ch_str;

	entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.hdr_entry));
	if (entry_text[0] == '\0') {
		alertpanel_error(_("Header name is not set."));
		return;
	}
	
	while (*entry_text && 
	       (*entry_text == '\n' || *entry_text == '\r' || 
	        *entry_text == '\t' || *entry_text == ' '))
		entry_text++;
	
	if (!custom_header_is_allowed(entry_text)) {
		alertpanel_error(_("This Header name is not allowed as a custom header."));
		return;
	}

	ch = g_new0(CustomHeader, 1);

	ch->account_id = ac->account_id;

	ch->name = g_strdup(entry_text);
	unfold_line(ch->name);
	g_strstrip(ch->name);
	gtk_entry_set_text(GTK_ENTRY(customhdr.hdr_entry), ch->name);

	entry_text = gtk_entry_get_text(GTK_ENTRY(customhdr.val_entry));
	while (*entry_text && 
	       (*entry_text == '\n' || *entry_text == '\r' || 
	        *entry_text == '\t' || *entry_text == ' '))
		entry_text++;
	
	if (entry_text[0] != '\0') {
		ch->value = g_strdup(entry_text);
		unfold_line(ch->value);
		g_strstrip(ch->value);
		gtk_entry_set_text(GTK_ENTRY(customhdr.val_entry), ch->value);
	}

	ch_str = g_strdup_printf("%s: %s", ch->name,
				 ch->value ? ch->value : "");
	
	prefs_custom_header_list_view_insert_header
		(customhdr.list_view, NULL, ch_str, ch);
	
	g_free(ch_str);

	prefs_custom_header_set_list(cur_ac);

}
Exemplo n.º 3
0
static void apply_window_add_tag(void)
{
	gchar *new_tag = gtk_editable_get_chars(GTK_EDITABLE(applywindow.add_entry), 0, -1);
	g_strstrip(new_tag);
	if (new_tag && *new_tag) {
		gint id;
		FindTagInStore fis;
		if (!(IS_NOT_RESERVED_TAG(new_tag))) {
			alertpanel_error(_("You entered a reserved tag name, please choose another instead."));
			g_free(new_tag);
			return;
		}
		id = tags_get_id_for_str(new_tag);
		APPLYWINDOW_LOCK();
		if (id == -1) {
			id = tags_add_tag(new_tag);
			tags_write_tags();
			if (mainwindow_get_mainwindow())
				summary_set_tag(
					mainwindow_get_mainwindow()->summaryview, 
					id, NULL);
			main_window_reflect_tags_changes(mainwindow_get_mainwindow());
			apply_window_list_view_insert_tag(applywindow.taglist, NULL, id);
		} 
		fis.tag_id = id;
		fis.path = NULL;
		gtk_tree_model_foreach(gtk_tree_view_get_model
				(GTK_TREE_VIEW(applywindow.taglist)), 
				(GtkTreeModelForeachFunc) find_tag_in_store,
			       	&fis);
		if (fis.path) {
			GtkTreeSelection *selection;
			GtkTreePath* path;
			GtkTreeModel *model = gtk_tree_view_get_model(
				GTK_TREE_VIEW(applywindow.taglist));

			if (mainwindow_get_mainwindow())
				summary_set_tag(
					mainwindow_get_mainwindow()->summaryview, 
					id, NULL);
			selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(applywindow.taglist));
			gtk_tree_selection_select_iter(selection, &fis.iter);
			path = gtk_tree_model_get_path(model, &fis.iter);
			/* XXX returned path may not be valid??? create new one to be sure */ 
			gtk_tree_view_set_cursor(GTK_TREE_VIEW(applywindow.taglist), path, NULL, FALSE);
			apply_window_list_view_insert_tag(applywindow.taglist, &fis.iter, id);
			gtk_tree_path_free(path);
		}
		APPLYWINDOW_UNLOCK();
	} else {
		alertpanel_error(_("Tag is not set."));
	}
	g_free(new_tag);
}
Exemplo n.º 4
0
static void prefs_themes_btn_remove_clicked_cb(GtkWidget *widget, gpointer data)
{
	ThemesData *tdata = prefs_themes_data;
	gchar      *theme_str;
	gchar      *alert_title = NULL;
	AlertValue  val = 0;
	gchar      *tmp = NULL;

	theme_str = tdata->displayed;

	tmp = g_path_get_basename(theme_str);

	if (IS_SYSTEM_THEME(theme_str)) {
		if (!superuser_p()) {
			alertpanel_error(_("Only root can remove system themes"));
			return;
		}
		alert_title = g_strdup_printf(_("Remove system theme '%s'"), tmp);
	}
	if (NULL == alert_title) {
		alert_title = g_strdup_printf(_("Remove theme '%s'"), tmp);
	}

	g_free(tmp);

	val = alertpanel(alert_title,
			 _("Are you sure you want to remove this theme?"),
			 GTK_STOCK_NO, GTK_STOCK_YES, NULL);
	g_free(alert_title);

	if (G_ALERTALTERNATE == val) {
		gchar *status = NULL;

		prefs_themes_foreach_file(theme_str, prefs_themes_file_remove, &status); 
		if (0 != rmdir(theme_str)) {
			if (status != NULL) {
				alertpanel_error(_("File %s failed\nwhile removing theme."), status);
				g_free(status);
			}
			else
				alertpanel_error(_("Removing theme directory failed."));
		}
		else {	
			alertpanel_notice(_("Theme removed successfully"));
			/* update interface back to first theme */
			prefs_themes_get_themes_and_names(tdata);
			prefs_themes_set_themes_menu(GTK_COMBO_BOX(tdata->page->op_menu), tdata);
			prefs_themes_display_global_stats(tdata);
			tdata->displayed = (gchar *)((g_list_first(tdata->themes))->data);
			prefs_themes_get_theme_info(tdata);
		}
	}
}
Exemplo n.º 5
0
static void import_ok_cb(GtkWidget *widget, gpointer data)
{
	const gchar *utf8mbox, *destdir;
	FolderItem *dest;
	gchar *mbox;

	utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
	destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));

	if (utf8mbox && !*utf8mbox) {
		alertpanel_error(_("Source mbox filename can't be left empty."));
		gtk_widget_grab_focus(file_entry);
		return;
	}
	if (destdir && !*destdir) {
		if (alertpanel(_("Import mbox file"), _("Destination folder is not set.\nImport mbox file to the Inbox folder?"),
						GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL, ALERTFOCUS_FIRST)
			== G_ALERTALTERNATE) {
			gtk_widget_grab_focus(dest_entry);
			return;
		}
	}

	mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
	if (!mbox) {
		g_warning("import_ok_cb(): failed to convert character set.");
		mbox = g_strdup(utf8mbox);
	}

	if (!destdir || !*destdir) {
		dest = folder_find_item_from_path(INBOX_DIR);
	} else {
		dest = folder_find_item_from_identifier
			(destdir);
	}

	if (!dest) {
		alertpanel_error(_("Can't find the destination folder."));
		gtk_widget_grab_focus(dest_entry);
		g_free(mbox);
		return;
	} else {
		import_ok = proc_mbox(dest, mbox, FALSE, NULL);
	}

	g_free(mbox);

	if (gtk_main_level() > 1)
		gtk_main_quit();
}
Exemplo n.º 6
0
static void foldersel_cb(GtkWidget *widget, gpointer data)
{
	struct ArchiverPrefsPage *page = (struct ArchiverPrefsPage *) data;
	gchar *startdir = NULL;
	gchar *dirname;
	gchar *tmp;
	
	if (archiver_prefs.save_folder && *archiver_prefs.save_folder)
		startdir = g_strconcat(archiver_prefs.save_folder,
				       G_DIR_SEPARATOR_S, NULL);
	else
		startdir = g_strdup(get_home_dir());

	dirname = filesel_select_file_save_folder(_("Select destination folder"), startdir);
	if (!dirname) {
		g_free(startdir);
		return;
	}
	if (!is_dir_exist(dirname)) {
		alertpanel_error(_("'%s' is not a directory."),dirname);
		g_free(dirname);
		g_free(startdir);
		return;
	}
	if (dirname[strlen(dirname)-1] == G_DIR_SEPARATOR)
		dirname[strlen(dirname)-1] = '\0';
	g_free(startdir);

	tmp =  g_filename_to_utf8(dirname,-1, NULL, NULL, NULL);
	gtk_entry_set_text(GTK_ENTRY(page->save_folder), tmp);

	g_free(dirname);
	g_free(tmp);
}
Exemplo n.º 7
0
static void load_cb(GtkButton *button, PluginWindow *pluginwindow)
{
	GList *file_list;

	file_list = filesel_select_multiple_files_open_with_filter(
			_("Select the Plugins to load"), get_plugin_dir(), 
			"*." G_MODULE_SUFFIX);

	if (file_list) {
		GList *tmp;
		pluginwindow->loading = TRUE;
		for ( tmp = file_list; tmp; tmp = tmp->next) {
			gchar *file, *error = NULL;

			file = (gchar *) tmp->data;
			if (!file) continue;
			plugin_load(file, &error);
			if (error != NULL) {
				gchar *basename = g_path_get_basename(file);
				alertpanel_error(
				_("The following error occurred while loading %s:\n\n%s\n"),
				basename, error);
				g_free(basename);
				g_free(error);
			}

			/* FIXME: globally or atom-ly : ? */
			set_plugin_list(pluginwindow);
			g_free(file);
		}
		pluginwindow->loading = FALSE;
		g_list_free(file_list);
	}		
}
Exemplo n.º 8
0
void mimeview_print_part(MimeView *mimeview, MimeInfo *partinfo)
{
	g_return_if_fail(partinfo != NULL);

	if (!mimeview->messageview->file) return;

	if (partinfo->mime_type == MIME_MESSAGE_RFC822) {
		gchar *filename;
		MsgInfo *msginfo;
		MsgFlags flags = {0, 0};

		filename = procmime_get_tmp_file_name(partinfo);
		if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) {
			alertpanel_error
				(_("Can't save the part of multipart message."));
			g_free(filename);
			return;
		}

		msginfo = procheader_parse_file(filename, flags, TRUE);
		msginfo->file_path = filename;
		filename = NULL;
		printing_print_message
			(msginfo, mimeview->textview->show_all_headers);
		procmsg_msginfo_free(msginfo);
	} else if (partinfo->mime_type == MIME_TEXT ||
		   partinfo->mime_type == MIME_TEXT_HTML) {
		printing_print_message_part(mimeview->messageview->msginfo,
					    partinfo);
	}
}
Exemplo n.º 9
0
void mimeview_save_part_as(MimeView *mimeview, MimeInfo *partinfo)
{
	gchar *filename = NULL;

	g_return_if_fail(partinfo != NULL);

	if (!mimeview->messageview->file) return;

	if (partinfo->filename) {
		filename = filesel_save_as(partinfo->filename);
	} else if (partinfo->name) {
		gchar *defname;

		defname = g_strdup(partinfo->name);
		subst_for_filename(defname);
		filename = filesel_save_as(defname);
		g_free(defname);
	} else
		filename = filesel_save_as(NULL);

	if (!filename)
		return;

	if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0)
		alertpanel_error
			(_("Can't save the part of multipart message."));

	g_free(filename);
}
Exemplo n.º 10
0
static const gchar *master_passphrase()
{
	gchar *input;
	gboolean end = FALSE;

	if (!prefs_common_get_prefs()->use_master_passphrase) {
		return PASSCRYPT_KEY;
	}

	if (_master_passphrase != NULL) {
		debug_print("Master passphrase is in memory, offering it.\n");
		return _master_passphrase;
	}

	while (!end) {
		input = input_dialog_with_invisible(_("Input master passphrase"),
				_("Input master passphrase"), NULL);

		if (input == NULL) {
			debug_print("Cancel pressed at master passphrase dialog.\n");
			break;
		}

		if (master_passphrase_is_correct(input)) {
			debug_print("Entered master passphrase seems to be correct, remembering it.\n");
			_master_passphrase = input;
			end = TRUE;
		} else {
			alertpanel_error(_("Incorrect master passphrase."));
		}
	}

	return _master_passphrase;
}
Exemplo n.º 11
0
void clamd_create_config_manual(const gchar* host, int port) {
	if (! host || port < 1) {
		g_warning("Missing host or port < 1");
		return;
	}
	if (config && config->ConfigType == MANUAL &&
			config->manual.host && config->manual.port == port &&
			strcmp(config->manual.host, host) == 0) {
		debug_print("%s : %s and %d : %d - Identical. No need to read again\n",
			config->manual.host, host, config->manual.port, port);
		return;
	}

	if (config)
		clamd_config_free(config);
	config = clamd_config_new();
	
	config->ConfigType = MANUAL;
	config->manual.host = g_strdup(host);
	config->manual.port = port;
	/* INET socket */
	Socket = (Clamd_Socket *) malloc(sizeof(Clamd_Socket));
	if (Socket) {
		Socket->type = INET_SOCKET;
		Socket->socket.port = port;
		Socket->socket.host = g_strdup(host);
	}
	else {
		/*g_error("%s: Not able to find required information", path);*/
		alertpanel_error(_("Could not create socket"));
	}
}
Exemplo n.º 12
0
static void mimeview_launch(MimeView *mimeview)
{
	MimeInfo *partinfo;
	gchar *filename;

	if (!mimeview->opened) return;
	if (!mimeview->file) return;

	partinfo = mimeview_get_selected_part(mimeview);
	if (!partinfo) { 
		partinfo = (MimeInfo *) gtk_object_get_data
			(GTK_OBJECT(mimeview->popupmenu),
			 "pop_partinfo");
		gtk_object_set_data(GTK_OBJECT(mimeview->popupmenu),
				    "pop_partinfo", NULL);
	}			 
	g_return_if_fail(partinfo != NULL);

	filename = procmime_get_tmp_file_name(partinfo);

	if (procmime_get_part(filename, partinfo) < 0)
		alertpanel_error
			(_("Can't save the part of multipart message."));
	else
		mimeview_view_file(filename, partinfo, NULL);

	g_free(filename);
}
Exemplo n.º 13
0
/**
 * Write a single attachment to file
 * \param filename Filename with path
 * \param partinfo Attachment to save
 */
static gboolean mimeview_write_part(const gchar *filename,
				    MimeInfo *partinfo)
{
	gchar *dir;
	
	dir= g_dirname(filename);
	if (!is_dir_exist(dir))
		make_dir_hier(dir);
	g_free(dir);

	if (is_file_exist(filename)) {
		AlertValue aval;
		gchar *res;
		
		res = g_strdup_printf(_("Overwrite existing file '%s'?"),
				      filename);
		aval = alertpanel(_("Overwrite"), res, _("OK"), 
				  _("Cancel"), NULL);
		g_free(res);					  
		if (G_ALERTDEFAULT != aval) return FALSE;
	}

	if (procmime_get_part(filename, partinfo) < 0) {
		alertpanel_error
			(_("Can't save the part of multipart message."));
		return FALSE;
	}

	return TRUE;
}
Exemplo n.º 14
0
static void mimeview_drag_data_get(GtkWidget	    *widget,
				   GdkDragContext   *drag_context,
				   GtkSelectionData *selection_data,
				   guint	     info,
				   guint	     time,
				   MimeView	    *mimeview)
{
	gchar *filename, *uriname;
	MimeInfo *partinfo;

	if (!mimeview->opened) return;
	if (!mimeview->file) return;

	partinfo = mimeview_get_selected_part(mimeview);
	if (!partinfo) return;

	filename = g_basename(get_part_name(partinfo));
	if (*filename == '\0') return;

	filename = g_strconcat(get_mime_tmp_dir(), G_DIR_SEPARATOR_S,
			       filename, NULL);

	if (procmime_get_part(filename, partinfo) < 0)
		alertpanel_error
			(_("Can't save the part of multipart message."));

	uriname = g_strconcat("file://", filename, NULL);
	gtk_selection_data_set(selection_data, selection_data->target, 8,
			       uriname, strlen(uriname));

	g_free(uriname);
	g_free(filename);
}
Exemplo n.º 15
0
static void add_mailbox(GtkAction *action, gpointer callback_data)
{
	MainWindow *mainwin = (MainWindow *) callback_data;
	gchar *path, *basename;
	Folder *folder;

	path = input_dialog(_("Add mailbox"),
			    _("Input the location of mailbox.\n"
			      "If the existing mailbox is specified, it will be\n"
			      "scanned automatically."),
			    "Mail");
	if (!path) return;
	if (folder_find_from_path(path)) {
		alertpanel_error(_("The mailbox '%s' already exists."), path);
		g_free(path);
		return;
	}
	basename = g_path_get_basename(path);

	if (!folder_local_name_ok(basename)) {
		g_free(path);
		g_free(basename);
		return;
	}

	folder = folder_new(folder_get_class_from_string("mailmbox"), 
			    !strcmp(path, "Mail") ? _("Mailbox") : basename,
			    path);
	g_free(basename);
	g_free(path);

	if (folder->klass->create_tree(folder) < 0) {
		alertpanel_error(_("Creation of the mailbox failed.\n"
				   "Maybe some files already exist, or you don't have the permission to write there."));
		folder_destroy(folder);
		return;
	}

	folder_add(folder);
	folder_scan_tree(folder, TRUE);

	folderview_set(mainwin->folderview);

	return;
}
Exemplo n.º 16
0
void quotefmt_check_forward_formats(gboolean use_format,
				    gchar *override_from_fmt,
				    gchar *quotation_mark,
				    gchar *body_fmt)
{
	if (use_format) {
		gint line;

		if (!prefs_template_string_is_valid(quotation_mark, NULL, TRUE, FALSE))
			alertpanel_error(_("The \"Quotation mark\" field of the \"Forward\" template is invalid."));

		if (override_from_fmt && !prefs_template_string_is_valid(override_from_fmt, NULL, TRUE, TRUE))
			alertpanel_error(_("The \"From\" field of the \"Forward\" template contains an invalid email address."));

		if (!prefs_template_string_is_valid(body_fmt, &line, TRUE, FALSE)) {
			alertpanel_error(_("The body of the \"Forward\" template has an error at line %d."), line);
		}
	}
}
Exemplo n.º 17
0
static void prefs_display_header_list_view_set_row(gboolean hidden)
{
	GtkTreeView *list_view;
	DisplayHeaderProp *dp;
	gchar *entry_text;
	GtkTreeModel *model;

#if !GTK_CHECK_VERSION(2, 24, 0)
	entry_text = gtk_combo_box_get_active_text(GTK_COMBO_BOX(dispheader.hdr_combo));
#else
	entry_text = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(dispheader.hdr_combo));
#endif
	if (!entry_text)
		entry_text = gtk_editable_get_chars(
				GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(dispheader.hdr_combo))),0,-1);
	if (!entry_text || entry_text[0] == '\0') {
		alertpanel_error(_("Header name is not set."));
		return;
	}

	if (hidden)
		list_view = GTK_TREE_VIEW(dispheader.hidden_headers_list_view);
	else
		list_view = GTK_TREE_VIEW(dispheader.headers_list_view);

	if (prefs_display_header_find_header(list_view, entry_text) != -1) {
		alertpanel_error(_("This header is already in the list."));
		return;
	}

	dp = g_new0(DisplayHeaderProp, 1);

	dp->name = g_strdup(entry_text);
	dp->hidden = hidden;

	model = gtk_tree_view_get_model(list_view);
	prefs_display_header_insert_header(GTK_LIST_STORE(model),
					   dp->name, dp);

	prefs_display_header_set_list();
	
	g_free(entry_text);
}
Exemplo n.º 18
0
void quotefmt_check_new_msg_formats(gboolean use_format,
				    gchar *override_from_fmt,
				    gchar *subject_fmt,
				    gchar *body_fmt)
{
	if (use_format) {
		gint line;

		if (override_from_fmt && !prefs_template_string_is_valid(override_from_fmt, NULL, TRUE, TRUE))
			alertpanel_error(_("The \"From\" field of the \"New message\" template contains an invalid email address."));

		if (!prefs_template_string_is_valid(subject_fmt, NULL, TRUE, FALSE))
			alertpanel_error(_("The \"Subject\" field of the \"New message\" template is invalid."));

		if (!prefs_template_string_is_valid(body_fmt, &line, TRUE, FALSE)) {
			alertpanel_error(_("The body of the \"New message\" template has an error at line %d."), line);
		}
	}
}
Exemplo n.º 19
0
void mimeview_save_all(MimeView *mimeview)
{
	gchar *dir;

	dir = filesel_select_dir(NULL);
	if (!dir) return;

	if (procmime_get_all_parts(dir, mimeview->messageview->file, mimeview->messageview->mimeinfo) < 0)
		alertpanel_error(_("Can't save the attachments."));

	g_free(dir);
}
Exemplo n.º 20
0
static void unsubscribe_newsgroup_cb(GtkAction *action, gpointer data)
{
	FolderView *folderview = (FolderView *)data;
	FolderItem *item;
	gchar *name;
	gchar *message;
	gchar *old_id;
	AlertValue avalue;
	MainWindow *mainwin = mainwindow_get_mainwindow();
	
	if (!folderview->selected) return;

	item = folderview_get_selected_item(folderview);
	cm_return_if_fail(item != NULL);

	if (mainwin->lock_count || news_folder_locked(item->folder))
		return;

	cm_return_if_fail(item->folder != NULL);
	cm_return_if_fail(FOLDER_TYPE(item->folder) == F_NEWS);
	cm_return_if_fail(item->folder->account != NULL);

	old_id = folder_item_get_identifier(item);

	name = trim_string(item->path, 32);
	message = g_strdup_printf(_("Really unsubscribe newsgroup '%s'?"), name);
	avalue = alertpanel_full(_("Unsubscribe newsgroup"), message,
		 	         GTK_STOCK_CANCEL, _("_Unsubscribe"), NULL,
							 ALERTFOCUS_FIRST, FALSE, NULL, ALERT_WARNING);
	g_free(message);
	g_free(name);
	if (avalue != G_ALERTALTERNATE) return;

	if (item == folderview_get_opened_item(folderview)) {
		summary_clear_all(folderview->summaryview);
		folderview_close_opened(folderview, TRUE);
	}

	if(item->folder->klass->remove_folder(item->folder, item) < 0) {
		folder_item_scan(item);
		alertpanel_error(_("Can't remove the folder '%s'."), name);
		g_free(old_id);
		return;
	}
	
	folder_write_list();
	
	prefs_filtering_delete_path(old_id);
	g_free(old_id);
}
static gint prefs_display_header_clist_set_row(gboolean hidden)
{
    GtkCList *clist;
    DisplayHeaderProp *dp;
    const gchar *entry_text;
    gchar *dp_str[1];
    gint row;

    entry_text = gtk_entry_get_text(GTK_ENTRY(dispheader.hdr_entry));
    if (entry_text[0] == '\0') {
        alertpanel_error(_("Header name is not set."));
        return -1;
    }

    if (hidden)
        clist = GTK_CLIST(dispheader.hidden_headers_clist);
    else
        clist = GTK_CLIST(dispheader.headers_clist);

    if (prefs_display_header_find_header(clist, entry_text) != -1) {
        alertpanel_error(_("This header is already in the list."));
        return -1;
    }

    dp = g_new0(DisplayHeaderProp, 1);

    dp->name = g_strdup(entry_text);
    dp->hidden = hidden;

    dp_str[0] = dp->name;
    row = gtk_clist_append(clist, dp_str);
    gtk_clist_set_row_data(clist, row, dp);

    prefs_display_header_set_list();

    return row;
}
Exemplo n.º 22
0
static void mimeview_open_with(MimeView *mimeview)
{
	MimeInfo *partinfo;
	gchar *filename;
	gchar *cmd;

	if (!mimeview->opened) return;
	if (!mimeview->file) return;

	partinfo = mimeview_get_selected_part(mimeview);
	if (!partinfo) { 
		partinfo = (MimeInfo *) gtk_object_get_data
			(GTK_OBJECT(mimeview->popupmenu),
			 "pop_partinfo");
		gtk_object_set_data(GTK_OBJECT(mimeview->popupmenu),
				    "pop_partinfo", NULL);
	}			 
	g_return_if_fail(partinfo != NULL);

	filename = procmime_get_tmp_file_name(partinfo);

	if (procmime_get_part(filename, partinfo) < 0) {
		alertpanel_error
			(_("Can't save the part of multipart message."));
		g_free(filename);
		return;
	}

	if (!prefs_common.mime_open_cmd_history)
		prefs_common.mime_open_cmd_history =
			add_history(NULL, prefs_common.mime_open_cmd);

	cmd = input_dialog_combo
		(_("Open with"),
		 _("Enter the command line to open file:\n"
		   "(`%s' will be replaced with file name)"),
		 prefs_common.mime_open_cmd,
		 prefs_common.mime_open_cmd_history,
		 TRUE);
	if (cmd) {
		mimeview_view_file(filename, partinfo, cmd);
		g_free(prefs_common.mime_open_cmd);
		prefs_common.mime_open_cmd = cmd;
		prefs_common.mime_open_cmd_history =
			add_history(prefs_common.mime_open_cmd_history, cmd);
	}

	g_free(filename);
}
Exemplo n.º 23
0
Arquivo: news.c Projeto: Mortal/claws
static void warn_etpan(void)
{
	static gboolean missing_news_warning = TRUE;
	if (missing_news_warning) {
		missing_news_warning = FALSE;
		alertpanel_error(
			_("You have one or more News accounts "
			  "defined. However this version of "
			  "Claws Mail has been built without "
			  "News support; your News account(s) are "
			  "disabled.\n\n"
			  "You probably need to "
			  "install libetpan and recompile "
			  "Claws Mail."));
	}
}
Exemplo n.º 24
0
static void cache_clean_button_clicked_cb(GtkButton *button, gpointer data)
{
	GtkLabel *label = (GtkLabel *) data;
	gint val = 0;
	AvatarCleanupResult *acr;
	guint misses;

	val = alertpanel_full(_("Clear icon cache"),
			_("Are you sure you want to remove all cached avatar icons?"),
			GTK_STOCK_NO, GTK_STOCK_YES, NULL, FALSE,
			NULL, ALERT_WARNING, G_ALERTDEFAULT);
	if (val != G_ALERTALTERNATE)
		return;

	debug_print("cleaning missing cache");
	misses = g_hash_table_size(libravatarmisses);
	g_hash_table_remove_all(libravatarmisses);

	debug_print("cleaning disk cache");
	acr = libravatar_cache_clean();
	if (acr == NULL) {
		alertpanel_error(_("Not enough memory for operation"));
		return;
	}

	if (acr->e_stat == 0 && acr->e_unlink == 0) {
		alertpanel_notice(_("Icon cache successfully cleared:\n"
			"• %u missing entries removed.\n"
			"• %u files removed."),
			misses, acr->removed);
		gtk_label_set_markup(label,
			_("<span color=\"#006400\">Icon cache succesfully cleared!</span>"));
	}
	else {
		alertpanel_warning(_("Errors clearing icon cache:\n"
			"• %u missing entries removed.\n"
			"• %u files removed.\n"
			"• %u files failed to be read.\n"
			"• %u files couldn't be removed."),
			misses, acr->removed, acr->e_stat, acr->e_unlink);
		gtk_label_set_markup(label,
			_("<span color=\"red\">Error clearing icon cache.</span>"));
	}
	gtk_widget_set_sensitive(GTK_WIDGET(button), FALSE);
	g_free(acr);
}
Exemplo n.º 25
0
void mimeview_launch_part(MimeView *mimeview, MimeInfo *partinfo)
{
	gchar *filename;

	g_return_if_fail(partinfo != NULL);

	if (!mimeview->messageview->file) return;

	filename = procmime_get_tmp_file_name(partinfo);

	if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0)
		alertpanel_error
			(_("Can't save the part of multipart message."));
	else
		mimeview_view_file(filename, partinfo, NULL);

	g_free(filename);
}
Exemplo n.º 26
0
gint plugin_init(gchar **error)
{
    gchar *rcpath;

    if (!check_plugin_version(MAKE_NUMERIC_VERSION(2,9,2,72),
                              VERSION_NUMERIC, PLUGIN_NAME, error))
        return -1;

    hook_id = hooks_register_hook(MAIL_FILTERING_HOOKLIST, mail_filtering_hook, NULL);
    if (hook_id == -1) {
        *error = g_strdup(_("Failed to register mail filtering hook"));
        return -1;
    }

    prefs_set_default(param);
    rcpath = g_strconcat(get_rc_dir(), G_DIR_SEPARATOR_S, COMMON_RC, NULL);
    prefs_read_config(param, "ClamAV", rcpath, NULL);
    g_free(rcpath);

    clamav_gtk_init();

    if (config.clamav_enable) {
        debug_print("Creating socket\n");
        config.alert_ack = TRUE;
        Clamd_Stat status = clamd_prepare();
        switch (status) {
        case NO_SOCKET:
            g_warning("[init] No socket information");
            alertpanel_error(_("Init\nNo socket information.\nAntivirus disabled."));
            break;
        case NO_CONNECTION:
            g_warning("[init] Clamd does not respond to ping");
            alertpanel_warning(_("Init\nClamd does not respond to ping.\nIs clamd running?"));
            break;
        default:
            break;
        }
    }

    debug_print("Clamd plugin loaded\n");

    return 0;

}
Exemplo n.º 27
0
static void mimeview_show_image_part(MimeView *mimeview, MimeInfo *partinfo)
{
	gchar *filename;

	if (!partinfo) return;

	filename = procmime_get_tmp_file_name(partinfo);

	if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0)
		alertpanel_error
			(_("Can't get the part of multipart message."));
	else {
		mimeview_change_view_type(mimeview, MIMEVIEW_IMAGE);
		imageview_show_image(mimeview->imageview, partinfo, filename,
				     prefs_common.resize_image);
		g_unlink(filename);
	}

	g_free(filename);
}
Exemplo n.º 28
0
static void mimeview_reply(MimeView *mimeview, guint action)
{
	MimeInfo *partinfo;
	gchar *filename;
	MsgInfo *msginfo;
	MsgFlags flags = {0, 0};
	ComposeMode mode = action;

	if (!mimeview->opened) return;
	if (!mimeview->messageview->file) return;

	partinfo = mimeview_get_selected_part(mimeview);
	g_return_if_fail(partinfo != NULL);

	if (partinfo->mime_type != MIME_MESSAGE_RFC822)
		return;

	filename = procmime_get_tmp_file_name(partinfo);
	if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) {
		alertpanel_error
			(_("Can't save the part of multipart message."));
			g_free(filename);
			return;
	}

	msginfo = procheader_parse_file(filename, flags, TRUE);
	msginfo->file_path = filename;
	filename = NULL;
	if (prefs_common.reply_with_quote)
		mode |= COMPOSE_WITH_QUOTE;

	if (mimeview->messageview->mainwin)
		compose_reply(msginfo, mimeview->messageview->mainwin->summaryview->folder_item,
			      mode, NULL);
	else
		compose_reply(msginfo, NULL, mode, NULL);

	g_unlink(msginfo->file_path);
	procmsg_msginfo_free(msginfo);
}
Exemplo n.º 29
0
void mimeview_open_part_with(MimeView *mimeview, MimeInfo *partinfo)
{
	gchar *filename;
	gchar *cmd;

	g_return_if_fail(partinfo != NULL);

	if (!mimeview->messageview->file) return;

	filename = procmime_get_tmp_file_name(partinfo);

	if (procmime_get_part(filename, mimeview->messageview->file, partinfo) < 0) {
		alertpanel_error
			(_("Can't save the part of multipart message."));
		g_free(filename);
		return;
	}

	if (!prefs_common.mime_open_cmd_history)
		prefs_common.mime_open_cmd_history =
			add_history(NULL, prefs_common.mime_open_cmd);

	cmd = input_dialog_combo
		(_("Open with"),
		 _("Enter the command line to open file:\n"
		   "(`%s' will be replaced with file name)"),
		 prefs_common.mime_open_cmd,
		 prefs_common.mime_open_cmd_history,
		 TRUE);
	if (cmd) {
		mimeview_view_file(filename, partinfo, cmd);
		g_free(prefs_common.mime_open_cmd);
		prefs_common.mime_open_cmd = cmd;
		prefs_common.mime_open_cmd_history =
			add_history(prefs_common.mime_open_cmd_history, cmd);
	}

	g_free(filename);
}
Exemplo n.º 30
0
/*!
 *\brief	display an error with a View Log button
 *
 */
void alertpanel_error_log(const gchar *format, ...)
{
	va_list args;
	int val;
	MainWindow *mainwin;
	gchar buf[ALERT_PANEL_BUFSIZE];

	va_start(args, format);
	g_vsnprintf(buf, sizeof(buf), format, args);
	va_end(args);
	strretchomp(buf);

	mainwin = mainwindow_get_mainwindow();
	
	if (mainwin && mainwin->logwin) {
		mainwindow_clear_error(mainwin);
		val = alertpanel_full(_("Error"), buf, GTK_STOCK_CLOSE,
				      _("_View log"), NULL, ALERTFOCUS_FIRST, FALSE, NULL,
				      ALERT_ERROR);
		if (val == G_ALERTALTERNATE)
			log_window_show(mainwin->logwin);
	} else
		alertpanel_error("%s", buf);
}