Commit a4b3ab79 authored by Robin Stocker's avatar Robin Stocker

Include movie title in suggested name of gallery

Also make it use "Gallery" instead of "Screenshot".

https://bugzilla.gnome.org/show_bug.cgi?id=595760
parent 91b9cebd
......@@ -68,7 +68,7 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
TotemGallery *gallery;
GtkWidget *container;
GtkBuilder *builder;
gchar *uri, *suggested_name;
gchar *movie_title, *uri, *suggested_name;
GFile *file;
/* Create the gallery and its interface */
......@@ -105,8 +105,15 @@ totem_gallery_new (Totem *totem, TotemPlugin *plugin)
"gallery_dialog_content"));
gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (gallery), container);
/* Translators: the argument is a screenshot number, used to prevent overwriting files. Just translate "Screenshot", and not the ".jpg". */
uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot%d.jpg"));
movie_title = totem_get_short_title (totem);
/* Translators: The first argument is the movie title. The second
* argument is a number which is used to prevent overwriting files.
* Just translate "Gallery", and not the ".jpg". Example:
* "Galerie-%s-%d.jpg". */
uri = totem_screenshot_plugin_setup_file_chooser (N_("Gallery-%s-%d.jpg"), movie_title);
g_free (movie_title);
file = g_file_new_for_uri (uri);
/* We can use g_file_get_basename here and be sure that it's UTF-8
* because we provided the name. */
......
......@@ -106,7 +106,7 @@ take_screenshot_action_cb (GtkAction *action, TotemScreenshotPlugin *self)
return;
}
dialog = totem_screenshot_new (TOTEM_PLUGIN (self), pixbuf);
dialog = totem_screenshot_new (priv->totem, TOTEM_PLUGIN (self), pixbuf);
gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
......@@ -294,12 +294,12 @@ impl_deactivate (TotemPlugin *plugin, TotemObject *totem)
}
static char *
make_filename_for_dir (const char *directory, const char *format)
make_filename_for_dir (const char *directory, const char *format, const char *movie_title)
{
char *fullpath, *filename;
guint i = 1;
filename = g_strdup_printf (_(format), i);
filename = g_strdup_printf (_(format), movie_title, i);
fullpath = g_build_filename (directory, filename, NULL);
while (g_file_test (fullpath, G_FILE_TEST_EXISTS) != FALSE && i < G_MAXINT) {
......@@ -307,7 +307,7 @@ make_filename_for_dir (const char *directory, const char *format)
g_free (filename);
g_free (fullpath);
filename = g_strdup_printf (_(format), i);
filename = g_strdup_printf (_(format), movie_title, i);
fullpath = g_build_filename (directory, filename, NULL);
}
......@@ -317,7 +317,7 @@ make_filename_for_dir (const char *directory, const char *format)
}
gchar *
totem_screenshot_plugin_setup_file_chooser (const char *filename_format)
totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const char *movie_title)
{
GConfClient *client;
char *path, *filename, *full, *uri;
......@@ -337,7 +337,7 @@ totem_screenshot_plugin_setup_file_chooser (const char *filename_format)
path = g_strdup (g_get_home_dir ());
}
filename = make_filename_for_dir (path, filename_format);
filename = make_filename_for_dir (path, filename_format, movie_title);
/* Build the URI */
full = g_build_filename (path, filename, NULL);
......
......@@ -56,7 +56,7 @@ typedef struct {
GType totem_screenshot_plugin_get_type (void) G_GNUC_CONST;
G_MODULE_EXPORT GType register_totem_plugin (GTypeModule *module);
gchar *totem_screenshot_plugin_setup_file_chooser (const char *filename_format) G_GNUC_WARN_UNUSED_RESULT;
gchar *totem_screenshot_plugin_setup_file_chooser (const char *filename_format, const char *movie_name) G_GNUC_WARN_UNUSED_RESULT;
void totem_screenshot_plugin_update_file_chooser (const char *filename);
G_END_DECLS
......
......@@ -145,16 +145,19 @@ totem_screenshot_init (TotemScreenshot *screenshot)
}
GtkWidget *
totem_screenshot_new (TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image)
totem_screenshot_new (Totem *totem, TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image)
{
TotemScreenshot *screenshot;
GtkContainer *content_area;
char *interface_path, *initial_uri;
gchar *movie_title, *interface_path, *initial_uri;
screenshot = TOTEM_SCREENSHOT (g_object_new (TOTEM_TYPE_SCREENSHOT, NULL));
movie_title = totem_get_short_title (totem);
/* Create the screenshot widget */
initial_uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot%d.png"));
initial_uri = totem_screenshot_plugin_setup_file_chooser (N_("Screenshot-%s-%d.png"), movie_title);
g_free (movie_title);
interface_path = totem_plugin_find_file (screenshot_plugin, "gnome-screenshot.ui");
screenshot->priv->widget = GNOME_SCREENSHOT_WIDGET (gnome_screenshot_widget_new (interface_path, screen_image, initial_uri));
g_free (interface_path);
......
......@@ -54,7 +54,7 @@ struct TotemScreenshotClass {
};
GType totem_screenshot_get_type (void) G_GNUC_CONST;
GtkWidget *totem_screenshot_new (TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image) G_GNUC_WARN_UNUSED_RESULT;
GtkWidget *totem_screenshot_new (Totem *totem, TotemPlugin *screenshot_plugin, GdkPixbuf *screen_image) G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment