summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBastien Nocera <hadess@hadess.net>2010-08-18 14:24:46 +0100
committerBastien Nocera <hadess@hadess.net>2010-08-18 14:24:46 +0100
commit0ca00f4b3d19e6d26070550833d42bae9ec953a3 (patch)
treef4d67e8c4694ae4e9945890406341e8588c6ab06 /src
parentabd3f289890b017684874382c4caa4e8e04e36d2 (diff)
downloadnautilus-sendto-0ca00f4b3d19e6d26070550833d42bae9ec953a3.tar.gz
Add starts of a test case for setting the title
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am13
-rw-r--r--src/nautilus-sendto-command.c11
-rw-r--r--src/nautilus-sendto-mimetype.c31
-rw-r--r--src/nautilus-sendto-mimetype.h27
-rw-r--r--src/test-mimetype.c50
5 files changed, 129 insertions, 3 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8977b34..8a97328 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,3 +1,5 @@
+include $(top_srcdir)/Makefile.decl
+
SUBDIRS = extension plugins
INCLUDES = \
-DDATADIR=\"$(datadir)\" \
@@ -16,7 +18,9 @@ INCLUDES = \
noinst_LTLIBRARIES = libnstplugin.la
libnstplugin_la_SOURCES = \
nst-enum-types.c \
- nst-enum-types.h
+ nst-enum-types.h \
+ nautilus-sendto-mimetype.c \
+ nautilus-sendto-mimetype.h
libnstplugin_la_LIBADD = $(NAUTILUS_SENDTO_LIBS)
bin_PROGRAMS = nautilus-sendto
@@ -24,6 +28,13 @@ bin_PROGRAMS = nautilus-sendto
nautilus_sendto_SOURCES = nautilus-sendto-command.c
nautilus_sendto_LDADD = $(NAUTILUS_SENDTO_LIBS) libnstplugin.la $(builddir)/plugins/libnautilussendto-1.0.la
+pwd=`pwd`
+
+noinst_PROGRAMS = $(TEST_PROGS)
+TEST_PROGS += test-mimetype
+test_mimetype_SOURCES = test-mimetype.c
+test_mimetype_LDADD = $(NAUTILUS_SENDTO_LIBS) libnstplugin.la $(builddir)/plugins/libnautilussendto-1.0.la
+
nst_headers_to_scan_for_enums = plugins/nautilus-sendto-plugin.h
# Generate the enums source code, with glib-mkenums:
# This is based on the same Makefile.am stuff in pango:
diff --git a/src/nautilus-sendto-command.c b/src/nautilus-sendto-command.c
index 671ceb9..a3ac0ee 100644
--- a/src/nautilus-sendto-command.c
+++ b/src/nautilus-sendto-command.c
@@ -28,7 +28,9 @@
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include <gtk/gtk.h>
+
#include "nautilus-sendto-plugin.h"
+#include "nautilus-sendto-mimetype.h"
#define NAUTILUS_SENDTO_LAST_MEDIUM "last-medium"
#define NAUTILUS_SENDTO_STATUS_LABEL_TIMEOUT_SECONDS 10
@@ -272,6 +274,7 @@ nautilus_sendto_create_ui (void)
GtkSettings *gtk_settings;
GtkWidget *button_image;
const char *ui_file;
+ char *title;
app = gtk_builder_new ();
if (run_from_build_dir) {
@@ -302,8 +305,12 @@ nautilus_sendto_create_ui (void)
G_CALLBACK (update_button_image), button_image);
update_button_image (gtk_settings, NULL, button_image);
- /* FIXME:
- * Set the title of the window depending on the mime-types in mime_types */
+ /* Set a title depending on the number of files to
+ * share, and their types */
+ title = nst_title_from_mime_types ((const char **) mime_types, g_list_length (file_list));
+ gtk_window_set_title (GTK_WINDOW (gtk_builder_get_object (app, "nautilus_sendto_dialog")),
+ title);
+ g_free (title);
set_model_for_options_treeview (ui);
g_signal_connect (G_OBJECT (ui->dialog), "destroy",
diff --git a/src/nautilus-sendto-mimetype.c b/src/nautilus-sendto-mimetype.c
new file mode 100644
index 0000000..ac15b1a
--- /dev/null
+++ b/src/nautilus-sendto-mimetype.c
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2010 Bastien Nocera
+ *
+ * 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 the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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 av.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Author: Roberto Majadas <roberto.majadas@openshine.com>
+ * Bastien Nocera <hadess@hadess.net>
+ */
+
+#include "nautilus-sendto-mimetype.h"
+
+char *
+nst_title_from_mime_types (const char **mimetypes,
+ guint num_files)
+{
+ return NULL;
+}
+
diff --git a/src/nautilus-sendto-mimetype.h b/src/nautilus-sendto-mimetype.h
new file mode 100644
index 0000000..c23875c
--- /dev/null
+++ b/src/nautilus-sendto-mimetype.h
@@ -0,0 +1,27 @@
+/*
+ * Copyright (C) 2010 Bastien Nocera
+ *
+ * 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 the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * 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 av.
+ *
+ * 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., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301 USA.
+ *
+ * Author: Roberto Majadas <roberto.majadas@openshine.com>
+ * Bastien Nocera <hadess@hadess.net>
+ */
+
+#include <glib.h>
+
+char *nst_title_from_mime_types (const char **mimetypes,
+ guint num_files);
+
diff --git a/src/test-mimetype.c b/src/test-mimetype.c
new file mode 100644
index 0000000..ee1d44a
--- /dev/null
+++ b/src/test-mimetype.c
@@ -0,0 +1,50 @@
+
+#include "config.h"
+
+#include <locale.h>
+#include <glib.h>
+#include <glib-object.h>
+#include <glib/gi18n.h>
+
+#include "nautilus-sendto-mimetype.h"
+
+typedef struct {
+ const char **mimetypes;
+ guint num_files;
+ const char *result;
+} TitleTests;
+
+static TitleTests titles[] = {
+ {
+ { "application/octet-stream", NULL },
+ 1,
+ "Sharing one file",
+ },
+};
+
+static void
+test_name (void)
+{
+ guint i;
+
+ for (i = 0; i < G_N_ELEMENTS (titles); i++) {
+ g_assert_cmpstr (nst_title_from_mime_types (titles[i].mimetypes, titles[i].num_files), ==, titles[i].result);
+ }
+}
+
+int main (int argc, char **argv)
+{
+ bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR);
+ bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+ textdomain (GETTEXT_PACKAGE);
+
+ setlocale (LC_ALL, "en_US.UTF-8");
+
+ g_type_init ();
+ g_test_init (&argc, &argv, NULL);
+ g_test_bug_base ("http://bugzilla.gnome.org/show_bug.cgi?id=");
+
+ g_test_add_func ("/mimetype/name", test_name);
+
+ return g_test_run ();
+}