[Xfce4-commits] <thunar:master> Fix compiler warnings in plugins.
Nick Schermer
nick at xfce.org
Fri Aug 21 23:02:01 CEST 2009
Updating branch refs/heads/master
to f074d6cc730ca77617b94723a9bf7d3793554c19 (commit)
from 0b98190d44c6efb7777658c2f1a649a0fcd4b16c (commit)
commit f074d6cc730ca77617b94723a9bf7d3793554c19
Author: Nick Schermer <nick at xfce.org>
Date: Fri Aug 21 23:01:15 2009 +0200
Fix compiler warnings in plugins.
Also refactor the wallpaper plugin code a bit, so it
matches the thunar coding style.
plugins/thunar-apr/thunar-apr-abstract-page.c | 2 -
plugins/thunar-apr/thunar-apr-desktop-page.c | 2 -
plugins/thunar-apr/thunar-apr-image-page.c | 2 -
plugins/thunar-apr/thunar-apr-plugin.c | 7 +
plugins/thunar-apr/thunar-apr-provider.c | 2 -
plugins/thunar-sbr/thunar-sbr-case-renamer.c | 6 +-
plugins/thunar-sbr/thunar-sbr-date-renamer.c | 12 +-
plugins/thunar-sbr/thunar-sbr-insert-renamer.c | 6 +-
plugins/thunar-sbr/thunar-sbr-number-renamer.c | 18 +-
plugins/thunar-sbr/thunar-sbr-plugin.c | 7 +
plugins/thunar-sbr/thunar-sbr-provider.c | 2 -
plugins/thunar-sbr/thunar-sbr-remove-renamer.c | 6 +-
plugins/thunar-sbr/thunar-sbr-replace-renamer.c | 16 +-
plugins/thunar-sendto-email/main.c | 8 +-
plugins/thunar-uca/thunar-uca-chooser.c | 2 -
plugins/thunar-uca/thunar-uca-editor.c | 2 -
plugins/thunar-uca/thunar-uca-model.c | 10 +-
plugins/thunar-uca/thunar-uca-plugin.c | 7 +
plugins/thunar-uca/thunar-uca-provider.c | 2 -
plugins/thunar-wallpaper/thunar-wallpaper-plugin.c | 7 +
plugins/thunar-wallpaper/twp-provider.c | 320 ++++++++++----------
21 files changed, 216 insertions(+), 230 deletions(-)
diff --git a/plugins/thunar-apr/thunar-apr-abstract-page.c b/plugins/thunar-apr/thunar-apr-abstract-page.c
index 1766c36..e16075e 100644
--- a/plugins/thunar-apr/thunar-apr-abstract-page.c
+++ b/plugins/thunar-apr/thunar-apr-abstract-page.c
@@ -43,8 +43,6 @@ enum
-static void thunar_apr_abstract_page_class_init (ThunarAprAbstractPageClass *klass);
-static void thunar_apr_abstract_page_init (ThunarAprAbstractPage *abstract_page);
static void thunar_apr_abstract_page_dispose (GObject *object);
static void thunar_apr_abstract_page_get_property (GObject *object,
guint prop_id,
diff --git a/plugins/thunar-apr/thunar-apr-desktop-page.c b/plugins/thunar-apr/thunar-apr-desktop-page.c
index d0d345f..b99bad8 100644
--- a/plugins/thunar-apr/thunar-apr-desktop-page.c
+++ b/plugins/thunar-apr/thunar-apr-desktop-page.c
@@ -49,8 +49,6 @@
-static void thunar_apr_desktop_page_class_init (ThunarAprDesktopPageClass *klass);
-static void thunar_apr_desktop_page_init (ThunarAprDesktopPage *desktop_page);
static void thunar_apr_desktop_page_finalize (GObject *object);
static void thunar_apr_desktop_page_file_changed (ThunarAprAbstractPage *abstract_page,
ThunarxFileInfo *file);
diff --git a/plugins/thunar-apr/thunar-apr-image-page.c b/plugins/thunar-apr/thunar-apr-image-page.c
index 148f8da..b9fd7e6 100644
--- a/plugins/thunar-apr/thunar-apr-image-page.c
+++ b/plugins/thunar-apr/thunar-apr-image-page.c
@@ -32,8 +32,6 @@
-static void thunar_apr_image_page_class_init (ThunarAprImagePageClass *klass);
-static void thunar_apr_image_page_init (ThunarAprImagePage *image_page);
static void thunar_apr_image_page_file_changed (ThunarAprAbstractPage *abstract_page,
ThunarxFileInfo *file);
diff --git a/plugins/thunar-apr/thunar-apr-plugin.c b/plugins/thunar-apr/thunar-apr-plugin.c
index aaad310..11cf955 100644
--- a/plugins/thunar-apr/thunar-apr-plugin.c
+++ b/plugins/thunar-apr/thunar-apr-plugin.c
@@ -29,6 +29,13 @@
+G_MODULE_EXPORT void thunar_extension_initialize (ThunarxProviderPlugin *plugin);
+G_MODULE_EXPORT void thunar_extension_shutdown (void);
+G_MODULE_EXPORT void thunar_extension_list_types (const GType **types,
+ gint *n_types);
+
+
+
static GType type_list[1];
diff --git a/plugins/thunar-apr/thunar-apr-provider.c b/plugins/thunar-apr/thunar-apr-provider.c
index cd3b15d..66c3b0a 100644
--- a/plugins/thunar-apr/thunar-apr-provider.c
+++ b/plugins/thunar-apr/thunar-apr-provider.c
@@ -35,9 +35,7 @@
-static void thunar_apr_provider_class_init (ThunarAprProviderClass *klass);
static void thunar_apr_provider_property_page_provider_init (ThunarxPropertyPageProviderIface *iface);
-static void thunar_apr_provider_init (ThunarAprProvider *apr_provider);
static GList *thunar_apr_provider_get_pages (ThunarxPropertyPageProvider *property_page_provider,
GList *files);
diff --git a/plugins/thunar-sbr/thunar-sbr-case-renamer.c b/plugins/thunar-sbr/thunar-sbr-case-renamer.c
index 60596dc..9f8f2e8 100644
--- a/plugins/thunar-sbr/thunar-sbr-case-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-case-renamer.c
@@ -37,8 +37,6 @@ enum
-static void thunar_sbr_case_renamer_class_init (ThunarSbrCaseRenamerClass *klass);
-static void thunar_sbr_case_renamer_init (ThunarSbrCaseRenamer *case_renamer);
static void thunar_sbr_case_renamer_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -50,7 +48,7 @@ static void thunar_sbr_case_renamer_set_property (GObject
static gchar *thunar_sbr_case_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index);
+ guint idx);
@@ -227,7 +225,7 @@ static gchar*
thunar_sbr_case_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index)
+ guint idx)
{
ThunarSbrCaseRenamer *case_renamer = THUNAR_SBR_CASE_RENAMER (renamer);
diff --git a/plugins/thunar-sbr/thunar-sbr-date-renamer.c b/plugins/thunar-sbr/thunar-sbr-date-renamer.c
index 688d105..8f0deaa 100644
--- a/plugins/thunar-sbr/thunar-sbr-date-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-date-renamer.c
@@ -56,8 +56,6 @@ enum
-static void thunar_sbr_date_renamer_class_init (ThunarSbrDateRenamerClass *klass);
-static void thunar_sbr_date_renamer_init (ThunarSbrDateRenamer *date_renamer);
static void thunar_sbr_date_renamer_finalize (GObject *object);
static void thunar_sbr_date_renamer_get_property (GObject *object,
guint prop_id,
@@ -77,7 +75,7 @@ static guint64 thunar_sbr_get_time (ThunarxFileInfo *
static gchar *thunar_sbr_date_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index);
+ guint idx);
@@ -366,15 +364,15 @@ thunar_sbr_get_time_string (guint64 file_time,
const gchar *format)
{
struct tm *tm;
- time_t time;
+ time_t _time;
gchar *converted;
gchar buffer[1024];
gint length;
- time = (time_t) file_time;
+ _time = (time_t) file_time;
/* determine the local file time */
- tm = localtime (&time);
+ tm = localtime (&_time);
/* conver the format to the current locale */
converted = g_locale_from_utf8 (format, -1, NULL, NULL, NULL);
@@ -535,7 +533,7 @@ static gchar*
thunar_sbr_date_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index)
+ guint idx)
{
ThunarSbrDateRenamer *date_renamer = THUNAR_SBR_DATE_RENAMER (renamer);
gchar *string;
diff --git a/plugins/thunar-sbr/thunar-sbr-insert-renamer.c b/plugins/thunar-sbr/thunar-sbr-insert-renamer.c
index f2a9c94..88d49a8 100644
--- a/plugins/thunar-sbr/thunar-sbr-insert-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-insert-renamer.c
@@ -40,8 +40,6 @@ enum
-static void thunar_sbr_insert_renamer_class_init (ThunarSbrInsertRenamerClass *klass);
-static void thunar_sbr_insert_renamer_init (ThunarSbrInsertRenamer *insert_renamer);
static void thunar_sbr_insert_renamer_finalize (GObject *object);
static void thunar_sbr_insert_renamer_get_property (GObject *object,
guint prop_id,
@@ -54,7 +52,7 @@ static void thunar_sbr_insert_renamer_set_property (GObject
static gchar *thunar_sbr_insert_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index);
+ guint idx);
@@ -323,7 +321,7 @@ static gchar*
thunar_sbr_insert_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index)
+ guint idx)
{
ThunarSbrInsertRenamer *insert_renamer = THUNAR_SBR_INSERT_RENAMER (renamer);
const gchar *t;
diff --git a/plugins/thunar-sbr/thunar-sbr-number-renamer.c b/plugins/thunar-sbr/thunar-sbr-number-renamer.c
index ec0476e..52d8fd8 100644
--- a/plugins/thunar-sbr/thunar-sbr-number-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-number-renamer.c
@@ -50,8 +50,6 @@ enum
-static void thunar_sbr_number_renamer_class_init (ThunarSbrNumberRenamerClass *klass);
-static void thunar_sbr_number_renamer_init (ThunarSbrNumberRenamer *number_renamer);
static void thunar_sbr_number_renamer_finalize (GObject *object);
static void thunar_sbr_number_renamer_get_property (GObject *object,
guint prop_id,
@@ -65,7 +63,7 @@ static void thunar_sbr_number_renamer_realize (GtkWidget
static gchar *thunar_sbr_number_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index);
+ guint idx);
static void thunar_sbr_number_renamer_update (ThunarSbrNumberRenamer *number_renamer);
@@ -371,7 +369,7 @@ static gchar*
thunar_sbr_number_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index)
+ guint idx)
{
ThunarSbrNumberRenamer *number_renamer = THUNAR_SBR_NUMBER_RENAMER (renamer);
gboolean invalid = TRUE;
@@ -404,26 +402,26 @@ thunar_sbr_number_renamer_process (ThunarxRenamer *renamer,
switch (number_renamer->mode)
{
case THUNAR_SBR_NUMBER_MODE_123:
- number = g_strdup_printf ("%u", start + index);
+ number = g_strdup_printf ("%u", start + idx);
break;
case THUNAR_SBR_NUMBER_MODE_010203:
- number = g_strdup_printf ("%02u", start + index);
+ number = g_strdup_printf ("%02u", start + idx);
break;
case THUNAR_SBR_NUMBER_MODE_001002003:
- number = g_strdup_printf ("%03u", start + index);
+ number = g_strdup_printf ("%03u", start + idx);
break;
case THUNAR_SBR_NUMBER_MODE_000100020003:
- number = g_strdup_printf ("%04u", start + index);
+ number = g_strdup_printf ("%04u", start + idx);
break;
case THUNAR_SBR_NUMBER_MODE_ABC:
if (start >= 'a' && start <= 'z')
- number = g_strdup_printf ("%c", (gchar) (MIN (start + index, 'z')));
+ number = g_strdup_printf ("%c", (gchar) (MIN (start + idx, 'z')));
else if (start >= 'A' && start <= 'Z')
- number = g_strdup_printf ("%c", (gchar) (MIN (start + index, 'Z')));
+ number = g_strdup_printf ("%c", (gchar) (MIN (start + idx, 'Z')));
else
g_assert_not_reached ();
break;
diff --git a/plugins/thunar-sbr/thunar-sbr-plugin.c b/plugins/thunar-sbr/thunar-sbr-plugin.c
index 49dd143..5ae8f72 100644
--- a/plugins/thunar-sbr/thunar-sbr-plugin.c
+++ b/plugins/thunar-sbr/thunar-sbr-plugin.c
@@ -32,6 +32,13 @@
+G_MODULE_EXPORT void thunar_extension_initialize (ThunarxProviderPlugin *plugin);
+G_MODULE_EXPORT void thunar_extension_shutdown (void);
+G_MODULE_EXPORT void thunar_extension_list_types (const GType **types,
+ gint *n_types);
+
+
+
static GType type_list[1];
diff --git a/plugins/thunar-sbr/thunar-sbr-provider.c b/plugins/thunar-sbr/thunar-sbr-provider.c
index 1083a98..57ecf9b 100644
--- a/plugins/thunar-sbr/thunar-sbr-provider.c
+++ b/plugins/thunar-sbr/thunar-sbr-provider.c
@@ -32,9 +32,7 @@
-static void thunar_sbr_provider_class_init (ThunarSbrProviderClass *klass);
static void thunar_sbr_provider_renamer_provider_init (ThunarxRenamerProviderIface *iface);
-static void thunar_sbr_provider_init (ThunarSbrProvider *sbr_provider);
static GList *thunar_sbr_provider_get_renamers (ThunarxRenamerProvider *renamer_provider);
diff --git a/plugins/thunar-sbr/thunar-sbr-remove-renamer.c b/plugins/thunar-sbr/thunar-sbr-remove-renamer.c
index 4a5cd5e..42261a5 100644
--- a/plugins/thunar-sbr/thunar-sbr-remove-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-remove-renamer.c
@@ -40,8 +40,6 @@ enum
-static void thunar_sbr_remove_renamer_class_init (ThunarSbrRemoveRenamerClass *klass);
-static void thunar_sbr_remove_renamer_init (ThunarSbrRemoveRenamer *remove_renamer);
static void thunar_sbr_remove_renamer_get_property (GObject *object,
guint prop_id,
GValue *value,
@@ -54,7 +52,7 @@ static void thunar_sbr_remove_renamer_realize (GtkWidget
static gchar *thunar_sbr_remove_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index);
+ guint idx);
static void thunar_sbr_remove_renamer_update (ThunarSbrRemoveRenamer *remove_renamer);
@@ -331,7 +329,7 @@ static gchar*
thunar_sbr_remove_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index)
+ guint idx)
{
ThunarSbrRemoveRenamer *remove_renamer = THUNAR_SBR_REMOVE_RENAMER (renamer);
const gchar *start_pointer;
diff --git a/plugins/thunar-sbr/thunar-sbr-replace-renamer.c b/plugins/thunar-sbr/thunar-sbr-replace-renamer.c
index 0f74de0..8774fbd 100644
--- a/plugins/thunar-sbr/thunar-sbr-replace-renamer.c
+++ b/plugins/thunar-sbr/thunar-sbr-replace-renamer.c
@@ -51,8 +51,6 @@ enum
-static void thunar_sbr_replace_renamer_class_init (ThunarSbrReplaceRenamerClass *klass);
-static void thunar_sbr_replace_renamer_init (ThunarSbrReplaceRenamer *replace_renamer);
static void thunar_sbr_replace_renamer_finalize (GObject *object);
static void thunar_sbr_replace_renamer_get_property (GObject *object,
guint prop_id,
@@ -66,7 +64,7 @@ static void thunar_sbr_replace_renamer_realize (GtkWidget
static gchar *thunar_sbr_replace_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index);
+ guint idx);
#ifdef HAVE_PCRE
static gchar *thunar_sbr_replace_renamer_pcre_exec (ThunarSbrReplaceRenamer *replace_renamer,
const gchar *text);
@@ -422,7 +420,7 @@ static gchar*
thunar_sbr_replace_renamer_process (ThunarxRenamer *renamer,
ThunarxFileInfo *file,
const gchar *text,
- guint index)
+ guint idx)
{
ThunarSbrReplaceRenamer *replace_renamer = THUNAR_SBR_REPLACE_RENAMER (renamer);
@@ -458,7 +456,7 @@ thunar_sbr_replace_renamer_pcre_exec (ThunarSbrReplaceRenamer *replace_renamer,
GString *result;
gint second;
gint first;
- gint index;
+ gint idx;
gint *ovec;
gint olen;
gint rc;
@@ -532,11 +530,11 @@ thunar_sbr_replace_renamer_pcre_exec (ThunarSbrReplaceRenamer *replace_renamer,
else if (g_ascii_isdigit (r[0]))
{
/* \<num> and $<num> is replaced with the <num>th subpattern */
- index = (r[0] - '0');
- if (G_LIKELY (index >= 0 && index < rc))
+ idx = (r[0] - '0');
+ if (G_LIKELY (idx >= 0 && idx < rc))
{
- first = ovec[2 * index];
- second = ovec[2 * index + 1];
+ first = ovec[2 * idx];
+ second = ovec[2 * idx + 1];
}
}
else if (r[-1] == r[0])
diff --git a/plugins/thunar-sendto-email/main.c b/plugins/thunar-sendto-email/main.c
index 8edef40..c6e8f11 100644
--- a/plugins/thunar-sendto-email/main.c
+++ b/plugins/thunar-sendto-email/main.c
@@ -390,7 +390,7 @@ tse_compress (GList *infos,
GFile *parent;
GFile *parent_parent;
gchar **argv;
- gchar *basename;
+ gchar *base_name;
gchar *zipfile;
gchar *tmppath;
gchar *tmpdir;
@@ -437,9 +437,9 @@ tse_compress (GList *infos,
if (parent_parent != NULL)
{
/* use the parent directory's name */
- basename = g_file_get_basename (parent);
- zipfile = g_strconcat (tmpdir, G_DIR_SEPARATOR_S, basename, ".zip", NULL);
- g_free (basename);
+ base_name = g_file_get_basename (parent);
+ zipfile = g_strconcat (tmpdir, G_DIR_SEPARATOR_S, base_name, ".zip", NULL);
+ g_free (base_name);
g_object_unref (parent_parent);
}
diff --git a/plugins/thunar-uca/thunar-uca-chooser.c b/plugins/thunar-uca/thunar-uca-chooser.c
index c97e711..1aa9c6b 100644
--- a/plugins/thunar-uca/thunar-uca-chooser.c
+++ b/plugins/thunar-uca/thunar-uca-chooser.c
@@ -32,8 +32,6 @@
-static void thunar_uca_chooser_class_init (ThunarUcaChooserClass *klass);
-static void thunar_uca_chooser_init (ThunarUcaChooser *uca_chooser);
static void thunar_uca_chooser_finalize (GObject *object);
static gboolean thunar_uca_chooser_key_press_event (GtkWidget *widget,
GdkEventKey *event);
diff --git a/plugins/thunar-uca/thunar-uca-editor.c b/plugins/thunar-uca/thunar-uca-editor.c
index 6bca904..aaa0617 100644
--- a/plugins/thunar-uca/thunar-uca-editor.c
+++ b/plugins/thunar-uca/thunar-uca-editor.c
@@ -35,8 +35,6 @@
-static void thunar_uca_editor_class_init (ThunarUcaEditorClass *klass);
-static void thunar_uca_editor_init (ThunarUcaEditor *uca_editor);
static void thunar_uca_editor_finalize (GObject *object);
static const gchar *thunar_uca_editor_get_icon_name (const ThunarUcaEditor *uca_editor);
static void thunar_uca_editor_set_icon_name (ThunarUcaEditor *uca_editor,
diff --git a/plugins/thunar-uca/thunar-uca-model.c b/plugins/thunar-uca/thunar-uca-model.c
index 0eaaa3a..822c8a2 100644
--- a/plugins/thunar-uca/thunar-uca-model.c
+++ b/plugins/thunar-uca/thunar-uca-model.c
@@ -86,9 +86,7 @@ typedef enum
-static void thunar_uca_model_class_init (ThunarUcaModelClass *klass);
static void thunar_uca_model_tree_model_init (GtkTreeModelIface *iface);
-static void thunar_uca_model_init (ThunarUcaModel *uca_model);
static void thunar_uca_model_finalize (GObject *object);
static GtkTreeModelFlags thunar_uca_model_get_flags (GtkTreeModel *tree_model);
static gint thunar_uca_model_get_n_columns (GtkTreeModel *tree_model);
@@ -369,17 +367,17 @@ thunar_uca_model_get_path (GtkTreeModel *tree_model,
GtkTreeIter *iter)
{
ThunarUcaModel *uca_model = THUNAR_UCA_MODEL (tree_model);
- gint index;
+ gint idx;
g_return_val_if_fail (THUNAR_UCA_IS_MODEL (uca_model), NULL);
g_return_val_if_fail (iter->stamp == uca_model->stamp, NULL);
/* determine the index of the iter */
- index = g_list_position (uca_model->items, iter->user_data);
- if (G_UNLIKELY (index < 0))
+ idx = g_list_position (uca_model->items, iter->user_data);
+ if (G_UNLIKELY (idx < 0))
return NULL;
- return gtk_tree_path_new_from_indices (index, -1);
+ return gtk_tree_path_new_from_indices (idx, -1);
}
diff --git a/plugins/thunar-uca/thunar-uca-plugin.c b/plugins/thunar-uca/thunar-uca-plugin.c
index 3231321..5ee6d21 100644
--- a/plugins/thunar-uca/thunar-uca-plugin.c
+++ b/plugins/thunar-uca/thunar-uca-plugin.c
@@ -29,6 +29,13 @@
+G_MODULE_EXPORT void thunar_extension_initialize (ThunarxProviderPlugin *plugin);
+G_MODULE_EXPORT void thunar_extension_shutdown (void);
+G_MODULE_EXPORT void thunar_extension_list_types (const GType **types,
+ gint *n_types);
+
+
+
static GType type_list[1];
diff --git a/plugins/thunar-uca/thunar-uca-provider.c b/plugins/thunar-uca/thunar-uca-provider.c
index 217e553..63bae6c 100644
--- a/plugins/thunar-uca/thunar-uca-provider.c
+++ b/plugins/thunar-uca/thunar-uca-provider.c
@@ -34,10 +34,8 @@
-static void thunar_uca_provider_class_init (ThunarUcaProviderClass *klass);
static void thunar_uca_provider_menu_provider_init (ThunarxMenuProviderIface *iface);
static void thunar_uca_provider_preferences_provider_init (ThunarxPreferencesProviderIface *iface);
-static void thunar_uca_provider_init (ThunarUcaProvider *uca_provider);
static void thunar_uca_provider_finalize (GObject *object);
static GList *thunar_uca_provider_get_actions (ThunarxPreferencesProvider *preferences_provider,
GtkWidget *window);
diff --git a/plugins/thunar-wallpaper/thunar-wallpaper-plugin.c b/plugins/thunar-wallpaper/thunar-wallpaper-plugin.c
index 7d6ef37..db93f81 100644
--- a/plugins/thunar-wallpaper/thunar-wallpaper-plugin.c
+++ b/plugins/thunar-wallpaper/thunar-wallpaper-plugin.c
@@ -28,6 +28,13 @@
+G_MODULE_EXPORT void thunar_extension_initialize (ThunarxProviderPlugin *plugin);
+G_MODULE_EXPORT void thunar_extension_shutdown (void);
+G_MODULE_EXPORT void thunar_extension_list_types (const GType **types,
+ gint *n_types);
+
+
+
static GType type_list[1];
diff --git a/plugins/thunar-wallpaper/twp-provider.c b/plugins/thunar-wallpaper/twp-provider.c
index f510b38..f8c8e8c 100644
--- a/plugins/thunar-wallpaper/twp-provider.c
+++ b/plugins/thunar-wallpaper/twp-provider.c
@@ -36,30 +36,29 @@
#define XFDESKTOP_SELECTION_FMT "XFDESKTOP_SELECTION_%d"
#define NAUTILUS_SELECTION_FMT "NAUTILUS_DESKTOP_WINDOW_ID"
-static gboolean _has_xfconf_query = FALSE;
-static gboolean _has_gconftool = FALSE;
-typedef enum {
- DESKTOP_TYPE_NONE,
- DESKTOP_TYPE_XFCE,
- DESKTOP_TYPE_NAUTILUS
-} DesktopType;
-
-static DesktopType desktop_type;
-
static void twp_menu_provider_init (ThunarxMenuProviderIface *iface);
-static void twp_provider_class_init (TwpProviderClass *klass);
-static void twp_provider_init (TwpProvider *twp_provider);
static void twp_provider_finalize (GObject *object);
static GList *twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
GtkWidget *window,
GList *files);
-
static void twp_action_set_wallpaper (GtkAction *action,
gpointer user_data);
-static gboolean check_cli_tools ();
+
+typedef enum
+{
+ DESKTOP_TYPE_NONE,
+ DESKTOP_TYPE_XFCE,
+ DESKTOP_TYPE_NAUTILUS
+} DesktopType;
+
+
+
+static DesktopType desktop_type = DESKTOP_TYPE_NONE;
+static gboolean _has_xfconf_query = FALSE;
+static gboolean _has_gconftool = FALSE;
@@ -78,9 +77,7 @@ struct _TwpProvider
-THUNARX_DEFINE_TYPE_WITH_CODE (TwpProvider,
- twp_provider,
- G_TYPE_OBJECT,
+THUNARX_DEFINE_TYPE_WITH_CODE (TwpProvider, twp_provider, G_TYPE_OBJECT,
THUNARX_IMPLEMENT_INTERFACE (THUNARX_TYPE_MENU_PROVIDER,
twp_menu_provider_init));
@@ -104,9 +101,25 @@ twp_provider_class_init (TwpProviderClass *klass)
static void
twp_provider_init (TwpProvider *twp_provider)
{
- check_cli_tools();
+ gchar *program;
+
+ program = g_find_program_in_path ("xfconf-query");
+ if (G_LIKELY (program != NULL))
+ {
+ _has_xfconf_query = TRUE;
+ g_free (program);
+ }
+
+ program = g_find_program_in_path ("gconftool-2");
+ if (G_LIKELY (program != NULL))
+ {
+ _has_gconftool = TRUE;
+ g_free (program);
+ }
}
+
+
static void
twp_provider_finalize (GObject *object)
{
@@ -120,74 +133,73 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
GtkWidget *window,
GList *files)
{
- GtkWidget *action = NULL;
+ GtkWidget *action = NULL;
GFile *location;
- GList *actions = NULL;
+ GList *actions = NULL;
gchar selection_name[100];
Atom xfce_selection_atom;
Atom nautilus_selection_atom;
+ GdkScreen *gdk_screen = gdk_screen_get_default();
+ gint xscreen = gdk_screen_get_number(gdk_screen);
- GdkScreen *gdk_screen = gdk_screen_get_default();
- gint xscreen = gdk_screen_get_number(gdk_screen);
+ desktop_type = DESKTOP_TYPE_NONE;
- desktop_type = DESKTOP_TYPE_NONE;
-
- /* we can only set a single wallpaper */
- if (files->next == NULL)
+ /* we can only set a single wallpaper */
+ if (files->next == NULL)
{
- /* get the location of the file */
- location = thunarx_file_info_get_location (files->data);
+ /* get the location of the file */
+ location = thunarx_file_info_get_location (files->data);
- /* unable to handle non-local files */
- if (G_UNLIKELY (!g_file_has_uri_scheme (location, "file")))
- {
- g_object_unref (location);
- return NULL;
- }
+ /* unable to handle non-local files */
+ if (G_UNLIKELY (!g_file_has_uri_scheme (location, "file")))
+ {
+ g_object_unref (location);
+ return NULL;
+ }
- /* release the location */
- g_object_unref (location);
+ /* release the location */
+ g_object_unref (location);
- if (!thunarx_file_info_is_directory (files->data))
+ if (!thunarx_file_info_is_directory (files->data))
{
- if (thunarx_file_info_has_mime_type (files->data, "image/jpeg")
+ if (thunarx_file_info_has_mime_type (files->data, "image/jpeg")
||thunarx_file_info_has_mime_type (files->data, "image/png")
||thunarx_file_info_has_mime_type (files->data, "image/svg+xml")
||thunarx_file_info_has_mime_type (files->data, "image/svg+xml-compressed"))
{
- action = g_object_new (GTK_TYPE_ACTION,
- "name", "Twp::setwallpaper",
- "icon-name", "background",
- "label", _("Set as wallpaper"),
- NULL);
- g_signal_connect (action, "activate", G_CALLBACK (twp_action_set_wallpaper), files->data);
-
- actions = g_list_append (actions, action);
+ action = g_object_new (GTK_TYPE_ACTION,
+ "name", "Twp::setwallpaper",
+ "icon-name", "background",
+ "label", _("Set as wallpaper"),
+ NULL);
+ g_signal_connect (action, "activate", G_CALLBACK (twp_action_set_wallpaper), files->data);
+
+ actions = g_list_append (actions, action);
}
}
}
- g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen);
- xfce_selection_atom = XInternAtom (gdk_display, selection_name, False);
+ g_snprintf(selection_name, 100, XFDESKTOP_SELECTION_FMT, xscreen);
+ xfce_selection_atom = XInternAtom (gdk_display, selection_name, False);
- if((XGetSelectionOwner(GDK_DISPLAY(), xfce_selection_atom)))
+ if ((XGetSelectionOwner(GDK_DISPLAY(), xfce_selection_atom)))
{
- if (_has_xfconf_query)
- desktop_type = DESKTOP_TYPE_XFCE;
+ if (_has_xfconf_query)
+ desktop_type = DESKTOP_TYPE_XFCE;
}
- else
+ else
{
- /* FIXME: This is wrong, nautilus WINDOW_ID is not a selection */
- g_snprintf(selection_name, 100, NAUTILUS_SELECTION_FMT);
- nautilus_selection_atom = XInternAtom (gdk_display, selection_name, False);
- if((XGetSelectionOwner(GDK_DISPLAY(), nautilus_selection_atom)))
- {
- if (_has_gconftool)
- desktop_type = DESKTOP_TYPE_NAUTILUS;
- }
+ /* FIXME: This is wrong, nautilus WINDOW_ID is not a selection */
+ g_snprintf(selection_name, 100, NAUTILUS_SELECTION_FMT);
+ nautilus_selection_atom = XInternAtom (gdk_display, selection_name, False);
+ if((XGetSelectionOwner(GDK_DISPLAY(), nautilus_selection_atom)))
+ {
+ if (_has_gconftool)
+ desktop_type = DESKTOP_TYPE_NAUTILUS;
+ }
}
- if ((desktop_type == DESKTOP_TYPE_NONE) && (action != NULL))
+ if ((desktop_type == DESKTOP_TYPE_NONE) && (action != NULL))
{
//gtk_widget_set_sensitive (action, FALSE);
}
@@ -196,120 +208,96 @@ twp_provider_get_file_actions (ThunarxMenuProvider *menu_provider,
}
static void
-twp_action_set_wallpaper (GtkAction *action, gpointer user_data)
+twp_action_set_wallpaper (GtkAction *action,
+ gpointer user_data)
{
- ThunarxFileInfo *file_info = user_data;
- GdkDisplay *display = gdk_display_get_default();
- gint n_screens = gdk_display_get_n_screens (display);
- gint screen_nr = 0;
- gint n_monitors;
- gint monitor_nr = 0;
- GdkScreen *screen;
- gchar *image_path_prop;
- gchar *image_show_prop;
- gchar *image_style_prop;
- gchar *file_uri;
- gchar *file_name = NULL;
- gchar *hostname = NULL;
- gchar *command;
-
- if (desktop_type != DESKTOP_TYPE_NONE)
+ ThunarxFileInfo *file_info = user_data;
+ GdkDisplay *display = gdk_display_get_default();
+ gint n_screens = gdk_display_get_n_screens (display);
+ gint screen_nr = 0;
+ gint n_monitors;
+ gint monitor_nr = 0;
+ GdkScreen *screen;
+ gchar *image_path_prop;
+ gchar *image_show_prop;
+ gchar *image_style_prop;
+ gchar *file_uri;
+ gchar *file_name = NULL;
+ gchar *hostname = NULL;
+ gchar *command;
+
+ if (desktop_type != DESKTOP_TYPE_NONE)
{
- file_uri = thunarx_file_info_get_uri (file_info);
- file_name = g_filename_from_uri (file_uri, &hostname, NULL);
- if (hostname != NULL)
- {
- g_free (hostname);
- g_free (file_uri);
- g_free (file_name);
- return;
- }
- if (n_screens > 1)
- {
- screen = gdk_display_get_default_screen (display);
- }
- else
+ file_uri = thunarx_file_info_get_uri (file_info);
+ file_name = g_filename_from_uri (file_uri, &hostname, NULL);
+ if (hostname != NULL)
{
- screen = gdk_display_get_screen (display, 0);
+ g_free (hostname);
+ g_free (file_uri);
+ g_free (file_name);
+
+ return;
}
- n_monitors = gdk_screen_get_n_monitors (screen);
-
- if (n_monitors > 1)
+ if (n_screens > 1)
+ screen = gdk_display_get_default_screen (display);
+ else
+ screen = gdk_display_get_screen (display, 0);
+
+ n_monitors = gdk_screen_get_n_monitors (screen);
+ if (n_monitors > 1)
{
-
+ /* ? */
}
- g_free(file_uri);
+ g_free(file_uri);
}
- switch (desktop_type)
+ switch (desktop_type)
{
- case DESKTOP_TYPE_XFCE:
- g_debug ("set on xfce");
- image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-path", screen_nr, monitor_nr);
- image_show_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-show", screen_nr, monitor_nr);
- image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-style", screen_nr, monitor_nr);
-
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t string -s \"%s\"", image_path_prop, file_name);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t bool -s true", image_show_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-
- command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t int -s 0", image_style_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-
- g_free(image_path_prop);
- g_free(image_show_prop);
- g_free(image_style_prop);
- break;
- case DESKTOP_TYPE_NAUTILUS:
- g_debug ("set on gnome");
- image_path_prop = g_strdup_printf("/desktop/gnome/background/picture_filename");
- image_show_prop = g_strdup_printf("/desktop/gnome/background/draw_background");
-
- command = g_strdup_printf ("gconftool-2 %s --set %s--type string", image_path_prop, file_name);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-
-
- command = g_strdup_printf ("gconftool-2 %s --set true --type boolean", image_show_prop);
- g_spawn_command_line_async (command, NULL);
- g_free (command);
-
- g_free(image_path_prop);
- g_free(image_show_prop);
- break;
-
- default:
- return;
- break;
+ case DESKTOP_TYPE_XFCE:
+ g_debug ("set on xfce");
+ image_path_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-path", screen_nr, monitor_nr);
+ image_show_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-show", screen_nr, monitor_nr);
+ image_style_prop = g_strdup_printf("/backdrop/screen%d/monitor%d/image-style", screen_nr, monitor_nr);
+
+ command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t string -s \"%s\"", image_path_prop, file_name);
+ g_spawn_command_line_async (command, NULL);
+ g_free (command);
+
+ command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t bool -s true", image_show_prop);
+ g_spawn_command_line_async (command, NULL);
+ g_free (command);
+
+ command = g_strdup_printf ("xfconf-query -c xfce4-desktop -p %s --create -t int -s 0", image_style_prop);
+ g_spawn_command_line_async (command, NULL);
+ g_free (command);
+
+ g_free(image_path_prop);
+ g_free(image_show_prop);
+ g_free(image_style_prop);
+ break;
+
+ case DESKTOP_TYPE_NAUTILUS:
+ g_debug ("set on gnome");
+ image_path_prop = g_strdup_printf("/desktop/gnome/background/picture_filename");
+ image_show_prop = g_strdup_printf("/desktop/gnome/background/draw_background");
+
+ command = g_strdup_printf ("gconftool-2 %s --set %s--type string", image_path_prop, file_name);
+ g_spawn_command_line_async (command, NULL);
+ g_free (command);
+
+
+ command = g_strdup_printf ("gconftool-2 %s --set true --type boolean", image_show_prop);
+ g_spawn_command_line_async (command, NULL);
+ g_free (command);
+
+ g_free(image_path_prop);
+ g_free(image_show_prop);
+ break;
+
+ default:
+ return;
+ break;
}
- g_free(file_name);
-}
-
-
-static gboolean
-check_cli_tools ()
-{
- gchar *program;
-
- program = g_find_program_in_path ("xfconf-query");
- if (G_LIKELY (program != NULL))
- {
- _has_xfconf_query = TRUE;
- g_free (program);
- }
-
- program = g_find_program_in_path ("gconftool-2");
- if (G_LIKELY (program != NULL))
- {
- _has_gconftool = TRUE;
- g_free (program);
- }
-
- return TRUE;
+ g_free(file_name);
}
More information about the Xfce4-commits
mailing list