static void prefs_spelling_btn_aspell_path_clicked_cb(GtkWidget *widget, gpointer data) { SpellingPage *spelling = (SpellingPage *) data; gchar *file_path; GtkWidget *new_menu; file_path = filesel_select_file(_("Select dictionaries location"), prefs_common.aspell_path); if (file_path != NULL) { gchar *tmp_path, *tmp; tmp_path = g_dirname(file_path); tmp = g_strdup_printf("%s%s", tmp_path, G_DIR_SEPARATOR_S); g_free(tmp_path); new_menu = gtkaspell_dictionary_option_menu_new(tmp); gtk_option_menu_set_menu(GTK_OPTION_MENU(spelling->optmenu_dictionary), new_menu); gtk_entry_set_text(GTK_ENTRY(spelling->entry_aspell_path), tmp); /* select first one */ gtk_option_menu_set_history(GTK_OPTION_MENU( spelling->optmenu_dictionary), 0); g_free(tmp); } }
/** * Menu callback: Save the selected attachment * \param mimeview Current display */ static void mimeview_save_as(MimeView *mimeview) { gchar *filename; gchar *filepath = NULL; gchar *filedir = NULL; MimeInfo *partinfo; gchar *partname = NULL; 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); if (get_part_name(partinfo) == NULL) { return; } partname = g_strdup(get_part_name(partinfo)); subst_for_filename(partname); if (prefs_common.attach_save_dir) filepath = g_strconcat(prefs_common.attach_save_dir, G_DIR_SEPARATOR_S, partname, NULL); else filepath = g_strdup(partname); g_free(partname); filename = filesel_select_file(_("Save as"), filepath); if (!filename) { g_free(filepath); return; } mimeview_write_part(filename, partinfo); filedir = g_dirname(filename); if (filedir && strcmp(filedir, ".")) { if (prefs_common.attach_save_dir) g_free(prefs_common.attach_save_dir); prefs_common.attach_save_dir = g_strdup(filedir); } g_free(filedir); g_free(filepath); }
static void imp_ldif_file_select( void ) { gchar *sSelFile; sSelFile = filesel_select_file( _("Select LDIF File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN ); if ( sSelFile ) { gchar *sUTF8File; sUTF8File = conv_filename_to_utf8( sSelFile ); gtk_entry_set_text( GTK_ENTRY(impldif_dlg.file_entry), sUTF8File ); g_free( sUTF8File ); g_free( sSelFile ); } }
/*! *\brief saves crash log to a file */ static void crash_save_crash_log(GtkButton *button, const gchar *text) { time_t timer; struct tm *lt; char buf[100]; gchar *filename; timer = time(NULL); lt = localtime(&timer); strftime(buf, sizeof buf, "sylpheed-crash-log-%Y-%m-%d-%H-%M-%S.txt", lt); if (NULL != (filename = filesel_select_file(_("Save crash information"), buf)) && *filename) str_write_to_file(text, filename); }
static void edit_jpilot_file_select( void ) { gchar *sFile; gchar *sUTF8File; sFile = filesel_select_file( _("Select JPilot File"), NULL, GTK_FILE_CHOOSER_ACTION_OPEN ); if( sFile ) { sUTF8File = conv_filename_to_utf8( sFile ); gtk_entry_set_text( GTK_ENTRY(jpilotedit.file_entry), sUTF8File ); g_free( sUTF8File ); g_free( sFile ); edit_jpilot_file_check(); } }
static void sel_btn_clicked(GtkButton *button, gpointer data) { gchar *file; gchar *utf8_file; g_signal_handlers_block_by_func(dialog, focus_out, NULL); if (chooser_action == GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER) file = filesel_select_dir(NULL); else file = filesel_select_file(_("Select file"), NULL, chooser_action); if (file) { utf8_file = conv_filename_to_utf8(file); gtk_entry_set_text(GTK_ENTRY(entry), utf8_file); g_free(utf8_file); } g_signal_handlers_unblock_by_func(dialog, focus_out, NULL); }
/** * Menu callback: Save all attached files * \param mimeview Current display */ static void mimeview_save_all(MimeView *mimeview) { MimeInfo *partinfo; gchar *dirname; gchar *startdir = NULL; gint number = 1; if (!mimeview->opened) return; if (!mimeview->file) return; if (!mimeview->mimeinfo) return; partinfo = mimeview->mimeinfo; if (prefs_common.attach_save_dir) startdir = g_strconcat(prefs_common.attach_save_dir, G_DIR_SEPARATOR_S, NULL); dirname = filesel_select_file(_("Select destination folder"), startdir); if (!dirname) { if (startdir) g_free(startdir); return; } if (!is_dir_exist (dirname)) { alertpanel_error(_("`%s' is not a directory."), dirname); if (startdir) g_free(startdir); return; } if (dirname[strlen(dirname)-1] == G_DIR_SEPARATOR) dirname[strlen(dirname)-1] = '\0'; /* Skip the first part, that is sometimes DISPOSITIONTYPE_UNKNOWN */ if (partinfo && partinfo->type == MIMETYPE_MESSAGE) partinfo = procmime_mimeinfo_next(partinfo); if (partinfo && partinfo->type == MIMETYPE_MULTIPART) { partinfo = procmime_mimeinfo_next(partinfo); if (partinfo && partinfo->type == MIMETYPE_TEXT) partinfo = procmime_mimeinfo_next(partinfo); } while (partinfo != NULL) { if (partinfo->type != MIMETYPE_MESSAGE && partinfo->type != MIMETYPE_MULTIPART && partinfo->disposition != DISPOSITIONTYPE_INLINE) { gchar *filename = mimeview_get_filename_for_part (partinfo, dirname, number++); mimeview_write_part(filename, partinfo); g_free(filename); } partinfo = procmime_mimeinfo_next(partinfo); } if (prefs_common.attach_save_dir) g_free(prefs_common.attach_save_dir); prefs_common.attach_save_dir = g_strdup(dirname); if (startdir) g_free(startdir); }