1 /* Copyright (c) 2006, Nokia Corporation
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * * Neither the name of the Nokia Corporation nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 #include <libgnomevfs/gnome-vfs-mime.h>
31 #include <libgnomeui/gnome-icon-lookup.h>
32 #include <tny-gnome-device.h>
34 #include "modest-platform.h"
35 #include "modest-mail-operation-queue.h"
36 #include "modest-runtime.h"
39 modest_platform_init (void)
41 return TRUE; /* nothing to do */
46 modest_platform_get_new_device (void)
48 return TNY_DEVICE (tny_gnome_device_new ());
53 modest_platform_get_file_icon_name (const gchar* name, const gchar* mime_type,
54 gchar **effective_mime_type)
56 GString *mime_str = NULL;
57 gchar *icon_name = NULL;
59 const static gchar* octet_stream = "application/octet-stream";
61 g_return_val_if_fail (name || mime_type, NULL);
63 if (!mime_type || g_ascii_strcasecmp (mime_type, octet_stream))
64 mime_str = g_string_new(gnome_vfs_mime_type_from_name_or_default
65 (name, "application/octet-stream"));
67 mime_str = g_string_new (mime_type);
68 g_string_ascii_down (mime_str);
71 uri = g_strconcat ("file:///", name ? name : "dummy", NULL);
72 icon_name = gnome_icon_lookup (gtk_icon_theme_get_default(), NULL,
73 uri, NULL, NULL, mime_str->str, 0, 0);
76 if (effective_mime_type)
77 *effective_mime_type = g_string_free (mime_str, FALSE);
79 g_string_free (mime_str, TRUE);
85 modest_platform_activate_uri (const gchar *uri)
87 modest_runtime_not_implemented (NULL);
92 modest_platform_show_uri_popup (const gchar *uri)
94 modest_runtime_not_implemented (NULL);
99 modest_platform_get_icon (const gchar *name)
104 g_return_val_if_fail (name, NULL);
106 pixbuf = gdk_pixbuf_new_from_file (name, &err);
109 g_printerr ("modest: error while loading icon '%s': %s\n",
119 modest_platform_get_app_name (void)
125 modest_platform_run_new_folder_dialog (ModestWindow *parent_window,
126 TnyFolderStore *parent_folder)
128 GtkWidget *dialog, *entry;
130 gboolean finished = FALSE;
131 TnyFolder *new_folder;
132 ModestMailOperation *mail_op;
134 /* Ask the user for the folder name */
135 dialog = gtk_dialog_new_with_buttons (_("New Folder Name"),
136 GTK_WINDOW (parent_window),
143 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
144 gtk_label_new (_("Please enter a name for the new folder")),
147 entry = gtk_entry_new_with_max_length (40);
148 gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox),
152 gtk_widget_show_all (GTK_WIDGET(GTK_DIALOG(dialog)->vbox));
154 if (gtk_dialog_run (GTK_DIALOG(dialog)) == GTK_RESPONSE_REJECT) {
155 gtk_widget_destroy (dialog);
159 folder_name = g_strdup (gtk_entry_get_text (GTK_ENTRY (entry)));
160 gtk_widget_destroy (dialog);
162 mail_op = modest_mail_operation_new ();
163 modest_mail_operation_queue_add (modest_runtime_get_mail_operation_queue (),
166 new_folder = modest_mail_operation_create_folder (mail_op,
168 (const gchar *) folder_name);
170 g_object_unref (new_folder);
175 g_object_unref (mail_op);
176 g_free (folder_name);