Commit 2eb6b06c authored by Nick Schermer's avatar Nick Schermer

Add theme installation basics with dnd.

Script does nothing yet, but this implements the
basics in the appearance dialog.
parent ab9bd9a2
......@@ -63,7 +63,7 @@ AC_PROG_LIBTOOL()
dnl **********************************
dnl *** Check for standard headers ***
dnl **********************************
AC_CHECK_HEADERS([errno.h memory.h math.h stdlib.h string.h unistd.h signal.h time.h sys/types.h])
AC_CHECK_HEADERS([errno.h memory.h math.h stdlib.h string.h unistd.h signal.h time.h sys/types.h sys/wait.h])
AC_CHECK_FUNCS([daemon setsid])
dnl ******************************
......@@ -182,6 +182,16 @@ if test x"$enable_sound_settings" = x"yes"; then
fi
AC_SUBST(ENABLE_SOUND_SETTINGS)
dnl ******************************
dnl *** Set helper path prefix ***
dnl ******************************
AC_ARG_WITH([helper-path-prefix],
[AC_HELP_STRING([--with-helper-path-prefix=PATH],
[Path prefix under which helper executables will be installed (default: $libdir)])],
[HELPER_PATH_PREFIX="$withval"],
[HELPER_PATH_PREFIX="$libdir"])
AC_SUBST([HELPER_PATH_PREFIX])
dnl ***********************************
dnl *** Check for debugging support ***
dnl ***********************************
......
......@@ -5,6 +5,7 @@ INCLUDES = \
-DDATADIR=\"$(datadir)\" \
-DSRCDIR=\"$(top_srcdir)\" \
-DLOCALEDIR=\"$(localedir)\" \
-DHELPERDIR=\"$(HELPER_PATH_PREFIX)/xfce4/settings\" \
-DG_LOG_DOMAIN=\"xfce4-appearance-settings\" \
$(PLATFORM_CPPFLAGS)
......@@ -31,6 +32,9 @@ xfce4_appearance_settings_LDADD = \
$(LIBXFCE4UI_LIBS) \
$(XFCONF_LIBS)
xfce4_appearance_scriptsdir = $(HELPER_PATH_PREFIX)/xfce4/settings
xfce4_appearance_scripts_SCRIPTS = appearance-install-theme
if MAINTAINER_MODE
BUILT_SOURCES = \
......@@ -49,6 +53,7 @@ desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
EXTRA_DIST = \
$(desktop_in_files) \
appearance-install-theme \
appearance-dialog.glade
DISTCLEANFILES = \
......
......@@ -27,6 +27,9 @@
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#ifdef HAVE_SYS_WAIT_H
#include <sys/wait.h>
#endif
#include <glib.h>
#include <gtk/gtk.h>
......@@ -78,6 +81,11 @@ static const gchar* xft_rgba_array[] =
"none", "rgb", "bgr", "vrgb", "vbgr"
};
static const GtkTargetEntry theme_drop_targets[] =
{
{ "text/uri-list", 0, 0 }
};
/* Option entries */
static GdkNativeWindow opt_socket_id = 0;
static gboolean opt_version = FALSE;
......@@ -668,6 +676,67 @@ appearance_settings_dialog_channel_property_changed (XfconfChannel *channel,
}
}
static void
cb_theme_uri_dropped (GtkWidget *widget,
GdkDragContext *drag_context,
gint x,
gint y,
GtkSelectionData *data,
guint info,
guint timestamp)
{
gchar **uris;
gchar *argv[3];
guint i;
GError *error = NULL;
gint status;
GtkWidget *toplevel;
gchar *filename;
uris = gtk_selection_data_get_uris (data);
if (uris != NULL)
{
argv[0] = HELPERDIR G_DIR_SEPARATOR_S "appearance-install-theme";
argv[2] = NULL;
toplevel = gtk_widget_get_toplevel (widget);
for (i = 0; uris[i] != NULL; i++)
{
filename = g_filename_from_uri (uris[i], NULL, NULL);
if (filename == NULL)
continue;
argv[1] = filename;
if (g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, &status, &error)
&& status > 0)
{
switch (WEXITSTATUS (status))
{
case 1:
break;
default:
g_set_error_literal (&error, 0, 0, _("An unknown error occured"));
break;
}
}
if (error != NULL)
{
xfce_dialog_show_error (GTK_WINDOW (toplevel), error, _("Failed to install theme"));
g_clear_error (&error);
}
g_free (filename);
}
g_strfreev (uris);
}
}
static void
appearance_settings_dialog_configure_widgets (GtkBuilder *builder)
{
......@@ -696,6 +765,11 @@ appearance_settings_dialog_configure_widgets (GtkBuilder *builder)
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (cb_icon_theme_tree_selection_changed), NULL);
gtk_drag_dest_set (GTK_WIDGET (object), GTK_DEST_DEFAULT_ALL,
theme_drop_targets, G_N_ELEMENTS (theme_drop_targets),
GDK_ACTION_COPY);
g_signal_connect (G_OBJECT (object), "drag-data-received", G_CALLBACK (cb_theme_uri_dropped), NULL);
/* Gtk (UI) themes */
object = gtk_builder_get_object (builder, "gtk_theme_treeview");
......@@ -715,6 +789,11 @@ appearance_settings_dialog_configure_widgets (GtkBuilder *builder)
gtk_tree_selection_set_mode (selection, GTK_SELECTION_SINGLE);
g_signal_connect (G_OBJECT (selection), "changed", G_CALLBACK (cb_ui_theme_tree_selection_changed), NULL);
gtk_drag_dest_set (GTK_WIDGET (object), GTK_DEST_DEFAULT_ALL,
theme_drop_targets, G_N_ELEMENTS (theme_drop_targets),
GDK_ACTION_COPY);
g_signal_connect (G_OBJECT (object), "drag-data-received", G_CALLBACK (cb_theme_uri_dropped), NULL);
/* Subpixel (rgba) hinting Combo */
object = gtk_builder_get_object (builder, "xft_rgba_store");
......
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