[pan2/testing] forgot this
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing] forgot this
- Date: Fri, 16 Dec 2011 22:20:10 +0000 (UTC)
commit 0dbceb32f5df94fdf66eb493336d2e72e905fe74
Author: Heinrich MÃller <henmull src gnome org>
Date: Fri Dec 16 23:14:17 2011 +0100
forgot this
pan/gui/e-cte-dialog.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++
pan/gui/e-cte-dialog.h | 14 +++++
2 files changed, 159 insertions(+), 0 deletions(-)
---
diff --git a/pan/gui/e-cte-dialog.c b/pan/gui/e-cte-dialog.c
new file mode 100644
index 0000000..c452d2d
--- /dev/null
+++ b/pan/gui/e-cte-dialog.c
@@ -0,0 +1,145 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
+/*
+ * Copyright (C) 2001 Ximian, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public
+ * License along with this program; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ */
+
+#include "e-cte-dialog.h"
+
+#include <gmime/gmime.h>
+#include <glib/gi18n.h>
+
+/**
+ * e_cte_dialog:
+ * @title: title for the dialog box
+ * @prompt: prompt string for the dialog box
+ * @now: active cte
+ * @parent: a parent window for the dialog box, or %NULL
+ *
+ * This creates a new dialog box with the given @title and @prompt and
+ * a cte set picker menu. It then runs the dialog and returns
+ * the selected content-transfer-encoding, or GMIME_CONTENT_ENCODING_8BIT if the user cancels/aborts.
+ *
+ * Return value: the selected content transfer encoding, or GMIME_CONTENT_ENCODING_8BIT.
+ **/
+GMimeContentEncoding
+e_cte_dialog (const char *title, const char *prompt, GMimeContentEncoding now, GtkWindow *parent)
+{
+ GtkDialog *dialog;
+ GtkWidget *label, *picker, *vbox, *hbox;
+ GMimeContentEncoding ret = GMIME_CONTENT_ENCODING_8BIT;
+
+ dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (title,
+ parent,
+ GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_OK, GTK_RESPONSE_OK,
+ NULL));
+
+ //gtk_dialog_set_has_separator (dialog, FALSE);
+ gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK);
+
+ vbox = gtk_vbox_new (FALSE, 6);
+ gtk_container_set_border_width (GTK_CONTAINER (vbox), 12);
+ gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area(dialog)), vbox, FALSE, FALSE, 0);
+ gtk_widget_show (vbox);
+
+ label = gtk_label_new (prompt);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5);
+ gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ hbox = gtk_hbox_new (FALSE, 12);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
+ gtk_widget_show (hbox);
+
+ label = gtk_label_new ("");
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+ gtk_widget_show (label);
+
+ GtkTreeIter iter;
+ GtkListStore * store;
+ GtkCellRenderer * renderer;
+
+ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("Default encoding"), 1, GMIME_CONTENT_ENCODING_DEFAULT, -1);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("7Bit Encoding"), 1, GMIME_CONTENT_ENCODING_7BIT, -1);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("8Bit Encoding"), 1, GMIME_CONTENT_ENCODING_8BIT, -1);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("BASE64 Encoding"), 1, GMIME_CONTENT_ENCODING_BASE64, -1);
+ gtk_list_store_append (store, &iter);
+ gtk_list_store_set (store, &iter, 0, _("Quoted-Printable Encoding"), 1, GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE, -1);
+
+ int active = 0;
+ switch (now)
+ {
+ case GMIME_CONTENT_ENCODING_DEFAULT:
+ active = 0;
+ break;
+ case GMIME_CONTENT_ENCODING_7BIT:
+ active = 1;
+ break;
+ case GMIME_CONTENT_ENCODING_8BIT:
+ active = 2;
+ break;
+ case GMIME_CONTENT_ENCODING_BASE64:
+ active = 3;
+ break;
+ case GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE:
+ active = 4;
+ break;
+ }
+ picker = gtk_combo_box_new_with_model (GTK_TREE_MODEL(store));
+ gtk_combo_box_set_active (GTK_COMBO_BOX(picker), active);
+
+ renderer = gtk_cell_renderer_text_new ();
+ gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (picker), renderer, TRUE);
+ gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (picker), renderer, "text", 0, NULL);
+
+ gtk_box_pack_start (GTK_BOX (hbox), picker, TRUE, TRUE, 0);
+
+ gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area(dialog)), 0);
+ gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area(dialog)), 12);
+
+ gtk_widget_show_all (GTK_WIDGET (dialog));
+ gtk_widget_show_all (GTK_WIDGET (hbox));
+
+ g_object_ref (dialog);
+
+ if (gtk_dialog_run (dialog) == GTK_RESPONSE_OK)
+ {
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ GMimeContentEncoding value;
+
+ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX(picker), &iter))
+ return;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX(picker));
+ gtk_tree_model_get (model, &iter, 1, &value, -1);
+ ret = value;
+ }
+
+ gtk_widget_destroy (GTK_WIDGET (dialog));
+ g_object_unref (dialog);
+
+ return ret;
+}
diff --git a/pan/gui/e-cte-dialog.h b/pan/gui/e-cte-dialog.h
new file mode 100644
index 0000000..fa610d5
--- /dev/null
+++ b/pan/gui/e-cte-dialog.h
@@ -0,0 +1,14 @@
+#ifndef E_CTE_DIALOG_H
+#define E_CTE_DIALOG_H
+
+#include <config.h>
+#include <gmime/gmime.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+GMimeContentEncoding e_cte_dialog (const char *title, const char *prompt, GMimeContentEncoding now, GtkWindow *parent);
+
+G_END_DECLS
+
+#endif
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]