aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-12-17 07:03:28 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2009-12-17 07:03:28 +0000
commit1aaf8ce241d8700c4645e3090cfeccd4b20eee28 (patch)
tree80404ff4b3692e6ef998c9f6b5c5ea29b5d3e88e
parentd5175b3fc5fda02558b7754ba160eee360ccb7ec (diff)
added select button to 'Add mailbox' dialog.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2399 ee746299-78ed-0310-b773-934348b2243d
-rw-r--r--ChangeLog6
-rw-r--r--src/filesel.c2
-rw-r--r--src/inputdialog.c59
-rw-r--r--src/inputdialog.h8
-rw-r--r--src/mainwindow.c11
5 files changed, 72 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index e223fa5d..4ac02745 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
2009-12-17
+ * src/inputdialog.[ch]
+ src/filesel.c
+ src/mainwindow.c: added select button to 'Add mailbox' dialog.
+
+2009-12-17
+
* libsylph/utils.[ch]
src/setup.c: check whether the specified location includes settings
folder.
diff --git a/src/filesel.c b/src/filesel.c
index 745ecd1f..3cceec61 100644
--- a/src/filesel.c
+++ b/src/filesel.c
@@ -180,7 +180,7 @@ gchar *filesel_select_dir(const gchar *dir)
GSList *list;
gchar *selected = NULL;
- list = filesel_select_file_full(_("Select directory"), dir,
+ list = filesel_select_file_full(_("Select folder"), dir,
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
FALSE);
if (list) {
diff --git a/src/inputdialog.c b/src/inputdialog.c
index ae8ce71a..b967b805 100644
--- a/src/inputdialog.c
+++ b/src/inputdialog.c
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2006 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,23 +41,26 @@
#include "inputdialog.h"
#include "manage_window.h"
#include "inc.h"
+#include "filesel.h"
#include "prefs_common.h"
#include "gtkutils.h"
#include "utils.h"
-#define INPUT_ENTRY_WIDTH 400
+#define DIALOG_WIDTH 420
typedef enum
{
INPUT_DIALOG_NORMAL,
INPUT_DIALOG_INVISIBLE,
- INPUT_DIALOG_COMBO
+ INPUT_DIALOG_COMBO,
+ INPUT_DIALOG_FILESEL
} InputDialogType;
static gboolean ack;
static gboolean fin;
static InputDialogType type;
+static GtkFileChooserAction chooser_action;
static GtkWidget *dialog;
static GtkWidget *msg_label;
@@ -87,6 +90,8 @@ static gboolean key_pressed (GtkWidget *widget,
gpointer data);
static void entry_activated (GtkEditable *editable);
static void combo_activated (GtkEditable *editable);
+static void sel_btn_clicked (GtkButton *button,
+ gpointer data);
static gint focus_out (GtkWidget *widget,
GdkEventFocus *event,
gpointer data);
@@ -151,14 +156,29 @@ gchar *input_dialog_query_password(const gchar *server, const gchar *user)
return pass;
}
+gchar *input_dialog_with_filesel(const gchar *title, const gchar *message,
+ const gchar *default_string,
+ GtkFileChooserAction action)
+{
+ if (dialog)
+ return NULL;
+
+ input_dialog_create(INPUT_DIALOG_FILESEL);
+ chooser_action = action;
+
+ return input_dialog_open(title, message, default_string);
+}
+
static void input_dialog_create(InputDialogType dialog_type)
{
GtkWidget *vbox;
GtkWidget *hbox;
+ GtkWidget *sel_btn;
GtkWidget *cancel_button;
dialog = gtk_dialog_new();
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
+ gtk_widget_set_size_request(dialog, DIALOG_WIDTH, -1);
gtk_container_set_border_width
(GTK_CONTAINER(GTK_DIALOG(dialog)->action_area), 5);
gtk_window_set_position(GTK_WINDOW(dialog),
@@ -184,20 +204,28 @@ static void input_dialog_create(InputDialogType dialog_type)
gtk_box_pack_start(GTK_BOX(hbox), msg_label, FALSE, FALSE, 0);
gtk_label_set_justify(GTK_LABEL(msg_label), GTK_JUSTIFY_LEFT);
+ hbox = gtk_hbox_new(FALSE, 4);
+ gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0);
+
type = dialog_type;
if (dialog_type == INPUT_DIALOG_COMBO) {
combo = gtk_combo_new();
- gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
- gtk_widget_set_size_request(combo, INPUT_ENTRY_WIDTH, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), combo, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(GTK_COMBO(combo)->entry), "activate",
G_CALLBACK(combo_activated), NULL);
} else {
entry = gtk_entry_new();
- gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0);
- gtk_widget_set_size_request(entry, INPUT_ENTRY_WIDTH, -1);
+ gtk_box_pack_start(GTK_BOX(hbox), entry, TRUE, TRUE, 0);
g_signal_connect(G_OBJECT(entry), "activate",
G_CALLBACK(entry_activated), NULL);
+ if (dialog_type == INPUT_DIALOG_FILESEL) {
+ sel_btn = gtk_button_new_with_label("...");
+ gtk_box_pack_start(GTK_BOX(hbox), sel_btn,
+ FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(sel_btn), "clicked",
+ G_CALLBACK(sel_btn_clicked), NULL);
+ }
if (dialog_type == INPUT_DIALOG_INVISIBLE)
gtk_entry_set_visibility(GTK_ENTRY(entry), FALSE);
}
@@ -331,6 +359,23 @@ static void combo_activated(GtkEditable *editable)
fin = TRUE;
}
+static void sel_btn_clicked(GtkButton *button, gpointer data)
+{
+ gchar *file;
+ gchar *utf8_file;
+
+ 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);
+ }
+}
+
static gint focus_out(GtkWidget *widget, GdkEventFocus *event, gpointer data)
{
#ifdef G_OS_WIN32
diff --git a/src/inputdialog.h b/src/inputdialog.h
index 392f73bb..02bdda33 100644
--- a/src/inputdialog.h
+++ b/src/inputdialog.h
@@ -1,6 +1,6 @@
/*
* Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
- * Copyright (C) 1999-2005 Hiroyuki Yamamoto
+ * Copyright (C) 1999-2009 Hiroyuki Yamamoto
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@
#define __INPUTDIALOG_H__
#include <glib.h>
+#include <gtk/gtkfilechooser.h>
gchar *input_dialog (const gchar *title,
const gchar *message,
@@ -36,4 +37,9 @@ gchar *input_dialog_combo (const gchar *title,
gchar *input_dialog_query_password (const gchar *server,
const gchar *user);
+gchar *input_dialog_with_filesel (const gchar *title,
+ const gchar *message,
+ const gchar *default_string,
+ GtkFileChooserAction action);
+
#endif /* __INPUTDIALOG_H__ */
diff --git a/src/mainwindow.c b/src/mainwindow.c
index 8fe78cea..f83ffcfa 100644
--- a/src/mainwindow.c
+++ b/src/mainwindow.c
@@ -1779,11 +1779,12 @@ void main_window_add_mailbox(MainWindow *mainwin)
gchar *path;
Folder *folder;
- path = input_dialog(_("Add mailbox"),
- _("Specify the location of mailbox.\n"
- "If the existing mailbox is specified, it will be\n"
- "scanned automatically."),
- "Mail");
+ path = input_dialog_with_filesel
+ (_("Add mailbox"),
+ _("Specify the location of mailbox.\n"
+ "If the existing mailbox is specified, it will be\n"
+ "scanned automatically."),
+ "Mail", GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER);
if (!path) return;
if (folder_find_from_path(path)) {
alertpanel_error(_("The mailbox `%s' already exists."), path);