Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
xfce4-settings
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
198
Issues
198
List
Boards
Labels
Service Desk
Milestones
Custom Issue Tracker
Custom Issue Tracker
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Xfce
xfce4-settings
Commits
ed1083bd
Commit
ed1083bd
authored
Oct 23, 2011
by
Nick Schermer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make the script work for gtk-2.0 and xfwm4 themes.
parent
2eb6b06c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
164 additions
and
31 deletions
+164
-31
dialogs/appearance-settings/appearance-install-theme
dialogs/appearance-settings/appearance-install-theme
+106
-1
dialogs/appearance-settings/main.c
dialogs/appearance-settings/main.c
+58
-30
No files found.
dialogs/appearance-settings/appearance-install-theme
100644 → 100755
View file @
ed1083bd
#!/bin/sh
#
# Copyright (C) 2011 Nick Schermer <nick@xfce.org>
#
# 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.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
exit
0
dndfilename
=
"
$1
"
retval
=
0
installtheme
()
{
file
=
"
$1
"
suffix
=
"
$2
"
basedir
=
${
file
#
$tmpdir
/
}
themedir
=
${
basedir
%/
$suffix
}
themename
=
`
basename
"
$themedir
"
`
themetype
=
`
dirname
"
$suffix
"
`
src
=
"
$tmpdir
/
$themedir
/
$themetype
"
dest
=
"
$HOME
/.themes/
$themename
"
if
test
!
-d
"
$dest
/
$themetype
"
;
then
# move theme to the users' theme directory
mkdir
-p
"
$dest
"
&&
mv
"
$src
"
"
$dest
"
fi
}
# leave if no file is provided
if
test
-z
"
$dndfilename
"
-o
-z
"
$HOME
"
;
then
# 1: common error, should never happen
exit
1
fi
# check file size, abort if bigger then 50Mb, only works for files
if
test
x
"
`
which
stat
2>/dev/null
`
"
!=
x
""
;
then
dndsize
=
`
stat
-c
%s
"
$dndfilename
"
`
if
test
"
$dndsize
"
-gt
52428800
;
then
# 2: File too big
exit
2
fi
fi
# provide tempdir to extract the tarball or folder
# we try $XDG_CACHE_HOME because it is more likely this is on the
# same partition, so moving the theme after extract is faster
if
test
x
"
`
which
mktemp
2>/dev/null
`
"
!=
x
""
;
then
tmpdir
=
`
TMPDIR
=
"
$XDG_CACHE_HOME
"
mktemp
-d
`
else
tmpdir
=
"/tmp/tmp.
$$
.
$RANDOM
"
mkdir
"
$tmpdir
"
fi
if
test
!
-d
"
$tmpdir
"
;
then
# 3: Failed to create temp directory
exit
3
fi
# check if uri is directory or file
if
test
-d
"
$dndfilename
"
;
then
cp
-r
"
$dndfilename
"
"
$tmpdir
"
||
retval
=
1
elif
test
-f
"
$dndfilename
"
;
then
case
"
$dndfilename
"
in
*
.tar.gz|
*
.tar.Z|
*
.tgz|
*
.tar.bz2|
*
.tbz2|
*
.tbz|
*
.tar
)
# extract the archive
tar
-C
"
$tmpdir
"
-xf
"
$dndfilename
"
||
retval
=
4
;;
*
.zip
)
# extract the archive
unzip
-d
"
$tmpdir
"
"
$dndfilename
"
||
retval
=
4
;;
*
)
# 5: unknow file format
retval
=
5
;;
esac
fi
# detect theme type and move it to the correct location if
# extracting or copying succeeded
if
test
"
$retval
"
-eq
0
;
then
# install gtk-2.0 themes
suffix
=
"gtk-2.0/gtkrc"
find
"
$tmpdir
"
-path
"
$tmpdir
/*/
$suffix
"
-type
f |
while
read
file
;
do
installtheme
"
$file
"
"
$suffix
"
done
# install xfwm4 themes
suffix
=
"xfwm4/themerc"
find
"
$tmpdir
"
-path
"
$tmpdir
/*/
$suffix
"
-type
f |
while
read
file
;
do
installtheme
"
$file
"
"
$suffix
"
done
fi
# cleanup
rm
-rf
"
$tmpdir
"
exit
$retval
dialogs/appearance-settings/main.c
View file @
ed1083bd
...
...
@@ -690,51 +690,79 @@ cb_theme_uri_dropped (GtkWidget *widget,
guint
i
;
GError
*
error
=
NULL
;
gint
status
;
GtkWidget
*
toplevel
;
GtkWidget
*
toplevel
=
gtk_widget_get_toplevel
(
widget
)
;
gchar
*
filename
;
GdkCursor
*
cursor
;
GdkWindow
*
gdkwindow
;
uris
=
gtk_selection_data_get_uris
(
data
);
if
(
uris
!=
NULL
)
{
argv
[
0
]
=
HELPERDIR
G_DIR_SEPARATOR_S
"appearance-install-theme"
;
argv
[
2
]
=
NULL
;
if
(
uris
==
NULL
)
return
;
toplevel
=
gtk_widget_get_toplevel
(
widget
);
argv
[
0
]
=
HELPERDIR
G_DIR_SEPARATOR_S
"appearance-install-theme"
;
argv
[
2
]
=
NULL
;
for
(
i
=
0
;
uris
[
i
]
!=
NULL
;
i
++
)
{
filename
=
g_filename_from_uri
(
uris
[
i
],
NULL
,
NULL
);
if
(
filename
==
NULL
)
continue
;
/* inform the user we are installing the theme */
gdkwindow
=
gtk_widget_get_window
(
widget
);
cursor
=
gdk_cursor_new_for_display
(
gtk_widget_get_display
(
widget
),
GDK_WATCH
);
gdk_window_set_cursor
(
gdkwindow
,
cursor
);
argv
[
1
]
=
filename
;
/* iterate main loop to show cursor */
while
(
gtk_events_pending
())
gtk_main_iteration
();
if
(
g_spawn_sync
(
NULL
,
argv
,
NULL
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
&
status
,
&
error
)
&&
status
>
0
)
{
switch
(
WEXITSTATUS
(
status
))
{
case
1
:
for
(
i
=
0
;
uris
[
i
]
!=
NULL
;
i
++
)
{
filename
=
g_filename_from_uri
(
uris
[
i
],
NULL
,
NULL
);
if
(
filename
==
NULL
)
continue
;
break
;
argv
[
1
]
=
filename
;
default:
g_set_error_literal
(
&
error
,
0
,
0
,
_
(
"An unknown error occured"
));
break
;
}
}
if
(
error
!=
NULL
)
if
(
g_spawn_sync
(
NULL
,
argv
,
NULL
,
0
,
NULL
,
NULL
,
NULL
,
NULL
,
&
status
,
&
error
)
&&
status
>
0
)
{
switch
(
WEXITSTATUS
(
status
))
{
xfce_dialog_show_error
(
GTK_WINDOW
(
toplevel
),
error
,
_
(
"Failed to install theme"
));
g_clear_error
(
&
error
);
case
2
:
g_set_error
(
&
error
,
G_SPAWN_ERROR
,
0
,
_
(
"File is larger then %d MB, installation aborted"
),
50
);
break
;
case
3
:
g_set_error_literal
(
&
error
,
G_SPAWN_ERROR
,
0
,
_
(
"Failed to create temporary directory"
));
break
;
case
4
:
g_set_error_literal
(
&
error
,
G_SPAWN_ERROR
,
0
,
_
(
"Failed to extract archive"
));
break
;
case
5
:
g_set_error_literal
(
&
error
,
G_SPAWN_ERROR
,
0
,
_
(
"Unknown format, only archives and directories are supported"
));
break
;
default:
g_set_error
(
&
error
,
G_SPAWN_ERROR
,
0
,
_
(
"An unknown error, exit code is %d"
),
WEXITSTATUS
(
status
));
break
;
}
}
g_free
(
filename
);
if
(
error
!=
NULL
)
{
xfce_dialog_show_error
(
GTK_WINDOW
(
toplevel
),
error
,
_
(
"Failed to install theme"
));
g_clear_error
(
&
error
);
}
g_
strfreev
(
uris
);
g_
free
(
filename
);
}
g_strfreev
(
uris
);
gdk_window_set_cursor
(
gdkwindow
,
NULL
);
gdk_cursor_unref
(
cursor
);
}
static
void
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment