[gthumb/ext] added ability to set an image as desktop background
- From: Paolo Bacchilega <paobac src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gthumb/ext] added ability to set an image as desktop background
- Date: Mon, 19 Oct 2009 11:27:43 +0000 (UTC)
commit 616dc75170921a5c9a2f72433ccd8334c38c90e0
Author: Paolo Bacchilega <paobac src gnome org>
Date: Mon Oct 19 13:27:00 2009 +0200
added ability to set an image as desktop background
configure.ac | 1 +
extensions/Makefile.am | 35 ++++---
extensions/desktop_background/Makefile.am | 31 ++++++
extensions/desktop_background/actions.c | 59 +++++++++++
extensions/desktop_background/actions.h | 32 ++++++
extensions/desktop_background/callbacks.c | 106 ++++++++++++++++++++
extensions/desktop_background/callbacks.h | 31 ++++++
.../desktop_background.extension.in.in | 10 ++
extensions/desktop_background/main.c | 54 ++++++++++
extensions/resize_images/main.c | 2 +-
10 files changed, 343 insertions(+), 18 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 7162a64..7c605f6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -285,6 +285,7 @@ extensions/catalogs/data/ui/Makefile
extensions/comments/Makefile
extensions/comments/data/Makefile
extensions/comments/data/ui/Makefile
+extensions/desktop_background/Makefile
extensions/exiv2/Makefile
extensions/file_manager/Makefile
extensions/file_tools/Makefile
diff --git a/extensions/Makefile.am b/extensions/Makefile.am
index 9d4c532..b16f2b1 100644
--- a/extensions/Makefile.am
+++ b/extensions/Makefile.am
@@ -1,20 +1,21 @@
-SUBDIRS = \
- catalogs \
- comments \
- exiv2 \
- file_manager \
- file_tools \
- file_viewer \
- image_rotation \
- image_viewer \
- jpeg_utils \
- list_tools \
- photo_importer \
- pixbuf_savers \
- red_eye_removal \
- rename_series \
- resize_images \
- search \
+SUBDIRS = \
+ catalogs \
+ comments \
+ desktop_background \
+ exiv2 \
+ file_manager \
+ file_tools \
+ file_viewer \
+ image_rotation \
+ image_viewer \
+ jpeg_utils \
+ list_tools \
+ photo_importer \
+ pixbuf_savers \
+ red_eye_removal \
+ rename_series \
+ resize_images \
+ search \
slideshow
-include $(top_srcdir)/git.mk
diff --git a/extensions/desktop_background/Makefile.am b/extensions/desktop_background/Makefile.am
new file mode 100644
index 0000000..486713b
--- /dev/null
+++ b/extensions/desktop_background/Makefile.am
@@ -0,0 +1,31 @@
+extensiondir = $(libdir)/gthumb-2.0/extensions
+extension_LTLIBRARIES = libdesktop_background.la
+
+libdesktop_background_la_SOURCES = \
+ $(JPEG_FILES) \
+ actions.c \
+ actions.h \
+ callbacks.c \
+ callbacks.h \
+ main.c
+
+libdesktop_background_la_CFLAGS = $(GTHUMB_CFLAGS) $(DISABLE_DEPRECATED) $(WARNINGS) -I$(top_srcdir) -I$(top_builddir)/gthumb
+libdesktop_background_la_LDFLAGS = $(EXTENSION_LIBTOOL_FLAGS)
+libdesktop_background_la_LIBADD = $(GTHUMB_LIBS)
+libdesktop_background_la_DEPENDENCIES = $(top_builddir)/gthumb/gthumb$(EXEEXT)
+
+extensioninidir = $(extensiondir)
+extensionini_in_files = desktop_background.extension.in.in
+extensionini_DATA = $(extensionini_in_files:.extension.in.in=.extension)
+
+%.extension.in: %.extension.in.in $(extension_LTLIBRARIES)
+ sed -e "s|%LIBRARY%|`. ./$(extension_LTLIBRARIES) && echo $$dlname`|" \
+ $< > $@
+
+%.extension: %.extension.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*po) ; LC_ALL=C $(INTLTOOL_MERGE) -d -u -c $(top_builddir)/po/.intltool-merge-cache $(top_srcdir)/po $< $@
+
+EXTRA_DIST = $(extensionini_in_files)
+
+DISTCLEANFILES = $(extensionini_DATA)
+
+-include $(top_srcdir)/git.mk
diff --git a/extensions/desktop_background/actions.c b/extensions/desktop_background/actions.c
new file mode 100644
index 0000000..5a165f4
--- /dev/null
+++ b/extensions/desktop_background/actions.c
@@ -0,0 +1,59 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * 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 details.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <gthumb.h>
+
+
+void
+gth_browser_activate_action_tool_desktop_background (GtkAction *action,
+ GthBrowser *browser)
+{
+ GList *items;
+ GList *file_list;
+ GthFileData *file_data;
+ char *path;
+ GError *error = NULL;
+
+ items = gth_file_selection_get_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
+ file_list = gth_file_list_get_files (GTH_FILE_LIST (gth_browser_get_file_list (browser)), items);
+
+ if (file_list == NULL)
+ return;
+
+ file_data = file_list->data;
+ if (file_data == NULL)
+ return;
+
+ path = g_file_get_path (file_data->file);
+ if (path != NULL)
+ eel_gconf_set_string ("/desktop/gnome/background/picture_filename", path);
+
+ if (! g_spawn_command_line_async ("gnome-appearance-properties --show-page=background", &error))
+ _gtk_error_dialog_from_gerror_run (GTK_WINDOW (browser), _("Could not show the desktop background properties"), &error);
+
+ g_free (path);
+ _g_object_list_unref (file_list);
+ _gtk_tree_path_list_free (items);
+}
diff --git a/extensions/desktop_background/actions.h b/extensions/desktop_background/actions.h
new file mode 100644
index 0000000..dca3344
--- /dev/null
+++ b/extensions/desktop_background/actions.h
@@ -0,0 +1,32 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * 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 details.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef ACTIONS_H
+#define ACTIONS_H
+
+#include <gtk/gtk.h>
+
+#define DEFINE_ACTION(x) void x (GtkAction *action, gpointer data);
+
+DEFINE_ACTION(gth_browser_activate_action_tool_desktop_background)
+
+#endif /* ACTIONS_H */
diff --git a/extensions/desktop_background/callbacks.c b/extensions/desktop_background/callbacks.c
new file mode 100644
index 0000000..aa945d2
--- /dev/null
+++ b/extensions/desktop_background/callbacks.c
@@ -0,0 +1,106 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * 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 details.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+#include <gdk/gdkkeysyms.h>
+#include <gthumb.h>
+#include "actions.h"
+
+#define BROWSER_DATA_KEY "desktop-background-browser-data"
+
+
+static const char *fixed_ui_info =
+"<ui>"
+" <popup name='ListToolsPopup'>"
+" <placeholder name='Tools'>"
+" <menuitem name='DesktopBackground' action='Tool_DesktopBackground'/>"
+" </placeholder>"
+" </popup>"
+"</ui>";
+
+
+static GtkActionEntry action_entries[] = {
+ { "Tool_DesktopBackground", "desktop-background",
+ N_("Set as Desktop Background"), NULL,
+ N_("Set the image as desktop background"),
+ G_CALLBACK (gth_browser_activate_action_tool_desktop_background) },
+};
+
+
+typedef struct {
+ GtkActionGroup *action_group;
+} BrowserData;
+
+
+static void
+browser_data_free (BrowserData *data)
+{
+ g_free (data);
+}
+
+
+void
+db__gth_browser_construct_cb (GthBrowser *browser)
+{
+ BrowserData *data;
+ GError *error = NULL;
+
+ g_return_if_fail (GTH_IS_BROWSER (browser));
+
+ data = g_new0 (BrowserData, 1);
+ data->action_group = gtk_action_group_new ("Desktop Background Actions");
+ gtk_action_group_set_translation_domain (data->action_group, NULL);
+ gtk_action_group_add_actions (data->action_group,
+ action_entries,
+ G_N_ELEMENTS (action_entries),
+ browser);
+ gtk_ui_manager_insert_action_group (gth_browser_get_ui_manager (browser), data->action_group, 0);
+
+ if (! gtk_ui_manager_add_ui_from_string (gth_browser_get_ui_manager (browser), fixed_ui_info, -1, &error)) {
+ g_message ("building menus failed: %s", error->message);
+ g_clear_error (&error);
+ }
+
+ g_object_set_data_full (G_OBJECT (browser), BROWSER_DATA_KEY, data, (GDestroyNotify) browser_data_free);
+}
+
+
+void
+db__gth_browser_update_sensitivity_cb (GthBrowser *browser)
+{
+ BrowserData *data;
+ GtkAction *action;
+ int n_selected;
+ gboolean sensitive;
+
+ data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY);
+ g_return_if_fail (data != NULL);
+
+ n_selected = gth_file_selection_get_n_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser)));
+ sensitive = n_selected == 1;
+
+ action = gtk_action_group_get_action (data->action_group, "Tool_DesktopBackground");
+ g_object_set (action, "sensitive", sensitive, NULL);
+}
diff --git a/extensions/desktop_background/callbacks.h b/extensions/desktop_background/callbacks.h
new file mode 100644
index 0000000..714cde5
--- /dev/null
+++ b/extensions/desktop_background/callbacks.h
@@ -0,0 +1,31 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * 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 details.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+#ifndef CALLBACKS_H
+#define CALLBACKS_H
+
+#include <gthumb.h>
+
+void db__gth_browser_construct_cb (GthBrowser *browser);
+void db__gth_browser_update_sensitivity_cb (GthBrowser *browser);
+
+#endif /* CALLBACKS_H */
diff --git a/extensions/desktop_background/desktop_background.extension.in.in b/extensions/desktop_background/desktop_background.extension.in.in
new file mode 100644
index 0000000..f8cc084
--- /dev/null
+++ b/extensions/desktop_background/desktop_background.extension.in.in
@@ -0,0 +1,10 @@
+[Extension]
+_Name=Desktop background
+_Description=Set the image as desktop background
+_Authors=gthumb development team
+Copyright=Copyright © 2009 The Free Software Foundation, Inc.
+Version=1.0
+
+[Loader]
+Type=module
+File=%LIBRARY%
diff --git a/extensions/desktop_background/main.c b/extensions/desktop_background/main.c
new file mode 100644
index 0000000..ee5a7f4
--- /dev/null
+++ b/extensions/desktop_background/main.c
@@ -0,0 +1,54 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+
+/*
+ * GThumb
+ *
+ * Copyright (C) 2009 Free Software Foundation, Inc.
+ *
+ * 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 details.
+ *
+ * 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., 59 Temple Street #330, Boston, MA 02111-1307, USA.
+ */
+
+
+#include <config.h>
+#include <gtk/gtk.h>
+#include <gthumb.h>
+#include "callbacks.h"
+
+
+G_MODULE_EXPORT void
+gthumb_extension_activate (void)
+{
+ gth_hook_add_callback ("gth-browser-construct", 40, G_CALLBACK (db__gth_browser_construct_cb), NULL);
+ gth_hook_add_callback ("gth-browser-update-sensitivity", 10, G_CALLBACK (db__gth_browser_update_sensitivity_cb), NULL);
+}
+
+
+G_MODULE_EXPORT void
+gthumb_extension_deactivate (void)
+{
+}
+
+
+G_MODULE_EXPORT gboolean
+gthumb_extension_is_configurable (void)
+{
+ return FALSE;
+}
+
+
+G_MODULE_EXPORT void
+gthumb_extension_configure (GtkWindow *parent)
+{
+}
diff --git a/extensions/resize_images/main.c b/extensions/resize_images/main.c
index 9258c4f..cdae2ff 100644
--- a/extensions/resize_images/main.c
+++ b/extensions/resize_images/main.c
@@ -30,7 +30,7 @@
G_MODULE_EXPORT void
gthumb_extension_activate (void)
{
- gth_hook_add_callback ("gth-browser-construct", 10, G_CALLBACK (ri__gth_browser_construct_cb), NULL);
+ gth_hook_add_callback ("gth-browser-construct", 20, G_CALLBACK (ri__gth_browser_construct_cb), NULL);
gth_hook_add_callback ("gth-browser-update-sensitivity", 10, G_CALLBACK (ri__gth_browser_update_sensitivity_cb), NULL);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]