[frogr] Add support for allowing the user decide whether to remove file extensions (#644797)
- From: Mario Sanchez Prada <msanchez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [frogr] Add support for allowing the user decide whether to remove file extensions (#644797)
- Date: Thu, 21 Apr 2011 22:58:10 +0000 (UTC)
commit ac4e20f323293fa4efbd13780c70cfe59a986657
Author: Mario Sanchez Prada <msanchez igalia com>
Date: Fri Apr 22 00:57:25 2011 +0200
Add support for allowing the user decide whether to remove file extensions (#644797)
https://bugzilla.gnome.org/show_bug.cgi?id=644797
src/frogr-config.c | 31 +++++++++++++++++++++++++++++++
src/frogr-config.h | 4 ++++
src/frogr-picture-loader.c | 14 +++++++++-----
src/frogr-settings-dialog.c | 25 ++++++++++++++++++++++++-
4 files changed, 68 insertions(+), 6 deletions(-)
---
diff --git a/src/frogr-config.c b/src/frogr-config.c
index 25a8cfe..f2133a5 100644
--- a/src/frogr-config.c
+++ b/src/frogr-config.c
@@ -59,6 +59,7 @@ struct _FrogrConfigPrivate
FspContentType content_type;
gboolean tags_autocompletion;
+ gboolean remove_extensions;
gboolean use_proxy;
gchar *proxy_host;
@@ -215,6 +216,16 @@ _load_settings (FrogrConfig *self, const gchar *config_dir)
xmlFree (content);
}
+ if (!xmlStrcmp (node->name, (const xmlChar*) "remove-extensions"))
+ {
+ xmlChar *content = NULL;
+
+ content = xmlNodeGetContent (node);
+ priv->remove_extensions = !xmlStrcmp (content, (const xmlChar*) "1");
+
+ xmlFree (content);
+ }
+
if (!xmlStrcmp (node->name, (const xmlChar*) "default-visibility"))
_load_visibility_xml (self, xml, node);
@@ -536,6 +547,7 @@ _save_settings (FrogrConfig *self)
/* Other stuff */
_xml_add_string_child (root, "tags-autocompletion", priv->tags_autocompletion ? "1" : "0");
+ _xml_add_string_child (root, "remove-extensions", priv->remove_extensions ? "1" : "0");
/* Use proxy */
node = xmlNewNode (NULL, (const xmlChar*) "http-proxy");
@@ -760,6 +772,7 @@ frogr_config_init (FrogrConfig *self)
priv->safety_level = FSP_SAFETY_LEVEL_SAFE;
priv->content_type = FSP_CONTENT_TYPE_PHOTO;
priv->tags_autocompletion = TRUE;
+ priv->remove_extensions = TRUE;
priv->use_proxy = FALSE;
priv->proxy_host = NULL;
priv->proxy_port = NULL;
@@ -1041,6 +1054,24 @@ frogr_config_get_tags_autocompletion (FrogrConfig *self)
}
void
+frogr_config_set_remove_extensions (FrogrConfig *self, gboolean value)
+{
+ g_return_if_fail (FROGR_IS_CONFIG (self));
+
+ FrogrConfigPrivate * priv = FROGR_CONFIG_GET_PRIVATE (self);
+ priv->remove_extensions = value;
+}
+
+gboolean
+frogr_config_get_remove_extensions (FrogrConfig *self)
+{
+ g_return_val_if_fail (FROGR_IS_CONFIG (self), FALSE);
+
+ FrogrConfigPrivate *priv = FROGR_CONFIG_GET_PRIVATE (self);
+ return priv->remove_extensions;
+}
+
+void
frogr_config_set_use_proxy (FrogrConfig *self, gboolean value)
{
g_return_if_fail (FROGR_IS_CONFIG (self));
diff --git a/src/frogr-config.h b/src/frogr-config.h
index 50a8436..9675e9c 100644
--- a/src/frogr-config.h
+++ b/src/frogr-config.h
@@ -106,6 +106,10 @@ void frogr_config_set_tags_autocompletion (FrogrConfig *self, gboolean value);
gboolean frogr_config_get_tags_autocompletion (FrogrConfig *self);
+void frogr_config_set_remove_extensions (FrogrConfig *self, gboolean value);
+
+gboolean frogr_config_get_remove_extensions (FrogrConfig *self);
+
void frogr_config_set_use_proxy (FrogrConfig *self, gboolean value);
gboolean frogr_config_get_use_proxy (FrogrConfig *self);
diff --git a/src/frogr-picture-loader.c b/src/frogr-picture-loader.c
index 36eb2af..2340abd 100644
--- a/src/frogr-picture-loader.c
+++ b/src/frogr-picture-loader.c
@@ -234,7 +234,6 @@ _load_next_picture_cb (GObject *object,
GFileInfo* file_info;
gchar *file_uri;
gchar *file_name;
- gchar *extension_dot;
/* Gather needed information */
file_info = g_file_query_info (file, G_FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME,
@@ -253,10 +252,15 @@ _load_next_picture_cb (GObject *object,
if (file_info)
g_object_unref (file_info);
- /* Remove extension if present */
- extension_dot = g_strrstr (file_name, ".");
- if (extension_dot)
- *extension_dot = '\0';
+ if (frogr_config_get_remove_extensions (priv->config))
+ {
+ gchar *extension_dot;
+
+ /* Remove extension if present */
+ extension_dot = g_strrstr (file_name, ".");
+ if (extension_dot)
+ *extension_dot = '\0';
+ }
file_uri = g_file_get_uri (file);
gdk_pixbuf_loader_close (pixbuf_loader, NULL);
diff --git a/src/frogr-settings-dialog.c b/src/frogr-settings-dialog.c
index c25741a..f895cd2 100644
--- a/src/frogr-settings-dialog.c
+++ b/src/frogr-settings-dialog.c
@@ -54,6 +54,7 @@ typedef struct _FrogrSettingsDialogPrivate {
GtkWidget *moderate_rb;
GtkWidget *restricted_rb;
GtkWidget *tags_autocompletion_cb;
+ GtkWidget *remove_extensions_cb;
GtkWidget *use_proxy_cb;
GtkWidget *proxy_host_label;
@@ -70,6 +71,7 @@ typedef struct _FrogrSettingsDialogPrivate {
gboolean friend_visibility;
gboolean show_in_search;
gboolean tags_autocompletion;
+ gboolean remove_extensions;
FspSafetyLevel safety_level;
FspContentType content_type;
@@ -288,9 +290,17 @@ _add_general_page (FrogrSettingsDialog *self, GtkNotebook *notebook)
gtk_box_pack_start (GTK_BOX (box1), cbutton, FALSE, FALSE, 0);
priv->tags_autocompletion_cb = cbutton;
+ g_signal_connect (G_OBJECT (priv->tags_autocompletion_cb), "toggled",
+ G_CALLBACK (_on_button_toggled),
+ self);
+
+ cbutton = gtk_check_button_new_with_mnemonic (_("Remo_ve file extensions before upload"));
+ gtk_box_pack_start (GTK_BOX (box1), cbutton, FALSE, FALSE, 0);
+ priv->remove_extensions_cb = cbutton;
+
gtk_box_pack_start (GTK_BOX (vbox), box1, FALSE, FALSE, 0);
- g_signal_connect (G_OBJECT (priv->tags_autocompletion_cb), "toggled",
+ g_signal_connect (G_OBJECT (priv->remove_extensions_cb), "toggled",
G_CALLBACK (_on_button_toggled),
self);
@@ -424,6 +434,7 @@ _fill_dialog_with_data (FrogrSettingsDialog *self)
priv->content_type = frogr_config_get_default_content_type (priv->config);
priv->safety_level = frogr_config_get_default_safety_level (priv->config);
priv->tags_autocompletion = frogr_config_get_tags_autocompletion (priv->config);
+ priv->remove_extensions = frogr_config_get_remove_extensions (priv->config);
priv->use_proxy = frogr_config_get_use_proxy (priv->config);
g_free (priv->proxy_host);
@@ -476,6 +487,9 @@ _fill_dialog_with_data (FrogrSettingsDialog *self)
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->tags_autocompletion_cb),
priv->tags_autocompletion);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->remove_extensions_cb),
+ priv->remove_extensions);
+
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->use_proxy_cb),
priv->use_proxy);
if (priv->proxy_host)
@@ -510,6 +524,7 @@ _save_data (FrogrSettingsDialog *self)
frogr_config_set_default_safety_level (priv->config, priv->safety_level);
frogr_config_set_tags_autocompletion (priv->config, priv->tags_autocompletion);
+ frogr_config_set_remove_extensions (priv->config, priv->remove_extensions);
frogr_config_set_use_proxy (priv->config, priv->use_proxy);
@@ -641,6 +656,12 @@ _on_button_toggled (GtkToggleButton *button, gpointer data)
DEBUG ("Enable tags autocompletion set to %s", active ? "TRUE" : "FALSE");
}
+ if (GTK_WIDGET (button) == priv->remove_extensions_cb)
+ {
+ priv->remove_extensions = active;
+ DEBUG ("Enable tags autocompletion set to %s", active ? "TRUE" : "FALSE");
+ }
+
if (GTK_WIDGET (button) == priv->use_proxy_cb)
{
priv->use_proxy = active;
@@ -764,6 +785,7 @@ frogr_settings_dialog_init (FrogrSettingsDialog *self)
priv->moderate_rb = NULL;
priv->restricted_rb = NULL;
priv->tags_autocompletion_cb = NULL;
+ priv->remove_extensions_cb = NULL;
priv->use_proxy_cb = NULL;
priv->proxy_host_label = NULL;
priv->proxy_host_entry = NULL;
@@ -780,6 +802,7 @@ frogr_settings_dialog_init (FrogrSettingsDialog *self)
priv->safety_level = FSP_SAFETY_LEVEL_NONE;
priv->content_type = FSP_CONTENT_TYPE_NONE;
priv->tags_autocompletion = FALSE;
+ priv->remove_extensions = FALSE;
priv->use_proxy = FALSE;
priv->proxy_host = NULL;
priv->proxy_port = NULL;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]