uget-1.10.4/0000775000175000017500000000000012260772027007551 500000000000000uget-1.10.4/depcomp0000755000175000017500000004755611736361705011071 00000000000000#! /bin/sh # depcomp - compile a program generating dependencies as side-effects scriptversion=2011-12-04.11; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2010, # 2011 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Originally written by Alexandre Oliva . case $1 in '') echo "$0: No command. Try \`$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: depcomp [--help] [--version] PROGRAM [ARGS] Run PROGRAMS ARGS to compile a file, generating dependencies as side-effects. Environment variables: depmode Dependency tracking mode. source Source file read by `PROGRAMS ARGS'. object Object file output by `PROGRAMS ARGS'. DEPDIR directory where to store dependencies. depfile Dependency file to output. tmpdepfile Temporary file to use when outputting dependencies. libtool Whether libtool is used (yes/no). Report bugs to . EOF exit $? ;; -v | --v*) echo "depcomp $scriptversion" exit $? ;; esac if test -z "$depmode" || test -z "$source" || test -z "$object"; then echo "depcomp: Variables source, object and depmode must be set" 1>&2 exit 1 fi # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. depfile=${depfile-`echo "$object" | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} rm -f "$tmpdepfile" # Some modes work just like other modes, but use different flags. We # parameterize here, but still list the modes in the big case below, # to make depend.m4 easier to write. Note that we *cannot* use a case # here, because this file can only contain one case statement. if test "$depmode" = hp; then # HP compiler uses -M and no extra arg. gccflag=-M depmode=gcc fi if test "$depmode" = dashXmstdout; then # This is just like dashmstdout with a different argument. dashmflag=-xM depmode=dashmstdout fi cygpath_u="cygpath -u -f -" if test "$depmode" = msvcmsys; then # This is just like msvisualcpp but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvisualcpp fi if test "$depmode" = msvc7msys; then # This is just like msvc7 but w/o cygpath translation. # Just convert the backslash-escaped backslashes to single forward # slashes to satisfy depend.m4 cygpath_u='sed s,\\\\,/,g' depmode=msvc7 fi case "$depmode" in gcc3) ## gcc 3 implements dependency tracking that does exactly what ## we want. Yay! Note: for some reason libtool 1.4 doesn't like ## it if -MD -MP comes after the -MF stuff. Hmm. ## Unfortunately, FreeBSD c89 acceptance of flags depends upon ## the command line argument order; so add the flags where they ## appear in depend2.am. Note that the slowdown incurred here ## affects only configure: in makefiles, %FASTDEP% shortcuts this. for arg do case $arg in -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; *) set fnord "$@" "$arg" ;; esac shift # fnord shift # $arg done "$@" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi mv "$tmpdepfile" "$depfile" ;; gcc) ## There are various ways to get dependency output from gcc. Here's ## why we pick this rather obscure method: ## - Don't want to use -MD because we'd like the dependencies to end ## up in a subdir. Having to rename by hand is ugly. ## (We might end up doing this anyway to support other compilers.) ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like ## -MM, not -M (despite what the docs say). ## - Using -M directly means running the compiler twice (even worse ## than renaming). if test -z "$gccflag"; then gccflag=-MD, fi "$@" -Wp,"$gccflag$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ## The second -e expression handles DOS-style file names with drive letters. sed -e 's/^[^:]*: / /' \ -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" ## This next piece of magic avoids the `deleted header file' problem. ## The problem is that when a header file which appears in a .P file ## is deleted, the dependency causes make to die (because there is ## typically no way to rebuild the header). We avoid this by adding ## dummy dependencies for each header file. Too bad gcc doesn't do ## this for us directly. tr ' ' ' ' < "$tmpdepfile" | ## Some versions of gcc put a space before the `:'. On the theory ## that the space means something, we add a space to the output as ## well. hp depmode also adds that space, but also prefixes the VPATH ## to the object. Take care to not repeat it in the output. ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; sgi) if test "$libtool" = yes; then "$@" "-Wp,-MDupdate,$tmpdepfile" else "$@" -MDupdate "$tmpdepfile" fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files echo "$object : \\" > "$depfile" # Clip off the initial element (the dependent). Don't try to be # clever and replace this with sed code, as IRIX sed won't handle # lines with more than a fixed number of characters (4096 in # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; # the IRIX cc adds comments like `#:fec' to the end of the # dependency line. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ tr ' ' ' ' >> "$depfile" echo >> "$depfile" # The second pass generates a dummy entry for each header file. tr ' ' ' ' < "$tmpdepfile" \ | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; aix) # The C for AIX Compiler uses -M and outputs the dependencies # in a .u file. In older versions, this file always lives in the # current directory. Also, the AIX compiler puts `$object:' at the # start of each line; $object doesn't have directory information. # Version 6 uses the directory in both cases. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.u tmpdepfile2=$base.u tmpdepfile3=$dir.libs/$base.u "$@" -Wc,-M else tmpdepfile1=$dir$base.u tmpdepfile2=$dir$base.u tmpdepfile3=$dir$base.u "$@" -M fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then # Each line is of the form `foo.o: dependent.h'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else # The sourcefile does not contain any dependencies, so just # store a dummy comment line, to avoid errors with the Makefile # "include basename.Plo" scheme. echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; icc) # Intel's C compiler understands `-MD -MF file'. However on # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c # ICC 7.0 will fill foo.d with something like # foo.o: sub/foo.c # foo.o: sub/foo.h # which is wrong. We want: # sub/foo.o: sub/foo.c # sub/foo.o: sub/foo.h # sub/foo.c: # sub/foo.h: # ICC 7.1 will output # foo.o: sub/foo.c sub/foo.h # and will wrap long lines using \ : # foo.o: sub/foo.c ... \ # sub/foo.h ... \ # ... "$@" -MD -MF "$tmpdepfile" stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" # Each line is of the form `foo.o: dependent.h', # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. # Do two passes, one to just change these to # `$object: dependent.h' and one to simply `dependent.h:'. sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" # Some versions of the HPUX 10.20 sed can't process this invocation # correctly. Breaking it into two sed invocations is a workaround. sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; hp2) # The "hp" stanza above does not work with aCC (C++) and HP's ia64 # compilers, which have integrated preprocessors. The correct option # to use with these is +Maked; it writes dependencies to a file named # 'foo.d', which lands next to the object file, wherever that # happens to be. # Much of this is similar to the tru64 case; see comments there. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then tmpdepfile1=$dir$base.d tmpdepfile2=$dir.libs/$base.d "$@" -Wc,+Maked else tmpdepfile1=$dir$base.d tmpdepfile2=$dir$base.d "$@" +Maked fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," "$tmpdepfile" > "$depfile" # Add `dependent.h:' lines. sed -ne '2,${ s/^ *// s/ \\*$// s/$/:/ p }' "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" "$tmpdepfile2" ;; tru64) # The Tru64 compiler uses -MD to generate dependencies as a side # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put # dependencies in `foo.d' instead, so we check for that too. # Subdirectories are respected. dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` test "x$dir" = "x$object" && dir= base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` if test "$libtool" = yes; then # With Tru64 cc, shared objects can also be used to make a # static library. This mechanism is used in libtool 1.4 series to # handle both shared and static libraries in a single compilation. # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. # # With libtool 1.5 this exception was removed, and libtool now # generates 2 separate objects for the 2 libraries. These two # compilations output dependencies in $dir.libs/$base.o.d and # in $dir$base.o.d. We have to check for both files, because # one of the two compilations can be disabled. We should prefer # $dir$base.o.d over $dir.libs/$base.o.d because the latter is # automatically cleaned when .libs/ is deleted, while ignoring # the former would cause a distcleancheck panic. tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 tmpdepfile2=$dir$base.o.d # libtool 1.5 tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 "$@" -Wc,-MD else tmpdepfile1=$dir$base.o.d tmpdepfile2=$dir$base.d tmpdepfile3=$dir$base.d tmpdepfile4=$dir$base.d "$@" -MD fi stat=$? if test $stat -eq 0; then : else rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" exit $stat fi for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" do test -f "$tmpdepfile" && break done if test -f "$tmpdepfile"; then sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" # That's a tab and a space in the []. sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" else echo "#dummy" > "$depfile" fi rm -f "$tmpdepfile" ;; msvc7) if test "$libtool" = yes; then showIncludes=-Wc,-showIncludes else showIncludes=-showIncludes fi "$@" $showIncludes > "$tmpdepfile" stat=$? grep -v '^Note: including file: ' "$tmpdepfile" if test "$stat" = 0; then : else rm -f "$tmpdepfile" exit $stat fi rm -f "$depfile" echo "$object : \\" > "$depfile" # The first sed program below extracts the file names and escapes # backslashes for cygpath. The second sed program outputs the file # name when reading, but also accumulates all include files in the # hold buffer in order to output them again at the end. This only # works with sed implementations that can handle large buffers. sed < "$tmpdepfile" -n ' /^Note: including file: *\(.*\)/ { s//\1/ s/\\/\\\\/g p }' | $cygpath_u | sort -u | sed -n ' s/ /\\ /g s/\(.*\)/ \1 \\/p s/.\(.*\) \\/\1:/ H $ { s/.*/ / G p }' >> "$depfile" rm -f "$tmpdepfile" ;; msvc7msys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; #nosideeffect) # This comment above is used by automake to tell side-effect # dependency tracking mechanisms from slower ones. dashmstdout) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout, regardless of -o. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done test -z "$dashmflag" && dashmflag=-M # Require at least two characters before searching for `:' # in the target name. This is to cope with DOS-style filenames: # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. "$@" $dashmflag | sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" rm -f "$depfile" cat < "$tmpdepfile" > "$depfile" tr ' ' ' ' < "$tmpdepfile" | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; dashXmstdout) # This case only exists to satisfy depend.m4. It is never actually # run, as this mode is specially recognized in the preamble. exit 1 ;; makedepend) "$@" || exit $? # Remove any Libtool call if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # X makedepend shift cleared=no eat=no for arg do case $cleared in no) set ""; shift cleared=yes ;; esac if test $eat = yes; then eat=no continue fi case "$arg" in -D*|-I*) set fnord "$@" "$arg"; shift ;; # Strip any option that makedepend may not understand. Remove # the object too, otherwise makedepend will parse it as a source file. -arch) eat=yes ;; -*|$object) ;; *) set fnord "$@" "$arg"; shift ;; esac done obj_suffix=`echo "$object" | sed 's/^.*\././'` touch "$tmpdepfile" ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" rm -f "$depfile" # makedepend may prepend the VPATH from the source file name to the object. # No need to regex-escape $object, excess matching of '.' is harmless. sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" sed '1,2d' "$tmpdepfile" | tr ' ' ' ' | \ ## Some versions of the HPUX 10.20 sed can't process this invocation ## correctly. Breaking it into two sed invocations is a workaround. sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" rm -f "$tmpdepfile" "$tmpdepfile".bak ;; cpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi # Remove `-o $object'. IFS=" " for arg do case $arg in -o) shift ;; $object) shift ;; *) set fnord "$@" "$arg" shift # fnord shift # $arg ;; esac done "$@" -E | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | sed '$ s: \\$::' > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" cat < "$tmpdepfile" >> "$depfile" sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" rm -f "$tmpdepfile" ;; msvisualcpp) # Important note: in order to support this mode, a compiler *must* # always write the preprocessed file to stdout. "$@" || exit $? # Remove the call to Libtool. if test "$libtool" = yes; then while test "X$1" != 'X--mode=compile'; do shift done shift fi IFS=" " for arg do case "$arg" in -o) shift ;; $object) shift ;; "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") set fnord "$@" shift shift ;; *) set fnord "$@" "$arg" shift shift ;; esac done "$@" -E 2>/dev/null | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" rm -f "$depfile" echo "$object : \\" > "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" echo " " >> "$depfile" sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" rm -f "$tmpdepfile" ;; msvcmsys) # This case exists only to let depend.m4 do its work. It works by # looking at the text of this script. This case will never be run, # since it is checked for above. exit 1 ;; none) exec "$@" ;; *) echo "Unknown depmode $depmode" 1>&2 exit 1 ;; esac exit 0 # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: uget-1.10.4/tests/0000775000175000017500000000000012260772031010706 500000000000000uget-1.10.4/tests/test-download.c0000664000175000017500000000760012165471260013565 00000000000000#include // exit(), EXIT_SUCCESS, EXIT_FAILURE #ifdef _WIN32 #include #include #include #endif // _WIN32 #include #include #include #include #include static void dump_progress (UgetProgress* progress) { #ifdef _WIN32 printf ("complete size : %I64d byte\n", progress->complete); #else g_print ("complete size : %lld byte\n", (long long int) progress->complete); #endif #ifdef _WIN32 printf ("total size : %I64d byte\n", progress->total); #else g_print ("total size : %lld byte\n", (long long int) progress->total); #endif g_print ("speed (upload) : %.2f byte/sec\n", (double) progress->upload_speed); g_print ("speed : %.2f byte/sec\n", (double) progress->download_speed); g_print ("percent : %.2f%%\n", progress->percent); g_print ("consumed time : %.2f sec\n", progress->consume_time); g_print ("remain time : %.2f sec\n", progress->remain_time); } static void plugin_callback (UgPlugin* plugin, const UgMessage* msg, gpointer user_data) { UgetProgress* progress; switch (msg->type) { case UG_MESSAGE_STATE: g_print ("--- Message State : State changed to %d\n", msg->data.v_int); break; case UG_MESSAGE_PROGRESS: g_print ("--- Message Progress :\n"); progress = ug_data_new (UgetProgressInfo); if (ug_plugin_get (plugin, UG_TYPE_INSTANCE, progress) == UG_RESULT_OK) dump_progress (progress); ug_data_free (progress); break; case UG_MESSAGE_ERROR: g_print ("--- Message Error %d: %s\n", msg->code, msg->string); break; case UG_MESSAGE_WARNING: g_print ("--- Message Warning %d: %s\n", msg->code, msg->string); break; case UG_MESSAGE_INFO: g_print ("--- Message Info %d: %s\n", msg->code, msg->string); break; case UG_MESSAGE_DATA: switch (msg->code) { case UG_MESSAGE_DATA_FILE_CHANGED: g_print ("--- Message Data : File changed to %s\n", msg->data.v_string); break; // HTTP message case UG_MESSAGE_DATA_HTTP_LOCATION: g_print ("--- Message Data : HTTP Location: %s\n", msg->data.v_string); break; case UG_MESSAGE_DATA_HTTP_CONTENT_LOCATION: g_print ("--- Message Data : HTTP Content-Location: %s\n", msg->data.v_string); break; case UG_MESSAGE_DATA_HTTP_CONTENT_DISPOSITION: g_print ("--- Message Data : HTTP Content-disposition: %s\n", msg->data.v_string); break; default: break; } break; default: break; } } int main (int argc, char* argv[]) { const UgOptionEntry* uoentry; UgDataset* dataset; UgetCommon* common; UgPlugin* plugin; GOptionContext* context; GOptionGroup* group; GError* error = NULL; #ifdef _WIN32 // curl_global_init() will do this WSADATA WSAData; WSAStartup (MAKEWORD (2, 2), &WSAData); #endif uglib_init (); // parse command-line options context = g_option_context_new ("[URL]"); group = g_option_group_new (NULL, NULL, NULL, NULL, NULL); uoentry = ug_option_get_main_entry (); g_option_group_add_entries (group, uoentry->entry); g_option_context_set_main_group (context, group); if (g_option_context_parse (context, &argc, &argv, &error) == FALSE) { g_print ("Option parsing failed : %s\n", error->message); exit (EXIT_FAILURE); // EXIT_FAILURE == 1 } // get URL from remained arguments if (argc == 1) { g_print ("%s", g_option_context_get_help (context, TRUE, NULL)); exit (EXIT_FAILURE); // EXIT_FAILURE == 1 } dataset = ug_dataset_new (); ug_option_entry_get (uoentry, dataset); common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); common->url = g_strdup (argv[1]); plugin = ug_plugin_new_by_data (dataset); ug_dataset_unref (dataset); if (plugin) { ug_plugin_set_state (plugin, UG_STATE_ACTIVE); while (ug_plugin_dispatch (plugin, plugin_callback, NULL)) ug_plugin_delay (plugin, 1000); ug_plugin_unref (plugin); } uglib_finalize (); #ifdef _WIN32 WSACleanup (); #endif return EXIT_SUCCESS; // EXIT_SUCCESS == 0 } uget-1.10.4/tests/Makefile.am0000664000175000017500000000152112021236333012654 00000000000000 noinst_PROGRAMS = test-download test-conf test-ipc test-xmlrpc TESTS_LIBS = @GLIB_LIBS@ @GIO_LIBS@ @GTHREAD_LIBS@ @GMODULE_LIBS@ @CURL_LIBS@ @LIBPWMD_LIBS@ # set the include path found by configure AM_CPPFLAGS = -I$(top_srcdir)/uglib -I$(top_srcdir)/tests AM_CFLAGS = @LFS_CFLAGS@ @GLIB_CFLAGS@ @GIO_CFLAGS@ @GTHREAD_CFLAGS@ @GMODULE_CFLAGS@ @CURL_CFLAGS@ @LIBPWMD_CFLAGS@ AM_LDFLAGS = @LFS_LDFLAGS@ test_download_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_download_SOURCES = test-download.c test_conf_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_conf_SOURCES = test-conf.c test_ipc_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_ipc_SOURCES = test-ipc.c test_xmlrpc_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_xmlrpc_SOURCES = test-xmlrpc.c uget-1.10.4/tests/test-xmlrpc.c0000664000175000017500000000770212021236333013255 00000000000000#ifdef HAVE_CONFIG_H #include #endif #ifdef _WIN32 #include #endif #ifdef HAVE_PLUGIN_ARIA2 #include void ug_xmlrpc_value_dump (UgXmlrpcValue* value); void ug_xmlrpc_value_dump_data (UgXmlrpcValue* value) { UgXmlrpcValue* child; guint index; for (index = 0; index < value->len; index++) { child = value->data + index; if (child->name) g_print ("name = %s, ", child->name); else g_print ("index = %d, ", index); ug_xmlrpc_value_dump (child); } } void ug_xmlrpc_value_dump (UgXmlrpcValue* value) { switch (value->type) { case UG_XMLRPC_INT: g_print ("int = %d\n", value->c.int_); break; case UG_XMLRPC_INT64: g_print ("int64 = %lld\n", (long long) value->c.int64); break; case UG_XMLRPC_BOOLEAN: g_print ("boolean = %d\n", value->c.int_); break; case UG_XMLRPC_STRING: g_print ("string = '%s'\n", value->c.string); break; case UG_XMLRPC_DOUBLE: g_print ("double = %f\n", value->c.double_); break; case UG_XMLRPC_DATETIME: g_print ("datetime = '%s'\n", value->c.datetime); break; case UG_XMLRPC_BINARY: g_print ("binary data, length = %u\n", value->len); break; case UG_XMLRPC_NIL: g_print ("nil\n"); break; case UG_XMLRPC_ARRAY: g_print ("array --- start ---\n"); ug_xmlrpc_value_dump_data (value); g_print ("array --- end ---\n"); break; case UG_XMLRPC_STRUCT: g_print ("struct --- start ---\n"); ug_xmlrpc_value_dump_data (value); g_print ("struct --- end ---\n"); break; default: break; } } void aria2_getVersion (UgXmlrpc* xmlrpc) { UgXmlrpcValue* value; UgXmlrpcResponse response; g_print ("aria2.getVersion\n"); response = ug_xmlrpc_call (xmlrpc, "aria2.getVersion", UG_XMLRPC_NONE); switch (response) { case UG_XMLRPC_ERROR: g_print ("- error\n"); break; case UG_XMLRPC_FAULT: case UG_XMLRPC_OK: value = ug_xmlrpc_get_value (xmlrpc); ug_xmlrpc_value_dump (value); break; } g_print ("\n"); } void aria2_tellStatus (UgXmlrpc* xmlrpc) { UgXmlrpcValue* value; UgXmlrpcResponse response; g_print ("aria2.tellStatus\n"); response = ug_xmlrpc_call (xmlrpc, "aria2.tellStatus", UG_XMLRPC_STRING, "1", UG_XMLRPC_NONE); switch (response) { case UG_XMLRPC_ERROR: g_print ("- error\n"); break; case UG_XMLRPC_FAULT: case UG_XMLRPC_OK: value = ug_xmlrpc_get_value (xmlrpc); ug_xmlrpc_value_dump (value); break; } g_print ("\n"); } void aria2_changeGlobalOption (UgXmlrpc* xmlrpc) { UgXmlrpcValue* options; UgXmlrpcValue* member; UgXmlrpcValue* value; UgXmlrpcResponse response; g_print ("aria2.changeGlobalOption\n"); options = ug_xmlrpc_value_new_struct (2); // max-overall-download-limit member = ug_xmlrpc_value_alloc (options); member->name = "max-overall-download-limit"; member->type = UG_XMLRPC_STRING; member->c.string = g_strdup_printf ("%dK", 0); // max-overall-upload-limit member = ug_xmlrpc_value_alloc (options); member->name = "max-overall-upload-limit"; member->type = UG_XMLRPC_STRING; member->c.string = g_strdup_printf ("%dK", 0); response = ug_xmlrpc_call (xmlrpc, "aria2.changeGlobalOption", UG_XMLRPC_STRUCT, options, UG_XMLRPC_NONE); switch (response) { case UG_XMLRPC_ERROR: g_print ("- error\n"); break; case UG_XMLRPC_FAULT: case UG_XMLRPC_OK: value = ug_xmlrpc_get_value (xmlrpc); ug_xmlrpc_value_dump (value); break; } g_print ("\n"); ug_xmlrpc_value_free (options); } void test_xmlrpc (void) { UgXmlrpc* xmlrpc; xmlrpc = g_malloc0 (sizeof (UgXmlrpc)); ug_xmlrpc_init (xmlrpc); ug_xmlrpc_use_client (xmlrpc, "http://localhost:6800/rpc", NULL); aria2_getVersion (xmlrpc); aria2_tellStatus (xmlrpc); aria2_changeGlobalOption (xmlrpc); ug_xmlrpc_finalize (xmlrpc); g_free (xmlrpc); } #endif // HAVE_PLUGIN_ARIA2 int main (int argc, char* argv[]) { #ifdef _WIN32 WSADATA WSAData; WSAStartup (MAKEWORD (2, 2), &WSAData); #endif #ifdef HAVE_PLUGIN_ARIA2 test_xmlrpc (); #endif #ifdef _WIN32 WSACleanup (); #endif return 0; // EXIT_SUCCESS } uget-1.10.4/tests/test-ipc.c0000664000175000017500000000421712021236333012521 00000000000000#ifdef _WIN32 #include #include #include #else #include #endif #include #include #define COUNT_LIMIT 3 static gboolean server_timer (gpointer); static gpointer client_thread (gpointer); GMainLoop* main_loop; // server static gboolean server_timer (gpointer data) { static UgIpc ipc; static guint count = 0; static gboolean inited = FALSE; GPtrArray* args; if (inited == FALSE) { inited = TRUE; g_print ("Startup uGet IPC server...\n"); ug_ipc_init (&ipc, NULL); ug_ipc_use_server (&ipc); } if (count < COUNT_LIMIT) { args = ug_ipc_pop (&ipc); if (args) { ug_arg_free (args, TRUE); count++; } return TRUE; } g_print ("Shutdown uGet IPC server...\n"); // server shutdown ug_ipc_finalize (&ipc); // exit main loop g_main_loop_quit (main_loop); // exit thread return FALSE; } // client static gpointer client_thread (gpointer data) { UgIpc ipc; guint count; gchar* string = "http://test.org/index.htm"; g_print ("Connect to uGet IPC server...\n"); ug_ipc_init (&ipc, NULL); ug_ipc_use_client (&ipc); for (count=0; count < COUNT_LIMIT; count++) { // sleep 500,000 microseconds (0.5 seconds) g_usleep (500 * 1000); // ping g_print ("uGet IPC client: ping...\n"); if (ug_ipc_ping (&ipc) == FALSE) g_print ("uGet IPC client: ping fail\n"); else g_print ("uGet IPC client: ping ok\n"); // send g_print ("uGet IPC client: send...\n"); if (ug_ipc_send (&ipc, 1, &string) == FALSE) g_print ("uGet IPC client: send fail\n"); else g_print ("uGet IPC client: send ok\n"); } g_print ("Disconnect...\n"); // disconnect ug_ipc_finalize (&ipc); return NULL; } int main (int argc, char* argv[]) { #ifdef _WIN32 WSADATA WSAData; WSAStartup (MAKEWORD (2, 2), &WSAData); #endif main_loop = g_main_loop_new (NULL, FALSE); // start server server_timer (NULL); g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 500, (GSourceFunc) server_timer, NULL, NULL); // start client thread g_thread_new ("ipc-client", (GThreadFunc) client_thread, NULL); g_main_loop_run (main_loop); #ifdef _WIN32 WSACleanup (); #endif return 0; // EXIT_SUCCESS } uget-1.10.4/tests/Makefile.in0000664000175000017500000004060012260757434012705 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : noinst_PROGRAMS = test-download$(EXEEXT) test-conf$(EXEEXT) \ test-ipc$(EXEEXT) test-xmlrpc$(EXEEXT) subdir = tests DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am_test_conf_OBJECTS = test-conf.$(OBJEXT) test_conf_OBJECTS = $(am_test_conf_OBJECTS) am__DEPENDENCIES_1 = test_conf_DEPENDENCIES = $(top_builddir)/uglib/libuglib.a \ $(am__DEPENDENCIES_1) am_test_download_OBJECTS = test-download.$(OBJEXT) test_download_OBJECTS = $(am_test_download_OBJECTS) test_download_DEPENDENCIES = $(top_builddir)/uglib/libuglib.a \ $(am__DEPENDENCIES_1) am_test_ipc_OBJECTS = test-ipc.$(OBJEXT) test_ipc_OBJECTS = $(am_test_ipc_OBJECTS) test_ipc_DEPENDENCIES = $(top_builddir)/uglib/libuglib.a \ $(am__DEPENDENCIES_1) am_test_xmlrpc_OBJECTS = test-xmlrpc.$(OBJEXT) test_xmlrpc_OBJECTS = $(am_test_xmlrpc_OBJECTS) test_xmlrpc_DEPENDENCIES = $(top_builddir)/uglib/libuglib.a \ $(am__DEPENDENCIES_1) DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(test_conf_SOURCES) $(test_download_SOURCES) \ $(test_ipc_SOURCES) $(test_xmlrpc_SOURCES) DIST_SOURCES = $(test_conf_SOURCES) $(test_download_SOURCES) \ $(test_ipc_SOURCES) $(test_xmlrpc_SOURCES) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APP_INDICATOR_CFLAGS = @APP_INDICATOR_CFLAGS@ APP_INDICATOR_LIBS = @APP_INDICATOR_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURL_CFLAGS = @CURL_CFLAGS@ CURL_CONFIG = @CURL_CONFIG@ CURL_LIBS = @CURL_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETCONF = @GETCONF@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@ GSTREAMER_LIBS = @GSTREAMER_LIBS@ GTHREAD_CFLAGS = @GTHREAD_CFLAGS@ GTHREAD_LIBS = @GTHREAD_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ LDFLAGS = @LDFLAGS@ LFS_CFLAGS = @LFS_CFLAGS@ LFS_LDFLAGS = @LFS_LDFLAGS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ LIBPWMD_CFLAGS = @LIBPWMD_CFLAGS@ LIBPWMD_LIBS = @LIBPWMD_LIBS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ intltool__v_merge_options_ = @intltool__v_merge_options_@ intltool__v_merge_options_0 = @intltool__v_merge_options_0@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ TESTS_LIBS = @GLIB_LIBS@ @GIO_LIBS@ @GTHREAD_LIBS@ @GMODULE_LIBS@ @CURL_LIBS@ @LIBPWMD_LIBS@ # set the include path found by configure AM_CPPFLAGS = -I$(top_srcdir)/uglib -I$(top_srcdir)/tests AM_CFLAGS = @LFS_CFLAGS@ @GLIB_CFLAGS@ @GIO_CFLAGS@ @GTHREAD_CFLAGS@ @GMODULE_CFLAGS@ @CURL_CFLAGS@ @LIBPWMD_CFLAGS@ AM_LDFLAGS = @LFS_LDFLAGS@ test_download_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_download_SOURCES = test-download.c test_conf_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_conf_SOURCES = test-conf.c test_ipc_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_ipc_SOURCES = test-ipc.c test_xmlrpc_LDADD = $(top_builddir)/uglib/libuglib.a $(TESTS_LIBS) test_xmlrpc_SOURCES = test-xmlrpc.c all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu tests/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu tests/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): clean-noinstPROGRAMS: -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS) test-conf$(EXEEXT): $(test_conf_OBJECTS) $(test_conf_DEPENDENCIES) $(EXTRA_test_conf_DEPENDENCIES) @rm -f test-conf$(EXEEXT) $(LINK) $(test_conf_OBJECTS) $(test_conf_LDADD) $(LIBS) test-download$(EXEEXT): $(test_download_OBJECTS) $(test_download_DEPENDENCIES) $(EXTRA_test_download_DEPENDENCIES) @rm -f test-download$(EXEEXT) $(LINK) $(test_download_OBJECTS) $(test_download_LDADD) $(LIBS) test-ipc$(EXEEXT): $(test_ipc_OBJECTS) $(test_ipc_DEPENDENCIES) $(EXTRA_test_ipc_DEPENDENCIES) @rm -f test-ipc$(EXEEXT) $(LINK) $(test_ipc_OBJECTS) $(test_ipc_LDADD) $(LIBS) test-xmlrpc$(EXEEXT): $(test_xmlrpc_OBJECTS) $(test_xmlrpc_DEPENDENCIES) $(EXTRA_test_xmlrpc_DEPENDENCIES) @rm -f test-xmlrpc$(EXEEXT) $(LINK) $(test_xmlrpc_OBJECTS) $(test_xmlrpc_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-conf.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-download.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-ipc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/test-xmlrpc.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic clean-noinstPROGRAMS mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ clean-noinstPROGRAMS ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-data \ install-data-am install-dvi install-dvi-am install-exec \ install-exec-am install-html install-html-am install-info \ install-info-am install-man install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: uget-1.10.4/tests/test-conf.c0000664000175000017500000000231512165471260012701 00000000000000#include #include #include void test_conf () { UgMarkup* markup; UgDataset* dataset; UgetProgress* progress; UgetHttp* http; UgetFtp* ftp; markup = ug_markup_new (); dataset = ug_dataset_new (); progress = ug_dataset_realloc (dataset, UgetProgressInfo, 0); http = ug_dataset_realloc (dataset, UgetHttpInfo, 0); ftp = ug_dataset_realloc (dataset, UgetFtpInfo, 0); progress->total = 1484889; http->redirection_limit = 10; http->referrer = g_strdup ("http://123.123.123.1/ref"); ftp->user = g_strdup ("ftpuser"); ftp->password = g_strdup ("ftppassword"); ug_markup_write_start (markup, "test.ug.xml", TRUE); ug_data_write_markup ((UgData*) dataset, markup); ug_markup_write_end (markup); ug_dataset_unref (dataset); dataset = ug_dataset_new (); if (ug_markup_parse ("test.ug.xml", &ug_data_parser, dataset)) { progress = ug_dataset_realloc (dataset, UgetProgressInfo, 0); http = ug_dataset_realloc (dataset, UgetHttpInfo, 0); ftp = ug_dataset_realloc (dataset, UgetFtpInfo, 0); } ug_dataset_unref (dataset); ug_markup_free (markup); } int main (int argc, char* argv[]) { uglib_init (); test_conf (); uglib_finalize (); return 0; } uget-1.10.4/missing0000755000175000017500000002415211736361705011076 00000000000000#! /bin/sh # Common stub for a few missing GNU programs while installing. scriptversion=2012-01-06.13; # UTC # Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005, 2006, # 2008, 2009, 2010, 2011, 2012 Free Software Foundation, Inc. # Originally by Fran,cois Pinard , 1996. # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. if test $# -eq 0; then echo 1>&2 "Try \`$0 --help' for more information" exit 1 fi run=: sed_output='s/.* --output[ =]\([^ ]*\).*/\1/p' sed_minuso='s/.* -o \([^ ]*\).*/\1/p' # In the cases where this matters, `missing' is being run in the # srcdir already. if test -f configure.ac; then configure_ac=configure.ac else configure_ac=configure.in fi msg="missing on your system" case $1 in --run) # Try to run requested program, and just exit if it succeeds. run= shift "$@" && exit 0 # Exit code 63 means version mismatch. This often happens # when the user try to use an ancient version of a tool on # a file that requires a minimum version. In this case we # we should proceed has if the program had been absent, or # if --run hadn't been passed. if test $? = 63; then run=: msg="probably too old" fi ;; -h|--h|--he|--hel|--help) echo "\ $0 [OPTION]... PROGRAM [ARGUMENT]... Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an error status if there is no known handling for PROGRAM. Options: -h, --help display this help and exit -v, --version output version information and exit --run try to run the given command, and emulate it if it fails Supported PROGRAM values: aclocal touch file \`aclocal.m4' autoconf touch file \`configure' autoheader touch file \`config.h.in' autom4te touch the output file, or create a stub one automake touch all \`Makefile.in' files bison create \`y.tab.[ch]', if possible, from existing .[ch] flex create \`lex.yy.c', if possible, from existing .c help2man touch the output file lex create \`lex.yy.c', if possible, from existing .c makeinfo touch the output file yacc create \`y.tab.[ch]', if possible, from existing .[ch] Version suffixes to PROGRAM as well as the prefixes \`gnu-', \`gnu', and \`g' are ignored when checking the name. Send bug reports to ." exit $? ;; -v|--v|--ve|--ver|--vers|--versi|--versio|--version) echo "missing $scriptversion (GNU Automake)" exit $? ;; -*) echo 1>&2 "$0: Unknown \`$1' option" echo 1>&2 "Try \`$0 --help' for more information" exit 1 ;; esac # normalize program name to check for. program=`echo "$1" | sed ' s/^gnu-//; t s/^gnu//; t s/^g//; t'` # Now exit if we have it, but it failed. Also exit now if we # don't have it and --version was passed (most likely to detect # the program). This is about non-GNU programs, so use $1 not # $program. case $1 in lex*|yacc*) # Not GNU programs, they don't have --version. ;; *) if test -z "$run" && ($1 --version) > /dev/null 2>&1; then # We have it, but it failed. exit 1 elif test "x$2" = "x--version" || test "x$2" = "x--help"; then # Could not run --version or --help. This is probably someone # running `$TOOL --version' or `$TOOL --help' to check whether # $TOOL exists and not knowing $TOOL uses missing. exit 1 fi ;; esac # If it does not exist, or fails to run (possibly an outdated version), # try to emulate it. case $program in aclocal*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." touch aclocal.m4 ;; autoconf*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." touch configure ;; autoheader*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`acconfig.h' or \`${configure_ac}'. You might want to install the \`Autoconf' and \`GNU m4' packages. Grab them from any GNU archive site." files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` test -z "$files" && files="config.h" touch_files= for f in $files; do case $f in *:*) touch_files="$touch_files "`echo "$f" | sed -e 's/^[^:]*://' -e 's/:.*//'`;; *) touch_files="$touch_files $f.in";; esac done touch $touch_files ;; automake*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. You might want to install the \`Automake' and \`Perl' packages. Grab them from any GNU archive site." find . -type f -name Makefile.am -print | sed 's/\.am$/.in/' | while read f; do touch "$f"; done ;; autom4te*) echo 1>&2 "\ WARNING: \`$1' is needed, but is $msg. You might have modified some files without having the proper tools for further handling them. You can get \`$1' as part of \`Autoconf' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo "#! /bin/sh" echo "# Created by GNU Automake missing as a replacement of" echo "# $ $@" echo "exit 0" chmod +x $file exit 1 fi ;; bison*|yacc*) echo 1>&2 "\ WARNING: \`$1' $msg. You should only need it if you modified a \`.y' file. You may need the \`Bison' package in order for those modifications to take effect. You can get \`Bison' from any GNU archive site." rm -f y.tab.c y.tab.h if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.y) SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.c fi SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` if test -f "$SRCFILE"; then cp "$SRCFILE" y.tab.h fi ;; esac fi if test ! -f y.tab.h; then echo >y.tab.h fi if test ! -f y.tab.c; then echo 'main() { return 0; }' >y.tab.c fi ;; lex*|flex*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.l' file. You may need the \`Flex' package in order for those modifications to take effect. You can get \`Flex' from any GNU archive site." rm -f lex.yy.c if test $# -ne 1; then eval LASTARG=\${$#} case $LASTARG in *.l) SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` if test -f "$SRCFILE"; then cp "$SRCFILE" lex.yy.c fi ;; esac fi if test ! -f lex.yy.c; then echo 'main() { return 0; }' >lex.yy.c fi ;; help2man*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a dependency of a manual page. You may need the \`Help2man' package in order for those modifications to take effect. You can get \`Help2man' from any GNU archive site." file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -f "$file"; then touch $file else test -z "$file" || exec >$file echo ".ab help2man is required to generate this page" exit $? fi ;; makeinfo*) echo 1>&2 "\ WARNING: \`$1' is $msg. You should only need it if you modified a \`.texi' or \`.texinfo' file, or any other file indirectly affecting the aspect of the manual. The spurious call might also be the consequence of using a buggy \`make' (AIX, DU, IRIX). You might want to install the \`Texinfo' package or the \`GNU make' package. Grab either from any GNU archive site." # The file to touch is that specified with -o ... file=`echo "$*" | sed -n "$sed_output"` test -z "$file" && file=`echo "$*" | sed -n "$sed_minuso"` if test -z "$file"; then # ... or it is the one specified with @setfilename ... infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` file=`sed -n ' /^@setfilename/{ s/.* \([^ ]*\) *$/\1/ p q }' $infile` # ... or it is derived from the source name (dir/f.texi becomes f.info) test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info fi # If the file does not exist, the user really needs makeinfo; # let's fail without touching anything. test -f $file || exit 1 touch $file ;; *) echo 1>&2 "\ WARNING: \`$1' is needed, and is $msg. You might have modified some files without having the proper tools for further handling them. Check the \`README' file, it often tells you about the needed prerequisites for installing this package. You may also peek at any GNU archive site, in case some other package would contain this missing \`$1' program." exit 1 ;; esac exit 0 # Local variables: # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: uget-1.10.4/compile0000755000175000017500000001533711736361705011062 00000000000000#! /bin/sh # Wrapper for compilers which do not understand '-c -o'. scriptversion=2012-01-04.17; # UTC # Copyright (C) 1999, 2000, 2003, 2004, 2005, 2009, 2010, 2012 Free # Software Foundation, Inc. # Written by Tom Tromey . # # 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, 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, see . # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # This file is maintained in Automake, please report # bugs to or send patches to # . nl=' ' # We need space, tab and new line, in precisely that order. Quoting is # there to prevent tools from complaining about whitespace usage. IFS=" "" $nl" file_conv= # func_file_conv build_file lazy # Convert a $build file to $host form and store it in $file # Currently only supports Windows hosts. If the determined conversion # type is listed in (the comma separated) LAZY, no conversion will # take place. func_file_conv () { file=$1 case $file in / | /[!/]*) # absolute file, and not a UNC file if test -z "$file_conv"; then # lazily determine how to convert abs files case `uname -s` in MINGW*) file_conv=mingw ;; CYGWIN*) file_conv=cygwin ;; *) file_conv=wine ;; esac fi case $file_conv/,$2, in *,$file_conv,*) ;; mingw/*) file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` ;; cygwin/*) file=`cygpath -m "$file" || echo "$file"` ;; wine/*) file=`winepath -w "$file" || echo "$file"` ;; esac ;; esac } # func_cl_wrapper cl arg... # Adjust compile command to suit cl func_cl_wrapper () { # Assume a capable shell lib_path= shared=: linker_opts= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. eat=1 case $2 in *.o | *.[oO][bB][jJ]) func_file_conv "$2" set x "$@" -Fo"$file" shift ;; *) func_file_conv "$2" set x "$@" -Fe"$file" shift ;; esac ;; -I*) func_file_conv "${1#-I}" mingw set x "$@" -I"$file" shift ;; -l*) lib=${1#-l} found=no save_IFS=$IFS IFS=';' for dir in $lib_path $LIB do IFS=$save_IFS if $shared && test -f "$dir/$lib.dll.lib"; then found=yes set x "$@" "$dir/$lib.dll.lib" break fi if test -f "$dir/$lib.lib"; then found=yes set x "$@" "$dir/$lib.lib" break fi done IFS=$save_IFS test "$found" != yes && set x "$@" "$lib.lib" shift ;; -L*) func_file_conv "${1#-L}" if test -z "$lib_path"; then lib_path=$file else lib_path="$lib_path;$file" fi linker_opts="$linker_opts -LIBPATH:$file" ;; -static) shared=false ;; -Wl,*) arg=${1#-Wl,} save_ifs="$IFS"; IFS=',' for flag in $arg; do IFS="$save_ifs" linker_opts="$linker_opts $flag" done IFS="$save_ifs" ;; -Xlinker) eat=1 linker_opts="$linker_opts $2" ;; -*) set x "$@" "$1" shift ;; *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) func_file_conv "$1" set x "$@" -Tp"$file" shift ;; *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) func_file_conv "$1" mingw set x "$@" "$file" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -n "$linker_opts"; then linker_opts="-link$linker_opts" fi exec "$@" $linker_opts exit 1 } eat= case $1 in '') echo "$0: No command. Try '$0 --help' for more information." 1>&2 exit 1; ;; -h | --h*) cat <<\EOF Usage: compile [--help] [--version] PROGRAM [ARGS] Wrapper for compilers which do not understand '-c -o'. Remove '-o dest.o' from ARGS, run PROGRAM with the remaining arguments, and rename the output as expected. If you are trying to build a whole package this is not the right script to run: please start by reading the file 'INSTALL'. Report bugs to . EOF exit $? ;; -v | --v*) echo "compile $scriptversion" exit $? ;; cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac ofile= cfile= for arg do if test -n "$eat"; then eat= else case $1 in -o) # configure might choose to run compile as 'compile cc -o foo foo.c'. # So we strip '-o arg' only if arg is an object. eat=1 case $2 in *.o | *.obj) ofile=$2 ;; *) set x "$@" -o "$2" shift ;; esac ;; *.c) cfile=$1 set x "$@" "$1" shift ;; *) set x "$@" "$1" shift ;; esac fi shift done if test -z "$ofile" || test -z "$cfile"; then # If no '-o' option was seen then we might have been invoked from a # pattern rule where we don't need one. That is ok -- this is a # normal compilation that the losing compiler can handle. If no # '.c' file was seen then we are probably linking. That is also # ok. exec "$@" fi # Name of file we expect compiler to create. cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` # Create the lock directory. # Note: use '[/\\:.-]' here to ensure that we don't use the same name # that we are using for the .o file. Also, base the name on the expected # object file name, since that is what matters with a parallel build. lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d while true; do if mkdir "$lockdir" >/dev/null 2>&1; then break fi sleep 1 done # FIXME: race condition here if user kills between mkdir and trap. trap "rmdir '$lockdir'; exit 1" 1 2 15 # Run the compile. "$@" ret=$? if test -f "$cofile"; then test "$cofile" = "$ofile" || mv "$cofile" "$ofile" elif test -f "${cofile}bj"; then test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" fi rmdir "$lockdir" exit $ret # Local Variables: # mode: shell-script # sh-indentation: 2 # eval: (add-hook 'write-file-hooks 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-time-zone: "UTC" # time-stamp-end: "; # UTC" # End: uget-1.10.4/config.h.in0000664000175000017500000000662412260757454011533 00000000000000/* config.h.in. Generated from configure.ac by autoheader. */ /* always defined to indicate that i18n is enabled */ #undef ENABLE_NLS /* Have AppIndicator */ #undef HAVE_APP_INDICATOR /* Define to 1 if you have the `bind_textdomain_codeset' function. */ #undef HAVE_BIND_TEXTDOMAIN_CODESET /* Define to 1 if you have the `dcgettext' function. */ #undef HAVE_DCGETTEXT /* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT /* Define to 1 if gnutls support is required. */ #undef HAVE_GNUTLS /* Define to 1 if gstreamer support is required. */ #undef HAVE_GSTREAMER /* Define to 1 if you have the header file. */ #undef HAVE_INTTYPES_H /* Define if your file defines LC_MESSAGES. */ #undef HAVE_LC_MESSAGES /* Define to 1 if libnotify support is required. */ #undef HAVE_LIBNOTIFY /* Define to 1 if libpwmd support is required. */ #undef HAVE_LIBPWMD /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H /* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H /* Define to 1 to enable aria2 plug-in. */ #undef HAVE_PLUGIN_ARIA2 /* Define to 1 to enable cURL plug-in. */ #undef HAVE_PLUGIN_CURL /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H /* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H /* Define to 1 if you have the header file. */ #undef HAVE_STRING_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H /* Define to 1 to make temporary download files hidden. */ #undef HIDE_TEMPORARY_FILE /* Define the location where the catalogs will be installed */ #undef LOCALEDIR /* Define to 1 if your C compiler doesn't accept -c and -o together. */ #undef NO_MINUS_C_MINUS_O /* Name of package */ #undef PACKAGE /* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT /* Define to the full name of this package. */ #undef PACKAGE_NAME /* Define to the full name and version of this package. */ #undef PACKAGE_STRING /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME /* Define to the home page for this package. */ #undef PACKAGE_URL /* Define to the version of this package. */ #undef PACKAGE_VERSION /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # undef _ALL_SOURCE #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # undef _GNU_SOURCE #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # undef _POSIX_PTHREAD_SEMANTICS #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # undef _TANDEM_SOURCE #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # undef __EXTENSIONS__ #endif /* Version number of package */ #undef VERSION /* Define to 1 if on MINIX. */ #undef _MINIX /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ #undef _POSIX_1_SOURCE /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE uget-1.10.4/Makefile.am0000664000175000017500000000034211740440107011515 00000000000000# intltool : add "po" in SUBDIRS SUBDIRS = \ uglib \ uget-gtk \ uget-cmd \ tests \ pixmaps \ sounds \ po \ Windows EXTRA_DIST = uget-gtk.desktop appsdir = $(datadir)/applications apps_DATA = uget-gtk.desktop uget-1.10.4/Windows/0000775000175000017500000000000012260772033011200 500000000000000uget-1.10.4/Windows/msvc/0000775000175000017500000000000012260772033012150 500000000000000uget-1.10.4/Windows/msvc/uget.sln0000664000175000017500000001057011740440107013551 00000000000000 Microsoft Visual Studio Solution File, Format Version 10.00 # Visual C++ Express 2008 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uglib", "uglib.vcproj", "{742B79B4-66D8-471B-8720-BC789D706356}" EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-conf", "test-conf.vcproj", "{A40E98A3-72E3-4AA4-A0FD-BB54AF47E512}" ProjectSection(ProjectDependencies) = postProject {742B79B4-66D8-471B-8720-BC789D706356} = {742B79B4-66D8-471B-8720-BC789D706356} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-download", "test-download.vcproj", "{DCF37A71-2C88-4A41-A9EA-41CC56C82538}" ProjectSection(ProjectDependencies) = postProject {742B79B4-66D8-471B-8720-BC789D706356} = {742B79B4-66D8-471B-8720-BC789D706356} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-ipc", "test-ipc.vcproj", "{71F0938B-F2FC-467C-97DF-4C06FBBC0CE1}" ProjectSection(ProjectDependencies) = postProject {742B79B4-66D8-471B-8720-BC789D706356} = {742B79B4-66D8-471B-8720-BC789D706356} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uget-gtk", "uget-gtk.vcproj", "{9D164547-3F37-4C14-BCCE-91EB2F3DC317}" ProjectSection(ProjectDependencies) = postProject {742B79B4-66D8-471B-8720-BC789D706356} = {742B79B4-66D8-471B-8720-BC789D706356} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "uget-cmd", "uget-cmd.vcproj", "{EC1E1B1A-CA74-4BB1-B3B4-0DC1BF68D2EA}" ProjectSection(ProjectDependencies) = postProject {742B79B4-66D8-471B-8720-BC789D706356} = {742B79B4-66D8-471B-8720-BC789D706356} EndProjectSection EndProject Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-xmlrpc", "test-xmlrpc.vcproj", "{F43E17FF-786B-43B0-8702-9998797C5FD6}" ProjectSection(ProjectDependencies) = postProject {742B79B4-66D8-471B-8720-BC789D706356} = {742B79B4-66D8-471B-8720-BC789D706356} EndProjectSection EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 Release|Win32 = Release|Win32 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {742B79B4-66D8-471B-8720-BC789D706356}.Debug|Win32.ActiveCfg = Debug|Win32 {742B79B4-66D8-471B-8720-BC789D706356}.Debug|Win32.Build.0 = Debug|Win32 {742B79B4-66D8-471B-8720-BC789D706356}.Release|Win32.ActiveCfg = Release|Win32 {742B79B4-66D8-471B-8720-BC789D706356}.Release|Win32.Build.0 = Release|Win32 {A40E98A3-72E3-4AA4-A0FD-BB54AF47E512}.Debug|Win32.ActiveCfg = Debug|Win32 {A40E98A3-72E3-4AA4-A0FD-BB54AF47E512}.Debug|Win32.Build.0 = Debug|Win32 {A40E98A3-72E3-4AA4-A0FD-BB54AF47E512}.Release|Win32.ActiveCfg = Release|Win32 {A40E98A3-72E3-4AA4-A0FD-BB54AF47E512}.Release|Win32.Build.0 = Release|Win32 {DCF37A71-2C88-4A41-A9EA-41CC56C82538}.Debug|Win32.ActiveCfg = Debug|Win32 {DCF37A71-2C88-4A41-A9EA-41CC56C82538}.Debug|Win32.Build.0 = Debug|Win32 {DCF37A71-2C88-4A41-A9EA-41CC56C82538}.Release|Win32.ActiveCfg = Release|Win32 {DCF37A71-2C88-4A41-A9EA-41CC56C82538}.Release|Win32.Build.0 = Release|Win32 {71F0938B-F2FC-467C-97DF-4C06FBBC0CE1}.Debug|Win32.ActiveCfg = Debug|Win32 {71F0938B-F2FC-467C-97DF-4C06FBBC0CE1}.Debug|Win32.Build.0 = Debug|Win32 {71F0938B-F2FC-467C-97DF-4C06FBBC0CE1}.Release|Win32.ActiveCfg = Release|Win32 {71F0938B-F2FC-467C-97DF-4C06FBBC0CE1}.Release|Win32.Build.0 = Release|Win32 {9D164547-3F37-4C14-BCCE-91EB2F3DC317}.Debug|Win32.ActiveCfg = Debug|Win32 {9D164547-3F37-4C14-BCCE-91EB2F3DC317}.Debug|Win32.Build.0 = Debug|Win32 {9D164547-3F37-4C14-BCCE-91EB2F3DC317}.Release|Win32.ActiveCfg = Release|Win32 {9D164547-3F37-4C14-BCCE-91EB2F3DC317}.Release|Win32.Build.0 = Release|Win32 {EC1E1B1A-CA74-4BB1-B3B4-0DC1BF68D2EA}.Debug|Win32.ActiveCfg = Debug|Win32 {EC1E1B1A-CA74-4BB1-B3B4-0DC1BF68D2EA}.Debug|Win32.Build.0 = Debug|Win32 {EC1E1B1A-CA74-4BB1-B3B4-0DC1BF68D2EA}.Release|Win32.ActiveCfg = Release|Win32 {EC1E1B1A-CA74-4BB1-B3B4-0DC1BF68D2EA}.Release|Win32.Build.0 = Release|Win32 {F43E17FF-786B-43B0-8702-9998797C5FD6}.Debug|Win32.ActiveCfg = Debug|Win32 {F43E17FF-786B-43B0-8702-9998797C5FD6}.Debug|Win32.Build.0 = Debug|Win32 {F43E17FF-786B-43B0-8702-9998797C5FD6}.Release|Win32.ActiveCfg = Release|Win32 {F43E17FF-786B-43B0-8702-9998797C5FD6}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection EndGlobal uget-1.10.4/Windows/msvc/test-ipc.vcproj0000664000175000017500000001107212007236355015047 00000000000000 uget-1.10.4/Windows/msvc/uglib.vcproj0000664000175000017500000001435612165471260014432 00000000000000 uget-1.10.4/Windows/msvc/test-xmlrpc.vcproj0000664000175000017500000001117712007236355015607 00000000000000 uget-1.10.4/Windows/msvc/test-conf.vcproj0000664000175000017500000001112512007236355015220 00000000000000 uget-1.10.4/Windows/msvc/msvc-config.txt0000664000175000017500000000423512010700575015043 00000000000000--- include dir --- (C/C++ - General - Additional Include Directories) uglib D:\devpack\gtk3\include D:\devpack\gtk3\include\glib-2.0 D:\devpack\gtk3\lib\glib-2.0\include D:\devpack\curl-msvc\include ..\..\uglib uget-cmd D:\devpack\gtk3\include D:\devpack\gtk3\include\glib-2.0 D:\devpack\gtk3\lib\glib-2.0\include D:\devpack\curl-msvc\include ..\..\uglib ..\..\uget-cmd uget-gtk D:\devpack\gtk3\include D:\devpack\gtk3\include\glib-2.0 D:\devpack\gtk3\include\gtk-3.0 D:\devpack\gtk3\include\gdk-pixbuf-2.0 D:\devpack\gtk3\include\pango-1.0 D:\devpack\gtk3\include\atk-1.0 D:\devpack\gtk3\include\cairo D:\devpack\gtk3\lib\glib-2.0\include D:\devpack\gtk3\lib\gtk-3.0\include D:\devpack\curl-msvc\include ..\..\uglib ..\..\uget-gtk --- lib dir --- (Linker - General - Additional Library Directories) D:\devpack\gtk3\lib D:\devpack\curl-msvc\lib Debug Release --- lib --- (Linker - Input - Additional Dependencies) glib-2.0.lib gthread-2.0.lib gmodule-2.0.lib gobject-2.0.lib gtk-3.lib gdk-3.lib gdk_pixbuf-2.0.lib pango-1.0.lib pangowin32-1.0.lib atk-1.0.lib cairo.lib intl.lib libcurl.lib Ws2_32.lib Winmm.lib --- project (solution) --- 1. Caeate Name : ProjectName Location : path\ProjectDir Don't "Create directory for solution" 2. Rename path\ProjectDir\ProjectName to path\ProjectDir\msvc 3. Commit follow file only *.sln *.vcproj --- project type --- 1. Windows Console (Linker - System - SubSystem) - Select "Console" (C/C++ - Preprocessor - Preprocessor Definitions) - add "_CONSOLE", remove "_WINDOWS" 2. Windows GUI (Linker - System - SubSystem) - Select "Windows" (C/C++ - Preprocessor - Preprocessor Definitions) - add "_WINDOWS", remove "_CONSOLE" 3. Windows Dynamic Library (DLL) (General - Configuration Type) - Select "Dynamic Library (.dll)" (C/C++ - Preprocessor - Preprocessor Definitions) - add "_USRDLL" 4. Windows Static Library (LIB) (General - Configuration Type) - Select "Static Library (.lib)" (C/C++ - Preprocessor - Preprocessor Definitions) - add "_LIB" --- debug --- (Debug - Environment) - add "PATH=C:\Program Files\gtk3-Runtime\bin" or add "PATH=C:\Program Files\Common Files\GTK\3.0\bin" uget-1.10.4/Windows/msvc/uget-gtk.vcproj0000664000175000017500000001762112010700575015046 00000000000000 uget-1.10.4/Windows/msvc/test-download.vcproj0000664000175000017500000001123312007236355016102 00000000000000 uget-1.10.4/Windows/msvc/uget-cmd.vcproj0000664000175000017500000001141112007236355015021 00000000000000 uget-1.10.4/Windows/make-pot.bat0000664000175000017500000000106311740440107013321 00000000000000rem --- create uget-filelist.txt dir /b ..\uglib\*.c ..\uglib\*.h ..\uget-gtk\*.c ..\uget-gtk\*.h > uget-filelist.txt rem --- GetText for Windows rem --- http://sourceforge.net/projects/gnuwin32/ rem --- http://gnuwin32.sourceforge.net/packages/gettext.htm xgettext -C -s -D ..\src -D ..\uget-gtk -f uget-filelist.txt --keyword=_ --keyword=N_ -o ..\po\uget.pot rem --- merge files rem msgmerge ..\po\de.po ..\po\uget.pot rem msgmerge ..\po\es.po ..\po\uget.pot rem msgmerge ..\po\zh_CN.po ..\po\uget.pot rem msgmerge ..\po\zh_TW.po ..\po\uget.pot pause uget-1.10.4/Windows/Makefile.am0000664000175000017500000000113012007227722013146 00000000000000EXTRA_DIST = \ make-pot.bat \ nsis/uget-no-gtk.nsi \ nsis/License-install.txt \ resources/uget.rc \ resources/uget-icon.ico \ msvc/msvc-config.txt \ msvc/test-conf.vcproj \ msvc/test-download.vcproj \ msvc/test-ipc.vcproj \ msvc/test-xmlrpc.vcproj \ msvc/uget.sln \ msvc/uget-cmd.vcproj \ msvc/uget-gtk.vcproj \ msvc/uglib.vcproj \ CodeBlocks/mingw-config.txt \ CodeBlocks/test-conf.cbp \ CodeBlocks/test-download.cbp \ CodeBlocks/test-ipc.cbp \ CodeBlocks/test-xmlrpc.cbp \ CodeBlocks/uget.workspace \ CodeBlocks/uget-cmd.cbp \ CodeBlocks/uget-gtk.cbp \ CodeBlocks/uglib.cbp uget-1.10.4/Windows/CodeBlocks/0000775000175000017500000000000012260772033013210 500000000000000uget-1.10.4/Windows/CodeBlocks/uget-cmd.cbp0000664000175000017500000000403112007236355015322 00000000000000 uget-1.10.4/Windows/CodeBlocks/uget-gtk.cbp0000664000175000017500000001270612226461337015357 00000000000000 uget-1.10.4/Windows/CodeBlocks/test-conf.cbp0000664000175000017500000000332212007236355015521 00000000000000 uget-1.10.4/Windows/CodeBlocks/test-download.cbp0000664000175000017500000000334212007236355016405 00000000000000 uget-1.10.4/Windows/CodeBlocks/test-xmlrpc.cbp0000664000175000017500000000340212007236355016100 00000000000000 uget-1.10.4/Windows/CodeBlocks/uglib.cbp0000664000175000017500000000777112165471260014736 00000000000000 uget-1.10.4/Windows/CodeBlocks/uget.workspace0000664000175000017500000000067711740440107016022 00000000000000 uget-1.10.4/Windows/CodeBlocks/mingw-config.txt0000664000175000017500000000162512010700575016254 00000000000000--- include dir --- uglib D:\devpack\gtk3\include D:\devpack\gtk3\include\glib-2.0 D:\devpack\gtk3\lib\glib-2.0\include D:\devpack\curl-mingw\include ..\..\uglib uget-cmd D:\devpack\gtk3\include D:\devpack\gtk3\include\glib-2.0 D:\devpack\gtk3\lib\glib-2.0\include D:\devpack\curl-mingw\include ..\..\uglib ..\..\uget-cmd uget-gtk D:\devpack\gtk3\include D:\devpack\gtk3\include\glib-2.0 D:\devpack\gtk3\include\gtk-3.0 D:\devpack\gtk3\include\gdk-pixbuf-2.0 D:\devpack\gtk3\include\pango-1.0 D:\devpack\gtk3\include\atk-1.0 D:\devpack\gtk3\include\cairo D:\devpack\gtk3\lib\glib-2.0\include D:\devpack\gtk3\lib\gtk-3.0\include D:\devpack\curl-mingw\include ..\..\uglib ..\..\uget-gtk --- lib dir --- D:\devpack\gtk3\lib D:\devpack\curl-mingw\lib Debug Release --- lib --- uglib glib-2.0.dll gthread-2.0.dll gmodule-2.0.dll gobject-2.0.dll gtk-3.dll gdk-3.dll gdk_pixbuf-2.0.dll intl.dll curldll ws2_32 winmm uget-1.10.4/Windows/CodeBlocks/test-ipc.cbp0000664000175000017500000000331612007236355015352 00000000000000 uget-1.10.4/Windows/resources/0000775000175000017500000000000012260772033013212 500000000000000uget-1.10.4/Windows/resources/uget-icon.ico0000664000175000017500000004220612165471260015526 00000000000000 hF   600 %(  ^4NW.S-S-S-S-S-S-S-S-S-S-S-S-W.^4N[2*F.N.N.N.N.N.N.N.N.N.N.N.N*F[2!]54R4R4R4R4R4R4R4R4R4R4R4R4R4R!]5&a::X:X:X:X/|F l+ q* r+ p* o* q*&s69V:X&a:*f>@^=Z-u@,t?o${% '%w2+v>x${%")2{B@^*f>/lCEc%j2k o!w$%+3:B]Ec%o2x$&,6BEc/lC4pHKh"f,l!-s<{%07CYKhKhFa n)%,9EKh4pH9uMQm#g.l!AWw&5{CJbQmQmJd6{I!y(:FQm9uM?zTWs%i.k E[p!'y,7{AWsWs5vEf t%;}FWs?zTDX]x/o<$i-J_g p&5x?]x]xMc=}N?PPf]xDXI]c~c~c~Ncbl#5u?c~c~;xJ`l#={Gc~I]Pciiibz` h"6s>ii>zMa&m*A|KiPcViooooVi-l52q;0o9&h0&g/)k35s?HUoVi\p}uuuuuuuuuuuu}\p_sҌʪʪʪʪʪʪʪʪʪʪʪʪ_sdwEaubvbvbvbvbvbvbvbvbvbvbvbvaudwE(0 +{{+4,yF:X>Z@\D_E`HbJeMfMfJeHbE`D_@\>Z:X,yF4 )xC/N0N1O3Q4R5R5R5R5R5R5R5R5R4R3Q1O0N/N)xC "1P4R8V=Z?\A]A];U5K7N7N7N7N7N2|F6MR!j)q"w${%}%"k(:U9X @^wJw}hmpr%\-^h$h)D|Osss[lObi!'k,B|N}lotuHVSd!f&C~Ouuu]oTc k&*k0E}Qnquvw9oDQ["X#NFDIS\$c(*b/E{QŸpsuvwwi~VeQ`Q`O^M]M\O^P_ScSc`uŸ |uuvvvvvvvvvvvvuu| x\ĤܙȨȩȩȩȩȩȩȩȩȩȩȩȩȩȩȨĤx\ ( @ ]_^<;< <;< ]_^AAA >|                        |>AAA 0:&L&N'P)Q+R-T.U0V1W2X3Y5Y6Z6Z5Y3Y2X1W0V.U-T+R)Q'P&N&L:0srrU&L&T$P%Q%Q%Q&R&R&R&R&R%Q%Q%Q%Q%Q%Q&R&R&R&R&R%Q%Q%Q$P&T&LUsrr:79\'Q&S&R'T(T(U)U*U*U*U*U*U*U*V*V*U*U*U*U*U*U)U(U(T'T&R&S'Q\:79@=?Z*R)V)V+V,W-X-X.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y.Y-X-X,W+V)V)V*RZ@=??<>Y+U,Y,X-Z/[1\2\2\2\0X#<p.j(l(m(n(m(l(l(k(p-!y4$>.Y-Z,X,Y+UY?<>?<>X-W.[/[2\3]4_5_6_2Xa$hr"w${%{%v$q#t#w#w#v$u$p"k'/V/[.[-WX?<>?<>W/Y1_2]4_6a7b8c8cg(m w$|%&!(!~(s)-Lk!x${%|%& '!|($t32]1_/YW?<>?<>W2[3a5_,Mg*g)h)l)k!v${% '%,)/&q,5X;d(@k x$z%~&!('.(s,0Q3a2[W?<>?<>U3^6c1VYin!p"r"v$z% ~&'--3.y34P=h=h=h!p0n!y$|%#))/+z1/J6c3^U?<>><=T7`8e'@bq"r"p"r#y%}&$+,3064F@j@j@j@j<=><=T9c:h'@dq"j (<"v/u""~((.-~31z=AjBlBlBlBlBl7Yat"|%'-,x13O:h9cT><=><=Q=e<=><=Q?h>k)Bap"^Fp.Fj !x'#o(:XGqGqGqGqGqGqGqGqGq$t4n!%{++u06Q>k?hQ><=><=PCl@n+Dbo!\Js/Ghs"&y18S:TAbJsJsJsJsJs4P3M1Il!$y**s/7S@nClP><==<<ODlBo,Ean ZKu/Gdp!o"!m'&h+5KKuKuKuKuKuT[cn "w((q.7PBoDlO=<<=<<NHqEr-F`m!YNw1Han!q"#u))q.8MNwNwNwNwNwT!Y_c j%&e*6PErHqN=<<=<<MJrFs.G[gTPy2J^j m!!r')p.:OQzQzQzQzQz9T7P6Q7Q8R9UBhFsJrM=<<=<<LNuHv6T_) e+ _,R|3K[h k!!p')n.;PR|R|R|R|R|EiDgEgEfEfDfGpHvNuL=<<=<<JQyJxMyQ{R}S}T~4KXei n&'l,;OT~T~T~T~T~NOTX] Z$:UJxQyJ=<<=<<IT{LzP{S~UVWŀ9RVdhm$&i);PWŀWŀWŀWŀWŀV"^cg m%&g*=WLzT{I=<<<<<HW~N}RTŀVƀWƁXƃCdPbfk$#f(9PXƃXƃXƃXƃXƃV"]cg"m(&h,?ZN}W~H<<<<<<GYP~S~WǂXȂZȄ[ȄZƄ ^+Zdh" d%WRʁ\F<<<=<=E_ŜWȃXɅYɄ[Ɇ]ɇ]ʇ]ʇY:S.t?&g2'h3'g1#d/!c-!b-!b-!b-#d/'g3+k7/n:/j;EcŜ_E=<=766DaÇU΃WɄXʅZˆ[ˇ\ˇ\ˇ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ\ˇ\ˇ[ˇZˆXʅWɄU΃aÇD766onnBcÈU΃YʆYˆZˇ[ˈ[ˇ\ˇ\ˇ\ˈ\ˈ\ˈ\ˈ\ˈ\ˈ\ˈ\ˈ\ˈ\ˈ\ˇ\ˇ[ˇ[ˈZˇYˆYʆU΃cÈBonn&xʘaّXЇYщYщZщ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъ[ъZщYщYщXЇaّxʘ&755(A2huvx•x•x–x–y–y–y–y–y–y–y–y–y–y–y–y–y–y–x–x–x•x•vu(A2h755`]_QRR$$$$$$QRR`]_(0` hhhdee                                    deehhhqqq(7====================================7(qqqCw                                      wC 8^.&L)Q*Q+R,S/U0V2W3X4Y5Y7[7[9\:^<`>`>`@a@a>`>`<`:^9\7[7[5Y4Y3X2W0V/U,S+R*Q)Q&L^.8 Y_0*Z%Q$P$P$P%R%R&R&R&R&S&S&S&S&S&S'S'S'S'S'S'S'S'S&S&S&S&S&S&S&R&R&R%R%Q%Q$P$P%Q*Z_0Yn%K%Q$O$O%O%P%P&P&P&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&Q&P&P%P%P%P$O$O%Q%Kn_`` r&O&R&Q&Q&R'T'R'S(S(U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U)U(U(S'S'S&R&S&Q&Q&R&O r_``ijj p'Q'U'U'U(V)V*V+V+V+W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W,W+W+V+V*V)V(V'U'U'U'Q pijjhhh p(R)V*V*V+V,W,X-Y.X.Y.Z/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y/Y.Z.Y.X-Y,X,W+V*V*V)V(R phhhhhh o(S*W*W,W,Y-Y/Y/[0[1[1\1\2\2\2\0W'B%9%9%9%9%9%9%9%9%9%9%9%9%9$9$9'B-S/[/Z-Y,Y,W*W*W(S ohhhhhh n+U,Z,Z-Z/[0\2\2\3]3]3]4_3]2\'=t$t#w$x$z%{%{&v$q#u#y%y%x$x$x$y%{%{&x$v,+N0\/[-Z,Z,Z+U nhhhhhh m,U/\/[0\1\2\3^4_5_6`6`6`5^#4s#t#w$y%{%}& ~&z%dUe w#z%y%y%y%z%|%~& '|&i#+M1\0\/[/\,U mhhhhhh m-X0^0\2]2^4_5`7b7b8b8c8c'<r"s"u#x${%}%&}%k G@1Tm%w#y$x$y$z${%~%& '!y&^$/V2]0\0^-X mhhhhhh l.W2_1]3_4_6a5\1U1U1V2V2Ss$s"u#w$z%}& ' ' t%T4.O9d.Om!w$x$x$y${%}&&")$+!i'%t:3_1]2_.W lhhhhhh k/X2`3^5`6a(>p#o"o"p"p"q"r#t#w$z%}& '$+%{, `%>(t>;d;d;d(?o"v$w$x$z%}& '#*(/&r+ P&5`3^2`/X khhhhhh j0Z4b5`5b)An!n!o!o!p!q"r"t#w#y$|% &%+).&k+ J#$Z1=f=g=g=gZq"x${%!}'&,(z.'b+%G'4~KBkBkBkBkBkBkBkBkBk+Ais"v#z$"~((.)s.%O'5[9e8f8a hhhhhhh f;c:h;h4Wj k m!Z 2DmCm'8w$z%"})%y,%f)!I$,`:DmDmDmDmDmDmDmDmDmDmCl"p0j s#w${&&-(q.$N'8\;h:h;c fhhhhhh e=e;iaFqFqFqFqFqFqFqFqFqFqFqFqFq:\j!t#x$&},(o-%N':^=j=j?h  ehhhhhh  dAi>k?k8Zi j l!Z 2HqHr(9s#u$n#a!7PIqIqIqIqIqIqIqIqIqIqIqIqIqIqHr0Hq#v$$z+&m,$L&<`?k>kAi  dhhhhhh  dDl?nBm8Zij l Y 1JsJs(8q"s"r"!t(2E4G4H2xDCgJsJsJsJsJsJsJs?`+?,?,@-Ar#t##y)&l+#K&=`Bm?nDl  dhhhhhh  bFn@nCo:]h i k!X 1KtKu(8n"p"r#t$!v'&x,'l,"K%@`KuKuKuKuKuKuKu8Udegj n!r##w)&j+#J&>cCo@nFn  bhhhhhh  `IpBoEq;]hij X 0LwMw'8l n!p!r" t%$w*&k+"K%@bLwLwLwLwLwLwLw8U\]`cfi n%#b( F#?cEqBoIp  `hhhhhh  `KrCpEr;^gh i V /NwNw(~8i k!m!o"r%$u*&j+"J%CcOxOxOxOxOxOxOx8T@ACEGJOJ < ?dErCpKr  `hhhhhh  `MtEqGs=^`aaP - PyPy(~8hil n!p##t)&i*"J%DdPyPyPyPyPyPyPyAb&g8'g8'g8'i8'i8&k8*m<,n?-k?GpGsEqMt  `hhhhhh  ^PwEsIu<^EEE9 $ Q{Q{)}9fhj l o#"s(&h*"J%EeQ{Q{Q{Q{Q{Q{Q{Q{Q{Q{Q{Q{Q{QzPyLwKwJvIuEsPw  ^hhhhhh  ^SxGuJwEm%d7&d8&d8&c8)g_acfh l%"a'E!HiWŁWŁWŁWŁWŁWŁWŁ?\[]_bfi "m'$b' D#GkN{KzZ~ [hhhhhh Y\L|P}R}R~SŀVƀWƁXƂXƃXƃ8P]`cegk$!`&CIjXƃXƃXƃXƃXƃXƃXƃ@][]`cfi#$n)&c*"F%IlP}L|\ YhhhhhhY^M}Q}R~TƀVƁWǁXǂYǃYǃYDŽOuT^bdfi#b%M JkYDŽYDŽYDŽYDŽYDŽYDŽYDŽA^\^`cfj%&n+&c+#E&ImQ}M}^YhhhhhhX`N}R~RVȀWȀXǂYɃZɄ[Ʉ\Ʌ\Ʌ2}FT`ceh" h% a%Ji[Ʌ[Ʌ[Ʌ[Ʌ[Ʌ[Ʌ[ɅC_\_adg""k''o,'b+#E%InR~N}`XhhhhhhWbPʀSTȁVɁXȃYɅYɄZɄ\Ʌ\Ʌ\Ɇ\Dž&e4MV[` b#c$c$` ^\ZYXVVXY\^b##e('h,(],#C%JpSPʀbWhhhhhhWdQʀTǁUɁVɂXɅYɅZɄ[Ʌ\Ɇ]Ɇ]Ɇ]Ɇ[Ń1uE;@EGIIFDBA@@??@ACGK N#$Q&$K&!:#KpTǁQʀdWhhhhhhVg‰R̂VɃVɂXɅXʅZʆZʅ[ʆ]ʇ]ʇ]ʈ]ʈ]ʈ]ʈV~@\2rG/jA0kB0kB/jA.i@,h>+f=+f=+f=+f=+f=+f=,h>.i@1lC2nD3oE5qH5pH5mHR{VɃR̂g‰VhhhgggThÌS̓WɄVʄXʅX˄YˆZˇ[ˆ\ˆ\ˇ\ˇ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ]ˈ\ˇ\ˇ\ˆ[ˆZˇYˆXʅXʅVʄWɄS̓hÌTgggnnnTjčT΃XʅX˄X˄X˄ZˆZˇ\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇\̇ZˇZˆX˄X˄X˄XʅT΃jčTnnn MmĐVφYˆY̆Y̆ŻŻ[̈\̉\̉\͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉]͉\͉\̉\̉[̈ŻŻY̆Y̆YˆVφmĐ M ;|ǙXφV˄X̆X̆X̆ẊẎẎẎŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻŻẎẎẎẊX̆X̆X̆V˄Xφ|Ǚ;EEEizڳcЎ`ҍ`ҍaҎaҎaҎaҎaҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎbҎaҎaҎaҎaҎaҎ`ҍ`ҍcЎڳizEEE i{ȥ˨ͪͪͪͪͪͪͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͫͪͪͪͪͪͪ˨ȥi{ ?>>?>>srrmmmnmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmnmmmmmsrruget-1.10.4/Windows/resources/uget.rc0000664000175000017500000000005311740440107014416 00000000000000MAINICON ICON DISCARDABLE "uget-icon.ico" uget-1.10.4/Windows/Makefile.in0000664000175000017500000002577612260757434013216 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = Windows DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APP_INDICATOR_CFLAGS = @APP_INDICATOR_CFLAGS@ APP_INDICATOR_LIBS = @APP_INDICATOR_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURL_CFLAGS = @CURL_CFLAGS@ CURL_CONFIG = @CURL_CONFIG@ CURL_LIBS = @CURL_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETCONF = @GETCONF@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@ GSTREAMER_LIBS = @GSTREAMER_LIBS@ GTHREAD_CFLAGS = @GTHREAD_CFLAGS@ GTHREAD_LIBS = @GTHREAD_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ LDFLAGS = @LDFLAGS@ LFS_CFLAGS = @LFS_CFLAGS@ LFS_LDFLAGS = @LFS_LDFLAGS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ LIBPWMD_CFLAGS = @LIBPWMD_CFLAGS@ LIBPWMD_LIBS = @LIBPWMD_LIBS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ intltool__v_merge_options_ = @intltool__v_merge_options_@ intltool__v_merge_options_0 = @intltool__v_merge_options_0@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = \ make-pot.bat \ nsis/uget-no-gtk.nsi \ nsis/License-install.txt \ resources/uget.rc \ resources/uget-icon.ico \ msvc/msvc-config.txt \ msvc/test-conf.vcproj \ msvc/test-download.vcproj \ msvc/test-ipc.vcproj \ msvc/test-xmlrpc.vcproj \ msvc/uget.sln \ msvc/uget-cmd.vcproj \ msvc/uget-gtk.vcproj \ msvc/uglib.vcproj \ CodeBlocks/mingw-config.txt \ CodeBlocks/test-conf.cbp \ CodeBlocks/test-download.cbp \ CodeBlocks/test-ipc.cbp \ CodeBlocks/test-xmlrpc.cbp \ CodeBlocks/uget.workspace \ CodeBlocks/uget-cmd.cbp \ CodeBlocks/uget-gtk.cbp \ CodeBlocks/uglib.cbp all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu Windows/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu Windows/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile installdirs: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-strip installcheck installcheck-am installdirs \ maintainer-clean maintainer-clean-generic mostlyclean \ mostlyclean-generic pdf pdf-am ps ps-am uninstall uninstall-am # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: uget-1.10.4/Windows/nsis/0000775000175000017500000000000012260772033012154 500000000000000uget-1.10.4/Windows/nsis/uget-no-gtk.nsi0000664000175000017500000001525212007236355014756 00000000000000;-------------------------------- ;Include Modern UI !include "MUI2.nsh" ;-------------------------------- ;General ;Name and file Name "uGet" OutFile "uget-no-gtk.exe" ;Default installation folder ; InstallDir "$LOCALAPPDATA\uGet" InstallDir "$PROGRAMFILES\uGet" ;Get installation folder from registry if available InstallDirRegKey HKLM "Software\uGet" "" ;Request application privileges for Windows Vista RequestExecutionLevel user ;-------------------------------- ;Variables ; MUI_PAGE_STARTMENU Var StartMenuFolder ;-------------------------------- ;Interface Settings !define MUI_HEADERIMAGE ; !define MUI_HEADERIMAGE_BITMAP ".\pixmaps\uget-icon-32x32.bmp" ; optional !define MUI_ABORTWARNING ;-------------------------------- ;Pages !insertmacro MUI_PAGE_LICENSE ".\License-install.txt" !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_DIRECTORY ;Start Menu Folder Page Configuration !define MUI_STARTMENUPAGE_REGISTRY_ROOT "HKLM" !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\uGet" !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" !insertmacro MUI_PAGE_STARTMENU Application $StartMenuFolder ; Function Page custom DetectAndSetupGTK !insertmacro MUI_PAGE_INSTFILES ;Finish Page config !define MUI_FINISHPAGE_RUN "$INSTDIR\uget.exe" !insertmacro MUI_PAGE_FINISH !insertmacro MUI_UNPAGE_CONFIRM !insertmacro MUI_UNPAGE_INSTFILES ;-------------------------------- ;Languages !insertmacro MUI_LANGUAGE "English" ;-------------------------------- ;Installer Sections Section "uGet program" uGetProgram ; All file and folder placed in .\archive SetOutPath "$INSTDIR" File /r .\archive\*.* ; main program File ..\CodeBlocks\Release\uget.exe ; icons SetOutPath "$INSTDIR\icons\hicolor\" File ..\..\pixmaps\icons\hicolor\index.theme SetOutPath "$INSTDIR\icons\hicolor\16x16\apps" File ..\..\pixmaps\icons\hicolor\16x16\apps\uget-icon.png File ..\..\pixmaps\icons\hicolor\16x16\apps\uget-error.png File ..\..\pixmaps\icons\hicolor\16x16\apps\uget-downloading.png SetOutPath "$INSTDIR\icons\hicolor\24x24\apps" File ..\..\pixmaps\icons\hicolor\24x24\apps\uget-icon.png File ..\..\pixmaps\icons\hicolor\24x24\apps\uget-error.png File ..\..\pixmaps\icons\hicolor\24x24\apps\uget-downloading.png SetOutPath "$INSTDIR\icons\hicolor\32x32\apps" File ..\..\pixmaps\icons\hicolor\32x32\apps\uget-icon.png File ..\..\pixmaps\icons\hicolor\32x32\apps\uget-error.png File ..\..\pixmaps\icons\hicolor\32x32\apps\uget-downloading.png SetOutPath "$INSTDIR\icons\hicolor\48x48\apps" File ..\..\pixmaps\icons\hicolor\48x48\apps\uget-icon.png File ..\..\pixmaps\icons\hicolor\48x48\apps\uget-error.png File ..\..\pixmaps\icons\hicolor\48x48\apps\uget-downloading.png SetOutPath "$INSTDIR\icons\hicolor\64x64\apps" File ..\..\pixmaps\icons\hicolor\64x64\apps\uget-icon.png SetOutPath "$INSTDIR\icons\hicolor\128x128\apps" File ..\..\pixmaps\icons\hicolor\128x128\apps\uget-icon.png SetOutPath "$INSTDIR\icons\hicolor\scalable\apps\" File ..\..\pixmaps\icons\hicolor\scalable\apps\uget-icon.svg ; pixmaps ; SetOutPath "$INSTDIR\pixmaps\uget" ; File ..\..\pixmaps\logo.png ; sounds SetOutPath "$INSTDIR\sounds\uget" File ..\..\sounds\notification.wav ;Store installation folder WriteRegStr HKLM "Software\uGet" "" $INSTDIR ; Write the uninstall keys for Windows WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\uGet" "DisplayName" "uGet" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\uGet" "UninstallString" '"$INSTDIR\Uninstall.exe"' WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\uGet" "NoModify" 1 WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\uGet" "NoRepair" 1 ;Create uninstaller WriteUninstaller "$INSTDIR\Uninstall.exe" ; MUI_PAGE_STARTMENU !insertmacro MUI_STARTMENU_WRITE_BEGIN Application ;Create shortcuts CreateDirectory "$SMPROGRAMS\$StartMenuFolder" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\uGet.lnk" "$INSTDIR\uget.exe" CreateShortCut "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" "$INSTDIR\Uninstall.exe" !insertmacro MUI_STARTMENU_WRITE_END SectionEnd ;-------------------------------- ;Descriptions ;Language strings LangString DESC_uGetProgram ${LANG_ENGLISH} "Install uGet main program." ;Assign language strings to sections !insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN !insertmacro MUI_DESCRIPTION_TEXT ${uGetProgram} $(DESC_uGetProgram) !insertmacro MUI_FUNCTION_DESCRIPTION_END ;-------------------------------- ;Uninstaller Section Section "Uninstall" ; Remove the uninstall keys for Windows DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\uGet" ; Remove registry keys (installation folder and Path) DeleteRegKey HKLM SOFTWARE\uGet DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\uget.exe" ;ADD YOUR OWN FILES HERE... Delete $INSTDIR\uget.exe ; libcurl & OpenSSL Delete $INSTDIR\libcurl.dll Delete $INSTDIR\libeay32.dll Delete $INSTDIR\libidn-11.dll Delete $INSTDIR\libssh2.dll Delete $INSTDIR\libssl32.dll Delete $INSTDIR\zlib1.dll ; License Delete $INSTDIR\COPYING Delete $INSTDIR\COPYING.libcurl Delete $INSTDIR\LICENSE.OpenSSL ; delete folder RMDir /r "$INSTDIR\pixmaps" RMDir /r "$INSTDIR\icons" RMDir /r "$INSTDIR\locale" RMDir /r "$INSTDIR\sounds" Delete "$INSTDIR\Uninstall.exe" RMDir "$INSTDIR" ; MUI_PAGE_STARTMENU !insertmacro MUI_STARTMENU_GETFOLDER Application $StartMenuFolder Delete "$SMPROGRAMS\$StartMenuFolder\uGet.lnk" Delete "$SMPROGRAMS\$StartMenuFolder\Uninstall.lnk" RMDir "$SMPROGRAMS\$StartMenuFolder" DeleteRegKey /ifempty HKLM "Software\uGet" SectionEnd ; ----------------------------------------------------------------------------- ; Functions Function DetectAndSetupGTK ReadRegStr $0 HKLM "Software\GTK\3.0" Version ; StrCmp str1 str2 jump_if_equal [jump_if_not_equal] StrCmp $0 "" GtkNotInst GtkInst GtkNotInst: MessageBox MB_OK|MB_ICONSTOP "GTK+ Runtime Environment version 3.4.x or newer is required to use uGet.$\n$\nYou can download it from http://gtk-win.sourceforge.net/" Quit GtkInst: ; StrCpy var1 var2 len position ; Check major version StrCpy $1 $0 1 0 ${If} $1 < 3 Goto GtkNotInst ${EndIf} ; Check minor version StrCpy $1 $0 2 2 ${If} $1 >= 4 Goto DoReg ${Else} Goto GtkNotInst ${EndIf} DoReg: ReadRegStr $2 HKLM "Software\GTK\3.0" DllPath WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\uget.exe" "" "$INSTDIR\uget.exe" WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\App Paths\uget.exe" "Path" "$INSTDIR;$2" FunctionEnd uget-1.10.4/Windows/nsis/License-install.txt0000664000175000017500000000327311754043630015671 00000000000000 Copyright (C) 2005-2012 by Raymond Huang plushuang at users.sourceforge.net This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA --- In addition, as a special exception, the copyright holders give permission to link the code of portions of this program with the OpenSSL library under certain conditions as described in each individual source file, and distribute linked combinations including the two. You must obey the GNU Lesser General Public License in all respects for all of the code used other than OpenSSL. If you modify file(s) with this exception, you may extend this exception to your version of the file(s), but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version. If you delete this exception statement from all source files in the program, then also delete it here. --- This package contain aria2, cURL libcurl, and OpenSSL library. aria2 license : GNU General Public License cURL license : http://curl.haxx.se/docs/copyright.html OpenSSL license : http://www.openssl.org/source/license.html uget-1.10.4/pixmaps/0000775000175000017500000000000012260772032011226 500000000000000uget-1.10.4/pixmaps/icons/0000775000175000017500000000000012260772032012341 500000000000000uget-1.10.4/pixmaps/icons/hicolor/0000775000175000017500000000000012260772032014000 500000000000000uget-1.10.4/pixmaps/icons/hicolor/22x22/0000775000175000017500000000000012260772032014557 500000000000000uget-1.10.4/pixmaps/icons/hicolor/22x22/apps/0000775000175000017500000000000012260772032015522 500000000000000uget-1.10.4/pixmaps/icons/hicolor/22x22/apps/uget-tray-downloading.png0000664000175000017500000000124312165471260022377 00000000000000PNG  IHDRĴl;tEXtSoftwareAdobe ImageReadyqe<EIDATxb?--\ 2Q@y0f  R '֥><JF&FW=~M_NO;k)O8 w'/-0 PRPÖ``faB]dA @_#R]ŏ/!_;npYG+~}MtWg_xb=}tŭR]gD,L Fhj`R/FSp^DqLfV&f'ϿKE Kc+no<#yzgxD`_b]RU@KA4@Y@}d.D2A99ݦNAFP]oǔ - ^e0r0)(qbM._?솕 I <7[@(MkZ`_Ӽ#IENDB`uget-1.10.4/pixmaps/icons/hicolor/22x22/apps/uget-tray-default.png0000664000175000017500000000107212165471260021516 00000000000000PNG  IHDRĴl;tEXtSoftwareAdobe ImageReadyqe<IDATxb?--\ 2Q@0Z#  ـR !֥_H1?*C0~~FT$B,Ha:H `#YËoz>>~7?j6M /}bgecGW_f絨iXS #3 u 18wO|( 8\O| ?,Lz%عX9 ##l 6 ٸX@ g2zFLOH;mOV< )I?s[8i,)_(0 ~n;Wn- B߮oxw6K3$qFVÇކv؃ak$-A$4mzȒ YgO`h-GM$.E 9\$9Kcu6+5^} 3S \8`l laoYX1hIA@ale@ JjL='pM(rB1~ cx^GdV:kPJ[w0JUsb#U(y,V;A=9"9JeRʭO߬85PfM*/?ݠB znb8,B`yGx5p͞@ڐMq\â@P( )quۦ Tc?^XȚI a󑡃E Xf>g' ?BB?,3G]|B =FJbK9*V%#;IENDB`uget-1.10.4/pixmaps/icons/hicolor/24x24/0000775000175000017500000000000012260772032014563 500000000000000uget-1.10.4/pixmaps/icons/hicolor/24x24/apps/0000775000175000017500000000000012260772032015526 500000000000000uget-1.10.4/pixmaps/icons/hicolor/24x24/apps/uget-tray-downloading.png0000664000175000017500000000121312165471260022400 00000000000000PNG  IHDRw=tEXtSoftwareAdobe ImageReadyqe<-IDATxb?--}2>`!lTbi-0^GӀT&v=|6FS[Y}4\p U!.A-xy;7' YYFO>a$@ʍ1Quxo\Є7`Xp 3kZL.Z`*NN бD?/ϡYv< + H$E\@W5Xs{6Ko410͖T%:'rJ$O.VĽΰE~[ r tE133:dq`p,cac&n}vhbr]ٟ~aK=j ɡ2 a>X4,Ujc7z@e6# } v.*C#d..w̸ 6too$^].w!dDq Hox3xm9`!lTbiͭ0^6@g4R]}S} 4\A߿ZrÝo'+0"Pn}14_򪣷oðgR`6pml:Ź)G(Wu)M_Ľd>QNIBL۹H 6S2 R#I&` j \JGx;&( Ӭ;ښ?z)Hs##&Ї܅jP͈0THV<R vɋEŇ@yl8`O*Is 3Ë.x|׌KsA6ʭ@,B(AUR[*WgʶIENDB`uget-1.10.4/pixmaps/icons/hicolor/24x24/apps/uget-tray-error.png0000664000175000017500000000141012165471260021223 00000000000000PNG  IHDRw=tEXtSoftwareAdobe ImageReadyqe<IDATxb?--}2>`!lTb9-0^6@g4R]} S 4܌A,ܿo{Y\RUOD~BW6!*>!'"t5g{g͘4;s/]Kic$@ʍy 3+sHybh50.$}97g?^ @k0#`S/ `+k،L 4@*hp>r@ 9xYIĽ ׁ @@%+Eş.ϯ%(*~}gQH-b(-.OAF/yliGPbsV'h%z*HJqs2??̯wϼ4ݰ 8 bo 7*Pזãʤ/ YG׬\IENDB`uget-1.10.4/pixmaps/icons/hicolor/24x24/apps/uget-icon.png0000664000175000017500000000227212165471260020054 00000000000000PNG  IHDRw=tEXtSoftwareAdobe ImageReadyqe<\IDATxڴVMoU=c8NRUSTZ$$*ۊn_`-/ĆBB @Z膠|@@bB\3o}vܴN{{νEyyiX[[sss 'fZV|v.N:ZdYu [~`&u=xOPa~x޵ur&nC ECK.!ޅ1?!wGsR'qyvl1i Df ,-!%-Մ՗?`qRTI"$DC*K!J<^p =:u{w*3Eʋxs,z}y3B 9m0֓8$'302/4ES'Y.kذeȤ-+d6ϼ 1Lk:{ 4%wvwAЯ%fGg^ōowcW `X:TezRd4aHUvJݝ|}2#K*K΢226H@ BG-,`)uIZ)YJTi`0"(*8"7SLTzy=l*-1^) "2*W"̿Z6Fh *T*J&GP@l i2H肦DceGQx[J62$&~]-خCK:Ndظ"ZC(_m$$k$ # :umbmzQ[@z@+q2Aj:03KMsd6ɑPFSbatEXtSoftwareAdobe ImageReadyqe<)IDATx}i%u9U^o=3$g"mɴEۢODIH$IA  3?1h1Kd)I{Dj.9rسt{ɽUVzəA뮷t={.\|x!\|(ދBz7M:u9EFNsZ\СC& )y=z|Ac1b̃1`G{キA`<}9rz!\]]U'ʣw}ܯGi||#Ç|$O/c=8oٿ]oZt8J8@P:?I`2sG깿?΅q)n_`ii x8p@pivkbzlJ}+/@Fp$iIXBtomӿaן]_[=vX|&>)R 1t M:≩r/փ XD7f`~(zD?>ggzwA&=O>~y,&7o0J48+t :b QZH m8{m*@ՙF#gjH4Ay="<7k_K1}V'x~av/ C|/}n]I ԕgzul@WE7S w4 ahU,c'#}#\7t |& ɖ-ҿox;?8sԡlHj:߉kK*DzdQ`:0tSVDuɟ׿?;rH߿OQ|MGr@o`.I:q$TWR)Tr1+((98$J~Z-)WR}%I`JFGFvJt 9SǹF(x.xd7JUr~axk1^\BS9)yiP''ǺZXcRnlkS :Qg;f>Vk تμ/s|ND%*^%7%?yzLyXx }xcFbz/#A"E!3U̮dM"P" NL2 TӀ^j9QP_,Cۂ[m&/ !G#BmZ@Z l\| qME*:ikFZζ|_^xӎ2ҋ뼵"Mw q5p6̈́ h6  9f2 #[%g%og|H,}`P(3 LNBR. ;AZWC0KO@%t:؋MCBbTnGc*J[jbL%`-g Pq[>dAzM;\Ʌ.ߋT$c 9 l\K>;7Yg/~J 8bc Ƒ`-#' NGF+L#6h}kkd/9t3L -F,3U|ɱT \=s݅К0!҉jR&|QA@wP&}tg+pqv9 s! ]k8mZ/^b32uN]S_ʢKpg9b+}l |mo ^>v3oz X1 K2adψ5_ *U3Jh 6ddX@D/I>NKF-'4Ӷn3l,"RF ",, ,:G/oB4A+Epe ]iU& ݏ 6WsX59r*3Y1-+yVXLED _bjDw*C="ta-FW ە61.u L Hb)cΪAŬLx --AWh@;JGDZUϞRٝ8s3()q$q"pB8C1]gL *4clMLٷ_#Ox2J!X|{/߂m#o^od+Tu(KDh5:aN+b89x>#'' rcqNAM $ |l` hJ-al5kY}_kϞ+ȳznyIBq\ˍÿ"T ;rK(~Q)߀^bm*9 btH-V)!J[wz=9` W(UI# _ī0fN?\Gaq H YA{4tx2- \ϱT$9h_V44@; %/a0bP $Bk/@4h?`בMXٚ匔k@Ը,%"z}pj3:.S!d^&r& %cdqˀr%ɧ>t+j +M2 |d; Z$MLϹ;[Ԝt[l뙙Q\"-"U[ab[/=#X@ɛnaUNr#.q ߏ}9ND*u c:o@t B,.h0ЙB&ŀR?a)ϯ5rɜ3i XP.PdțvޅLN!`Hȷ "?yc?+uF؃DNr+a@r~ x,g&VdsW 3c+ܜ+ WRhM_1·zE:& [=^EK[': 8* =4rMVٕOӂ<$/P^6)YF*XY^pg00G[ជXxASGT[OY $KiJ8 M/'.Rsmu+B䖄qᴗax|bbrBp<'Tm >< QcE ;0 e<6t9\Vpa MlQ0UP2OuJMe\dk%X6p<Z| 9i'\M tIVf{x;\V}! ~>]ԭpu-q&0_Y5yrV&\@A2q*^F%NZcPut(oL]@v vߺǯfKJ3e `e _qoOËOԦYQ; _wc5ȭC1DtmA[2[I-P8 ` ^Sɓ0o6qұiQN~nyzVG /- y :JPer/CKX -(o~u9zVBWvkP6 j kɭ PIX-&%Fb8+2ю@DԬ4{+z˱=aR5{< U;P髭sB k,߯g>QrUJ_, ziOHQ)ЧXW `EsP5[Ln[x p~~<I,خᆏl8cyݰT0&0_t"C0EQ4BQDXX e.BclgVUO7;zbDVҰjB%@A~V&tK۶BTؿrY&;X%/ `uly38! P>@vgN*lB^٬GRy*) CR%pWD#`@E8OO GtnUAdqKeÅ* @:9]++`q^+O;9m6",0@H. q8'՚T(ͰY51[xGIX8|WbtF#[l&0MS a-,l}x$(a0TM r\aW;7ugCBIW n+ơlmPajTƅ6 bEU}8Nn soD/ȿ5 c+sV3ߓ56<P`B>zAݪ:!N T!*L =è4ӌ1R;yp\yJ6MY njw  _aG[TAoA>C@g[oq$.BuMW=!=~65a&|[? Ƞ %rڶ-$#j-S\6ӟEvd(#C~#j䩋ؒ3l pQ ""C8ěCT{D%}Hy"uSdsb;X& < M [in* /2LĒ(3I$ =_m=۰ރx$|0B}1vY*rqhTg@aUQt*ʚtp]XC~?GI h qX:nvY=ҺJ^fSO˦'G>i(oX!Cr7г[|uUuIbhM%iЎ_I@TuP(uܜdž GZh iuT3CȾ6pR T.QJ0ftC+upoŬ]TتE>òT"z a"P ZqaydPOxBIZ8/pcW?ĻГXE9`=P(֚ɭ $}[̖AUM(5ޓ"q»N[* .cY :L';X>&XaE`qJDL̜Cp4J@kGHLb#E8Υ>x?r9QΡdy;BU2HkձV x_`ZJ7@R1-dk ۧxd++? ֖{³g ~5\86Adl4i(At_R6T;t)*L \@O}ۖ JJ+ U(+gs`p %񪯷V7S @&gcW݊_D5XɿiLgr wkW%ntUhl܋\Pʠڠ$ ol{&%{ B3,,`|b+hM S)J|Ucnf;?l?8Ohx97nV0oV12WzP -Ap_Gw.lK8R >:On_Y‹ϝMW,m4I6㹌2U ȸjJ(O߳gDi*2 @M[;gY|)tH p6 Efzȟ6$[!$"I VIE_mmyP8ʲTlWc a03w*A흭4:xNe)^:~r[\\~JR6tBȕT6#&I{Ea/nR\hb];<g[7=+P(ڄS*³K⁎ؐ= ,dڴ0ӫ>ec9B_.j0rX v2v r@vW43z6+D^mm̔*D) ]x١y#MɞtS+A`۾.eaW>wQy2 4̜Y ?\5AB̑Nযw9Qk#HR c8TZQА 'S$XW5rv~ĺn{Y'"_#y-H]A ,_hyXv 22~9ϡ?HS`Q+:Q3"eU#kn{UqFO~jr`[ pۥT]Ҷ ɶD׬xd2(-?zE(qV,B2X\%|5>1LŖ_4r 69WY\e>i9iET^A޲=˃{e."l',,ZUf)I%ͩ ]^c'x o<9 {ñ<߅_:^Cе;;BYZ[M~kca@ $ lo.RUln?oj{^"k#0wnn I3%Ѽ(AvH<ЍW];Ays0hûY(Yצ~"a Ty?DIKxe/{YYDc*s(s{ט]e{8|,*;4}ߞŹuz^̡qm~ju<[>> qX?VpLcb# O$Ǒ.bPwv\R%C/^VQS#ȩb+hJ S>6,2 ̜] 7b{tJJ7P+#YJ2wo\ka)@ 01ݲ1VFPtýMYXOwD-&rͺJlтs'sbw8> |cf֕moh|QyPU z{nwmHm␇x-2(:Z\FMW"C?: 58wq=* ZtQ˥8y{,ek2a (]S}~lQ0Fp b)Rld/ #Nz#: #9 ECkv/0 P]P"țDd_qg7btMS5JGNGv=NRpKALC*`-c&aN s4t =7 FԃizOw.jJ@dv%0vGpT' *]*S/(MJ[nWd>RV Q3~B{{[;yCtZP<8e@;<i(ar :$p# 'QL|#$ri7gY0Xk\A#'"*jx6p([0?M'ˈa1L0U$usn){4&X0sBc\f`PǬ 7!pD/ڼB{*ԌF@;#(rV͢VFVSP\Yy1(͒(HA DtY@y,QONT9`qVd͓ /I|(A} ݹ(O /@^)VElUMAnG^@_([;5JnJ~\JV>OiOCɠT3i0jP~%JB,-6gd:r«Nۿq$`@lja31meލT1o+M f-Z$(I:JnJ~=3 ,Ro^߻.9ydGF}7Q/BKHW}ȬD8r ` N+@p*j>]yןӧ 0jŰ:~v񴒛Ӛk.w*?tI>~dc?=}s2E$sF]yQ)(Λs_:ۧ g&Ub !b!5ߪ5ř{?Ţ.B|MJ_~n񌒗<帪:zf)SftJ3>(s˳WͿj؎V{t*Iw>f7:bEڼ1v^zYߋ7I'q䉪9w!닜+Vbk'x}Ě\6;'(nҚ/aRt9ٙ,fRer\rj9 o} ~r6T+`\ZZ|s`tg2OǣQA\@֚wSZS<hW={aCn[< ,`ȋ<ŘSgo 5h!b]sWޕyy9FwQr.,ǏO?4t萯qQ|ǴU;nmG?>W~6 }ѵ{7J, $dT*5PCO[JWGu9||G|%y5Vp]5}׿u&c?7/XcI >J_W\H9I9u;ֿtKOCp U3Z61"6Ю`xG|qaN-CbY+u pEX5>/`_2?ўe!J {Ðý"<@B xUʉ,{T]E~IENDB`uget-1.10.4/pixmaps/icons/hicolor/96x96/0000775000175000017500000000000012260772032014605 500000000000000uget-1.10.4/pixmaps/icons/hicolor/96x96/apps/0000775000175000017500000000000012260772032015550 500000000000000uget-1.10.4/pixmaps/icons/hicolor/96x96/apps/uget-icon.png0000664000175000017500000001420112165471260020071 00000000000000PNG  IHDR``w8tEXtSoftwareAdobe ImageReadyqe<#IDATx]YWZuս؎LNd`4K`&3 B <$xaX$$i^x` 2b$8p=qvowSuunǶ>[ݺUN!v` gvHwe燧N #tNѓK.9w|Sx/]#>36e3y5!UX<877\5/Dae|l;WWW0E ~_OC(Ȼ۶w6Ή|pU1@!jtoO_Zfwaw F-h@V؟Xv{X0 [W:mq 1'ۿ716ڽ W;[XkPu_4444+imH~a~fgfpQB+$RMN'p-˿ɇ0! u< L&hfbz 7;sC?r=diACAKASIHҀ,ZPl7P{Ft9[tQ4zU6Y->p1 T@<:.T&SD$C} RY9UPт #:R>ħK f| jIv+AKASM4afFm?o`s˟ PҚ'`&f̯2崑;|bZ3*~rJNr&' t=?Z- v䙷j>AԅEF"9ESS#;_gZ^hpk eN`yKT?2xWˋ@!`L3`9j&j92Wbon  8H+LZ*v<dvJH~Iђ ?z1%/zx'wz~_;ov& SDhi-18"Hf@ R"=EKϾ|nnCX}OdɟT+.Z+n b$#6TT&%Ԁ@rHh8W6ӵmm[\H9}"-Vs,vz%`kĄi; !0I̠<#j0z*.,wJﵛ@1q^87"3~&)Eր\obz̋<Ӥފ/LKr5DCuWNڵ1trGg!  (ZTG_ZKtHjzaҗ'f 1b&lAD5veoSaUe[ GJ=97' ###E&E96[t&]MjrT NxY%6{~\* zD]<>Bяi_h8;So=JA%aR ϭL"̈́vb,"`\c AV7H4d"#I.];ak!/I!ݨf 2{҆EnЭGazBS^P5A^!p19=үTN#B#8a; B]-# t"2H;N7Hr(Zi}'lʂ3y5#EA;a氾Nj *MNKcA\5#^s%p5;1DVS,89 #{[m`pZ'&?Xӥ>`O'>wfw&$o!/:63;[9tUq%)Ld(?/B4бT3g:.,٦Ků/ ꚧ@3=FD7R"0A]h D(᥏QI*"Ayo6]&hDG= ȹuj"  HJahCC<}AФπBLX -.Iڝ2j۪VF(fi!_tI^/oC{c4y8J's#vEd>@(t=(>3tQQh,aR^x±0 JL;:&D4b&ψigGIG<‰!z{rzE(! tf O1$;QD"=,nPZݮ ~[bfdF=@ w2w%O9fo`&v"̗N=`묡lqBC΄XyF ,uFP@wv~ ,eKI֤E%Dm&b0BEo= 2J(䟹4K;U5H` ^[SȀCͤ.^KF EgjA?3j]a1A X?Lp]h_Z,Z-ڵ/n%Go\PO?mri@F r&btsaȁݨ!h?2>369_-.C!B ALL=ǬEdI9X3bE2)-/,T9>}_ ~^~>Mǀ.z׀ 1EUP=pEd8t|c{{kGpנ2_*ג8oBkv%w) 3bP͵$LgXD&xkkw nv?@U&d^4L09_,AVnܧbkùw(^7sTd轶"u)l/#-q2D6ոOh5śk0}ǟv+p].T!>AcAD#]UDT) \ &Twgœ-nyjXyVCqH*L 6 ͒ 2a}m&+HeCP б ԙ79\`.OסCsGzMBX"Iȅ1l&,91|Qi:/)w9jvy$&9aGdn,%cwO{<BIn+Kߛ;1Unˬ` <ݷIh>d.- WsɏyUEg5]DhQ+"( J1'naYGZ M^taluW>ڂTss5L49$S|GS^c},*ŗ5AhJw+307UL%ܧZP&"*%hwRllx49+CD:CSHhxZ9`t46 .j&KW#(tܼ֛_.GP9X2e~3+蘶ġbC6fL\]}UXWfaeyzP裿{>=rib[p ؼL~cd-)/*2Qg6|UY'\eA+bX]0('m^d՞ o.kp&O֒x?J|gcz2tT4-N J4D: Ңm2كKso@a=a,\n,񅚄8eHҌ嚒:5g?;S#dz!*dr`v^Kt% ؖ Hl20ݱҌsGɧ&eYgԅ\ah4*eIXNϹpq<fmteR>1Dpg ~b/ؤ%bY}'1<"mDLgt-a djJ 6xR k1ﺄcƸ03W)PbGJҀtmW,U`ڠ`Q^[ ξy;GŜ SZ'Iz#,|fD}>*H_@_9{ЙP='op'Z}hu} țs9:Pf ,0K|I-NuCGnF: uJcbZwUc>=FdX5;lI|1oDi̟Gu?~BNpaE:=hmZT T&(`4(e)q%SwgfnAI}HlQ~Vd9%0fx]{sO7;^: #` wHUA (h l[ #ŀiV=ɓgd c#]@ ?5b}Ԕ91Lŝ5AKASI۞鿺3<ٓ+~{rSkz}Tt8˷̱o"'ShM>d%r)2#Κm[b@KKn,u&^+'1cG~bb~Xu2Y4Ps_kEt9K;EkBX6ȘNdMH]ϔ0fqWGW%M7S$ڂ!ⶫ|(becP܎[&lk|ܐĿ>V'&HQ[ C [R3m/3`(lI#$_|ۙwۆO 靶k3MtJ#hPhgP mɀNOҍ)!}[aJ~LXuɀH hI Rzmܧq)͆J6_[bIENDB`uget-1.10.4/pixmaps/icons/hicolor/48x48/0000775000175000017500000000000012260772032014577 500000000000000uget-1.10.4/pixmaps/icons/hicolor/48x48/apps/0000775000175000017500000000000012260772032015542 500000000000000uget-1.10.4/pixmaps/icons/hicolor/48x48/apps/uget-tray-downloading.png0000664000175000017500000000217412165471260022423 00000000000000PNG  IHDR00WtEXtSoftwareAdobe ImageReadyqe<IDATxb?PL Cz`#,FFF 8E*^1@ b~}`l)Q@ـ4 NC` Q5RϾ~?|spp׷?NBuK]}v7|j"۬zǟT0T)!u}^S$?8d7!Ef*SRg:ƧG"!EUd?6#FXhtSX IUTHkg>O {<t<Ez xzMG""6_i @EDy⎇Eǟiz`)c"bk`)"&hr%*C;UbT$i`xxͻO@7_>{%) qp_zye;h9xm;wHR:NtK 'Os$aŔDuX+12avq5R43@]*@}I]RZdbPS\P b[_/Bb+ Nde iڡcRi 6.O"/A"* ;G$4LZŽ^J@~肎)QCs7 Zv54Otb='WT(`i'}{R2k{>1.VY^jcm-CHQ 9^}S l,HE7q %κa-C8Aezfac˘j(%$H[>o~2+cE` fB(xHz"&\SAMmP/8r@n9ҨU<- A-HHuiAInN9^l1bϿ~yǣo>8 l@d=DH8;ƥ 4Jn#t"gp QP\71:= @ɣz9IENDB`uget-1.10.4/pixmaps/icons/hicolor/48x48/apps/uget-tray-default.png0000664000175000017500000000165612165471260021546 00000000000000PNG  IHDR00WtEXtSoftwareAdobe ImageReadyqe<PIDATxb?PL Cz`#,FFF 8E*^1@pL vb~5`liS@ـ C` Q5R؆I뇟.ZxHe`r=Cq5O$'0+2`&UR!=V$¿Dy_{<t<Ez WG=+1t761?R/Dy⎇ >H^ 3Rg:oGU~KXDp Lo?\p<H O,~}A3  >1 #Ӑ' `R ?O!$,=d< Pr󵠹ĹD͌ /)i̽[p2̢8TJOIvQqQ5;ꇑ?6&38 BjY[ ]׳>? lso ~yt^o~2X<ǷcipW AOUD1ݶz2^w`ͣ"ɉ`)*ӫo*@]m*@cJb*K_LC-!AZ:ʗw?;1@p,6fK]9)Z8,8r뇟; C ;zj|aj"r\@DL w?~>O^;P2Wgj{@c>4JA TixbPwQf;h["*5y`jӥd>F 1ӿ XIENDB`uget-1.10.4/pixmaps/icons/hicolor/48x48/apps/uget-tray-error.png0000664000175000017500000000253212165471260021245 00000000000000PNG  IHDR00WtEXtSoftwareAdobe ImageReadyqe<IDATxZ}L[Uo__ -¬6 %E1+a]ܨ%FctAd32q9 52Ba-/υ){I~~{=ۉ#(- X@FżTysy`V (V'ȃAe| (K` L dL7(: H+N>ϧr(-K@.M0[ǚk!Y9ҝUŅi 4fn7LZ=~7? [W * K23ƌN8 n$eĴP贶n`O Y=.hT1G!#J8CZr+z/+/r?Q}wvڠ:v۱ M@;猒,zq 6CէlJ_FwuB8ǜlk庈%4ќese 0!4@y":ӳH<4Nftgi< ܁ks+K?9DJpB>wg8)qK< sGZ"&A>#WB:bd2wdoAxD'zCs$waU4ĵ[t]g/ tǿا3;8P.km-*?L(\@W_C({ Xasu:u`!x5BX jurSvo'., [dP{lo-P)\)SLYtR/u\@#i^BMZZ(uF ]oOVZXB ersf{=I@g~aB[m0_Q  y xul)&C!c:|HuP?ZL1#;3Ih18z~.Y۰s>C[Z%o}v,ONC&S$&֏z)qe#kB8וR>I7|@Z|yݟoݐW%QRC!+hL+SwWr7۱BPu[ > )e5KEyU&Se08 U A:@5NnDrS=Z#p@6Cl#<4,ݼX{Yä#2KIENDB`uget-1.10.4/pixmaps/icons/hicolor/48x48/apps/uget-icon.png0000664000175000017500000000627212165471260020074 00000000000000PNG  IHDR00WtEXtSoftwareAdobe ImageReadyqe< \IDATxZ]]U^{s\_%j ڄ` $<`& } F 1"EHCV jҙ;v)MN;wk}[k}ʼn'ZB]5Y򆘛E{Ȳ_Ӵw}74 j 333⡇~d_}U5<2DY2M볩;oݩy䗢n[)%P-0wg;n~RIoJi2zag/6zɩ {yo+IFv~<(k.byG$2xTv;ߚ{]?U?5m7]'aEG{0PZ<,( "7j,F2֒0*5M|IQCu Zhk@ZYZŋ%Od*eϭF~}z{vuFu""*W~=bނž`)lKIok'"1?݅:c[1X?'Yi_00Ͻk) }+Vq? (Ye gk F,1 ( kv% $IB$0I 7~mԚD%uvv8y2AnFӿ? cC 5pYpN )z"s6bTv a$1 a7UӓEv! @]wsl6,{gcx-O(6i#S, O*Tsak 7wT] y 2'/W6 PVmsMxN~c.+C0)+G;ۙłW9 )_߉+yp}QXf:u<;іcA d(cJ p酩Yro(>+,?/~& Xe k})d5/%.89uDqb< q4.V튅~_#4]8n@c,D "RFt/["Z?KAxrgS,gnu O Y#B u?(- C`wv+DA!Q~.b"4=mjîۮ/ѐ.b463JhKc 8t qp \X?<jMd7^ϦPPƾbQ)BOpNY ;w"B, NDN6iR-o\ J]OV=-"MgPU Q\ Uӝ8›$5Ulߵ7(JC"6J 9z@6 Cѭ"QxUڍe[:@}sxn \CP@ɲS˥t"=;"Z:ȍbυsÞ .0vekUCǥ8K\IJpEyMa\3üh^P"bdAmZ:\s~Tիx1 _Md KJp/'.Tܝɠ-kv(#pl0zlqWxA!$0~Kшt J /%P»O o<axS㲻sw1倌s sBUцTX_^;@Ł"C Wř O8{pQ 2m&q4TUHV2,gMCga p Os}'9zSSHEiHh31k)QDbˇ h7֜34aK4w ^:dwԀbJ*n>T'TQ6vX,m Èt6;hqR -]K#o{?ԁRZ_>c "BLN)bxTKH.I] #z4$&%d h!G2y.їN9q eIb%}TJMP*Knk2p S=#37h?$o~r ~zGf%[<}S- -vum؂N1rBA6\:rb Hf&\ƻo9o*x)pg.!\oC#8xA0[Ǵ% TAr*Iס'f%8B _ۂ985>1@lkW8˂uק0ʶx@x墉_Sԩvqk0<\MX}h"7bV]+?ԹEJ"DCt`e<ﲁ皫u'&d7'U [ v ,g&;=O+}'RJp-u;99t1pAz*_Z[%IO_2H~Q2p C98sf-[D A*MH7{Cxkl %0 OCG\\cVyB!ʸ ae%mCn_  0o!L+m6A%XG[wBTxp*6Kyw\~W-7Vﰙjsdq‹O ZDWrԆ츻FA$kmvSp* c:gd|atrJ;@wCޠC<_ ; rR^^ᓝ+9ii&zFJ ܽ{h5r_9L[[ͭ-^ʕsy}Iӆ[6HX 3aOY/WJ<ljgpͭaHx6|ƇNZE8V$IXJ4C g;q LlVLW yr/ P7MqN5IpyE{H#[=ع{W ~zp>cTotj}?۷-@kN<VZ?\|V!R&׽ޣJ[nEٳ'b獗IENDB`uget-1.10.4/pixmaps/icons/hicolor/16x16/0000775000175000017500000000000012260772032014565 500000000000000uget-1.10.4/pixmaps/icons/hicolor/16x16/apps/0000775000175000017500000000000012260772032015530 500000000000000uget-1.10.4/pixmaps/icons/hicolor/16x16/apps/uget-tray-downloading.png0000664000175000017500000000104512165471260022405 00000000000000PNG  IHDRatEXtSoftwareAdobe ImageReadyqe<IDATxb8@ `" ?1M ;!?Ω$MSuT5f.~vw%܏Z @?V323-⎇o 2`&]f|v;o߿ @;'_L.r%!  d'0דko?YYma<얌0$t (-*[lwM*fpoC ~}߿<\ >ȼd?v309bD6. f#6<0#kvɋ/~fV&/r)] #[K'L7`dbdDS7hP"3#ǟ2" e2Teyq=톎{ѳ33 JxW > S E?IENDB`uget-1.10.4/pixmaps/icons/hicolor/16x16/apps/uget-tray-default.png0000664000175000017500000000061212165471260021523 00000000000000PNG  IHDRatEXtSoftwareAdobe ImageReadyqe<,IDATxb8@ `"W?1M [L>l&E3?V&5 @^8Ȓ/ys 01|!. " ΋{g_vOp;':603F-ǗN,D#V?vbVp}fD΍t)?tfMhJ_0O0X>pfIENDB`uget-1.10.4/pixmaps/icons/hicolor/16x16/apps/uget-tray-error.png0000664000175000017500000000106412165471260021232 00000000000000PNG  IHDRatEXtSoftwareAdobe ImageReadyqe<IDATxb8@ `"?1M ;8r/{I (.ڡE8=LL\B)Y[?60 33[GKr9v $xK4;[贈B?AUĸ ;'_hI dP&Hx TjY;H  &F!!{ qOKaqE#$<+o ?[Z~ Bsŝa&_Ҽ뇞3EA ش {x6. 6f3/]zI*PeT 0q [ K+Lzu'N* aN^6VR#*jmD>}f:&oC 5>AKIJM7>qz#zvbbXO4O0~+IENDB`uget-1.10.4/pixmaps/icons/hicolor/16x16/apps/uget-icon.png0000664000175000017500000000121412165471260020051 00000000000000PNG  IHDRatEXtSoftwareAdobe ImageReadyqe<.IDATxڔn@Ol"hR$EY </ѾoMJT4Җ^r{.f(* ɖ||1yՋBM9ޥI.t:<K !,#${u~(0Sh 0! #,ZUXq!%$ǻmϟ> RG,"&p:82DL]č%1b,LJ774"lr\ȎLjq5s-*bԍDYiLo>(9xGЩ6"ܞ(cX29+jTڨw慲Un|_&eS'WZy#~@60 Sd'AIENDB`uget-1.10.4/pixmaps/icons/hicolor/scalable/0000775000175000017500000000000012260772032015546 500000000000000uget-1.10.4/pixmaps/icons/hicolor/scalable/apps/0000775000175000017500000000000012260772032016511 500000000000000uget-1.10.4/pixmaps/icons/hicolor/scalable/apps/uget-icon.svg0000664000175000017500000004366712165471260021067 00000000000000 image/svg+xml uget-1.10.4/pixmaps/icons/hicolor/index.theme0000664000175000017500000000130512165471260016055 00000000000000[Icon Theme] Name=hicolor Comment=Uget icons for hicolor Directories=16x16/apps,22x22/apps,24x24/apps,32x32/apps,48x48/apps,64x64/apps,96x96/apps,128x128/apps,scalable/apps Inherits=default [16x16/apps] Size=16 Type=Fixed Context=Applications [22x22/apps] Size=24 Type=Fixed Context=Applications [24x24/apps] Size=24 Type=Fixed Context=Applications [32x32/apps] Size=32 Type=Fixed Context=Applications [48x48/apps] Size=48 Type=Fixed Context=Applications [64x64/apps] Size=64 Type=Fixed Context=Applications [96x96/apps] Size=64 Type=Fixed Context=Applications [128x128/apps] Size=128 Type=Fixed Context=Applications [scalable/apps] Size=128 Type=Scalable MinSize=1 MaxSize=256 Context=Applications uget-1.10.4/pixmaps/icons/hicolor/32x32/0000775000175000017500000000000012260772032014561 500000000000000uget-1.10.4/pixmaps/icons/hicolor/32x32/apps/0000775000175000017500000000000012260772032015524 500000000000000uget-1.10.4/pixmaps/icons/hicolor/32x32/apps/uget-tray-downloading.png0000664000175000017500000000153212165471260022402 00000000000000PNG  IHDR szztEXtSoftwareAdobe ImageReadyqe<IDATxb?@&`1j1,lJbE >XalFay8 A?Hsr/adbDQvg7C^,HEY__LdbTpٗ¦u@*D@J'/ u ]3ղS/ R4Z/|}STCO 8׿,lLnH?. X|r>,R ix𓲤*B w)%!@r9@ x|prWe u7߅p}yCr;ۇW~Gހ,:д80Z˻`G\Ʀv6\,k}R:a_ Je[!e -5{٥vt'&fF?`J Ҙ(* y8$s @KlpX$o~MlTȖ o+l[" p:kk>XG02I-[ &tf&e8soOfj譨 7OYJD#XmP\w .>RmFފ!DŽ#=j{ Π_Tl2Tuw6"Y~"7Ju8 Jqj*sU󇟿x绀 I@TCibtbk :70'nIENDB`uget-1.10.4/pixmaps/icons/hicolor/32x32/apps/uget-tray-default.png0000664000175000017500000000121212165471260021514 00000000000000PNG  IHDR szztEXtSoftwareAdobe ImageReadyqe<,IDATxb?@&`1j1,l4bE ZalFaysA>" HsrW勁Sf>.Fr"DjX7=(4,>Z.[ %  ~P0Ū?}4 Ag6Jv>1=}^?,*pW_$"{H#9H pw`2\~~Ŋoe4 GhmHRAD zN^6f&&- i'_>bT(Hp@x8ɫ[K^80yC8p`5_~NK| (xrL Xٙa&~R"

Xal^bu-Yt'%> Zi@Y) / 󙈰ϯa96@1bacUb$/1T1`8BT.4Rgbf{ځ'/,]+3S$CO^m շ=3/?Aw¯tojiőI[FX5k[$1`|oRHBw<(dcuNYk FwNs&@1Kcbb| gx~2h0J(Ͽ@k$r.0>_!:`faRBhR@BfFV5D ]@ 8d UE/;o73)F jXWvcD,؉5A\ɂrJj4hE~D(@3̼w;ymiQ0M99ORXZsGkM9#wٙ+Ny\OXEEuf_oR\&uywޮQ5fJ/q gtϜ8!8vJ=z߿ةOk C+`K3=3K)I̚j{'m8%du Pw{!^kP{cs}4|{aB+9,> ,˘EE!Z6`t7*xie4:rnN6^oI8\p6-W$`7!ʈ6ouII<#6ƵsGhַXƃƐxJ)jYOEKCK%|P֖+02 U>73mJxW2E۞\KOZ$'>Zd `QXF\NŜ/NѭZ> /m\8$p" &yQ+Ge9񢉹-۷O/ ˦g!93 Y.R1/>O$ E}VXRJA cVd^7u`]:{~0bD77@BIk-g-2=:YHըB+ֺ[&S*sX2h1#{e0 J,RI`A-Ɂ+d9+AgJ"mjɵ%Gԉ>p v"]$ޗ -,r[ ˽WXJUNqb֯YԿl?F#\mRTQaNƠ5.~^$v\: 5-@#OǶ= ǯ>%l\lBK3ʩA&BpwX(J+KTOڐ~:MB <;B9eFg=e!b񍝐tvdnsЅUJL5yF?_I ""{I'+`@kodBC-G{8WU`f;+ h? aj8ݮMBi0B4Z|6?VpyREKvm!u/&j5h :[DC,𯌆m:E=m8BC-Dgt6}JJjTߠ)`TR\SHs,JEI(p'ЃkWNgPk΢n[ac?]^JQGNCC:0`xQ6f@XV~ob9PvBkj]&]6,'(a5q4NiS`e¤$SvB$+ya\S v.! 8 %T0 Xq"NQW8pe6Y$LҺvKɣJJbũ-9ς6 h7y~) ^܄iL3ޱsN[>S -СCkeFj8p@#@jٳpرPBrG}q }_u?Οq◎`xL&eWHB ֨ <=Ks$GOs/@_i?HB"Ȝ,e72Bp"j'Ofku)ʘJ> ,rU (n~i ȗ;ޒmT8qu"̯ D5N‡L1qj gr7jD*7dB!r6AC_n&eϰ@8\KFϹ Ҙy 9exKGW E\?c}`f] .T%2|mAx f*0W3/X$`GP"POV3=B.8*TĽŸyA!cZ6J6(F9;ӰhQ+8ËSpHĀq.٨x:os?2w`;?BqoAP$:Pc&2~l'ڬ0*W+E@-`]2 (O#6#lVCVM8ӝ4֗D>)?` L&ahAp /.*%>cmq\qCb)Fݳx tH#)( 0*Ӵ֔{k'X tY {аR6Bw4FۦJT=u|hMb0 &C>އ"|+kAU2OZ> Q6Qsun4efR sgarXxfܗܓQF mQ@50/:ֱ$k =&GzK*EϤyB=P) PZ,M׼@\&P r:wbmO[z zukn@AНK!B0`0`Uzc &C X%~l%Wў7B3 o/*sȝL(7fu _!LpБnp+%̌m)$)EMbqJYsH=-) VjCiIy9a*?ڶI⑨y3١Jc!PTQ},:/$((So3X?!lf[u%선6;~`HaU(l& =!%4 "ǀAezX)BbE,"(*+UmѠBX{VDshm@<+Ai5 j)NV ""UqzH[wp@ƗB4\0r&wcd(BaF@TM<=<z\#lݫR,HJUBX'`6we0@X]HaUVE!cmV+.BR7b+i M(Sx~MhGVl6:Uph#G%CdVT`ߦ'͙5 W RqѧskhMFh'`GEUz azaMkeJ^]HArx7Z6hITppKłNfrc;cP~һNL=5bc=0yvk+ )L~؂-{ؕ,deqm6f+X<%РEȐk ruConI ak"d(OUlKK9;s} ugA7]&] MÿMR%zpw6OV|7-"/C]W$/Qf!$};Zb ϾsuYdKL"8Sؑ&7$<#v9,̧e|Cݤ:PnI 'nXе$uO8K̴-Fʡ H>P̻Fm]S'1Btسo ,V2ȦX{^b"Ma{~ Ze-\noM_5%re^W""lDUZc&Е .)y{z9!>{~Ν;avKWxVdž MGaݑg]~c TNGN8EYtkr]#{ڋEkl WBat>rkX\24OZ \)%eRfvGQnSk$y%V@5 Q_`VqG)H_{>QRc<,IRfFykS?Ƿhn⚪N1YA]Gd=Ǖ{4{*xċ #UNJֽqyߟ9t{Jʘe٢Y#lرcӧOJ4{T|"$CxGܱ!ɩS/ ~&dÇo?~+6 N/v_xY 8ŅWԌ +bQ7`IL~JU`:t$aʾ{?dd'X3uY[oA(Y55݋W^!1\p\3p`rʥ*IENDB`uget-1.10.4/pixmaps/Makefile.am0000664000175000017500000000364412165471260013214 00000000000000# icons installing path: # $(datadir)/icons/hicolor/16x16/apps/uget-icon.png # $(datadir)/icons/hicolor/22x22/apps/uget-icon.png # $(datadir)/icons/hicolor/24x24/apps/uget-icon.png # $(datadir)/icons/hicolor/32x32/apps/uget-icon.png # $(datadir)/icons/hicolor/48x48/apps/uget-icon.png # $(datadir)/icons/hicolor/64x64/apps/uget-icon.png # $(datadir)/icons/hicolor/96x96/apps/uget-icon.png # $(datadir)/icons/hicolor/128x128/apps/uget-icon.png # $(datadir)/icons/hicolor/scalable/apps/uget-icon.svg # iconsdir = $(datadir) nobase_dist_icons_DATA = \ icons/hicolor/16x16/apps/uget-icon.png \ icons/hicolor/22x22/apps/uget-icon.png \ icons/hicolor/24x24/apps/uget-icon.png \ icons/hicolor/32x32/apps/uget-icon.png \ icons/hicolor/48x48/apps/uget-icon.png \ icons/hicolor/64x64/apps/uget-icon.png \ icons/hicolor/96x96/apps/uget-icon.png \ icons/hicolor/128x128/apps/uget-icon.png \ icons/hicolor/scalable/apps/uget-icon.svg \ icons/hicolor/16x16/apps/uget-tray-default.png \ icons/hicolor/22x22/apps/uget-tray-default.png \ icons/hicolor/24x24/apps/uget-tray-default.png \ icons/hicolor/32x32/apps/uget-tray-default.png \ icons/hicolor/48x48/apps/uget-tray-default.png \ icons/hicolor/16x16/apps/uget-tray-downloading.png \ icons/hicolor/22x22/apps/uget-tray-downloading.png \ icons/hicolor/24x24/apps/uget-tray-downloading.png \ icons/hicolor/32x32/apps/uget-tray-downloading.png \ icons/hicolor/48x48/apps/uget-tray-downloading.png \ icons/hicolor/16x16/apps/uget-tray-error.png \ icons/hicolor/22x22/apps/uget-tray-error.png \ icons/hicolor/24x24/apps/uget-tray-error.png \ icons/hicolor/32x32/apps/uget-tray-error.png \ icons/hicolor/48x48/apps/uget-tray-error.png # pixmaps # ugetpixmapdir = $(datadir)/pixmaps/uget dist_ugetpixmap_DATA = logo.png # icons/hicolor/index.theme is needed by gtk_icon_theme_append_search_path() # EXTRA_DIST = icons/hicolor/index.theme uget-1.10.4/pixmaps/logo.png0000664000175000017500000003212612165471260012623 00000000000000PNG  IHDRVQstEXtSoftwareAdobe ImageReadyqe<3IDATx} EoUe%LBB" ;a䩠x "W\>޻?x}  Ȣ }}Y{U_UW92œIt饪}%U>.h//6(1QK?=9Rv:,1 ~xGo [VAk jvR;Yofo?CT'}P@@x@h ?uY>}8mHk"=\X_1of=(>11~y^V|X͈b9xK oطw)_YΤZC6S>:-TX@(@@A{b(Ai6}Ǯʏ.%^' NNwyr*̵M:P3jtP=.p`( F$<0jR6x )3nr !|[s*'8+q46_lil{$Έҩ[Cd>GC(LZ3Cu ~)7AXbHJQ.2E޾\>=5,@*`(ĆTA1) \z H_ $ @z='zHT)9N?ou.B@jA27$2'3LZP /}DcPHO ]#a`0)ZD. Wl~ P~t63ψ@% @J#9Bu]!xVФ$O`! e-8ulUVPoHD.)7ND D[(MݑJ3Q+䝯޶E~.Wg´v /OF0d @\gL6Mx:/S4'0Ɉc%wqO{fL?bb;A vR|:K@Dw3_jih(A3C#Z>7~*m 鳏7=~aɨebUW|!}Xqme{R΍;Aj4E0"ģrjp NzmH>`:֡݊p7 h1Ȅa{r݅掆kp3($^|C`;Yj|л_SRt?wFDBP;XDΫkJI)U}&$j+hBj$60 (C٨S`OUTīv0yEJ¨8N`p.DIG 8B f?*E1~ALb|u!>J OD2t*mHDA8.*g#p{!g+C6) AkiyW,}̈́cm@D([Ċ JJ)Mȱ%QI/XH&]0*3FT7yDTI+ES;H'`R6y8NKx_I2NC"Q."MTf Q9#J0R",q>= K6\'tI4N@x`aG4UtCtȾ7NUTuQ>X&*|LivyP08 j%.y>If b &`כOsNhΪlS L@$I"$$1Uɮ 1ԎiD52j=J J:60(7X#84bFM6DDaCB7Yp0U&RQ:I,P}КZfJ"`fqP+9łN!iaHH!<{>$Iِz9V%G2F]ȁ6{=7,}oO0?mh/I:SUEĺd5HȶY*JRDfJ*CIlaؾE`g!$ZL2$"HQDs$MK?$ fz*a.RT>+)`Aj%$ i';uMqPX(w67 ?BZ #r5iqfH&)V8/+ANr8<%h\( -**LmSt"m"!t} PQ oݖh "8Ia\):)p)JLf!ʋ\yD)\g6(H$#!,8fUT-RaOk_R49e4LTŀ% V]! T o* &~bR)$jdq1'.ꏭ7GE#$A +6+k&!g+L8cSeq>SjZ{bjV5Zb:AѢA'" WEr_1]yHF`|(:,!*` f|X":W<%qJZM!Ek5fCXqvep38aϜ= ٧fkN49ᵌ1HݺLXzphIa 9-Ĺ==px͐# `QIB(W:w hdDRhXe.?< 9P6?/Mu u EcQ d\F*08̑ eNDu$YE }$~=eGkD": BdG4$2 AN \)R)&돯&?Ri4L1"1@zD\PJp fx"tF; Wk%5Jܴ,99̉(KD 3mDWCB0RTιP@DA—*`NKTXs9,аcc"e$!0bwr@4Lbf2,X9k]~y(xQu XD@i6SDKKQӤU2"Z ^ 5L; d$$>f1]C<`Ul`|Mp!ՠU&J Yf&jyQѾ$9*@iq;n!:i Q3%A ZBH$Ѥ/U8N,x”"N͌K +XRt)dQT$1Bp,IJHqDBX*G#),q16m"e+LmK4`tBI8/Ơ$&#*@VtTΤ(TQ@{bSU,oFI ʷ"&٨jYxbjXk)a~$ BeXe&UlYwX$j$k0,L@B|jeb HIDA(x OrR.}H_ftHT@c0ϐX6|+9 *l8fp1uu: AY]\L;L b*߳}8ZikZ\3ʟpkM+w_hk}/m[͹c+uʕ>qLUnݸnnGeE@Ґ-OQDqR|H 930r(XټDkkz%FQ h0Y7urZv2~oZovU_#0_fTO}Hj_J,#80*B53p- $yͷwf`ˉ5}r52,'(:A-8PM% 4% FbO# x&4%H k( 4TUi{c}fy|R;$ @m60_Qm맼7?=Sr.!cYiQ@ !BGNs#9̮NghD:Ś#DJDsHyA=O^= |ߐ0JcJQW'*NjxQbX9xE"[/ TqDDٍrƗYwT.o]$wbD@ SlvjJ ),f[,,d?Q7K82*s?/< 窹T}bo\. !x>O6f9$2ݏ(%qi_>6.q~t]/O)4σ5hXdd,l +ppHEBbWO,B!4  ڜ!0LG >GC:g "[IUVZG\pȵk:Uhyw_"ЀsVxM0 zx/@,Bi2֏]FWnjJQ)D,UU:HWeߋ<3Ջhu$)Q$Q"ɜSY M9FTc5}-zggx%6XiU, RjMz  $Y_ R?OEQyǿa0ɔsqpqϷgD$uc/JOιS Œο5,,@*0 X kaH85<6kLI^ 5{ 4z5z̕Ӿ "|xw;m2D\\(!!FMC) ;`D9! iTV5hUbnr{mZ8*raA_JI4m)8a\͓.4@CtNSu/0p!cĂi&1(g!9sSş};6->ƹ7=}ǖ}˛?q?f1š!4Z% (QIMz8d3$j&U vy벾UVܩMp@"o41NX@!)%~g #IYâ`?(⍯~IS^]}?碗|:Է4娴udHt0!s'?@$~>)z ȇ}֣5H˧I& S7Z&}lTJ!Mm%"BpV^_cp`Jst,$.4vHz&x$TĂyfO9w@B\?GaB:Q𘜱Ki$Z $c?aw=&J.GP1c.9^ <(W ׹%N%C#/shrߛrūS.G IeB`_}qҒJ[&Q09E jI1>#c*OX JE-۠^dts(nO4at%T<|682WékIT@SI$aTOu RdGX ."ZhJUfXZhyhE{hmPӂJ&\u;bO*^1F6m#*bH:%3~ZfduŔx[95"4iA(o<ˮ82 !B5AdfDs',[SKoTGVеDՍhN2En0S&Fb: mSood@CB{帻HMxY{Sl"fY{e1g/|_]&ecA'm{@ `n gQt IU.Pof_|)6͐T5 ;:<ͪ#HؒgR2&틴9YVDbo[6=. MH7HAh cԆ\G$K']6daW)s&C| +ȉE5.uTIҐ]vnBD&r}NXԞx`"zߑ Rn${_[ge{ͻ^3PK3<2}b C‹ao>D?UGNӋג`蹱YbY\A[gge:B͢}`({j̩,7pOX"}}TuC. b9{5 ;Cw{PMV6S&W[²wٽ>qԁ:k`h5;= i\Cz:nމ.5uD =Qo&9Jo2$i2q:PYFSRȎx5 @.:!qVޙKTrj$L N: B_w_4 Aw2BK-|:tf!4ɟWR=JPP+RIܣuj[.8CU7Xm.@_ S$v/r-#9k1%w 30 `j܎HnϜzMDDr=z7BlPpB"8HXb `Pw|sa>U4,轜fj|D.DY0lƄƄ+Jk2zX @%-*:.B\JQMNsR:gPP5 y1<o:Jks7oic쨟nJӺL}*Sךj ?,&E DQ ؊y꺜˗nN۞ybmŝ@amBqV1ž 1@EzEqo<()X9\Sj*/j\-9yL>4x#/"BܙMeiS$!yߘq^ǂhOG+Foz p;=;n6^e Z o"RNO=E CMmϪ7￟o΍DM,4DLԉ>dcjpԽjԒ,$$\x9mHeq"H:ZNՈӛ`d/.$maeUUDF1i9̙Υdq-;~c AeKh RvM7}5RED* >,{^_;nDS$pNh'5\sUSJlB/7r_]룿]9t(YhH4$hPqC"йY_ަsS:ĴAC CURa@kʑhᵿ<(>+0Bp `dhNF}[Z ͕p*蔷zb  ( hB .>9TIvSM)44 v]:S4>*ڦhR9*'ONM?Sn%s/%wa6I Zw_6*/kZbۖ_ǛQ |?'+& >`@*~5]3]{Ro[N-:Ggw]s Oo[1$Կ*(sGrE{7N=t򑍟:d'Ԥa)"&wݞ g>9˗ aP#ᘜ '9"y J܃&GAH!T3ܿ:@`&bqrNiſKI /%*K+b!U5gg6 l]G}?;g6s Ot447fyTDžvܳvCWZ:dX kz:9r_B-3N_wRd?5-{+O/0w~}O.gfvR;L8uQˉos~vuj@ ~&W=燝:aKˀhx@_iտ_O n*,! w|\t8eߡh:}Lv6go].Jӣ&^쳯[0BJخ'^97-I+c򥰝~9mr!=24 YxqlZ鰭 lcCJ>uiGxOWb Y_tֳYo>)rZ;^o1/)ڌ;6_򲽺$̈\$[R?.!οknWoٲ9fai͟q1hõ#FϐH4\1Ǽ w]%P* TYRP.Smzw Hwel[Xt{]'-(dW'd&tis]O]no1>/KX-̴9b L;Fl?wHlo_ѷcN/9cmNP^ N6H)gmzkMuמ3\\rJGsֻ{LC꽢Ag6.%7N@xz/x;[o()0bӵu): ݖ>UZ2aaϖaNq%?֓%};['l~P2[* ʳwo:yqS/7}]o[51yD^ebJtm/o&)'$mϻ'8Q01W1(S4PGcm}2鿾aN@B}˵TXi'$Rso9"?&\ݿjf3#|uE~8$s=y^ <(C.m0E|Z߻oKbo}l s;V ;ba~T ~m] |;?\/յ|@cn+KV"{6ym`Wܐ{Qn6cbtGgwPis ܗm]߾ݳ{(?eQL([) !c//z:-JϮsKsr˺|7Zt%#"LJ ZVJoS[v}9 /k缷OmmVv6`hCZ_I5e29m,vmzt׋kIH{֕I *Nt<8 eBJ@ v~M}?tx^Sߖ΋ms]{`G]e!zR(v441P` .0ӔVLL9aѤ#@Qtxc]v9O\+l ^6E<qn@WUɤQJguݥ'rw/i%:`'aeV.tYm󲝜%{9/u?sG:OΜϟ~B!9XvȂ'3_][J迴4C).{hx_E<١B#> עiߚ:e_ַγCpvV*,C?6c"$v-."c?7J'Tl@l9 W矛yfˮi{Wz7_9Iy[]13LyM\\)6pJz~¾U׸,ص=g2?x?/k~7JKx=9cFߖRFu< 0y,gIENDB`uget-1.10.4/pixmaps/Makefile.in0000664000175000017500000003741512260757434013236 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = pixmaps DIST_COMMON = $(dist_ugetpixmap_DATA) $(nobase_dist_icons_DATA) \ $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(ugetpixmapdir)" "$(DESTDIR)$(iconsdir)" DATA = $(dist_ugetpixmap_DATA) $(nobase_dist_icons_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APP_INDICATOR_CFLAGS = @APP_INDICATOR_CFLAGS@ APP_INDICATOR_LIBS = @APP_INDICATOR_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURL_CFLAGS = @CURL_CFLAGS@ CURL_CONFIG = @CURL_CONFIG@ CURL_LIBS = @CURL_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETCONF = @GETCONF@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@ GSTREAMER_LIBS = @GSTREAMER_LIBS@ GTHREAD_CFLAGS = @GTHREAD_CFLAGS@ GTHREAD_LIBS = @GTHREAD_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ LDFLAGS = @LDFLAGS@ LFS_CFLAGS = @LFS_CFLAGS@ LFS_LDFLAGS = @LFS_LDFLAGS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ LIBPWMD_CFLAGS = @LIBPWMD_CFLAGS@ LIBPWMD_LIBS = @LIBPWMD_LIBS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ intltool__v_merge_options_ = @intltool__v_merge_options_@ intltool__v_merge_options_0 = @intltool__v_merge_options_0@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ # icons installing path: # $(datadir)/icons/hicolor/16x16/apps/uget-icon.png # $(datadir)/icons/hicolor/22x22/apps/uget-icon.png # $(datadir)/icons/hicolor/24x24/apps/uget-icon.png # $(datadir)/icons/hicolor/32x32/apps/uget-icon.png # $(datadir)/icons/hicolor/48x48/apps/uget-icon.png # $(datadir)/icons/hicolor/64x64/apps/uget-icon.png # $(datadir)/icons/hicolor/96x96/apps/uget-icon.png # $(datadir)/icons/hicolor/128x128/apps/uget-icon.png # $(datadir)/icons/hicolor/scalable/apps/uget-icon.svg # iconsdir = $(datadir) nobase_dist_icons_DATA = \ icons/hicolor/16x16/apps/uget-icon.png \ icons/hicolor/22x22/apps/uget-icon.png \ icons/hicolor/24x24/apps/uget-icon.png \ icons/hicolor/32x32/apps/uget-icon.png \ icons/hicolor/48x48/apps/uget-icon.png \ icons/hicolor/64x64/apps/uget-icon.png \ icons/hicolor/96x96/apps/uget-icon.png \ icons/hicolor/128x128/apps/uget-icon.png \ icons/hicolor/scalable/apps/uget-icon.svg \ icons/hicolor/16x16/apps/uget-tray-default.png \ icons/hicolor/22x22/apps/uget-tray-default.png \ icons/hicolor/24x24/apps/uget-tray-default.png \ icons/hicolor/32x32/apps/uget-tray-default.png \ icons/hicolor/48x48/apps/uget-tray-default.png \ icons/hicolor/16x16/apps/uget-tray-downloading.png \ icons/hicolor/22x22/apps/uget-tray-downloading.png \ icons/hicolor/24x24/apps/uget-tray-downloading.png \ icons/hicolor/32x32/apps/uget-tray-downloading.png \ icons/hicolor/48x48/apps/uget-tray-downloading.png \ icons/hicolor/16x16/apps/uget-tray-error.png \ icons/hicolor/22x22/apps/uget-tray-error.png \ icons/hicolor/24x24/apps/uget-tray-error.png \ icons/hicolor/32x32/apps/uget-tray-error.png \ icons/hicolor/48x48/apps/uget-tray-error.png # pixmaps # ugetpixmapdir = $(datadir)/pixmaps/uget dist_ugetpixmap_DATA = logo.png # icons/hicolor/index.theme is needed by gtk_icon_theme_append_search_path() # EXTRA_DIST = icons/hicolor/index.theme all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu pixmaps/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu pixmaps/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-dist_ugetpixmapDATA: $(dist_ugetpixmap_DATA) @$(NORMAL_INSTALL) test -z "$(ugetpixmapdir)" || $(MKDIR_P) "$(DESTDIR)$(ugetpixmapdir)" @list='$(dist_ugetpixmap_DATA)'; test -n "$(ugetpixmapdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(ugetpixmapdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(ugetpixmapdir)" || exit $$?; \ done uninstall-dist_ugetpixmapDATA: @$(NORMAL_UNINSTALL) @list='$(dist_ugetpixmap_DATA)'; test -n "$(ugetpixmapdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(ugetpixmapdir)'; $(am__uninstall_files_from_dir) install-nobase_dist_iconsDATA: $(nobase_dist_icons_DATA) @$(NORMAL_INSTALL) test -z "$(iconsdir)" || $(MKDIR_P) "$(DESTDIR)$(iconsdir)" @list='$(nobase_dist_icons_DATA)'; test -n "$(iconsdir)" || list=; \ $(am__nobase_list) | while read dir files; do \ xfiles=; for file in $$files; do \ if test -f "$$file"; then xfiles="$$xfiles $$file"; \ else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \ test -z "$$xfiles" || { \ test "x$$dir" = x. || { \ echo "$(MKDIR_P) '$(DESTDIR)$(iconsdir)/$$dir'"; \ $(MKDIR_P) "$(DESTDIR)$(iconsdir)/$$dir"; }; \ echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(iconsdir)/$$dir'"; \ $(INSTALL_DATA) $$xfiles "$(DESTDIR)$(iconsdir)/$$dir" || exit $$?; }; \ done uninstall-nobase_dist_iconsDATA: @$(NORMAL_UNINSTALL) @list='$(nobase_dist_icons_DATA)'; test -n "$(iconsdir)" || list=; \ $(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \ dir='$(DESTDIR)$(iconsdir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(ugetpixmapdir)" "$(DESTDIR)$(iconsdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dist_ugetpixmapDATA \ install-nobase_dist_iconsDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-dist_ugetpixmapDATA \ uninstall-nobase_dist_iconsDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am \ install-dist_ugetpixmapDATA install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man \ install-nobase_dist_iconsDATA install-pdf install-pdf-am \ install-ps install-ps-am install-strip installcheck \ installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-generic pdf \ pdf-am ps ps-am uninstall uninstall-am \ uninstall-dist_ugetpixmapDATA uninstall-nobase_dist_iconsDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: uget-1.10.4/sounds/0000775000175000017500000000000012260772032011060 500000000000000uget-1.10.4/sounds/notification.wav0000664000175000017500000002540011740440107014203 00000000000000RIFF*WAVEfmt DXdata*EQJKF&0^$rA=W*{ u(0;7Vl=aZ>j|%@g!wou:_G.i;STe=_9J@358. 'cS?#u4DUK/I?u&Auv&3Yq@5tK>+02r2{/s*h9 ^2wZY)*^.GCWP3]b_`P]Q2yend8,)O?7+k(o<0dNX`Gy<;8F*KLT;(Dx(Z]~XW]*k}HfjI 107dqQOZ<ZB>p|fXGt2;L+p7yb.N|[!F uKh3 T dM>Uux_& H zyO?#jZS& .@hLK8n\jBG5 V1XF 3xb(Z|6%S6$[sr%Q]+ ` y[eN-W2v/L &?VHELL\0%qz\^ ,9)|$nSXC4ko !J"4E.kCF5UxUdpI B "Q( ] e@ +V9<2q}b@{ 7uEgI{ +Xp&x 0&aZ 2=[#N 9N\mi K,/a'Y z/dV/)oz5-#h+:) j Ob>eq[I} _ zY 2 qG8` J? 7gJ . zo  d Yr'uY -Zk h\  +iKYo7OEI# 'e9 EV{ +.n$ϓ> [S *WMYX^ C9.k B$|oLKۅ*6ZF [ !bVٹu_Iݵ ,F˔) ' Iĉ3/` ' d-9+2X_?VRZxd3C#8 ')l%K/&3?>'-#Ԥah2M'4AC=_#AAG])"w1<<=B_ mlKqۯD78q{B2/S0GC'`ߒ&M$8oY@V$a>Ph-ݳ$43:*c4! 6֜>!L7$K!$&.?PO@S@,-( : Yfb. K<4۷8P(7 ?B_(t5\) !>A?WK QUlI5փ(6<ZYϧ,☦o 2`*Җ76 C x!cy7ϝ+)`$ _ ;.t}h Ԍ[ɨ xHMI3!cܶFŝ P L5B#>/:!V*6 [/Y&޽q )i[<`ߊ gJIGO.%c,%_2!UD#4)c"8% Ej}\Jd+X9%J $s'! TY E )H) NԼ G #iPߠҙ*/3RŗCU HT?< EJ* 0aJT,Hӛ΄4h9jz[8hԴ޶naA07= On0GBG70&)&\=INE8:ImD04>:X ~[[ ;"lӥZ8+ȼōʸ /$3Gp#P#GἹdI| 0 = -%~X),) oYħx%*Е ܍ާǼ PB=? ':q= D- $=)4>599(/"CfF ',37Kl5!!&7XEB:P38b:&"?a ?EԼ?,U$@8  * Lh&*R*g?>DNOLK!TO=;#BXPA=9?;gAMjPKGB;];J5!U3Z.6 , v t:hK*zj,-z 2,& ~/QCH9L6,B::t..7|OYGG?PFKQU?\-87?#7s D'-6+ j&  Xί%`wp-7s0< * 6b)hn-2%Vl(UU|-y+kBH7# 184! Pg!  Te.p ۍe7 (Ґ`QfXv mj<O  _ m 1d+0J-\$#)r(QPQ+* +  nkwj#:ӱL%FNt&pk\* M "HK O|U pq2\iߕQݷ*ކ=ǚEΓէqvnҰߑ*AaUg$7\ }  7LL 4 ]o rF-mפO݀pطU)԰ '}!X1  \S z 9 ; b  {f{`E{g(8gٚB֣oޣݐOո)?OY?@ n p _##!0W1]ffS+7'UgD>XY tir 'Fbd_$!!!L M D @nz+/' 'ON/fߑ |.R.1 " 5 O a#!!%"s5; ' 9  "4=3c-y.vC[=T] 9KcyI'?e ='0  /H 4@\qib = 2 { `)7?axd, = 7kG m HW+  " h]H1eB]G@ L | 8z4tLpE#9OARSi^ & B $8(1 r|Du d[Jp_OQ~d$V[ ~r="zD N s qJQ>$4k|S6vE"p"6 r c "j \ |6sMj j]c^I1{L5O}k?YjnT ouf  i - W<;n`Zpd _D@W{IxeUoG2  5 b S j5o x C j !Ac\';Qa {C 6g y- S +V *  4  : _ , y&9/[W8X:*mUD/ )1< v Y m+],dQ Q_C!n=> (Jr$3UkrZ)  " 5v_zi4/i[vIE (iI\ sd 7   S 2 Q Co'LGD)@|$G+p)@\V0M-^5(-+:>+Z`|SY8bi{G+'UN<>G"M6-pmV d>!vQf; "Lh';.-Dbj~zB#z`$c Q  W/q' B84A#jofP=+R0 ?:<[ jWb3eK6.9PkD7u ^r\{5]4It'k*3%gt^P4hhb= >W~5B>g :d 8 ~\/PV(ZB2bSseK F]j}piXIc ] xUu}8}NOw% .'hKjmd]4`'D,b3;iFJ(o$=c8ZYL|W ;:0o;U`Le.iDB<V2Dk5 z3kV:JEj`A(-k5O  |7O#"X-L>xw9C .Ot5Zjro#tK@Jm@?]BKQMXC#5^nYM9Y,7mo8-rIs,~j@bZ2}6 { KUDqIiE\dLry.R&N&S78(}w <~B$'PFo)E}Bcpvqw| 9saX|>8h\w( X2Nie@.4R>]Ffhc[qs;  J-6$ 0yIVyub>JMSe"(Qz 9;Oxx,B2ec:3pE^}$eq I(21Gp\nZ[P6T[JA6!@1NcF[yunk=36%O9 7} hT ,`ksy<%?mb@ZR\>npS\fsw`C8 YW}@u}yuI@2rjb| 6+*PsH,#(<O-A^!yw`@MjE8SjU=k 0aRz#"'f[I63mF#D3+:Um;rsFbkk%8&Jzg3WYTs[rDAmXO-+D0Gvss`fZF4g~5-:/T && m[YZzv?6Ze^z|` ,;C{bBcocn:]eM% =jqkz.5 Sub^g%6Oa:=31iB) 2Rsh]c 8 8RQg{rnzx\QfhrH18%|'7r 4;JuywqX=M>-E^O*vuSJM:&Lq!#,?Obv{YVSN( xwqvrhnt\KIYPRhsaSg3b}s\|\cdsjR5=8"  oZ`]T}"1_#0~7 kP_vwgVVfiPQq|qmgz<fj~uget-1.10.4/sounds/Makefile.am0000664000175000017500000000014111740440107013025 00000000000000soundsdir = $(datadir)/sounds/uget sounds_DATA = notification.wav EXTRA_DIST = $(sounds_DATA) uget-1.10.4/sounds/Makefile.in0000664000175000017500000003114512260757434013062 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : subdir = sounds DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = SOURCES = DIST_SOURCES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ *) f=$$p;; \ esac; am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; am__install_max = 40 am__nobase_strip_setup = \ srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` am__nobase_strip = \ for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" am__nobase_list = $(am__nobase_strip_setup); \ for p in $$list; do echo "$$p $$p"; done | \ sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ if (++n[$$2] == $(am__install_max)) \ { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ END { for (dir in files) print dir, files[dir] }' am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' am__uninstall_files_from_dir = { \ test -z "$$files" \ || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ $(am__cd) "$$dir" && rm -f $$files; }; \ } am__installdirs = "$(DESTDIR)$(soundsdir)" DATA = $(sounds_DATA) DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APP_INDICATOR_CFLAGS = @APP_INDICATOR_CFLAGS@ APP_INDICATOR_LIBS = @APP_INDICATOR_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURL_CFLAGS = @CURL_CFLAGS@ CURL_CONFIG = @CURL_CONFIG@ CURL_LIBS = @CURL_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETCONF = @GETCONF@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@ GSTREAMER_LIBS = @GSTREAMER_LIBS@ GTHREAD_CFLAGS = @GTHREAD_CFLAGS@ GTHREAD_LIBS = @GTHREAD_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ LDFLAGS = @LDFLAGS@ LFS_CFLAGS = @LFS_CFLAGS@ LFS_LDFLAGS = @LFS_LDFLAGS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ LIBPWMD_CFLAGS = @LIBPWMD_CFLAGS@ LIBPWMD_LIBS = @LIBPWMD_LIBS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ intltool__v_merge_options_ = @intltool__v_merge_options_@ intltool__v_merge_options_0 = @intltool__v_merge_options_0@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ soundsdir = $(datadir)/sounds/uget sounds_DATA = notification.wav EXTRA_DIST = $(sounds_DATA) all: all-am .SUFFIXES: $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu sounds/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu sounds/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-soundsDATA: $(sounds_DATA) @$(NORMAL_INSTALL) test -z "$(soundsdir)" || $(MKDIR_P) "$(DESTDIR)$(soundsdir)" @list='$(sounds_DATA)'; test -n "$(soundsdir)" || list=; \ for p in $$list; do \ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ echo "$$d$$p"; \ done | $(am__base_list) | \ while read files; do \ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(soundsdir)'"; \ $(INSTALL_DATA) $$files "$(DESTDIR)$(soundsdir)" || exit $$?; \ done uninstall-soundsDATA: @$(NORMAL_UNINSTALL) @list='$(sounds_DATA)'; test -n "$(soundsdir)" || list=; \ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ dir='$(DESTDIR)$(soundsdir)'; $(am__uninstall_files_from_dir) tags: TAGS TAGS: ctags: CTAGS CTAGS: distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(DATA) installdirs: for dir in "$(DESTDIR)$(soundsdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-generic mostlyclean-am distclean: distclean-am -rm -f Makefile distclean-am: clean-am distclean-generic dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-soundsDATA install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-soundsDATA .MAKE: install-am install-strip .PHONY: all all-am check check-am clean clean-generic distclean \ distclean-generic distdir dvi dvi-am html html-am info info-am \ install install-am install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am install-man \ install-pdf install-pdf-am install-ps install-ps-am \ install-soundsDATA install-strip installcheck installcheck-am \ installdirs maintainer-clean maintainer-clean-generic \ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am uninstall \ uninstall-am uninstall-soundsDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: uget-1.10.4/uget-gtk/0000775000175000017500000000000012260772031011273 500000000000000uget-1.10.4/uget-gtk/UgDownloadDialog.c0000664000175000017500000003412212260761064014550 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include // static functions static void ug_download_dialog_set_page0 (UgDownloadDialog* ddialog, gboolean completed); static void ug_download_dialog_set_page1 (UgDownloadDialog* ddialog, gboolean completed); // signal handlers static void on_dialog_show (GtkWidget *widget, UgDownloadDialog* ddialog); static void on_button_back (GtkWidget* button, UgDownloadDialog* ddialog); static void on_button_forward (GtkWidget* button, UgDownloadDialog* ddialog); static void on_category_cursor_changed (GtkTreeView* view, UgDownloadDialog* ddialog); UgDownloadDialog* ug_download_dialog_new (const gchar* title, GtkWindow* parent) { UgDownloadDialog* ddialog; GtkWidget* widget; GtkBox* box; ddialog = g_malloc0 (sizeof (UgDownloadDialog)); ddialog->self = (GtkDialog*) gtk_dialog_new_with_buttons (title, parent, GTK_DIALOG_DESTROY_WITH_PARENT, NULL, NULL); box = (GtkBox*) gtk_dialog_get_content_area (ddialog->self); widget = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (box, widget, TRUE, TRUE, 0); ddialog->hbox = (GtkBox*) widget; gtk_widget_show_all (GTK_WIDGET (box)); // back button box = (GtkBox*) gtk_dialog_get_action_area (ddialog->self); widget = gtk_button_new_from_stock (GTK_STOCK_GO_BACK); gtk_box_pack_start (box, widget, FALSE, FALSE, 0); ddialog->button_back = widget; g_signal_connect (widget, "clicked", G_CALLBACK (on_button_back), ddialog); // forward button widget = gtk_button_new_from_stock (GTK_STOCK_GO_FORWARD); gtk_box_pack_start (box, widget, FALSE, FALSE, 0); ddialog->button_forward = widget; g_signal_connect (widget, "clicked", G_CALLBACK (on_button_forward), ddialog); // OK & cancel buttons gtk_dialog_add_button (ddialog->self, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); gtk_dialog_add_button (ddialog->self, GTK_STOCK_OK, GTK_RESPONSE_OK); gtk_dialog_set_default_response (ddialog->self, GTK_RESPONSE_OK); // form (Page 1) ug_proxy_form_init (&ddialog->proxy); ug_download_form_init (&ddialog->download, &ddialog->proxy, (GtkWindow*) ddialog->self); // initialize page status ddialog->page.array[1] = ug_download_from_use_notebook (&ddialog->download, NULL, NULL); ddialog->page.completed[1] = FALSE; ddialog->page.completed[0] = TRUE; ug_download_dialog_set_current_page (ddialog, 1); // set callback ddialog->download.notify.func = (gpointer) ug_download_dialog_set_page1; ddialog->download.notify.data = ddialog; // signal g_signal_connect_after (ddialog->self, "show", G_CALLBACK (on_dialog_show), ddialog); return ddialog; } void ug_download_dialog_free (UgDownloadDialog* ddialog) { // remove pages from container and destroy them. g_object_ref (ddialog->page.current); gtk_container_remove (GTK_CONTAINER (ddialog->hbox), ddialog->page.current); if (ddialog->selector.self) { gtk_widget_destroy (ddialog->selector.self); ug_selector_finalize (&ddialog->selector); } if (ddialog->download.page1) { gtk_widget_destroy (ddialog->page.array[1]); // gtk_widget_destroy (ddialog->download.page1); // gtk_widget_destroy (ddialog->download.page2); } if (ddialog->batch.self) gtk_widget_destroy (ddialog->batch.self); // free external data if (ddialog->dataset) ug_dataset_unref (ddialog->dataset); // destroy dialog gtk_widget_destroy (GTK_WIDGET (ddialog->self)); g_free (ddialog); } void ug_download_dialog_use_batch (UgDownloadDialog* ddialog) { GtkRequisition requisition; // (Page 0) ug_batch_form_init (&ddialog->batch); ug_download_form_set_multiple (&ddialog->download, TRUE); gtk_widget_get_preferred_size (ddialog->download.page1, &requisition, NULL); gtk_widget_set_size_request (ddialog->batch.self, requisition.width, requisition.height); // setup page and button ddialog->page.array[0] = ddialog->batch.self; ddialog->page.completed[0] = FALSE; ddialog->page.completed[1] = TRUE; ug_download_dialog_set_current_page (ddialog, 0); gtk_widget_show (ddialog->button_back); gtk_widget_show (ddialog->button_forward); // set callback ddialog->batch.notify.func = (gpointer) ug_download_dialog_set_page0; ddialog->batch.notify.data = ddialog; } void ug_download_dialog_use_selector (UgDownloadDialog* ddialog) { GtkRequisition requisition; // (Page 0) ug_selector_init (&ddialog->selector, (GtkWindow*) ddialog->self); ug_download_form_set_multiple (&ddialog->download, TRUE); gtk_widget_get_preferred_size (ddialog->download.page1, &requisition, NULL); gtk_widget_set_size_request (ddialog->selector.self, requisition.width, requisition.height); // setup page and button ddialog->page.array[0] = ddialog->selector.self; ddialog->page.completed[0] = FALSE; ddialog->page.completed[1] = TRUE; ug_download_dialog_set_current_page (ddialog, 0); gtk_widget_show (ddialog->button_back); gtk_widget_show (ddialog->button_forward); // set callback ddialog->selector.notify.func = (gpointer) ug_download_dialog_set_page0; ddialog->selector.notify.data = ddialog; } void ug_download_dialog_set_category (UgDownloadDialog* ddialog, UgCategoryWidget* cwidget) { GtkTreeModel* model; GtkTreePath* path; GtkWidget* scrolled; GtkBox* vbox; ddialog->category_view = ug_category_view_new (); ug_category_view_set_icon_visible (ddialog->category_view, FALSE); model = cwidget->filter; gtk_tree_view_set_model (ddialog->category_view, model); // signal g_signal_connect (ddialog->category_view, "cursor-changed", G_CALLBACK (on_category_cursor_changed), ddialog); // select current category and emit "cursor-changed" signal. gtk_tree_view_get_cursor (cwidget->view, &path, NULL); if (path == NULL) path = gtk_tree_path_new_from_indices (0, -1); else if (gtk_tree_path_get_depth (path) == 2) gtk_tree_path_up (path); gtk_tree_view_set_cursor (ddialog->category_view, path, NULL, FALSE); gtk_tree_path_free (path); // scrolled window scrolled = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_size_request (scrolled, 165, 100); gtk_widget_show (scrolled); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolled), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (ddialog->category_view)); // pack vbox vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_box_pack_start (vbox, gtk_label_new (_("Category")), FALSE, FALSE, 0); gtk_box_pack_start (vbox, (GtkWidget*) scrolled, TRUE, TRUE, 0); gtk_widget_show_all ((GtkWidget*) vbox); // pack hbox gtk_box_pack_start (ddialog->hbox, (GtkWidget*) vbox, FALSE, FALSE, 1); } void ug_download_dialog_set_current_page (UgDownloadDialog* ddialog, gint nth_page) { if (ddialog->page.current) { g_object_ref (ddialog->page.current); gtk_container_remove (GTK_CONTAINER (ddialog->hbox), ddialog->page.current); ddialog->page.current = NULL; } if (nth_page == 0 && ddialog->page.array[0]) { ddialog->page.current = ddialog->page.array[0]; gtk_box_pack_end (ddialog->hbox, ddialog->page.current, TRUE, TRUE, 1); gtk_widget_set_sensitive (ddialog->button_back, FALSE); gtk_widget_set_sensitive (ddialog->button_forward, TRUE); } else if (nth_page == 1) { ddialog->page.current = ddialog->page.array[1]; gtk_box_pack_end (ddialog->hbox, ddialog->page.current, TRUE, TRUE, 1); gtk_widget_set_sensitive (ddialog->button_back, TRUE); gtk_widget_set_sensitive (ddialog->button_forward, FALSE); } } void ug_download_dialog_get (UgDownloadDialog* ddialog, UgDataset* dataset) { ug_proxy_form_get (&ddialog->proxy, dataset); ug_download_form_get (&ddialog->download, dataset); } void ug_download_dialog_set (UgDownloadDialog* ddialog, UgDataset* dataset) { ug_proxy_form_set (&ddialog->proxy, dataset, FALSE); ug_download_form_set (&ddialog->download, dataset, FALSE); } UgCategory* ug_download_dialog_get_category (UgDownloadDialog* ddialog) { UgCategory* category; GtkTreeModel* model; GtkTreePath* path; GtkTreeIter iter; gtk_tree_view_get_cursor (ddialog->category_view, &path, NULL); model = gtk_tree_view_get_model (ddialog->category_view); if (path) { gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); } else if (gtk_tree_model_get_iter_first (model, &iter) == FALSE) return NULL; gtk_tree_model_get (model, &iter, 0, &category, -1); return category; } GList* ug_download_dialog_get_downloads (UgDownloadDialog* ddialog) { UgDataset* dataset; UgetCommon* common; GList* list; GList* link; // batch if (ddialog->batch.self) { list = ug_batch_form_get_list (&ddialog->batch, FALSE); for (link = list; link; link = link->next) { dataset = ug_dataset_new (); ug_download_dialog_get (ddialog, dataset); common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); g_free (common->url); common->url = link->data; ug_download_complete_data (dataset); link->data = dataset; } return list; } // selector if (ddialog->selector.self) { dataset = ug_dataset_new (); ug_download_dialog_get (ddialog, dataset); list = ug_selector_get_marked_downloads (&ddialog->selector); for (link = list; link; link = link->next) { ug_data_assign (link->data, dataset); ug_download_complete_data (link->data); } ug_dataset_unref (dataset); return list; } // external data if (ddialog->dataset) { // ug_download_dialog_free() will call ug_dataset_unref() dataset = ddialog->dataset; ug_dataset_ref (dataset); } else dataset = ug_dataset_new (); ug_download_dialog_get (ddialog, dataset); list = g_list_prepend (NULL, dataset); return list; } // ---------------------------------------------------------------------------- // static functions // static void ug_download_dialog_decide_completed (UgDownloadDialog* ddialog) { GtkTreePath* path; gboolean completed; // enable or disable GTK_RESPONSE_OK if (ddialog->page.completed[0]==TRUE && ddialog->page.completed[1]==TRUE) completed = TRUE; else completed = FALSE; // if no category selected, disable GTK_RESPONSE_OK. if (ddialog->category_view) { gtk_tree_view_get_cursor (ddialog->category_view, &path, NULL); if (path) gtk_tree_path_free (path); else completed = FALSE; } gtk_dialog_set_response_sensitive (ddialog->self, GTK_RESPONSE_OK, completed); } static void ug_download_dialog_set_page0 (UgDownloadDialog* ddialog, gboolean completed) { ddialog->page.completed[0] = completed; gtk_widget_set_sensitive (ddialog->button_forward, completed); ug_download_dialog_decide_completed (ddialog); } static void ug_download_dialog_set_page1 (UgDownloadDialog* ddialog, gboolean completed) { ddialog->page.completed[1] = completed; ug_download_dialog_decide_completed (ddialog); } // ---------------------------------------------------------------------------- // signal handler // static void on_dialog_show (GtkWidget *widget, UgDownloadDialog* ddialog) { // emit callback & set focus if (ddialog->batch.self) { ug_batch_form_update_preview (&ddialog->batch); gtk_window_set_focus ((GtkWindow*) ddialog->self, (GtkWidget*) ddialog->batch.entry); } else if (ddialog->selector.self) { ug_selector_count_marked (&ddialog->selector); gtk_window_set_focus ((GtkWindow*) ddialog->self, (GtkWidget*) ddialog->selector.notebook); } else if (gtk_widget_is_sensitive (ddialog->download.url_entry)) { gtk_window_set_focus ((GtkWindow*) ddialog->self, (GtkWidget*) ddialog->download.url_entry); } else { gtk_window_set_focus ((GtkWindow*) ddialog->self, (GtkWidget*) ddialog->download.folder_entry); } } static void on_button_back (GtkWidget* button, UgDownloadDialog* ddialog) { ug_download_dialog_set_current_page (ddialog, 0); } static void on_button_forward (GtkWidget* button, UgDownloadDialog* ddialog) { ug_download_dialog_set_current_page (ddialog, 1); } static void on_category_cursor_changed (GtkTreeView* view, UgDownloadDialog* ddialog) { GtkTreeModel* model; GtkTreePath* path; GtkTreeIter iter; UgCategory* category; gtk_tree_view_get_cursor (view, &path, NULL); if (path == NULL) { gtk_dialog_set_response_sensitive (ddialog->self, GTK_RESPONSE_OK, FALSE); return; } if (ddialog->page.completed[0]==TRUE && ddialog->page.completed[1]==TRUE) gtk_dialog_set_response_sensitive (ddialog->self, GTK_RESPONSE_OK, TRUE); // apply settings model = gtk_tree_view_get_model (view); gtk_tree_view_get_cursor (view, &path, NULL); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, 0, &category, -1); if (category->defaults) { ug_download_form_set (&ddialog->download, category->defaults, TRUE); ug_proxy_form_set (&ddialog->proxy, category->defaults, TRUE); } } uget-1.10.4/uget-gtk/UgApp-gtk.c0000664000175000017500000011261312260761064013166 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include #include #include #include const char* ug_get_attachment_dir (void) { static const char* dir = NULL; if (dir == NULL) { dir = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, "attachment", NULL); } return dir; } static void ug_app_update_config_dir (void) { gchar* former_dir; gchar* dir; former_dir = g_build_filename (g_get_user_config_dir (), "Uget", NULL); dir = g_filename_from_utf8 (former_dir, -1, NULL, NULL, NULL); if (g_file_test (dir, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) { g_free (dir); dir = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, NULL); ug_rename (former_dir, dir); } g_free (former_dir); g_free (dir); } void ug_app_init (UgAppGtk* app) { UgCategory* category; UgetCommon* common; ug_running_init (&app->running); // upgrade from Uget 1.6 ug_app_update_config_dir (); // initialize widgets in UgApp-gtk-gui.c ug_app_init_gui (app); // initialize settings ug_setting_init (&app->setting); // load settings & data ug_attachment_init (ug_get_attachment_dir ()); ug_app_load (app); ug_attachment_sync (); // apply settings ug_app_set_setting (app, &app->setting); ug_clipboard_init (&app->clipboard, app->setting.clipboard.pattern); app->launch_regex = g_regex_new (app->setting.launch.types, G_REGEX_CASELESS, 0, NULL); // If no category exists, create new one. if (ug_category_widget_n_category (&app->cwidget) == 0) { category = ug_category_new_with_gtk (app->cwidget.primary.category); category->name = g_strdup ("Home"); common = ug_dataset_alloc_front (category->defaults, UgetCommonInfo); common->folder = g_strdup (g_get_home_dir ()); ug_category_widget_append (&app->cwidget, category); } // initialize signal handlers in UgApp-gtk-callback.c ug_app_init_callback (app); // initialize timeout in UgApp-gtk-timeout.c ug_app_init_timeout (app); // initialize aria2 ug_app_aria2_init (app); ug_app_aria2_setup (app); // get update info ug_app_get_update_info (app); ug_app_menubar_sync_category (app, TRUE); ug_category_view_set_cursor (app->cwidget.primary.view, 0, -1); gtk_window_set_focus (app->window.self, (GtkWidget*) app->cwidget.primary.view); // set user interface if (app->setting.ui.start_in_offline_mode) gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (app->trayicon.menu.offline_mode), TRUE); if (app->setting.ui.start_in_tray == FALSE) gtk_widget_show ((GtkWidget*) app->window.self); ug_app_trayicon_decide_visible (app); } void ug_app_quit (UgAppGtk* app) { // stop all active download ug_running_clear (&app->running); // get and update setting before program save it ug_app_get_setting (app, &app->setting); // save data ug_app_save (app); // aria2 ug_app_aria2_finalize (app); // hide icon in system tray before quit ug_trayicon_set_visible (&app->trayicon, FALSE); // hide window gtk_widget_hide (GTK_WIDGET (app->window.self)); // clear update info ug_app_clear_update_info (app); // aria2 ug_app_aria2_shutdown (app); // This will quit gtk_main() in main() gtk_main_quit (); } void ug_app_save (UgAppGtk* app) { GList* list; gchar* file; // save setting file = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, UG_APP_GTK_SETTING_FILE, NULL); ug_setting_save (&app->setting, file); g_free (file); // get and save all tasks from primary category list = ug_category_gtk_get_all (app->cwidget.primary.category); file = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, UG_APP_GTK_DOWNLOAD_FILE, NULL); ug_download_list_save (list, file); g_list_free (list); g_free (file); // save categories file = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, UG_APP_GTK_CATEGORY_FILE, NULL); list = ug_category_widget_get_list (&app->cwidget); ug_category_list_save (list, file); g_list_free (list); g_free (file); } void ug_app_load (UgAppGtk* app) { GList* category_list; GList* download_list; GList* link; gchar* file; // load setting file = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, UG_APP_GTK_SETTING_FILE, NULL); ug_setting_load (&app->setting, file); g_free (file); // load all tasks from file file = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, UG_APP_GTK_DOWNLOAD_FILE, NULL); download_list = ug_download_list_load (file); g_free (file); // load all categories file = g_build_filename (g_get_user_config_dir (), UG_APP_GTK_DIR, UG_APP_GTK_CATEGORY_FILE, NULL); category_list = ug_category_list_load (file); g_free (file); // set primary category for (link = category_list; link; link = link->next) ug_category_use_gtk (link->data, app->cwidget.primary.category); // add tasks to primary category for (link = download_list; link; link = link->next) ug_category_add (app->cwidget.primary.category, link->data); // link and add tasks to categories ug_category_list_link (category_list, download_list); ug_category_widget_add_list (&app->cwidget, category_list); g_list_free (category_list); // free unused tasks and list g_list_foreach (download_list, (GFunc) ug_dataset_unref, NULL); g_list_free (download_list); } void ug_app_set_setting (UgAppGtk* app, UgSetting* setting) { // set window position, size, and maximized state if (setting->window.width > 0 && setting->window.height > 0 && setting->window.x < gdk_screen_width () && setting->window.y < gdk_screen_height () && setting->window.x + setting->window.width > 0 && setting->window.y + setting->window.height > 0) { gtk_window_move (app->window.self, setting->window.x, setting->window.y); gtk_window_resize (app->window.self, setting->window.width, setting->window.height); } if (setting->window.maximized) gtk_window_maximize (app->window.self); // set visible widgets gtk_widget_set_visible (app->toolbar.self, setting->window.toolbar); gtk_widget_set_visible ((GtkWidget*) app->statusbar.self, setting->window.statusbar); gtk_widget_set_visible (app->cwidget.self, setting->window.category); gtk_widget_set_visible (app->summary.self, setting->window.summary); gtk_widget_set_visible (app->banner.self, setting->window.banner); // Summary app->summary.visible.name = setting->summary.name; app->summary.visible.folder = setting->summary.folder; app->summary.visible.category = setting->summary.category; app->summary.visible.url = setting->summary.url; app->summary.visible.message = setting->summary.message; // ---------------------------------------------------- // UgEditMenu gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.edit.clipboard_monitor, setting->clipboard.monitor); // ---------------------------------------------------- // UgViewMenu gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.toolbar, setting->window.toolbar); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.statusbar, setting->window.statusbar); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.category, setting->window.category); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.summary, setting->window.summary); // summary items gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.summary_items.name, setting->summary.name); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.summary_items.folder, setting->summary.folder); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.summary_items.category, setting->summary.category); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.summary_items.url, setting->summary.url); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.summary_items.message, setting->summary.message); // download column gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.completed, setting->download_column.completed); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.total, setting->download_column.total); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.percent, setting->download_column.percent); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.elapsed, setting->download_column.elapsed); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.left, setting->download_column.left); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.speed, setting->download_column.speed); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.upload_speed, setting->download_column.upload_speed); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.uploaded, setting->download_column.uploaded); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.ratio, setting->download_column.ratio); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.retry, setting->download_column.retry); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.category, setting->download_column.category); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.url, setting->download_column.url); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.added_on, setting->download_column.added_on); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.view.columns.completed_on, setting->download_column.completed_on); #ifdef HAVE_APP_INDICATOR // AppIndicator if (setting->ui.app_indicator == FALSE) app->trayicon.indicator = NULL; #endif // HAVE_APP_INDICATOR // get setting of download column app->cwidget.sort.nth = app->setting.download_column.sort.nth; app->cwidget.sort.order = app->setting.download_column.sort.order; // aria2 ug_app_decide_bt_meta_sensitive (app); } void ug_app_get_setting (UgAppGtk* app, UgSetting* setting) { GdkWindowState gdk_wstate; GdkWindow* gdk_window; // get window position, size, and maximzied state if (gtk_widget_get_visible (GTK_WIDGET (app->window.self)) == TRUE) { gdk_window = gtk_widget_get_window (GTK_WIDGET (app->window.self)); gdk_wstate = gdk_window_get_state (gdk_window); if (gdk_wstate & GDK_WINDOW_STATE_MAXIMIZED) setting->window.maximized = TRUE; else setting->window.maximized = FALSE; // get geometry if (setting->window.maximized == FALSE) { gtk_window_get_position (app->window.self, &setting->window.x, &setting->window.y); gtk_window_get_size (app->window.self, &setting->window.width, &setting->window.height); } } // get setting of download column if (app->cwidget.current.widget == &app->cwidget.current.cgtk->all) { app->setting.download_column.sort.nth = app->cwidget.current.widget->sort.nth; app->setting.download_column.sort.order = app->cwidget.current.widget->sort.order; } else { app->setting.download_column.sort.nth = app->cwidget.sort.nth; app->setting.download_column.sort.order = app->cwidget.sort.order; } // banner setting->window.banner = gtk_widget_get_visible (app->banner.self); } // ------------------------------------ static size_t write_update_info (void *ptr, size_t size, size_t nmemb, GString* buf) { if (buf->len > 4096) return 0; g_string_append_len (buf, ptr, size * nmemb); return nmemb; } static void get_update_info_thread (UgAppGtk* app) { CURL* curl; CURLcode res; long response_code = 0; curl = curl_easy_init(); curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, (curl_write_callback) write_update_info); curl_easy_setopt (curl, CURLOPT_WRITEDATA, app->update_info.text); curl_easy_setopt (curl, CURLOPT_URL, "http://ugetdm.com/versioncheck?v=" PACKAGE_VERSION); curl_easy_setopt (curl, CURLOPT_NOSIGNAL, 1); res = curl_easy_perform (curl); curl_easy_getinfo (curl, CURLINFO_RESPONSE_CODE, &response_code); curl_easy_cleanup (curl); if (res == CURLE_OK && response_code < 400) app->update_info.ready = TRUE; app->update_info.thread = NULL; } void ug_app_get_update_info (UgAppGtk* app) { if (app->update_info.thread == NULL) { if (app->update_info.text == NULL) app->update_info.text = g_string_sized_new (2048); g_string_set_size (app->update_info.text, 0); app->update_info.ready = FALSE; app->update_info.thread = g_thread_new ("get update info", (GThreadFunc) get_update_info_thread, app); g_thread_unref (app->update_info.thread); } } void ug_app_clear_update_info (UgAppGtk* app) { if (app->update_info.thread == NULL) { if (app->update_info.text) g_string_free (app->update_info.text, TRUE); app->update_info.text = NULL; app->update_info.ready = FALSE; } } // ------------------------------------------------------- // UgClipboard void ug_clipboard_init (struct UgClipboard* clipboard, const gchar* pattern) { clipboard->self = gtk_clipboard_get (GDK_SELECTION_CLIPBOARD); clipboard->text = NULL; clipboard->regex = g_regex_new (pattern, G_REGEX_CASELESS, 0, NULL); } void ug_clipboard_set_pattern (struct UgClipboard* clipboard, const gchar* pattern) { if (clipboard->regex) g_regex_unref (clipboard->regex); clipboard->regex = g_regex_new (pattern, G_REGEX_CASELESS, 0, NULL); } void ug_clipboard_set_text (struct UgClipboard* clipboard, gchar* text) { g_free (clipboard->text); clipboard->text = text; gtk_clipboard_set_text (clipboard->self, text, -1); } GList* ug_clipboard_get_uris (struct UgClipboard* clipboard) { GList* list; gchar* text; if (gtk_clipboard_wait_is_text_available (clipboard->self) == FALSE) return NULL; text = gtk_clipboard_wait_for_text (clipboard->self); if (text == NULL) return NULL; // get URIs that scheme is not "file" from text list = ug_text_get_uris (text, -1); list = ug_uri_list_remove_scheme (list, "file"); g_free (text); return list; } GList* ug_clipboard_get_matched (struct UgClipboard* clipboard, const gchar* text) { GList* link; GList* list; gchar* temp; if (text == NULL) { g_free (clipboard->text); clipboard->text = NULL; return NULL; } // compare temp = (clipboard->text) ? clipboard->text : ""; if (g_ascii_strcasecmp (text, temp) == 0) return NULL; // replace text g_free (clipboard->text); clipboard->text = g_strdup (text); // get and filter list list = ug_text_get_uris (text, -1); list = ug_uri_list_remove_scheme (list, "file"); // filter by filename extension for (link = list; link; link = link->next) { temp = ug_uri_get_filename (link->data); // get filename extension if (temp) text = strrchr (temp, '.'); else text = NULL; // free URIs if not matched if (text == NULL || g_regex_match (clipboard->regex, text+1, 0, NULL) == FALSE) { g_free (link->data); link->data = NULL; } g_free (temp); } list = g_list_remove_all (list, NULL); return list; } // ------------------------------------------------------- // UgTrayIcon and UgStatusbar void ug_trayicon_set_info (struct UgTrayIcon* trayicon, guint n_active, gint64 down_speed, gint64 up_speed) { gchar* string; gchar* string_down_speed; gchar* string_up_speed; guint current_status; // change tray icon if (trayicon->error_occurred) { string = UG_APP_GTK_TRAY_ICON_ERROR_NAME; current_status = 2; } else if (n_active > 0) { string = UG_APP_GTK_TRAY_ICON_ACTIVE_NAME; current_status = 1; } else { string = UG_APP_GTK_TRAY_ICON_NAME; current_status = 0; } if (trayicon->last_status != current_status) { trayicon->last_status = current_status; #ifdef HAVE_APP_INDICATOR if (trayicon->indicator) { trayicon->error_occurred = FALSE; if (app_indicator_get_status (trayicon->indicator) != APP_INDICATOR_STATUS_PASSIVE) { if (current_status == 0) { app_indicator_set_status (trayicon->indicator, APP_INDICATOR_STATUS_ACTIVE); } else { app_indicator_set_attention_icon (trayicon->indicator, string); // app_indicator_set_attention_icon_full (trayicon->indicator, // string, "attention"); app_indicator_set_status (trayicon->indicator, APP_INDICATOR_STATUS_ATTENTION); } } } else #endif // HAVE_APP_INDICATOR gtk_status_icon_set_from_icon_name (trayicon->self, string); } // change tooltip string_down_speed = ug_str_dtoa_unit ((gdouble) down_speed, 1, "/s"); string_up_speed = ug_str_dtoa_unit ((gdouble) up_speed, 1, "/s"); string = g_strdup_printf ( UG_APP_GTK_NAME " " UG_APP_GTK_VERSION "\n" "%u %s" "\n" "D: %s" "\n" "U: %s", n_active, _("tasks"), string_down_speed, string_up_speed); #ifdef HAVE_APP_INDICATOR if (trayicon->indicator) { // g_object_set (trayicon->indicator, "icon-desc", string, NULL); // g_object_set (trayicon->indicator, "attention-icon-desc", string, NULL); } else #endif // HAVE_APP_INDICATOR gtk_status_icon_set_tooltip_text (trayicon->self, string); g_free (string_down_speed); g_free (string_up_speed); g_free (string); } void ug_trayicon_set_visible (struct UgTrayIcon* trayicon, gboolean visible) { #ifdef HAVE_APP_INDICATOR if (trayicon->indicator) { if (visible) app_indicator_set_status (trayicon->indicator, APP_INDICATOR_STATUS_ACTIVE); else app_indicator_set_status (trayicon->indicator, APP_INDICATOR_STATUS_PASSIVE); } else #endif // HAVE_APP_INDICATOR gtk_status_icon_set_visible (trayicon->self, visible); } void ug_statusbar_set_info (struct UgStatusbar* statusbar, UgDownloadWidget* dwidget) { static guint context_id = 0; gint n_selected; gchar* string; if (context_id == 0) context_id = gtk_statusbar_get_context_id (statusbar->self, "selected"); gtk_statusbar_pop (statusbar->self, context_id); if (dwidget) { n_selected = ug_download_widget_count_selected (dwidget); string = g_strdup_printf (_("Selected %d items"), n_selected); gtk_statusbar_push (statusbar->self, context_id, string); g_free (string); } } void ug_statusbar_set_speed (struct UgStatusbar* statusbar, gint64 down_speed, gint64 up_speed) { gchar* string; string = ug_str_dtoa_unit ((gdouble) down_speed, 1, "/s"); gtk_label_set_text (statusbar->down_speed, string); g_free (string); string = ug_str_dtoa_unit ((gdouble) up_speed, 1, "/s"); gtk_label_set_text (statusbar->up_speed, string); g_free (string); } // ------------------------------------------------------- // utility or integrate functions // confirmation dialog struct UgConfirmationDialog { // GtkWidget* self; GtkToggleButton* confirmation; GtkToggleButton* setting; UgAppGtk* app; }; static void on_confirm_to_quit_response (GtkWidget* dialog, gint response, struct UgConfirmationDialog* ucd) { UgAppGtk* app; app = ucd->app; app->dialogs.close_confirmation = NULL; if (response == GTK_RESPONSE_YES) { // window close setting if (gtk_toggle_button_get_active (ucd->setting) == FALSE) app->setting.ui.close_action = 1; // Minimize to tray. else app->setting.ui.close_action = 2; // Exit. // window close confirmation if (gtk_toggle_button_get_active (ucd->confirmation) == FALSE) app->setting.ui.close_confirmation = TRUE; else app->setting.ui.close_confirmation = FALSE; // minimize to tray or exit when user close window. ug_app_window_close (app); } gtk_widget_destroy (dialog); g_free (ucd); } void ug_app_confirm_to_quit (UgAppGtk* app) { struct UgConfirmationDialog* ucd; GtkWidget* dialog; GtkWidget* button; GtkBox* hbox; GtkBox* vbox; gchar* title; // show previous message dialog if (app->dialogs.close_confirmation) { gtk_window_present ((GtkWindow*) app->dialogs.close_confirmation); return; } // create confirmation dialog title = g_strconcat (UG_APP_GTK_NAME " - ", _("Really Quit?"), NULL); dialog = gtk_dialog_new_with_buttons (title, app->window.self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_NO, GTK_RESPONSE_NO, GTK_STOCK_YES, GTK_RESPONSE_YES, NULL); g_free (title); app->dialogs.close_confirmation = dialog; ucd = g_malloc (sizeof (struct UgConfirmationDialog)); // ucd->self = dialog; ucd->app = app; gtk_container_set_border_width (GTK_CONTAINER (dialog), 4); vbox = (GtkBox*) gtk_dialog_get_content_area (GTK_DIALOG (dialog)); // image and label hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (hbox, gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 8); gtk_box_pack_start (hbox, gtk_label_new (_("Are you sure you want to quit?")), FALSE, FALSE, 4); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 6); // check button hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); button = gtk_check_button_new_with_label (_("Remember this action")); gtk_box_pack_end (hbox, button, TRUE, TRUE, 20); gtk_box_pack_end (vbox, (GtkWidget*) hbox, FALSE, FALSE, 10); ucd->confirmation = (GtkToggleButton*) button; // radio button button = gtk_radio_button_new_with_label_from_widget (NULL, _("Minimize to tray")); gtk_box_pack_start (vbox, button, FALSE, FALSE, 1); button = gtk_radio_button_new_with_label_from_widget ((GtkRadioButton*) button, _("Exit uGet")); gtk_box_pack_start (vbox, button, FALSE, FALSE, 1); ucd->setting = (GtkToggleButton*) button; // config if (app->setting.ui.close_action == 0) gtk_toggle_button_set_active (ucd->confirmation, TRUE); else if (app->setting.ui.close_confirmation == FALSE) gtk_toggle_button_set_active (ucd->confirmation, TRUE); else gtk_toggle_button_set_active (ucd->confirmation, FALSE); // if (app->setting.ui.close_action == 1) // gtk_toggle_button_set_active (ucd->setting, TRUE); if (app->setting.ui.close_action == 2) gtk_toggle_button_set_active ((GtkToggleButton*) button, TRUE); g_signal_connect (dialog, "response", G_CALLBACK (on_confirm_to_quit_response), ucd); gtk_widget_show_all ((GtkWidget*) dialog); } // delete confirmation dialog static void on_confirm_to_delete_response (GtkWidget* dialog, gint response, struct UgConfirmationDialog* ucd) { UgAppGtk* app; app = ucd->app; app->dialogs.delete_confirmation = NULL; if (response == GTK_RESPONSE_YES) { // delete confirmation if (gtk_toggle_button_get_active (ucd->confirmation) == FALSE) app->setting.ui.delete_confirmation = TRUE; else app->setting.ui.delete_confirmation = FALSE; } // refresh gtk_widget_set_sensitive ((GtkWidget*) app->window.self, TRUE); gtk_widget_destroy (dialog); g_free (ucd); } void ug_app_confirm_to_delete (UgAppGtk* app, GCallback response, gpointer response_data) { struct UgConfirmationDialog* ucd; GtkWidget* dialog; GtkWidget* button; GtkBox* hbox; GtkBox* vbox; gchar* title; // show previous message dialog if (app->dialogs.delete_confirmation) { gtk_window_present ((GtkWindow*) app->dialogs.delete_confirmation); return; } // create confirmation dialog title = g_strconcat (UG_APP_GTK_NAME " - ", _("Really delete files?"), NULL); dialog = gtk_dialog_new_with_buttons (title, app->window.self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_NO, GTK_RESPONSE_NO, GTK_STOCK_YES, GTK_RESPONSE_YES, NULL); g_free (title); app->dialogs.delete_confirmation = dialog; ucd = g_malloc (sizeof (struct UgConfirmationDialog)); // ucd->self = dialog; ucd->app = app; gtk_container_set_border_width (GTK_CONTAINER (dialog), 4); vbox = (GtkBox*) gtk_dialog_get_content_area (GTK_DIALOG (dialog)); // image and label hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (hbox, gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG), FALSE, FALSE, 8); gtk_box_pack_start (hbox, gtk_label_new (_("Are you sure you want to delete files?")), FALSE, FALSE, 4); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 6); // check button hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); button = gtk_check_button_new_with_label (_("Do not ask me again")); gtk_box_pack_end (hbox, button, TRUE, TRUE, 20); gtk_box_pack_end (vbox, (GtkWidget*) hbox, FALSE, FALSE, 10); ucd->confirmation = (GtkToggleButton*) button; // config if (app->setting.ui.delete_confirmation == FALSE) gtk_toggle_button_set_active ((GtkToggleButton*) button, TRUE); else gtk_toggle_button_set_active ((GtkToggleButton*) button, FALSE); g_signal_connect (dialog, "response", G_CALLBACK (response), response_data); g_signal_connect_after (dialog, "response", G_CALLBACK (on_confirm_to_delete_response), ucd); gtk_widget_set_sensitive ((GtkWidget*) app->window.self, FALSE); gtk_widget_show_all ((GtkWidget*) dialog); } // message dialog static void on_message_response (GtkWidget* dialog, gint response, GtkWidget** value) { gtk_widget_destroy (dialog); *value = NULL; } void ug_app_show_message (UgAppGtk* app, GtkMessageType type, const gchar* message) { GtkWidget* dialog; GtkWidget** value; gchar* title; dialog = gtk_message_dialog_new (app->window.self, GTK_DIALOG_DESTROY_WITH_PARENT, type, GTK_BUTTONS_OK, "%s", message); // set title switch (type) { case GTK_MESSAGE_ERROR: if (app->dialogs.error) gtk_widget_destroy (app->dialogs.error); app->dialogs.error = dialog; value = &app->dialogs.error; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Error"), NULL); break; default: if (app->dialogs.message) gtk_widget_destroy (app->dialogs.message); app->dialogs.message = dialog; value = &app->dialogs.message; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Message"), NULL); break; } gtk_window_set_title ((GtkWindow*) dialog, title); g_free (title); // signal handler g_signal_connect (dialog, "response", G_CALLBACK (on_message_response), value); gtk_widget_show (dialog); } void ug_app_window_close (UgAppGtk* app) { switch (app->setting.ui.close_action) { default: case 1: // Minimize to tray. #ifndef HAVE_APP_INDICATOR // This may cause Ubuntu Unity crash gtk_window_iconify (app->window.self); #endif gtk_widget_hide ((GtkWidget*) app->window.self); ug_app_trayicon_decide_visible (app); break; case 2: // Exit. ug_app_quit (app); break; } } void ug_app_trayicon_decide_visible (UgAppGtk* app) { gboolean visible; if (app->setting.ui.show_trayicon) visible = TRUE; else { if (gtk_widget_get_visible ((GtkWidget*) app->window.self)) visible = FALSE; else visible = TRUE; } ug_trayicon_set_visible (&app->trayicon, visible); } // this function used by ug_app_menubar_sync_category() static void on_move_download (GtkWidget* widget, UgAppGtk* app) { GPtrArray* array; UgDownloadWidget* dwidget; UgCategory* category; GList* list; GList* link; guint index; array = app->menubar.download.move_to.array; category = NULL; for (index = 0; index < array->len; index += 2) { if (widget == g_ptr_array_index (array, index)) { category = g_ptr_array_index (array, index + 1); break; } } if (category == NULL || category == app->cwidget.current.category) return; list = ug_download_widget_get_selected (app->cwidget.current.widget); for (link = list; link; link = link->next) ug_category_gtk_move_to (app->cwidget.current.category, link->data, category); g_list_free (list); // refresh dwidget = app->cwidget.current.widget; gtk_widget_queue_draw (app->cwidget.self); gtk_widget_queue_draw (GTK_WIDGET (dwidget->view)); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } void ug_app_menubar_sync_category (UgAppGtk* app, gboolean reset) { UgCategory* category; GtkWidget* menu_item; GtkWidget* image; GPtrArray* array; GtkTreeModel* model; GtkTreeIter iter; gboolean valid; guint index; array = app->menubar.download.move_to.array; model = GTK_TREE_MODEL (app->cwidget.store); if (reset) { // remove all item for (index = 0; index < array->len; index += 2) { menu_item = g_ptr_array_index (array, index); gtk_container_remove ((GtkContainer*) app->menubar.download.move_to.self, menu_item); } g_ptr_array_set_size (array, 0); // add new item valid = gtk_tree_model_get_iter_first (model, &iter); for (index = 0; valid; index += 2) { gtk_tree_model_get (model, &iter, 0, &category, -1); valid = gtk_tree_model_iter_next (model, &iter); // create menu item menu_item = gtk_image_menu_item_new_with_label (category->name); image = gtk_image_new_from_stock (UG_APP_GTK_CATEGORY_STOCK, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*) menu_item, image); gtk_menu_shell_append (GTK_MENU_SHELL (app->menubar.download.move_to.self), menu_item); g_signal_connect (menu_item, "activate", G_CALLBACK (on_move_download), app); gtk_widget_show (menu_item); g_ptr_array_add (array, menu_item); g_ptr_array_add (array, category); } } // set sensitive for (index = 0; index < array->len; index += 2) { menu_item = g_ptr_array_index (array, index); category = g_ptr_array_index (array, index +1); if (category == app->cwidget.current.category) gtk_widget_set_sensitive (menu_item, FALSE); else gtk_widget_set_sensitive (menu_item, TRUE); } } void ug_app_reset_download_column (UgAppGtk* app) { struct UgDownloadColumnSetting* setting; GtkTreeViewColumn* column; UgDownloadWidget* dwidget; UgCategoryGtk* cgtk; gboolean sensitive; // ---------------------------------------------------- // set UgViewMenu sensitive cgtk = app->cwidget.current.cgtk; dwidget = app->cwidget.current.widget; // Finished if (dwidget == &cgtk->finished) sensitive = FALSE; else sensitive = TRUE; gtk_widget_set_sensitive (app->menubar.view.columns.completed, sensitive); gtk_widget_set_sensitive (app->menubar.view.columns.percent, sensitive); // Recycled if (dwidget == &cgtk->recycled) sensitive = FALSE; else sensitive = TRUE; gtk_widget_set_sensitive (app->menubar.view.columns.elapsed, sensitive); // Finished & Recycled if (dwidget == &cgtk->finished || dwidget == &cgtk->recycled) sensitive = FALSE; else sensitive = TRUE; gtk_widget_set_sensitive (app->menubar.view.columns.left, sensitive); gtk_widget_set_sensitive (app->menubar.view.columns.speed, sensitive); gtk_widget_set_sensitive (app->menubar.view.columns.upload_speed, sensitive); gtk_widget_set_sensitive (app->menubar.view.columns.uploaded, sensitive); gtk_widget_set_sensitive (app->menubar.view.columns.ratio, sensitive); // ---------------------------------------------------- // set download column visible setting = &app->setting.download_column; // changed_count set in on_change_visible_column() if (dwidget->changed_count != setting->changed_count) { dwidget->changed_count = setting->changed_count; if (dwidget != &cgtk->finished) { column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_COMPLETE); gtk_tree_view_column_set_visible (column, setting->completed); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_PERCENT); gtk_tree_view_column_set_visible (column, setting->percent); } if (dwidget != &cgtk->recycled) { column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_ELAPSED); gtk_tree_view_column_set_visible (column, setting->elapsed); } if (dwidget != &cgtk->finished && dwidget != &cgtk->recycled) { column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_LEFT); gtk_tree_view_column_set_visible (column, setting->left); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_SPEED); gtk_tree_view_column_set_visible (column, setting->speed); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_UPLOAD_SPEED); gtk_tree_view_column_set_visible (column, setting->upload_speed); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_UPLOADED); gtk_tree_view_column_set_visible (column, setting->uploaded); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_RATIO); gtk_tree_view_column_set_visible (column, setting->ratio); } column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_SIZE); gtk_tree_view_column_set_visible (column, setting->total); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_RETRY); gtk_tree_view_column_set_visible (column, setting->retry); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_CATEGORY); gtk_tree_view_column_set_visible (column, setting->category); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_URL); gtk_tree_view_column_set_visible (column, setting->url); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_ADDED_ON); gtk_tree_view_column_set_visible (column, setting->added_on); column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_COMPLETED_ON); gtk_tree_view_column_set_visible (column, setting->completed_on); } } void ug_app_decide_download_sensitive (UgAppGtk* app) { UgDownloadWidget* dwidget; UgCategoryGtk* cgtk; gboolean sensitive = FALSE; static gboolean last_sensitive = TRUE; cgtk = app->cwidget.current.cgtk; dwidget = app->cwidget.current.widget; if (ug_download_widget_count_selected (dwidget) > 0) sensitive = TRUE; // change sensitive after select/unselect if (last_sensitive != sensitive) { last_sensitive = sensitive; gtk_widget_set_sensitive (app->toolbar.runnable, sensitive); gtk_widget_set_sensitive (app->toolbar.pause, sensitive); gtk_widget_set_sensitive (app->toolbar.properties, sensitive); gtk_widget_set_sensitive (app->menubar.download.open, sensitive); gtk_widget_set_sensitive (app->menubar.download.open_folder, sensitive); gtk_widget_set_sensitive (app->menubar.download.delete, sensitive); gtk_widget_set_sensitive (app->menubar.download.delete_file, sensitive); gtk_widget_set_sensitive (app->menubar.download.force_start, sensitive); gtk_widget_set_sensitive (app->menubar.download.runnable, sensitive); gtk_widget_set_sensitive (app->menubar.download.pause, sensitive); gtk_widget_set_sensitive (app->menubar.download.move_to.item, sensitive); gtk_widget_set_sensitive (app->menubar.download.properties, sensitive); } // Move Up/Down/Top/Bottom functions need reset sensitive when selection changed. // These need by on_move_download_xxx() series. if (dwidget == &cgtk->all || dwidget == &cgtk->active) sensitive = FALSE; gtk_widget_set_sensitive (app->toolbar.move_up, sensitive); gtk_widget_set_sensitive (app->toolbar.move_down, sensitive); gtk_widget_set_sensitive (app->toolbar.move_top, sensitive); gtk_widget_set_sensitive (app->toolbar.move_bottom, sensitive); gtk_widget_set_sensitive (app->menubar.download.move_up, sensitive); gtk_widget_set_sensitive (app->menubar.download.move_down, sensitive); gtk_widget_set_sensitive (app->menubar.download.move_top, sensitive); gtk_widget_set_sensitive (app->menubar.download.move_bottom, sensitive); } void ug_app_decide_category_sensitive (UgAppGtk* app) { static gboolean last_sensitive = TRUE; gboolean sensitive; if (app->cwidget.current.category) sensitive = TRUE; else sensitive = FALSE; if (last_sensitive != sensitive) { last_sensitive = sensitive; gtk_widget_set_sensitive (app->menubar.category.properties, sensitive); gtk_widget_set_sensitive (app->menubar.view.columns.self, sensitive); } if (app->cwidget.current.category == app->cwidget.primary.category) { gtk_widget_set_sensitive (app->menubar.category.delete, FALSE); gtk_widget_set_sensitive (app->menubar.category.properties, FALSE); } else { gtk_widget_set_sensitive (app->menubar.category.delete, sensitive); gtk_widget_set_sensitive (app->menubar.category.properties, sensitive); } ug_app_decide_download_sensitive (app); } void ug_app_decide_bt_meta_sensitive (UgAppGtk* app) { gboolean sensitive; sensitive = app->setting.plugin.aria2.enable; gtk_widget_set_sensitive (app->trayicon.menu.create_metalink, sensitive); gtk_widget_set_sensitive (app->trayicon.menu.create_torrent, sensitive); gtk_widget_set_sensitive (app->toolbar.create_metalink, sensitive); gtk_widget_set_sensitive (app->toolbar.create_torrent, sensitive); gtk_widget_set_sensitive (app->menubar.file.create.metalink, sensitive); gtk_widget_set_sensitive (app->menubar.file.create.torrent, sensitive); } uget-1.10.4/uget-gtk/UgSetting.c0000664000175000017500000005262712260761064013310 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include static void ug_string_list_in_markup (GList** string_list, GMarkupParseContext* context); static void ug_string_list_to_markup (GList** string_list, UgMarkup* markup); static void ug_schedule_state_in_markup (guint (*state)[7][24], GMarkupParseContext* context); static void ug_schedule_state_to_markup (guint (*state)[7][24], UgMarkup* markup); // ---------------------------------------------------------------------------- // UgDownloadColumnSetting static const UgDataEntry ug_download_column_setting_entry[] = { {"completed", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, completed), UG_TYPE_INT, NULL, NULL}, {"total", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, total), UG_TYPE_INT, NULL, NULL}, {"percent", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, percent), UG_TYPE_INT, NULL, NULL}, {"elapsed", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, elapsed), UG_TYPE_INT, NULL, NULL}, {"left", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, left), UG_TYPE_INT, NULL, NULL}, {"speed", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, speed), UG_TYPE_INT, NULL, NULL}, {"UploadSpeed", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, upload_speed), UG_TYPE_INT, NULL, NULL}, {"uploaded", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, uploaded), UG_TYPE_INT, NULL, NULL}, {"ratio", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, ratio), UG_TYPE_INT, NULL, NULL}, {"retry", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, retry), UG_TYPE_INT, NULL, NULL}, {"category", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, category), UG_TYPE_INT, NULL, NULL}, {"URL", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, url), UG_TYPE_INT, NULL, NULL}, {"AddedOn", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, added_on), UG_TYPE_INT, NULL, NULL}, {"CompletedOn", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, completed_on), UG_TYPE_INT, NULL, NULL}, {"sort-nth", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, sort.nth), UG_TYPE_INT, NULL, NULL}, {"sort-order", G_STRUCT_OFFSET (struct UgDownloadColumnSetting, sort.order), UG_TYPE_INT, NULL, NULL}, {NULL} // null-terminated }; static const UgDataInterface ug_download_column_setting_iface = { sizeof (struct UgDownloadColumnSetting), "DownloadColumnSetting", ug_download_column_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // UgSummarySetting static const UgDataEntry ug_summary_setting_entry[] = { {"name", G_STRUCT_OFFSET (struct UgSummarySetting, name), UG_TYPE_INT, NULL, NULL}, {"folder", G_STRUCT_OFFSET (struct UgSummarySetting, folder), UG_TYPE_INT, NULL, NULL}, {"category", G_STRUCT_OFFSET (struct UgSummarySetting, category), UG_TYPE_INT, NULL, NULL}, {"URL", G_STRUCT_OFFSET (struct UgSummarySetting, url), UG_TYPE_INT, NULL, NULL}, {"message", G_STRUCT_OFFSET (struct UgSummarySetting, message), UG_TYPE_INT, NULL, NULL}, {NULL} // null-terminated }; static const UgDataInterface ug_summary_setting_iface = { sizeof (struct UgSummarySetting), "SummarySetting", ug_summary_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // UgWindowSetting static const UgDataEntry ug_window_setting_entry[] = { {"Toolbar", G_STRUCT_OFFSET (struct UgWindowSetting, toolbar), UG_TYPE_INT, NULL, NULL}, {"Statusbar", G_STRUCT_OFFSET (struct UgWindowSetting, statusbar), UG_TYPE_INT, NULL, NULL}, {"Category", G_STRUCT_OFFSET (struct UgWindowSetting, category), UG_TYPE_INT, NULL, NULL}, {"Summary", G_STRUCT_OFFSET (struct UgWindowSetting, summary), UG_TYPE_INT, NULL, NULL}, {"Banner", G_STRUCT_OFFSET (struct UgWindowSetting, banner), UG_TYPE_INT, NULL, NULL}, {"x", G_STRUCT_OFFSET (struct UgWindowSetting, x) , UG_TYPE_INT, NULL, NULL}, {"y", G_STRUCT_OFFSET (struct UgWindowSetting, y), UG_TYPE_INT, NULL, NULL}, {"width", G_STRUCT_OFFSET (struct UgWindowSetting, width), UG_TYPE_INT, NULL, NULL}, {"height", G_STRUCT_OFFSET (struct UgWindowSetting, height), UG_TYPE_INT, NULL, NULL}, {"maximized", G_STRUCT_OFFSET (struct UgWindowSetting, maximized), UG_TYPE_INT, NULL, NULL}, {NULL}, // null-terminated }; static const UgDataInterface ug_window_setting_iface = { sizeof (struct UgWindowSetting), "WindowSetting", ug_window_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // UgUserInterfaceSetting static const UgDataEntry ug_user_interface_setting_entry[] = { {"CloseConfirmation", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, close_confirmation), UG_TYPE_INT, NULL, NULL}, {"CloseAction", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, close_action), UG_TYPE_INT, NULL, NULL}, {"DeleteConfirmation", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, delete_confirmation), UG_TYPE_INT, NULL, NULL}, {"ShowTrayIcon", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, show_trayicon), UG_TYPE_INT, NULL, NULL}, {"StartInTray", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, start_in_tray), UG_TYPE_INT, NULL, NULL}, {"StartInOfflineMode", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, start_in_offline_mode), UG_TYPE_INT, NULL, NULL}, {"StartNotification", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, start_notification), UG_TYPE_INT, NULL, NULL}, {"SoundNotification", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, sound_notification), UG_TYPE_INT, NULL, NULL}, {"ApplyRecently", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, apply_recently), UG_TYPE_INT, NULL, NULL}, #ifdef HAVE_APP_INDICATOR {"AppIndicator", G_STRUCT_OFFSET (struct UgUserInterfaceSetting, app_indicator), UG_TYPE_INT, NULL, NULL}, #endif {NULL}, // null-terminated }; static const UgDataInterface ug_user_interface_setting_iface = { sizeof (struct UgUserInterfaceSetting), "UserInterfaceSetting", ug_user_interface_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // UgClipboardSetting static const UgDataEntry ug_clipboard_setting_entry[] = { {"pattern", G_STRUCT_OFFSET (struct UgClipboardSetting, pattern), UG_TYPE_STRING, NULL, NULL}, {"monitor", G_STRUCT_OFFSET (struct UgClipboardSetting, monitor), UG_TYPE_INT, NULL, NULL}, {"quiet", G_STRUCT_OFFSET (struct UgClipboardSetting, quiet), UG_TYPE_INT, NULL, NULL}, {"NthCategory", G_STRUCT_OFFSET (struct UgClipboardSetting, nth_category), UG_TYPE_INT, NULL, NULL}, {NULL}, // null-terminated }; static const UgDataInterface ug_clipboard_setting_iface = { sizeof (struct UgClipboardSetting), "ClipboardSetting", ug_clipboard_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // UgSpeedLimitSetting static const UgDataEntry ug_speed_limit_setting_entry[] = { {"NormalUpload", G_STRUCT_OFFSET (struct UgSpeedLimitSetting, normal.upload), UG_TYPE_UINT, NULL, NULL}, {"NormalDownload", G_STRUCT_OFFSET (struct UgSpeedLimitSetting, normal.download), UG_TYPE_UINT, NULL, NULL}, {"SchedulerUpload", G_STRUCT_OFFSET (struct UgSpeedLimitSetting, scheduler.upload), UG_TYPE_UINT, NULL, NULL}, {"SchedulerDownload", G_STRUCT_OFFSET (struct UgSpeedLimitSetting, scheduler.download), UG_TYPE_UINT, NULL, NULL}, {NULL}, // null-terminated }; static const UgDataInterface ug_speed_limit_setting_iface = { sizeof (struct UgSpeedLimitSetting), "SpeedLimitSetting", ug_speed_limit_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // SchedulerSetting static const UgDataEntry ug_scheduler_setting_entry[] = { {"enable", G_STRUCT_OFFSET (struct UgSchedulerSetting, enable), UG_TYPE_INT, NULL, NULL}, {"state", G_STRUCT_OFFSET (struct UgSchedulerSetting, state), UG_TYPE_CUSTOM, ug_schedule_state_in_markup, ug_schedule_state_to_markup}, {NULL}, // null-terminated }; static const UgDataInterface ug_scheduler_setting_iface = { sizeof (struct UgSchedulerSetting), "SchedulerSetting", ug_scheduler_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // PluginSetting static const UgDataEntry ug_plugin_setting_entry[] = { {"aria2-enable", G_STRUCT_OFFSET (struct UgPluginSetting, aria2.enable), UG_TYPE_INT, NULL, NULL}, {"aria2-launch", G_STRUCT_OFFSET (struct UgPluginSetting, aria2.launch), UG_TYPE_INT, NULL, NULL}, {"aria2-shutdown", G_STRUCT_OFFSET (struct UgPluginSetting, aria2.shutdown), UG_TYPE_INT, NULL, NULL}, {"aria2-path", G_STRUCT_OFFSET (struct UgPluginSetting, aria2.path), UG_TYPE_STRING, NULL, NULL}, {"aria2-args", G_STRUCT_OFFSET (struct UgPluginSetting, aria2.args), UG_TYPE_STRING, NULL, NULL}, {"aria2-uri", G_STRUCT_OFFSET (struct UgPluginSetting, aria2.uri), UG_TYPE_STRING, NULL, NULL}, {NULL}, // null-terminated }; static const UgDataInterface ug_plugin_setting_iface = { sizeof (struct UgPluginSetting), "PluginSetting", ug_plugin_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // CommandlineSetting static const UgDataEntry ug_commandline_setting_entry[] = { {"quiet", G_STRUCT_OFFSET (struct UgCommandlineSetting, quiet), UG_TYPE_INT, NULL, NULL}, {"CategoryIndex", G_STRUCT_OFFSET (struct UgCommandlineSetting, category_index), UG_TYPE_INT, NULL, NULL}, {NULL}, // null-terminated }; static const UgDataInterface ug_commandline_setting_iface = { sizeof (struct UgCommandlineSetting), "CommandlineSetting", ug_commandline_setting_entry, NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // UgSetting static const UgDataEntry uget_setting_data_entry[] = { {"LaunchApp", G_STRUCT_OFFSET (UgSetting, launch.active), UG_TYPE_INT, NULL, NULL}, {"LaunchAppTypes", G_STRUCT_OFFSET (UgSetting, launch.types), UG_TYPE_STRING, NULL, NULL}, {"AutoSave", G_STRUCT_OFFSET (UgSetting, auto_save.active), UG_TYPE_INT, NULL, NULL}, {"AutoSaveInterval",G_STRUCT_OFFSET (UgSetting, auto_save.interval),UG_TYPE_INT, NULL, NULL}, {"DownloadColumn", G_STRUCT_OFFSET (UgSetting, download_column), UG_TYPE_STATIC, NULL, NULL}, {"Summary", G_STRUCT_OFFSET (UgSetting, summary), UG_TYPE_STATIC, NULL, NULL}, {"Window", G_STRUCT_OFFSET (UgSetting, window), UG_TYPE_STATIC, NULL, NULL}, {"UserInterface", G_STRUCT_OFFSET (UgSetting, ui), UG_TYPE_STATIC, NULL, NULL}, {"Clipboard", G_STRUCT_OFFSET (UgSetting, clipboard), UG_TYPE_STATIC, NULL, NULL}, {"SpeedLimit", G_STRUCT_OFFSET (UgSetting, speed_limit), UG_TYPE_STATIC, NULL, NULL}, {"Scheduler", G_STRUCT_OFFSET (UgSetting, scheduler), UG_TYPE_STATIC, NULL, NULL}, {"Commandline", G_STRUCT_OFFSET (UgSetting, commandline), UG_TYPE_STATIC, NULL, NULL}, {"Plug-in", G_STRUCT_OFFSET (UgSetting, plugin), UG_TYPE_STATIC, NULL, NULL}, // {"OfflineMode", G_STRUCT_OFFSET (UgSetting, offline_mode), UG_TYPE_INT, NULL, NULL}, // {"Shutdown", G_STRUCT_OFFSET (UgSetting, shutdown), UG_TYPE_INT, NULL, NULL}, {"FolderList", G_STRUCT_OFFSET (UgSetting, folder_list), UG_TYPE_CUSTOM, ug_string_list_in_markup, ug_string_list_to_markup}, {NULL}, // null-terminated }; static const UgDataInterface uget_setting_iface = { sizeof (UgSetting), // instance_size "UgSetting", // name uget_setting_data_entry, // entry NULL, NULL, NULL, }; // ---------------------------------------------------------------------------- // "FolderList" UgMarkup functions // static void ug_string_list_start_element (GMarkupParseContext* context, const gchar* element_name, const gchar** attr_names, const gchar** attr_values, GList** string_list, GError** error) { guint index; for (index=0; attr_names[index]; index++) { if (strcmp (attr_names[index], "value") == 0) *string_list = g_list_prepend (*string_list, g_strdup (attr_values[index])); } // skip end_element() one times. g_markup_parse_context_push (context, &ug_markup_skip_parser, NULL); } // GList** user_data static GMarkupParser ug_string_list_parser = { (gpointer) ug_string_list_start_element, (gpointer) g_markup_parse_context_pop, NULL, NULL, NULL }; static void ug_string_list_in_markup (GList** string_list, GMarkupParseContext* context) { g_markup_parse_context_push (context, &ug_string_list_parser, string_list); } static void ug_string_list_to_markup (GList** string_list, UgMarkup* markup) { GList* link; for (link = g_list_last (*string_list); link; link = link->prev) { ug_markup_write_element_start (markup, "string value='%s'", link->data); ug_markup_write_element_end (markup, "string"); } } // ---------------------------------------------------------------------------- // "UgSchedulerSetting" UgMarkup functions // void ug_schedule_state_text (GMarkupParseContext *context, const gchar *text, gsize text_len, guint (*state)[7][24], GError **error) { guint weekdays, dayhours; for (weekdays = 0; weekdays < 7; weekdays++) { for (dayhours = 0; dayhours < 24; dayhours++) { (*state)[weekdays][dayhours] = atoi (text); text = strchr (text, ','); if (text) text++; } } } // guint (*state)[7][24] static GMarkupParser ug_schedule_state_parser = { (gpointer) NULL, (gpointer) g_markup_parse_context_pop, (gpointer) ug_schedule_state_text, NULL, NULL }; static void ug_schedule_state_in_markup (guint (*state)[7][24], GMarkupParseContext* context) { g_markup_parse_context_push (context, &ug_schedule_state_parser, state); } static void ug_schedule_state_to_markup (guint (*state)[7][24], UgMarkup* markup) { guint weekdays, dayhours; GString* gstr; gstr = g_string_sized_new (2 * 7 * 24 + 1); for (weekdays = 0; weekdays < 7; weekdays++) { for (dayhours = 0; dayhours < 24; dayhours++) { g_string_append_printf (gstr, "%u,", (*state)[weekdays][dayhours]); } } ug_markup_write_text (markup, gstr->str, gstr->len); g_string_free (gstr, TRUE); } // ---------------------------------------------------------------------------- // "UgSetting" UgMarkup functions // static void uget_setting_start_element (GMarkupParseContext* context, const gchar* element_name, const gchar** attr_names, const gchar** attr_values, UgSetting* setting, GError** error) { guint index; // if (strcmp (element_name, "UgSetting") != 0) { // g_set_error (error, G_MARKUP_ERROR, // G_MARKUP_ERROR_UNKNOWN_ELEMENT, "Unknown element"); // return; // } for (index=0; attr_names[index]; index++) { if (strcmp (attr_names[index], "version") != 0) continue; if (strcmp (attr_values[index], "1") == 0) { g_markup_parse_context_push (context, &ug_data_parser, setting); return; } } g_set_error (error, G_MARKUP_ERROR, G_MARKUP_ERROR_UNKNOWN_ELEMENT, "Unknown element"); } // UgSetting* user_data static GMarkupParser ug_setting_parser = { (gpointer) uget_setting_start_element, (gpointer) g_markup_parse_context_pop, NULL, NULL, NULL }; // ---------------------------------------------------------------------------- // "UgSetting" functions // void ug_setting_init (UgSetting* setting) { guint weekdays, dayhours; setting->iface = &uget_setting_iface; // "SummarySetting" setting->summary.iface = &ug_summary_setting_iface; setting->summary.name = TRUE; setting->summary.folder = TRUE; setting->summary.category = FALSE; setting->summary.url = FALSE; setting->summary.message = TRUE; // "DownloadColumnSetting" setting->download_column.iface = &ug_download_column_setting_iface; setting->download_column.changed_count = 1; setting->download_column.completed = TRUE; setting->download_column.total = TRUE; setting->download_column.percent = TRUE; setting->download_column.elapsed = TRUE; setting->download_column.left = TRUE; setting->download_column.speed = TRUE; setting->download_column.upload_speed = TRUE; setting->download_column.uploaded = FALSE; setting->download_column.ratio = TRUE; setting->download_column.retry = TRUE; setting->download_column.category = FALSE; setting->download_column.url = FALSE; setting->download_column.added_on = TRUE; setting->download_column.completed_on = FALSE; // default sorted column setting->download_column.sort.nth = UG_DOWNLOAD_COLUMN_ADDED_ON; setting->download_column.sort.order = GTK_SORT_DESCENDING; // "WindowSetting" setting->window.iface = &ug_window_setting_iface; setting->window.toolbar = TRUE; setting->window.statusbar = TRUE; setting->window.category = TRUE; setting->window.summary = TRUE; setting->window.banner = TRUE; setting->window.x = 0; setting->window.y = 0; setting->window.width = 0; setting->window.height = 0; setting->window.maximized = FALSE; // "UserInterfaceSetting" setting->ui.iface = &ug_user_interface_setting_iface; setting->ui.close_confirmation = TRUE; setting->ui.close_action = 0; setting->ui.delete_confirmation = TRUE; setting->ui.show_trayicon = TRUE; setting->ui.start_in_tray = FALSE; setting->ui.start_in_offline_mode = FALSE; setting->ui.start_notification = TRUE; setting->ui.sound_notification = TRUE; setting->ui.apply_recently = TRUE; #ifdef HAVE_APP_INDICATOR setting->ui.app_indicator = TRUE; #endif // "ClipboardSetting" setting->clipboard.iface = &ug_clipboard_setting_iface; g_free (setting->clipboard.pattern); setting->clipboard.pattern = g_strdup (UG_APP_GTK_CLIPBOARD_PATTERN); setting->clipboard.monitor = TRUE; setting->clipboard.quiet = FALSE; setting->clipboard.nth_category = 0; // "SpeedLimitSetting" setting->speed_limit.iface = &ug_speed_limit_setting_iface; setting->speed_limit.normal.upload = 0; setting->speed_limit.normal.download = 0; setting->speed_limit.scheduler.upload = 0; setting->speed_limit.scheduler.download = 0; // "SchedulerSetting" setting->scheduler.iface = &ug_scheduler_setting_iface; setting->scheduler.enable = FALSE; for (weekdays = 0; weekdays < 7; weekdays++) { for (dayhours = 0; dayhours < 24; dayhours++) setting->scheduler.state[weekdays][dayhours] = UG_SCHEDULE_NORMAL; } // "CommandlineSetting" setting->commandline.iface = &ug_commandline_setting_iface; setting->commandline.quiet = FALSE; setting->commandline.category_index = -1; // "PluginSetting" setting->plugin.iface = &ug_plugin_setting_iface; setting->plugin.aria2.enable = FALSE; setting->plugin.aria2.launch = TRUE; setting->plugin.aria2.shutdown = TRUE; setting->plugin.aria2.path = g_strdup ("aria2c"); setting->plugin.aria2.args = g_strdup ("--enable-rpc=true -D --check-certificate=false"); setting->plugin.aria2.uri = g_strdup ("http://localhost:6800/rpc"); // "FolderList" setting->folder_list = NULL; // Others setting->offline_mode = FALSE; setting->shutdown = 0; setting->launch.active = TRUE; setting->launch.types = g_strdup (UG_APP_GTK_LAUNCH_APP_TYPES); setting->auto_save.active = TRUE; setting->auto_save.interval = 3; } gboolean ug_setting_save (UgSetting* setting, const gchar* file) { UgMarkup* markup; markup = ug_markup_new (); if (ug_markup_write_start (markup, file, TRUE)) { ug_markup_write_element_start (markup, "UgSetting version='1'"); ug_data_write_markup ((UgData*) setting, markup); ug_markup_write_element_end (markup, "UgSetting"); ug_markup_write_end (markup); return TRUE; } return FALSE; } gboolean ug_setting_load (UgSetting* setting, const gchar* file) { return ug_markup_parse (file, &ug_setting_parser, setting); } uget-1.10.4/uget-gtk/UgSetting.h0000664000175000017500000001371512260761064013310 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_SETTING_H #define UG_SETTING_H #ifdef HAVE_CONFIG_H #include #endif #ifndef PACKAGE_VERSION #define PACKAGE_VERSION "1.10.4" #endif #include #ifdef __cplusplus extern "C" { #endif #define UG_APP_GTK_NAME "uGet" #define UG_APP_GTK_VERSION PACKAGE_VERSION " (stable branch)" // default setting #define UG_APP_GTK_CLIPBOARD_PATTERN "BIN|ZIP|GZ|7Z|Z|TAR|TGZ|BZ2|LZH|A[0-9]?|RAR|R[0-9][0-9]|3GP|AAC|FLAC|M4A|M4P|MP3|OGG|WAV|WMA|MP4|OGV|MKV|AVI|MOV|WMV|FLV|F4V|MPG|MPEG|RMVB|RPM|DEB|EXE" #define UG_APP_GTK_LAUNCH_APP_TYPES "torrent" typedef struct UgSetting UgSetting; typedef enum UgScheduleState UgScheduleState; enum UgScheduleState { UG_SCHEDULE_TURN_OFF, UG_SCHEDULE_UPLOAD_ONLY, // reserve UG_SCHEDULE_LIMITED_SPEED, UG_SCHEDULE_NORMAL, UG_SCHEDULE_N_STATE, }; // struct UgSetting { const UgDataInterface* iface; // for UgMarkup parse/write // "DownloadColumnSetting" struct UgDownloadColumnSetting { const UgDataInterface* iface; // for UgMarkup parse/write guint changed_count; // sync with UgDownloadWidget.changed_count gboolean completed; gboolean total; gboolean percent; gboolean elapsed; // consuming time gboolean left; // remaining time gboolean speed; gboolean upload_speed; gboolean uploaded; gboolean ratio; gboolean retry; gboolean category; gboolean url; gboolean added_on; gboolean completed_on; struct { gint nth; gint order; // sort order } sort; } download_column; // "SummarySetting" struct UgSummarySetting { const UgDataInterface* iface; // for UgMarkup parse/write gboolean name; gboolean folder; gboolean category; gboolean url; gboolean message; } summary; // "WindowSetting" struct UgWindowSetting { const UgDataInterface* iface; // for UgMarkup parse/write // visible gboolean toolbar; gboolean statusbar; gboolean category; gboolean summary; gboolean banner; gint x; // window position gint y; gint width; gint height; gboolean maximized; } window; struct UgUserInterfaceSetting { const UgDataInterface* iface; // for UgMarkup parse/write // close_action == 0, Let user decide. // close_action == 1, Minimize to tray. // close_action == 2, Exit Uget. // close_confirmation == FALSE, Remember this action. // close_confirmation == TRUE, Always confirm. gboolean close_confirmation; gint close_action; gboolean delete_confirmation; gboolean show_trayicon; gboolean start_in_tray; gboolean start_in_offline_mode; gboolean start_notification; gboolean sound_notification; gboolean apply_recently; #ifdef HAVE_APP_INDICATOR gboolean app_indicator; #endif } ui; // "ClipboardSetting" struct UgClipboardSetting { const UgDataInterface* iface; // for UgMarkup parse/write gchar* pattern; gboolean monitor; gboolean quiet; gint nth_category; } clipboard; // "SpeedLimitSetting" - global speed limits struct UgSpeedLimitSetting { const UgDataInterface* iface; // for UgMarkup parse/write struct { guint upload; // KiB / second guint download; // KiB / second } normal; struct { guint upload; // KiB / second guint download; // KiB / second } scheduler; } speed_limit; // "SchedulerSetting" struct UgSchedulerSetting { const UgDataInterface* iface; // for UgMarkup parse/write gboolean enable; guint state[7][24]; // 1 week, 7 days, 24 hours } scheduler; // "CommandlineSetting" struct UgCommandlineSetting { const UgDataInterface* iface; // for UgMarkup parse/write gboolean quiet; // --quiet gint category_index; // --category-index } commandline; // "PluginSetting" struct UgPluginSetting { const UgDataInterface* iface; // for UgMarkup parse/write struct { gboolean enable; gboolean launch; gboolean shutdown; gchar* path; gchar* args; gchar* uri; } aria2; } plugin; gboolean offline_mode; guint shutdown; // shutdown when downloads complete // "FolderList" GList* folder_list; // Others struct UgLaunchSetting { gboolean active; gchar* types; } launch; struct UgAutoSave { gboolean active; guint interval; } auto_save; }; void ug_setting_init (UgSetting* setting); gboolean ug_setting_save (UgSetting* setting, const gchar* file); gboolean ug_setting_load (UgSetting* setting, const gchar* file); #ifdef __cplusplus } #endif #endif // End of UG_SETTING_H uget-1.10.4/uget-gtk/UgSettingForm.h0000664000175000017500000001230012260761064014121 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_SETTING_FORM_H #define UG_SETTING_FORM_H #include #include #ifdef __cplusplus extern "C" { #endif // ---------------------------------------------------------------------------- // UgClipboardSettingForm struct UgClipboardSettingForm { GtkWidget* self; GtkEntry* pattern; GtkToggleButton* monitor; GtkToggleButton* quiet; // add download to Nth category GtkWidget* nth_label; GtkSpinButton* nth_spin; }; void ug_clipboard_setting_form_init (struct UgClipboardSettingForm* csform); void ug_clipboard_setting_form_set (struct UgClipboardSettingForm* csform, UgSetting* setting); void ug_clipboard_setting_form_get (struct UgClipboardSettingForm* csform, UgSetting* setting); // ---------------------------------------------------------------------------- // UgUserInterfaceForm struct UgUserInterfaceForm { GtkWidget* self; GtkToggleButton* confirm_close; GtkToggleButton* confirm_delete; GtkToggleButton* show_trayicon; GtkToggleButton* start_in_tray; GtkToggleButton* start_in_offline_mode; GtkToggleButton* start_notification; GtkToggleButton* sound_notification; GtkToggleButton* apply_recently; }; void ug_user_interface_form_init (struct UgUserInterfaceForm* uiform); void ug_user_interface_form_set (struct UgUserInterfaceForm* uiform, UgSetting* setting); void ug_user_interface_form_get (struct UgUserInterfaceForm* uiform, UgSetting* setting); // ---------------------------------------------------------------------------- // UgLaunchSettingForm struct UgLaunchSettingForm { GtkWidget* self; GtkToggleButton* active; GtkEntry* types; }; void ug_launch_setting_form_init (struct UgLaunchSettingForm* lsform); void ug_launch_setting_form_set (struct UgLaunchSettingForm* lsform, UgSetting* setting); void ug_launch_setting_form_get (struct UgLaunchSettingForm* lsform, UgSetting* setting); // ---------------------------------------------------------------------------- // UgAutoSaveForm struct UgAutoSaveForm { GtkWidget* self; // auto save and interval GtkToggleButton* active; GtkWidget* interval_label; GtkSpinButton* interval_spin; GtkWidget* minutes_label; // minutes }; void ug_auto_save_form_init (struct UgAutoSaveForm* asform); void ug_auto_save_form_set (struct UgAutoSaveForm* asform, UgSetting* setting); void ug_auto_save_form_get (struct UgAutoSaveForm* asform, UgSetting* setting); // ---------------------------------------------------------------------------- // UgCommandlineSettingForm struct UgCommandlineSettingForm { GtkWidget* self; // --quiet GtkToggleButton* quiet; // --category-index GtkWidget* index_label; GtkSpinButton* index_spin; }; void ug_commandline_setting_form_init (struct UgCommandlineSettingForm* csform); void ug_commandline_setting_form_set (struct UgCommandlineSettingForm* csform, UgSetting* setting); void ug_commandline_setting_form_get (struct UgCommandlineSettingForm* csform, UgSetting* setting); // ---------------------------------------------------------------------------- // UgPluginSettingForm struct UgPluginSettingForm { GtkWidget* self; // auto save and interval GtkToggleButton* enable; GtkToggleButton* launch; GtkToggleButton* shutdown; GtkEntry* uri; GtkEntry* path; GtkEntry* args; GtkWidget* hint; // Speed Limits GtkSpinButton* upload; // KiB/s GtkSpinButton* download; // KiB/s }; void ug_plugin_setting_form_init (struct UgPluginSettingForm* psform); void ug_plugin_setting_form_set (struct UgPluginSettingForm* psform, UgSetting* setting); void ug_plugin_setting_form_get (struct UgPluginSettingForm* psform, UgSetting* setting); #ifdef __cplusplus } #endif #endif // End of UG_SETTING_FORM_H uget-1.10.4/uget-gtk/UgDownloadDialog.h0000664000175000017500000000655712260761064014570 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_DOWNLOAD_DIALOG_H #define UG_DOWNLOAD_DIALOG_H #include #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgDownloadDialog UgDownloadDialog; struct UgDownloadDialog { GtkDialog* self; GtkBox* hbox; GtkTreeView* category_view; GtkWidget* button_back; GtkWidget* button_forward; UgSelector selector; UgBatchForm batch; UgProxyForm proxy; UgDownloadForm download; struct UgDownloadDialogPage { gboolean completed[2]; GtkWidget* array[2]; GtkWidget* current; } page; // External data UgDataset* dataset; // Additional data struct { gpointer app; gpointer data; } user; }; UgDownloadDialog* ug_download_dialog_new (const gchar* title, GtkWindow* parent); void ug_download_dialog_free (UgDownloadDialog* ddialog); void ug_download_dialog_use_batch (UgDownloadDialog* ddialog); void ug_download_dialog_use_selector (UgDownloadDialog* ddialog); void ug_download_dialog_set_category (UgDownloadDialog* ddialog, UgCategoryWidget* cwidget); void ug_download_dialog_set_current_page (UgDownloadDialog* ddialog, gint nth_page); void ug_download_dialog_get (UgDownloadDialog* ddialog, UgDataset* dataset); // replace void ug_download_dialog_set (UgDownloadDialog* ddialog, UgDataset* dataset); // change widget value // return current UgCategoryGtk in cursor position. UgCategory* ug_download_dialog_get_category (UgDownloadDialog* ddialog); // return newly-created list of UgDataset. // To free the returned value, use: // g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); // g_list_free (list); GList* ug_download_dialog_get_downloads (UgDownloadDialog* ddialog); #ifdef __cplusplus } #endif #endif // End of UG_DOWNLOAD_DIALOG_H uget-1.10.4/uget-gtk/UgSettingForm.c0000664000175000017500000005256012260761064014130 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include // ---------------------------------------------------------------------------- // UgClipboardSettingForm // static void on_clipboard_monitor_toggled (GtkWidget* widget, struct UgClipboardSettingForm* csform) { gboolean sensitive; sensitive = gtk_toggle_button_get_active (csform->monitor); gtk_widget_set_sensitive ((GtkWidget*) csform->pattern, sensitive); } static void on_clipboard_quiet_mode_toggled (GtkWidget* widget, struct UgClipboardSettingForm* csform) { gboolean sensitive; sensitive = gtk_toggle_button_get_active (csform->quiet); gtk_widget_set_sensitive ((GtkWidget*) csform->nth_label, sensitive); gtk_widget_set_sensitive ((GtkWidget*) csform->nth_spin, sensitive); } void ug_clipboard_setting_form_init (struct UgClipboardSettingForm* csform) { GtkWidget* widget; GtkWidget* entry; GtkBox* vbox; GtkBox* hbox; csform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox = (GtkBox*) csform->self; // Monitor button widget = gtk_check_button_new_with_mnemonic ( _("_Monitor clipboard for specified file types:")); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); g_signal_connect (widget, "toggled", G_CALLBACK (on_clipboard_monitor_toggled), csform); csform->monitor = (GtkToggleButton*) widget; // file type pattern : entry entry = gtk_entry_new (); gtk_box_pack_start (vbox, entry, FALSE, FALSE, 2); csform->pattern = (GtkEntry*) entry; // tips hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); gtk_box_pack_end (hbox, gtk_label_new (_("Separate the types with character '|'.")), FALSE, FALSE, 2); hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); gtk_box_pack_end (hbox, gtk_label_new (_("You can use regular expressions here.")), FALSE, FALSE, 2); gtk_box_pack_start (vbox, gtk_label_new (""), FALSE, FALSE, 2); // quiet mode hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 2); widget = gtk_check_button_new_with_mnemonic (_("_Quiet mode")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 0); g_signal_connect (widget, "toggled", G_CALLBACK (on_clipboard_quiet_mode_toggled), csform); csform->quiet = (GtkToggleButton*) widget; // Nth category widget = gtk_spin_button_new_with_range (-1.0, 100.0, 1.0); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); csform->nth_spin = (GtkSpinButton*) widget; widget = gtk_label_new (_("Add URL to Nth category")); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); csform->nth_label = widget; } void ug_clipboard_setting_form_set (struct UgClipboardSettingForm* csform, UgSetting* setting) { if (setting->clipboard.pattern) gtk_entry_set_text (csform->pattern, setting->clipboard.pattern); gtk_toggle_button_set_active (csform->monitor, setting->clipboard.monitor); gtk_toggle_button_set_active (csform->quiet, setting->clipboard.quiet); gtk_spin_button_set_value (csform->nth_spin, setting->clipboard.nth_category); gtk_toggle_button_toggled (csform->monitor); gtk_toggle_button_toggled (csform->quiet); // on_clipboard_monitor_toggled ((GtkWidget*) csform->monitor, csform); // on_clipboard_quiet_mode_toggled ((GtkWidget*) csform->quiet, csform); } void ug_clipboard_setting_form_get (struct UgClipboardSettingForm* csform, UgSetting* setting) { g_free (setting->clipboard.pattern); setting->clipboard.pattern = g_strdup (gtk_entry_get_text (csform->pattern)); setting->clipboard.monitor = gtk_toggle_button_get_active (csform->monitor); setting->clipboard.quiet = gtk_toggle_button_get_active (csform->quiet); setting->clipboard.nth_category = gtk_spin_button_get_value_as_int (csform->nth_spin); } // ---------------------------------------------------------------------------- // UgUserInterfaceForm // void ug_user_interface_form_init (struct UgUserInterfaceForm* uiform) { GtkWidget* widget; GtkBox* vbox; uiform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox = (GtkBox*) uiform->self; // check button widget = gtk_check_button_new_with_label (_("Show confirmation dialog on close")); uiform->confirm_close = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Confirm when deleting files")); uiform->confirm_delete = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Always show tray icon")); uiform->show_trayicon = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Minimize to tray on startup")); uiform->start_in_tray = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Enable offline mode on startup")); uiform->start_in_offline_mode = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Download starting notification")); uiform->start_notification = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Sound when download is finished")); uiform->sound_notification = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); widget = gtk_check_button_new_with_label (_("Apply recently download settings")); uiform->apply_recently = (GtkToggleButton*) widget; gtk_box_pack_start (vbox, widget, FALSE, FALSE, 1); } void ug_user_interface_form_set (struct UgUserInterfaceForm* uiform, UgSetting* setting) { gtk_toggle_button_set_active (uiform->confirm_close, setting->ui.close_confirmation); gtk_toggle_button_set_active (uiform->confirm_delete, setting->ui.delete_confirmation); gtk_toggle_button_set_active (uiform->show_trayicon, setting->ui.show_trayicon); gtk_toggle_button_set_active (uiform->start_in_tray, setting->ui.start_in_tray); gtk_toggle_button_set_active (uiform->start_in_offline_mode, setting->ui.start_in_offline_mode); gtk_toggle_button_set_active (uiform->start_notification, setting->ui.start_notification); gtk_toggle_button_set_active (uiform->sound_notification, setting->ui.sound_notification); gtk_toggle_button_set_active (uiform->apply_recently, setting->ui.apply_recently); } void ug_user_interface_form_get (struct UgUserInterfaceForm* uiform, UgSetting* setting) { setting->ui.close_confirmation = gtk_toggle_button_get_active (uiform->confirm_close); setting->ui.delete_confirmation = gtk_toggle_button_get_active (uiform->confirm_delete); setting->ui.show_trayicon = gtk_toggle_button_get_active (uiform->show_trayicon); setting->ui.start_in_tray = gtk_toggle_button_get_active (uiform->start_in_tray); setting->ui.start_in_offline_mode = gtk_toggle_button_get_active (uiform->start_in_offline_mode); setting->ui.start_notification = gtk_toggle_button_get_active (uiform->start_notification); setting->ui.sound_notification = gtk_toggle_button_get_active (uiform->sound_notification); setting->ui.apply_recently = gtk_toggle_button_get_active (uiform->apply_recently); } // ---------------------------------------------------------------------------- // UgLaunchSettingForm // static void on_launch_app_toggled (GtkWidget* widget, struct UgLaunchSettingForm* lsform) { gboolean sensitive; sensitive = gtk_toggle_button_get_active (lsform->active); gtk_widget_set_sensitive ((GtkWidget*) lsform->types, sensitive); } void ug_launch_setting_form_init (struct UgLaunchSettingForm* lsform) { GtkWidget* widget; GtkWidget* entry; GtkBox* vbox; GtkBox* hbox; lsform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox = (GtkBox*) lsform->self; // active button hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); widget = gtk_check_button_new_with_mnemonic ( _("_Launch default application for specified file types:")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 0); g_signal_connect (widget, "toggled", G_CALLBACK (on_launch_app_toggled), lsform); lsform->active = (GtkToggleButton*) widget; // launch app entry entry = gtk_entry_new (); gtk_box_pack_start (vbox, entry, FALSE, FALSE, 2); lsform->types = (GtkEntry*) entry; // Launch app tips hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); gtk_box_pack_end (hbox, gtk_label_new (_("Separate the types with character '|'.")), FALSE, FALSE, 2); hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); gtk_box_pack_end (hbox, gtk_label_new (_("You can use regular expressions here.")), FALSE, FALSE, 2); } void ug_launch_setting_form_set (struct UgLaunchSettingForm* lsform, UgSetting* setting) { // launch app gtk_toggle_button_set_active (lsform->active, setting->launch.active); if (setting->launch.types) gtk_entry_set_text (lsform->types, setting->launch.types); gtk_toggle_button_toggled (lsform->active); // on_launch_app_toggled ((GtkWidget*) lsform->active, lsform); } void ug_launch_setting_form_get (struct UgLaunchSettingForm* lsform, UgSetting* setting) { setting->launch.active = gtk_toggle_button_get_active (lsform->active); g_free (setting->launch.types); setting->launch.types = g_strdup (gtk_entry_get_text (lsform->types)); } // ---------------------------------------------------------------------------- // UgAutoSaveForm // static void on_auto_save_toggled (GtkWidget* widget, struct UgAutoSaveForm* asform) { gboolean sensitive; sensitive = gtk_toggle_button_get_active (asform->active); gtk_widget_set_sensitive (asform->interval_label, sensitive); gtk_widget_set_sensitive ((GtkWidget*) asform->interval_spin, sensitive); gtk_widget_set_sensitive (asform->minutes_label, sensitive); } void ug_auto_save_form_init (struct UgAutoSaveForm* asform) { GtkBox* hbox; GtkWidget* widget; asform->self = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); hbox = (GtkBox*) asform->self; widget = gtk_check_button_new_with_mnemonic (_("_Auto save")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 0); g_signal_connect (widget, "toggled", G_CALLBACK (on_auto_save_toggled), asform); asform->active = (GtkToggleButton*) widget; // auto save spin & label (interval) widget = gtk_label_new_with_mnemonic (_("minutes")); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); asform->minutes_label = widget; widget = gtk_spin_button_new_with_range (1.0, 120.0, 1.0); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); asform->interval_spin = (GtkSpinButton*) widget; // auto save label widget = gtk_label_new_with_mnemonic (_("_Interval:")); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); asform->interval_label = widget; gtk_label_set_mnemonic_widget (GTK_LABEL (asform->interval_label), (GtkWidget*) asform->interval_spin); } void ug_auto_save_form_set (struct UgAutoSaveForm* asform, UgSetting* setting) { gtk_toggle_button_set_active (asform->active, setting->auto_save.active); gtk_spin_button_set_value (asform->interval_spin, (gdouble) setting->auto_save.interval); gtk_toggle_button_toggled (asform->active); // on_auto_save_toggled ((GtkWidget*) asform->active, asform); } void ug_auto_save_form_get (struct UgAutoSaveForm* asform, UgSetting* setting) { setting->auto_save.active = gtk_toggle_button_get_active (asform->active); setting->auto_save.interval = gtk_spin_button_get_value_as_int (asform->interval_spin); } // ---------------------------------------------------------------------------- // UgCommandlineSettingForm // void ug_commandline_setting_form_init (struct UgCommandlineSettingForm* csform) { GtkWidget* widget; GtkBox* vbox; GtkBox* hbox; csform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox = (GtkBox*) csform->self; // Commandline Settings hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 2); widget = gtk_label_new (_("Commandline Settings")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); gtk_box_pack_start (hbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 2); // --quiet widget = gtk_check_button_new_with_mnemonic (_("Use '--quiet' by default")); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 0); csform->quiet = (GtkToggleButton*) widget; // --category-index hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 2); widget = gtk_label_new (_("'--category-index' default value")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); csform->index_label = widget; widget = gtk_spin_button_new_with_range (-1.0, 100.0, 1.0); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); csform->index_spin = (GtkSpinButton*) widget; } void ug_commandline_setting_form_set (struct UgCommandlineSettingForm* csform, UgSetting* setting) { gtk_toggle_button_set_active (csform->quiet, setting->commandline.quiet); gtk_spin_button_set_value (csform->index_spin, setting->commandline.category_index); } void ug_commandline_setting_form_get (struct UgCommandlineSettingForm* csform, UgSetting* setting) { setting->commandline.quiet = gtk_toggle_button_get_active (csform->quiet); setting->commandline.category_index = gtk_spin_button_get_value_as_int (csform->index_spin); } // ---------------------------------------------------------------------------- // UgPluginSettingForm // static void on_plugin_aria2_toggled (GtkWidget* widget, struct UgPluginSettingForm* psform) { gboolean sensitive; sensitive = gtk_toggle_button_get_active (psform->enable); gtk_widget_set_sensitive ((GtkWidget*) psform->launch, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->shutdown, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->uri, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->upload, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->download, sensitive); if (sensitive) sensitive = gtk_toggle_button_get_active (psform->launch); gtk_widget_set_sensitive ((GtkWidget*) psform->path, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->args, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->hint, sensitive); } static void on_plugin_aria2_launch_toggled (GtkWidget* widget, struct UgPluginSettingForm* psform) { gboolean sensitive; sensitive = gtk_toggle_button_get_active (psform->launch); gtk_widget_set_sensitive ((GtkWidget*) psform->path, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->args, sensitive); gtk_widget_set_sensitive ((GtkWidget*) psform->hint, sensitive); } void ug_plugin_setting_form_init (struct UgPluginSettingForm* psform) { GtkBox* vbox; GtkBox* hbox; GtkWidget* widget; psform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox = (GtkBox*) psform->self; // Enable aria2 plug-in hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, TRUE, 2); widget = gtk_check_button_new_with_mnemonic (_("_Enable aria2 plug-in")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 0); gtk_box_pack_start (hbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 4); g_signal_connect (widget, "toggled", G_CALLBACK (on_plugin_aria2_toggled), psform); psform->enable = (GtkToggleButton*) widget; widget = gtk_check_button_new_with_mnemonic (_("_Launch aria2 on startup")); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 2); g_signal_connect (widget, "toggled", G_CALLBACK (on_plugin_aria2_launch_toggled), psform); psform->launch = (GtkToggleButton*) widget; widget = gtk_check_button_new_with_mnemonic (_("_Shutdown aria2 on exit")); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 2); psform->shutdown = (GtkToggleButton*) widget; // URI entry hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, TRUE, 2); widget = gtk_label_new ("URI"); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); widget = gtk_entry_new (); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 4); psform->uri = (GtkEntry*) widget; // Path hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, TRUE, 2); widget = gtk_label_new (_("Path")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); widget = gtk_entry_new (); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 4); psform->path = (GtkEntry*) widget; // Arguments hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, TRUE, 2); widget = gtk_label_new (_("Arguments")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); widget = gtk_entry_new (); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 4); psform->args = (GtkEntry*) widget; // aria2 plug-in hint widget = gtk_label_new (_("You must restart uGet after modifying 'Arguments'.")); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 2); psform->hint = widget; // Speed Limits hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, TRUE, 2); widget = gtk_label_new (_("Speed Limits")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); gtk_box_pack_start (hbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 2); // Upload hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 2); widget = gtk_label_new (_("Upload")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); widget = gtk_label_new (_("KiB/s")); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); widget = gtk_spin_button_new_with_range (0.0, 4000000000.0, 5.0); gtk_entry_set_width_chars (GTK_ENTRY (widget), 15); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); psform->upload = (GtkSpinButton*) widget; // Download hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 2); widget = gtk_label_new (_("Download")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); widget = gtk_label_new (_("KiB/s")); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); widget = gtk_spin_button_new_with_range (0.0, 4000000000.0, 5.0); gtk_entry_set_width_chars (GTK_ENTRY (widget), 15); gtk_box_pack_end (hbox, widget, FALSE, FALSE, 2); psform->download = (GtkSpinButton*) widget; gtk_widget_show (psform->self); } void ug_plugin_setting_form_set (struct UgPluginSettingForm* psform, UgSetting* setting) { gtk_toggle_button_set_active (psform->enable, setting->plugin.aria2.enable); gtk_toggle_button_set_active (psform->launch, setting->plugin.aria2.launch); gtk_toggle_button_set_active (psform->shutdown, setting->plugin.aria2.shutdown); gtk_entry_set_text (psform->uri, setting->plugin.aria2.uri); gtk_entry_set_text (psform->path, setting->plugin.aria2.path); gtk_entry_set_text (psform->args, setting->plugin.aria2.args); gtk_spin_button_set_value (psform->upload, setting->speed_limit.normal.upload); gtk_spin_button_set_value (psform->download, setting->speed_limit.normal.download); on_plugin_aria2_toggled ((GtkWidget*) psform->enable, psform); } void ug_plugin_setting_form_get (struct UgPluginSettingForm* psform, UgSetting* setting) { setting->plugin.aria2.enable = gtk_toggle_button_get_active (psform->enable); setting->plugin.aria2.launch = gtk_toggle_button_get_active (psform->launch); setting->plugin.aria2.shutdown = gtk_toggle_button_get_active (psform->shutdown); setting->plugin.aria2.uri = g_strdup (gtk_entry_get_text (psform->uri)); setting->plugin.aria2.path = g_strdup (gtk_entry_get_text (psform->path)); setting->plugin.aria2.args = g_strdup (gtk_entry_get_text (psform->args)); setting->speed_limit.normal.upload = (guint) gtk_spin_button_get_value (psform->upload); setting->speed_limit.normal.download = (guint) gtk_spin_button_get_value (psform->download); } uget-1.10.4/uget-gtk/UgApp-gtk-main.c0000664000175000017500000001573512260761064014117 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ // ---------------------------------------------------------------------------- #ifdef _WIN32 // This is for ATTACH_PARENT_PROCESS #ifndef _WIN32_WINNT #define _WIN32_WINNT 0x501 // WinXP #endif #define _CRT_SECURE_NO_WARNINGS 1 #include #include #include #include // ------------------------------------ // Windows functions static void win32_winsock_init (void) { WSADATA WSAData; WSAStartup (MAKEWORD (2, 2), &WSAData); } static void win32_winsock_finalize (void) { WSACleanup (); } #if defined (_WINDOWS) static void atexit_callback (void) { FreeConsole (); } static void win32_console_init (void) { typedef BOOL (CALLBACK* LPFNATTACHCONSOLE) (DWORD); LPFNATTACHCONSOLE AttachConsole; HMODULE hmod; // If stdout hasn't been redirected to a file, alloc a console // (_istty() doesn't work for stuff using the GUI subsystem) if (_fileno(stdout) == -1 || _fileno(stdout) == -2) { AttachConsole = NULL; #ifdef UNICODE if ((hmod = GetModuleHandle(L"kernel32.dll"))) #else if ((hmod = GetModuleHandle("kernel32.dll"))) #endif { AttachConsole = (LPFNATTACHCONSOLE) GetProcAddress(hmod, "AttachConsole"); } if ( (AttachConsole && AttachConsole (ATTACH_PARENT_PROCESS)) || AllocConsole() ) { freopen("CONOUT$", "w", stdout); freopen("CONOUT$", "w", stderr); atexit (atexit_callback); } } } int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nFunsterStil) { int main (int argc, char** argv); // below main() return main (__argc, __argv); } #endif // _WINDOWS #endif // _WIN32 // ---------------------------------------------------------------------------- #ifdef HAVE_CONFIG_H #include #endif #include // exit(), EXIT_SUCCESS, EXIT_FAILURE #include // uglib #include // GnuTLS #ifdef HAVE_GNUTLS #include #include GCRY_THREAD_OPTION_PTHREAD_IMPL; void init_gnutls_locks (void) { gcry_control (GCRYCTL_SET_THREAD_CBS); } #endif // HAVE_GNUTLS // GStreamer #ifdef HAVE_GSTREAMER #include gboolean gst_inited = FALSE; #endif // libnotify #ifdef HAVE_LIBNOTIFY #include #endif // I18N #ifndef GETTEXT_PACKAGE #define GETTEXT_PACKAGE "uget" #endif #include // ---------------------------------------------------------------------------- // ug_get_data_dir() defined in UgApp-gtk.h const gchar* ug_get_data_dir (void) { #ifdef DATADIR_WIN_PROG // change DATADIR to main program installed path. static gchar* data_dir = NULL; if (data_dir == NULL) { gchar* path; gunichar2* path_wcs; HMODULE hmod; hmod = GetModuleHandle (NULL); // UNICODE path_wcs = g_malloc (sizeof (wchar_t) * MAX_PATH); GetModuleFileNameW (hmod, path_wcs, MAX_PATH); path = g_utf16_to_utf8 (path_wcs, -1, NULL, NULL, NULL); g_free (path_wcs); data_dir = g_path_get_dirname (path); g_free (path); } return data_dir; #elif defined (DATADIR) return DATADIR; #else return "/usr/share"; #endif // DATADIR_WIN_PROG } // ---------------------------------------------------------------------------- UgAppGtk* app; // SIGTERM static void term_signal_handler (int sig) { // This will quit gtk_main() to main() ug_app_quit (app); } // ---------------------------------------------------------------------------- int main (int argc, char** argv) { gchar* string; gint ipc_status; // I18N #ifdef LOCALEDIR bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); #else string = g_build_filename (ug_get_data_dir (), "locale", NULL); bindtextdomain (GETTEXT_PACKAGE, string); g_free (string); #endif bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #ifdef HAVE_GNUTLS init_gnutls_locks (); #endif string = ug_arg_find_version (argc, argv); if (string) { #if defined (_WIN32) && defined (_WINDOWS) win32_console_init (); #endif // _WIN32 && _WINDOWS g_print ("uGet " PACKAGE_VERSION " for GTK+" "\n"); return EXIT_SUCCESS; } string = ug_arg_find_help (argc, argv); // initialize for MS-Windows #if defined (_WIN32) #if defined (_WINDOWS) if (string) win32_console_init (); #endif // _WINDOWS win32_winsock_init (); #endif // _WIN32 // uglib: options app = g_slice_alloc0 (sizeof (UgAppGtk)); ug_option_init (&app->option); ug_option_add (&app->option, NULL, gtk_get_option_group (TRUE)); if (string) { g_print ("uGet " PACKAGE_VERSION " for GTK+" "\n"); ug_option_help (&app->option, argv[0], string); } // GTK+ gtk_init (&argc, &argv); // GStreamer #ifdef HAVE_GSTREAMER gst_inited = gst_init_check (&argc, &argv, NULL); #endif // IPC initialize & check exist Uget program ipc_status = ug_ipc_init_with_args (&app->ipc, argc, argv); if (ipc_status < 1) { if (ipc_status == -1) g_print ("uget: IPC failed.\n"); // if (ipc_status == 0) // g_print ("uget: Server exists.\n"); ug_ipc_finalize (&app->ipc); goto exit; } // libnotify #ifdef HAVE_LIBNOTIFY notify_init ("uGet"); #endif // register uget interfaces uglib_init (); // main program ug_app_init (app); signal (SIGTERM, term_signal_handler); gtk_main (); // libnotify #ifdef HAVE_LIBNOTIFY if (notify_is_initted ()) notify_uninit (); #endif // shutdown IPC and sleep 3 second to wait thread g_usleep (3 * 1000000); ug_ipc_finalize (&app->ipc); exit: // finalize for MS-Windows #ifdef _WIN32 win32_winsock_finalize (); #endif return EXIT_SUCCESS; } uget-1.10.4/uget-gtk/UgApp-gtk-callback.c0000664000175000017500000020623312260761064014722 00000000000000static const char uget_license[] = { " Copyright (C) 2005-2014 by C.H. Huang" "\n" " plushuang.tw@gmail.com" "\n" "\n" "This library is free software; you can redistribute it and/or" "\n" "modify it under the terms of the GNU Lesser General Public" "\n" "License as published by the Free Software Foundation; either" "\n" "version 2.1 of the License, or (at your option) any later version." "\n" "\n" "This library is distributed in the hope that it will be useful," "\n" "but WITHOUT ANY WARRANTY; without even the implied warranty of" "\n" "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU" "\n" "Lesser General Public License for more details." "\n" "\n" "You should have received a copy of the GNU Lesser General Public" "\n" "License along with this library; if not, write to the Free Software" "\n" "Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA" "\n" "\n" "---------" "\n" "\n" "In addition, as a special exception, the copyright holders give" "\n" "permission to link the code of portions of this program with the" "\n" "OpenSSL library under certain conditions as described in each" "\n" "individual source file, and distribute linked combinations" "\n" "including the two." "\n" "You must obey the GNU Lesser General Public License in all respects" "\n" "for all of the code used other than OpenSSL. If you modify" "\n" "file(s) with this exception, you may extend this exception to your" "\n" "version of the file(s), but you are not obligated to do so. If you" "\n" "do not wish to do so, delete this exception statement from your" "\n" "version. If you delete this exception statement from all source" "\n" "files in the program, then also delete it here." "\n" "\0" }; #ifdef _WIN32 #include #endif #include // for GDK_KEY_xxx... // uglib #include #include #include #include #include #include #include #include #define UGET_URL_WEBSITE "http://ugetdm.com/" // static data static const gchar* uget_authors[] = { "C.H. Huang (\xE9\xBB\x83\xE6\xAD\xA3\xE9\x9B\x84)", NULL }; static const gchar* uget_artists[] = { "Logo designer: Michael Tunnell (visuex.com)", "Website by: Michael Tunnell (visuex.com)", "Former Logo designer: saf1 (linuxac.org)", "Former Logo improver: Skeleton_Eel (linuxac.org)", NULL }; static const gchar* uget_version = UG_APP_GTK_VERSION; static const gchar* uget_comments = N_("Download Manager"); static const gchar* uget_copyright = "Copyright (C) 2005-2014 C.H. Huang"; static const gchar* translator_credits = N_("translator-credits"); // static functions static void ug_window_init_callback (struct UgWindow* window, UgAppGtk* app); static void ug_toolbar_init_callback (struct UgToolbar* toolbar, UgAppGtk* app); static void ug_menubar_init_callback (struct UgMenubar* menubar, UgAppGtk* app); static void ug_trayicon_init_callback (struct UgTrayIcon* icon, UgAppGtk* app); static GtkWidget* create_file_chooser (const gchar* title, GtkWindow* parent, const gchar* filter_name, const gchar* mine_type); void ug_app_init_callback (UgAppGtk* app) { // gtk_accel_group_connect (app->accel_group, GDK_KEY_q, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE, // g_cclosure_new_swap (G_CALLBACK (ug_app_quit), app, NULL)); // gtk_accel_group_connect (app->accel_group, GDK_KEY_s, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE, // g_cclosure_new_swap (G_CALLBACK (ug_app_save), app, NULL)); // gtk_accel_group_connect (app->accel_group, GDK_KEY_c, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE, // g_cclosure_new_swap (G_CALLBACK (on_summary_copy_selected), app, NULL)); ug_window_init_callback (&app->window, app); ug_toolbar_init_callback (&app->toolbar, app); ug_menubar_init_callback (&app->menubar, app); ug_trayicon_init_callback (&app->trayicon, app); } // ---------------------------------------------------------------------------- // Category // static void on_create_category_response (GtkDialog *dialog, gint response_id, UgCategoryDialog* cdialog) { UgCategory* category; UgAppGtk* app; if (response_id == GTK_RESPONSE_OK) { app = cdialog->user.app; ug_download_form_get_folder_list (&cdialog->download, &app->setting.folder_list); category = ug_category_new_with_gtk (app->cwidget.primary.category); ug_category_dialog_get (cdialog, category); ug_category_widget_append (&app->cwidget, category); ug_app_menubar_sync_category (app, TRUE); } ug_category_dialog_free (cdialog); } static void on_create_category (GtkWidget* widget, UgAppGtk* app) { UgCategoryDialog* cdialog; gchar* string; string = g_strconcat (UG_APP_GTK_NAME " - ", _("New Category"), NULL); cdialog = ug_category_dialog_new (string, app->window.self); g_free (string); ug_download_form_set_folder_list (&cdialog->download, app->setting.folder_list); // copy setting from current category if (app->cwidget.current.category != app->cwidget.primary.category) { ug_category_dialog_set (cdialog, app->cwidget.current.category); string = g_strconcat (_("Copy - "), app->cwidget.current.category->name, NULL); gtk_entry_set_text (GTK_ENTRY (cdialog->category.name_entry), string); g_free (string); } else { string = _("New Category"); gtk_entry_set_text (GTK_ENTRY (cdialog->category.name_entry), string); } // show category dialog cdialog->user.app = app; g_signal_connect (cdialog->self, "response", G_CALLBACK (on_create_category_response), cdialog); gtk_widget_show ((GtkWidget*) cdialog->self); } static void on_delete_category (GtkWidget* widget, UgAppGtk* app) { UgCategory* current; GtkWidget* download_view; if (app->cwidget.current.category == app->cwidget.primary.category) return; // remove current view before removing category download_view = app->cwidget.current.widget->self; g_object_ref (download_view); gtk_container_remove (GTK_CONTAINER (app->window.vpaned), download_view); // remove and delete category current = app->cwidget.current.category; ug_category_widget_remove (&app->cwidget, current); // refresh gtk_widget_queue_draw ((GtkWidget*) app->cwidget.primary.view); ug_app_menubar_sync_category (app, TRUE); } static void on_config_category_response (GtkDialog *dialog, gint response_id, UgCategoryDialog* cdialog) { UgAppGtk* app; app = cdialog->user.app; if (response_id == GTK_RESPONSE_OK) { ug_download_form_get_folder_list (&cdialog->download, &app->setting.folder_list); ug_category_dialog_get (cdialog, app->cwidget.current.category); } gtk_widget_set_sensitive ((GtkWidget*)app->window.self, TRUE); ug_category_dialog_free (cdialog); } static void on_config_category (GtkWidget* widget, UgAppGtk* app) { UgCategoryDialog* cdialog; gchar* title; if (app->cwidget.current.category == app->cwidget.primary.category) return; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Category Properties"), NULL); cdialog = ug_category_dialog_new (title, app->window.self); g_free (title); ug_download_form_set_folder_list (&cdialog->download, app->setting.folder_list); ug_category_dialog_set (cdialog, app->cwidget.current.category); // show category dialog cdialog->user.app = app; g_signal_connect (cdialog->self, "response", G_CALLBACK (on_config_category_response), cdialog); gtk_widget_set_sensitive ((GtkWidget*)app->window.self, FALSE); gtk_widget_show ((GtkWidget*) cdialog->self); } // ---------------------------------------------------------------------------- // Download // static void ug_app_setup_download_dialog (UgAppGtk* app, UgDownloadDialog* ddialog) { UgetCommon* common; GtkTreePath* path; GtkTreeModel* model; ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); if (app->setting.ui.apply_recently && app->last.download) { model = gtk_tree_view_get_model (ddialog->category_view); if (app->last.category_index < gtk_tree_model_iter_n_children (model, NULL)) { path = gtk_tree_path_new_from_indices (app->last.category_index, -1); gtk_tree_view_set_cursor (ddialog->category_view, path, NULL, FALSE); gtk_tree_path_free (path); } common = ug_dataset_realloc (app->last.download, UgetCommonInfo, 0); if (common && common->file) { g_free (common->file); common->file = NULL; } ug_download_dialog_set (ddialog, app->last.download); } } static void on_create_download_response (GtkDialog *dialog, gint response_id, UgDownloadDialog* ddialog) { UgCategory* category; UgAppGtk* app; GList* list; GList* link; GtkTreePath* path; if (response_id == GTK_RESPONSE_OK) { app = ddialog->user.app; ug_download_form_get_folder_list (&ddialog->download, &app->setting.folder_list); category = ug_download_dialog_get_category (ddialog); if (category) { list = ug_download_dialog_get_downloads (ddialog); for (link = list; link; link = link->next) ug_category_add (category, link->data); // get last download settings if (list->data) { if (app->last.download) ug_dataset_unref (app->last.download); ug_dataset_ref (list->data); app->last.download = list->data; } // get last category index gtk_tree_view_get_cursor (ddialog->category_view, &path, NULL); if (path) { app->last.category_index = *gtk_tree_path_get_indices (path); gtk_tree_path_free (path); } // free unused g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); g_list_free (list); gtk_widget_queue_draw ((GtkWidget*) app->cwidget.self); } } ug_download_dialog_free (ddialog); } static void on_create_download (GtkWidget* widget, UgAppGtk* app) { UgDownloadDialog* ddialog; gchar* title; GList* list; title = g_strconcat (UG_APP_GTK_NAME " - ", _("New Download"), NULL); ddialog = ug_download_dialog_new (title, app->window.self); g_free (title); if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == FALSE) gtk_window_set_transient_for ((GtkWindow*) ddialog->self, NULL); // setup download dialog ug_app_setup_download_dialog (app, ddialog); // use first URI from clipboard to set URL entry list = ug_clipboard_get_uris (&app->clipboard); if (list) { ddialog->download.changed.url = TRUE; gtk_entry_set_text ((GtkEntry*) ddialog->download.url_entry, list->data); g_list_foreach (list, (GFunc) g_free, NULL); g_list_free (list); ug_download_form_complete_entry (&ddialog->download); } // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show ((GtkWidget*) ddialog->self); } static void on_create_sequence (GtkWidget* widget, UgAppGtk* app) { UgDownloadDialog* ddialog; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("URL Sequence batch"), NULL); ddialog = ug_download_dialog_new (title, app->window.self); g_free (title); ug_download_dialog_use_batch (ddialog); // setup download dialog ug_app_setup_download_dialog (app, ddialog); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show (GTK_WIDGET (ddialog->self)); } static void on_create_from_clipboard (GtkWidget* widget, UgAppGtk* app) { UgDownloadDialog* ddialog; UgSelectorPage* page; GList* list; gchar* title; list = ug_clipboard_get_uris (&app->clipboard); if (list == NULL) { ug_app_show_message (app, GTK_MESSAGE_ERROR, _("No URLs found in clipboard.")); return; } title = g_strconcat (UG_APP_GTK_NAME " - ", _("Clipboard batch"), NULL); ddialog = ug_download_dialog_new (title, app->window.self); g_free (title); if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == FALSE) gtk_window_set_transient_for ((GtkWindow*) ddialog->self, NULL); ug_download_dialog_use_selector (ddialog); // selector ug_selector_hide_href (&ddialog->selector); page = ug_selector_add_page (&ddialog->selector, _("Clipboard")); ug_selector_page_add_uris (page, list); g_list_free (list); // setup download dialog ug_app_setup_download_dialog (app, ddialog); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show (GTK_WIDGET (ddialog->self)); } static void on_create_torrent_response (GtkWidget* dialog, gint response, UgAppGtk* app) { UgDownloadDialog* ddialog; gchar* string; gchar* uri; if (response != GTK_RESPONSE_OK ) { gtk_widget_destroy (dialog); return; } // get filename uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); gtk_widget_destroy (dialog); string = g_strconcat (UG_APP_GTK_NAME " - ", _("New Torrent"), NULL); ddialog = ug_download_dialog_new (string, app->window.self); g_free (string); if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == FALSE) gtk_window_set_transient_for ((GtkWindow*) ddialog->self, NULL); ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); gtk_entry_set_text (GTK_ENTRY (ddialog->download.url_entry), uri); g_free (uri); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show ((GtkWidget*) ddialog->self); } static void on_create_torrent (GtkWidget* widget, UgAppGtk* app) { GtkWidget* dialog; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Open Torrent file"), NULL); dialog = create_file_chooser (title, app->window.self, "Torrent file (*.torrent)", "application/x-bittorrent"); g_free (title); g_signal_connect (dialog, "response", G_CALLBACK (on_create_torrent_response), app); gtk_widget_show (dialog); } static void on_create_metalink_response (GtkWidget* dialog, gint response, UgAppGtk* app) { UgDownloadDialog* ddialog; gchar* string; gchar* uri; if (response != GTK_RESPONSE_OK ) { gtk_widget_destroy (dialog); return; } // get filename uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); gtk_widget_destroy (dialog); string = g_strconcat (UG_APP_GTK_NAME " - ", _("New Metalink"), NULL); ddialog = ug_download_dialog_new (string, app->window.self); g_free (string); if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == FALSE) gtk_window_set_transient_for ((GtkWindow*) ddialog->self, NULL); ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); gtk_entry_set_text (GTK_ENTRY (ddialog->download.url_entry), uri); g_free (uri); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show ((GtkWidget*) ddialog->self); } static void on_create_metalink (GtkWidget* widget, UgAppGtk* app) { GtkWidget* dialog; GtkFileFilter* filter; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Open Metalink file"), NULL); dialog = gtk_file_chooser_dialog_new (title, app->window.self, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_window_set_destroy_with_parent ((GtkWindow*) dialog, TRUE); filter = gtk_file_filter_new (); gtk_file_filter_set_name (filter, "Metalink file (*.metalink, *.meta4)"); gtk_file_filter_add_pattern (filter, "*.metalink"); gtk_file_filter_add_pattern (filter, "*.meta4"); // gtk_file_filter_add_mime_type (filter, "application/metalink+xml"); // gtk_file_filter_add_mime_type (filter, "application/metalink4+xml"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); g_signal_connect (dialog, "response", G_CALLBACK (on_create_metalink_response), app); gtk_widget_show (dialog); } static void on_delete_download (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetRelation* relation; GList* list; GList* link; // check shift key status GdkWindow* gdk_win; GdkDevice* dev_pointer; GdkModifierType mask; dwidget = app->cwidget.current.widget; // check shift key status gdk_win = gtk_widget_get_parent_window ((GtkWidget*) dwidget->view); dev_pointer = gdk_device_manager_get_client_pointer ( gdk_display_get_device_manager (gdk_window_get_display (gdk_win))); gdk_window_get_device_position (gdk_win, dev_pointer, NULL, NULL, &mask); // clear summary ug_summary_show (&app->summary, NULL); // set action status "stop by user" and "deleted" app->action.stop = TRUE; app->action.deleted = TRUE; list = ug_download_widget_get_selected (dwidget); for (link = list; link; link = link->next) { // stop task ug_running_remove (&app->running, link->data); // delete data or move it to recycled relation = UG_DATASET_RELATION ((UgDataset*) link->data); if ((relation->hints & UG_HINT_RECYCLED) || (mask & GDK_SHIFT_MASK)) ug_category_gtk_remove (relation->category, link->data); else { relation->hints |= UG_HINT_RECYCLED; ug_category_gtk_changed (relation->category, link->data); } } g_list_free (list); app->action.deleted = FALSE; // update gtk_widget_queue_draw ((GtkWidget*) app->cwidget.self); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } static void on_delete_download_file_response (GtkWidget* widget, gint response_id, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetCommon* common; gchar* path; GList* list; GList* link; if (response_id != GTK_RESPONSE_YES) return; dwidget = app->cwidget.current.widget; // clear summary ug_summary_show (&app->summary, NULL); // set action status "stop by user" and "deleted" app->action.stop = TRUE; app->action.deleted = TRUE; list = ug_download_widget_get_selected (dwidget); for (link = list; link; link = link->next) { // stop task ug_running_remove (&app->running, link->data); // delete file common = UG_DATASET_COMMON ((UgDataset*) link->data); if (common->folder) { path = g_build_filename (common->folder, common->file, NULL); ug_delete_file (path); g_free (path); } else if (common->file) ug_delete_file (common->file); // delete data ug_category_gtk_remove (app->cwidget.current.category, link->data); } g_list_free (list); app->action.deleted = FALSE; // update gtk_widget_queue_draw ((GtkWidget*) app->cwidget.self); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } static void on_delete_download_file (GtkWidget* widget, UgAppGtk* app) { if (app->setting.ui.delete_confirmation == FALSE) on_delete_download_file_response (widget, GTK_RESPONSE_YES, app); else { ug_app_confirm_to_delete (app, G_CALLBACK (on_delete_download_file_response), app); } } static void on_open_download_file (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetCommon* common; UgDataset* dataset; GtkWidget* dialog; gchar* string; dwidget = app->cwidget.current.widget; dataset = ug_download_widget_get_cursor (dwidget); if (dataset == NULL) return; common = ug_dataset_get (dataset, UgetCommonInfo, 0); if (common->folder == NULL || common->file == NULL) return; if (ug_launch_default_app (common->folder, common->file) == FALSE) { string = g_strdup_printf (_("Can't launch default application for file '%s'."), common->file); dialog = gtk_message_dialog_new (app->window.self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", string); g_free (string); string = g_strconcat (UG_APP_GTK_NAME " - ", _("Error"), NULL); gtk_window_set_title ((GtkWindow*) dialog, string); g_free (string); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show ((GtkWidget*) dialog); } } static void on_open_download_folder (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetCommon* common; UgDataset* dataset; GtkWidget* dialog; gchar* string; dwidget = app->cwidget.current.widget; dataset = ug_download_widget_get_cursor (dwidget); if (dataset == NULL) return; common = ug_dataset_get (dataset, UgetCommonInfo, 0); if (common->folder == NULL) return; string = g_filename_from_utf8 (common->folder, -1, NULL, NULL, NULL); if (g_file_test (string, G_FILE_TEST_EXISTS) == FALSE) { g_free (string); string = g_strdup_printf (_("'%s' - This folder does not exist."), common->folder); dialog = gtk_message_dialog_new (app->window.self, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, "%s", string); g_free (string); string = g_strconcat (UG_APP_GTK_NAME " - ", _("Error"), NULL); gtk_window_set_title ((GtkWindow*) dialog, string); g_free (string); g_signal_connect (dialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show ((GtkWidget*) dialog); return; } g_free (string); #ifdef _WIN32 { gchar* path; gchar* argument; gunichar2* argument_os; path = g_build_filename (common->folder, common->file, NULL); if (g_file_test (path, G_FILE_TEST_EXISTS)) argument = g_strconcat ("/e,/select,\"", path, "\"", NULL); else argument = g_strconcat ("/e,\"", common->folder, "\"", NULL); g_free (path); argument_os = g_utf8_to_utf16 (argument, -1, NULL, NULL, NULL); g_free (argument); ShellExecuteW (NULL, NULL, L"explorer", argument_os, NULL, SW_SHOW); g_free (argument_os); } #else { GError* error = NULL; GFile* gfile; gchar* uri; gfile = g_file_new_for_path (common->folder); uri = g_file_get_uri (gfile); g_object_unref (gfile); g_app_info_launch_default_for_uri (uri, NULL, &error); g_free (uri); if (error) g_error_free (error); } #endif } static void on_config_download_response (GtkDialog *dialog, gint response_id, UgDownloadDialog* ddialog) { UgDownloadWidget* dwidget; UgAppGtk* app; GList* list; GList* link; app = ddialog->user.app; dwidget = app->cwidget.current.widget; if (response_id == GTK_RESPONSE_OK) { ug_download_form_get_folder_list (&ddialog->download, &app->setting.folder_list); list = ug_download_widget_get_selected (dwidget); for (link = list; link; link = link->next) ug_download_dialog_get (ddialog, link->data); g_list_free (list); } ug_download_dialog_free (ddialog); // refresh other data & status gtk_widget_set_sensitive ((GtkWidget*) app->window.self, TRUE); gtk_widget_queue_draw (GTK_WIDGET (dwidget->view)); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } static void on_config_download (GtkWidget* widget, UgAppGtk* app) { UgDownloadDialog* ddialog; gchar* title; GList* list; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Download Properties"), NULL); ddialog = ug_download_dialog_new (title, app->window.self); g_free (title); // UgDownloadForm list = ug_download_widget_get_selected (app->cwidget.current.widget); ug_download_form_set_multiple (&ddialog->download, (list->next) ? TRUE : FALSE); ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_form_set_relation (&ddialog->download, FALSE); ug_download_dialog_set (ddialog, list->data); g_list_free (list); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_config_download_response), ddialog); gtk_widget_set_sensitive ((GtkWidget*) app->window.self, FALSE); gtk_widget_show (GTK_WIDGET (ddialog->self)); } static void on_set_download_force_start (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetRelation* relation; GList* list; GList* link; dwidget = app->cwidget.current.widget; list = ug_download_widget_get_selected (dwidget); for (link = list; link; link = link->next) { relation = UG_DATASET_RELATION ((UgDataset*) link->data); relation->hints &= ~UG_HINT_UNRUNNABLE; ug_running_add (&app->running, link->data); } g_list_free (list); // refresh other data & status gtk_widget_queue_draw (app->cwidget.self); gtk_widget_queue_draw (GTK_WIDGET (dwidget->view)); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } static void on_set_download_runnable (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetRelation* relation; GList* list; GList* link; dwidget = app->cwidget.current.widget; list = ug_download_widget_get_selected (dwidget); for (link = list; link; link = link->next) { relation = UG_DATASET_RELATION ((UgDataset*) link->data); relation->hints &= ~UG_HINT_UNRUNNABLE; // If task is in Finished or Recycled, move it to Queuing. ug_category_gtk_changed (relation->category, link->data); } g_list_free (list); // refresh other data & status gtk_widget_queue_draw (app->cwidget.self); gtk_widget_queue_draw (GTK_WIDGET (dwidget->view)); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } static void on_set_download_to_pause (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; UgetRelation* relation; GList* list; GList* link; // set action status "stop by user" app->action.stop = TRUE; dwidget = app->cwidget.current.widget; list = ug_download_widget_get_selected (dwidget); for (link = list; link; link = link->next) { relation = UG_DATASET_RELATION ((UgDataset*) link->data); relation->hints |= UG_HINT_PAUSED; // stop task ug_running_remove (&app->running, link->data); } g_list_free (list); // refresh other data & status gtk_widget_queue_draw (GTK_WIDGET (dwidget->view)); ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } static void on_move_download_up (GtkWidget* widget, UgAppGtk* app) { if (app->cwidget.current.category == NULL) return; if (ug_category_gtk_move_selected_up (app->cwidget.current.category, app->cwidget.current.widget)) { gtk_widget_set_sensitive (app->toolbar.move_down, TRUE); gtk_widget_set_sensitive (app->toolbar.move_bottom, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_down, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_bottom, TRUE); } else { gtk_widget_set_sensitive (app->toolbar.move_up, FALSE); gtk_widget_set_sensitive (app->toolbar.move_top, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_up, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_top, FALSE); } } static void on_move_download_down (GtkWidget* widget, UgAppGtk* app) { if (app->cwidget.current.category == NULL) return; if (ug_category_gtk_move_selected_down (app->cwidget.current.category, app->cwidget.current.widget)) { gtk_widget_set_sensitive (app->toolbar.move_up, TRUE); gtk_widget_set_sensitive (app->toolbar.move_top, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_up, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_top, TRUE); } else { gtk_widget_set_sensitive (app->toolbar.move_down, FALSE); gtk_widget_set_sensitive (app->toolbar.move_bottom, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_down, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_bottom, FALSE); } } static void on_move_download_to_top (GtkWidget* widget, UgAppGtk* app) { if (app->cwidget.current.category == NULL) return; if (ug_category_gtk_move_selected_to_top (app->cwidget.current.category, app->cwidget.current.widget)) { gtk_widget_set_sensitive (app->toolbar.move_down, TRUE); gtk_widget_set_sensitive (app->toolbar.move_bottom, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_down, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_bottom, TRUE); } gtk_widget_set_sensitive (app->toolbar.move_up, FALSE); gtk_widget_set_sensitive (app->toolbar.move_top, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_up, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_top, FALSE); } static void on_move_download_to_bottom (GtkWidget* widget, UgAppGtk* app) { if (app->cwidget.current.category == NULL) return; if (ug_category_gtk_move_selected_to_bottom (app->cwidget.current.category, app->cwidget.current.widget)) { gtk_widget_set_sensitive (app->toolbar.move_up, TRUE); gtk_widget_set_sensitive (app->toolbar.move_top, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_up, TRUE); gtk_widget_set_sensitive (app->menubar.download.move_top, TRUE); } gtk_widget_set_sensitive (app->toolbar.move_down, FALSE); gtk_widget_set_sensitive (app->toolbar.move_bottom, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_down, FALSE); gtk_widget_set_sensitive (app->menubar.download.move_bottom, FALSE); } // ---------------------------------------------------------------------------- // UgFileMenu // static GtkWidget* create_file_chooser (const gchar* title, GtkWindow* parent, const gchar* filter_name, const gchar* mine_type) { GtkWidget* dialog; GtkFileFilter* filter; dialog = gtk_file_chooser_dialog_new (title, parent, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_window_set_destroy_with_parent ((GtkWindow*) dialog, TRUE); filter = gtk_file_filter_new (); gtk_file_filter_set_name (filter, filter_name); gtk_file_filter_add_mime_type (filter, mine_type); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); return dialog; } static void on_import_html_file_response (GtkWidget* dialog, gint response, UgAppGtk* app) { UgHtmlContext* context; UgHtmlFilter* filter_a; UgHtmlFilter* filter_img; UgDownloadDialog* ddialog; UgSelectorPage* page; gchar* string; gchar* file; if (response != GTK_RESPONSE_OK ) { gtk_widget_destroy (dialog); return; } // read URLs from html file string = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); gtk_widget_destroy (dialog); file = g_filename_to_utf8 (string, -1, NULL, NULL, NULL); g_free (string); string = NULL; // parse html context = ug_html_context_new (); filter_a = ug_html_filter_new ("A", "HREF"); // ug_html_context_add_filter (context, filter_a); filter_img = ug_html_filter_new ("IMG", "SRC"); // ug_html_context_add_filter (context, filter_img); ug_html_context_parse_file (context, file); g_free (file); if (context->base_href) string = g_strdup (context->base_href); ug_html_context_free (context); // UgDownloadDialog ddialog = ug_download_dialog_new ( gtk_window_get_title ((GtkWindow*) dialog), app->window.self); ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); ug_download_dialog_use_selector (ddialog); // set if (string) { gtk_entry_set_text (ddialog->selector.href_entry, string); g_free (string); } // add link page = ug_selector_add_page (&ddialog->selector, _("Link ")); ug_selector_page_add_uris (page, filter_a->attr_values); filter_a->attr_values = NULL; ug_html_filter_unref (filter_a); // add image page = ug_selector_add_page (&ddialog->selector, _("Image ")); ug_selector_page_add_uris (page, filter_img->attr_values); filter_img->attr_values = NULL; ug_html_filter_unref (filter_img); // setup & show download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show ((GtkWidget*) ddialog->self); } static void on_import_html_file (GtkWidget* widget, UgAppGtk* app) { GtkWidget* dialog; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Import URLs from HTML file"), NULL); dialog = create_file_chooser (title, app->window.self, "HTML file (*.htm, *.html)", "text/html"); g_free (title); g_signal_connect (dialog, "response", G_CALLBACK (on_import_html_file_response), app); gtk_widget_show (dialog); } static void on_import_text_file_response (GtkWidget* dialog, gint response, UgAppGtk* app) { UgDownloadDialog* ddialog; UgSelectorPage* page; gchar* string; gchar* file; GList* list; GError* error = NULL; if (response != GTK_RESPONSE_OK ) { gtk_widget_destroy (dialog); return; } // read URLs from text file string = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); gtk_widget_destroy (dialog); file = g_filename_to_utf8 (string, -1, NULL, NULL, NULL); g_free (string); list = ug_text_file_get_uris (file, &error); g_free (file); if (error) { ug_app_show_message (app, GTK_MESSAGE_ERROR, error->message); g_error_free (error); return; } // UgDownloadDialog ddialog = ug_download_dialog_new ( gtk_window_get_title ((GtkWindow*) dialog), app->window.self); ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); ug_download_dialog_use_selector (ddialog); page = ug_selector_add_page (&ddialog->selector, _("Text File")); ug_selector_hide_href (&ddialog->selector); ug_selector_page_add_uris (page, list); g_list_free (list); // setup & show download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_create_download_response), ddialog); gtk_widget_show ((GtkWidget*) ddialog->self); } static void on_import_text_file (GtkWidget* widget, UgAppGtk* app) { GtkWidget* dialog; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Import URLs from text file"), NULL); dialog = create_file_chooser (title, app->window.self, "Plain text file", "text/plain"); g_free (title); g_signal_connect (dialog, "response", G_CALLBACK (on_import_text_file_response), app); gtk_widget_show (dialog); } static void on_export_text_file_response (GtkWidget* dialog, gint response, UgAppGtk* app) { GIOChannel* channel; gchar* string; GList* list; GList* link; if (response != GTK_RESPONSE_OK ) { gtk_widget_destroy (dialog); return; } // write all URLs to text file string = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog)); gtk_widget_destroy (dialog); channel = g_io_channel_new_file (string, "w", NULL); g_free (string); list = ug_category_gtk_get_all (app->cwidget.primary.category); for (link = list; link; link = link->next) { string = UG_DATASET_COMMON ((UgDataset*) link->data)->url; if (string) { g_io_channel_write_chars (channel, string, -1, NULL, NULL); #ifdef _WIN32 g_io_channel_write_chars (channel, "\r\n", 2, NULL, NULL); #else g_io_channel_write_chars (channel, "\n", 1, NULL, NULL); #endif } } g_list_free (list); g_io_channel_unref (channel); } static void on_export_text_file (GtkWidget* widget, UgAppGtk* app) { GtkWidget* dialog; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Export to"), NULL); dialog = gtk_file_chooser_dialog_new (_("Export to"), app->window.self, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_window_set_destroy_with_parent ((GtkWindow*) dialog, TRUE); g_signal_connect (dialog, "response", G_CALLBACK (on_export_text_file_response), app); gtk_widget_show (dialog); } static void on_offline_mode (GtkWidget* widget, UgAppGtk* app) { UgDownloadWidget* dwidget; GtkCheckMenuItem* item; item = GTK_CHECK_MENU_ITEM (widget); app->setting.offline_mode = gtk_check_menu_item_get_active (item); item = GTK_CHECK_MENU_ITEM (app->menubar.file.offline_mode); gtk_check_menu_item_set_active (item, app->setting.offline_mode); item = GTK_CHECK_MENU_ITEM (app->trayicon.menu.offline_mode); gtk_check_menu_item_set_active (item, app->setting.offline_mode); // into offline mode if (app->setting.offline_mode == TRUE) { // set action status "stop by user" app->action.stop = TRUE; // stop all active tasks ug_running_clear (&app->running); // refresh gtk_widget_queue_draw (app->cwidget.self); dwidget = app->cwidget.current.widget; gtk_widget_queue_draw (GTK_WIDGET (dwidget->view)); // ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } } // ---------------------------------------------------------------------------- // UgEditMenu // static void on_monitor_clipboard (GtkWidget* widget, UgAppGtk* app) { gboolean active; active = gtk_check_menu_item_get_active ((GtkCheckMenuItem*) widget); app->setting.clipboard.monitor = active; } static void on_config_settings_response (GtkDialog *dialog, gint response, UgSettingDialog* sdialog) { UgAppGtk* app; app = sdialog->user_data; app->dialogs.setting = NULL; if (response == GTK_RESPONSE_OK) { ug_setting_dialog_get (sdialog, &app->setting); // clipboard ug_clipboard_set_pattern (&app->clipboard, app->setting.clipboard.pattern); gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.edit.clipboard_monitor, app->setting.clipboard.monitor); // launch g_regex_unref (app->launch_regex); app->launch_regex = g_regex_new (app->setting.launch.types, G_REGEX_CASELESS, 0, NULL); // ui ug_app_trayicon_decide_visible (app); // aria2 ug_app_decide_bt_meta_sensitive (app); ug_app_aria2_setup (app); app->aria2.remote_updated = FALSE; } ug_setting_dialog_free (sdialog); // refresh // gtk_check_menu_item_toggled ((GtkCheckMenuItem*) app->menubar.edit.clipboard_monitor); on_monitor_clipboard (app->menubar.edit.clipboard_monitor, app); } static void on_config_shutdown (GtkWidget* widget, UgAppGtk* app) { gboolean active; active = gtk_check_menu_item_get_active ((GtkCheckMenuItem*) widget); app->setting.shutdown = active; } static void on_config_settings (GtkWidget* widget, UgAppGtk* app) { UgSettingDialog* sdialog; gchar* title; if (app->dialogs.setting) { gtk_window_present ((GtkWindow*) app->dialogs.setting); return; } title = g_strconcat (UG_APP_GTK_NAME " - ", _("Settings"), NULL); sdialog = ug_setting_dialog_new (title, app->window.self); g_free (title); ug_setting_dialog_set (sdialog, &app->setting); app->dialogs.setting = (GtkWidget*) sdialog->self; // set page if (widget == app->menubar.edit.clipboard_option) gtk_notebook_set_current_page (sdialog->notebook, UG_SETTING_PAGE_CLIPBOARD); else gtk_notebook_set_current_page (sdialog->notebook, UG_SETTING_PAGE_UI); // show settings dialog sdialog->user_data = app; g_signal_connect (sdialog->self, "response", G_CALLBACK (on_config_settings_response), sdialog); gtk_widget_show ((GtkWidget*) sdialog->self); } static void on_config_clipboard (GtkWidget* widget, UgAppGtk* app) { on_config_settings (widget, app); } // ---------------------------------------------------------------------------- // UgViewMenu // void on_change_visible_widget (GtkWidget* widget, UgAppGtk* app) { struct UgWindowSetting* setting; gboolean visible; setting = &app->setting.window; visible = gtk_check_menu_item_get_active ((GtkCheckMenuItem*) widget); // Toolbar if (widget == app->menubar.view.toolbar) { setting->toolbar = visible; if (visible) gtk_widget_show (app->toolbar.self); else gtk_widget_hide (app->toolbar.self); return; } // Statusbar if (widget == app->menubar.view.statusbar) { setting->statusbar = visible; if (visible) gtk_widget_show ((GtkWidget*) app->statusbar.self); else gtk_widget_hide ((GtkWidget*) app->statusbar.self); return; } // Category if (widget == app->menubar.view.category) { setting->category = visible; if (visible) gtk_widget_show (app->cwidget.self); else gtk_widget_hide (app->cwidget.self); return; } // Summary if (widget == app->menubar.view.summary) { setting->summary = visible; if (visible) gtk_widget_show (app->summary.self); else gtk_widget_hide (app->summary.self); return; } } void on_change_visible_summary (GtkWidget* widget, UgAppGtk* app) { struct UgSummarySetting* setting; gboolean visible; setting = &app->setting.summary; visible = gtk_check_menu_item_get_active ((GtkCheckMenuItem*) widget); // which widget if (widget == app->menubar.view.summary_items.name) { setting->name = visible; app->summary.visible.name = visible; } else if (widget == app->menubar.view.summary_items.folder) { setting->folder = visible; app->summary.visible.folder = visible; } else if (widget == app->menubar.view.summary_items.category) { setting->category = visible; app->summary.visible.category = visible; } else if (widget == app->menubar.view.summary_items.url) { setting->url = visible; app->summary.visible.url = visible; } else if (widget == app->menubar.view.summary_items.message) { setting->message = visible; app->summary.visible.message = visible; } ug_summary_show (&app->summary, ug_download_widget_get_cursor (app->cwidget.current.widget)); } void on_change_visible_column (GtkWidget* widget, UgAppGtk* app) { struct UgDownloadColumnSetting* setting; UgDownloadWidget* dwidget; GtkTreeViewColumn* column; gboolean visible; gint column_index; setting = &app->setting.download_column; dwidget = app->cwidget.current.widget; visible = gtk_check_menu_item_get_active ((GtkCheckMenuItem*) widget); // which widget if (widget == app->menubar.view.columns.completed) { column_index = UG_DOWNLOAD_COLUMN_COMPLETE; setting->completed = visible; } else if (widget == app->menubar.view.columns.total) { column_index = UG_DOWNLOAD_COLUMN_SIZE; setting->total = visible; } else if (widget == app->menubar.view.columns.percent) { column_index = UG_DOWNLOAD_COLUMN_PERCENT; setting->percent = visible; } else if (widget == app->menubar.view.columns.elapsed) { column_index = UG_DOWNLOAD_COLUMN_ELAPSED; setting->elapsed = visible; } else if (widget == app->menubar.view.columns.left) { column_index = UG_DOWNLOAD_COLUMN_LEFT; setting->left = visible; } else if (widget == app->menubar.view.columns.speed) { column_index = UG_DOWNLOAD_COLUMN_SPEED; setting->speed = visible; } else if (widget == app->menubar.view.columns.upload_speed) { column_index = UG_DOWNLOAD_COLUMN_UPLOAD_SPEED; setting->upload_speed = visible; } else if (widget == app->menubar.view.columns.uploaded) { column_index = UG_DOWNLOAD_COLUMN_UPLOADED; setting->uploaded = visible; } else if (widget == app->menubar.view.columns.ratio) { column_index = UG_DOWNLOAD_COLUMN_RATIO; setting->ratio = visible; } else if (widget == app->menubar.view.columns.retry) { column_index = UG_DOWNLOAD_COLUMN_RETRY; setting->retry = visible; } else if (widget == app->menubar.view.columns.category) { column_index = UG_DOWNLOAD_COLUMN_CATEGORY; setting->category = visible; } else if (widget == app->menubar.view.columns.url) { column_index = UG_DOWNLOAD_COLUMN_URL; setting->url = visible; } else if (widget == app->menubar.view.columns.added_on) { column_index = UG_DOWNLOAD_COLUMN_ADDED_ON; setting->added_on = visible; } else if (widget == app->menubar.view.columns.completed_on) { column_index = UG_DOWNLOAD_COLUMN_COMPLETED_ON; setting->completed_on = visible; } else return; column = gtk_tree_view_get_column (dwidget->view, column_index); gtk_tree_view_column_set_visible (column, visible); // sync changed_count setting->changed_count++; dwidget->changed_count = setting->changed_count; } // ---------------------------------------------------------------------------- // UgHelpMenu // void on_help_online (GtkWidget* widget, UgAppGtk* app) { ug_launch_uri ("http://ugetdm.com/help"); } void on_documentation (GtkWidget* widget, UgAppGtk* app) { ug_launch_uri ("http://ugetdm.com/documentation"); } void on_support_forum (GtkWidget* widget, UgAppGtk* app) { ug_launch_uri ("http://ugetdm.com/forum/"); } void on_submit_feedback (GtkWidget* widget, UgAppGtk* app) { ug_launch_uri ("http://ugetdm.com/feedback"); } void on_report_bug (GtkWidget* widget, UgAppGtk* app) { ug_launch_uri ("http://ugetdm.com/reportbug"); } void on_check_updates (GtkWidget* widget, UgAppGtk* app) { ug_launch_uri ("http://ugetdm.com/versioncheck?v=" PACKAGE_VERSION); } void on_about (GtkWidget* widget, UgAppGtk* app) { GtkDialog* adialog; GdkPixbuf* pixbuf; char* path; path = g_build_filename ( ug_get_data_dir (), "pixmaps", "uget", "logo.png", NULL); pixbuf = gdk_pixbuf_new_from_file (path, NULL); g_free (path); // if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == FALSE) { // gtk_window_deiconify (app->window.self); // gtk_widget_show ((GtkWidget*) app->window.self); // } adialog = (GtkDialog*) gtk_about_dialog_new (); gtk_window_set_transient_for ((GtkWindow*) adialog, app->window.self); gtk_dialog_set_default_response (adialog, GTK_RESPONSE_CANCEL); g_object_set (adialog, // "logo-icon-name", UG_APP_GTK_APP_ICON_NAME, "logo", pixbuf, "program-name", UG_APP_GTK_NAME, "version", uget_version, "comments", gettext (uget_comments), "copyright", uget_copyright, #ifdef _WIN32 "website-label", UGET_URL_WEBSITE, #else "website", UGET_URL_WEBSITE, #endif "license", uget_license, "authors", uget_authors, "artists", uget_artists, "translator-credits", gettext (translator_credits), NULL); if (app->update_info.ready) { GtkScrolledWindow* scrolled; GtkTextBuffer* tbuf; GtkWidget* textview; GtkBox* box; textview = gtk_text_view_new (); tbuf = gtk_text_view_get_buffer ((GtkTextView*) textview); gtk_text_buffer_set_text (tbuf, app->update_info.text->str, -1); scrolled = (GtkScrolledWindow*) gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_size_request ((GtkWidget*) scrolled, 200, 120); gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_IN); gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled), textview); gtk_widget_show_all ((GtkWidget*) scrolled); box = (GtkBox*) gtk_dialog_get_content_area (adialog); gtk_box_pack_end (box, (GtkWidget*) scrolled, TRUE, TRUE, 2); } // Close button - GTK_RESPONSE_CANCEL g_signal_connect (adialog, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_dialog_run (adialog); if (pixbuf) g_object_unref (pixbuf); } // ---------------------------------------------------------------------------- // UgTrayIcon // static void on_trayicon_activate (GtkStatusIcon* status_icon, UgAppGtk* app) { if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == TRUE) { // get position and size gtk_window_get_position (app->window.self, &app->setting.window.x, &app->setting.window.y); gtk_window_get_size (app->window.self, &app->setting.window.width, &app->setting.window.height); // hide window #ifdef _WIN32 gtk_window_iconify (app->window.self); #endif gtk_widget_hide ((GtkWidget*) app->window.self); } else { #ifdef _WIN32 gtk_widget_show ((GtkWidget*) app->window.self); gtk_window_deiconify (app->window.self); #endif gtk_window_present (app->window.self); ug_app_trayicon_decide_visible (app); } // clear error status if (app->trayicon.error_occurred) { app->trayicon.error_occurred = FALSE; gtk_status_icon_set_from_icon_name (status_icon, UG_APP_GTK_TRAY_ICON_NAME); } } static void on_trayicon_popup_menu (GtkStatusIcon* status_icon, guint button, guint activate_time, UgAppGtk* app) { gtk_menu_set_screen ((GtkMenu*) app->trayicon.menu.self, gtk_status_icon_get_screen (status_icon)); #ifdef _WIN32 gtk_menu_popup ((GtkMenu*) app->trayicon.menu.self, NULL, NULL, NULL, NULL, button, activate_time); #else gtk_menu_popup ((GtkMenu*) app->trayicon.menu.self, NULL, NULL, gtk_status_icon_position_menu, status_icon, button, activate_time); #endif } static void on_trayicon_show_window (GtkWidget* widget, UgAppGtk* app) { if (gtk_widget_get_visible ((GtkWidget*) app->window.self)) gtk_window_present (app->window.self); else { gtk_widget_show ((GtkWidget*) app->window.self); gtk_window_deiconify (app->window.self); gtk_window_present (app->window.self); ug_app_trayicon_decide_visible (app); } } // ---------------------------------------------------------------------------- // UgWindow // button-press-event static gboolean on_button_press_event (GtkTreeView* treeview, GdkEventButton* event, UgAppGtk* app) { GtkTreeSelection* selection; GtkTreePath* path; GtkMenu* menu; gboolean is_selected; // right button press // if (event->type != GDK_BUTTON_PRESS) // return FALSE; if (event->button != 3) // right mouse button return FALSE; // popup a menu if (treeview == app->cwidget.view || treeview == app->cwidget.primary.view) menu = (GtkMenu*) app->menubar.category.self; else if (treeview == app->summary.view) menu = app->summary.menu.self; else menu = (GtkMenu*) app->menubar.download.self; gtk_menu_popup (menu, NULL, NULL, NULL, NULL, event->button, gtk_get_current_event_time()); if (gtk_tree_view_get_path_at_pos (treeview, (gint)event->x, (gint)event->y, &path, NULL, NULL, NULL)) { selection = gtk_tree_view_get_selection (treeview); is_selected = gtk_tree_selection_path_is_selected (selection, path); gtk_tree_path_free (path); if (is_selected) return TRUE; } return FALSE; } // This function is used by on_window_key_press_event() static void menu_position_func (GtkMenu* menu, gint* x, gint* y, gboolean* push_in, gpointer user_data) { GtkRequisition menu_requisition; GtkAllocation allocation; GtkWidget* widget; gint max_x, max_y; widget = user_data; gdk_window_get_origin (gtk_widget_get_window (widget), x, y); gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL); gtk_widget_get_allocation (widget, &allocation); if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) *x += allocation.width - allocation.width / 3; else *x += allocation.width / 3; *y += allocation.height / 3; // if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) // *x += allocation.width - menu_requisition.width; // else // *x += allocation.x; // *y += allocation.y + allocation.height; // Make sure we are on the screen. max_x = MAX (0, gdk_screen_width () - menu_requisition.width); max_y = MAX (0, gdk_screen_height () - menu_requisition.height); *x = CLAMP (*x, 0, max_x); *y = CLAMP (*y, 0, max_y); } // key-press-event static gboolean on_window_key_press_event (GtkWidget *widget, GdkEventKey *event, UgAppGtk* app) { GtkTreeView* focus; GtkMenu* menu; // g_print ("key-press : 0x%x\n", event->keyval); if (event->keyval != GDK_KEY_Menu) return FALSE; focus = (GtkTreeView*) gtk_window_get_focus (app->window.self); if (focus == app->cwidget.primary.view) { widget = (GtkWidget*) app->cwidget.primary.view; menu = (GtkMenu*) app->menubar.category.self; } else if (focus == app->cwidget.view) { widget = (GtkWidget*) app->cwidget.view; menu = (GtkMenu*) app->menubar.category.self; } else if (focus == app->summary.view) { widget = (GtkWidget*) app->summary.view; menu = (GtkMenu*) app->summary.menu.self; } else if (focus == app->cwidget.current.widget->view) { widget = (GtkWidget*) app->cwidget.current.widget->view; menu = (GtkMenu*) app->menubar.download.self; } else return FALSE; gtk_menu_popup (menu, NULL, NULL, menu_position_func, widget, 0, gtk_get_current_event_time()); return TRUE; } // UgWindow.self "delete-event" static gboolean on_window_delete_event (GtkWidget* widget, GdkEvent* event, UgAppGtk* app) { if (app->setting.ui.close_confirmation == FALSE) { ug_app_window_close (app); return TRUE; } ug_app_confirm_to_quit (app); return TRUE; } // UgDownloadWidget.view "key-press-event" static gboolean on_download_key_press_event (GtkWidget* widget, GdkEventKey* event, UgAppGtk* app) { if (event->keyval == GDK_KEY_Delete && app->cwidget.current.category) { on_delete_download (widget, app); return TRUE; } /* // check shift key status GdkWindow* gdk_win; GdkDevice* dev_pointer; GdkModifierType mask; // check shift key status gdk_win = gtk_widget_get_parent_window ((GtkWidget*) app->cwidget.current.widget->view); dev_pointer = gdk_device_manager_get_client_pointer ( gdk_display_get_device_manager (gdk_window_get_display (gdk_win))); gdk_window_get_device_position (gdk_win, dev_pointer, NULL, NULL, &mask); if (app->cwidget.current.category) { switch (event->keyval) { case GDK_KEY_Delete: case GDK_KEY_KP_Delete: if (mask & GDK_SHIFT_MASK) on_delete_download_file (widget, app); else on_delete_download (widget, app); return TRUE; case GDK_KEY_Return: case GDK_KEY_KP_Enter: if (mask & GDK_SHIFT_MASK) on_open_download_folder (widget, app); else on_open_download_file (widget, app); return TRUE; } } */ return FALSE; } // UgDownloadWidget.view selection "changed" static void on_download_selection_changed (GtkTreeSelection* selection, UgAppGtk* app) { UgDownloadWidget* dwidget; dwidget = app->cwidget.current.widget; ug_statusbar_set_info (&app->statusbar, dwidget); ug_app_decide_download_sensitive (app); } // UgDownloadWidget.view "cursor-changed" static void on_download_cursor_changed (GtkTreeView* view, UgAppGtk* app) { UgDownloadWidget* dwidget; UgDataset* dataset; // Add "action.deleted" to avoid crash in GTK+ 3.4. This maybe GTK+ bug. // 1. user delete an iter in GtkTreeModel. // 2. emit "cursor-changed" signal because cursor changed after deleting. // 3. call gtk_tree_view_get_cursor(view, &path) // 4. call gtk_tree_model_get_iter(model, &iter, path) and result TRUE. // 5. call gtk_tree_model_get(model, &iter, ...) may result invalid iter // and crash... if (app->action.deleted == FALSE) { dwidget = app->cwidget.current.widget; dataset = ug_download_widget_get_cursor (dwidget); ug_summary_show (&app->summary, dataset); } } // UgCategoryWidget.view and primary_view "cursor-changed" static void on_category_cursor_changed (GtkTreeView* view, UgAppGtk* app) { UgDownloadWidget* dwidget; GtkTreeSelection* selection; GList* list; // ---------------------------------------------------- // switch UgDownloadWidget in right side dwidget = app->cwidget.current.widget; list = gtk_container_get_children (GTK_CONTAINER (app->window.vpaned)); list = g_list_remove (list, app->summary.self); if (list) { g_object_ref (list->data); gtk_container_remove (GTK_CONTAINER (app->window.vpaned), list->data); g_list_free (list); } gtk_paned_pack1 (app->window.vpaned, dwidget->self, TRUE, TRUE); // connect signals if (dwidget) { if (dwidget->signal_connected == FALSE) { dwidget->signal_connected = TRUE; selection = gtk_tree_view_get_selection (dwidget->view); g_signal_connect (selection, "changed", G_CALLBACK (on_download_selection_changed), app); g_signal_connect (dwidget->view, "cursor-changed", G_CALLBACK (on_download_cursor_changed), app); g_signal_connect (dwidget->view, "key-press-event", G_CALLBACK (on_download_key_press_event), app); g_signal_connect (dwidget->view, "button-press-event", G_CALLBACK (on_button_press_event), app); } // refresh summary ug_summary_show (&app->summary, ug_download_widget_get_cursor (dwidget)); } // refresh ug_app_menubar_sync_category (app, FALSE); ug_statusbar_set_info (&app->statusbar, dwidget); ug_app_reset_download_column (app); ug_app_decide_category_sensitive (app); } // UgSummary.menu.copy signal handler static void on_summary_copy_selected (GtkWidget* widget, UgAppGtk* app) { gchar* text; text = ug_summary_get_text_selected (&app->summary); ug_clipboard_set_text (&app->clipboard, text); } // UgSummary.menu.copy_all signal handler static void on_summary_copy_all (GtkWidget* widget, UgAppGtk* app) { gchar* text; text = ug_summary_get_text_all (&app->summary); ug_clipboard_set_text (&app->clipboard, text); } // ---------------------------------------------------------------------------- // used by ug_app_init_callback() // UgWindow static void ug_window_init_callback (struct UgWindow* window, UgAppGtk* app) { // UgCategoryWidget g_signal_connect_after (app->cwidget.primary.view, "cursor-changed", G_CALLBACK (on_category_cursor_changed), app); g_signal_connect_after (app->cwidget.view, "cursor-changed", G_CALLBACK (on_category_cursor_changed), app); // pop-up menu by mouse button // g_signal_connect (app->cwidget.primary.view, "button-press-event", // G_CALLBACK (on_button_press_event), app); g_signal_connect (app->cwidget.view, "button-press-event", G_CALLBACK (on_button_press_event), app); g_signal_connect (app->summary.view, "button-press-event", G_CALLBACK (on_button_press_event), app); // UgSummary.menu signal handlers g_signal_connect (app->summary.menu.copy, "activate", G_CALLBACK (on_summary_copy_selected), app); g_signal_connect (app->summary.menu.copy_all, "activate", G_CALLBACK (on_summary_copy_all), app); // UgWindow.self signal handlers g_signal_connect (window->self, "key-press-event", G_CALLBACK (on_window_key_press_event), app); g_signal_connect (window->self, "delete-event", G_CALLBACK (on_window_delete_event), app); g_signal_connect_swapped (window->self, "destroy", G_CALLBACK (ug_app_quit), app); } #ifdef _WIN32 static gboolean tray_menu_timeout (GtkMenu* menu) { gtk_menu_popdown (menu); // return FALSE if the source should be removed. return FALSE; } static gboolean tray_menu_leave_enter (GtkWidget* menu, GdkEventCrossing* event, gpointer data) { static guint tray_menu_timer = 0; if (event->type == GDK_LEAVE_NOTIFY && (event->detail == GDK_NOTIFY_ANCESTOR || event->detail == GDK_NOTIFY_UNKNOWN)) { if (tray_menu_timer == 0) { tray_menu_timer = g_timeout_add (500, (GSourceFunc) tray_menu_timeout, menu); } } else if (event->type == GDK_ENTER_NOTIFY && event->detail == GDK_NOTIFY_ANCESTOR) { if (tray_menu_timer != 0) { g_source_remove (tray_menu_timer); tray_menu_timer = 0; } } return FALSE; } #endif // _WIN32 // UgTrayIcon static void ug_trayicon_init_callback (struct UgTrayIcon* icon, UgAppGtk* app) { g_signal_connect (icon->self, "activate", G_CALLBACK (on_trayicon_activate), app); g_signal_connect (icon->self, "popup-menu", G_CALLBACK (on_trayicon_popup_menu), app); #ifdef _WIN32 g_signal_connect (icon->menu.self, "leave-notify-event", G_CALLBACK (tray_menu_leave_enter), NULL); g_signal_connect (icon->menu.self, "enter-notify-event", G_CALLBACK (tray_menu_leave_enter), NULL); #endif g_signal_connect (icon->menu.create_download, "activate", G_CALLBACK (on_create_download), app); g_signal_connect (icon->menu.create_clipboard, "activate", G_CALLBACK (on_create_from_clipboard), app); g_signal_connect (icon->menu.create_torrent, "activate", G_CALLBACK (on_create_torrent), app); g_signal_connect (icon->menu.create_metalink, "activate", G_CALLBACK (on_create_metalink), app); g_signal_connect (icon->menu.settings, "activate", G_CALLBACK (on_config_settings), app); g_signal_connect (icon->menu.show_window, "activate", G_CALLBACK (on_trayicon_show_window), app); g_signal_connect (icon->menu.offline_mode, "toggled", G_CALLBACK (on_offline_mode), app); g_signal_connect (icon->menu.about, "activate", G_CALLBACK (on_about), app); g_signal_connect_swapped (icon->menu.quit, "activate", G_CALLBACK (ug_app_quit), app); } // UgToolbar static void ug_toolbar_init_callback (struct UgToolbar* toolbar, UgAppGtk* app) { // create new g_signal_connect (toolbar->create, "clicked", G_CALLBACK (on_create_download), app); g_signal_connect (toolbar->create_download, "activate", G_CALLBACK (on_create_download), app); g_signal_connect (toolbar->create_category, "activate", G_CALLBACK (on_create_category), app); g_signal_connect (toolbar->create_sequence, "activate", G_CALLBACK (on_create_sequence), app); g_signal_connect (toolbar->create_clipboard, "activate", G_CALLBACK (on_create_from_clipboard), app); g_signal_connect (toolbar->create_torrent, "activate", G_CALLBACK (on_create_torrent), app); g_signal_connect (toolbar->create_metalink, "activate", G_CALLBACK (on_create_metalink), app); // save g_signal_connect_swapped (toolbar->save, "clicked", G_CALLBACK (ug_app_save), app); // change status g_signal_connect (toolbar->runnable, "clicked", G_CALLBACK (on_set_download_runnable), app); g_signal_connect (toolbar->pause, "clicked", G_CALLBACK (on_set_download_to_pause), app); // change data g_signal_connect (toolbar->properties, "clicked", G_CALLBACK (on_config_download), app); // move g_signal_connect (toolbar->move_up, "clicked", G_CALLBACK (on_move_download_up), app); g_signal_connect (toolbar->move_down, "clicked", G_CALLBACK (on_move_download_down), app); g_signal_connect (toolbar->move_top, "clicked", G_CALLBACK (on_move_download_to_top), app); g_signal_connect (toolbar->move_bottom, "clicked", G_CALLBACK (on_move_download_to_bottom), app); } // UgMenubar static void ug_menubar_init_callback (struct UgMenubar* menubar, UgAppGtk* app) { // ---------------------------------------------------- // UgFileMenu g_signal_connect (menubar->file.create.download, "activate", G_CALLBACK (on_create_download), app); g_signal_connect (menubar->file.create.category, "activate", G_CALLBACK (on_create_category), app); g_signal_connect (menubar->file.create.torrent, "activate", G_CALLBACK (on_create_torrent), app); g_signal_connect (menubar->file.create.metalink, "activate", G_CALLBACK (on_create_metalink), app); g_signal_connect (menubar->file.batch.clipboard, "activate", G_CALLBACK (on_create_from_clipboard), app); g_signal_connect (menubar->file.batch.sequence, "activate", G_CALLBACK (on_create_sequence), app); g_signal_connect (menubar->file.batch.text_import, "activate", G_CALLBACK (on_import_text_file), app); g_signal_connect (menubar->file.batch.html_import, "activate", G_CALLBACK (on_import_html_file), app); g_signal_connect (menubar->file.batch.text_export, "activate", G_CALLBACK (on_export_text_file), app); g_signal_connect_swapped (menubar->file.save, "activate", G_CALLBACK (ug_app_save), app); g_signal_connect (menubar->file.offline_mode, "toggled", G_CALLBACK (on_offline_mode), app); g_signal_connect_swapped (menubar->file.quit, "activate", G_CALLBACK (ug_app_quit), app); // ---------------------------------------------------- // UgEditMenu g_signal_connect (menubar->edit.clipboard_monitor, "activate", G_CALLBACK (on_monitor_clipboard), app); g_signal_connect (menubar->edit.clipboard_option, "activate", G_CALLBACK (on_config_clipboard), app); g_signal_connect (menubar->edit.shutdown, "activate", G_CALLBACK (on_config_shutdown), app); g_signal_connect (menubar->edit.settings, "activate", G_CALLBACK (on_config_settings), app); // ---------------------------------------------------- // UgViewMenu g_signal_connect (menubar->view.toolbar, "toggled", G_CALLBACK (on_change_visible_widget), app); g_signal_connect (menubar->view.statusbar, "toggled", G_CALLBACK (on_change_visible_widget), app); g_signal_connect (menubar->view.category, "toggled", G_CALLBACK (on_change_visible_widget), app); g_signal_connect (menubar->view.summary, "toggled", G_CALLBACK (on_change_visible_widget), app); // summary items g_signal_connect (menubar->view.summary_items.name, "toggled", G_CALLBACK (on_change_visible_summary), app); g_signal_connect (menubar->view.summary_items.folder, "toggled", G_CALLBACK (on_change_visible_summary), app); g_signal_connect (menubar->view.summary_items.category, "toggled", G_CALLBACK (on_change_visible_summary), app); g_signal_connect (menubar->view.summary_items.url, "toggled", G_CALLBACK (on_change_visible_summary), app); g_signal_connect (menubar->view.summary_items.message, "toggled", G_CALLBACK (on_change_visible_summary), app); // download columns g_signal_connect (menubar->view.columns.completed, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.total, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.percent, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.elapsed, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.left, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.speed, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.upload_speed, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.uploaded, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.ratio, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.retry, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.category, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.url, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.added_on, "toggled", G_CALLBACK (on_change_visible_column), app); g_signal_connect (menubar->view.columns.completed_on, "toggled", G_CALLBACK (on_change_visible_column), app); // ---------------------------------------------------- // UgCategoryMenu g_signal_connect (menubar->category.create, "activate", G_CALLBACK (on_create_category), app); g_signal_connect (menubar->category.delete, "activate", G_CALLBACK (on_delete_category), app); g_signal_connect (menubar->category.properties, "activate", G_CALLBACK (on_config_category), app); // ---------------------------------------------------- // UgDownloadMenu g_signal_connect (menubar->download.create, "activate", G_CALLBACK (on_create_download), app); g_signal_connect (menubar->download.delete, "activate", G_CALLBACK (on_delete_download), app); // file & folder g_signal_connect (menubar->download.delete_file, "activate", G_CALLBACK (on_delete_download_file), app); g_signal_connect (menubar->download.open, "activate", G_CALLBACK (on_open_download_file), app); g_signal_connect (menubar->download.open_folder, "activate", G_CALLBACK (on_open_download_folder), app); // change status g_signal_connect (menubar->download.force_start, "activate", G_CALLBACK (on_set_download_force_start), app); g_signal_connect (menubar->download.runnable, "activate", G_CALLBACK (on_set_download_runnable), app); g_signal_connect (menubar->download.pause, "activate", G_CALLBACK (on_set_download_to_pause), app); // move g_signal_connect (menubar->download.move_up, "activate", G_CALLBACK (on_move_download_up), app); g_signal_connect (menubar->download.move_down, "activate", G_CALLBACK (on_move_download_down), app); g_signal_connect (menubar->download.move_top, "activate", G_CALLBACK (on_move_download_to_top), app); g_signal_connect (menubar->download.move_bottom, "activate", G_CALLBACK (on_move_download_to_bottom), app); // change data g_signal_connect (menubar->download.properties, "activate", G_CALLBACK (on_config_download), app); // ---------------------------------------------------- // UgHelpMenu g_signal_connect (menubar->help.help_online, "activate", G_CALLBACK (on_help_online), app); g_signal_connect (menubar->help.documentation, "activate", G_CALLBACK (on_documentation), app); g_signal_connect (menubar->help.support_forum, "activate", G_CALLBACK (on_support_forum), app); g_signal_connect (menubar->help.submit_feedback, "activate", G_CALLBACK (on_submit_feedback), app); g_signal_connect (menubar->help.check_updates, "activate", G_CALLBACK (on_check_updates), app); g_signal_connect (menubar->help.report_bug, "activate", G_CALLBACK (on_report_bug), app); g_signal_connect (menubar->help.about_uget, "activate", G_CALLBACK (on_about), app); } uget-1.10.4/uget-gtk/UgCategoryDialog.c0000664000175000017500000000735612260761064014567 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include UgCategoryDialog* ug_category_dialog_new (const gchar* title, GtkWindow* parent) { UgCategoryDialog* cdialog; GtkNotebook* notebook; GtkWidget* vbox; cdialog = g_malloc0 (sizeof (UgCategoryDialog)); cdialog->self = (GtkDialog*) gtk_dialog_new_with_buttons (title, parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (cdialog->self, GTK_RESPONSE_OK); ug_proxy_form_init (&cdialog->proxy); ug_download_form_init (&cdialog->download, &cdialog->proxy, (GtkWindow*) cdialog->self); ug_download_form_set_multiple (&cdialog->download, TRUE); ug_category_form_init (&cdialog->category); notebook = (GtkNotebook*) gtk_notebook_new (); gtk_widget_show ((GtkWidget*) notebook); gtk_notebook_append_page (notebook, cdialog->category.self, gtk_label_new (_("Category settings"))); gtk_notebook_append_page (notebook, cdialog->download.page1, gtk_label_new (_("Default for new download 1"))); gtk_notebook_append_page (notebook, cdialog->download.page2, gtk_label_new (_("Default 2"))); vbox = gtk_dialog_get_content_area (cdialog->self); gtk_box_pack_start ((GtkBox*) vbox, (GtkWidget*) notebook, FALSE, FALSE, 0); gtk_widget_show (vbox); gtk_container_set_focus_child (GTK_CONTAINER (cdialog->self), cdialog->category.name_entry); return cdialog; } void ug_category_dialog_free (UgCategoryDialog* cdialog) { gtk_widget_destroy ((GtkWidget*) cdialog->self); g_free (cdialog); } void ug_category_dialog_get (UgCategoryDialog* cdialog, UgCategory* category) { ug_category_form_get (&cdialog->category, category); if (category->defaults == NULL) category->defaults = ug_dataset_new (); ug_download_form_get (&cdialog->download, category->defaults); ug_proxy_form_get (&cdialog->proxy, category->defaults); } void ug_category_dialog_set (UgCategoryDialog* cdialog, UgCategory* category) { ug_category_form_set (&cdialog->category, category); if (category->defaults) { ug_download_form_set (&cdialog->download, category->defaults, FALSE); ug_proxy_form_set (&cdialog->proxy, category->defaults, FALSE); } } uget-1.10.4/uget-gtk/UgApp-gtk-timeout.c0000664000175000017500000005461112260761064014655 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef HAVE_CONFIG_H #include # if HAVE_LIBNOTIFY # include # endif # if HAVE_GSTREAMER # include # endif #endif #define _CRT_SECURE_NO_WARNINGS #include #ifdef _WIN32 #ifndef _WIN32_IE #define _WIN32_IE 0x0600 #endif #include #include #endif // _End of _WIN32 #include #include #include #include #include #include #include static void ug_app_notify_starting (UgAppGtk* app); static void ug_app_notify_completed (UgAppGtk* app); // GSourceFunc static gboolean ug_app_timeout_ipc (UgAppGtk* app); static gboolean ug_app_timeout_queuing (UgAppGtk* app); static gboolean ug_app_timeout_clipboard (UgAppGtk* app); static gboolean ug_app_timeout_autosave (UgAppGtk* app); void ug_app_init_timeout (UgAppGtk* app) { // 0.5 seconds g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 500, (GSourceFunc) ug_app_timeout_ipc, app, NULL); // 0.5 seconds g_timeout_add_full (G_PRIORITY_DEFAULT_IDLE, 500, (GSourceFunc) ug_running_dispatch, &app->running, NULL); // 1 seconds g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 1, (GSourceFunc) ug_app_timeout_queuing, app, NULL); // 2 seconds g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 2, (GSourceFunc) ug_app_timeout_clipboard, app, NULL); // 1 minutes g_timeout_add_seconds_full (G_PRIORITY_DEFAULT_IDLE, 60, (GSourceFunc) ug_app_timeout_autosave, app, NULL); } static gboolean ug_app_timeout_autosave (UgAppGtk* app) { static guint counts = 0; counts++; // "app->setting.auto_save.interval" may changed by user if (counts >= app->setting.auto_save.interval) { counts = 0; if (app->setting.auto_save.active) ug_app_save (app); } // return FALSE if the source should be removed. return TRUE; } // ---------------------------------------------------------------------------- // Clipboard // static gboolean clipboard_processing = FALSE; static void on_keep_above_window_show (GtkWindow *window, gpointer user_data) { gtk_window_present (window); gtk_window_set_keep_above (window, FALSE); } static void on_add_download_response (GtkDialog *dialog, gint response, UgDownloadDialog* ddialog) { UgCategory* category; UgAppGtk* app; GList* list; GList* link; if (response == GTK_RESPONSE_OK) { app = ddialog->user.app; ug_download_form_get_folder_list (&ddialog->download, &app->setting.folder_list); category = ug_download_dialog_get_category (ddialog); if (category) { list = ug_download_dialog_get_downloads (ddialog); for (link = list; link; link = link->next) ug_category_add (category, link->data); g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); g_list_free (list); gtk_widget_queue_draw ((GtkWidget*) app->cwidget.self); } } ug_download_dialog_free (ddialog); } static void uget_add_uris_selected (UgAppGtk* app, GList* list) { UgDownloadDialog* ddialog; UgSelectorPage* page; gchar* string; if (list->next == NULL) { // only 1 url matched string = g_strconcat (UG_APP_GTK_NAME " - ", _("New from Clipboard"), " (", _("only one matched"), ")", NULL); // ddialog = ug_download_dialog_new (string, app->window.self); ddialog = ug_download_dialog_new (string, NULL); g_free (string); gtk_entry_set_text ((GtkEntry*) ddialog->download.url_entry, list->data); g_free (list->data); } else { string = g_strconcat (UG_APP_GTK_NAME " - ", _("New from Clipboard"), NULL); // ddialog = ug_download_dialog_new (string, app->window.self); ddialog = ug_download_dialog_new (string, NULL); g_free (string); ug_download_dialog_use_selector (ddialog); ug_selector_hide_href (&ddialog->selector); page = ug_selector_add_page (&ddialog->selector, _("Clipboard")); ug_selector_page_add_uris (page, list); } g_list_free (list); ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_add_download_response), ddialog); g_signal_connect_after (ddialog->self, "show", G_CALLBACK (on_keep_above_window_show), NULL); // Make sure dilaog will show on top first time. // uget_on_keep_above_window_show () will set keep_above = FALSE gtk_window_set_keep_above ((GtkWindow*) ddialog->self, TRUE); gtk_widget_show ((GtkWidget*) ddialog->self); } static void uget_add_uris_quietly (UgAppGtk* app, GList* list) { UgCategory* category; UgDataset* dataset; UgetCommon* common; GList* link; // get category if (app->setting.clipboard.nth_category == -1) category = ug_category_view_get_cursor (app->cwidget.view); else { category = ug_category_view_get_nth (app->cwidget.view, app->setting.clipboard.nth_category); } if (category == NULL) category = ug_category_view_get_nth (app->cwidget.view, 0); if (category == NULL) return; // add list to category for (link = list; link; link = link->next) { dataset = ug_dataset_new (); ug_data_assign (dataset, category->defaults); common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); g_free (common->url); common->url = link->data; ug_download_complete_data (dataset); ug_category_add (category, dataset); } g_list_free (list); } static void on_clipboard_text_received (GtkClipboard* clipboard, const gchar* text, gpointer user_data) { UgAppGtk* app; GList* list; app = (UgAppGtk*) user_data; list = ug_clipboard_get_matched (&app->clipboard, text); if (list) { if (app->setting.clipboard.quiet) uget_add_uris_quietly (app, list); else uget_add_uris_selected (app, list); } clipboard_processing = FALSE; } static gboolean ug_app_timeout_clipboard (UgAppGtk* app) { if (app->setting.clipboard.monitor && clipboard_processing == FALSE) { // set FALSE in on_clipboard_text_received() clipboard_processing = TRUE; gtk_clipboard_request_text (app->clipboard.self, on_clipboard_text_received, app); } // return FALSE if the source should be removed. return TRUE; } // ---------------------------------------------------------------------------- // IPC // static void uget_add_download_selected (UgAppGtk* app, GList* list, gint category_index) { UgDownloadDialog* ddialog; UgSelectorPage* page; gchar* string; string = g_strconcat (UG_APP_GTK_NAME " - ", _("New Download"), NULL); // ddialog = ug_download_dialog_new (string, app->window.self); ddialog = ug_download_dialog_new (string, NULL); g_free (string); if (list->next) { ug_download_dialog_set (ddialog, list->data); ug_download_dialog_use_selector (ddialog); ug_selector_hide_href (&ddialog->selector); page = ug_selector_add_page (&ddialog->selector, _("Command line")); ug_selector_page_add_downloads (page, list); } else { ug_download_dialog_set (ddialog, list->data); ddialog->download.changed.url = TRUE; // set external data to UgDownloadDialog ddialog->dataset = list->data; ug_dataset_ref (list->data); } ug_download_form_set_folder_list (&ddialog->download, app->setting.folder_list); ug_download_dialog_set_category (ddialog, &app->cwidget); ug_category_view_set_cursor (ddialog->category_view, category_index, -1); // connect signal and set data in download dialog ddialog->user.app = app; g_signal_connect (ddialog->self, "response", G_CALLBACK (on_add_download_response), ddialog); g_signal_connect_after (ddialog->self, "show", G_CALLBACK (on_keep_above_window_show), NULL); // Make sure dilaog will show on top first time. // uget_on_keep_above_window_show () will set keep_above = FALSE gtk_window_set_keep_above ((GtkWindow*) ddialog->self, TRUE); gtk_widget_show ((GtkWidget*) ddialog->self); } static void uget_add_download_quietly (UgAppGtk* app, GList* list, gint category_index) { UgCategory* category; UgDataset* dataset; GList* link; // get category category = ug_category_view_get_nth (app->cwidget.view, category_index); if (category == NULL) category = ug_category_view_get_cursor (app->cwidget.view); if (category == NULL) return; // add list to category for (link = list; link; link = link->next) { dataset = link->data; ug_data_assign (dataset, category->defaults); ug_download_complete_data (dataset); ug_category_add (category, dataset); } } static gboolean ug_app_timeout_ipc (UgAppGtk* app) { GPtrArray* args; GList* list; gint category_index; args = ug_ipc_pop (&app->ipc); if (args == NULL) return TRUE; // If no argument, program presents main window to the user. if (args->len == 1) { ug_arg_free (args, TRUE); if (gtk_widget_get_visible ((GtkWidget*) app->window.self) == FALSE) gtk_window_deiconify (app->window.self); gtk_window_present (app->window.self); return TRUE; } // get and parse downloads list = ug_option_parse (&app->option, args); ug_arg_free (args, TRUE); // set-offline switch (app->option.data->offline) { case 0: app->setting.offline_mode = FALSE; gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.file.offline_mode, FALSE); break; case 1: app->setting.offline_mode = TRUE; gtk_check_menu_item_set_active ( (GtkCheckMenuItem*) app->menubar.file.offline_mode, TRUE); break; default: break; } // if no data if (list == NULL) return TRUE; // create attachment (backup cookie & post file) if (ug_download_create_attachment (list->data, FALSE) == TRUE) g_list_foreach (list->next, (GFunc) ug_download_assign_attachment, list->data); // add downloads category_index = app->option.data->category_index; if (category_index == -1) category_index = app->setting.commandline.category_index; if (app->option.data->quiet || app->setting.commandline.quiet) uget_add_download_quietly (app, list, category_index); else uget_add_download_selected (app, list, category_index); // free unused downloads g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); g_list_free (list); // return FALSE if the source should be removed. return TRUE; } // ---------------------------------------------------------------------------- // queuing // static void ug_app_launch_default_app (UgDataset* dataset, GRegex* regex) { UgetCommon* common; const gchar* file_ext; common = UG_DATASET_COMMON (dataset); if (common == NULL || common->file == NULL) return; file_ext = strrchr (common->file, G_DIR_SEPARATOR); if (file_ext == NULL) file_ext = common->file; file_ext = strrchr (common->file, '.'); if (file_ext == NULL) return; if (g_regex_match (regex, file_ext + 1, 0, NULL)) ug_launch_default_app (common->folder, common->file); } // scheduler static gboolean ug_app_decide_schedule_state (UgAppGtk* app) { struct tm* timem; time_t timet; guint weekdays, dayhours; gboolean changed; UgScheduleState state; if (app->setting.scheduler.enable == FALSE) { app->schedule_state = UG_SCHEDULE_NORMAL; return FALSE; } // get current time timet = time (NULL); timem = localtime (&timet); dayhours = timem->tm_hour; if (timem->tm_wday == 0) weekdays = 6; else weekdays = timem->tm_wday - 1; // get current schedule state state = app->setting.scheduler.state [weekdays][dayhours]; if (app->schedule_state == state) changed = FALSE; else { app->schedule_state = state; changed = TRUE; // switch mode switch (state) { case UG_SCHEDULE_TURN_OFF: ug_running_clear (&app->running); break; case UG_SCHEDULE_LIMITED_SPEED: // ug_running_set_speed (&app->running, // app->setting.speed_limit.scheduler.download, 0); break; default: // no speed limit ug_running_set_speed (&app->running, 0, 0); break; } } return changed; } // start, stop tasks and refresh information. static gboolean ug_app_timeout_queuing (UgAppGtk* app) { GList* tasks; GList* list; GList* link; gboolean changed; static guint n_before = 0; guint n_after; gint64 down_speed; gint64 up_speed; union { UgetRelation* relation; gchar* string; } temp; // check aria2.failed_count (one shot) if (app->aria2.failed_count == 5) { ug_app_show_message (app, GTK_MESSAGE_ERROR, _("Failed to connect to aria2.\n" "Is aria2 shutdown? or aria2 launch failed.")); } // If changed is TRUE, it will refresh all category-related data. changed = ug_app_decide_schedule_state (app); // do something for inactive tasks tasks = ug_running_get_inactive (&app->running); for (link = tasks; link; link = link->next) { temp.relation = UG_DATASET_RELATION ((UgDataset*) link->data); // This will change tray icon. if (temp.relation->hints & UG_HINT_ERROR) app->trayicon.error_occurred = TRUE; // launch default application if ((temp.relation->hints & UG_HINT_COMPLETED) && app->setting.launch.active) ug_app_launch_default_app (link->data, app->launch_regex); // remove inactive tasks from group ug_running_remove (&app->running, link->data); changed = TRUE; } g_list_free (tasks); // category list list = ug_category_widget_get_list (&app->cwidget); for (link = list; link; link = link->next) { // clear excess downloads if (ug_category_gtk_clear_excess (link->data)) changed = TRUE; // Don't activate tasks if offline mode was enabled or schedule turns off tasks. if (app->setting.offline_mode || app->schedule_state == UG_SCHEDULE_TURN_OFF) continue; // get queuing tasks from categories and activate them tasks = ug_category_gtk_get_tasks (link->data); if (ug_running_add_tasks (&app->running, tasks)) changed = TRUE; g_list_free (tasks); } g_list_free (list); // get number of tasks after queuing n_after = ug_running_get_n_tasks (&app->running); // some tasks was start or stop if (n_before != n_after) { // downloading start if (n_before == 0 && n_after > 0) { // starting notification if (app->setting.ui.start_notification) ug_app_notify_starting (app); } // downloading completed else if (n_before > 0 && n_after == 0) { if (app->action.stop == FALSE) { // completed notification ug_app_notify_completed (app); // shutdown if (app->setting.shutdown) { ug_app_save (app); ug_shutdown (); ug_app_show_message (app, GTK_MESSAGE_INFO, _("This program need root privileges to shutdown.")); } } } // window title if (n_after > 0) { temp.string = g_strdup_printf (UG_APP_GTK_NAME " - %u %s", n_after, _("tasks")); gtk_window_set_title (app->window.self, temp.string); g_free (temp.string); } else gtk_window_set_title (app->window.self, UG_APP_GTK_NAME); // update n_before = n_after; changed = TRUE; } // category or download status changed if (changed || n_after) { // get overall speed // if (app->setting.plugin.aria2.enable == FALSE) ug_running_get_speed (&app->running, &down_speed, &up_speed); // else { // down_speed = app->aria2.download_speed; // up_speed = app->aria2.upload_speed; // } // refresh download info gtk_widget_queue_draw (app->cwidget.current.widget->self); // summary ug_summary_show (&app->summary, ug_download_widget_get_cursor (app->cwidget.current.widget)); // status bar ug_statusbar_set_speed (&app->statusbar, down_speed, up_speed); // tray icon ug_trayicon_set_info (&app->trayicon, n_after, down_speed, up_speed); } // category status changed if (changed) gtk_widget_queue_draw (app->cwidget.self); // reset action status "stop by user" app->action.stop = FALSE; // return FALSE if the source should be removed. return TRUE; } // ---------------------------------------------------------------------------- // sound // static void uget_play_sound (const gchar* sound_file); // GStreamer #ifdef HAVE_GSTREAMER static gboolean ugst_bus_func (GstBus* bus, GstMessage* msg, gpointer data) { GstElement* playbin = data; GError* error = NULL; switch (GST_MESSAGE_TYPE (msg)) { case GST_MESSAGE_WARNING: gst_message_parse_warning (msg, &error, NULL); // g_print ("uget-gtk: gstreamer: %s\n", error->message); g_error_free (error); break; case GST_MESSAGE_ERROR: gst_message_parse_error (msg, &error, NULL); // g_print ("uget-gtk: gstreamer: %s\n", error->message); g_error_free (error); // clean up case GST_MESSAGE_EOS: gst_element_set_state (playbin, GST_STATE_NULL); gst_object_unref (GST_OBJECT (playbin)); break; default: break; } return TRUE; } static void uget_play_sound (const gchar* sound_file) { GstElement* playbin = NULL; GstBus* bus = NULL; char* uri; gchar* file_os; extern gboolean gst_inited; // uget-gtk/main.c if (gst_inited == FALSE) return; file_os = g_filename_from_utf8 (sound_file, -1, NULL, NULL, NULL); if (g_file_test (file_os, G_FILE_TEST_EXISTS) == FALSE) { g_free (file_os); return; } playbin = gst_element_factory_make ("playbin", "play"); if (playbin == NULL) { g_free (file_os); return; } uri = g_filename_to_uri (file_os, NULL, NULL); g_free (file_os); g_object_set (G_OBJECT (playbin), "uri", uri, NULL); bus = gst_pipeline_get_bus (GST_PIPELINE (playbin)); gst_bus_add_watch (bus, ugst_bus_func, playbin); gst_element_set_state (playbin, GST_STATE_PLAYING); gst_object_unref (bus); g_free (uri); } #elif defined (_WIN32) static void uget_play_sound (const gchar* sound_file) { gunichar2* file_wcs; if (g_file_test (sound_file, G_FILE_TEST_EXISTS) == FALSE) return; file_wcs = g_utf8_to_utf16 (sound_file, -1, NULL, NULL, NULL); PlaySoundW (file_wcs, NULL, SND_ASYNC | SND_FILENAME); g_free (file_wcs); } #else // --disable-gstreamer static void uget_play_sound (const gchar* sound_file) { } #endif // HAVE_GSTREAMER // ---------------------------------------------------------------------------- // notification // #ifdef HAVE_LIBNOTIFY static void ug_app_notify (UgAppGtk* app, const gchar* title, const gchar* body) { static NotifyNotification* notification = NULL; gchar* string; if (notify_is_initted () == FALSE) return; // set title and body string = g_strconcat (UG_APP_GTK_NAME " - ", title, NULL); if (notification == NULL) { #if defined (NOTIFY_VERSION_MINOR) && NOTIFY_VERSION_MAJOR >= 0 && NOTIFY_VERSION_MINOR >= 7 notification = notify_notification_new (string, body, UG_APP_GTK_APP_ICON_NAME); #else notification = notify_notification_new (string, body, UG_APP_GTK_APP_ICON_NAME, NULL); #endif notify_notification_set_timeout (notification, 7000); // milliseconds } else { notify_notification_update (notification, string, body, UG_APP_GTK_TRAY_ICON_NAME); } g_free (string); notify_notification_show (notification, NULL); } #elif defined (_WIN32) static void ug_app_notify (UgAppGtk* app, const gchar* title, const gchar* body) { static NOTIFYICONDATAW* pNotifyData = NULL; gchar* string; gunichar2* string_wcs; if (pNotifyData == NULL) { pNotifyData = g_malloc0 (sizeof (NOTIFYICONDATAW)); pNotifyData->cbSize = sizeof (NOTIFYICONDATAW); pNotifyData->uFlags = NIF_INFO; // Use a balloon ToolTip instead of a standard ToolTip. pNotifyData->uTimeout = 7000; // milliseconds, This member is deprecated as of Windows Vista. pNotifyData->dwInfoFlags = NIIF_INFO | NIIF_NOSOUND; // Add an information icon to balloon ToolTip. // gtkstatusicon.c // (create_tray_observer): WNDCLASS.lpszClassName = "gtkstatusicon-observer" pNotifyData->hWnd = FindWindowA ("gtkstatusicon-observer", NULL); } if (pNotifyData->hWnd == NULL) return; // gtkstatusicon.c // (gtk_status_icon_init): priv->nid.uID = GPOINTER_TO_UINT (status_icon); pNotifyData->uID = GPOINTER_TO_UINT (app->trayicon.self); // title string = g_strconcat (UG_APP_GTK_NAME " - ", title, NULL); string_wcs = g_utf8_to_utf16 (string, -1, NULL, NULL, NULL); wcsncpy (pNotifyData->szInfoTitle, string_wcs, 64 -1); // null-terminated g_free (string); g_free (string_wcs); // body string_wcs = g_utf8_to_utf16 (body, -1, NULL, NULL, NULL); wcsncpy (pNotifyData->szInfo, string_wcs, 256 -1); // null-terminated g_free (string_wcs); Shell_NotifyIconW (NIM_MODIFY, pNotifyData); } #else static void ug_app_notify (UgAppGtk* app, const gchar* title, const gchar* info) { // do nothing } #endif // HAVE_LIBNOTIFY #define NOTIFICATION_STARTING_TITLE _("Download Starting") #define NOTIFICATION_STARTING_STRING _("Starting download queue.") #define NOTIFICATION_COMPLETED_TITLE _("Download Completed") #define NOTIFICATION_COMPLETED_STRING _("All queuing downloads have been completed.") static void ug_app_notify_completed (UgAppGtk* app) { gchar* path; ug_app_notify (app, NOTIFICATION_COMPLETED_TITLE, NOTIFICATION_COMPLETED_STRING); if (app->setting.ui.sound_notification) { path = g_build_filename (ug_get_data_dir (), "sounds", "uget", "notification.wav", NULL); uget_play_sound (path); g_free (path); } } static void ug_app_notify_starting (UgAppGtk* app) { // gchar* path; ug_app_notify (app, NOTIFICATION_STARTING_TITLE, NOTIFICATION_STARTING_STRING); // path = g_build_filename (ug_get_data_dir (), "sounds", "uget", // "notification.wav", NULL); // uget_play_sound (path); // g_free (path); } uget-1.10.4/uget-gtk/UgScheduleForm.c0000664000175000017500000003404412260761064014244 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #define GRID_FONT_SIZE 10 #define GRID_WIDTH 14 #define GRID_HEIGHT 16 #define GRID_WIDTH_LINE (GRID_WIDTH + 1) #define GRID_HEIGHT_LINE (GRID_HEIGHT + 1) #define GRID_WIDTH_ALL (GRID_WIDTH_LINE * 24 + 1) #define GRID_HEIGHT_ALL (GRID_HEIGHT_LINE * 7 + 1) #define COLOR_DISABLE_R 0.5 #define COLOR_DISABLE_G 0.5 #define COLOR_DISABLE_B 0.5 static const gdouble colors[UG_SCHEDULE_N_STATE][3] = { {1.0, 1.0, 1.0}, // UG_SCHEDULE_TURN_OFF {1.0, 0.752, 0.752}, // UG_SCHEDULE_UPLOAD_ONLY - reserve {0.552, 0.807, 0.552}, // UG_SCHEDULE_LIMITED_SPEED // {0.0, 0.658, 0.0}, // UG_SCHEDULE_NORMAL {0.0, 0.758, 0.0}, // UG_SCHEDULE_NORMAL }; static const gchar* week_days[7] = { N_("Mon"), N_("Tue"), N_("Wed"), N_("Thu"), N_("Fri"), N_("Sat"), N_("Sun"), }; // grid one static GtkWidget* ug_grid_one_new (const gdouble* rgb_array); static gboolean ug_grid_one_draw (GtkWidget* widget, cairo_t* cr, const gdouble* rgb_array); // signal handler static void on_enable_toggled (GtkToggleButton* togglebutton, struct UgScheduleForm* sform); static gboolean on_draw_callback (GtkWidget* widget, cairo_t* cr, struct UgScheduleForm* sform); static gboolean on_button_press_event (GtkWidget* widget, GdkEventMotion* event, struct UgScheduleForm* sform); static gboolean on_motion_notify_event (GtkWidget* widget, GdkEventMotion* event, struct UgScheduleForm* sform); static gboolean on_leave_notify_event (GtkWidget* menu, GdkEventCrossing* event, struct UgScheduleForm* sform); void ug_schedule_form_init (struct UgScheduleForm* sform) { GtkWidget* widget; GtkGrid* caption; GtkBox* hbox; GtkBox* vbox; sform->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); vbox = (GtkBox*) sform->self; // Enable Scheduler hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*)hbox, FALSE, FALSE, 2); widget = gtk_check_button_new_with_mnemonic (_("_Enable Scheduler")); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 2); gtk_box_pack_start (hbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 2); g_signal_connect (widget, "toggled", G_CALLBACK (on_enable_toggled), sform); sform->enable = widget; // drawing area widget = gtk_drawing_area_new (); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 2); // gtk_widget_set_has_window (widget, FALSE); gtk_widget_set_size_request (widget, GRID_WIDTH_ALL + 32, GRID_HEIGHT_ALL); gtk_widget_add_events (widget, GDK_BUTTON_PRESS_MASK | GDK_POINTER_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); g_signal_connect (widget, "draw", G_CALLBACK (on_draw_callback), sform); g_signal_connect (widget, "button-press-event", G_CALLBACK (on_button_press_event), sform); g_signal_connect (widget, "motion-notify-event", G_CALLBACK (on_motion_notify_event), sform); g_signal_connect (widget, "leave-notify-event", G_CALLBACK (on_leave_notify_event), sform); sform->drawing = widget; // grid for tips, SpinButton sform->caption = gtk_grid_new (); gtk_box_pack_start (vbox, sform->caption, FALSE, FALSE, 2); // gtk_container_set_border_width (GTK_CONTAINER (sform->caption), 10); caption = (GtkGrid*) sform->caption; // time tips widget = gtk_label_new (""); gtk_misc_set_alignment (GTK_MISC (widget), (gfloat)0.4, (gfloat)0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 0, 0, 5, 1); sform->time_tips = GTK_LABEL (widget); // Turn off - gridone widget = ug_grid_one_new (colors[UG_SCHEDULE_TURN_OFF]); g_object_set (widget, "margin", 3, NULL); gtk_grid_attach (caption, widget, 0, 1, 1, 1); // Turn off - label widget = gtk_label_new (_("Turn off")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 1, 1, 1, 1); // Turn off - help label widget = gtk_label_new (_("- stop all task")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 2, 1, 2, 1); // Normal - gridone widget = ug_grid_one_new (colors[UG_SCHEDULE_NORMAL]); g_object_set (widget, "margin", 3, NULL); gtk_grid_attach (caption, widget, 0, 2, 1, 1); // Normal - label widget = gtk_label_new (_("Normal")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 1, 2, 1, 1); // Normal - help label widget = gtk_label_new (_("- run task normally")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 2, 2, 2, 1); /* // Speed limit - gridone widget = ug_grid_one_new (colors[UG_SCHEDULE_LIMITED_SPEED]); g_object_set (widget, "margin", 3, NULL); gtk_grid_attach (caption, widget, 0, 3, 1, 1); // Speed limit - label widget = gtk_label_new (_("Limited speed")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 1, 3, 1, 1); // Speed limit - SpinButton widget = gtk_spin_button_new_with_range (5, 99999999, 1); g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 2, 3, 1, 1); sform->spin_speed = (GtkSpinButton*) widget; // Speed limit - KiB/s label widget = gtk_label_new (_("KiB/s")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, NULL); gtk_grid_attach (caption, widget, 3, 3, 1, 1); */ // change sensitive state gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sform->enable), FALSE); gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (sform->enable)); gtk_widget_show_all (sform->self); } void ug_schedule_form_get (struct UgScheduleForm* sform, UgSetting* setting) { // gint value; memcpy (setting->scheduler.state, sform->state, sizeof (setting->scheduler.state)); setting->scheduler.enable = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (sform->enable)); // value = gtk_spin_button_get_value_as_int (sform->spin_speed); // setting->scheduler.speed_limit = value * 1024; } void ug_schedule_form_set (struct UgScheduleForm* sform, UgSetting* setting) { // gint value; memcpy (sform->state, setting->scheduler.state, sizeof (sform->state)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sform->enable), setting->scheduler.enable); gtk_toggle_button_toggled (GTK_TOGGLE_BUTTON (sform->enable)); // value = setting->scheduler.speed_limit / 1024; // gtk_spin_button_set_value (sform->spin_speed, value); } // ---------------------------------------------------------------------------- // signal handler // static void on_enable_toggled (GtkToggleButton* togglebutton, struct UgScheduleForm* sform) { gboolean active; active = gtk_toggle_button_get_active (togglebutton); gtk_widget_set_sensitive (sform->drawing, active); gtk_widget_set_sensitive (sform->caption, active); } static gboolean on_draw_callback (GtkWidget* widget, cairo_t* cr, struct UgScheduleForm* sform) { gboolean sensitive; gint y, x; gdouble cy, cx, ox; PangoContext* context; PangoLayout* layout; PangoFontDescription* desc; cairo_set_line_width (cr, 1); sensitive = gtk_widget_get_sensitive (widget); // setup Pango context = gtk_widget_get_pango_context (widget); desc = pango_context_get_font_description (context); layout = pango_cairo_create_layout (cr); pango_layout_set_font_description (layout, desc); // week days // ox = x offset for (ox = 0, cy = 0.5, y = 0; y < 7; y++, cy+=GRID_HEIGHT_LINE) { cairo_move_to (cr, 1, cy); pango_layout_set_text (layout, gettext (week_days[y]), -1); pango_cairo_update_layout (cr, layout); pango_cairo_show_layout (cr, layout); pango_layout_get_size (layout, &x, NULL); x /= PANGO_SCALE; if (x + 4 > ox) ox = x + 4; } g_object_unref (layout); if (sform->drawing_offset == 0) sform->drawing_offset = ox; // draw grid columns for (cx = 0.5; cx <= GRID_WIDTH_ALL; cx += GRID_WIDTH_LINE) { cairo_move_to (cr, ox + cx, 0 + 0.5); cairo_line_to (cr, ox + cx, GRID_HEIGHT_ALL - 1.0 + 0.5); } // draw grid rows for (cy = 0.5; cy <= GRID_HEIGHT_ALL; cy += GRID_HEIGHT_LINE) { cairo_move_to (cr, ox + 0.5, cy); cairo_line_to (cr, ox + GRID_WIDTH_ALL - 1.0 + 0.5, cy); } cairo_stroke (cr); // fill grid if (sensitive == FALSE) { cairo_set_source_rgb (cr, COLOR_DISABLE_R, COLOR_DISABLE_G, COLOR_DISABLE_B); } for (cy = 1.5, y = 0; y < 7; y++, cy+=GRID_HEIGHT_LINE) { for (cx = 1.5+ox, x = 0; x < 24; x++, cx+=GRID_WIDTH_LINE) { if (sensitive) { cairo_set_source_rgb (cr, colors [sform->state[y][x]][0], colors [sform->state[y][x]][1], colors [sform->state[y][x]][2]); } cairo_rectangle (cr, cx, cy, GRID_WIDTH - 0.5, GRID_HEIGHT - 0.5); cairo_fill (cr); } } return FALSE; } static gboolean on_button_press_event (GtkWidget *widget, GdkEventMotion *event, struct UgScheduleForm* sform) { gint x, y; cairo_t* cr; UgScheduleState state; x = (event->x - sform->drawing_offset) / GRID_WIDTH_LINE; y = event->y / GRID_HEIGHT_LINE; if (x < 0 || y < 0 || x >= 24 || y >= 7) return FALSE; state = (sform->state[y][x] == UG_SCHEDULE_TURN_OFF) ? UG_SCHEDULE_NORMAL : UG_SCHEDULE_TURN_OFF; // state = sform->state[y][x] + 1; // if (state == UG_SCHEDULE_UPLOAD_ONLY) // state++; // if (state > UG_SCHEDULE_NORMAL) // state = UG_SCHEDULE_TURN_OFF; sform->state[y][x] = state; sform->last_state = state; // cairo cr = gdk_cairo_create (gtk_widget_get_window (widget)); cairo_set_source_rgb (cr, colors [state][0], colors [state][1], colors [state][2]); cairo_rectangle (cr, (gdouble)x * GRID_WIDTH_LINE + 1.0 + 0.5 + sform->drawing_offset, (gdouble)y * GRID_HEIGHT_LINE + 1.0 + 0.5, GRID_WIDTH - 0.5, GRID_HEIGHT - 0.5); cairo_fill (cr); cairo_destroy (cr); return TRUE; } static gboolean on_motion_notify_event (GtkWidget *widget, GdkEventMotion *event, struct UgScheduleForm* sform) { gint x, y; gchar* string; cairo_t* cr; GdkWindow* gdkwin; GdkModifierType mod; UgScheduleState state; gdkwin = gtk_widget_get_window (widget); gdk_window_get_device_position (gdkwin, event->device, &x, &y, &mod); x -= sform->drawing_offset; x /= GRID_WIDTH_LINE; y /= GRID_HEIGHT_LINE; if (x < 0 || y < 0 || x >= 24 || y >= 7) { // clear time_tips gtk_label_set_text (sform->time_tips, ""); return FALSE; } // update time_tips string = g_strdup_printf ("%s, %.2d:00 - %.2d:59", gettext (week_days[y]), x, x); gtk_label_set_text (sform->time_tips, string); g_free (string); // if no button press if ((mod & GDK_BUTTON1_MASK) == 0) return FALSE; state = sform->last_state; sform->state[y][x] = state; // cairo cr = gdk_cairo_create (gdkwin); cairo_rectangle (cr, sform->drawing_offset, 0, GRID_WIDTH_ALL, GRID_HEIGHT_ALL); cairo_clip (cr); cairo_set_source_rgb (cr, colors [state][0], colors [state][1], colors [state][2]); cairo_rectangle (cr, (gdouble)x * GRID_WIDTH_LINE + 1.0 + 0.5 + sform->drawing_offset, (gdouble)y * GRID_HEIGHT_LINE + 1.0 + 0.5, GRID_WIDTH - 0.5, GRID_HEIGHT - 0.5); cairo_fill (cr); cairo_destroy (cr); return TRUE; } static gboolean on_leave_notify_event (GtkWidget* menu, GdkEventCrossing* event, struct UgScheduleForm* sform) { gtk_label_set_text (sform->time_tips, ""); return TRUE; } // ---------------------------------------------------------------------------- // grid one // static GtkWidget* ug_grid_one_new (const gdouble* rgb_array) { GtkWidget* widget; widget = gtk_drawing_area_new (); gtk_widget_set_size_request (widget, GRID_WIDTH + 2, GRID_HEIGHT + 2); gtk_widget_add_events (widget, GDK_POINTER_MOTION_MASK); g_signal_connect (widget, "draw", G_CALLBACK (ug_grid_one_draw), (gpointer) rgb_array); return widget; } static gboolean ug_grid_one_draw (GtkWidget* widget, cairo_t* cr, const gdouble* rgb_array) { GtkAllocation allocation; gdouble x, y, width, height; gtk_widget_get_allocation (widget, &allocation); x = 0.5; y = 0.5; width = (gdouble) (allocation.width - 1); height = (gdouble) (allocation.height - 1); cairo_set_line_width (cr, 1); cairo_rectangle (cr, x, y, width, height); cairo_stroke (cr); if (gtk_widget_get_sensitive (widget)) { cairo_set_source_rgb (cr, rgb_array [0], rgb_array [1], rgb_array [2]); } else { cairo_set_source_rgb (cr, COLOR_DISABLE_R, COLOR_DISABLE_G, COLOR_DISABLE_B); } cairo_rectangle (cr, x + 1.0, y + 1.0, width - 2.0, height - 2.0); cairo_fill (cr); return FALSE; } uget-1.10.4/uget-gtk/UgCategoryForm.c0000664000175000017500000001346312260761064014267 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include void ug_category_form_init (UgCategoryForm* cform) { GtkWidget* label; GtkGrid* top_grid; GtkGrid* grid; cform->self = gtk_grid_new (); top_grid = (GtkGrid*) cform->self; gtk_container_set_border_width (GTK_CONTAINER (top_grid), 2); cform->name_entry = gtk_entry_new (); cform->name_label = gtk_label_new_with_mnemonic (_("Category _name:")); gtk_entry_set_activates_default (GTK_ENTRY (cform->name_entry), TRUE); gtk_label_set_mnemonic_widget (GTK_LABEL (cform->name_label), cform->name_entry); g_object_set (cform->name_label, "margin", 2, NULL); g_object_set (cform->name_entry, "margin", 2, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, cform->name_label, 0, 0, 1, 1); gtk_grid_attach (top_grid, cform->name_entry, 1, 0, 1, 1); // option table grid = (GtkGrid*) gtk_grid_new (); g_object_set (grid, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (top_grid, GTK_WIDGET (grid), 0, 1, 2, 1); cform->spin_active = gtk_spin_button_new_with_range (1.0, 20.0, 1.0); gtk_entry_set_width_chars (GTK_ENTRY(cform->spin_active), 4); label = gtk_label_new_with_mnemonic (_("Active _downloads:")); gtk_label_set_mnemonic_widget (GTK_LABEL(label), cform->spin_active); g_object_set (label, "margin", 2, NULL); g_object_set (cform->spin_active, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (grid, label, 0, 0, 1, 1); gtk_grid_attach (grid, cform->spin_active, 1, 0, 1, 1); cform->spin_finished = gtk_spin_button_new_with_range (0.0, 9999.0, 1.0); label = gtk_label_new_with_mnemonic (_("Capacity of Finished:")); gtk_label_set_mnemonic_widget (GTK_LABEL(label), cform->spin_finished); gtk_entry_set_width_chars (GTK_ENTRY(cform->spin_finished), 4); g_object_set (label, "margin", 2, NULL); g_object_set (cform->spin_finished, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (grid, label, 0, 1, 1, 1); gtk_grid_attach (grid, cform->spin_finished, 1, 1, 1, 1); cform->spin_recycled = gtk_spin_button_new_with_range (0.0, 9999.0, 1.0); label = gtk_label_new_with_mnemonic (_("Capacity of Recycled:")); gtk_label_set_mnemonic_widget (GTK_LABEL(label), cform->spin_recycled); gtk_entry_set_width_chars (GTK_ENTRY(cform->spin_recycled), 4); g_object_set (label, "margin", 2, NULL); g_object_set (cform->spin_recycled, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (grid, label, 0, 2, 1, 1); gtk_grid_attach (grid, cform->spin_recycled, 1, 2, 1, 1); gtk_widget_show_all (GTK_WIDGET (top_grid)); } void ug_category_form_get (UgCategoryForm* cform, UgCategory* category) { // category = category->queuing; // ug_category_dialog_get() has do this if (gtk_widget_is_sensitive (cform->name_entry) == TRUE) ug_str_set (&category->name, gtk_entry_get_text ((GtkEntry*) cform->name_entry), -1); category->active_limit = gtk_spin_button_get_value_as_int ((GtkSpinButton*) cform->spin_active); // Finished category->finished_limit = gtk_spin_button_get_value_as_int ((GtkSpinButton*) cform->spin_finished); // Recycled category->recycled_limit = gtk_spin_button_get_value_as_int ((GtkSpinButton*) cform->spin_recycled); } void ug_category_form_set (UgCategoryForm* cform, UgCategory* category) { // category = category->queuing; // ug_category_dialog_get() has do this if (gtk_widget_is_sensitive (cform->name_entry) == TRUE) gtk_entry_set_text ((GtkEntry*) cform->name_entry, (category->name) ? category->name : ""); gtk_spin_button_set_value ((GtkSpinButton*) cform->spin_active, (gdouble) category->active_limit); // Finished gtk_spin_button_set_value ((GtkSpinButton*) cform->spin_finished, (gdouble) category->finished_limit); // Recycled gtk_spin_button_set_value ((GtkSpinButton*) cform->spin_recycled, (gdouble) category->recycled_limit); } void ug_category_form_set_multiple (UgCategoryForm* cform, gboolean multiple_mode) { if (multiple_mode) { gtk_widget_hide (cform->name_entry); gtk_widget_hide (cform->name_label); gtk_widget_set_sensitive (cform->name_entry, FALSE); gtk_widget_set_sensitive (cform->name_label, FALSE); } else { gtk_widget_show (cform->name_entry); gtk_widget_show (cform->name_label); gtk_widget_set_sensitive (cform->name_entry, TRUE); gtk_widget_set_sensitive (cform->name_label, TRUE); } } uget-1.10.4/uget-gtk/Makefile.am0000664000175000017500000000251012245116260013244 00000000000000bin_PROGRAMS = uget-gtk UGET_GTK_LIBS = @GTK_LIBS@ @GIO_LIBS@ @GTHREAD_LIBS@ @CURL_LIBS@ @GNUTLS_LIBS@ @LIBNOTIFY_LIBS@ @APP_INDICATOR_LIBS@ @GSTREAMER_LIBS@ @LIBPWMD_LIBS@ # set the include path found by configure uget_gtk_CPPFLAGS = -DDATADIR='"$(datadir)"' -I$(top_srcdir)/uglib -I$(top_srcdir)/uget-gtk uget_gtk_CFLAGS = @LFS_CFLAGS@ @GTK_CFLAGS@ @GIO_CFLAGS@ @GTHREAD_CFLAGS@ @CURL_CFLAGS@ @GNUTLS_CFLAGS@ @LIBNOTIFY_CFLAGS@ @APP_INDICATOR_CFLAGS@ @GSTREAMER_CFLAGS@ @LIBPWMD_CFLAGS@ uget_gtk_LDFLAGS = @LFS_LDFLAGS@ uget_gtk_LDADD = $(top_builddir)/uglib/libuglib.a $(UGET_GTK_LIBS) uget_gtk_SOURCES = UgSetting.c \ UgSelector.c UgSummary.c UgSettingForm.c UgScheduleForm.c UgBanner.c \ UgDownloadForm.c UgCategoryForm.c UgProxyForm.c UgBatchForm.c \ UgDownloadWidget.c UgCategoryWidget.c UgCategory-gtk.c \ UgDownloadDialog.c UgCategoryDialog.c UgSettingDialog.c \ UgApp-gtk.c UgApp-gtk-gui.c UgApp-gtk-aria2.c \ UgApp-gtk-callback.c UgApp-gtk-timeout.c \ UgApp-gtk-main.c noinst_HEADERS = UgSetting.h \ UgSelector.h UgSummary.h UgSettingForm.h UgScheduleForm.h UgBanner.h \ UgDownloadForm.h UgCategoryForm.h UgProxyForm.h UgBatchForm.h \ UgDownloadWidget.h UgCategoryWidget.h UgCategory-gtk.h \ UgDownloadDialog.h UgCategoryDialog.h UgSettingDialog.h \ UgApp-gtk.h uget-1.10.4/uget-gtk/UgCategory-gtk.h0000664000175000017500000001063612260761064014232 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_CATEGORY_GTK_H #define UG_CATEGORY_GTK_H #include #include #include #ifdef __cplusplus extern "C" { #endif #define UG_CATEGORY_GTK(category) ((UgCategoryGtk*) (category)->user.category) #define UG_RELATION_GTK_CATEGORY(relation) ((UgCategoryGtk*) (relation)->user.category) #define UG_RELATION_GTK_LISTSTORE(relation) ((GtkListStore*) (relation)->user.storage) #define UG_RELATION_GTK_TREEITER(relation) ((GtkTreeIter*) (relation)->user.position) #define UG_RELATION_GTK_DLWIDGET(relation) ((UgDownloadWidget*) (relation)->user.data) // ---------------------------------------------------------------------------- // UgCategoryGtk: additional data for UgCategory and GTK+ // typedef struct UgCategoryGtk UgCategoryGtk; struct UgCategoryGtk { UgCategoryGtk* primary; // if it is NULL, this category is primary. GtkListStore* store; // Only primary category has this. GtkTreeModel* filter; // model or filter for primary.store UgDownloadWidget all; // GtkTreeModelSort UgDownloadWidget active; // GtkTreeModelFilter UgDownloadWidget queuing; // GtkTreeModelFilter UgDownloadWidget finished; // GtkTreeModelFilter UgDownloadWidget recycled; // GtkTreeModelFilter // iterator for UgCategoryWidget.store GtkTreeIter tree_iter; }; // If primary == NULL, this category will be a primary category. // One uget-gtk program has only one primary category. // All dataset store in primary category. // Other categories use filter to classify dataset in primary category. UgCategory* ug_category_new_with_gtk (UgCategory* primary); // set additional data and functions to UgCategory. void ug_category_use_gtk (UgCategory* category, UgCategory* primary); // functions will be used by UgCategoryFuncs (UgCategory::funcs) void ug_category_gtk_add (UgCategory* category, UgDataset* dataset); GList* ug_category_gtk_get_all (UgCategory* category); GList* ug_category_gtk_get_tasks (UgCategory* category); void ug_category_gtk_changed (UgCategory* category, UgDataset* dataset); // other functions used by uget-gtk void ug_category_gtk_remove (UgCategory* category, UgDataset* dataset); void ug_category_gtk_clear (UgCategory* category, UgCategoryHints hint, guint from_nth); void ug_category_gtk_move_to (UgCategory* category, UgDataset* dataset, UgCategory* cdest); gboolean ug_category_gtk_move_selected_up (UgCategory* category, UgDownloadWidget* dlwidget); gboolean ug_category_gtk_move_selected_down (UgCategory* category, UgDownloadWidget* dlwidget); gboolean ug_category_gtk_move_selected_to_top (UgCategory* category, UgDownloadWidget* dlwidget); gboolean ug_category_gtk_move_selected_to_bottom (UgCategory* category, UgDownloadWidget* dlwidget); // If no data cleared, return FALSE. gboolean ug_category_gtk_clear_excess (UgCategory* category); #ifdef __cplusplus } #endif #endif // UG_CATEGORY_GTK_H uget-1.10.4/uget-gtk/UgDownloadForm.c0000664000175000017500000011627212260761064014263 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include #include #include // UG_APP_GTK_NAME #include // UgAppGtk::aria2 #include static void ug_download_form_init_page1 (UgDownloadForm* dform, UgProxyForm* proxy); static void ug_download_form_init_page2 (UgDownloadForm* dform); static void ug_download_form_decide_sensitive (UgDownloadForm* dform); // aria2 // signal handler static void on_spin_changed (GtkEditable *editable, UgDownloadForm* dform); static void on_entry_changed (GtkEditable *editable, UgDownloadForm* dform); static void on_url_entry_changed (GtkEditable *editable, UgDownloadForm* dform); static void on_http_entry_changed (GtkEditable *editable, UgDownloadForm* dform); static void on_select_folder (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgDownloadForm* dform); static void on_select_cookie (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgDownloadForm* dform); static void on_select_post (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgDownloadForm* dform); void ug_download_form_init (UgDownloadForm* dform, UgProxyForm* proxy, GtkWindow* parent) { dform->changed.enable = TRUE; dform->changed.url = FALSE; dform->changed.file = FALSE; dform->changed.folder = FALSE; dform->changed.user = FALSE; dform->changed.password = FALSE; dform->changed.referrer = FALSE; dform->changed.cookie = FALSE; dform->changed.post = FALSE; dform->changed.agent = FALSE; dform->changed.retry = FALSE; dform->changed.delay = FALSE; dform->changed.retrieve_timestamp= FALSE; dform->parent = parent; ug_download_form_init_page1 (dform, proxy); ug_download_form_init_page2 (dform); ug_download_form_decide_sensitive (dform); // for aria2 gtk_widget_show_all (dform->page1); gtk_widget_show_all (dform->page2); } GtkWidget* ug_download_from_use_notebook (UgDownloadForm* dform, const gchar* label1, const gchar* label2) { GtkWidget* widget; GtkNotebook* notebook; label1 = (label1) ? label1 : _("General"); label2 = (label2) ? label2 : _("Advanced"); widget = gtk_notebook_new (); gtk_widget_show (widget); notebook = (GtkNotebook*) widget; gtk_notebook_append_page (notebook, dform->page1, gtk_label_new (label1)); gtk_notebook_append_page (notebook, dform->page2, gtk_label_new (label2)); return widget; } static void ug_download_form_init_page1 (UgDownloadForm* dform, UgProxyForm* proxy) { GtkWidget* widget; GtkGrid* top_grid; GtkGrid* grid; GtkWidget* frame; GtkWidget* vbox; GtkWidget* hbox; dform->page1 = gtk_grid_new (); top_grid = (GtkGrid*) dform->page1; gtk_container_set_border_width (GTK_CONTAINER (top_grid), 2); // URL - entry widget = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (widget), 20); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin-left", 1, "margin-right", 1, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); g_object_set (widget, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 0, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_url_entry_changed), dform); dform->url_entry = widget; // URL - label widget = gtk_label_new_with_mnemonic (_("_URL:")); gtk_label_set_mnemonic_widget (GTK_LABEL(widget), dform->url_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (top_grid, widget, 0, 0, 1, 1); dform->url_label = widget; // Mirrors - entry widget = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (widget), 20); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin-left", 1, "margin-right", 1, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); g_object_set (widget, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 1, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_url_entry_changed), dform); dform->mirrors_entry = widget; // Mirrors - label widget = gtk_label_new_with_mnemonic (_("Mirrors:")); gtk_label_set_mnemonic_widget (GTK_LABEL(widget), dform->mirrors_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 2, "margin-bottom", 2, NULL); gtk_grid_attach (top_grid, widget, 0, 1, 1, 1); dform->mirrors_label = widget; // File - entry widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 2, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); dform->file_entry = widget; // File - label widget = gtk_label_new_with_mnemonic (_("File:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->file_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (top_grid, widget, 0, 2, 1, 1); dform->file_label = widget; // Folder - combo entry + icon dform->folder_combo = gtk_combo_box_text_new_with_entry (); dform->folder_entry = gtk_bin_get_child (GTK_BIN (dform->folder_combo)); widget = dform->folder_entry; gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_DIRECTORY); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, _("Select Folder")); g_object_set (dform->folder_combo, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, dform->folder_combo, 1, 3, 1, 1); g_signal_connect (widget, "icon-release", G_CALLBACK (on_select_folder), dform); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); // Folder - label widget = gtk_label_new_with_mnemonic (_("_Folder:")); gtk_label_set_mnemonic_widget(GTK_LABEL (widget), dform->folder_combo); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (top_grid, widget, 0, 3, 1, 1); // Referrer - entry widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 1, 4, 2, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->referrer_entry = widget; // Referrer - label widget = gtk_label_new_with_mnemonic (_("Referrer:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->referrer_entry); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (top_grid, widget, 0, 4, 1, 1); // dform->referrer_label = widget; // ---------------------------------------------------- // HBox for "Status" and "Login" hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); g_object_set (hbox, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, hbox, 0, 5, 3, 1); // ---------------------------------------------------- // frame for Status (start mode) frame = gtk_frame_new (_("Status")); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_container_add (GTK_CONTAINER (frame), vbox); gtk_box_pack_start (GTK_BOX (hbox), frame, FALSE, FALSE, 0); dform->radio_runnable = gtk_radio_button_new_with_mnemonic (NULL, _("_Runnable")); dform->radio_pause = gtk_radio_button_new_with_mnemonic_from_widget ( (GtkRadioButton*)dform->radio_runnable, _("P_ause")); gtk_box_pack_start (GTK_BOX (vbox), dform->radio_runnable, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), dform->radio_pause, FALSE, FALSE, 0); // ---------------------------------------------------- // frame for login frame = gtk_frame_new (_("Login")); grid = (GtkGrid*) gtk_grid_new (); gtk_container_set_border_width (GTK_CONTAINER (grid), 2); gtk_container_add (GTK_CONTAINER (frame), (GtkWidget*) grid); gtk_box_pack_start (GTK_BOX (hbox), frame, TRUE, TRUE, 2); // User - entry widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 0, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); dform->username_entry = widget; // User - label widget = gtk_label_new (_("User:")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); // dform->username_label = widget; // Password - entry widget = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (widget), FALSE); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 1, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_entry_changed), dform); dform->password_entry = widget; // Password - label widget = gtk_label_new (_("Password:")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); // dform->password_label = widget; // ---------------------------------------------------- // frame for option frame = gtk_frame_new (_("Options")); grid = (GtkGrid*) gtk_grid_new (); gtk_container_add (GTK_CONTAINER (frame), (GtkWidget*) grid); gtk_container_set_border_width (GTK_CONTAINER (grid), 2); g_object_set (frame, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, frame, 0, 6, 3, 1); // Retry limit - spin button widget = gtk_spin_button_new_with_range (0.0, 99.0, 1.0); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 1, 0, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_spin_changed), dform); dform->spin_retry = widget; // Retry limit - label widget = gtk_label_new_with_mnemonic (_("Retry _limit:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->spin_retry); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); // counts - label widget = gtk_label_new (_("counts")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 2, 0, 1, 1); // Retry delay - spin button widget = gtk_spin_button_new_with_range (0.0, 600.0, 1.0); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 1, 1, 1, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_spin_changed), dform); dform->spin_delay = widget; // Retry delay - label widget = gtk_label_new_with_mnemonic (_("Retry _delay:")); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), dform->spin_delay); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); // seconds - label widget = gtk_label_new (_("seconds")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 2, 1, 1, 1); // Connections per server // separator widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 3, 0, 1, 2); // "Connections per server" - title label widget = gtk_label_new (_("Connections per server")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 4, 0, 3, 1); dform->title_connections = widget; // connections - spin button widget = gtk_spin_button_new_with_range (1.0, 20.0, 1.0); gtk_entry_set_width_chars (GTK_ENTRY (widget), 3); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 5, 1, 1, 1); dform->spin_connections = widget; // connections - label widget = gtk_label_new (_("connections")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 6, 1, 1, 1); dform->label_connections = widget; // ---------------------------------------------------- // proxy // ug_proxy_widget_init (&dform->proxy_dform); if (proxy) { widget = proxy->self; g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (top_grid, widget, 0, 7, 3, 1); } } static void ug_download_form_init_page2 (UgDownloadForm* dform) { GtkWidget* widget; GtkGrid* grid; dform->page2 = gtk_grid_new (); grid = (GtkGrid*) dform->page2; gtk_container_set_border_width (GTK_CONTAINER (grid), 2); // label - cookie file widget = gtk_label_new (_("Cookie file:")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); dform->cookie_label = widget; // entry - cookie file widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FILE); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, _("Select Cookie File")); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 0, 3, 1); g_signal_connect (widget, "icon-release", G_CALLBACK (on_select_cookie), dform); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->cookie_entry = widget; // label - post file widget = gtk_label_new (_("Post file:")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); dform->post_label = widget; // entry - post file widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); gtk_entry_set_icon_from_stock (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, GTK_STOCK_FILE); gtk_entry_set_icon_tooltip_text (GTK_ENTRY (widget), GTK_ENTRY_ICON_SECONDARY, _("Select Post File")); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 1, 3, 1); g_signal_connect (widget, "icon-release", G_CALLBACK (on_select_post), dform); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->post_entry = widget; // label - user agent widget = gtk_label_new (_("User Agent:")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 2, 1, 1); dform->agent_label = widget; // entry - user agent widget = gtk_entry_new (); gtk_entry_set_activates_default (GTK_ENTRY (widget), TRUE); g_object_set (widget, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 1, 2, 3, 1); g_signal_connect (GTK_EDITABLE (widget), "changed", G_CALLBACK (on_http_entry_changed), dform); dform->agent_entry = widget; // label - Max upload speed widget = gtk_label_new (_("Max upload speed:")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 3, 2, 1); // spin - Max upload speed widget = gtk_spin_button_new_with_range (0, 99999999, 1); gtk_entry_set_width_chars (GTK_ENTRY (widget), 8); g_object_set (widget, "margin", 1, NULL); gtk_grid_attach (grid, widget, 2, 3, 1, 1); dform->spin_upload_speed = (GtkSpinButton*) widget; // label - "KiB/s" widget = gtk_label_new (_("KiB/s")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 3, 1, 1); // label - Max download speed widget = gtk_label_new (_("Max download speed:")); g_object_set (widget, "margin-left", 2, "margin-right", 2, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); gtk_grid_attach (grid, widget, 0, 4, 2, 1); // spin - Max download speed widget = gtk_spin_button_new_with_range (0, 99999999, 1); gtk_entry_set_width_chars (GTK_ENTRY (widget), 8); g_object_set (widget, "margin", 1, NULL); gtk_grid_attach (grid, widget, 2, 4, 1, 1); dform->spin_download_speed = (GtkSpinButton*) widget; // label - "KiB/s" widget = gtk_label_new (_("KiB/s")); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); // left, center g_object_set (widget, "margin", 2, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 4, 1, 1); // Retrieve timestamp widget = gtk_check_button_new_with_label (_("Retrieve timestamp")); gtk_grid_attach (grid, widget, 0, 5, 3, 1); dform->timestamp = (GtkToggleButton*) widget; } static void ug_download_form_decide_sensitive (UgDownloadForm* dform) { extern UgAppGtk* app; // UgApp-gtk-main.c gboolean sensitive; sensitive = app->setting.plugin.aria2.enable; gtk_widget_set_sensitive (dform->mirrors_label, sensitive); gtk_widget_set_sensitive (dform->mirrors_entry, sensitive); gtk_widget_set_sensitive (dform->title_connections, sensitive); gtk_widget_set_sensitive (dform->label_connections, sensitive); gtk_widget_set_sensitive (dform->spin_connections, sensitive); // disable sensitive = !sensitive; gtk_widget_set_sensitive (dform->cookie_label, sensitive); gtk_widget_set_sensitive (dform->cookie_entry, sensitive); gtk_widget_set_sensitive (dform->post_label, sensitive); gtk_widget_set_sensitive (dform->post_entry, sensitive); } void ug_download_form_get (UgDownloadForm* dform, UgDataset* dataset) { UgetCommon* common; UgetHttp* http; UgetRelation* relation; UgUri uuri; const gchar* text; gint number; // ------------------------------------------ // UgetCommon common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); // folder text = gtk_entry_get_text ((GtkEntry*)dform->folder_entry); ug_str_set (&common->folder, text, -1); // user text = gtk_entry_get_text ((GtkEntry*)dform->username_entry); ug_str_set (&common->user, text, -1); // password text = gtk_entry_get_text ((GtkEntry*)dform->password_entry); ug_str_set (&common->password, text, -1); // retry_limit number = gtk_spin_button_get_value_as_int ((GtkSpinButton*) dform->spin_retry); common->retry_limit = number; // retry_delay number = gtk_spin_button_get_value_as_int ((GtkSpinButton*) dform->spin_delay); common->retry_delay = number; // max_upload_speed number = gtk_spin_button_get_value_as_int ((GtkSpinButton*) dform->spin_upload_speed) * 1024; common->max_upload_speed = number; // max_download_speed number = gtk_spin_button_get_value_as_int ((GtkSpinButton*) dform->spin_download_speed) * 1024; common->max_download_speed = number; // max_connections number = gtk_spin_button_get_value_as_int ((GtkSpinButton*) dform->spin_connections); common->max_connections = number; // timestamp common->retrieve_timestamp = gtk_toggle_button_get_active (dform->timestamp); if (gtk_widget_is_sensitive (dform->url_entry) == TRUE) { ug_str_set (&common->url, gtk_entry_get_text ((GtkEntry*)dform->url_entry), -1); ug_str_set (&common->mirrors, gtk_entry_get_text ((GtkEntry*)dform->mirrors_entry), -1); ug_str_set (&common->file, gtk_entry_get_text ((GtkEntry*)dform->file_entry), -1); if (common->url) { ug_uri_init (&uuri, common->url); // set user text = ug_uri_get_user (&uuri); if (text) { g_free (common->user); common->user = (gchar*) text; } // set password text = ug_uri_get_password (&uuri); if (text) { g_free (common->password); common->password = (gchar*) text; } // Remove user & password from URL if (uuri.authority != uuri.host) { memmove ((char*)uuri.uri + uuri.authority, (char*)uuri.uri + uuri.host, strlen (uuri.uri + uuri.host) + 1); } } } // ------------------------------------------ // UgetHttp http = ug_dataset_realloc (dataset, UgetHttpInfo, 0); // referrer text = gtk_entry_get_text ((GtkEntry*) dform->referrer_entry); ug_str_set (&http->referrer, text, -1); // cookie_file text = gtk_entry_get_text ((GtkEntry*) dform->cookie_entry); ug_str_set (&http->cookie_file, text, -1); // post_file text = gtk_entry_get_text ((GtkEntry*) dform->post_entry); ug_str_set (&http->post_file, text, -1); // user_agent text = gtk_entry_get_text ((GtkEntry*) dform->agent_entry); ug_str_set (&http->user_agent, text, -1); // ------------------------------------------ // UgetRelation if (gtk_widget_get_sensitive (dform->radio_pause)) { relation = ug_dataset_realloc (dataset, UgetRelationInfo, 0); if (gtk_toggle_button_get_active ((GtkToggleButton*) dform->radio_pause)) relation->hints |= UG_HINT_PAUSED; else relation->hints &= ~UG_HINT_PAUSED; } } void ug_download_form_set (UgDownloadForm* dform, UgDataset* dataset, gboolean keep_changed) { UgetCommon* common; UgetHttp* http; UgetRelation* relation; common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); http = ug_dataset_get (dataset, UgetHttpInfo, 0); // disable changed flags dform->changed.enable = FALSE; // ------------------------------------------ // UgetCommon // set changed flags if (keep_changed==FALSE && common) { dform->changed.url = common->keeping.url; dform->changed.mirrors = common->keeping.mirrors; dform->changed.file = common->keeping.file; dform->changed.folder = common->keeping.folder; dform->changed.user = common->keeping.user; dform->changed.password = common->keeping.password; dform->changed.retry = common->keeping.retry_limit; dform->changed.delay = common->keeping.retry_delay; dform->changed.max_upload_speed = common->keeping.max_upload_speed; dform->changed.max_download_speed = common->keeping.max_download_speed; dform->changed.retrieve_timestamp = common->keeping.retrieve_timestamp; } // set data if (keep_changed==FALSE || dform->changed.url==FALSE) { if (gtk_widget_is_sensitive (dform->url_entry)) { gtk_entry_set_text ((GtkEntry*) dform->url_entry, (common && common->url) ? common->url : ""); } } if (keep_changed==FALSE || dform->changed.mirrors==FALSE) { if (gtk_widget_is_sensitive (dform->mirrors_entry)) { gtk_entry_set_text ((GtkEntry*) dform->mirrors_entry, (common && common->mirrors) ? common->mirrors : ""); } } if (keep_changed==FALSE || dform->changed.file==FALSE) { if (gtk_widget_is_sensitive (dform->file_entry)) { gtk_entry_set_text ((GtkEntry*) dform->file_entry, (common && common->file) ? common->file : ""); // set changed flags if (common && common->file) dform->changed.file = TRUE; } } if (keep_changed==FALSE || dform->changed.folder==FALSE) { g_signal_handlers_block_by_func (GTK_EDITABLE (dform->folder_entry), on_entry_changed, dform); gtk_entry_set_text ((GtkEntry*) dform->folder_entry, (common && common->folder) ? common->folder : ""); g_signal_handlers_unblock_by_func (GTK_EDITABLE (dform->folder_entry), on_entry_changed, dform); } if (keep_changed==FALSE || dform->changed.user==FALSE) { gtk_entry_set_text ((GtkEntry*) dform->username_entry, (common && common->user) ? common->user : ""); } if (keep_changed==FALSE || dform->changed.password==FALSE) { gtk_entry_set_text ((GtkEntry*) dform->password_entry, (common && common->password) ? common->password : ""); } if (keep_changed==FALSE || dform->changed.retry==FALSE) { gtk_spin_button_set_value ((GtkSpinButton*) dform->spin_retry, (common) ? common->retry_limit : 99); } if (keep_changed==FALSE || dform->changed.delay==FALSE) { gtk_spin_button_set_value ((GtkSpinButton*) dform->spin_delay, (common) ? common->retry_delay : 6); } if (keep_changed==FALSE || dform->changed.max_upload_speed==FALSE) { gtk_spin_button_set_value ((GtkSpinButton*) dform->spin_upload_speed, (gdouble) (common->max_upload_speed / 1024)); } if (keep_changed==FALSE || dform->changed.max_download_speed==FALSE) { gtk_spin_button_set_value ((GtkSpinButton*) dform->spin_download_speed, (gdouble) (common->max_download_speed / 1024)); } if (keep_changed==FALSE || dform->changed.connections==FALSE) { gtk_spin_button_set_value ((GtkSpinButton*) dform->spin_connections, common->max_connections); } if (keep_changed==FALSE || dform->changed.retrieve_timestamp==FALSE) gtk_toggle_button_set_active (dform->timestamp, common->retrieve_timestamp); // ------------------------------------------ // UgetHttp // set data if (keep_changed==FALSE || dform->changed.referrer==FALSE) { gtk_entry_set_text ((GtkEntry*) dform->referrer_entry, (http && http->referrer) ? http->referrer : ""); } if (keep_changed==FALSE || dform->changed.cookie==FALSE) { gtk_entry_set_text ((GtkEntry*) dform->cookie_entry, (http && http->cookie_file) ? http->cookie_file : ""); } if (keep_changed==FALSE || dform->changed.post==FALSE) { gtk_entry_set_text ((GtkEntry*) dform->post_entry, (http && http->post_file) ? http->post_file : ""); } if (keep_changed==FALSE || dform->changed.agent==FALSE) { gtk_entry_set_text ((GtkEntry*) dform->agent_entry, (http && http->user_agent) ? http->user_agent : ""); } // set changed flags if (keep_changed==FALSE && http) { dform->changed.referrer = http->keeping.referrer; dform->changed.cookie = http->keeping.cookie_file; dform->changed.post = http->keeping.post_file; dform->changed.agent = http->keeping.user_agent; } // ------------------------------------------ // UgetRelation if (gtk_widget_get_sensitive (dform->radio_pause)) { relation = ug_dataset_realloc (dataset, UgetRelationInfo, 0); if (relation->hints & UG_HINT_PAUSED) gtk_toggle_button_set_active ((GtkToggleButton*) dform->radio_pause, TRUE); else gtk_toggle_button_set_active ((GtkToggleButton*) dform->radio_runnable, TRUE); } // enable changed flags dform->changed.enable = TRUE; // complete entry ug_download_form_complete_entry (dform); } void ug_download_form_set_multiple (UgDownloadForm* dform, gboolean multiple_mode) { // dform->multiple = multiple_mode; if (multiple_mode) { gtk_widget_hide (dform->url_label); gtk_widget_hide (dform->url_entry); gtk_widget_hide (dform->mirrors_label); gtk_widget_hide (dform->mirrors_entry); gtk_widget_hide (dform->file_label); gtk_widget_hide (dform->file_entry); } else { gtk_widget_show (dform->url_label); gtk_widget_show (dform->url_entry); gtk_widget_show (dform->mirrors_label); gtk_widget_show (dform->mirrors_entry); gtk_widget_show (dform->file_label); gtk_widget_show (dform->file_entry); } multiple_mode = !multiple_mode; gtk_widget_set_sensitive (dform->url_label, multiple_mode); gtk_widget_set_sensitive (dform->url_entry, multiple_mode); gtk_widget_set_sensitive (dform->file_label, multiple_mode); gtk_widget_set_sensitive (dform->file_entry, multiple_mode); } void ug_download_form_set_relation (UgDownloadForm* dform, gboolean relation_mode) { gtk_widget_set_sensitive (dform->radio_pause, relation_mode); gtk_widget_set_sensitive (dform->radio_runnable, relation_mode); } void ug_download_form_set_folder_list (UgDownloadForm* dform, GList* folder_list) { GtkComboBoxText* combo; dform->changed.enable = FALSE; g_signal_handlers_block_by_func (GTK_EDITABLE (dform->folder_entry), on_entry_changed, dform); combo = GTK_COMBO_BOX_TEXT (dform->folder_combo); for (; folder_list; folder_list = folder_list->next) gtk_combo_box_text_append_text (combo, folder_list->data); // set default folder gtk_combo_box_set_active (GTK_COMBO_BOX (combo), 0); g_signal_handlers_unblock_by_func (GTK_EDITABLE (dform->folder_entry), on_entry_changed, dform); dform->changed.enable = TRUE; } void ug_download_form_get_folder_list (UgDownloadForm* dform, GList** folder_list) { const gchar* current; GList* link; guint length; current = gtk_entry_get_text ((GtkEntry*) dform->folder_entry); if (*current == 0) return; for (link = *folder_list; link; link = link->next) { if (strcmp (current, link->data) == 0) { *folder_list = g_list_remove_link (*folder_list, link); *folder_list = g_list_prepend (*folder_list, link->data); g_list_free_1 (link); return; } } length = g_list_length (*folder_list); if (length >= 8) { link = g_list_last (*folder_list); *folder_list = g_list_remove_link (*folder_list, link); g_free (link->data); g_list_free_1 (link); } *folder_list = g_list_prepend (*folder_list, g_strdup (current)); } void ug_download_form_complete_entry (UgDownloadForm* dform) { const gchar* text; // gchar* temp; UgUri upart; gboolean completed; // URL text = gtk_entry_get_text ((GtkEntry*) dform->url_entry); ug_uri_init (&upart, text); if (upart.host) { // disable changed flags dform->changed.enable = FALSE; /* // complete file entry text = gtk_entry_get_text ((GtkEntry*) dform->file_entry); if (text[0] == 0 || dform->changed.file == FALSE) { temp = ug_uri_get_file (&upart); gtk_entry_set_text ((GtkEntry*) dform->file_entry, (temp) ? temp : "index.htm"); g_free (temp); } // complete user entry text = gtk_entry_get_text ((GtkEntry*) dform->username_entry); if (text[0] == 0 || dform->changed.user == FALSE) { temp = ug_uri_get_user (&upart); gtk_entry_set_text ((GtkEntry*) dform->username_entry, (temp) ? temp : ""); g_free (temp); } // complete password entry text = gtk_entry_get_text ((GtkEntry*) dform->password_entry); if (text[0] == 0 || dform->changed.password == FALSE) { temp = ug_uri_get_password (&upart); gtk_entry_set_text ((GtkEntry*) dform->password_entry, (temp) ? temp : ""); g_free (temp); } */ // enable changed flags dform->changed.enable = TRUE; // status completed = TRUE; } else if (gtk_widget_is_sensitive (dform->url_entry) == FALSE) completed = TRUE; else completed = FALSE; if (dform->notify.func) dform->notify.func (dform->notify.data, completed); } // ---------------------------------------------------------------------------- // signal handler static void on_spin_changed (GtkEditable* editable, UgDownloadForm* dform) { if (dform->changed.enable) { if (editable == GTK_EDITABLE (dform->spin_retry)) dform->changed.retry = TRUE; else if (editable == GTK_EDITABLE (dform->spin_delay)) dform->changed.delay = TRUE; } } static void on_entry_changed (GtkEditable* editable, UgDownloadForm* dform) { if (dform->changed.enable) { if (editable == GTK_EDITABLE (dform->file_entry)) dform->changed.file = TRUE; else if (editable == GTK_EDITABLE (dform->folder_entry)) dform->changed.folder = TRUE; else if (editable == GTK_EDITABLE (dform->username_entry)) dform->changed.user = TRUE; else if (editable == GTK_EDITABLE (dform->password_entry)) dform->changed.password = TRUE; } } static void on_url_entry_changed (GtkEditable* editable, UgDownloadForm* dform) { if (dform->changed.enable) { dform->changed.url = TRUE; ug_download_form_complete_entry (dform); } } static void on_http_entry_changed (GtkEditable* editable, UgDownloadForm* dform) { if (dform->changed.enable) { if (editable == GTK_EDITABLE (dform->referrer_entry)) dform->changed.referrer = TRUE; else if (editable == GTK_EDITABLE (dform->cookie_entry)) dform->changed.cookie = TRUE; else if (editable == GTK_EDITABLE (dform->post_entry)) dform->changed.post = TRUE; else if (editable == GTK_EDITABLE (dform->agent_entry)) dform->changed.agent = TRUE; } } static void on_select_folder_response (GtkDialog* chooser, gint response, UgDownloadForm* dform) { gchar* file; gchar* path; if (response == GTK_RESPONSE_OK ) { file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); path = g_filename_to_utf8 (file, -1, NULL, NULL, NULL); gtk_entry_set_text (GTK_ENTRY (dform->folder_entry), path); g_free (path); g_free (file); } gtk_widget_destroy (GTK_WIDGET (chooser)); if (dform->parent) gtk_widget_set_sensitive ((GtkWidget*) dform->parent, TRUE); } static void on_select_folder (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgDownloadForm* dform) { GtkWidget* chooser; gchar* path; gchar* title; // disable sensitive of parent window // enable sensitive in function on_file_chooser_response() if (dform->parent) gtk_widget_set_sensitive ((GtkWidget*) dform->parent, FALSE); title = g_strconcat (UG_APP_GTK_NAME " - ", _("Select Folder"), NULL); chooser = gtk_file_chooser_dialog_new (title, dform->parent, GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_window_set_transient_for ((GtkWindow*) chooser, dform->parent); gtk_window_set_destroy_with_parent ((GtkWindow*) chooser, TRUE); path = (gchar*) gtk_entry_get_text ((GtkEntry*) dform->folder_entry); if (*path) { path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL); gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (chooser), path); g_free (path); } g_signal_connect (chooser, "response", G_CALLBACK (on_select_folder_response), dform); if (gtk_window_get_modal (dform->parent)) gtk_dialog_run ((GtkDialog*) chooser); else { gtk_window_set_modal ((GtkWindow*) chooser, FALSE); gtk_widget_show (chooser); } } static void on_select_cookie_response (GtkDialog* chooser, gint response, UgDownloadForm* dform) { gchar* file; gchar* path; if (response == GTK_RESPONSE_OK ) { file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); path = g_filename_to_utf8 (file, -1, NULL, NULL, NULL); gtk_entry_set_text (GTK_ENTRY (dform->cookie_entry), path); g_free (path); g_free (file); } gtk_widget_destroy (GTK_WIDGET (chooser)); if (dform->parent) gtk_widget_set_sensitive ((GtkWidget*) dform->parent, TRUE); } static void on_select_cookie (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgDownloadForm* dform) { GtkWidget* chooser; gchar* path; gchar* title; // disable sensitive of parent window // enable sensitive in function on_file_chooser_response() if (dform->parent) gtk_widget_set_sensitive ((GtkWidget*) dform->parent, FALSE); title = g_strconcat (UG_APP_GTK_NAME " - ", _("Select Cookie File"), NULL); chooser = gtk_file_chooser_dialog_new (title, dform->parent, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_window_set_transient_for ((GtkWindow*) chooser, dform->parent); gtk_window_set_destroy_with_parent ((GtkWindow*) chooser, TRUE); path = (gchar*) gtk_entry_get_text ((GtkEntry*) dform->cookie_entry); if (*path) { path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL); gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (chooser), path); g_free (path); } g_signal_connect (chooser, "response", G_CALLBACK (on_select_cookie_response), dform); if (gtk_window_get_modal (dform->parent)) gtk_dialog_run ((GtkDialog*) chooser); else { gtk_window_set_modal ((GtkWindow*) chooser, FALSE); gtk_widget_show (chooser); } } static void on_select_post_response (GtkDialog* chooser, gint response, UgDownloadForm* dform) { gchar* file; gchar* path; if (response == GTK_RESPONSE_OK ) { file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (chooser)); path = g_filename_to_utf8 (file, -1, NULL, NULL, NULL); gtk_entry_set_text (GTK_ENTRY (dform->post_entry), path); g_free (path); g_free (file); } gtk_widget_destroy (GTK_WIDGET (chooser)); if (dform->parent) gtk_widget_set_sensitive ((GtkWidget*) dform->parent, TRUE); } static void on_select_post (GtkEntry* entry, GtkEntryIconPosition icon_pos, GdkEvent* event, UgDownloadForm* dform) { GtkWidget* chooser; gchar* path; gchar* title; // disable sensitive of parent window // enable sensitive in function on_file_chooser_response() if (dform->parent) gtk_widget_set_sensitive ((GtkWidget*) dform->parent, FALSE); title = g_strconcat (UG_APP_GTK_NAME " - ", _("Select Post File"), NULL); chooser = gtk_file_chooser_dialog_new (title, dform->parent, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_window_set_transient_for ((GtkWindow*) chooser, dform->parent); gtk_window_set_destroy_with_parent ((GtkWindow*) chooser, TRUE); path = (gchar*) gtk_entry_get_text ((GtkEntry*) dform->post_entry); if (*path) { path = g_filename_from_utf8 (path, -1, NULL, NULL, NULL); gtk_file_chooser_select_filename (GTK_FILE_CHOOSER (chooser), path); g_free (path); } g_signal_connect (chooser, "response", G_CALLBACK (on_select_post_response), dform); if (gtk_window_get_modal (dform->parent)) gtk_dialog_run ((GtkDialog*) chooser); else { gtk_window_set_modal ((GtkWindow*) chooser, FALSE); gtk_widget_show (chooser); } } uget-1.10.4/uget-gtk/UgCategoryForm.h0000664000175000017500000000443212260761064014270 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_CATEGORY_FORM_H #define UG_CATEGORY_FORM_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgCategoryForm UgCategoryForm; struct UgCategoryForm { GtkWidget* self; GtkWidget* name_label; GtkWidget* name_entry; GtkWidget* spin_active; GtkWidget* spin_finished; GtkWidget* spin_recycled; }; void ug_category_form_init (UgCategoryForm* cform); void ug_category_form_get (UgCategoryForm* cform, UgCategory* category); void ug_category_form_set (UgCategoryForm* cform, UgCategory* category); void ug_category_form_set_multiple (UgCategoryForm* cform, gboolean multiple_mode); #ifdef __cplusplus } #endif #endif // End of UG_CATEGORY_FROM_H uget-1.10.4/uget-gtk/UgDownloadForm.h0000664000175000017500000001143712260761064014265 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_DOWNLOAD_FORM_H #define UG_DOWNLOAD_FORM_H #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgDownloadForm UgDownloadForm; typedef void (*UgDownloadFormNotify) (gpointer user_data, gboolean completed); struct UgDownloadForm { GtkWindow* parent; // parent window of UgDownloadForm.self // ---------------------------------------------------- // Page 1 // GtkWidget* page1; GtkWidget* url_label; GtkWidget* url_entry; // GtkWidget* url_button; GtkWidget* mirrors_label; GtkWidget* mirrors_entry; // GtkWidget* mirror_button; GtkWidget* file_label; GtkWidget* file_entry; // GtkWidget* file_button; GtkWidget* folder_combo; GtkWidget* folder_entry; // GtkWidget* folder_button; // GtkWidget* referrer_label; GtkWidget* referrer_entry; // widgets for login fields // GtkWidget* username_label; GtkWidget* username_entry; // GtkWidget* password_label; GtkWidget* password_entry; // widgets for Status GtkWidget* radio_runnable; GtkWidget* radio_pause; // GtkWidget* spin_parts; // GtkWidget* spin_redirect; GtkWidget* spin_retry; // counts GtkWidget* spin_delay; // seconds // Connections per server GtkWidget* title_connections; GtkWidget* label_connections; GtkWidget* spin_connections; // connections // ---------------------------------------------------- // Page 2 // GtkWidget* page2; GtkWidget* cookie_label; GtkWidget* cookie_entry; GtkWidget* post_label; GtkWidget* post_entry; GtkWidget* agent_label; // user agent GtkWidget* agent_entry; GtkSpinButton* spin_download_speed; GtkSpinButton* spin_upload_speed; GtkToggleButton* timestamp; // ---------------------------------------------------- // User changed entry // struct UgDownloadFormChanged { gboolean enable:1; gboolean url:1; gboolean mirrors:1; gboolean file:1; gboolean folder:1; gboolean user:1; gboolean password:1; gboolean referrer:1; gboolean cookie:1; gboolean post:1; gboolean agent:1; gboolean retry:1; // spin_retry gboolean delay:1; // spin_delay gboolean connections:1; // spin_connections gboolean max_upload_speed:1; // spin_upload_speed gboolean max_download_speed:1; // spin_download_speed gboolean retrieve_timestamp:1; } changed; // ---------------------------------------------------- // callback // struct { UgDownloadFormNotify func; gpointer data; } notify; }; void ug_download_form_init (UgDownloadForm* dform, UgProxyForm* proxy, GtkWindow* parent); GtkWidget* ug_download_from_use_notebook (UgDownloadForm* dform, const gchar* label1, const gchar* label2); void ug_download_form_get (UgDownloadForm* dform, UgDataset* dataset); void ug_download_form_set (UgDownloadForm* dform, UgDataset* dataset, gboolean keep_changed); void ug_download_form_set_multiple (UgDownloadForm* dform, gboolean multiple_mode); void ug_download_form_set_relation (UgDownloadForm* dform, gboolean relation_mode); void ug_download_form_set_folder_list (UgDownloadForm* dform, GList* folder_list); void ug_download_form_get_folder_list (UgDownloadForm* dform, GList** folder_list); void ug_download_form_complete_entry (UgDownloadForm* dform); #ifdef __cplusplus } #endif #endif // End of UG_DOWNLOAD_FORM_H uget-1.10.4/uget-gtk/UgApp-gtk.h0000664000175000017500000002737012260761064013200 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_APP_GTK_H #define UG_APP_GTK_H #include // uglib #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_APP_INDICATOR #include #endif #ifdef __cplusplus extern "C" { #endif #define UG_APP_GTK_DIR "uGet" #define UG_APP_GTK_SETTING_FILE "Setting.xml" #define UG_APP_GTK_CATEGORY_FILE "CategoryList.xml" #define UG_APP_GTK_DOWNLOAD_FILE "DownloadList.xml" #define UG_APP_GTK_APP_ICON_NAME "uget-icon" #define UG_APP_GTK_TRAY_ICON_NAME "uget-tray-default" #define UG_APP_GTK_TRAY_ICON_ERROR_NAME "uget-tray-error" #define UG_APP_GTK_TRAY_ICON_ACTIVE_NAME "uget-tray-downloading" #define UG_APP_GTK_ACCEL_PATH_CTRL_N "/Download/New" #define UG_APP_GTK_ACCEL_PATH_DELETE "/Download/Delete" #define UG_APP_GTK_ACCEL_PATH_DELETE_F "/Download/DeleteFile" #define UG_APP_GTK_ACCEL_PATH_OPEN "/Download/Open" #define UG_APP_GTK_ACCEL_PATH_OPEN_F "/Download/OpenFolder" #define UG_APP_GTK_CATEGORY_STOCK GTK_STOCK_DND_MULTIPLE typedef struct UgAppGtk UgAppGtk; // implemented in UgApp-gtk-main.c const gchar* ug_get_data_dir (void); // return g_get_user_config_dir () + UG_APP_GTK_DIR + "attachment" const gchar* ug_get_attachment_dir (void); // ---------------------------------------------------------------------------- // UgAppGtk: Uget application for GTK+ struct UgAppGtk { // command argument, IPC, UgRunning UgIpc ipc; // initialize in UgApp-gtk-main.c UgOption option; // initialize in UgApp-gtk-main.c UgRunning running; UgSetting setting; // UgSetting.h UgScheduleState schedule_state; GRegex* launch_regex; // for Launch application // last download settings struct LastDownloadSetting { UgDataset* download; gint category_index; } last; // check for updates struct { GThread* thread; GString* text; gboolean ready; } update_info; // aria2 plug-in struct { GThread* thread; GMutex mutex; gchar* uri; // status gboolean launched; gboolean remote_updated; guint failed_count; // overall speed gint64 download_speed; gint64 upload_speed; } aria2; struct UgUserAction { gboolean deleted; // some task deleted by user gboolean stop; // some task stop by user } action; // Clipboard struct UgClipboard { GtkClipboard* self; gchar* text; GRegex* regex; } clipboard; // dialogs struct UgDialogs { GtkWidget* error; GtkWidget* message; GtkWidget* close_confirmation; GtkWidget* delete_confirmation; GtkWidget* setting; } dialogs; // ------------------------------------------------------- // GUI (initialize in UgApp-gtk-gui.c) GtkAccelGroup* accel_group; UgCategoryWidget cwidget; UgSummary summary; UgBanner banner; // -------------------------------- // System tray icon struct UgTrayIcon { #ifdef HAVE_APP_INDICATOR AppIndicator* indicator; #endif GtkStatusIcon* self; gboolean error_occurred; guint last_status; struct UgTrayIconMenu { GtkWidget* self; // (GtkMenu) pop-up menu GtkWidget* create_download; GtkWidget* create_clipboard; GtkWidget* create_torrent; GtkWidget* create_metalink; GtkWidget* settings; GtkWidget* about; GtkWidget* show_window; GtkWidget* offline_mode; GtkWidget* quit; } menu; } trayicon; // -------------------------------- // Main Window struct UgWindow { GtkWindow* self; // layout GtkPaned* vpaned; // right side (UgDownloadWidget and UgSummary) GtkPaned* hpaned; // separate left side and right side } window; // -------------------------------- // status bar struct UgStatusbar { GtkStatusbar* self; GtkLabel* down_speed; GtkLabel* up_speed; } statusbar; // -------------------------------- // Toolbar struct UgToolbar { GtkWidget* self; // GtkToolbar // GtkToolItem GtkWidget* create; // GtkMenuItem // menu for tool button GtkWidget* create_download; GtkWidget* create_category; GtkWidget* create_clipboard; GtkWidget* create_sequence; GtkWidget* create_torrent; GtkWidget* create_metalink; // GtkToolItem GtkWidget* save; GtkWidget* runnable; GtkWidget* pause; GtkWidget* properties; GtkWidget* move_up; GtkWidget* move_down; GtkWidget* move_top; GtkWidget* move_bottom; } toolbar; // -------------------------------- // Menubar --- start --- struct UgMenubar { GtkWidget* self; // GtkMenuBar // GtkWidget* self; // GtkMenu* // GtkWidget* shell; // GtkMenuShell* // GtkWidget* other; // GtkMenuItem* struct UgFileMenu { // file.create struct UgFileCreateMenu { GtkWidget* download; GtkWidget* category; GtkWidget* torrent; GtkWidget* metalink; } create; // file.batch struct UgFileBatchMenu { GtkWidget* clipboard; // Clipboard batch GtkWidget* sequence; // URL Sequence batch GtkWidget* text_import; // Text file import (.txt) GtkWidget* html_import; // HTML file import (.html) GtkWidget* text_export; // Export to Text file (.txt) } batch; GtkWidget* save; GtkWidget* offline_mode; GtkWidget* quit; } file; struct UgEditMenu { GtkWidget* clipboard_monitor; GtkWidget* clipboard_option; GtkWidget* shutdown; GtkWidget* settings; } edit; struct UgViewMenu { GtkWidget* toolbar; GtkWidget* statusbar; GtkWidget* category; GtkWidget* summary; struct UgViewItemMenu { GtkWidget* name; GtkWidget* folder; GtkWidget* category; // GtkWidget* elapsed; GtkWidget* url; GtkWidget* message; } summary_items; struct UgViewColMenu { GtkWidget* self; // GtkMenu GtkWidget* completed; GtkWidget* total; GtkWidget* percent; GtkWidget* elapsed; // consuming time GtkWidget* left; // remaining time GtkWidget* speed; GtkWidget* upload_speed; // torrent GtkWidget* uploaded; // torrent GtkWidget* ratio; // torrent GtkWidget* retry; GtkWidget* category; GtkWidget* url; GtkWidget* added_on; GtkWidget* completed_on; } columns; // download columns } view; struct UgCategoryMenu { GtkWidget* self; // GtkMenu GtkWidget* create; GtkWidget* delete; GtkWidget* properties; } category; struct UgDownloadMenu { GtkWidget* self; // GtkMenu GtkWidget* create; GtkWidget* delete; GtkWidget* delete_file; // delete file and data. GtkWidget* open; GtkWidget* open_folder; // open containing folder GtkWidget* force_start; GtkWidget* runnable; GtkWidget* pause; struct UgDownloadMoveToMenu { GtkWidget* self; // GtkMenu GtkWidget* item; // GtkMenuItem // This array used for mapping menu item and it's category // index 0, 2, 4, 6... GtkMenuItem* // index 1, 3, 5, 7... UgCategoryGtk* GPtrArray* array; } move_to; GtkWidget* move_up; GtkWidget* move_down; GtkWidget* move_top; GtkWidget* move_bottom; GtkWidget* properties; } download; struct UgHelpMenu { GtkWidget* help_online; GtkWidget* documentation; GtkWidget* support_forum; GtkWidget* submit_feedback; GtkWidget* check_updates; GtkWidget* report_bug; GtkWidget* about_uget; } help; } menubar; // Menubar --- end --- // -------------------------------- }; // use function name "ug_app_xxx" to replace "ug_app_gtk_xxx" here. // ug_app_init is easy to understand, ug_app_gtk_init and ug_appgtk_init are not. void ug_app_init (UgAppGtk* app); void ug_app_quit (UgAppGtk* app); void ug_app_save (UgAppGtk* app); void ug_app_load (UgAppGtk* app); void ug_app_set_setting (UgAppGtk* app, UgSetting* setting); void ug_app_get_setting (UgAppGtk* app, UgSetting* setting); void ug_app_get_update_info (UgAppGtk* app); void ug_app_clear_update_info (UgAppGtk* app); // UgApp-gtk-gui.c void ug_app_init_gui (UgAppGtk* app); // UgApp-gtk-callback.c void ug_app_init_callback (UgAppGtk* app); // UgApp-gtk-timeout.c void ug_app_init_timeout (UgAppGtk* app); // -------------------------------------------------------- // UgClipboard void ug_clipboard_init (struct UgClipboard* clipboard, const gchar* pattern); void ug_clipboard_set_pattern (struct UgClipboard* clipboard, const gchar* pattern); void ug_clipboard_set_text (struct UgClipboard* clipboard, gchar* text); GList* ug_clipboard_get_uris (struct UgClipboard* clipboard); GList* ug_clipboard_get_matched (struct UgClipboard* clipboard, const gchar* text); // -------------------------------------------------------- // UgTrayIcon and UgStatusbar void ug_trayicon_set_info (struct UgTrayIcon* trayicon, guint n_active, gint64 down_speed, gint64 up_speed); void ug_trayicon_set_visible (struct UgTrayIcon* trayicon, gboolean visible); void ug_statusbar_set_info (struct UgStatusbar* statusbar, UgDownloadWidget* dwidget); void ug_statusbar_set_speed (struct UgStatusbar* statusbar, gint64 down_speed, gint64 up_speed); // -------------------------------------------------------- // utility and integrate functions void ug_app_confirm_to_quit (UgAppGtk* app); void ug_app_confirm_to_delete (UgAppGtk* app, GCallback response, gpointer response_data); void ug_app_show_message (UgAppGtk* app, GtkMessageType type, const gchar* message); void ug_app_window_close (UgAppGtk* app); void ug_app_trayicon_decide_visible (UgAppGtk* app); void ug_app_menubar_sync_category (UgAppGtk* app, gboolean reset); void ug_app_reset_download_column (UgAppGtk* app); void ug_app_decide_download_sensitive (UgAppGtk* app); void ug_app_decide_category_sensitive (UgAppGtk* app); void ug_app_decide_bt_meta_sensitive (UgAppGtk* app); // -------------------------------------------------------- // aria2 #ifdef HAVE_PLUGIN_ARIA2 void ug_app_aria2_init (UgAppGtk* app); void ug_app_aria2_finalize (UgAppGtk* app); gboolean ug_app_aria2_setup (UgAppGtk* app); gboolean ug_app_aria2_launch (UgAppGtk* app); void ug_app_aria2_shutdown (UgAppGtk* app); #else #define ug_app_aria2_init(app) #define ug_app_aria2_finalize(app) #define ug_app_aria2_setup(app) #define ug_app_aria2_launch(app) #define ug_app_aria2_shutdown(app) #endif // HAVE_PLUGIN_ARIA2 #ifdef __cplusplus } #endif #endif // End of UG_APP_GTK_H uget-1.10.4/uget-gtk/UgApp-gtk-aria2.c0000664000175000017500000002127112260761064014161 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #ifdef _WIN32 #ifndef _WIN32_WINNT // This is for GetProcessId() #define _WIN32_WINNT 0x501 // 0x501 = WinXP #include #endif // _WIN32_WINNT #endif // _WIN32 #include #include #include #include #ifdef _WIN32 HANDLE hProc = NULL; BOOL CALLBACK ugEnumWindowsProc (HWND hwCurHwnd, LPARAM lparam) { DWORD dwCurPid = 0; struct { DWORD pid; HWND hWnd; char* buf; int bufLen; } *param; param = GUINT_TO_POINTER (lparam); // compare process ID GetWindowThreadProcessId (hwCurHwnd, &dwCurPid); if(dwCurPid != param->pid) return TRUE; // compare class name GetClassName (hwCurHwnd, param->buf, param->bufLen); if(strcmp (param->buf, "ConsoleWindowClass") == 0) { param->hWnd = hwCurHwnd; return FALSE; } return TRUE; } BOOL ugHideWindowByHandle (HANDLE hProcess) { struct { DWORD pid; HWND hWnd; char* buf; int bufLen; } param; param.pid = GetProcessId (hProcess); param.hWnd = NULL; param.bufLen = 256; param.buf = g_malloc (param.bufLen); EnumWindows (ugEnumWindowsProc, GPOINTER_TO_UINT (¶m)); g_free (param.buf); if (param.hWnd) { ShowWindow (param.hWnd, SW_HIDE); return TRUE; } return FALSE; } #endif // _WIN32 // ------------------------------------------------------ // aria2 // #ifdef HAVE_PLUGIN_ARIA2 static gpointer aria2_ctrl_thread (UgAppGtk* app) { UgXmlrpc* xmlrpc; UgXmlrpcValue* values; UgXmlrpcValue* member; UgXmlrpcResponse response; gchar* string_down; gchar* string_up; xmlrpc = g_malloc0 (sizeof (UgXmlrpc)); ug_xmlrpc_init (xmlrpc); for (;;) { // sleep one second g_usleep (1 * 1000 * 1000); #ifdef _WIN32 if (hProc && ugHideWindowByHandle (hProc) == TRUE) { CloseHandle (hProc); hProc = NULL; } #endif if (app->setting.plugin.aria2.enable == FALSE || app->setting.offline_mode) continue; // update URI g_mutex_lock (&app->aria2.mutex); if (app->aria2.uri) { ug_xmlrpc_use_client (xmlrpc, app->aria2.uri, NULL); g_free (app->aria2.uri); app->aria2.uri = NULL; } g_mutex_unlock (&app->aria2.mutex); if (app->aria2.remote_updated == FALSE) { string_down = g_strdup_printf ("%uK", app->setting.speed_limit.normal.download); string_up = g_strdup_printf ("%uK", app->setting.speed_limit.normal.upload); values = ug_xmlrpc_value_new_struct (2); // max-overall-download-limit member = ug_xmlrpc_value_alloc (values); member->name = "max-overall-download-limit"; member->type = UG_XMLRPC_STRING; member->c.string = string_down; // max-overall-upload-limit member = ug_xmlrpc_value_alloc (values); member->name = "max-overall-upload-limit"; member->type = UG_XMLRPC_STRING; member->c.string = string_up; // call aria2.changeGlobalOption response = ug_xmlrpc_call (xmlrpc, "aria2.changeGlobalOption", UG_XMLRPC_STRUCT, values, UG_XMLRPC_NONE); // free unused data g_free (string_down); g_free (string_up); ug_xmlrpc_value_free (values); // check response if (response == UG_XMLRPC_OK) { app->aria2.remote_updated = TRUE; app->aria2.failed_count = 0; } else { app->aria2.failed_count++; } } /* // get overall speed // call aria2.getGlobalStat response = ug_xmlrpc_call (xmlrpc, "aria2.getGlobalStat", UG_XMLRPC_NONE); if (response != UG_XMLRPC_OK) app->aria2.failed_count++; else { app->aria2.failed_count = 0; // get response values = ug_xmlrpc_get_value (xmlrpc); // download speed member = ug_xmlrpc_value_find (values, "downloadSpeed"); #if defined (_MSC_VER) || defined (__MINGW32__) app->aria2.download_speed = _atoi64 (member->c.string); #else // C99 Standard app->aria2.download_speed = atoll (member->c.string); #endif // upload speed member = ug_xmlrpc_value_find (values, "uploadSpeed"); #if defined (_MSC_VER) || defined (__MINGW32__) app->aria2.upload_speed = _atoi64 (member->c.string); #else // C99 Standard app->aria2.upload_speed = atoll (member->c.string); #endif } */ } ug_xmlrpc_finalize (xmlrpc); g_free (xmlrpc); return NULL; } void ug_app_aria2_init (UgAppGtk* app) { g_mutex_init (&app->aria2.mutex); } void ug_app_aria2_finalize (UgAppGtk* app) { // g_mutex_clear (&app->aria2.mutex); } gboolean ug_app_aria2_setup (UgAppGtk* app) { const UgPluginInterface* iface; // update URI g_mutex_lock (&app->aria2.mutex); if (app->aria2.uri) g_free (app->aria2.uri); app->aria2.uri = g_strdup (app->setting.plugin.aria2.uri); g_mutex_unlock (&app->aria2.mutex); ug_plugin_global_set (&ug_plugin_aria2_iface, UG_TYPE_STRING, app->setting.plugin.aria2.uri); iface = ug_plugin_interface_find ("aria2", 0); if (iface) ug_plugin_interface_unregister (iface); if (app->setting.plugin.aria2.enable) { ug_plugin_interface_register (&ug_plugin_aria2_iface); if (app->setting.plugin.aria2.launch) ug_app_aria2_launch (app); if (app->aria2.thread == NULL) { app->aria2.thread = g_thread_new ("aria2-ctrl", (GThreadFunc) aria2_ctrl_thread, app); } } return TRUE; } gboolean ug_app_aria2_launch (UgAppGtk* app) { GPtrArray* args; gchar** argv; gint argc; gint index; gboolean retval; GSpawnFlags flags; if (app->aria2.launched == TRUE) return TRUE; // arguments argc = 0; argv = NULL; g_shell_parse_argv (app->setting.plugin.aria2.args, &argc, &argv, NULL); args = g_ptr_array_sized_new (argc + 2); g_ptr_array_add (args, app->setting.plugin.aria2.path); for (index = 0; index < argc; index++) g_ptr_array_add (args, argv[index]); g_ptr_array_add (args, NULL); // NULL-terminated // If path is not absolute path, program will search PATH. if (strrchr (app->setting.plugin.aria2.path, G_DIR_SEPARATOR) == NULL) flags = G_SPAWN_SEARCH_PATH; else flags = 0; #ifdef _WIN32 // child_pid will be filled with a handle to the child process only if // you specified the G_SPAWN_DO_NOT_REAP_CHILD flag. // You should close the handle with CloseHandle() or g_spawn_close_pid() // when you no longer need it. flags |= G_SPAWN_DO_NOT_REAP_CHILD; #endif // spawn command retval = g_spawn_async (NULL, // working_directory (gchar**) args->pdata, // argv NULL, // envp flags, // GSpawnFlags NULL, // child_setup NULL, // user_data #ifdef _WIN32 &hProc, // child_pid (Windows HANDLE) #else NULL, // child_pid #endif NULL); // GError** // free arguments g_ptr_array_free (args, TRUE); g_strfreev (argv); // returning value if (retval == TRUE) app->aria2.launched = TRUE; else ug_app_show_message (app, GTK_MESSAGE_ERROR, _("failed to launch aria2.")); return retval; } void ug_app_aria2_shutdown (UgAppGtk* app) { UgXmlrpc* xmlrpc; xmlrpc = g_malloc0 (sizeof (UgXmlrpc)); ug_xmlrpc_init (xmlrpc); ug_xmlrpc_use_client (xmlrpc, app->setting.plugin.aria2.uri, NULL); if (app->setting.plugin.aria2.shutdown) { ug_xmlrpc_call (xmlrpc, "aria2.shutdown", NULL); app->aria2.launched = FALSE; } ug_xmlrpc_finalize (xmlrpc); g_free (xmlrpc); } #endif // HAVE_PLUGIN_ARIA2 uget-1.10.4/uget-gtk/UgDownloadWidget.c0000664000175000017500000015467512260761064014614 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include #include #include // Function used by GtkTreeModelSort. static gint ug_download_model_cmp_name (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_complete (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_size (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_percent (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_elapsed (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_left (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_speed (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_upload_speed (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_uploaded (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_ratio (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_retry (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_category (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_url (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_added_on (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); static gint ug_download_model_cmp_completed_on (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data); // signal handler static void on_name_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_complete_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_size_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_percent_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_elapsed_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_left_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_speed_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_upload_speed_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_uploaded_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_ratio_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_retry_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_category_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_url_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_added_on_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); static void on_completed_on_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget); void ug_download_widget_init (UgDownloadWidget* dwidget, GtkTreeModel* model) { GtkTreeSelection* selection; GtkScrolledWindow* scroll; dwidget->self = gtk_scrolled_window_new (NULL, NULL); dwidget->view = ug_download_view_new (); dwidget->model = model; gtk_tree_view_set_model (dwidget->view, model); selection = gtk_tree_view_get_selection (dwidget->view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); scroll = GTK_SCROLLED_WINDOW (dwidget->self); gtk_scrolled_window_set_shadow_type (scroll, GTK_SHADOW_IN); gtk_scrolled_window_set_policy (scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (dwidget->view)); gtk_widget_show_all (dwidget->self); } void ug_download_widget_finalize (UgDownloadWidget* dwidget) { gtk_widget_destroy (dwidget->self); g_object_unref (dwidget->model); } void ug_download_widget_set_filter (UgDownloadWidget* dwidget, GtkTreeModel* model, GtkTreeModelFilterVisibleFunc func, gpointer data) { GtkTreeModel* filter; filter = gtk_tree_model_filter_new (model, NULL); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (filter), func, data, NULL); gtk_tree_view_set_model (dwidget->view, filter); if (dwidget->model) g_object_unref (dwidget->model); dwidget->model = filter; } void ug_download_widget_use_sortable (UgDownloadWidget* dwidget, GtkTreeModel* model) { GtkTreeModel* sort; GtkTreeSortable* sortable; GtkTreeViewColumn* column; sort = gtk_tree_model_sort_new_with_model (model); sortable = GTK_TREE_SORTABLE (sort); gtk_tree_sortable_set_default_sort_func (sortable, ug_download_model_cmp_name, NULL, NULL); gtk_tree_view_set_model (dwidget->view, sort); if (dwidget->model) g_object_unref (dwidget->model); dwidget->model = sort; // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_NAME column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_NAME); gtk_tree_view_column_set_clickable (column, TRUE); gtk_tree_view_column_set_sort_indicator (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_name_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_COMPLETE column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_COMPLETE); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_complete_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_SIZE column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_SIZE); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_size_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_PERCENT column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_PERCENT); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_percent_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_ELAPSED column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_ELAPSED); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_elapsed_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_LEFT column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_LEFT); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_left_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_SPEED column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_SPEED); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_speed_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_UPLOAD_SPEED column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_UPLOAD_SPEED); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_upload_speed_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_UPLOADED column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_UPLOADED); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_uploaded_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_RATIO column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_RATIO); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_ratio_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_RETRY column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_RETRY); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_retry_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_CATEGORY column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_CATEGORY); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_category_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_URL column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_URL); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_url_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_ADDED_ON column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_ADDED_ON); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_added_on_column_clicked), dwidget); // GtkTreeViewColumn - UG_DOWNLOAD_COLUMN_COMPLETED_ON column = gtk_tree_view_get_column (dwidget->view, UG_DOWNLOAD_COLUMN_COMPLETED_ON); gtk_tree_view_column_set_clickable (column, TRUE); g_signal_connect (column, "clicked", G_CALLBACK (on_completed_on_column_clicked), dwidget); } GList* ug_download_widget_get_selected (UgDownloadWidget* dwidget) { UgDataset* dataset; GtkTreeSelection* selection; GtkTreeModel* model; GtkTreeIter iter; GList* list; GList* link; selection = gtk_tree_view_get_selection (dwidget->view); list = gtk_tree_selection_get_selected_rows (selection, &model); for (link = list; link; link = link->next) { gtk_tree_model_get_iter (model, &iter, link->data); gtk_tree_model_get (model, &iter, 0, &dataset, -1); gtk_tree_path_free (link->data); link->data = dataset; } return list; } GList* ug_download_widget_get_selected_indices (UgDownloadWidget* dwidget) { GtkTreeSelection* selection; GList* list; GList* link; gint index; selection = gtk_tree_view_get_selection (dwidget->view); list = gtk_tree_selection_get_selected_rows (selection, NULL); for (link = list; link; link = link->next) { index = *gtk_tree_path_get_indices (link->data); gtk_tree_path_free (link->data); link->data = GINT_TO_POINTER (index); } return list; } gint ug_download_widget_count_selected (UgDownloadWidget* dwidget) { GtkTreeSelection* selection; selection = gtk_tree_view_get_selection (dwidget->view); return gtk_tree_selection_count_selected_rows (selection); } UgDataset* ug_download_widget_get_cursor (UgDownloadWidget* dwidget) { UgDataset* dataset; GtkTreePath* path; GtkTreeIter iter; gboolean valid; gtk_tree_view_get_cursor (dwidget->view, &path, NULL); if (path) { valid = gtk_tree_model_get_iter (dwidget->model, &iter, path); gtk_tree_path_free (path); if (valid) { gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); return dataset; } } return NULL; } // ---------------------------------------------------------------------------- // GtkTreeView for UgDataset // #define UG_DOWNLOAD_ICON_NORMAL GTK_STOCK_FILE #define UG_DOWNLOAD_ICON_PAUSED GTK_STOCK_MEDIA_PAUSE #define UG_DOWNLOAD_ICON_ACTIVE GTK_STOCK_MEDIA_PLAY #define UG_DOWNLOAD_ICON_COMPLETED GTK_STOCK_YES #define UG_DOWNLOAD_ICON_ERROR GTK_STOCK_DIALOG_ERROR #define UG_DOWNLOAD_ICON_RECYCLED GTK_STOCK_DELETE #define UG_DOWNLOAD_ICON_FINISHED GTK_STOCK_GOTO_LAST static void col_set_icon (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; const gchar* stock_id; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; relation = UG_DATASET_RELATION (dataset); // set stock_id if (relation->hints & UG_HINT_DOWNLOADING) stock_id = UG_DOWNLOAD_ICON_ACTIVE; else if (relation->hints & UG_HINT_PAUSED) stock_id = UG_DOWNLOAD_ICON_PAUSED; else if (relation->hints & UG_HINT_ERROR) stock_id = UG_DOWNLOAD_ICON_ERROR; else if (relation->hints & UG_HINT_COMPLETED) stock_id = UG_DOWNLOAD_ICON_COMPLETED; else stock_id = UG_DOWNLOAD_ICON_NORMAL; g_object_set (cell, "stock-id", stock_id, NULL); } static void col_set_icon_all (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; const gchar* stock_id; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; relation = UG_DATASET_RELATION (dataset); // set stock_id if (relation->hints & UG_HINT_RECYCLED) stock_id = UG_DOWNLOAD_ICON_RECYCLED; else if (relation->hints & UG_HINT_FINISHED) stock_id = UG_DOWNLOAD_ICON_FINISHED; else if (relation->hints & UG_HINT_DOWNLOADING) stock_id = UG_DOWNLOAD_ICON_ACTIVE; else if (relation->hints & UG_HINT_PAUSED) stock_id = UG_DOWNLOAD_ICON_PAUSED; else if (relation->hints & UG_HINT_ERROR) stock_id = UG_DOWNLOAD_ICON_ERROR; else if (relation->hints & UG_HINT_COMPLETED) stock_id = UG_DOWNLOAD_ICON_COMPLETED; else stock_id = UG_DOWNLOAD_ICON_NORMAL; g_object_set (cell, "stock-id", stock_id, NULL); } static void col_set_name (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetCommon* common; gchar* string = NULL; gchar* name = NULL; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; common = UG_DATASET_COMMON (dataset); if (common->name) string = common->name; else if (common->file) string = common->file; else { if (common->url) name = ug_uri_get_filename (common->url); if (name == NULL) name = g_strconcat (_("unnamed"), " ", common->url, NULL); string = name; } g_object_set (cell, "text", string, NULL); g_free (name); } static void col_set_complete (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); if (progress) string = ug_str_dtoa_unit ((gdouble) progress->complete, 1, NULL); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_total (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); if (progress) string = ug_str_dtoa_unit ((gdouble) progress->total, 1, NULL); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_percent (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); if (progress) { // string = g_strdup_printf ("%.*f%c", 1, progress->percent, '%'); string = g_strdup_printf ("%.1f%c", progress->percent, '%'); g_object_set (cell, "visible", 1, NULL); g_object_set (cell, "value", (gint) progress->percent, NULL); g_object_set (cell, "text", string, NULL); g_free (string); } else { g_object_set (cell, "visible", 0, NULL); g_object_set (cell, "value", 0, NULL); g_object_set (cell, "text", "", NULL); } } static void col_set_consume_time (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); if (progress) string = ug_str_from_seconds ((guint) progress->consume_time, TRUE); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_remain_time (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); relation = UG_DATASET_RELATION (dataset); if (progress && relation && relation->plugin) string = ug_str_from_seconds ((guint) progress->remain_time, TRUE); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_speed (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); relation = UG_DATASET_RELATION (dataset); if (progress && relation && relation->plugin) string = ug_str_dtoa_unit ((gdouble) progress->download_speed, 1, "/s"); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_upload_speed (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); relation = UG_DATASET_RELATION (dataset); if (progress && relation && relation->plugin && progress->upload_speed) string = ug_str_dtoa_unit ((gdouble) progress->upload_speed, 1, "/s"); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_uploaded (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); if (progress && progress->uploaded) string = ug_str_dtoa_unit ((gdouble) progress->uploaded, 1, NULL); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_ratio (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetProgress* progress; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; progress = UG_DATASET_PROGRESS (dataset); if (progress && progress->ratio) string = g_strdup_printf ("%.2f", progress->ratio); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_retry (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetCommon* common; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; common = UG_DATASET_COMMON (dataset); if (common->retry_count != 0) string = g_strdup_printf ("%d", common->retry_count); else string = NULL; g_object_set (cell, "text", string, NULL); g_free (string); } static void col_set_category (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; relation = UG_DATASET_RELATION (dataset); if (relation && relation->category) string = relation->category->name; else string = NULL; g_object_set (cell, "text", string, NULL); } static void col_set_url (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; g_object_set (cell, "text", UG_DATASET_COMMON (dataset)->url, NULL); } static void col_set_added_on (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetLog* datalog; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; datalog = ug_dataset_get (dataset, UgetLogInfo, 0); string = (datalog) ? datalog->added_on : NULL; g_object_set (cell, "text", string, NULL); } static void col_set_completed_on (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetLog* datalog; gchar* string; gtk_tree_model_get (model, iter, 0, &dataset, -1); // avoid crash in GTK3 if (dataset == NULL) return; datalog = ug_dataset_get (dataset, UgetLogInfo, 0); string = (datalog) ? datalog->completed_on : NULL; g_object_set (cell, "text", string, NULL); } GtkTreeView* ug_download_view_new (void) { GtkTreeView* tview; GtkTreeSelection* selection; GtkCellRenderer* renderer; GtkCellRenderer* renderer_progress; GtkTreeViewColumn* column; tview = (GtkTreeView*)gtk_tree_view_new (); gtk_tree_view_set_fixed_height_mode (tview, TRUE); selection = gtk_tree_view_get_selection (tview); gtk_tree_selection_set_mode (selection, GTK_SELECTION_MULTIPLE); // column name column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Name")); renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_icon, NULL, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_name, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 180); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (tview, column); // column completed column = gtk_tree_view_column_new (); renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "xalign", 1.0, NULL); gtk_tree_view_column_set_title (column, _("Complete")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_complete, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 80); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // column total column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Size")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_total, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 80); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // column percent column = gtk_tree_view_column_new (); renderer_progress = gtk_cell_renderer_progress_new (); gtk_tree_view_column_set_title (column, _("%")); gtk_tree_view_column_pack_start (column, renderer_progress, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer_progress, col_set_percent, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 60); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // column "Elapsed" for consuming time column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Elapsed")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_consume_time, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 65); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // column "Left" for remaining time column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Left")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_remain_time, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 65); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // columns speed column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Speed")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_speed, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 90); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // columns upload speed column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Up Speed")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_upload_speed, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 90); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // columns uploaded column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Uploaded")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_uploaded, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 80); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // columns ratio column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Ratio")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_ratio, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 45); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // column retries column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Retry")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_retry, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 45); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_column_set_alignment (column, 1.0); gtk_tree_view_append_column (tview, column); // column category renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Category")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_category, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 100); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (tview, column); // column url // renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("URL")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_url, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 300); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (tview, column); // column addon_on // renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Added On")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_added_on, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 140); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (tview, column); // column completed_on // renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Completed On")); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_completed_on, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_min_width (column, 140); gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (tview, column); gtk_widget_show (GTK_WIDGET (tview)); return tview; } void ug_download_view_use_all_icon (GtkTreeView* view, gboolean visible_all) { GtkCellRenderer* renderer; GtkTreeViewColumn* column; // clear column = gtk_tree_view_get_column (view, 0); gtk_tree_view_column_clear (column); // pack icon renderer renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); if (visible_all) { gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_icon_all, NULL, NULL); } else { gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_icon, NULL, NULL); } // pack text renderer renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_name, NULL, NULL); } static void ug_download_view_clear_sort_status (GtkTreeView* view) { GtkTreeViewColumn* column; gint index; for (index = 0; index < UG_DOWNLOAD_N_COLUMN; index++) { column = gtk_tree_view_get_column (view, index); gtk_tree_view_column_set_sort_order (column, GTK_SORT_ASCENDING); gtk_tree_view_column_set_sort_indicator (column, FALSE); } } void ug_download_view_set_sort_order (GtkTreeView* view, guint nth_column, GtkSortType sorttype) { GtkTreeViewColumn* column; GtkTreeSortable* sortable; GtkTreeIterCompareFunc func; sortable = GTK_TREE_SORTABLE (gtk_tree_view_get_model (view)); column = gtk_tree_view_get_column (view, nth_column); ug_download_view_clear_sort_status (view); gtk_tree_view_column_set_sort_order (column, sorttype); gtk_tree_view_column_set_sort_indicator (column, TRUE); switch (nth_column) { case UG_DOWNLOAD_COLUMN_NAME: func = ug_download_model_cmp_name; break; case UG_DOWNLOAD_COLUMN_COMPLETE: func = ug_download_model_cmp_complete; break; case UG_DOWNLOAD_COLUMN_SIZE: func = ug_download_model_cmp_size; break; case UG_DOWNLOAD_COLUMN_PERCENT: func = ug_download_model_cmp_percent; break; case UG_DOWNLOAD_COLUMN_ELAPSED: func = ug_download_model_cmp_elapsed; break; case UG_DOWNLOAD_COLUMN_LEFT: func = ug_download_model_cmp_left; break; case UG_DOWNLOAD_COLUMN_SPEED: func = ug_download_model_cmp_speed; break; case UG_DOWNLOAD_COLUMN_UPLOAD_SPEED: func = ug_download_model_cmp_upload_speed; break; case UG_DOWNLOAD_COLUMN_UPLOADED: func = ug_download_model_cmp_uploaded; break; case UG_DOWNLOAD_COLUMN_RATIO: func = ug_download_model_cmp_ratio; break; case UG_DOWNLOAD_COLUMN_RETRY: func = ug_download_model_cmp_retry; break; case UG_DOWNLOAD_COLUMN_CATEGORY: func = ug_download_model_cmp_category; break; case UG_DOWNLOAD_COLUMN_URL: func = ug_download_model_cmp_url; break; case UG_DOWNLOAD_COLUMN_ADDED_ON: func = ug_download_model_cmp_added_on; break; case UG_DOWNLOAD_COLUMN_COMPLETED_ON: func = ug_download_model_cmp_completed_on; break; default: func = NULL; break; } gtk_tree_sortable_set_default_sort_func (sortable, func, GINT_TO_POINTER (sorttype), NULL); } // ---------------------------------------------------------------------------- // Function used by GtkTreeModelSort. // static gint ug_download_model_cmp_name (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetCommon* common; gchar* name1; gchar* name2; name1 = NULL; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { common = UG_DATASET_COMMON (dataset); if (common) { if (common->name) name1 = common->name; else if (common->file) name1 = common->file; } } name2 = NULL; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { common = UG_DATASET_COMMON (dataset); if (common) { if (common->name) name2 = common->name; else if (common->file) name2 = common->file; } } // g_strcmp0 can handle NULL gracefully by sorting it before non-NULL strings. if (user_data == NULL) return g_strcmp0 (name1, name2); else return g_strcmp0 (name2, name1); } static gint ug_download_model_cmp_complete (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gint64 completed1; gint64 completed2; completed1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) completed1 = progress->complete; } completed2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) completed2 = progress->complete; } if (user_data == NULL) return (gint) (completed1 - completed2); else return (gint) (completed2 - completed1); } static gint ug_download_model_cmp_size (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gint64 size1; gint64 size2; size1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) size1 = progress->total; } size2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) size2 = progress->total; } if (user_data == NULL) return (gint) (size1 - size2); else return (gint) (size2 - size1); } static gint ug_download_model_cmp_percent (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gdouble percent1; gdouble percent2; percent1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) percent1 = progress->percent; } percent2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) percent2 = progress->percent; } if (user_data == NULL) return (gint) (percent1 - percent2); else return (gint) (percent2 - percent1); } static gint ug_download_model_cmp_elapsed (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gdouble elapsed1; gdouble elapsed2; elapsed1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) elapsed1 = progress->consume_time; } elapsed2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) elapsed2 = progress->consume_time; } if (user_data == NULL) return (gint) (elapsed1 - elapsed2); else return (gint) (elapsed2 - elapsed1); } static gint ug_download_model_cmp_left (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gdouble left1; gdouble left2; left1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) left1 = progress->remain_time; } left2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) left2 = progress->remain_time; } if (user_data == NULL) return (gint) (left1 - left2); else return (gint) (left2 - left1); } static gint ug_download_model_cmp_speed (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gdouble speed1; gdouble speed2; speed1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) speed1 = progress->download_speed; } speed2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) speed2 = progress->download_speed; } if (user_data == NULL) return (gint) (speed1 - speed2); else return (gint) (speed2 - speed1); } static gint ug_download_model_cmp_upload_speed (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gdouble speed1; gdouble speed2; speed1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) speed1 = progress->upload_speed; } speed2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) speed2 = progress->upload_speed; } if (user_data == NULL) return (gint) (speed1 - speed2); else return (gint) (speed2 - speed1); } static gint ug_download_model_cmp_uploaded (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gint64 uploaded1; gint64 uploaded2; uploaded1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) uploaded1 = progress->uploaded; } uploaded2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) uploaded2 = progress->uploaded; } if (user_data == NULL) return (gint) (uploaded1 - uploaded2); else return (gint) (uploaded2 - uploaded1); } static gint ug_download_model_cmp_ratio (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetProgress* progress; gdouble ratio1; gdouble ratio2; ratio1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) ratio1 = progress->ratio; } ratio2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { progress = UG_DATASET_PROGRESS (dataset); if (progress) ratio2 = progress->ratio; } if (user_data == NULL) return (gint) (ratio1 - ratio2); else return (gint) (ratio2 - ratio1); } static gint ug_download_model_cmp_retry (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetCommon* common; gint retry1; gint retry2; retry1 = 0; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { common = UG_DATASET_COMMON (dataset); if (common) retry1 = common->retry_count; } retry2 = 0; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { common = UG_DATASET_COMMON (dataset); if (common) retry2 = common->retry_count; } if (user_data == NULL) return retry1 - retry2; else return retry2 - retry1; } static gint ug_download_model_cmp_category (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgCategory* category; gchar* name1; gchar* name2; name1 = NULL; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { category = UG_DATASET_RELATION (dataset)->category; if (category) name1 = category->name; } name2 = NULL; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { category = UG_DATASET_RELATION (dataset)->category; if (category) name2 = category->name; } // g_strcmp0 can handle NULL gracefully by sorting it before non-NULL strings. if (user_data == NULL) return g_strcmp0 (name1, name2); else return g_strcmp0 (name2, name1); } static gint ug_download_model_cmp_url (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetCommon* common; gchar* url1; gchar* url2; url1 = NULL; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { common = UG_DATASET_COMMON (dataset); if (common) url1 = common->url; } url2 = NULL; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { common = UG_DATASET_COMMON (dataset); if (common) url2 = common->url; } // g_strcmp0 can handle NULL gracefully by sorting it before non-NULL strings. if (user_data == NULL) return g_strcmp0 (url1, url2); else return g_strcmp0 (url2, url1); } static gint ug_download_model_cmp_added_on (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetLog* datalog; gchar* log1; gchar* log2; log1 = NULL; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { datalog = ug_dataset_get (dataset, UgetLogInfo, 0); if (datalog) log1 = datalog->added_on; } log2 = NULL; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { datalog = ug_dataset_get (dataset, UgetLogInfo, 0); if (datalog) log2 = datalog->added_on; } // g_strcmp0 can handle NULL gracefully by sorting it before non-NULL strings. if (user_data == NULL) return g_strcmp0 (log1, log2); else return g_strcmp0 (log2, log1); } static gint ug_download_model_cmp_completed_on (GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, gpointer user_data) { UgDataset* dataset; UgetLog* datalog; gchar* log1; gchar* log2; log1 = NULL; gtk_tree_model_get (model, a, 0, &dataset, -1); if (dataset) { datalog = ug_dataset_get (dataset, UgetLogInfo, 0); if (datalog) log1 = datalog->completed_on; } log2 = NULL; gtk_tree_model_get (model, b, 0, &dataset, -1); if (dataset) { datalog = ug_dataset_get (dataset, UgetLogInfo, 0); if (datalog) log2 = datalog->completed_on; } // g_strcmp0 can handle NULL gracefully by sorting it before non-NULL strings. if (user_data == NULL) return g_strcmp0 (log1, log2); else return g_strcmp0 (log2, log1); } // ---------------------------------------------------------------------------- // signal handler // static void ug_tree_view_column_clicked (GtkTreeViewColumn *treecolumn, GtkTreeView* view, GtkTreeIterCompareFunc func) { GtkSortType sorttype; GtkTreeSortable* sortable; sortable = GTK_TREE_SORTABLE (gtk_tree_view_get_model (view)); sorttype = gtk_tree_view_column_get_sort_order (treecolumn); if (gtk_tree_view_column_get_sort_indicator (treecolumn)) { if (sorttype == GTK_SORT_ASCENDING) sorttype = GTK_SORT_DESCENDING; else sorttype = GTK_SORT_ASCENDING; } ug_download_view_clear_sort_status (view); gtk_tree_view_column_set_sort_order (treecolumn, sorttype); gtk_tree_view_column_set_sort_indicator (treecolumn, TRUE); gtk_tree_sortable_set_default_sort_func (sortable, func, GINT_TO_POINTER (sorttype), NULL); } static void on_name_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_name); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_NAME; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_complete_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_complete); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_COMPLETE; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_size_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_size); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_SIZE; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_percent_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_percent); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_PERCENT; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_elapsed_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_elapsed); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_ELAPSED; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_left_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_left); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_LEFT; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_speed_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_speed); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_SPEED; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_upload_speed_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_upload_speed); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_UPLOAD_SPEED; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_uploaded_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_uploaded); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_UPLOADED; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_ratio_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_ratio); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_RATIO; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_retry_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_retry); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_RETRY; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_category_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_category); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_CATEGORY; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_url_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_url); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_URL; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_added_on_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_added_on); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_ADDED_ON; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } static void on_completed_on_column_clicked (GtkTreeViewColumn *treecolumn, UgDownloadWidget* dwidget) { ug_tree_view_column_clicked (treecolumn, dwidget->view, ug_download_model_cmp_completed_on); dwidget->sort.nth = UG_DOWNLOAD_COLUMN_COMPLETED_ON; dwidget->sort.order = gtk_tree_view_column_get_sort_order (treecolumn); } uget-1.10.4/uget-gtk/UgSelector.h0000664000175000017500000001003612260761064013444 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_SELECTOR_H #define UG_SELECTOR_H #include #ifdef __cplusplus extern "C" { #endif typedef struct UgSelector UgSelector; typedef struct UgSelectorPage UgSelectorPage; typedef void (*UgSelectorNotify) (gpointer user_data, gboolean completed); // ---------------------------------------------------------------------------- // UgSelector // struct UgSelector { GtkWidget* self; // GtkVBox GtkWindow* parent; // parent window of UgSelector.self GtkNotebook* notebook; // GtkWidget* href_label; GtkEntry* href_entry; // entry for hypertext reference GtkWidget* href_separator; // select button GtkWidget* select_all; GtkWidget* select_none; GtkWidget* select_filter; // select by filter // UgSelectorPage is placed in array GArray* pages; // UgSelectorFilter use UgSelectorFilterData in UgSelectorPage struct UgSelectorFilter { GtkDialog* dialog; GtkTreeView* host_view; GtkTreeView* ext_view; } filter; // callback struct { UgSelectorNotify func; gpointer data; } notify; }; void ug_selector_init (UgSelector* selector, GtkWindow* parent); void ug_selector_finalize (UgSelector* selector); void ug_selector_hide_href (UgSelector* selector); // (UgDataset*) list->data. // To free the returned value, use: // g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); // g_list_free (list); GList* ug_selector_get_marked_downloads (UgSelector* selector); // count marked item and notify gint ug_selector_count_marked (UgSelector* selector); UgSelectorPage* ug_selector_add_page (UgSelector* selector, const gchar* title); UgSelectorPage* ug_selector_get_page (UgSelector* selector, gint nth_page); // ---------------------------------------------------------------------------- // UgSelectorPage // struct UgSelectorPage { GtkWidget* self; // GtkScrolledWindow GtkTreeView* view; GtkListStore* store; // total marked count gint n_marked; // used by UgSelectorFilter struct UgSelectorFilterData { GHashTable* hash; GtkListStore* host; GtkListStore* ext; } filter; }; void ug_selector_page_init (UgSelectorPage* page); void ug_selector_page_finalize (UgSelectorPage* page); void ug_selector_page_add_uris (UgSelectorPage* page, GList* uris); void ug_selector_page_add_downloads (UgSelectorPage* page, GList* downloads); void ug_selector_page_make_filter (UgSelectorPage* page); void ug_selector_page_mark_by_filter_all (UgSelectorPage* page); #ifdef __cplusplus } #endif #endif // End of UG_SELECTOR_H uget-1.10.4/uget-gtk/UgSettingDialog.h0000664000175000017500000000531512260761064014425 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_SETTING_DIALOG_H #define UG_SETTING_DIALOG_H #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgSettingDialog UgSettingDialog; // ---------------------------------------------------------------------------- // UgSettingDialog enum UgSettingDialogPage { UG_SETTING_PAGE_UI, UG_SETTING_PAGE_CLIPBOARD, UG_SETTING_PAGE_OTHERS, }; struct UgSettingDialog { GtkDialog* self; GtkNotebook* notebook; struct UgClipboardSettingForm clipboard; struct UgUserInterfaceForm ui; struct UgLaunchSettingForm launch; struct UgAutoSaveForm auto_save; struct UgScheduleForm scheduler; struct UgCommandlineSettingForm commandline; struct UgPluginSettingForm plugin; gpointer user_data; }; UgSettingDialog* ug_setting_dialog_new (const gchar* title, GtkWindow* parent); void ug_setting_dialog_free (UgSettingDialog* dialog); void ug_setting_dialog_get (UgSettingDialog* dialog, UgSetting* setting); void ug_setting_dialog_set (UgSettingDialog* dialog, UgSetting* setting); #ifdef __cplusplus } #endif #endif // End of UG_SETTING_DIALOG_H uget-1.10.4/uget-gtk/UgSettingDialog.c0000664000175000017500000001405312260761064014417 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include UgSettingDialog* ug_setting_dialog_new (const gchar* title, GtkWindow* parent) { UgSettingDialog* dialog; GtkWidget* widget; GtkBox* vbox; dialog = g_malloc0 (sizeof (UgSettingDialog)); dialog->self = (GtkDialog*) gtk_dialog_new_with_buttons (title, parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (dialog->self, GTK_RESPONSE_OK); widget = gtk_notebook_new (); gtk_widget_set_size_request (widget, 430, 320); vbox = (GtkBox*) gtk_dialog_get_content_area (dialog->self); gtk_box_pack_start (vbox, widget, FALSE, FALSE, 0); dialog->notebook = (GtkNotebook*) widget; // ------------------------------------------------------------------------ // UI settings page vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_notebook_append_page (dialog->notebook, (GtkWidget*) vbox, gtk_label_new (_("UI Settings"))); ug_user_interface_form_init (&dialog->ui); gtk_box_pack_start (vbox, dialog->ui.self, FALSE, FALSE, 2); // ------------------------------------------------------------------------ // Clipboard settings page ug_clipboard_setting_form_init (&dialog->clipboard); gtk_container_set_border_width (GTK_CONTAINER (dialog->clipboard.self), 2); gtk_notebook_append_page (dialog->notebook, dialog->clipboard.self, gtk_label_new (_("Clipboard"))); // ------------------------------------------------------------------------ // Scheduler settings page ug_schedule_form_init (&dialog->scheduler); gtk_container_set_border_width (GTK_CONTAINER (dialog->scheduler.self), 2); gtk_notebook_append_page (dialog->notebook, dialog->scheduler.self, gtk_label_new (_("Scheduler"))); #ifdef HAVE_PLUGIN_ARIA2 // ------------------------------------------------------------------------ // Plugin settings page ug_plugin_setting_form_init (&dialog->plugin); gtk_container_set_border_width (GTK_CONTAINER (dialog->plugin.self), 2); gtk_notebook_append_page (dialog->notebook, dialog->plugin.self, gtk_label_new (_("Plug-in"))); #endif // HAVE_PLUGIN_ARIA2 // ------------------------------------------------------------------------ // Others settings page vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); gtk_container_set_border_width (GTK_CONTAINER (vbox), 2); gtk_notebook_append_page (dialog->notebook, (GtkWidget*) vbox, gtk_label_new (_("Others"))); ug_commandline_setting_form_init (&dialog->commandline); gtk_box_pack_start (vbox, dialog->commandline.self, FALSE, FALSE, 2); gtk_box_pack_start (vbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 2); ug_auto_save_form_init (&dialog->auto_save); gtk_box_pack_start (vbox, dialog->auto_save.self, FALSE, FALSE, 2); gtk_box_pack_start (vbox, gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), FALSE, FALSE, 2); ug_launch_setting_form_init (&dialog->launch); gtk_box_pack_start (vbox, dialog->launch.self, FALSE, FALSE, 2); gtk_widget_show_all ((GtkWidget*) dialog->notebook); // gtk_container_set_focus_child (GTK_CONTAINER (dialog->self), dialog->pattern_entry); // g_signal_connect (dialog->pattern_entry, "key-press-event", G_CALLBACK (on_key_press_event), dialog); return dialog; } void ug_setting_dialog_free (UgSettingDialog* dialog) { gtk_widget_destroy ((GtkWidget*) dialog->self); g_free (dialog); } void ug_setting_dialog_set (UgSettingDialog* dialog, UgSetting* setting) { ug_schedule_form_set (&dialog->scheduler, setting); ug_clipboard_setting_form_set (&dialog->clipboard, setting); ug_user_interface_form_set (&dialog->ui, setting); ug_launch_setting_form_set (&dialog->launch, setting); ug_auto_save_form_set (&dialog->auto_save, setting); ug_commandline_setting_form_set (&dialog->commandline, setting); #ifdef HAVE_PLUGIN_ARIA2 ug_plugin_setting_form_set (&dialog->plugin, setting); #endif } void ug_setting_dialog_get (UgSettingDialog* dialog, UgSetting* setting) { ug_schedule_form_get (&dialog->scheduler, setting); ug_clipboard_setting_form_get (&dialog->clipboard, setting); ug_user_interface_form_get (&dialog->ui, setting); ug_launch_setting_form_get (&dialog->launch, setting); ug_auto_save_form_get (&dialog->auto_save, setting); ug_commandline_setting_form_get (&dialog->commandline, setting); #ifdef HAVE_PLUGIN_ARIA2 ug_plugin_setting_form_get (&dialog->plugin, setting); #endif } uget-1.10.4/uget-gtk/UgSelector.c0000664000175000017500000006307212260761064013447 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include // UG_APP_GTK_NAME #include // ---------------------------------------------------------------------------- // UgSelectorItem // typedef struct UgSelectorItem UgSelectorItem; struct UgSelectorItem { gboolean mark; gchar* uri; UgDataset* dataset; }; // GtkListStore for UgSelectorItem static GList* ug_selector_store_get_marked (GtkListStore* store, GList* list); static void ug_selector_store_set_mark_all (GtkListStore* store, gboolean mark); static void ug_selector_store_clear (GtkListStore* store); // GtkTreeView for UgSelectorItem static GtkTreeView* ug_selector_view_new (const gchar* title, gboolean active_toggled); static GtkCellRenderer* ug_selector_view_get_renderer_toggle (GtkTreeView* view); // ---------------------------------------------------------------------------- // UgSelector // static void ug_selector_filter_init (struct UgSelectorFilter* filter, UgSelector* selector); static void ug_selector_filter_show (struct UgSelectorFilter* filter, UgSelectorPage* page); // signal handlers static void on_selector_item_toggled (GtkCellRendererToggle* cell, gchar* path_str, UgSelector* selector); static void on_selector_mark_all (GtkWidget* button, UgSelector* selector); static void on_selector_mark_none (GtkWidget* button, UgSelector* selector); static void on_selector_mark_filter (GtkWidget* button, UgSelector* selector); static void on_filter_dialog_response (GtkDialog* dialog, gint response_id, UgSelector* selector); static void on_filter_button_all (GtkWidget* widget, GtkTreeView* treeview); static void on_filter_button_none (GtkWidget* widget, GtkTreeView* treeview); void ug_selector_init (UgSelector* selector, GtkWindow* parent) { GtkBox* vbox; GtkBox* hbox; GtkWidget* widget; gchar* string; selector->parent = parent; selector->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); vbox = (GtkBox*) selector->self; hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); string = g_strconcat (_("Base hypertext reference"), " :", NULL); selector->href_label = gtk_label_new (string); g_free (string); gtk_box_pack_start (hbox, selector->href_label, FALSE, TRUE, 1); selector->href_entry = (GtkEntry*) gtk_entry_new (); gtk_box_pack_start (vbox, (GtkWidget*) selector->href_entry, FALSE, FALSE, 1); selector->href_separator = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (vbox, selector->href_separator, FALSE, FALSE, 1); selector->notebook = (GtkNotebook*) gtk_notebook_new (); gtk_box_pack_start (vbox, (GtkWidget*) selector->notebook, TRUE, TRUE, 1); hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 1); // select all widget = gtk_button_new_with_mnemonic (_("Mark _All")); g_signal_connect (widget, "clicked", G_CALLBACK (on_selector_mark_all), selector); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 1); selector->select_all = widget; // select none widget = gtk_button_new_with_mnemonic (_("Mark _None")); g_signal_connect (widget, "clicked", G_CALLBACK (on_selector_mark_none), selector); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 1); selector->select_none = widget; // select by filter widget = gtk_button_new_with_mnemonic (_("_Mark by filter...")); g_signal_connect (widget, "clicked", G_CALLBACK (on_selector_mark_filter), selector); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 1); selector->select_filter = widget; gtk_widget_show_all ((GtkWidget*) vbox); // UgSelectorPage initialize selector->pages = g_array_new (FALSE, FALSE, sizeof (UgSelectorPage)); // UgSelectorFilter initialize ug_selector_filter_init (&selector->filter, selector); } void ug_selector_finalize (UgSelector* selector) { UgSelectorPage* page; GArray* array; guint index; // UgSelectorPage finalize array = selector->pages; for (index=0; index < array->len; index++) { page = &g_array_index (array, UgSelectorPage, index); ug_selector_page_finalize (page); } g_array_free (selector->pages, TRUE); // UgSelectorFilter finalize gtk_widget_destroy (GTK_WIDGET (selector->filter.dialog)); } void ug_selector_hide_href (UgSelector* selector) { gtk_widget_hide ((GtkWidget*) selector->href_label); gtk_widget_hide ((GtkWidget*) selector->href_entry); gtk_widget_hide ((GtkWidget*) selector->href_separator); } static GList* ug_selector_get_marked (UgSelector* selector) { UgSelectorPage* page; GList* list; guint index; list = NULL; for (index = 0; index < selector->pages->len; index++) { page = &g_array_index (selector->pages, UgSelectorPage, index); list = ug_selector_store_get_marked (page->store, list); } return g_list_reverse (list); } GList* ug_selector_get_marked_downloads (UgSelector* selector) { UgSelectorItem* item; UgDataset* dataset; UgetCommon* common; GString* gstr; GList* list; GList* link; const gchar* base_href; list = ug_selector_get_marked (selector); base_href = gtk_entry_get_text (selector->href_entry); if (base_href[0] == 0) base_href = NULL; for (link = list; link; link = link->next) { item = link->data; // UgDataset list if (item->dataset) { dataset = item->dataset; ug_dataset_ref (dataset); link->data = dataset; // item->uri = NULL; continue; } // URI list if (ug_uri_scheme_len (item->uri) == 0 && base_href) { gstr = g_string_new (base_href); if (gstr->str[gstr->len -1] == '/') { if (item->uri[0] == '/') g_string_truncate (gstr, gstr->len -1); } else if (item->uri[0] != '/') g_string_append_c (gstr, '/'); g_string_append (gstr, item->uri); } else gstr = g_string_new (item->uri); dataset = ug_dataset_new (); common = ug_dataset_realloc (dataset, UgetCommonInfo, 0); common->url = g_string_free (gstr, FALSE); common->keeping.url = TRUE; link->data = dataset; } return list; } gint ug_selector_count_marked (UgSelector* selector) { gint count; guint index; count = 0; for (index = 0; index < selector->pages->len; index++) { count += g_array_index (selector->pages, UgSelectorPage, index).n_marked; // count += page->n_marked; } if (selector->notify.func) selector->notify.func (selector->notify.data, (count) ? TRUE: FALSE); return count; } UgSelectorPage* ug_selector_add_page (UgSelector* selector, const gchar* title) { GtkCellRenderer* renderer; UgSelectorPage* page; GArray* array; array = selector->pages; g_array_set_size (array, array->len + 1); page = &g_array_index (array, UgSelectorPage, array->len - 1); ug_selector_page_init (page); renderer = ug_selector_view_get_renderer_toggle (page->view); g_signal_connect (renderer, "toggled", G_CALLBACK (on_selector_item_toggled), selector); gtk_notebook_append_page (selector->notebook, page->self, gtk_label_new (title)); return page; } UgSelectorPage* ug_selector_get_page (UgSelector* selector, gint nth_page) { UgSelectorPage* page; if (nth_page < 0) nth_page = gtk_notebook_get_current_page (selector->notebook); if (nth_page == -1 || nth_page >= (gint)selector->pages->len) return NULL; page = &g_array_index (selector->pages, UgSelectorPage, nth_page); return page; } // ---------------------------------------------------------------------------- // UgSelectorFilter use UgSelectorFilterData in UgSelectorPage // static GtkWidget* ug_selector_filter_view_init (GtkTreeView* item_view) { GtkSizeGroup* sizegroup; GtkWidget* widget; GtkBox* vbox; GtkBox* hbox; vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); // filter view and it's scrolled window gtk_widget_set_size_request ((GtkWidget*) item_view, 120, 120); widget = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (widget), GTK_SHADOW_IN); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (item_view)); gtk_box_pack_start (vbox, widget, TRUE, TRUE, 2); // button sizegroup = gtk_size_group_new (GTK_SIZE_GROUP_HORIZONTAL); hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, FALSE, FALSE, 2); widget = gtk_button_new_with_label (_("All")); gtk_size_group_add_widget (sizegroup, widget); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 1); g_signal_connect (widget, "clicked", G_CALLBACK (on_filter_button_all), item_view); widget = gtk_button_new_with_label (_("None")); gtk_size_group_add_widget (sizegroup, widget); gtk_box_pack_start (hbox, widget, FALSE, FALSE, 1); g_signal_connect (widget, "clicked", G_CALLBACK (on_filter_button_none), item_view); return (GtkWidget*) vbox; } static void ug_selector_filter_init (struct UgSelectorFilter* filter, UgSelector* selector) { GtkDialog* dialog; GtkWidget* widget; GtkBox* vbox; GtkBox* hbox; gchar* title; title = g_strconcat (UG_APP_GTK_NAME " - ", _("Mark by filter"), NULL); dialog = (GtkDialog*) gtk_dialog_new_with_buttons (title, selector->parent, 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_free (title); gtk_window_set_modal ((GtkWindow*) dialog, FALSE); // gtk_window_set_resizable ((GtkWindow*) dialog, FALSE); gtk_window_set_destroy_with_parent ((GtkWindow*) dialog, TRUE); gtk_window_set_transient_for ((GtkWindow*) dialog, selector->parent); gtk_window_resize ((GtkWindow*) dialog, 480, 330); g_signal_connect (dialog, "response", G_CALLBACK (on_filter_dialog_response), selector); filter->dialog = dialog; vbox = (GtkBox*) gtk_dialog_get_content_area (dialog); gtk_box_pack_start (vbox, gtk_label_new (_("Mark URLs by host AND filename extension.")), FALSE, FALSE, 3); gtk_box_pack_start (vbox, gtk_label_new (_("This will reset all marks of URLs.")), FALSE, FALSE, 3); hbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 2); gtk_box_pack_start (vbox, (GtkWidget*) hbox, TRUE, TRUE, 1); // filter view ----------------------- // left side filter->host_view = ug_selector_view_new (_("Host"), TRUE); widget = ug_selector_filter_view_init (filter->host_view); gtk_box_pack_start (hbox, widget, TRUE, TRUE, 2); // right side (filename extension) filter->ext_view = ug_selector_view_new (_("File Ext."), TRUE); widget = ug_selector_filter_view_init (filter->ext_view); gtk_box_pack_start (hbox, widget, FALSE, TRUE, 2); gtk_widget_show_all (GTK_WIDGET (vbox)); } static void ug_selector_filter_show (struct UgSelectorFilter* filter, UgSelectorPage* page) { GtkWindow* parent; gtk_tree_view_set_model (filter->host_view, GTK_TREE_MODEL (page->filter.host)); gtk_tree_view_set_model (filter->ext_view, GTK_TREE_MODEL (page->filter.ext)); // disable sensitive of parent window // enable sensitive in function on_filter_dialog_response() parent = gtk_window_get_transient_for ((GtkWindow*) filter->dialog); if (parent) gtk_widget_set_sensitive ((GtkWidget*) parent, FALSE); // create filter dialog if (gtk_window_get_modal (parent)) gtk_dialog_run (filter->dialog); else gtk_widget_show ((GtkWidget*) filter->dialog); } // signal handler ------------------------------ static void on_selector_item_toggled (GtkCellRendererToggle* cell, gchar* path_str, UgSelector* selector) { UgSelectorPage* page; UgSelectorItem* item; GtkTreeIter iter; GtkTreePath* path; GtkTreeModel* model; page = ug_selector_get_page (selector, -1); model = GTK_TREE_MODEL (page->store); path = gtk_tree_path_new_from_string (path_str); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, 0, &item, -1); // UgSelectorItem.mark item->mark ^= 1; if (item->mark) page->n_marked++; else page->n_marked--; // count and notify ug_selector_count_marked (selector); } static void on_selector_mark_all (GtkWidget* button, UgSelector* selector) { UgSelectorPage* page; page = ug_selector_get_page (selector, -1); if (page == NULL) return; ug_selector_store_set_mark_all (page->store, TRUE); gtk_widget_queue_draw (GTK_WIDGET (page->view)); // count and notify page->n_marked = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (page->store), NULL); ug_selector_count_marked (selector); } static void on_selector_mark_none (GtkWidget* button, UgSelector* selector) { UgSelectorPage* page; page = ug_selector_get_page (selector, -1); if (page == NULL) return; ug_selector_store_set_mark_all (page->store, FALSE); gtk_widget_queue_draw (GTK_WIDGET (page->view)); // count and notify page->n_marked = 0; ug_selector_count_marked (selector); } static void on_selector_mark_filter (GtkWidget* button, UgSelector* selector) { UgSelectorPage* page; page = ug_selector_get_page (selector, -1); if (page == NULL) return; ug_selector_page_make_filter (page); ug_selector_filter_show (&selector->filter, page); } static void on_filter_dialog_response (GtkDialog* dialog, gint response_id, UgSelector* selector) { UgSelectorPage* page; GtkWindow* parent; if (response_id == GTK_RESPONSE_OK) { // update selection of page page = ug_selector_get_page (selector, -1); if (page) ug_selector_page_mark_by_filter_all (page); } // enable parent window parent = gtk_window_get_transient_for ((GtkWindow*) dialog); if (parent) gtk_widget_set_sensitive ((GtkWidget*) parent, TRUE); // hide filter dialog gtk_widget_hide ((GtkWidget*) dialog); // count and notify ug_selector_count_marked (selector); } static void on_filter_button_all (GtkWidget* widget, GtkTreeView* treeview) { GtkListStore* store; store = (GtkListStore*) gtk_tree_view_get_model (treeview); ug_selector_store_set_mark_all (store, TRUE); gtk_widget_queue_draw ((GtkWidget*) treeview); } static void on_filter_button_none (GtkWidget* widget, GtkTreeView* treeview) { GtkListStore* store; store = (GtkListStore*) gtk_tree_view_get_model (treeview); ug_selector_store_set_mark_all (store, FALSE); gtk_widget_queue_draw ((GtkWidget*) treeview); } // ---------------------------------------------------------------------------- // UgSelectorPage // void ug_selector_page_init (UgSelectorPage* page) { GtkScrolledWindow* scrolled; page->store = gtk_list_store_new (1, G_TYPE_POINTER); page->view = ug_selector_view_new (_("URL"), FALSE); gtk_tree_view_set_model (page->view, GTK_TREE_MODEL (page->store)); // scrolled page->self = gtk_scrolled_window_new (NULL, NULL); scrolled = GTK_SCROLLED_WINDOW (page->self); gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_IN); gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (page->view)); gtk_widget_show (page->self); // total marked count page->n_marked = 0; // UgSelectorFilterData initialize page->filter.hash = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, (GDestroyNotify) g_list_free); page->filter.host = gtk_list_store_new (1, G_TYPE_POINTER); page->filter.ext = gtk_list_store_new (1, G_TYPE_POINTER); } void ug_selector_page_finalize (UgSelectorPage* page) { ug_selector_store_clear (page->store); g_object_unref (page->store); // UgSelectorFilterData finalize g_hash_table_destroy (page->filter.hash); ug_selector_store_clear (page->filter.host); g_object_unref (page->filter.host); ug_selector_store_clear (page->filter.ext); g_object_unref (page->filter.ext); } void ug_selector_page_add_uris (UgSelectorPage* page, GList* uris) { GtkTreeIter iter; UgSelectorItem* item; for (; uris; uris = uris->next) { item = g_slice_alloc (sizeof (UgSelectorItem)); item->mark = TRUE; item->uri = uris->data; item->dataset = NULL; gtk_list_store_append (page->store, &iter); gtk_list_store_set (page->store, &iter, 0, item, -1); page->n_marked++; } } void ug_selector_page_add_downloads (UgSelectorPage* page, GList* list) { GtkTreeIter iter; UgDataset* dataset; UgSelectorItem* item; for (; list; list = list->next) { dataset = list->data; ug_dataset_ref (dataset); item = g_slice_alloc (sizeof (UgSelectorItem)); item->mark = TRUE; item->uri = UG_DATASET_COMMON (dataset)->url; item->dataset = dataset; gtk_list_store_append (page->store, &iter); gtk_list_store_set (page->store, &iter, 0, item, -1); page->n_marked++; } } static void ug_selector_page_add_filter (UgSelectorPage* page, GtkListStore* filter_store, gchar* key, UgSelectorItem* value) { GtkTreeIter iter; UgSelectorItem* filter_item; GList* filter_list; gchar* orig_key; if (g_hash_table_lookup_extended (page->filter.hash, key, (gpointer*) &orig_key, (gpointer*) &filter_list) == FALSE) { filter_item = g_slice_alloc (sizeof (UgSelectorItem)); filter_item->uri = key; filter_item->mark = TRUE; filter_item->dataset = NULL; gtk_list_store_append (filter_store, &iter); gtk_list_store_set (filter_store, &iter, 0, filter_item, -1); filter_list = NULL; } else { g_hash_table_steal (page->filter.hash, key); g_free (key); key = orig_key; } filter_list = g_list_prepend (filter_list, value); g_hash_table_insert (page->filter.hash, key, filter_list); } void ug_selector_page_make_filter (UgSelectorPage* page) { UgUri* upart; UgSelectorItem* item; GtkTreeModel* model; GtkTreeIter iter; int value; gchar* key; if (g_hash_table_size (page->filter.hash)) return; upart = g_slice_alloc (sizeof (UgUri)); model = GTK_TREE_MODEL (page->store); value = gtk_tree_model_get_iter_first (model, &iter); while (value) { gtk_tree_model_get (model, &iter, 0, &item, -1); // create filter by host ---------------- ug_uri_init (upart, item->uri); if (upart->authority) key = g_strndup (item->uri, upart->path); else key = g_strdup ("(none)"); ug_selector_page_add_filter (page, page->filter.host, key, item); // create filter by filename extension -- value = ug_uri_part_file_ext (upart, (const char**) &key); if (value) key = g_strdup_printf (".%.*s", value, key); else key = g_strdup (".(none)"); ug_selector_page_add_filter (page, page->filter.ext, key, item); // next value = gtk_tree_model_iter_next (model, &iter); } g_slice_free1 (sizeof (UgUri), upart); } static void ug_selector_page_mark_by_filter (UgSelectorPage* page, GtkListStore* filter_store) { UgSelectorItem* item; GList* related; GList* marked; GList* link; marked = ug_selector_store_get_marked (filter_store, NULL); for (link = marked; link; link = link->next) { item = link->data; related = g_hash_table_lookup (page->filter.hash, item->uri); for (; related; related = related->next) { item = related->data; item->mark++; // increase mark count } } g_list_free (marked); } void ug_selector_page_mark_by_filter_all (UgSelectorPage* page) { UgSelectorItem* item; GtkTreeModel* model; GtkTreeIter iter; gboolean valid; // clear all mark ug_selector_store_set_mark_all (page->store, FALSE); page->n_marked = 0; // If filter (host and filename extension) was selected, increase mark count. ug_selector_page_mark_by_filter (page, page->filter.host); ug_selector_page_mark_by_filter (page, page->filter.ext); // remark model = GTK_TREE_MODEL (page->store); valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, 0, &item, -1); valid = gtk_tree_model_iter_next (model, &iter); // decrease mark count. If mark count is 2, it still marked. if (item->mark > 0) { item->mark--; if (item->mark) page->n_marked++; } } } // ---------------------------------------------------------------------------- // GtkListStore for UgSelectorItem // (UgItem*) list->data. To free the returned value, call g_list_free() static GList* ug_selector_store_get_marked (GtkListStore* store, GList* list) { UgSelectorItem* item; GtkTreeModel* model; GtkTreeIter iter; gboolean valid; model = GTK_TREE_MODEL (store); valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, 0, &item, -1); valid = gtk_tree_model_iter_next (model, &iter); if (item->mark) list = g_list_prepend (list, item); } return list; } static void ug_selector_store_set_mark_all (GtkListStore* store, gboolean mark) { UgSelectorItem* item; GtkTreeModel* model; GtkTreeIter iter; gboolean valid; model = (GtkTreeModel*) store; valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, 0, &item, -1); valid = gtk_tree_model_iter_next (model, &iter); item->mark = mark; } } static void ug_selector_store_clear (GtkListStore* store) { UgSelectorItem* item; GtkTreeModel* model; GtkTreeIter iter; model = GTK_TREE_MODEL (store); while (gtk_tree_model_get_iter_first (model, &iter)) { gtk_tree_model_get (model, &iter, 0, &item, -1); gtk_list_store_remove (store, &iter); if (item->dataset) ug_dataset_unref (item->dataset); else g_free (item->uri); g_slice_free1 (sizeof (UgSelectorItem), item); } } // ---------------------------------------------------------------------------- // GtkTreeView for UgSelectorItem // static void col_set_toggle (GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgSelectorItem* item; gtk_tree_model_get (model, iter, 0, &item, -1); g_object_set (cell, "active", item->mark, NULL); } static void col_set_uri (GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgSelectorItem* item; gtk_tree_model_get (model, iter, 0, &item, -1); g_object_set (cell, "text", item->uri, NULL); } // toggled callback static void on_cell_toggled (GtkCellRendererToggle* cell, gchar* path_str, GtkTreeView* view) { GtkTreeIter iter; GtkTreePath* path; GtkTreeModel* model; UgSelectorItem* item; path = gtk_tree_path_new_from_string (path_str); model = gtk_tree_view_get_model (view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, 0, &item, -1); item->mark ^= 1; } static GtkTreeView* ug_selector_view_new (const gchar* title, gboolean active_toggled) { GtkTreeView* view; GtkCellRenderer* renderer; GtkTreeViewColumn* column; view = (GtkTreeView*) gtk_tree_view_new (); // gtk_tree_view_set_fixed_height_mode (view, TRUE); // UgSelectorItem.mark renderer = gtk_cell_renderer_toggle_new (); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, "M"); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_toggle, NULL, NULL); gtk_tree_view_column_set_resizable (column, FALSE); gtk_tree_view_column_set_alignment (column, 0.5); gtk_tree_view_column_set_min_width (column, 15); // gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (view, column); if (active_toggled) { g_signal_connect (renderer, "toggled", G_CALLBACK (on_cell_toggled), view); } // UgSelectorItem.uri renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, title); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, col_set_uri, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); // gtk_tree_view_column_set_expand (column, TRUE); // gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (view, column); gtk_widget_show (GTK_WIDGET (view)); return view; } static GtkCellRenderer* ug_selector_view_get_renderer_toggle (GtkTreeView* view) { GtkCellRenderer* renderer; GtkTreeViewColumn* column; GList* list; column = gtk_tree_view_get_column (view, 0); list = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); renderer = list->data; g_list_free (list); return renderer; } uget-1.10.4/uget-gtk/UgBanner.h0000664000175000017500000000436212260761064013076 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_BANNER_H #define UG_BANNER_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgBanner UgBanner; enum UgBannerState { UG_BANNER_DONATION, UG_BANNER_SURVEY, }; // -------------------------------- // Banner struct UgBanner { GtkWidget* self; GtkTextView* text_view; GtkTextBuffer* buffer; GtkTextTag* tag_link; uint8_t hovering_over_link; uint8_t status; } banner; void ug_banner_init (struct UgBanner* banner); void ug_banner_show_donation (struct UgBanner* banner); void ug_banner_show_survey (struct UgBanner* banner); #ifdef __cplusplus } #endif #endif // UG_BANNER_H uget-1.10.4/uget-gtk/UgBatchForm.h0000664000175000017500000000515112260761064013533 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_BATCH_FORM_H #define UG_BATCH_FORM_H #include #ifdef __cplusplus extern "C" { #endif typedef struct UgBatchForm UgBatchForm; typedef void (*UgBatchFormNotify) (gpointer user_data, gboolean completed); struct UgBatchForm { GtkWidget* self; // GtkGrid GtkEntry* entry; // URL, wildcard GtkWidget* radio; // GtkRadioButton // digit mode GtkWidget* spin_from; GtkWidget* spin_to; GtkWidget* spin_digits; GtkWidget* label_to; GtkWidget* label_digits; // character mode GtkEntry* entry_from; GtkEntry* entry_to; GtkWidget* label_case; // preview struct UgBatchFormPreview { GtkWidget* self; // GtkScrolledWindow GtkTreeView* view; GtkListStore* store; guint status; } preview; // callback struct { UgBatchFormNotify func; gpointer data; } notify; }; void ug_batch_form_init (UgBatchForm* bform); void ug_batch_form_update_preview (UgBatchForm* bform); GList* ug_batch_form_get_list (UgBatchForm* bform, gboolean preview); #ifdef __cplusplus } #endif #endif // End of UG_BATCH_FORM_H uget-1.10.4/uget-gtk/UgScheduleForm.h0000664000175000017500000000440212260761064014244 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_SCHEDULE_FORM_H #define UG_SCHEDULE_FORM_H #include #include #ifdef __cplusplus extern "C" { #endif struct UgScheduleForm { GtkWidget* self; GtkWidget* enable; GtkWidget* drawing; guint drawing_offset; GtkWidget* caption; GtkLabel* time_tips; GtkSpinButton* spin_speed; guint state[7][24]; // 1 week, 7 days, 24 hours UgScheduleState last_state; }; void ug_schedule_form_init (struct UgScheduleForm* sform); void ug_schedule_form_get (struct UgScheduleForm* sform, UgSetting* setting); void ug_schedule_form_set (struct UgScheduleForm* sform, UgSetting* setting); #ifdef __cplusplus } #endif #endif // End of UG_SCHEDULE_FORM_H uget-1.10.4/uget-gtk/UgCategory-gtk.c0000664000175000017500000005605312260761064014230 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include // uglib #include #include #include #include // UgCategory::user.category used for getting UgCategoruGtk // UgetRelation::user.category used for getting UgCategoruGtk // UgetRelation::user.storage used for getting GtkListStore in primary UgCategoruGtk // UgetRelation::user.position used for getting GtkTreeIter from GtkListStore in primary UgCategoruGtk // UgetRelation::user.data used for getting UgDownloadWidget // static functions static UgCategoryGtk* ug_category_gtk_new (void); static void ug_category_gtk_free (UgCategoryGtk* cgtk); // free GtkTreeIter in UgetRelation::position static void ug_slice_free_tree_iter (GtkTreeIter* iter); // Function used by GtkTreeModelFilter. static gboolean ug_download_model_filter_category (GtkTreeModel *model, GtkTreeIter *iter, UgCategory* category); static gboolean ug_download_model_filter_active (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); static gboolean ug_download_model_filter_queuing (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); static gboolean ug_download_model_filter_finished (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); static gboolean ug_download_model_filter_recycled (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); const UgCategoryFuncs cgtk_funcs = { ug_category_gtk_add, ug_category_gtk_get_all, ug_category_gtk_get_tasks, ug_category_gtk_changed, }; static UgCategoryGtk* ug_category_gtk_new (void) { UgCategoryGtk* cgtk; GtkTreeView* view; GtkTreeViewColumn* column; cgtk = g_malloc0 (sizeof (UgCategoryGtk)); // initialize UgDownloadWidget ug_download_widget_init (&cgtk->all, NULL); ug_download_widget_init (&cgtk->active, NULL); ug_download_widget_init (&cgtk->queuing, NULL); ug_download_widget_init (&cgtk->finished, NULL); ug_download_widget_init (&cgtk->recycled, NULL); // All view = cgtk->all.view; ug_download_view_use_all_icon (view, TRUE); // Finished column view = cgtk->finished.view; column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_COMPLETE); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_PERCENT); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_LEFT); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_SPEED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_UPLOAD_SPEED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_UPLOADED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_RATIO); gtk_tree_view_column_set_visible (column, FALSE); // Recycled column view = cgtk->recycled.view; column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_ELAPSED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_LEFT); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_SPEED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_UPLOAD_SPEED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_UPLOADED); gtk_tree_view_column_set_visible (column, FALSE); column = gtk_tree_view_get_column (view, UG_DOWNLOAD_COLUMN_RATIO); gtk_tree_view_column_set_visible (column, FALSE); return cgtk; } static void ug_category_gtk_free (UgCategoryGtk* cgtk) { UgDataset* dataset; UgetRelation* relation; GtkTreeModel* model; GtkTreeIter iter; // free UgDownloadWidget ug_download_widget_finalize (&cgtk->all); ug_download_widget_finalize (&cgtk->active); ug_download_widget_finalize (&cgtk->queuing); ug_download_widget_finalize (&cgtk->finished); ug_download_widget_finalize (&cgtk->recycled); // free all tasks model = cgtk->filter; while (gtk_tree_model_get_iter_first (model, &iter)) { gtk_tree_model_get (model, &iter, 0, &dataset, -1); // ug_category_gtk_remove (cgtk, dataset); relation = UG_DATASET_RELATION (dataset); gtk_list_store_remove ( relation->user.storage, relation->user.position); relation->user.storage = NULL; relation->category = NULL; // delete data and files ug_download_delete_temp (dataset); ug_dataset_unref (dataset); } // If it is primary category, UgCategoryGtk::store == UgCategoryGtk::filter // Only primary one has UgCategoryGtk::store if (cgtk->store) g_object_unref (cgtk->store); else if (cgtk->filter) g_object_unref (cgtk->filter); } // If primary == NULL, this category will be a primary category. // One uget-gtk program has only one primary category. // All dataset store in primary category. // Other categories use filter to classify dataset in primary category. UgCategory* ug_category_new_with_gtk (UgCategory* primary) { UgCategory* category; category = ug_category_new (); ug_category_use_gtk (category, primary); return category; } void ug_category_use_gtk (UgCategory* category, UgCategory* primary) { UgCategoryGtk* cgtk; cgtk = category->user.category; if (cgtk == NULL) { cgtk = ug_category_gtk_new (); category->user.category = cgtk; // destroy notify category->destroy.func = (UgNotifyFunc) ug_category_gtk_free; category->destroy.data = category->user.category; // functions category->funcs = &cgtk_funcs; } // primary related code ------------------------------- // If it is primary category, UgCategoryGtk::store == UgCategoryGtk::filter // Only primary one has UgCategoryGtk::store if (cgtk->store) g_object_unref (cgtk->store); else if (cgtk->filter) g_object_unref (cgtk->filter); // If primary == NULL, this is primary category if (primary == NULL) { cgtk->primary = NULL; cgtk->store = gtk_list_store_new (1, G_TYPE_POINTER); cgtk->filter = GTK_TREE_MODEL (cgtk->store); } else { cgtk->primary = primary->user.category; cgtk->store = NULL; cgtk->filter = gtk_tree_model_filter_new ( GTK_TREE_MODEL (cgtk->primary->store), NULL); gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (cgtk->filter), (GtkTreeModelFilterVisibleFunc) ug_download_model_filter_category, category, NULL); } ug_download_widget_use_sortable (&cgtk->all, cgtk->filter); // filter ug_download_widget_set_filter (&cgtk->active, cgtk->all.model, ug_download_model_filter_active, NULL); ug_download_widget_set_filter (&cgtk->queuing, cgtk->filter, ug_download_model_filter_queuing, NULL); ug_download_widget_set_filter (&cgtk->finished, cgtk->filter, ug_download_model_filter_finished, NULL); ug_download_widget_set_filter (&cgtk->recycled, cgtk->filter, ug_download_model_filter_recycled, NULL); } void ug_category_gtk_add (UgCategory* category, UgDataset* dataset) { UgCategoryGtk* cgtk; UgCategoryGtk* primary; UgetRelation* relation; GtkTreeModel* model; GtkTreePath* path; // add and set UgetRelation to dataset relation = UG_DATASET_RELATION (dataset); if (relation == NULL) relation = ug_dataset_alloc_front (dataset, UgetRelationInfo); // GtkTreeIter in relation->user.position if (relation->user.position == NULL) { relation->user.position = g_slice_alloc (sizeof (GtkTreeIter)); relation->destroy.func = (UgNotifyFunc) ug_slice_free_tree_iter; relation->destroy.data = relation->user.position; } cgtk = category->user.category; primary = (cgtk->primary) ? cgtk->primary : cgtk; // If dataset wasn't added to secondary category if (relation->category == NULL && cgtk != primary) { relation->category = category; // if dataset was added to primary GtkListStore if (relation->user.storage) { model = GTK_TREE_MODEL (relation->user.storage); path = gtk_tree_model_get_path (model, relation->user.position); gtk_tree_model_row_changed (model, path, relation->user.position); gtk_tree_path_free (path); } } // If dataset wasn't added to primary category if (relation->user.storage == NULL && primary) { // setup relation->user.data for ug_category_gtk_changed(). relation->hints &= ~UG_HINT_ACTIVE; if (relation->hints & UG_HINT_RECYCLED) relation->user.data = &cgtk->recycled; else if (relation->hints & UG_HINT_FINISHED) relation->user.data = &cgtk->finished; else relation->user.data = &cgtk->queuing; // add to primary category relation->user.storage = primary->store; gtk_list_store_append (relation->user.storage, relation->user.position); gtk_list_store_set (relation->user.storage, relation->user.position, 0, dataset, -1); // reference count ug_dataset_ref (dataset); } } GList* ug_category_gtk_get_all (UgCategory* category) { UgDataset* dataset; GtkTreeModel* model; GtkTreeIter iter; GList* list; gboolean valid; list = NULL; model = ((UgCategoryGtk*)category->user.category)->filter; valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, 0, &dataset, -1); list = g_list_prepend (list, dataset); valid = gtk_tree_model_iter_next (model, &iter); } return g_list_reverse (list); } GList* ug_category_gtk_get_tasks (UgCategory* category) { UgCategoryGtk* cgtk; UgDataset* dataset; UgetRelation* relation; GtkTreeIter iter; gboolean valid; GList* tasks; guint tasks_len; guint temp_len; cgtk = category->user.category; temp_len = gtk_tree_model_iter_n_children (cgtk->active.model, NULL); if (category->active_limit <= temp_len) return NULL; tasks = NULL; tasks_len = 0; temp_len = category->active_limit - temp_len; valid = gtk_tree_model_get_iter_first (cgtk->queuing.model, &iter); while (valid) { gtk_tree_model_get (cgtk->queuing.model, &iter, 0, &dataset, -1); valid = gtk_tree_model_iter_next (cgtk->queuing.model, &iter); // check relation = UG_DATASET_RELATION (dataset); if (relation->hints & UG_HINT_UNRUNNABLE) continue; tasks = g_list_prepend (tasks, dataset); tasks_len++; if (tasks_len >= temp_len) break; } return g_list_reverse (tasks); } void ug_category_gtk_changed (UgCategory* category, UgDataset* dataset) { UgDownloadWidget* dlwidget; UgetRelation* relation; UgCategoryGtk* cgtk; GtkTreeModel* model; GtkTreePath* path; cgtk = category->user.category; relation = UG_DATASET_RELATION (dataset); if (relation->hints & UG_HINT_RECYCLED) { dlwidget = &cgtk->recycled; relation->hints &= ~UG_HINT_FINISHED; } else if (relation->hints & UG_HINT_FINISHED) { dlwidget = &cgtk->finished; relation->hints &= ~UG_HINT_RECYCLED; } else if (relation->hints & UG_HINT_ACTIVE) dlwidget = &cgtk->active; else dlwidget = &cgtk->queuing; // Don't move task to the same UgDownloadWidget. if (relation->user.data == &cgtk->active && dlwidget == &cgtk->queuing) { relation->user.data = dlwidget; gtk_list_store_move_after (relation->user.storage, relation->user.position, NULL); } else if (relation->user.data != dlwidget) { relation->user.data = dlwidget; if (dlwidget == &cgtk->recycled || dlwidget == &cgtk->finished) { gtk_list_store_move_after (relation->user.storage, relation->user.position, NULL); } else { gtk_list_store_move_before (relation->user.storage, relation->user.position, NULL); } } model = GTK_TREE_MODEL (relation->user.storage); path = gtk_tree_model_get_path (model, relation->user.position); gtk_tree_model_row_changed (model, path, relation->user.position); gtk_tree_path_free (path); } void ug_category_gtk_remove (UgCategory* category, UgDataset* dataset) { UgetRelation* relation; relation = UG_DATASET_RELATION (dataset); if (relation->user.storage) { gtk_list_store_remove ( relation->user.storage, relation->user.position); } relation->user.storage = NULL; relation->category = NULL; // delete data and files ug_download_delete_temp (dataset); ug_dataset_unref (dataset); } void ug_category_gtk_clear (UgCategory* category, UgCategoryHints hint, guint from_nth) { UgCategoryGtk* cgtk; UgDataset* dataset; GtkTreeModel* model; GtkTreeIter iter; GList* list; GList* link; gboolean valid; cgtk = category->user.category; if (hint & UG_HINT_RECYCLED) model = cgtk->recycled.model; else if (hint & UG_HINT_FINISHED) model = cgtk->finished.model; else model = cgtk->queuing.model; // get tasks to clear list = NULL; valid = gtk_tree_model_iter_nth_child (model, &iter, NULL, from_nth); while (valid) { gtk_tree_model_get (model, &iter, 0, &dataset, -1); list = g_list_prepend (list, dataset); valid = gtk_tree_model_iter_next (model, &iter); } // remove tasks for (link = list; link; link = link->next) ug_category_gtk_remove (category, link->data); g_list_free (list); } void ug_category_gtk_move_to (UgCategory* category, UgDataset* dataset, UgCategory* category_dest) { UgetRelation* relation; relation = UG_DATASET_RELATION (dataset); if (relation->category == category_dest) return; // move relation->category = category_dest; relation->user.data = NULL; ug_category_gtk_changed (category_dest, dataset); } gboolean ug_category_gtk_move_selected_up (UgCategory* category, UgDownloadWidget* dwidget) { UgDataset* dataset; UgetRelation* relation; UgetRelation* relation_prev; GtkTreeIter iter; GtkTreePath* path; GList* list; GList* link; gint index; gint index_prev; gboolean retval = FALSE; index_prev = -1; list = ug_download_widget_get_selected_indices (dwidget); // scroll to first item if (list) { index = GPOINTER_TO_INT (list->data); if (index > 0) index--; path = gtk_tree_path_new_from_indices (index, -1); gtk_tree_view_scroll_to_cell (dwidget->view, path, NULL, FALSE, 0, 0); gtk_tree_path_free (path); } // move for (link = list; link; link = link->next) { index = GPOINTER_TO_INT (link->data); if (index == index_prev+1) { index_prev++; continue; } index_prev = index - 1; // get previous gtk_tree_model_iter_nth_child (dwidget->model, &iter, NULL, index_prev); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); relation_prev = UG_DATASET_RELATION (dataset); // get current gtk_tree_model_iter_next (dwidget->model, &iter); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); relation = UG_DATASET_RELATION (dataset); // swap gtk_list_store_swap (relation->user.storage, relation->user.position, relation_prev->user.position); retval = TRUE; } g_list_free (list); return retval; } gboolean ug_category_gtk_move_selected_down (UgCategory* category, UgDownloadWidget* dwidget) { UgDataset* dataset; UgetRelation* relation; UgetRelation* relation_next; GtkTreeIter iter; GtkTreePath* path; GList* list; GList* link; gint index; gint index_next; gboolean retval = FALSE; index_next = gtk_tree_model_iter_n_children (dwidget->model, NULL); list = ug_download_widget_get_selected_indices (dwidget); link = g_list_last (list); // scroll to last item if (link) { index = GPOINTER_TO_INT (link->data); if (index < index_next -1) index++; path = gtk_tree_path_new_from_indices (index, -1); gtk_tree_view_scroll_to_cell (dwidget->view, path, NULL, FALSE, 0, 0); gtk_tree_path_free (path); } // move for (; link; link = link->prev) { index = GPOINTER_TO_INT (link->data); if (index == index_next-1) { index_next--; continue; } index_next = index + 1; // get current gtk_tree_model_iter_nth_child (dwidget->model, &iter, NULL, index); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); relation = UG_DATASET_RELATION (dataset); // get next gtk_tree_model_iter_next (dwidget->model, &iter); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); relation_next = UG_DATASET_RELATION (dataset); // swap gtk_list_store_swap (relation->user.storage, relation->user.position, relation_next->user.position); retval = TRUE; } g_list_free (list); return retval; } gboolean ug_category_gtk_move_selected_to_top (UgCategory* category, UgDownloadWidget* dwidget) { UgDataset* dataset; UgetRelation* relation; UgetRelation* relation_top; GtkTreeIter iter; GList* list; GList* link; gint index; gint index_top; // get movable tasks relation_top = NULL; index_top = 0; list = ug_download_widget_get_selected_indices (dwidget); for (link=list; link; link=link->next, index_top++) { index = GPOINTER_TO_INT (link->data); if (index == index_top) { link->data = NULL; continue; } else { gtk_tree_model_iter_nth_child (dwidget->model, &iter, NULL, index); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); link->data = UG_DATASET_RELATION (dataset); } if (relation_top == NULL) { gtk_tree_model_iter_nth_child (dwidget->model, &iter, NULL, index_top); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); relation_top = UG_DATASET_RELATION (dataset); } } list = g_list_remove_all (list, NULL); if (list == NULL) return FALSE; // move to top for (link = list; link; link = link->next) { relation = link->data; gtk_list_store_move_before (relation->user.storage, relation->user.position, relation_top->user.position); } g_list_free (list); // scroll to top gtk_tree_view_scroll_to_point (dwidget->view, -1, 0); return TRUE; } gboolean ug_category_gtk_move_selected_to_bottom (UgCategory* category, UgDownloadWidget* dwidget) { UgDataset* dataset; UgetRelation* relation; UgetRelation* relation_bottom; GtkTreeIter iter; GtkTreePath* path; GList* list; GList* link; gint index; gint index_bottom; // get movable tasks relation_bottom = NULL; index_bottom = gtk_tree_model_iter_n_children (dwidget->model, NULL) - 1; list = ug_download_widget_get_selected_indices (dwidget); list = g_list_reverse (list); for (link=list; link; link=link->next, index_bottom--) { index = GPOINTER_TO_INT (link->data); if (index == index_bottom) { link->data = NULL; continue; } else { gtk_tree_model_iter_nth_child (dwidget->model, &iter, NULL, index); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); link->data = UG_DATASET_RELATION (dataset); } if (relation_bottom == NULL) { gtk_tree_model_iter_nth_child (dwidget->model, &iter, NULL, index_bottom); gtk_tree_model_get (dwidget->model, &iter, 0, &dataset, -1); relation_bottom = UG_DATASET_RELATION (dataset); } } list = g_list_remove_all (list, NULL); if (list == NULL) return FALSE; // move to bottom for (link = list; link; link = link->next) { relation = link->data; gtk_list_store_move_after (relation->user.storage, relation->user.position, relation_bottom->user.position); } g_list_free (list); // scroll to bottom index = gtk_tree_model_iter_n_children (dwidget->model, NULL) -1; path = gtk_tree_path_new_from_indices (index, -1); gtk_tree_view_scroll_to_cell (dwidget->view, path, NULL, FALSE, 0, 0); gtk_tree_path_free (path); return TRUE; } // If no data cleared, return FALSE. gboolean ug_category_gtk_clear_excess (UgCategory* category) { UgCategoryGtk* cgtk; guint n; gboolean retval = FALSE; cgtk = category->user.category; n = gtk_tree_model_iter_n_children (cgtk->finished.model, NULL); if (n > category->finished_limit) retval = TRUE; n = gtk_tree_model_iter_n_children (cgtk->recycled.model, NULL); if (n > category->recycled_limit) retval = TRUE; ug_category_gtk_clear (category, UG_HINT_FINISHED, category->finished_limit); ug_category_gtk_clear (category, UG_HINT_RECYCLED, category->recycled_limit); return retval; } // ---------------------------------------------------------------------------- // free GtkTreeIter in UgetRelation::user.position static void ug_slice_free_tree_iter (GtkTreeIter* iter) { g_slice_free1 (sizeof (GtkTreeIter), iter); } // Function used by GtkTreeModelFilter. static gboolean ug_download_model_filter_category (GtkTreeModel *model, GtkTreeIter *iter, UgCategory* category) { UgDataset* dataset; UgetRelation* relation; gtk_tree_model_get (model, iter, 0, &dataset, -1); if (dataset) { relation = UG_DATASET_RELATION (dataset); if (relation->category == category) return TRUE; } return FALSE; } static gboolean ug_download_model_filter_active (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; gtk_tree_model_get (model, iter, 0, &dataset, -1); if (dataset) { relation = UG_DATASET_RELATION (dataset); if (relation->hints & UG_HINT_ACTIVE) return TRUE; } return FALSE; } static gboolean ug_download_model_filter_queuing (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; gtk_tree_model_get (model, iter, 0, &dataset, -1); if (dataset) { relation = UG_DATASET_RELATION (dataset); if (relation->hints & (UG_HINT_FINISHED | UG_HINT_RECYCLED | UG_HINT_ACTIVE)) return FALSE; } return TRUE; } // Function used by GtkTreeModelFilter. static gboolean ug_download_model_filter_finished (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; gtk_tree_model_get (model, iter, 0, &dataset, -1); if (dataset) { relation = UG_DATASET_RELATION (dataset); if (relation->hints & UG_HINT_FINISHED) return TRUE; } return FALSE; } // Function used by GtkTreeModelFilter. static gboolean ug_download_model_filter_recycled (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDataset* dataset; UgetRelation* relation; gtk_tree_model_get (model, iter, 0, &dataset, -1); if (dataset) { relation = UG_DATASET_RELATION (dataset); if (relation->hints & UG_HINT_RECYCLED) return TRUE; } return FALSE; } uget-1.10.4/uget-gtk/UgProxyForm.c0000664000175000017500000003706612260761064013640 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include static void ug_proxy_form_std_init (UgProxyForm* pform); // signal handler static void on_type_changed (GtkComboBox* widget, UgProxyForm* pform); static void on_entry_std_changed (GtkEditable* editable, UgProxyForm* pform); #ifdef HAVE_LIBPWMD static void ug_proxy_form_pwmd_init (struct UgProxyFormPwmd* pfp, UgProxyForm* pform); static void on_entry_pwmd_changed (GtkEditable* editable, UgProxyForm* pform); #endif void ug_proxy_form_init (UgProxyForm* pform) { GtkWidget* vbox; GtkWidget* hbox; GtkWidget* widget; pform->changed.enable = TRUE; pform->changed.type = FALSE; // proxy type label & combo box widget = gtk_label_new (_("Proxy:")); pform->type = gtk_combo_box_text_new (); gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (pform->type), UGET_PROXY_NONE, _("Don't use")); gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (pform->type), UGET_PROXY_DEFAULT, _("Default")); gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (pform->type), UGET_PROXY_HTTP, "HTTP"); gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (pform->type), UGET_PROXY_SOCKS4, "SOCKS v4"); gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (pform->type), UGET_PROXY_SOCKS5, "SOCKS v5"); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 1); gtk_box_pack_start (GTK_BOX (hbox), pform->type, FALSE, FALSE, 2); gtk_box_pack_start (GTK_BOX (hbox), gtk_separator_new (GTK_ORIENTATION_HORIZONTAL), TRUE, TRUE, 2); g_signal_connect (pform->type, "changed", G_CALLBACK (on_type_changed), pform); vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); ug_proxy_form_std_init (pform); gtk_box_pack_end (GTK_BOX (vbox), pform->std, TRUE, TRUE, 0); #ifdef HAVE_LIBPWMD gtk_combo_box_text_insert_text (GTK_COMBO_BOX_TEXT (pform->type), UGET_PROXY_PWMD, "PWMD"); ug_proxy_form_pwmd_init (&pform->pwmd, pform); gtk_box_pack_end (GTK_BOX (vbox), pform->pwmd.self, TRUE, TRUE, 0); #endif // HAVE_LIBPWMD gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 3); pform->self = (GtkWidget*) vbox; gtk_widget_show_all (pform->self); } static void ug_proxy_form_std_init (UgProxyForm* pform) { GtkGrid* grid; GtkWidget* widget; GtkWidget* hbox; pform->changed.host = FALSE; pform->changed.port = FALSE; pform->changed.user = FALSE; pform->changed.password = FALSE; pform->std = gtk_grid_new (); grid = (GtkGrid*) pform->std; // host label & entry widget = gtk_label_new_with_mnemonic (_("Host:")); pform->host = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (pform->host), 8); gtk_entry_set_activates_default (GTK_ENTRY (pform->host), TRUE); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pform->host); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pform->host, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); gtk_grid_attach (grid, pform->host, 1, 0, 1, 1); // port label & entry widget = gtk_label_new_with_mnemonic (_("Port:")); pform->port = gtk_spin_button_new_with_range (0.0, 65535.0, 1.0); gtk_entry_set_width_chars (GTK_ENTRY (pform->port), 5); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pform->port); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); gtk_box_pack_start (GTK_BOX (hbox), pform->port, FALSE, FALSE, 0); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (hbox, "margin", 1, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); gtk_grid_attach (grid, hbox, 1, 1, 1, 1); // center separator widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL); g_object_set (widget, "margin", 1, NULL); gtk_grid_attach (grid, widget, 2, 0, 1, 2); // user label & entry widget = gtk_label_new_with_mnemonic (_("User:")); pform->user = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (pform->user), 7); gtk_entry_set_activates_default (GTK_ENTRY (pform->user), TRUE); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pform->user); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pform->user, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 0, 1, 1); gtk_grid_attach (grid, pform->user, 4, 0, 1, 1); // password label & entry widget = gtk_label_new_with_mnemonic (_("Password:")); pform->password = gtk_entry_new (); gtk_entry_set_visibility (GTK_ENTRY (pform->password), FALSE); gtk_entry_set_width_chars (GTK_ENTRY (pform->password), 7); gtk_entry_set_activates_default (GTK_ENTRY (pform->password), TRUE); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pform->password); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pform->password, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 1, 1, 1); gtk_grid_attach (grid, pform->password, 4, 1, 1, 1); g_signal_connect (GTK_EDITABLE (pform->user), "changed", G_CALLBACK (on_entry_std_changed), pform); g_signal_connect (GTK_EDITABLE (pform->password), "changed", G_CALLBACK (on_entry_std_changed), pform); g_signal_connect (GTK_EDITABLE (pform->host), "changed", G_CALLBACK (on_entry_std_changed), pform); g_signal_connect (GTK_EDITABLE (pform->port), "changed", G_CALLBACK (on_entry_std_changed), pform); gtk_widget_show_all (pform->std); } void ug_proxy_form_get (UgProxyForm* pform, UgDataset* dataset) { UgetProxy* proxy; gint index; index = gtk_combo_box_get_active ((GtkComboBox*) pform->type); proxy = ug_dataset_realloc (dataset, UgetProxyInfo, 0); proxy->type = index; ug_str_set (&proxy->user, gtk_entry_get_text ((GtkEntry*)pform->user), -1); ug_str_set (&proxy->password, gtk_entry_get_text ((GtkEntry*)pform->password), -1); ug_str_set (&proxy->host, gtk_entry_get_text ((GtkEntry*)pform->host), -1); proxy->port = gtk_spin_button_get_value_as_int ((GtkSpinButton*) pform->port); #ifdef HAVE_LIBPWMD ug_str_set (&proxy->pwmd.socket, gtk_entry_get_text ((GtkEntry*)pform->pwmd.socket), -1); ug_str_set (&proxy->pwmd.socket_args, gtk_entry_get_text ((GtkEntry*)pform->pwmd.socket_args), -1); ug_str_set (&proxy->pwmd.file, gtk_entry_get_text ((GtkEntry*)pform->pwmd.file), -1); ug_str_set (&proxy->pwmd.element, gtk_entry_get_text ((GtkEntry*)pform->pwmd.element), -1); #endif // HAVE_LIBPWMD } void ug_proxy_form_set (UgProxyForm* pform, UgDataset* dataset, gboolean keep_changed) { UgetProxy* proxy; proxy = ug_dataset_get (dataset, UgetProxyInfo, 0); // if no proxy data if (proxy == NULL) { pform->changed.enable = FALSE; // disable changed flags if (keep_changed == FALSE || pform->changed.type == FALSE) gtk_spin_button_set_value ((GtkSpinButton*) pform->port, 80); if (keep_changed == FALSE || pform->changed.port == FALSE) gtk_combo_box_set_active ((GtkComboBox*) pform->type, UGET_PROXY_NONE); pform->changed.enable = TRUE; // enable changed flags return; } // disable changed flags pform->changed.enable = FALSE; // set changed flags if (keep_changed == FALSE) { pform->changed.type = proxy->keeping.type; pform->changed.host = proxy->keeping.host; pform->changed.port = proxy->keeping.port; pform->changed.user = proxy->keeping.user; pform->changed.password = proxy->keeping.password; } // Type if (keep_changed == FALSE || pform->changed.type == FALSE) gtk_combo_box_set_active ((GtkComboBox*) pform->type, proxy->type); // User if (keep_changed == FALSE || pform->changed.user == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->user, (proxy->user) ? proxy->user : ""); } // Password if (keep_changed == FALSE || pform->changed.password == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->password, (proxy->password) ? proxy->password : ""); } // Host if (keep_changed == FALSE || pform->changed.host == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->host, (proxy->host) ? proxy->host : ""); } // Port if (keep_changed == FALSE || pform->changed.port == FALSE) gtk_spin_button_set_value ((GtkSpinButton*) pform->port, proxy->port); #ifdef HAVE_LIBPWMD if (keep_changed == FALSE) { pform->pwmd.changed.socket = proxy->pwmd.keeping.socket; pform->pwmd.changed.socket_args = proxy->pwmd.keeping.socket_args; pform->pwmd.changed.file = proxy->pwmd.keeping.file; pform->pwmd.changed.element = proxy->pwmd.keeping.element; } if (keep_changed == FALSE || pform->pwmd.changed.socket == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->pwmd.socket, (proxy->pwmd.socket) ? proxy->pwmd.socket: ""); } if (keep_changed == FALSE || pform->pwmd.changed.socket_args == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->pwmd.socket_args, (proxy->pwmd.socket_args) ? proxy->pwmd.socket_args: ""); } if (keep_changed == FALSE || pform->pwmd.changed.file == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->pwmd.file, (proxy->pwmd.file) ? proxy->pwmd.file: ""); } if (keep_changed == FALSE || pform->pwmd.changed.element == FALSE) { gtk_entry_set_text ((GtkEntry*) pform->pwmd.element, (proxy->pwmd.element) ? proxy->pwmd.element: ""); } #endif // HAVE_LIBPWMD // enable changed flags pform->changed.enable = TRUE; } //------------------------------------------------------------------- // signal static void on_type_changed (GtkComboBox* widget, UgProxyForm* pform) { gint index; gboolean sensitive; if (pform->changed.enable) pform->changed.type = TRUE; index = gtk_combo_box_get_active (widget); if (index == UGET_PROXY_NONE) sensitive = FALSE; else sensitive = TRUE; gtk_widget_set_sensitive (pform->std, sensitive); #ifdef HAVE_LIBPWMD gtk_widget_set_sensitive (pform->pwmd.self, sensitive); if (index == UGET_PROXY_PWMD) { gtk_widget_set_visible (pform->std, FALSE); gtk_widget_set_visible (pform->pwmd.self, TRUE); } else { gtk_widget_set_visible (pform->pwmd.self, FALSE); gtk_widget_set_visible (pform->std, TRUE); } #endif // HAVE_LIBPWMD } static void on_entry_std_changed (GtkEditable* editable, UgProxyForm* pform) { if (pform->changed.enable) { if (editable == GTK_EDITABLE (pform->host)) pform->changed.host = TRUE; else if (editable == GTK_EDITABLE (pform->port)) pform->changed.port = TRUE; else if (editable == GTK_EDITABLE (pform->user)) pform->changed.user = TRUE; else if (editable == GTK_EDITABLE (pform->password)) pform->changed.password = TRUE; } } // ---------------------------------------------------------------------------- // PWMD // #ifdef HAVE_LIBPWMD static void ug_proxy_form_pwmd_init (struct UgProxyFormPwmd* pfp, UgProxyForm* pform) { GtkGrid* grid; GtkWidget* widget; pfp->self = gtk_grid_new (); grid = (GtkGrid*) pfp->self; widget = gtk_label_new_with_mnemonic (_("Socket:")); pfp->socket = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (pfp->socket), 16); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pfp->socket); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pfp->socket, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 0, 0, 1, 1); gtk_grid_attach (grid, pfp->socket, 1, 0, 4, 1); widget = gtk_label_new_with_mnemonic (_("Socket args:")); pfp->socket_args = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (pfp->socket_args), 16); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pfp->socket_args); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pfp->socket_args, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 0, 1, 1, 1); gtk_grid_attach (grid, pfp->socket_args, 1, 1, 4, 1); widget = gtk_label_new_with_mnemonic (_("Element:")); pfp->element = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (pfp->element), 16); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pfp->element); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pfp->element, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 3, 2, 1, 1); gtk_grid_attach (grid, pfp->element, 4, 2, 1, 1); widget = gtk_separator_new (GTK_ORIENTATION_VERTICAL); g_object_set (widget, "margin", 1, NULL); gtk_grid_attach (grid, widget, 2, 2, 1, 2); widget = gtk_label_new_with_mnemonic (_("File:")); pfp->file = gtk_entry_new (); gtk_entry_set_width_chars (GTK_ENTRY (pfp->file), 16); gtk_label_set_mnemonic_widget (GTK_LABEL (widget), pfp->file); g_object_set (widget, "margin-left", 3, "margin-right", 3, NULL); g_object_set (widget, "margin-top", 1, "margin-bottom", 1, NULL); g_object_set (pfp->file, "margin", 1, "hexpand", TRUE, NULL); gtk_grid_attach (grid, widget, 0, 2, 1, 1); gtk_grid_attach (grid, pfp->file, 1, 2, 1, 1); g_signal_connect (GTK_EDITABLE (pform->pwmd.socket), "changed", G_CALLBACK (on_entry_pwmd_changed), pform); g_signal_connect (GTK_EDITABLE (pform->pwmd.socket_args), "changed", G_CALLBACK (on_entry_pwmd_changed), pform); g_signal_connect (GTK_EDITABLE (pform->pwmd.file), "changed", G_CALLBACK (on_entry_pwmd_changed), pform); g_signal_connect (GTK_EDITABLE (pform->pwmd.element), "changed", G_CALLBACK (on_entry_pwmd_changed), pform); gtk_widget_show_all ((GtkWidget*) grid); gtk_widget_hide ((GtkWidget*) grid); } static void on_entry_pwmd_changed (GtkEditable* editable, UgProxyForm* pform) { if (pform->changed.enable) { if (editable == GTK_EDITABLE (pform->pwmd.socket)) pform->pwmd.changed.socket = TRUE; else if (editable == GTK_EDITABLE (pform->pwmd.socket_args)) pform->pwmd.changed.socket_args = TRUE; else if (editable == GTK_EDITABLE (pform->pwmd.file)) pform->pwmd.changed.file = TRUE; else if (editable == GTK_EDITABLE (pform->pwmd.element)) pform->pwmd.changed.element = TRUE; } } #endif // HAVE_LIBPWMD uget-1.10.4/uget-gtk/UgCategoryWidget.h0000664000175000017500000000723412260761064014613 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_CATEGORY_WIDGET_H #define UG_CATEGORY_WIDGET_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgCategoryWidget UgCategoryWidget; // ---------------------------------------------------------------------------- // UgCategoryWidget // struct UgCategoryWidget { GtkWidget* self; // GtkVBox // secondary categories GtkWidget* scroll; // (GtkScrolledWindow) for UgCategoryWidget.view GtkTreeView* view; // secondary view use UgCategoryWidget.store GtkTreeStore* store; // used by UgCategoryWidget.view (secondary view) GtkTreeModel* filter; // used by UgDownloadDialog // primary UgCategory, UgCategoryGtk, and GtkTreeView. struct { UgCategory* category; UgCategoryGtk* cgtk; GtkTreeView* view; // category view } primary; // maybe primary or secondary // current (selected) UgCategory, UgCategoryGtk, GtkTreeView, and UgDownloadWidget. struct { UgCategory* category; UgCategoryGtk* cgtk; GtkTreeView* view; // category view UgDownloadWidget* widget; } current; // download column struct { gint nth; // enum UgDownloadViewColumn GtkSortType order; } sort; }; void ug_category_widget_init (UgCategoryWidget* cwidget); void ug_category_widget_append (UgCategoryWidget* cwidget, UgCategory* category); void ug_category_widget_remove (UgCategoryWidget* cwidget, UgCategory* category); void ug_category_widget_add_list (UgCategoryWidget* cwidget, GList* list); GList* ug_category_widget_get_list (UgCategoryWidget* cwidget); guint ug_category_widget_n_category (UgCategoryWidget* cwidget); // ---------------------------------------------------------------------------- // GtkTreeView for UgCategoryGtk // GtkTreeView* ug_category_view_new (void); UgCategory* ug_category_view_get_nth (GtkTreeView* view, gint n); UgCategory* ug_category_view_get_cursor (GtkTreeView* view); void ug_category_view_set_cursor (GtkTreeView* view, gint nth, gint nth_child); void ug_category_view_set_icon_visible (GtkTreeView* view, gboolean visible); #ifdef __cplusplus } #endif #endif // End of UG_CATEGORY_WIDGET_H uget-1.10.4/uget-gtk/UgCategoryWidget.c0000664000175000017500000004501012260761064014600 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #define UG_CATEGORY_GTK_ALL_NAME _("All") #define UG_CATEGORY_GTK_ACTIVE_NAME _("Active") #define UG_CATEGORY_GTK_QUEUING_NAME _("Queuing") #define UG_CATEGORY_GTK_FINISHED_NAME _("Finished") #define UG_CATEGORY_GTK_RECYCLED_NAME _("Recycled") // This is used by GtkTreeStore enum UgCategoryStoreColumn { UG_CATEGORY_STORE_INSTANCE, // UgCategory UG_CATEGORY_STORE_DOWNLOAD, // UgDownloadWidget UG_CATEGORY_N_COLUMN }; // signal handler static void ug_category_cursor_changed (GtkTreeView* view, UgCategoryWidget* cwidget); // Function used by GtkTreeModelFilter. static gboolean ug_category_model_filter (GtkTreeModel *model, GtkTreeIter *iter, gpointer data); // ---------------------------------------------------------------------------- // UgCategoryWidget // void ug_category_widget_init (UgCategoryWidget* cwidget) { GtkScrolledWindow* scroll; GtkListStore* primary_store; GtkTreeIter iter; GtkBox* vbox; // primary category cwidget->primary.category = ug_category_new_with_gtk (NULL); cwidget->primary.category->name = g_strdup (UG_CATEGORY_GTK_ALL_NAME); cwidget->primary.cgtk = cwidget->primary.category->user.category; // primary view & store cwidget->primary.view = ug_category_view_new (); primary_store = gtk_list_store_new (UG_CATEGORY_N_COLUMN, G_TYPE_POINTER, G_TYPE_POINTER); gtk_tree_view_set_model (cwidget->primary.view, GTK_TREE_MODEL (primary_store)); g_object_unref (primary_store); gtk_list_store_append (primary_store, &iter); gtk_list_store_set (primary_store, &iter, UG_CATEGORY_STORE_INSTANCE, cwidget->primary.category, UG_CATEGORY_STORE_DOWNLOAD, &cwidget->primary.cgtk->all, -1); gtk_list_store_append (primary_store, &iter); gtk_list_store_set (primary_store, &iter, UG_CATEGORY_STORE_INSTANCE, cwidget->primary.category, UG_CATEGORY_STORE_DOWNLOAD, &cwidget->primary.cgtk->active, -1); gtk_list_store_append (primary_store, &iter); gtk_list_store_set (primary_store, &iter, UG_CATEGORY_STORE_INSTANCE, cwidget->primary.category, UG_CATEGORY_STORE_DOWNLOAD, &cwidget->primary.cgtk->queuing, -1); gtk_list_store_append (primary_store, &iter); gtk_list_store_set (primary_store, &iter, UG_CATEGORY_STORE_INSTANCE, cwidget->primary.category, UG_CATEGORY_STORE_DOWNLOAD, &cwidget->primary.cgtk->finished, -1); gtk_list_store_append (primary_store, &iter); gtk_list_store_set (primary_store, &iter, UG_CATEGORY_STORE_INSTANCE, cwidget->primary.category, UG_CATEGORY_STORE_DOWNLOAD, &cwidget->primary.cgtk->recycled, -1); // secondary categories: model and view cwidget->store = gtk_tree_store_new (UG_CATEGORY_N_COLUMN, G_TYPE_POINTER, G_TYPE_POINTER); cwidget->view = ug_category_view_new (); gtk_tree_view_set_model (cwidget->view, GTK_TREE_MODEL (cwidget->store)); // secondary categories: scrolled for view cwidget->scroll = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_size_request (cwidget->scroll, 165, 100); scroll = GTK_SCROLLED_WINDOW (cwidget->scroll); gtk_scrolled_window_set_shadow_type (scroll, GTK_SHADOW_IN); gtk_scrolled_window_set_policy (scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (cwidget->view)); // filter for UgDownloadDialog cwidget->filter = gtk_tree_model_filter_new ( GTK_TREE_MODEL (cwidget->store), NULL); gtk_tree_model_filter_set_visible_func ( GTK_TREE_MODEL_FILTER (cwidget->filter), ug_category_model_filter, NULL, NULL); // container widget cwidget->self = gtk_box_new (GTK_ORIENTATION_VERTICAL, 2); vbox = GTK_BOX (cwidget->self); gtk_box_pack_start (vbox, GTK_WIDGET (cwidget->primary.view), FALSE, FALSE, 0); gtk_box_pack_start (vbox, gtk_label_new (_("Category")), FALSE, FALSE, 0); gtk_box_pack_start (vbox, GTK_WIDGET (cwidget->scroll), TRUE, TRUE, 0); gtk_widget_show_all (cwidget->self); // signal g_signal_connect (cwidget->primary.view, "cursor-changed", G_CALLBACK (ug_category_cursor_changed), cwidget); g_signal_connect (cwidget->view, "cursor-changed", G_CALLBACK (ug_category_cursor_changed), cwidget); } void ug_category_widget_append (UgCategoryWidget* cwidget, UgCategory* category) { UgCategoryGtk* cgtk; GtkTreeIter iter; if (cwidget->primary.category == category) return; cgtk = category->user.category; // append data to GtkTreeStore gtk_tree_store_append (cwidget->store, &cgtk->tree_iter, NULL); gtk_tree_store_set (cwidget->store, &cgtk->tree_iter, UG_CATEGORY_STORE_INSTANCE, category, UG_CATEGORY_STORE_DOWNLOAD, &cgtk->all, -1); gtk_tree_store_append (cwidget->store, &iter, &cgtk->tree_iter); gtk_tree_store_set (cwidget->store, &iter, UG_CATEGORY_STORE_INSTANCE, category, UG_CATEGORY_STORE_DOWNLOAD, &cgtk->active, -1); gtk_tree_store_append (cwidget->store, &iter, &cgtk->tree_iter); gtk_tree_store_set (cwidget->store, &iter, UG_CATEGORY_STORE_INSTANCE, category, UG_CATEGORY_STORE_DOWNLOAD, &cgtk->queuing, -1); gtk_tree_store_append (cwidget->store, &iter, &cgtk->tree_iter); gtk_tree_store_set (cwidget->store, &iter, UG_CATEGORY_STORE_INSTANCE, category, UG_CATEGORY_STORE_DOWNLOAD, &cgtk->finished, -1); gtk_tree_store_append (cwidget->store, &iter, &cgtk->tree_iter); gtk_tree_store_set (cwidget->store, &iter, UG_CATEGORY_STORE_INSTANCE, category, UG_CATEGORY_STORE_DOWNLOAD, &cgtk->recycled, -1); } void ug_category_widget_remove (UgCategoryWidget* cwidget, UgCategory* category) { GtkTreeSelection* selection; GtkTreeModel* model; GtkTreePath* path; gint n_rows; if (cwidget->primary.category == category) return; model = gtk_tree_view_get_model (cwidget->view); n_rows = gtk_tree_model_iter_n_children (model, NULL); if (n_rows == 1) { selection = gtk_tree_view_get_selection (cwidget->view); gtk_tree_selection_unselect_all (selection); // switch to primary_view gtk_tree_view_get_cursor (cwidget->primary.view, &path, NULL); gtk_tree_view_set_cursor (cwidget->primary.view, path, NULL, FALSE); gtk_tree_path_free (path); } else if (cwidget->current.category == category) { gtk_tree_view_get_cursor (cwidget->view, &path, NULL); if (gtk_tree_path_get_depth (path) == 2) gtk_tree_path_up (path); if (*gtk_tree_path_get_indices (path) == n_rows-1) gtk_tree_path_prev (path); else gtk_tree_path_next (path); gtk_tree_view_set_cursor (cwidget->view, path, NULL, FALSE); gtk_tree_path_free (path); } gtk_tree_store_remove (cwidget->store, &((UgCategoryGtk*)category->user.category)->tree_iter); ug_category_free (category); } void ug_category_widget_add_list (UgCategoryWidget* cwidget, GList* list) { for (; list; list = list->next) ug_category_widget_append (cwidget, list->data); } GList* ug_category_widget_get_list (UgCategoryWidget* cwidget) { GtkTreeIter iter; GtkTreeModel* model; UgCategoryGtk* category; gboolean valid; GList* list; list = NULL; model = GTK_TREE_MODEL (cwidget->store); valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, UG_CATEGORY_STORE_INSTANCE, &category, -1); list = g_list_prepend (list, category); valid = gtk_tree_model_iter_next (model, &iter); } return g_list_reverse (list); } guint ug_category_widget_n_category (UgCategoryWidget* cwidget) { return gtk_tree_model_iter_n_children (GTK_TREE_MODEL (cwidget->store), NULL); } void ug_category_widget_set_cursor (UgCategoryWidget* cwidget, gint nth_category, gint nth_dwidget) { GtkTreePath* path; if (nth_category == -1) { path = gtk_tree_path_new_from_indices (nth_dwidget, -1); gtk_tree_view_set_cursor (cwidget->primary.view, path, NULL, FALSE); } else { path = gtk_tree_path_new_from_indices (nth_category, nth_dwidget-1 , -1); gtk_tree_view_set_cursor (cwidget->view, path, NULL, FALSE); } gtk_tree_path_free (path); } // signal handler static void ug_category_cursor_changed (GtkTreeView* view, UgCategoryWidget* cwidget) { GtkTreeSelection* selection; GtkTreeModel* model; GtkTreePath* path; GtkTreeIter iter; // get setting of download column if (cwidget->current.widget == &cwidget->current.cgtk->all) { cwidget->sort.nth = cwidget->current.widget->sort.nth; cwidget->sort.order = cwidget->current.widget->sort.order; } if (cwidget->current.view != view) { cwidget->current.view = view; if (cwidget->primary.view == view) selection = gtk_tree_view_get_selection (cwidget->view); else selection = gtk_tree_view_get_selection (cwidget->primary.view); gtk_tree_selection_unselect_all (selection); } gtk_tree_view_get_cursor (view, &path, NULL); if (path) { model = gtk_tree_view_get_model (view); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, UG_CATEGORY_STORE_INSTANCE, &cwidget->current.category, UG_CATEGORY_STORE_DOWNLOAD, &cwidget->current.widget, -1); } else { cwidget->current.category = cwidget->primary.category; cwidget->current.widget = &cwidget->primary.cgtk->all; } // set UgCategoryGtk from UgCategory cwidget->current.cgtk = cwidget->current.category->user.category; // set setting of download column if (cwidget->current.widget == &cwidget->current.cgtk->all) { ug_download_view_set_sort_order (cwidget->current.widget->view, cwidget->sort.nth, cwidget->sort.order); cwidget->current.widget->sort.nth = cwidget->sort.nth; cwidget->current.widget->sort.order = cwidget->sort.order; } } // Function used by GtkTreeModelFilter. static gboolean ug_category_model_filter (GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgCategory* category; UgDownloadWidget* dwidget; gtk_tree_model_get (model, iter, UG_CATEGORY_STORE_INSTANCE, &category, UG_CATEGORY_STORE_DOWNLOAD, &dwidget, -1); if (category && &((UgCategoryGtk*)category->user.category)->all == dwidget) return TRUE; return FALSE; } // ---------------------------------------------------------------------------- // GtkTreeView for UgCategoryGtk // #define UG_CATEGORY_ICON_ALL GTK_STOCK_DND_MULTIPLE #define UG_CATEGORY_ICON_PAUSED GTK_STOCK_MEDIA_PAUSE #define UG_CATEGORY_ICON_EXECUTE GTK_STOCK_EXECUTE #define UG_CATEGORY_ICON_FINISHED GTK_STOCK_GOTO_LAST #define UG_CATEGORY_ICON_RECYCLED GTK_STOCK_DELETE static void category_col_set_icon (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgCategory* category; UgCategoryGtk* cgtk; UgDownloadWidget* dwidget; const gchar* stock_id; gtk_tree_model_get (model, iter, UG_CATEGORY_STORE_INSTANCE, &category, UG_CATEGORY_STORE_DOWNLOAD, &dwidget, -1); // avoid crash in GTK3 if (category == NULL || dwidget == NULL) return; cgtk = category->user.category; if (dwidget == &cgtk->all) stock_id = UG_CATEGORY_ICON_ALL; else if (dwidget == &cgtk->finished) stock_id = UG_CATEGORY_ICON_FINISHED; else if (dwidget == &cgtk->recycled) stock_id = UG_CATEGORY_ICON_RECYCLED; else if (dwidget == &cgtk->queuing) stock_id = UG_CATEGORY_ICON_PAUSED; else stock_id = UG_CATEGORY_ICON_EXECUTE; g_object_set (cell, "stock-id", stock_id, NULL); } static void category_col_set_name (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgCategory* category; UgCategoryGtk* cgtk; UgDownloadWidget* dwidget; gchar* string; gtk_tree_model_get (model, iter, UG_CATEGORY_STORE_INSTANCE, &category, UG_CATEGORY_STORE_DOWNLOAD, &dwidget, -1); // avoid crash in GTK3 if (category == NULL || dwidget == NULL) return; cgtk = category->user.category; if (dwidget == &cgtk->active) string = UG_CATEGORY_GTK_ACTIVE_NAME; else if (dwidget == &cgtk->queuing) string = UG_CATEGORY_GTK_QUEUING_NAME; else if (dwidget == &cgtk->finished) string = UG_CATEGORY_GTK_FINISHED_NAME; else if (dwidget == &cgtk->recycled) string = UG_CATEGORY_GTK_RECYCLED_NAME; else string = category->name; g_object_set (cell, "text", string, NULL); } static void category_col_set_quantity (GtkTreeViewColumn *tree_column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, gpointer data) { UgDownloadWidget* dwidget; gchar* string; gint quantity; gtk_tree_model_get (model, iter, UG_CATEGORY_STORE_DOWNLOAD, &dwidget, -1); // avoid crash in GTK3 if (dwidget == NULL) return; quantity = gtk_tree_model_iter_n_children (dwidget->model, NULL); string = g_strdup_printf ("%u", quantity); g_object_set (cell, "text", string, NULL); g_free (string); } GtkTreeView* ug_category_view_new (void) { GtkTreeView* view; GtkCellRenderer* renderer; GtkTreeViewColumn* column; view = (GtkTreeView*) gtk_tree_view_new (); gtk_tree_view_set_headers_visible (view, FALSE); // column name column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Category")); renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_cell_data_func (column, renderer, category_col_set_icon, NULL, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, category_col_set_name, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); // gtk_tree_view_column_set_min_width (column, 120); gtk_tree_view_column_set_expand (column, TRUE); // gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (view, column); // column Quantity = number of tasks column = gtk_tree_view_column_new (); gtk_tree_view_column_set_title (column, _("Quantity")); renderer = gtk_cell_renderer_text_new (); g_object_set (renderer, "xalign", 1.0, NULL); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, category_col_set_quantity, NULL, NULL); gtk_tree_view_column_set_resizable (column, TRUE); gtk_tree_view_column_set_expand (column, TRUE); gtk_tree_view_column_set_alignment (column, 1.0); // gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (view, column); gtk_widget_show (GTK_WIDGET (view)); return view; } UgCategory* ug_category_view_get_nth (GtkTreeView* view, gint n) { GtkTreeModel* model; GtkTreeIter iter; UgCategory* category; model = gtk_tree_view_get_model (view); if (gtk_tree_model_iter_nth_child (model, &iter, NULL, n) == FALSE) return NULL; gtk_tree_model_get (model, &iter, UG_CATEGORY_STORE_INSTANCE, &category, -1); return category; } UgCategory* ug_category_view_get_cursor (GtkTreeView* view) { GtkTreeModel* model; GtkTreePath* path; GtkTreeIter iter; UgCategory* category; model = gtk_tree_view_get_model (view); gtk_tree_view_get_cursor (view, &path, NULL); if (path) { gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); } else if (gtk_tree_model_get_iter_first (model, &iter) == FALSE) return NULL; gtk_tree_model_get (model, &iter, UG_CATEGORY_STORE_INSTANCE, &category, -1); return category; } void ug_category_view_set_cursor (GtkTreeView* view, gint nth, gint nth_child) { GtkTreePath* path; if (nth != -1) { path = gtk_tree_path_new_from_indices (nth, nth_child , -1); gtk_tree_view_set_cursor (view, path, NULL, FALSE); gtk_tree_path_free (path); } } void ug_category_view_set_icon_visible (GtkTreeView* view, gboolean visible) { GtkCellRenderer* renderer; GtkTreeViewColumn* column; // clear column = gtk_tree_view_get_column (view, 0); gtk_tree_view_column_clear (column); // pack icon renderer if (visible) { renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, renderer, FALSE); gtk_tree_view_column_set_cell_data_func (column, renderer, category_col_set_icon, NULL, NULL); } // pack text renderer renderer = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_cell_data_func (column, renderer, category_col_set_name, NULL, NULL); } uget-1.10.4/uget-gtk/UgSummary.h0000664000175000017500000000477012260761064013331 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_SUMMARY_H #define UG_SUMMARY_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgSummary UgSummary; struct UgSummary { GtkWidget* self; // (GtkScrolledWindow) container for view GtkTreeView* view; GtkListStore* store; struct UgSummaryMenu { GtkMenu* self; // (GtkMenu) pop-up menu GtkWidget* copy; // GtkMenuItem GtkWidget* copy_all; // GtkMenuItem } menu; struct UgSummaryVisible { gboolean name:1; gboolean folder:1; gboolean category:1; gboolean url:1; gboolean message:1; } visible; }; void ug_summary_init (UgSummary* summary, GtkAccelGroup* accel_group); void ug_summary_show (UgSummary* summary, UgDataset* dataset); // call g_free() to free returned string. gchar* ug_summary_get_text_selected (UgSummary* summary); gchar* ug_summary_get_text_all (UgSummary* summary); #ifdef __cplusplus } #endif #endif // End of UG_SUMMARY_H uget-1.10.4/uget-gtk/UgProxyForm.h0000664000175000017500000000572612260761064013643 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_PROXY_FORM_H #define UG_PROXY_FORM_H #include #include #ifdef HAVE_CONFIG_H #include #endif #ifdef __cplusplus extern "C" { #endif typedef struct UgProxyForm UgProxyForm; struct UgProxyForm { GtkWidget* self; // top level widget GtkWidget* type; // GtkComboBox // classic // struct UgProxyFormStd { GtkWidget* std; // proxy server GtkWidget* host; // GtkEntry GtkWidget* port; // GtkEntry // authentication GtkWidget* user; // GtkEntry GtkWidget* password; // GtkEntry // } std; // User changed entry struct UgProxyFormChanged { gboolean enable:1; // UgProxyFormStd gboolean type:1; gboolean host:1; gboolean port:1; gboolean user:1; gboolean password:1; } changed; //#ifdef HAVE_LIBPWMD struct UgProxyFormPwmd { GtkWidget* self; GtkWidget* socket; GtkWidget* socket_args; GtkWidget* file; GtkWidget* element; // User changed entry struct UgProxyFormPwmdChanged { gboolean socket:1; gboolean socket_args:1; gboolean file:1; gboolean element:1; } changed; } pwmd; //#endif // HAVE_LIBPWMD }; void ug_proxy_form_init (UgProxyForm* pform); void ug_proxy_form_get (UgProxyForm* pform, UgDataset* dataset); void ug_proxy_form_set (UgProxyForm* pform, UgDataset* dataset, gboolean keep_changed); #ifdef __cplusplus } #endif #endif // End of UG_PROXY_FORM_H uget-1.10.4/uget-gtk/UgBanner.c0000664000175000017500000002016512260761064013070 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include static GdkCursor* hand_cursor = NULL; static GdkCursor* regular_cursor = NULL; static gboolean motion_notify_event (GtkWidget* tv_widget, GdkEventMotion* event, UgBanner* banner); static gboolean event_after (GtkWidget* text_view, GdkEvent* ev, UgBanner* banner); static GtkWidget* create_x_button (UgBanner* banner); void ug_banner_init (struct UgBanner* banner) { GtkStyleContext* style_context; GdkRGBA rgba; hand_cursor = gdk_cursor_new (GDK_HAND2); regular_cursor = gdk_cursor_new (GDK_XTERM); banner->self = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); banner->buffer = gtk_text_buffer_new (NULL); banner->tag_link = gtk_text_buffer_create_tag (banner->buffer, NULL, "underline", PANGO_UNDERLINE_SINGLE, NULL); banner->text_view = (GtkTextView*) gtk_text_view_new_with_buffer (banner->buffer); gtk_text_view_set_cursor_visible (banner->text_view, FALSE); gtk_text_view_set_editable (banner->text_view, FALSE); gtk_box_pack_start (GTK_BOX (banner->self), GTK_WIDGET (banner->text_view), TRUE, TRUE, 0); g_signal_connect (banner->text_view, "event-after", G_CALLBACK (event_after), banner); g_signal_connect (banner->text_view, "motion-notify-event", G_CALLBACK (motion_notify_event), banner); // style: color style_context = gtk_widget_get_style_context (GTK_WIDGET (banner->text_view)); gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_SELECTED, &rgba); gtk_widget_override_background_color ( GTK_WIDGET (banner->text_view), GTK_STATE_FLAG_NORMAL, &rgba); gtk_style_context_get_color (style_context, GTK_STATE_FLAG_SELECTED, &rgba); gtk_widget_override_color ( GTK_WIDGET (banner->text_view), GTK_STATE_FLAG_NORMAL, &rgba); // close button gtk_box_pack_end (GTK_BOX (banner->self), create_x_button (banner), FALSE, FALSE, 0); ug_banner_show_donation (banner); } void ug_banner_show_donation (struct UgBanner* banner) { GtkTextIter iter; banner->status = UG_BANNER_DONATION; gtk_text_buffer_set_text(banner->buffer, "", 0); gtk_text_buffer_get_iter_at_offset (banner->buffer, &iter, 0); gtk_text_buffer_insert (banner->buffer, &iter, " ", 2); gtk_text_buffer_insert (banner->buffer, &iter, _("Attention uGetters:"), -1); gtk_text_buffer_insert (banner->buffer, &iter, " ", 1); gtk_text_buffer_insert (banner->buffer, &iter, _("we are running a Donation Drive " "for uGet's Future Development, please click "), -1); gtk_text_buffer_insert_with_tags (banner->buffer, &iter, _("HERE"), -1, banner->tag_link, NULL); } void ug_banner_show_survey (struct UgBanner* banner) { GtkTextIter iter; banner->status = UG_BANNER_SURVEY; gtk_text_buffer_set_text(banner->buffer, "", 0); gtk_text_buffer_get_iter_at_offset (banner->buffer, &iter, 0); gtk_text_buffer_insert (banner->buffer, &iter, " ", 2); gtk_text_buffer_insert (banner->buffer, &iter, _("Attention uGetters:"), -1); gtk_text_buffer_insert (banner->buffer, &iter, " ", 1); gtk_text_buffer_insert (banner->buffer, &iter, _("please fill out this quick User Survey for uGet."), -1); gtk_text_buffer_insert (banner->buffer, &iter, " - ", 3); gtk_text_buffer_insert_with_tags (banner->buffer, &iter, _("click here to take survey"), -1, banner->tag_link, NULL); } // ---------------------------------------------------------------------------- // static functions /* Links can also be activated by clicking. */ static gboolean event_after (GtkWidget* text_view, GdkEvent* ev, UgBanner* banner) { GtkTextIter start, end, iter; GtkTextBuffer *buffer; GdkEventButton *event; gint x, y; GSList* slist; if (ev->type != GDK_BUTTON_RELEASE) return FALSE; event = (GdkEventButton *)ev; if (event->button != GDK_BUTTON_PRIMARY) return FALSE; buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (text_view)); /* we shouldn't follow a link if the user has selected something */ gtk_text_buffer_get_selection_bounds (buffer, &start, &end); if (gtk_text_iter_get_offset (&start) != gtk_text_iter_get_offset (&end)) return FALSE; gtk_text_view_window_to_buffer_coords (GTK_TEXT_VIEW (text_view), GTK_TEXT_WINDOW_WIDGET, event->x, event->y, &x, &y); gtk_text_view_get_iter_at_location (GTK_TEXT_VIEW (text_view), &iter, x, y); slist = gtk_text_iter_get_tags (&iter); if (slist) { switch (banner->status) { case UG_BANNER_DONATION: // ug_launch_uri ("https://sourceforge.net/p/urlget/donate/?source=navbar"); ug_launch_uri ("http://ugetdm.com/donate"); break; case UG_BANNER_SURVEY: ug_launch_uri ("http://ugetdm.com/survey"); break; } } if (slist) g_slist_free (slist); return FALSE; } /* Update the cursor image if the pointer moved. */ /* Looks at all tags covering the position (x, y) in the text view, * and if one of them is a link, change the cursor to the "hands" cursor * typically used by web browsers. */ static gboolean motion_notify_event (GtkWidget* tv_widget, GdkEventMotion* event, UgBanner* banner) { GtkTextView* text_view; gint x, y; gboolean hovering = FALSE; GSList* slist; GtkTextIter iter; text_view = GTK_TEXT_VIEW (tv_widget); gtk_text_view_window_to_buffer_coords (text_view, GTK_TEXT_WINDOW_WIDGET, event->x, event->y, &x, &y); // set cursor if appropriate gtk_text_view_get_iter_at_location (text_view, &iter, x, y); slist = gtk_text_iter_get_tags (&iter); if (slist) hovering = TRUE; if (banner->hovering_over_link != hovering) { banner->hovering_over_link = hovering; if (banner->hovering_over_link) { gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), hand_cursor); } else { gdk_window_set_cursor (gtk_text_view_get_window (text_view, GTK_TEXT_WINDOW_TEXT), regular_cursor); } } if (slist) g_slist_free (slist); return FALSE; } // ------------------------------------ static gboolean on_x_button_release (GtkWidget* text_view, GdkEvent* ev, UgBanner* banner) { GdkEventButton *event; event = (GdkEventButton*) ev; if (event->button != GDK_BUTTON_PRIMARY) return FALSE; switch (banner->status) { case UG_BANNER_DONATION: ug_banner_show_survey (banner); break; case UG_BANNER_SURVEY: gtk_widget_hide (banner->self); break; } return FALSE; } static GtkWidget* create_x_button (UgBanner* banner) { GtkWidget* event_box; GtkWidget* label; label = gtk_label_new (" X "); event_box = gtk_event_box_new (); gtk_container_add (GTK_CONTAINER (event_box), label); g_signal_connect (event_box, "button-release-event", G_CALLBACK (on_x_button_release), banner); return event_box; } uget-1.10.4/uget-gtk/UgCategoryDialog.h0000664000175000017500000000460312260761064014564 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_CATEGORY_DIALOG_H #define UG_CATEGORY_DIALOG_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgCategoryDialog UgCategoryDialog; struct UgCategoryDialog { GtkDialog* self; UgCategoryForm category; UgDownloadForm download; UgProxyForm proxy; // Additional data struct { gpointer app; gpointer data; } user; }; UgCategoryDialog* ug_category_dialog_new (const gchar* title, GtkWindow* parent); void ug_category_dialog_free (UgCategoryDialog* cdialog); void ug_category_dialog_get (UgCategoryDialog* cdialog, UgCategory* category); void ug_category_dialog_set (UgCategoryDialog* cdialog, UgCategory* category); #ifdef __cplusplus } #endif #endif // End of UG_CATEGORY_DIALOG_H uget-1.10.4/uget-gtk/Makefile.in0000664000175000017500000017110012260757434013272 00000000000000# Makefile.in generated by automake 1.11.3 from Makefile.am. # @configure_input@ # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, # 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software # Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. @SET_MAKE@ VPATH = @srcdir@ pkgdatadir = $(datadir)/@PACKAGE@ pkgincludedir = $(includedir)/@PACKAGE@ pkglibdir = $(libdir)/@PACKAGE@ pkglibexecdir = $(libexecdir)/@PACKAGE@ am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd install_sh_DATA = $(install_sh) -c -m 644 install_sh_PROGRAM = $(install_sh) -c install_sh_SCRIPT = $(install_sh) -c INSTALL_HEADER = $(INSTALL_DATA) transform = $(program_transform_name) NORMAL_INSTALL = : PRE_INSTALL = : POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : bin_PROGRAMS = uget-gtk$(EXEEXT) subdir = uget-gtk DIST_COMMON = $(noinst_HEADERS) $(srcdir)/Makefile.am \ $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = am__installdirs = "$(DESTDIR)$(bindir)" PROGRAMS = $(bin_PROGRAMS) am_uget_gtk_OBJECTS = uget_gtk-UgSetting.$(OBJEXT) \ uget_gtk-UgSelector.$(OBJEXT) uget_gtk-UgSummary.$(OBJEXT) \ uget_gtk-UgSettingForm.$(OBJEXT) \ uget_gtk-UgScheduleForm.$(OBJEXT) uget_gtk-UgBanner.$(OBJEXT) \ uget_gtk-UgDownloadForm.$(OBJEXT) \ uget_gtk-UgCategoryForm.$(OBJEXT) \ uget_gtk-UgProxyForm.$(OBJEXT) uget_gtk-UgBatchForm.$(OBJEXT) \ uget_gtk-UgDownloadWidget.$(OBJEXT) \ uget_gtk-UgCategoryWidget.$(OBJEXT) \ uget_gtk-UgCategory-gtk.$(OBJEXT) \ uget_gtk-UgDownloadDialog.$(OBJEXT) \ uget_gtk-UgCategoryDialog.$(OBJEXT) \ uget_gtk-UgSettingDialog.$(OBJEXT) \ uget_gtk-UgApp-gtk.$(OBJEXT) uget_gtk-UgApp-gtk-gui.$(OBJEXT) \ uget_gtk-UgApp-gtk-aria2.$(OBJEXT) \ uget_gtk-UgApp-gtk-callback.$(OBJEXT) \ uget_gtk-UgApp-gtk-timeout.$(OBJEXT) \ uget_gtk-UgApp-gtk-main.$(OBJEXT) uget_gtk_OBJECTS = $(am_uget_gtk_OBJECTS) am__DEPENDENCIES_1 = uget_gtk_DEPENDENCIES = $(top_builddir)/uglib/libuglib.a \ $(am__DEPENDENCIES_1) uget_gtk_LINK = $(CCLD) $(uget_gtk_CFLAGS) $(CFLAGS) \ $(uget_gtk_LDFLAGS) $(LDFLAGS) -o $@ DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) CCLD = $(CC) LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ SOURCES = $(uget_gtk_SOURCES) DIST_SOURCES = $(uget_gtk_SOURCES) HEADERS = $(noinst_HEADERS) ETAGS = etags CTAGS = ctags DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) ACLOCAL = @ACLOCAL@ ALL_LINGUAS = @ALL_LINGUAS@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ APP_INDICATOR_CFLAGS = @APP_INDICATOR_CFLAGS@ APP_INDICATOR_LIBS = @APP_INDICATOR_LIBS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ CATALOGS = @CATALOGS@ CATOBJEXT = @CATOBJEXT@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ CPP = @CPP@ CPPFLAGS = @CPPFLAGS@ CURL_CFLAGS = @CURL_CFLAGS@ CURL_CONFIG = @CURL_CONFIG@ CURL_LIBS = @CURL_LIBS@ CYGPATH_W = @CYGPATH_W@ DATADIRNAME = @DATADIRNAME@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ ECHO_C = @ECHO_C@ ECHO_N = @ECHO_N@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ GETCONF = @GETCONF@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ GIO_CFLAGS = @GIO_CFLAGS@ GIO_LIBS = @GIO_LIBS@ GLIB_CFLAGS = @GLIB_CFLAGS@ GLIB_LIBS = @GLIB_LIBS@ GMODULE_CFLAGS = @GMODULE_CFLAGS@ GMODULE_LIBS = @GMODULE_LIBS@ GMOFILES = @GMOFILES@ GMSGFMT = @GMSGFMT@ GNUTLS_CFLAGS = @GNUTLS_CFLAGS@ GNUTLS_LIBS = @GNUTLS_LIBS@ GREP = @GREP@ GSTREAMER_CFLAGS = @GSTREAMER_CFLAGS@ GSTREAMER_LIBS = @GSTREAMER_LIBS@ GTHREAD_CFLAGS = @GTHREAD_CFLAGS@ GTHREAD_LIBS = @GTHREAD_LIBS@ GTK_CFLAGS = @GTK_CFLAGS@ GTK_LIBS = @GTK_LIBS@ INSTALL = @INSTALL@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ INSTOBJEXT = @INSTOBJEXT@ INTLLIBS = @INTLLIBS@ INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ INTLTOOL_MERGE = @INTLTOOL_MERGE@ INTLTOOL_PERL = @INTLTOOL_PERL@ INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ INTLTOOL_V_MERGE = @INTLTOOL_V_MERGE@ INTLTOOL_V_MERGE_OPTIONS = @INTLTOOL_V_MERGE_OPTIONS@ INTLTOOL__v_MERGE_ = @INTLTOOL__v_MERGE_@ INTLTOOL__v_MERGE_0 = @INTLTOOL__v_MERGE_0@ LDFLAGS = @LDFLAGS@ LFS_CFLAGS = @LFS_CFLAGS@ LFS_LDFLAGS = @LFS_LDFLAGS@ LIBNOTIFY_CFLAGS = @LIBNOTIFY_CFLAGS@ LIBNOTIFY_LIBS = @LIBNOTIFY_LIBS@ LIBOBJS = @LIBOBJS@ LIBPWMD_CFLAGS = @LIBPWMD_CFLAGS@ LIBPWMD_LIBS = @LIBPWMD_LIBS@ LIBS = @LIBS@ LTLIBOBJS = @LTLIBOBJS@ MAKEINFO = @MAKEINFO@ MKDIR_P = @MKDIR_P@ MKINSTALLDIRS = @MKINSTALLDIRS@ MSGFMT = @MSGFMT@ MSGFMT_OPTS = @MSGFMT_OPTS@ MSGMERGE = @MSGMERGE@ OBJEXT = @OBJEXT@ PACKAGE = @PACKAGE@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PKG_CONFIG = @PKG_CONFIG@ PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ POFILES = @POFILES@ POSUB = @POSUB@ PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ RANLIB = @RANLIB@ SET_MAKE = @SET_MAKE@ SHELL = @SHELL@ STRIP = @STRIP@ USE_NLS = @USE_NLS@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ abs_builddir = @abs_builddir@ abs_srcdir = @abs_srcdir@ abs_top_builddir = @abs_top_builddir@ abs_top_srcdir = @abs_top_srcdir@ ac_ct_CC = @ac_ct_CC@ am__include = @am__include@ am__leading_dot = @am__leading_dot@ am__quote = @am__quote@ am__tar = @am__tar@ am__untar = @am__untar@ bindir = @bindir@ build_alias = @build_alias@ builddir = @builddir@ datadir = @datadir@ datarootdir = @datarootdir@ docdir = @docdir@ dvidir = @dvidir@ exec_prefix = @exec_prefix@ host_alias = @host_alias@ htmldir = @htmldir@ includedir = @includedir@ infodir = @infodir@ install_sh = @install_sh@ intltool__v_merge_options_ = @intltool__v_merge_options_@ intltool__v_merge_options_0 = @intltool__v_merge_options_0@ libdir = @libdir@ libexecdir = @libexecdir@ localedir = @localedir@ localstatedir = @localstatedir@ mandir = @mandir@ mkdir_p = @mkdir_p@ oldincludedir = @oldincludedir@ pdfdir = @pdfdir@ prefix = @prefix@ program_transform_name = @program_transform_name@ psdir = @psdir@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ UGET_GTK_LIBS = @GTK_LIBS@ @GIO_LIBS@ @GTHREAD_LIBS@ @CURL_LIBS@ @GNUTLS_LIBS@ @LIBNOTIFY_LIBS@ @APP_INDICATOR_LIBS@ @GSTREAMER_LIBS@ @LIBPWMD_LIBS@ # set the include path found by configure uget_gtk_CPPFLAGS = -DDATADIR='"$(datadir)"' -I$(top_srcdir)/uglib -I$(top_srcdir)/uget-gtk uget_gtk_CFLAGS = @LFS_CFLAGS@ @GTK_CFLAGS@ @GIO_CFLAGS@ @GTHREAD_CFLAGS@ @CURL_CFLAGS@ @GNUTLS_CFLAGS@ @LIBNOTIFY_CFLAGS@ @APP_INDICATOR_CFLAGS@ @GSTREAMER_CFLAGS@ @LIBPWMD_CFLAGS@ uget_gtk_LDFLAGS = @LFS_LDFLAGS@ uget_gtk_LDADD = $(top_builddir)/uglib/libuglib.a $(UGET_GTK_LIBS) uget_gtk_SOURCES = UgSetting.c \ UgSelector.c UgSummary.c UgSettingForm.c UgScheduleForm.c UgBanner.c \ UgDownloadForm.c UgCategoryForm.c UgProxyForm.c UgBatchForm.c \ UgDownloadWidget.c UgCategoryWidget.c UgCategory-gtk.c \ UgDownloadDialog.c UgCategoryDialog.c UgSettingDialog.c \ UgApp-gtk.c UgApp-gtk-gui.c UgApp-gtk-aria2.c \ UgApp-gtk-callback.c UgApp-gtk-timeout.c \ UgApp-gtk-main.c noinst_HEADERS = UgSetting.h \ UgSelector.h UgSummary.h UgSettingForm.h UgScheduleForm.h UgBanner.h \ UgDownloadForm.h UgCategoryForm.h UgProxyForm.h UgBatchForm.h \ UgDownloadWidget.h UgCategoryWidget.h UgCategory-gtk.h \ UgDownloadDialog.h UgCategoryDialog.h UgSettingDialog.h \ UgApp-gtk.h all: all-am .SUFFIXES: .SUFFIXES: .c .o .obj $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) @for dep in $?; do \ case '$(am__configure_deps)' in \ *$$dep*) \ ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ && { if test -f $@; then exit 0; else break; fi; }; \ exit 1;; \ esac; \ done; \ echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu uget-gtk/Makefile'; \ $(am__cd) $(top_srcdir) && \ $(AUTOMAKE) --gnu uget-gtk/Makefile .PRECIOUS: Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status @case '$?' in \ *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(top_srcdir)/configure: $(am__configure_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(ACLOCAL_M4): $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): install-binPROGRAMS: $(bin_PROGRAMS) @$(NORMAL_INSTALL) test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)" @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ for p in $$list; do echo "$$p $$p"; done | \ sed 's/$(EXEEXT)$$//' | \ while read p p1; do if test -f $$p; \ then echo "$$p"; echo "$$p"; else :; fi; \ done | \ sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \ -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ sed 'N;N;N;s,\n, ,g' | \ $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ if ($$2 == $$4) files[d] = files[d] " " $$1; \ else { print "f", $$3 "/" $$4, $$1; } } \ END { for (d in files) print "f", d, files[d] }' | \ while read type dir files; do \ if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ test -z "$$files" || { \ echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ } \ ; done uninstall-binPROGRAMS: @$(NORMAL_UNINSTALL) @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ files=`for p in $$list; do echo "$$p"; done | \ sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ -e 's/$$/$(EXEEXT)/' `; \ test -n "$$list" || exit 0; \ echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ cd "$(DESTDIR)$(bindir)" && rm -f $$files clean-binPROGRAMS: -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) uget-gtk$(EXEEXT): $(uget_gtk_OBJECTS) $(uget_gtk_DEPENDENCIES) $(EXTRA_uget_gtk_DEPENDENCIES) @rm -f uget-gtk$(EXEEXT) $(uget_gtk_LINK) $(uget_gtk_OBJECTS) $(uget_gtk_LDADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgApp-gtk-callback.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgApp-gtk-gui.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgApp-gtk-main.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgApp-gtk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgBanner.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgBatchForm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgCategory-gtk.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgCategoryDialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgCategoryForm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgCategoryWidget.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgDownloadDialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgDownloadForm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgDownloadWidget.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgProxyForm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgScheduleForm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgSelector.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgSetting.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgSettingDialog.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgSettingForm.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/uget_gtk-UgSummary.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c $< .c.obj: @am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` uget_gtk-UgSetting.o: UgSetting.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSetting.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgSetting.Tpo -c -o uget_gtk-UgSetting.o `test -f 'UgSetting.c' || echo '$(srcdir)/'`UgSetting.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSetting.Tpo $(DEPDIR)/uget_gtk-UgSetting.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSetting.c' object='uget_gtk-UgSetting.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSetting.o `test -f 'UgSetting.c' || echo '$(srcdir)/'`UgSetting.c uget_gtk-UgSetting.obj: UgSetting.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSetting.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgSetting.Tpo -c -o uget_gtk-UgSetting.obj `if test -f 'UgSetting.c'; then $(CYGPATH_W) 'UgSetting.c'; else $(CYGPATH_W) '$(srcdir)/UgSetting.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSetting.Tpo $(DEPDIR)/uget_gtk-UgSetting.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSetting.c' object='uget_gtk-UgSetting.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSetting.obj `if test -f 'UgSetting.c'; then $(CYGPATH_W) 'UgSetting.c'; else $(CYGPATH_W) '$(srcdir)/UgSetting.c'; fi` uget_gtk-UgSelector.o: UgSelector.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSelector.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgSelector.Tpo -c -o uget_gtk-UgSelector.o `test -f 'UgSelector.c' || echo '$(srcdir)/'`UgSelector.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSelector.Tpo $(DEPDIR)/uget_gtk-UgSelector.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSelector.c' object='uget_gtk-UgSelector.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSelector.o `test -f 'UgSelector.c' || echo '$(srcdir)/'`UgSelector.c uget_gtk-UgSelector.obj: UgSelector.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSelector.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgSelector.Tpo -c -o uget_gtk-UgSelector.obj `if test -f 'UgSelector.c'; then $(CYGPATH_W) 'UgSelector.c'; else $(CYGPATH_W) '$(srcdir)/UgSelector.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSelector.Tpo $(DEPDIR)/uget_gtk-UgSelector.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSelector.c' object='uget_gtk-UgSelector.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSelector.obj `if test -f 'UgSelector.c'; then $(CYGPATH_W) 'UgSelector.c'; else $(CYGPATH_W) '$(srcdir)/UgSelector.c'; fi` uget_gtk-UgSummary.o: UgSummary.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSummary.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgSummary.Tpo -c -o uget_gtk-UgSummary.o `test -f 'UgSummary.c' || echo '$(srcdir)/'`UgSummary.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSummary.Tpo $(DEPDIR)/uget_gtk-UgSummary.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSummary.c' object='uget_gtk-UgSummary.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSummary.o `test -f 'UgSummary.c' || echo '$(srcdir)/'`UgSummary.c uget_gtk-UgSummary.obj: UgSummary.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSummary.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgSummary.Tpo -c -o uget_gtk-UgSummary.obj `if test -f 'UgSummary.c'; then $(CYGPATH_W) 'UgSummary.c'; else $(CYGPATH_W) '$(srcdir)/UgSummary.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSummary.Tpo $(DEPDIR)/uget_gtk-UgSummary.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSummary.c' object='uget_gtk-UgSummary.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSummary.obj `if test -f 'UgSummary.c'; then $(CYGPATH_W) 'UgSummary.c'; else $(CYGPATH_W) '$(srcdir)/UgSummary.c'; fi` uget_gtk-UgSettingForm.o: UgSettingForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSettingForm.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgSettingForm.Tpo -c -o uget_gtk-UgSettingForm.o `test -f 'UgSettingForm.c' || echo '$(srcdir)/'`UgSettingForm.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSettingForm.Tpo $(DEPDIR)/uget_gtk-UgSettingForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSettingForm.c' object='uget_gtk-UgSettingForm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSettingForm.o `test -f 'UgSettingForm.c' || echo '$(srcdir)/'`UgSettingForm.c uget_gtk-UgSettingForm.obj: UgSettingForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSettingForm.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgSettingForm.Tpo -c -o uget_gtk-UgSettingForm.obj `if test -f 'UgSettingForm.c'; then $(CYGPATH_W) 'UgSettingForm.c'; else $(CYGPATH_W) '$(srcdir)/UgSettingForm.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSettingForm.Tpo $(DEPDIR)/uget_gtk-UgSettingForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSettingForm.c' object='uget_gtk-UgSettingForm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSettingForm.obj `if test -f 'UgSettingForm.c'; then $(CYGPATH_W) 'UgSettingForm.c'; else $(CYGPATH_W) '$(srcdir)/UgSettingForm.c'; fi` uget_gtk-UgScheduleForm.o: UgScheduleForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgScheduleForm.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgScheduleForm.Tpo -c -o uget_gtk-UgScheduleForm.o `test -f 'UgScheduleForm.c' || echo '$(srcdir)/'`UgScheduleForm.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgScheduleForm.Tpo $(DEPDIR)/uget_gtk-UgScheduleForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgScheduleForm.c' object='uget_gtk-UgScheduleForm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgScheduleForm.o `test -f 'UgScheduleForm.c' || echo '$(srcdir)/'`UgScheduleForm.c uget_gtk-UgScheduleForm.obj: UgScheduleForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgScheduleForm.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgScheduleForm.Tpo -c -o uget_gtk-UgScheduleForm.obj `if test -f 'UgScheduleForm.c'; then $(CYGPATH_W) 'UgScheduleForm.c'; else $(CYGPATH_W) '$(srcdir)/UgScheduleForm.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgScheduleForm.Tpo $(DEPDIR)/uget_gtk-UgScheduleForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgScheduleForm.c' object='uget_gtk-UgScheduleForm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgScheduleForm.obj `if test -f 'UgScheduleForm.c'; then $(CYGPATH_W) 'UgScheduleForm.c'; else $(CYGPATH_W) '$(srcdir)/UgScheduleForm.c'; fi` uget_gtk-UgBanner.o: UgBanner.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgBanner.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgBanner.Tpo -c -o uget_gtk-UgBanner.o `test -f 'UgBanner.c' || echo '$(srcdir)/'`UgBanner.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgBanner.Tpo $(DEPDIR)/uget_gtk-UgBanner.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgBanner.c' object='uget_gtk-UgBanner.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgBanner.o `test -f 'UgBanner.c' || echo '$(srcdir)/'`UgBanner.c uget_gtk-UgBanner.obj: UgBanner.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgBanner.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgBanner.Tpo -c -o uget_gtk-UgBanner.obj `if test -f 'UgBanner.c'; then $(CYGPATH_W) 'UgBanner.c'; else $(CYGPATH_W) '$(srcdir)/UgBanner.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgBanner.Tpo $(DEPDIR)/uget_gtk-UgBanner.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgBanner.c' object='uget_gtk-UgBanner.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgBanner.obj `if test -f 'UgBanner.c'; then $(CYGPATH_W) 'UgBanner.c'; else $(CYGPATH_W) '$(srcdir)/UgBanner.c'; fi` uget_gtk-UgDownloadForm.o: UgDownloadForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgDownloadForm.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgDownloadForm.Tpo -c -o uget_gtk-UgDownloadForm.o `test -f 'UgDownloadForm.c' || echo '$(srcdir)/'`UgDownloadForm.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgDownloadForm.Tpo $(DEPDIR)/uget_gtk-UgDownloadForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgDownloadForm.c' object='uget_gtk-UgDownloadForm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgDownloadForm.o `test -f 'UgDownloadForm.c' || echo '$(srcdir)/'`UgDownloadForm.c uget_gtk-UgDownloadForm.obj: UgDownloadForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgDownloadForm.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgDownloadForm.Tpo -c -o uget_gtk-UgDownloadForm.obj `if test -f 'UgDownloadForm.c'; then $(CYGPATH_W) 'UgDownloadForm.c'; else $(CYGPATH_W) '$(srcdir)/UgDownloadForm.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgDownloadForm.Tpo $(DEPDIR)/uget_gtk-UgDownloadForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgDownloadForm.c' object='uget_gtk-UgDownloadForm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgDownloadForm.obj `if test -f 'UgDownloadForm.c'; then $(CYGPATH_W) 'UgDownloadForm.c'; else $(CYGPATH_W) '$(srcdir)/UgDownloadForm.c'; fi` uget_gtk-UgCategoryForm.o: UgCategoryForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategoryForm.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategoryForm.Tpo -c -o uget_gtk-UgCategoryForm.o `test -f 'UgCategoryForm.c' || echo '$(srcdir)/'`UgCategoryForm.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategoryForm.Tpo $(DEPDIR)/uget_gtk-UgCategoryForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategoryForm.c' object='uget_gtk-UgCategoryForm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategoryForm.o `test -f 'UgCategoryForm.c' || echo '$(srcdir)/'`UgCategoryForm.c uget_gtk-UgCategoryForm.obj: UgCategoryForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategoryForm.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategoryForm.Tpo -c -o uget_gtk-UgCategoryForm.obj `if test -f 'UgCategoryForm.c'; then $(CYGPATH_W) 'UgCategoryForm.c'; else $(CYGPATH_W) '$(srcdir)/UgCategoryForm.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategoryForm.Tpo $(DEPDIR)/uget_gtk-UgCategoryForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategoryForm.c' object='uget_gtk-UgCategoryForm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategoryForm.obj `if test -f 'UgCategoryForm.c'; then $(CYGPATH_W) 'UgCategoryForm.c'; else $(CYGPATH_W) '$(srcdir)/UgCategoryForm.c'; fi` uget_gtk-UgProxyForm.o: UgProxyForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgProxyForm.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgProxyForm.Tpo -c -o uget_gtk-UgProxyForm.o `test -f 'UgProxyForm.c' || echo '$(srcdir)/'`UgProxyForm.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgProxyForm.Tpo $(DEPDIR)/uget_gtk-UgProxyForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgProxyForm.c' object='uget_gtk-UgProxyForm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgProxyForm.o `test -f 'UgProxyForm.c' || echo '$(srcdir)/'`UgProxyForm.c uget_gtk-UgProxyForm.obj: UgProxyForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgProxyForm.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgProxyForm.Tpo -c -o uget_gtk-UgProxyForm.obj `if test -f 'UgProxyForm.c'; then $(CYGPATH_W) 'UgProxyForm.c'; else $(CYGPATH_W) '$(srcdir)/UgProxyForm.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgProxyForm.Tpo $(DEPDIR)/uget_gtk-UgProxyForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgProxyForm.c' object='uget_gtk-UgProxyForm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgProxyForm.obj `if test -f 'UgProxyForm.c'; then $(CYGPATH_W) 'UgProxyForm.c'; else $(CYGPATH_W) '$(srcdir)/UgProxyForm.c'; fi` uget_gtk-UgBatchForm.o: UgBatchForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgBatchForm.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgBatchForm.Tpo -c -o uget_gtk-UgBatchForm.o `test -f 'UgBatchForm.c' || echo '$(srcdir)/'`UgBatchForm.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgBatchForm.Tpo $(DEPDIR)/uget_gtk-UgBatchForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgBatchForm.c' object='uget_gtk-UgBatchForm.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgBatchForm.o `test -f 'UgBatchForm.c' || echo '$(srcdir)/'`UgBatchForm.c uget_gtk-UgBatchForm.obj: UgBatchForm.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgBatchForm.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgBatchForm.Tpo -c -o uget_gtk-UgBatchForm.obj `if test -f 'UgBatchForm.c'; then $(CYGPATH_W) 'UgBatchForm.c'; else $(CYGPATH_W) '$(srcdir)/UgBatchForm.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgBatchForm.Tpo $(DEPDIR)/uget_gtk-UgBatchForm.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgBatchForm.c' object='uget_gtk-UgBatchForm.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgBatchForm.obj `if test -f 'UgBatchForm.c'; then $(CYGPATH_W) 'UgBatchForm.c'; else $(CYGPATH_W) '$(srcdir)/UgBatchForm.c'; fi` uget_gtk-UgDownloadWidget.o: UgDownloadWidget.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgDownloadWidget.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgDownloadWidget.Tpo -c -o uget_gtk-UgDownloadWidget.o `test -f 'UgDownloadWidget.c' || echo '$(srcdir)/'`UgDownloadWidget.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgDownloadWidget.Tpo $(DEPDIR)/uget_gtk-UgDownloadWidget.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgDownloadWidget.c' object='uget_gtk-UgDownloadWidget.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgDownloadWidget.o `test -f 'UgDownloadWidget.c' || echo '$(srcdir)/'`UgDownloadWidget.c uget_gtk-UgDownloadWidget.obj: UgDownloadWidget.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgDownloadWidget.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgDownloadWidget.Tpo -c -o uget_gtk-UgDownloadWidget.obj `if test -f 'UgDownloadWidget.c'; then $(CYGPATH_W) 'UgDownloadWidget.c'; else $(CYGPATH_W) '$(srcdir)/UgDownloadWidget.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgDownloadWidget.Tpo $(DEPDIR)/uget_gtk-UgDownloadWidget.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgDownloadWidget.c' object='uget_gtk-UgDownloadWidget.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgDownloadWidget.obj `if test -f 'UgDownloadWidget.c'; then $(CYGPATH_W) 'UgDownloadWidget.c'; else $(CYGPATH_W) '$(srcdir)/UgDownloadWidget.c'; fi` uget_gtk-UgCategoryWidget.o: UgCategoryWidget.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategoryWidget.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategoryWidget.Tpo -c -o uget_gtk-UgCategoryWidget.o `test -f 'UgCategoryWidget.c' || echo '$(srcdir)/'`UgCategoryWidget.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategoryWidget.Tpo $(DEPDIR)/uget_gtk-UgCategoryWidget.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategoryWidget.c' object='uget_gtk-UgCategoryWidget.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategoryWidget.o `test -f 'UgCategoryWidget.c' || echo '$(srcdir)/'`UgCategoryWidget.c uget_gtk-UgCategoryWidget.obj: UgCategoryWidget.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategoryWidget.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategoryWidget.Tpo -c -o uget_gtk-UgCategoryWidget.obj `if test -f 'UgCategoryWidget.c'; then $(CYGPATH_W) 'UgCategoryWidget.c'; else $(CYGPATH_W) '$(srcdir)/UgCategoryWidget.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategoryWidget.Tpo $(DEPDIR)/uget_gtk-UgCategoryWidget.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategoryWidget.c' object='uget_gtk-UgCategoryWidget.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategoryWidget.obj `if test -f 'UgCategoryWidget.c'; then $(CYGPATH_W) 'UgCategoryWidget.c'; else $(CYGPATH_W) '$(srcdir)/UgCategoryWidget.c'; fi` uget_gtk-UgCategory-gtk.o: UgCategory-gtk.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategory-gtk.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategory-gtk.Tpo -c -o uget_gtk-UgCategory-gtk.o `test -f 'UgCategory-gtk.c' || echo '$(srcdir)/'`UgCategory-gtk.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategory-gtk.Tpo $(DEPDIR)/uget_gtk-UgCategory-gtk.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategory-gtk.c' object='uget_gtk-UgCategory-gtk.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategory-gtk.o `test -f 'UgCategory-gtk.c' || echo '$(srcdir)/'`UgCategory-gtk.c uget_gtk-UgCategory-gtk.obj: UgCategory-gtk.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategory-gtk.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategory-gtk.Tpo -c -o uget_gtk-UgCategory-gtk.obj `if test -f 'UgCategory-gtk.c'; then $(CYGPATH_W) 'UgCategory-gtk.c'; else $(CYGPATH_W) '$(srcdir)/UgCategory-gtk.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategory-gtk.Tpo $(DEPDIR)/uget_gtk-UgCategory-gtk.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategory-gtk.c' object='uget_gtk-UgCategory-gtk.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategory-gtk.obj `if test -f 'UgCategory-gtk.c'; then $(CYGPATH_W) 'UgCategory-gtk.c'; else $(CYGPATH_W) '$(srcdir)/UgCategory-gtk.c'; fi` uget_gtk-UgDownloadDialog.o: UgDownloadDialog.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgDownloadDialog.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgDownloadDialog.Tpo -c -o uget_gtk-UgDownloadDialog.o `test -f 'UgDownloadDialog.c' || echo '$(srcdir)/'`UgDownloadDialog.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgDownloadDialog.Tpo $(DEPDIR)/uget_gtk-UgDownloadDialog.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgDownloadDialog.c' object='uget_gtk-UgDownloadDialog.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgDownloadDialog.o `test -f 'UgDownloadDialog.c' || echo '$(srcdir)/'`UgDownloadDialog.c uget_gtk-UgDownloadDialog.obj: UgDownloadDialog.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgDownloadDialog.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgDownloadDialog.Tpo -c -o uget_gtk-UgDownloadDialog.obj `if test -f 'UgDownloadDialog.c'; then $(CYGPATH_W) 'UgDownloadDialog.c'; else $(CYGPATH_W) '$(srcdir)/UgDownloadDialog.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgDownloadDialog.Tpo $(DEPDIR)/uget_gtk-UgDownloadDialog.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgDownloadDialog.c' object='uget_gtk-UgDownloadDialog.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgDownloadDialog.obj `if test -f 'UgDownloadDialog.c'; then $(CYGPATH_W) 'UgDownloadDialog.c'; else $(CYGPATH_W) '$(srcdir)/UgDownloadDialog.c'; fi` uget_gtk-UgCategoryDialog.o: UgCategoryDialog.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategoryDialog.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategoryDialog.Tpo -c -o uget_gtk-UgCategoryDialog.o `test -f 'UgCategoryDialog.c' || echo '$(srcdir)/'`UgCategoryDialog.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategoryDialog.Tpo $(DEPDIR)/uget_gtk-UgCategoryDialog.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategoryDialog.c' object='uget_gtk-UgCategoryDialog.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategoryDialog.o `test -f 'UgCategoryDialog.c' || echo '$(srcdir)/'`UgCategoryDialog.c uget_gtk-UgCategoryDialog.obj: UgCategoryDialog.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgCategoryDialog.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgCategoryDialog.Tpo -c -o uget_gtk-UgCategoryDialog.obj `if test -f 'UgCategoryDialog.c'; then $(CYGPATH_W) 'UgCategoryDialog.c'; else $(CYGPATH_W) '$(srcdir)/UgCategoryDialog.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgCategoryDialog.Tpo $(DEPDIR)/uget_gtk-UgCategoryDialog.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgCategoryDialog.c' object='uget_gtk-UgCategoryDialog.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgCategoryDialog.obj `if test -f 'UgCategoryDialog.c'; then $(CYGPATH_W) 'UgCategoryDialog.c'; else $(CYGPATH_W) '$(srcdir)/UgCategoryDialog.c'; fi` uget_gtk-UgSettingDialog.o: UgSettingDialog.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSettingDialog.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgSettingDialog.Tpo -c -o uget_gtk-UgSettingDialog.o `test -f 'UgSettingDialog.c' || echo '$(srcdir)/'`UgSettingDialog.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSettingDialog.Tpo $(DEPDIR)/uget_gtk-UgSettingDialog.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSettingDialog.c' object='uget_gtk-UgSettingDialog.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSettingDialog.o `test -f 'UgSettingDialog.c' || echo '$(srcdir)/'`UgSettingDialog.c uget_gtk-UgSettingDialog.obj: UgSettingDialog.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgSettingDialog.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgSettingDialog.Tpo -c -o uget_gtk-UgSettingDialog.obj `if test -f 'UgSettingDialog.c'; then $(CYGPATH_W) 'UgSettingDialog.c'; else $(CYGPATH_W) '$(srcdir)/UgSettingDialog.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgSettingDialog.Tpo $(DEPDIR)/uget_gtk-UgSettingDialog.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgSettingDialog.c' object='uget_gtk-UgSettingDialog.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgSettingDialog.obj `if test -f 'UgSettingDialog.c'; then $(CYGPATH_W) 'UgSettingDialog.c'; else $(CYGPATH_W) '$(srcdir)/UgSettingDialog.c'; fi` uget_gtk-UgApp-gtk.o: UgApp-gtk.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk.Tpo -c -o uget_gtk-UgApp-gtk.o `test -f 'UgApp-gtk.c' || echo '$(srcdir)/'`UgApp-gtk.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk.c' object='uget_gtk-UgApp-gtk.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk.o `test -f 'UgApp-gtk.c' || echo '$(srcdir)/'`UgApp-gtk.c uget_gtk-UgApp-gtk.obj: UgApp-gtk.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk.Tpo -c -o uget_gtk-UgApp-gtk.obj `if test -f 'UgApp-gtk.c'; then $(CYGPATH_W) 'UgApp-gtk.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk.c' object='uget_gtk-UgApp-gtk.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk.obj `if test -f 'UgApp-gtk.c'; then $(CYGPATH_W) 'UgApp-gtk.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk.c'; fi` uget_gtk-UgApp-gtk-gui.o: UgApp-gtk-gui.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-gui.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-gui.Tpo -c -o uget_gtk-UgApp-gtk-gui.o `test -f 'UgApp-gtk-gui.c' || echo '$(srcdir)/'`UgApp-gtk-gui.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-gui.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-gui.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-gui.c' object='uget_gtk-UgApp-gtk-gui.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-gui.o `test -f 'UgApp-gtk-gui.c' || echo '$(srcdir)/'`UgApp-gtk-gui.c uget_gtk-UgApp-gtk-gui.obj: UgApp-gtk-gui.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-gui.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-gui.Tpo -c -o uget_gtk-UgApp-gtk-gui.obj `if test -f 'UgApp-gtk-gui.c'; then $(CYGPATH_W) 'UgApp-gtk-gui.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-gui.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-gui.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-gui.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-gui.c' object='uget_gtk-UgApp-gtk-gui.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-gui.obj `if test -f 'UgApp-gtk-gui.c'; then $(CYGPATH_W) 'UgApp-gtk-gui.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-gui.c'; fi` uget_gtk-UgApp-gtk-aria2.o: UgApp-gtk-aria2.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-aria2.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Tpo -c -o uget_gtk-UgApp-gtk-aria2.o `test -f 'UgApp-gtk-aria2.c' || echo '$(srcdir)/'`UgApp-gtk-aria2.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-aria2.c' object='uget_gtk-UgApp-gtk-aria2.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-aria2.o `test -f 'UgApp-gtk-aria2.c' || echo '$(srcdir)/'`UgApp-gtk-aria2.c uget_gtk-UgApp-gtk-aria2.obj: UgApp-gtk-aria2.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-aria2.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Tpo -c -o uget_gtk-UgApp-gtk-aria2.obj `if test -f 'UgApp-gtk-aria2.c'; then $(CYGPATH_W) 'UgApp-gtk-aria2.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-aria2.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-aria2.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-aria2.c' object='uget_gtk-UgApp-gtk-aria2.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-aria2.obj `if test -f 'UgApp-gtk-aria2.c'; then $(CYGPATH_W) 'UgApp-gtk-aria2.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-aria2.c'; fi` uget_gtk-UgApp-gtk-callback.o: UgApp-gtk-callback.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-callback.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-callback.Tpo -c -o uget_gtk-UgApp-gtk-callback.o `test -f 'UgApp-gtk-callback.c' || echo '$(srcdir)/'`UgApp-gtk-callback.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-callback.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-callback.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-callback.c' object='uget_gtk-UgApp-gtk-callback.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-callback.o `test -f 'UgApp-gtk-callback.c' || echo '$(srcdir)/'`UgApp-gtk-callback.c uget_gtk-UgApp-gtk-callback.obj: UgApp-gtk-callback.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-callback.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-callback.Tpo -c -o uget_gtk-UgApp-gtk-callback.obj `if test -f 'UgApp-gtk-callback.c'; then $(CYGPATH_W) 'UgApp-gtk-callback.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-callback.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-callback.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-callback.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-callback.c' object='uget_gtk-UgApp-gtk-callback.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-callback.obj `if test -f 'UgApp-gtk-callback.c'; then $(CYGPATH_W) 'UgApp-gtk-callback.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-callback.c'; fi` uget_gtk-UgApp-gtk-timeout.o: UgApp-gtk-timeout.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-timeout.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Tpo -c -o uget_gtk-UgApp-gtk-timeout.o `test -f 'UgApp-gtk-timeout.c' || echo '$(srcdir)/'`UgApp-gtk-timeout.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-timeout.c' object='uget_gtk-UgApp-gtk-timeout.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-timeout.o `test -f 'UgApp-gtk-timeout.c' || echo '$(srcdir)/'`UgApp-gtk-timeout.c uget_gtk-UgApp-gtk-timeout.obj: UgApp-gtk-timeout.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-timeout.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Tpo -c -o uget_gtk-UgApp-gtk-timeout.obj `if test -f 'UgApp-gtk-timeout.c'; then $(CYGPATH_W) 'UgApp-gtk-timeout.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-timeout.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-timeout.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-timeout.c' object='uget_gtk-UgApp-gtk-timeout.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-timeout.obj `if test -f 'UgApp-gtk-timeout.c'; then $(CYGPATH_W) 'UgApp-gtk-timeout.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-timeout.c'; fi` uget_gtk-UgApp-gtk-main.o: UgApp-gtk-main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-main.o -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-main.Tpo -c -o uget_gtk-UgApp-gtk-main.o `test -f 'UgApp-gtk-main.c' || echo '$(srcdir)/'`UgApp-gtk-main.c @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-main.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-main.c' object='uget_gtk-UgApp-gtk-main.o' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-main.o `test -f 'UgApp-gtk-main.c' || echo '$(srcdir)/'`UgApp-gtk-main.c uget_gtk-UgApp-gtk-main.obj: UgApp-gtk-main.c @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -MT uget_gtk-UgApp-gtk-main.obj -MD -MP -MF $(DEPDIR)/uget_gtk-UgApp-gtk-main.Tpo -c -o uget_gtk-UgApp-gtk-main.obj `if test -f 'UgApp-gtk-main.c'; then $(CYGPATH_W) 'UgApp-gtk-main.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-main.c'; fi` @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/uget_gtk-UgApp-gtk-main.Tpo $(DEPDIR)/uget_gtk-UgApp-gtk-main.Po @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='UgApp-gtk-main.c' object='uget_gtk-UgApp-gtk-main.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(uget_gtk_CPPFLAGS) $(CPPFLAGS) $(uget_gtk_CFLAGS) $(CFLAGS) -c -o uget_gtk-UgApp-gtk-main.obj `if test -f 'UgApp-gtk-main.c'; then $(CYGPATH_W) 'UgApp-gtk-main.c'; else $(CYGPATH_W) '$(srcdir)/UgApp-gtk-main.c'; fi` ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ mkid -fID $$unique tags: TAGS TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) set x; \ here=`pwd`; \ list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ shift; \ if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ test -n "$$unique" || unique=$$empty_fix; \ if test $$# -gt 0; then \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ "$$@" $$unique; \ else \ $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ $$unique; \ fi; \ fi ctags: CTAGS CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ $(TAGS_FILES) $(LISP) list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ unique=`for i in $$list; do \ if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ done | \ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ END { if (nonempty) { for (i in files) print i; }; }'`; \ test -z "$(CTAGS_ARGS)$$unique" \ || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ $$unique GTAGS: here=`$(am__cd) $(top_builddir) && pwd` \ && $(am__cd) $(top_srcdir) \ && gtags -i $(GTAGS_ARGS) "$$here" distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ dist_files=`for file in $$list; do echo $$file; done | \ sed -e "s|^$$srcdirstrip/||;t" \ -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ case $$dist_files in \ */*) $(MKDIR_P) `echo "$$dist_files" | \ sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ sort -u` ;; \ esac; \ for file in $$dist_files; do \ if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ if test -d $$d/$$file; then \ dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ if test -d "$(distdir)/$$file"; then \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ fi; \ cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ else \ test -f "$(distdir)/$$file" \ || cp -p $$d/$$file "$(distdir)/$$file" \ || exit 1; \ fi; \ done check-am: all-am check: check-am all-am: Makefile $(PROGRAMS) $(HEADERS) installdirs: for dir in "$(DESTDIR)$(bindir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am installcheck: installcheck-am install-strip: if test -z '$(STRIP)'; then \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ install; \ else \ $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ fi mostlyclean-generic: clean-generic: distclean-generic: -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @echo "it deletes files that may require special tools to rebuild." clean: clean-am clean-am: clean-binPROGRAMS clean-generic mostlyclean-am distclean: distclean-am -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags dvi: dvi-am dvi-am: html: html-am html-am: info: info-am info-am: install-data-am: install-dvi: install-dvi-am install-dvi-am: install-exec-am: install-binPROGRAMS install-html: install-html-am install-html-am: install-info: install-info-am install-info-am: install-man: install-pdf: install-pdf-am install-pdf-am: install-ps: install-ps-am install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am mostlyclean-am: mostlyclean-compile mostlyclean-generic pdf: pdf-am pdf-am: ps: ps-am ps-am: uninstall-am: uninstall-binPROGRAMS .MAKE: install-am install-strip .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic ctags distclean distclean-compile \ distclean-generic distclean-tags distdir dvi dvi-am html \ html-am info info-am install install-am install-binPROGRAMS \ install-data install-data-am install-dvi install-dvi-am \ install-exec install-exec-am install-html install-html-am \ install-info install-info-am install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ uninstall-am uninstall-binPROGRAMS # Tell versions [3.59,3.63) of GNU make to not export all variables. # Otherwise a system limit (for SysV at least) may be exceeded. .NOEXPORT: uget-1.10.4/uget-gtk/UgSummary.c0000664000175000017500000002176612260761064013330 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include enum UG_SUMMARY_COLUMN { UG_SUMMARY_COLUMN_ICON, UG_SUMMARY_COLUMN_NAME, UG_SUMMARY_COLUMN_VALUE, UG_SUMMARY_N_COLUMN }; // static functions static GtkTreeView* ug_summary_view_new (); static void ug_summary_store_realloc_next (GtkListStore* store, GtkTreeIter* iter); static void ug_summary_menu_init (UgSummary* summary, GtkAccelGroup* accel_group); void ug_summary_init (UgSummary* summary, GtkAccelGroup* accel_group) { GtkScrolledWindow* scroll; summary->store = gtk_list_store_new (UG_SUMMARY_N_COLUMN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING); summary->view = ug_summary_view_new (); gtk_tree_view_set_model (summary->view, GTK_TREE_MODEL (summary->store)); summary->self = gtk_scrolled_window_new (NULL, NULL); scroll = GTK_SCROLLED_WINDOW (summary->self); gtk_scrolled_window_set_shadow_type (scroll, GTK_SHADOW_IN); gtk_scrolled_window_set_policy (scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scroll), GTK_WIDGET (summary->view)); gtk_widget_set_size_request (summary->self, 200, 90); gtk_widget_show_all (summary->self); // menu ug_summary_menu_init (summary, accel_group); // visible summary->visible.name = 1; summary->visible.folder = 1; summary->visible.category = 0; summary->visible.url = 0; summary->visible.message = 1; } void ug_summary_show (UgSummary* summary, UgDataset* dataset) { UgetCommon* common; UgetRelation* relation; GtkTreeIter iter; gchar* name; gchar* value; gchar* filename; if (dataset == NULL) { gtk_list_store_clear (summary->store); return; } common = UG_DATASET_COMMON (dataset); relation = UG_DATASET_RELATION (dataset); iter.stamp = 0; // used by ug_summary_store_realloc_next() // Summary Name if (summary->visible.name) { filename = NULL; if (common->name) { name = g_strconcat (_("Name"), ":", NULL); value = common->name; } else { name = g_strconcat (_("File"), ":", NULL); value = common->file; if (value == NULL && common->url) { filename = ug_uri_get_filename (common->url); value = filename; } if (value == NULL) value = _("unnamed"); } ug_summary_store_realloc_next (summary->store, &iter); gtk_list_store_set (summary->store, &iter, UG_SUMMARY_COLUMN_ICON , GTK_STOCK_FILE, UG_SUMMARY_COLUMN_NAME , name, UG_SUMMARY_COLUMN_VALUE, value, -1); g_free (name); g_free (filename); } // Summary Folder if (summary->visible.folder) { name = g_strconcat (_("Folder"), ":", NULL); ug_summary_store_realloc_next (summary->store, &iter); gtk_list_store_set (summary->store, &iter, UG_SUMMARY_COLUMN_ICON , GTK_STOCK_DIRECTORY, UG_SUMMARY_COLUMN_NAME , name, UG_SUMMARY_COLUMN_VALUE, common->folder, -1); g_free (name); } // Summary Category if (summary->visible.category) { name = g_strconcat (_("Category"), ":", NULL); ug_summary_store_realloc_next (summary->store, &iter); gtk_list_store_set (summary->store, &iter, UG_SUMMARY_COLUMN_ICON , GTK_STOCK_DND_MULTIPLE, UG_SUMMARY_COLUMN_NAME , name, UG_SUMMARY_COLUMN_VALUE, relation->category->name, -1); g_free (name); } // Summary URL if (summary->visible.url) { name = g_strconcat (_("URL"), ":", NULL); ug_summary_store_realloc_next (summary->store, &iter); gtk_list_store_set (summary->store, &iter, UG_SUMMARY_COLUMN_ICON , GTK_STOCK_NETWORK, UG_SUMMARY_COLUMN_NAME , name, UG_SUMMARY_COLUMN_VALUE, common->url, -1); g_free (name); } // Summary Message if (summary->visible.message) { switch (relation->message.type) { case UG_MESSAGE_ERROR: value = GTK_STOCK_DIALOG_ERROR; break; case UG_MESSAGE_WARNING: value = GTK_STOCK_DIALOG_WARNING; break; default: value = GTK_STOCK_INFO; break; } name = g_strconcat (_("Message"), ":", NULL); ug_summary_store_realloc_next (summary->store, &iter); gtk_list_store_set (summary->store, &iter, UG_SUMMARY_COLUMN_ICON , value, UG_SUMMARY_COLUMN_NAME , name, UG_SUMMARY_COLUMN_VALUE, relation->message.string, -1); } // clear remaining rows if (gtk_tree_model_iter_next (GTK_TREE_MODEL (summary->store), &iter)) { while (gtk_list_store_remove (summary->store, &iter)) continue; } } gchar* ug_summary_get_text_selected (UgSummary* summary) { GtkTreeModel* model; GtkTreePath* path; GtkTreeIter iter; gchar* name; gchar* value; gtk_tree_view_get_cursor (summary->view, &path, NULL); if (path == NULL) return NULL; model = GTK_TREE_MODEL (summary->store); gtk_tree_model_get_iter (model, &iter, path); gtk_tree_path_free (path); gtk_tree_model_get (model, &iter, UG_SUMMARY_COLUMN_NAME , &name, UG_SUMMARY_COLUMN_VALUE, &value, -1); return g_strconcat (name, " ", value, NULL); } gchar* ug_summary_get_text_all (UgSummary* summary) { GtkTreeModel* model; GtkTreeIter iter; gchar* name; gchar* value; gboolean valid; GString* gstr; gstr = g_string_sized_new (60); model = GTK_TREE_MODEL (summary->store); valid = gtk_tree_model_get_iter_first (model, &iter); while (valid) { gtk_tree_model_get (model, &iter, UG_SUMMARY_COLUMN_NAME , &name, UG_SUMMARY_COLUMN_VALUE, &value, -1); valid = gtk_tree_model_iter_next (model, &iter); // string g_string_append (gstr, name); if (value) { g_string_append_c (gstr, ' '); g_string_append (gstr, value); } g_string_append_c (gstr, '\n'); } return g_string_free (gstr, FALSE); } // ---------------------------------------------------------------------------- // UgSummary static functions // static GtkTreeView* ug_summary_view_new () { GtkTreeView* view; GtkCellRenderer* renderer; view = (GtkTreeView*) gtk_tree_view_new (); gtk_tree_view_set_headers_visible (view, FALSE); // columns renderer = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_insert_column_with_attributes ( view, UG_SUMMARY_COLUMN_ICON, NULL, renderer, "stock-id", UG_SUMMARY_COLUMN_ICON, NULL); renderer = gtk_cell_renderer_text_new (); gtk_tree_view_insert_column_with_attributes ( view, UG_SUMMARY_COLUMN_NAME, _("Item"), renderer, "text", UG_SUMMARY_COLUMN_NAME, NULL); gtk_tree_view_insert_column_with_attributes ( view, UG_SUMMARY_COLUMN_VALUE, _("Value"), renderer, "text", UG_SUMMARY_COLUMN_VALUE, NULL); return view; } static void ug_summary_store_realloc_next (GtkListStore* store, GtkTreeIter* iter) { GtkTreeModel* model; model = GTK_TREE_MODEL (store); if (iter->stamp == 0) { if (gtk_tree_model_get_iter_first (model, iter) == FALSE) gtk_list_store_append (store, iter); } else if (gtk_tree_model_iter_next (model, iter) == FALSE) gtk_list_store_append (store, iter); } static void ug_summary_menu_init (UgSummary* summary, GtkAccelGroup* accel_group) { GtkWidget* image; GtkWidget* menu; GtkWidget* menu_item; // UgSummary.menu menu = gtk_menu_new (); // Copy menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_COPY, accel_group); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); summary->menu.copy = menu_item; // Copy All menu_item = gtk_image_menu_item_new_with_mnemonic (_("Copy _All")); image = gtk_image_new_from_stock (GTK_STOCK_SELECT_ALL, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (menu_item), image); gtk_menu_shell_append (GTK_MENU_SHELL (menu), menu_item); summary->menu.copy_all = menu_item; gtk_widget_show_all (menu); summary->menu.self = GTK_MENU (menu); } uget-1.10.4/uget-gtk/UgApp-gtk-gui.c0000664000175000017500000011726112260761064013754 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include // for GDK_KEY_key... #ifdef HAVE_CONFIG_H #include #endif // uglib #include #include static void ug_trayicon_init (struct UgTrayIcon* app_trayicon); static void ug_window_init (struct UgWindow* app_window, UgAppGtk* app); static void ug_statusbar_init (struct UgStatusbar* app_statusbar); static void ug_toolbar_init (struct UgToolbar* app_toolbar, GtkAccelGroup* accel_group); static void ug_menubar_init (struct UgMenubar* app_menubar, GtkAccelGroup* accel_group); void ug_app_init_gui (UgAppGtk* app) { #ifdef _WIN32 // This will use icons\hicolor\index.theme GtkIconTheme* icon_theme; gchar* path; icon_theme = gtk_icon_theme_get_default (); path = g_build_filename (ug_get_data_dir (), "icons", NULL); gtk_icon_theme_append_search_path (icon_theme, path); g_free (path); #endif // _WIN32 // Registers a new accelerator "Ctrl+N" with the global accelerator map. gtk_accel_map_add_entry (UG_APP_GTK_ACCEL_PATH_CTRL_N, GDK_KEY_n, GDK_CONTROL_MASK); gtk_accel_map_add_entry (UG_APP_GTK_ACCEL_PATH_DELETE, GDK_KEY_Delete, 0); // gtk_accel_map_add_entry (UG_APP_GTK_ACCEL_PATH_DELETE_F, GDK_KEY_Delete, GDK_SHIFT_MASK); gtk_accel_map_add_entry (UG_APP_GTK_ACCEL_PATH_DELETE_F, GDK_KEY_Delete, GDK_CONTROL_MASK); gtk_accel_map_add_entry (UG_APP_GTK_ACCEL_PATH_OPEN, GDK_KEY_Return, 0); gtk_accel_map_add_entry (UG_APP_GTK_ACCEL_PATH_OPEN_F, GDK_KEY_Return, GDK_SHIFT_MASK); // accelerators app->accel_group = gtk_accel_group_new (); // tray icon ug_trayicon_init (&app->trayicon); // main window ug_category_widget_init (&app->cwidget); ug_summary_init (&app->summary, app->accel_group); ug_statusbar_init (&app->statusbar); ug_toolbar_init (&app->toolbar, app->accel_group); ug_menubar_init (&app->menubar, app->accel_group); ug_banner_init (&app->banner); ug_window_init (&app->window, app); } // ---------------------------------------------------------------------------- // UgTrayIcon // static void ug_trayicon_init (struct UgTrayIcon* trayicon) { GtkWidget* image; GtkWidget* menu; GtkWidget* menu_item; gchar* icon_name; gchar* file_name; // UgTrayIcon.menu menu = gtk_menu_new (); // New Download menu_item = gtk_image_menu_item_new_with_mnemonic (_("New _Download...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.create_download = menu_item; // New Clipboard batch menu_item = gtk_image_menu_item_new_with_mnemonic (_("New Clipboard _batch...")); image = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.create_clipboard = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // New Torrent menu_item = gtk_image_menu_item_new_with_mnemonic (_("New Torrent...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.create_torrent = menu_item; // New Metalink menu_item = gtk_image_menu_item_new_with_mnemonic (_("New Metalink...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.create_metalink = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // Settings menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Settings...")); image = gtk_image_new_from_stock (GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.settings = menu_item; // About menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.about = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // Show window menu_item = gtk_menu_item_new_with_mnemonic (_("Show window")); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.show_window = menu_item; // Offline mode menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Offline Mode")); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.offline_mode = menu_item; // Quit menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, NULL); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); trayicon->menu.quit = menu_item; gtk_widget_show_all (menu); trayicon->menu.self = menu; // decide tray icon file_name = g_build_filename (ug_get_data_dir (), "icons", "hicolor", "16x16", "apps", "uget-icon.png", NULL); if (g_file_test (file_name, G_FILE_TEST_IS_REGULAR)) icon_name = UG_APP_GTK_TRAY_ICON_NAME; else icon_name = GTK_STOCK_GO_DOWN; g_free (file_name); #ifdef HAVE_APP_INDICATOR trayicon->indicator = app_indicator_new ("uget-gtk", icon_name, APP_INDICATOR_CATEGORY_APPLICATION_STATUS); if (trayicon->indicator) { app_indicator_set_menu (trayicon->indicator, GTK_MENU (trayicon->menu.self)); // app_indicator_set_attention_icon_full (trayicon->indicator, // UG_APP_GTK_TRAY_ICON_ACTIVE_NAME, NULL); app_indicator_set_attention_icon (trayicon->indicator, UG_APP_GTK_TRAY_ICON_ACTIVE_NAME); app_indicator_set_status (trayicon->indicator, APP_INDICATOR_STATUS_PASSIVE); } #endif // HAVE_APP_INDICATOR trayicon->self = gtk_status_icon_new_from_icon_name (icon_name); gtk_status_icon_set_visible (trayicon->self, FALSE); ug_trayicon_set_info (trayicon, 0, 0, 0); } // ---------------------------------------------------------------------------- // UgWindow // static void ug_window_init (struct UgWindow* window, UgAppGtk* app) { GtkBox* vbox; GtkBox* rbox; window->self = (GtkWindow*) gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (window->self, UG_APP_GTK_NAME); gtk_window_set_default_size (window->self, 780, 480); gtk_window_add_accel_group (window->self, app->accel_group); gtk_window_set_default_icon_name (UG_APP_GTK_APP_ICON_NAME); // top container for Main Window vbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_container_add (GTK_CONTAINER (window->self), GTK_WIDGET (vbox)); // banner + menubar gtk_box_pack_start (vbox, app->banner.self, FALSE, FALSE, 0); gtk_box_pack_start (vbox, app->menubar.self, FALSE, FALSE, 0); // right side vbox rbox = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); gtk_box_pack_start (rbox, app->toolbar.self, FALSE, FALSE, 0); // hpaned window->hpaned = (GtkPaned*) gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); gtk_box_pack_start (vbox, GTK_WIDGET (window->hpaned), TRUE, TRUE, 0); gtk_paned_pack1 (window->hpaned, app->cwidget.self, FALSE, TRUE); gtk_paned_pack2 (window->hpaned, GTK_WIDGET (rbox), TRUE, FALSE); // vpaned window->vpaned = (GtkPaned*) gtk_paned_new (GTK_ORIENTATION_VERTICAL); gtk_box_pack_start (rbox, (GtkWidget*) window->vpaned, TRUE, TRUE, 0); // gtk_paned_pack1 (window->vpaned, GTK_WIDGET (app->cwidget.primary->all.self), TRUE, TRUE); gtk_paned_pack2 (window->vpaned, GTK_WIDGET (app->summary.self), FALSE, TRUE); gtk_box_pack_start (vbox, GTK_WIDGET (app->statusbar.self), FALSE, FALSE, 0); gtk_widget_show_all ((GtkWidget*) vbox); } // ---------------------------------------------------------------------------- // UgStatusbar // static void ug_statusbar_init (struct UgStatusbar* sbar) { GtkBox* hbox; GtkWidget* widget; sbar->self = (GtkStatusbar*) gtk_statusbar_new (); hbox = GTK_BOX (sbar->self); // upload speed label widget = gtk_label_new (""); sbar->up_speed = (GtkLabel*) widget; gtk_widget_set_size_request (widget, 100, 0); gtk_box_pack_end (hbox, widget, FALSE, TRUE, 2); // gtk_label_set_width_chars (sbar->down_speed, 15); gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5); gtk_box_pack_end (hbox, gtk_label_new ("U:"), FALSE, TRUE, 2); gtk_box_pack_end (hbox, gtk_separator_new (GTK_ORIENTATION_VERTICAL), FALSE, TRUE, 8); // download speed label widget = gtk_label_new (""); sbar->down_speed = (GtkLabel*) widget; gtk_widget_set_size_request (widget, 100, 0); gtk_box_pack_end (hbox, widget, FALSE, TRUE, 2); // gtk_label_set_width_chars (sbar->down_speed, 15); gtk_misc_set_alignment (GTK_MISC (widget), 0, 0.5); gtk_box_pack_end (hbox, gtk_label_new ("D:"), FALSE, TRUE, 2); ug_statusbar_set_speed (sbar, 0, 0); } // ---------------------------------------------------------------------------- // UgToolbar // static void ug_toolbar_init (struct UgToolbar* ugt, GtkAccelGroup* accel_group) { GtkToolbar* toolbar; GtkToolItem* tool_item; GtkWidget* image; GtkWidget* menu; GtkWidget* menu_item; // toolbar ugt->self = gtk_toolbar_new (); toolbar = GTK_TOOLBAR (ugt->self); gtk_toolbar_set_style (toolbar, GTK_TOOLBAR_ICONS); gtk_toolbar_set_icon_size (toolbar, GTK_ICON_SIZE_SMALL_TOOLBAR); // New button --- start --- tool_item = (GtkToolItem*) gtk_menu_tool_button_new_from_stock (GTK_STOCK_NEW); gtk_tool_item_set_tooltip_text (tool_item, _("Create new download")); gtk_menu_tool_button_set_arrow_tooltip_text ((GtkMenuToolButton*)tool_item, "Create new item"); gtk_tool_item_set_homogeneous (tool_item, FALSE); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->create = GTK_WIDGET (tool_item); // menu for tool button (accelerators) menu = gtk_menu_new (); gtk_menu_set_accel_group ((GtkMenu*) menu, accel_group); gtk_menu_tool_button_set_menu ((GtkMenuToolButton*)tool_item, menu); // New Download (accelerators) menu_item = gtk_image_menu_item_new_with_mnemonic (_("New _Download...")); gtk_menu_item_set_accel_path ((GtkMenuItem*) menu_item, UG_APP_GTK_ACCEL_PATH_CTRL_N); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); ugt->create_download = menu_item; // New Category menu_item = gtk_image_menu_item_new_with_mnemonic (_("New _Category...")); image = gtk_image_new_from_stock (GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); ugt->create_category = menu_item; // New Clipboard batch menu_item = gtk_image_menu_item_new_with_mnemonic (_("New Clipboard _batch...")); image = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); ugt->create_clipboard = menu_item; gtk_widget_show_all (menu); // New URL Sequence batch menu_item = gtk_image_menu_item_new_with_mnemonic (_("New _URL Sequence batch...")); image = gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); ugt->create_sequence = menu_item; gtk_widget_show_all (menu); gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // New Torrent menu_item = gtk_image_menu_item_new_with_mnemonic (_("New Torrent...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); ugt->create_torrent = menu_item; gtk_widget_show_all (menu); // New Metalink menu_item = gtk_image_menu_item_new_with_mnemonic (_("New Metalink...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); ugt->create_metalink = menu_item; gtk_widget_show_all (menu); // New button --- end --- tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_SAVE); gtk_tool_item_set_tooltip_text (tool_item, _("Save all")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->save = GTK_WIDGET (tool_item); tool_item = gtk_separator_tool_item_new (); gtk_toolbar_insert (toolbar, tool_item, -1); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); gtk_tool_item_set_tooltip_text (tool_item, _("Set selected download runnable")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->runnable = GTK_WIDGET (tool_item); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_MEDIA_PAUSE); gtk_tool_item_set_tooltip_text (tool_item, _("Set selected download to pause")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->pause = GTK_WIDGET (tool_item); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_PROPERTIES); gtk_tool_item_set_tooltip_text (tool_item, _("Set selected download properties")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->properties = GTK_WIDGET (tool_item); tool_item = gtk_separator_tool_item_new (); gtk_toolbar_insert (toolbar, tool_item, -1); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_GO_UP); gtk_tool_item_set_tooltip_text (tool_item, _("Move selected download up")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->move_up = GTK_WIDGET (tool_item); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_GO_DOWN); gtk_tool_item_set_tooltip_text (tool_item, _("Move selected download down")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->move_down = GTK_WIDGET (tool_item); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_GOTO_TOP); gtk_tool_item_set_tooltip_text (tool_item, _("Move selected download to top")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->move_top = GTK_WIDGET (tool_item); tool_item = (GtkToolItem*) gtk_tool_button_new_from_stock (GTK_STOCK_GOTO_BOTTOM); gtk_tool_item_set_tooltip_text (tool_item, _("Move selected download to bottom")); gtk_toolbar_insert (toolbar, tool_item, -1); ugt->move_bottom = GTK_WIDGET (tool_item); gtk_widget_show_all ((GtkWidget*) toolbar); } // ---------------------------------------------------------------------------- // UgMenubar // static void ug_menubar_init (struct UgMenubar* menubar, GtkAccelGroup* accel_group) { GtkWidget* image; GtkWidget* menu; GtkWidget* sub_menu; GtkWidget* menu_item; // Menubar menubar->self = gtk_menu_bar_new (); // ---------------------------------------------------- // UgFileMenu menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_mnemonic (_("_File")); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, menu); gtk_menu_shell_append ((GtkMenuShell*)menubar->self, menu_item); // menu.gtk_menu_shell_append((GtkMenuShell*)menu, gtk_tearoff_menu_item_new() ); // New --- start --- (accelerators) menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, NULL); sub_menu = gtk_menu_new (); gtk_menu_set_accel_group ((GtkMenu*)sub_menu, accel_group); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, sub_menu); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); // New - Download (accelerators) menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Download...")); gtk_menu_item_set_accel_path ((GtkMenuItem*) menu_item, UG_APP_GTK_ACCEL_PATH_CTRL_N); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.create.download = menu_item; // New - Category menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Category...")); image = gtk_image_new_from_stock (GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.create.category = menu_item; // New - separator gtk_menu_shell_append ((GtkMenuShell*)sub_menu, gtk_separator_menu_item_new() ); // New - Torrent menu_item = gtk_image_menu_item_new_with_mnemonic (_("Torrent...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.create.torrent = menu_item; // New - Metalink menu_item = gtk_image_menu_item_new_with_mnemonic (_("Metalink...")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.create.metalink = menu_item; // New --- end --- // Batch Downloads --- start --- menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Batch Downloads")); sub_menu = gtk_menu_new (); gtk_menu_set_accel_group ((GtkMenu*)sub_menu, accel_group); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, sub_menu); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); // Batch downloads - Clipboard batch menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Clipboard batch...")); image = gtk_image_new_from_stock (GTK_STOCK_PASTE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.batch.clipboard = menu_item; // Batch downloads - URL Sequence batch menu_item = gtk_image_menu_item_new_with_mnemonic (_("_URL Sequence batch...")); image = gtk_image_new_from_stock (GTK_STOCK_SORT_ASCENDING, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.batch.sequence = menu_item; // Batch downloads - Text file import (.txt) menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Text file import (.txt)...")); image = gtk_image_new_from_stock (GTK_STOCK_GO_FORWARD, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.batch.text_import = menu_item; // Batch downloads - HTML file import (.html) menu_item = gtk_image_menu_item_new_with_mnemonic (_("_HTML file import (.html)...")); image = gtk_image_new_from_stock (GTK_STOCK_CONVERT, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.batch.html_import = menu_item; // Batch downloads - separator gtk_menu_shell_append ((GtkMenuShell*)sub_menu, gtk_separator_menu_item_new() ); // Batch downloads - Export to Text file (.txt) menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Export to Text file (.txt)...")); image = gtk_image_new_from_stock (GTK_STOCK_GO_BACK, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)sub_menu, menu_item); menubar->file.batch.text_export = menu_item; // Batch downloads --- end --- gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // Save menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_SAVE, accel_group); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->file.save = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // Offline mode menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Offline Mode")); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->file.offline_mode = menu_item; menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_QUIT, accel_group); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->file.quit = menu_item; // ---------------------------------------------------- // UgEditMenu menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_mnemonic (_("_Edit")); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, menu); gtk_menu_shell_append ((GtkMenuShell*)menubar->self, menu_item); // menu.gtk_menu_shell_append((GtkMenuShell*)menu, gtk_tearoff_menu_item_new() ); menu_item = gtk_check_menu_item_new_with_mnemonic (_("Clipboard _Monitor")); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->edit.clipboard_monitor = menu_item; menu_item = gtk_menu_item_new_with_mnemonic (_("_Clipboard Option...")); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->edit.clipboard_option = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); menu_item = gtk_check_menu_item_new_with_mnemonic (_("Shutdown when downloads complete")); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->edit.shutdown = menu_item; // menu_item = gtk_menu_item_new_with_mnemonic (_("_Settings...")); menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Settings...")); image = gtk_image_new_from_stock (GTK_STOCK_PROPERTIES, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->edit.settings = menu_item; // ---------------------------------------------------- // UgViewMenu menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_mnemonic (_("_View")); gtk_menu_item_set_submenu ((GtkMenuItem*) menu_item, menu); gtk_menu_shell_append ((GtkMenuShell*) menubar->self, menu_item); menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Toolbar")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->view.toolbar = menu_item; menu_item = gtk_check_menu_item_new_with_mnemonic (_("Statusbar")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->view.statusbar = menu_item; menu_item = gtk_check_menu_item_new_with_mnemonic (_("Category")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->view.category = menu_item; menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Summary")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->view.summary = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // Summary Items --- start --- menu_item = gtk_menu_item_new_with_mnemonic (_("Summary _Items")); sub_menu = gtk_menu_new (); gtk_menu_item_set_submenu ((GtkMenuItem*) menu_item, sub_menu); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); // Summary Items - Name menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Name")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); menubar->view.summary_items.name = menu_item; // Summary Items - Folder menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Folder")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); menubar->view.summary_items.folder = menu_item; // Summary Items - Category menu_item = gtk_check_menu_item_new_with_mnemonic (_("Category")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); menubar->view.summary_items.category = menu_item; // Summary Items - Elapsed // menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Elapsed")); // gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); // gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); // menubar->view.summary_items.elapsed = menu_item; // Summary Items - URL menu_item = gtk_check_menu_item_new_with_mnemonic (_("_URL")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); menubar->view.summary_items.url = menu_item; // Summary Items - Message menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Message")); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); menubar->view.summary_items.message = menu_item; // Summary Items --- end --- // gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // menu_item = gtk_check_menu_item_new_with_mnemonic (_("Download _Rules Hint")); // gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); // gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); // menubar->view.rules_hint = menu_item; // Download Columns --- start --- sub_menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_mnemonic (_("Download _Columns")); gtk_menu_item_set_submenu ((GtkMenuItem*) menu_item, sub_menu); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->view.columns.self = sub_menu; // Download Columns - Completed menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Complete")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.completed = menu_item; // Download Columns - Total menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Size")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.total = menu_item; // Download Columns - Percent (%) menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Percent '%'")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.percent = menu_item; // Download Columns - Elapsed menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Elapsed")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.elapsed = menu_item; // Download Columns - Left menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Left")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.left = menu_item; // Download Columns - Speed menu_item = gtk_check_menu_item_new_with_mnemonic (_("Speed")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.speed = menu_item; // Download Columns - Up Speed menu_item = gtk_check_menu_item_new_with_mnemonic (_("Up Speed")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.upload_speed = menu_item; // Download Columns - Uploaded menu_item = gtk_check_menu_item_new_with_mnemonic (_("Uploaded")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.uploaded = menu_item; // Download Columns - Ratio menu_item = gtk_check_menu_item_new_with_mnemonic (_("Ratio")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.ratio = menu_item; // Download Columns - Retry menu_item = gtk_check_menu_item_new_with_mnemonic (_("_Retry")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.retry = menu_item; // Download Columns - Category menu_item = gtk_check_menu_item_new_with_mnemonic (_("Category")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.category = menu_item; // Download Columns - URL menu_item = gtk_check_menu_item_new_with_mnemonic (_("_URL")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.url = menu_item; // Download Columns - Added On menu_item = gtk_check_menu_item_new_with_mnemonic (_("Added On")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.added_on = menu_item; // Download Columns - Completed On menu_item = gtk_check_menu_item_new_with_mnemonic (_("Completed On")); gtk_menu_shell_append ((GtkMenuShell*) sub_menu, menu_item); gtk_check_menu_item_set_active ((GtkCheckMenuItem*) menu_item, TRUE); menubar->view.columns.completed_on = menu_item; // Download Columns --- end --- // ---------------------------------------------------- // UgCategoryMenu menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_mnemonic (_("_Category")); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, menu); gtk_menu_shell_append ((GtkMenuShell*)menubar->self, menu_item); menubar->category.self = menu; // New Category menu_item = gtk_image_menu_item_new_with_mnemonic(_("_New Category...")); image = gtk_image_new_from_stock (GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->category.create = menu_item; // Delete Category menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Delete Category")); image = gtk_image_new_from_stock (GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->category.delete = menu_item; // Properties menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->category.properties = menu_item; // ---------------------------------------------------- // UgDownloadMenu menu = gtk_menu_new (); gtk_menu_set_accel_group ((GtkMenu*)menu, accel_group); menu_item = gtk_menu_item_new_with_mnemonic (_("_Download")); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, menu); gtk_menu_shell_append ((GtkMenuShell*)menubar->self, menu_item); menubar->download.self = menu; // gtk_menu_shell_append((GtkMenuShell*)menu, gtk_tearoff_menu_item_new() ); menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_NEW, accel_group); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.create = menu_item; menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_DELETE, accel_group); gtk_menu_item_set_accel_path ((GtkMenuItem*) menu_item, UG_APP_GTK_ACCEL_PATH_DELETE); // menu_item = gtk_image_menu_item_new_with_mnemonic (_("_Delete")); // image = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.delete = menu_item; menu_item = gtk_image_menu_item_new_with_mnemonic (_("Delete _File and Data")); gtk_menu_item_set_accel_path ((GtkMenuItem*) menu_item, UG_APP_GTK_ACCEL_PATH_DELETE_F); // image = gtk_image_new_from_stock (GTK_STOCK_DELETE, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.delete_file = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_OPEN, NULL); gtk_menu_item_set_accel_path ((GtkMenuItem*) menu_item, UG_APP_GTK_ACCEL_PATH_OPEN); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.open = menu_item; gtk_widget_hide (menu_item); menu_item = gtk_image_menu_item_new_with_mnemonic(_("Open _containing folder")); gtk_menu_item_set_accel_path ((GtkMenuItem*) menu_item, UG_APP_GTK_ACCEL_PATH_OPEN_F); image = gtk_image_new_from_stock (GTK_STOCK_DIRECTORY, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.open_folder = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); menu_item = gtk_image_menu_item_new_with_mnemonic(_("Force Start")); // image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.force_start = menu_item; menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Runnable")); image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PLAY, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.runnable = menu_item; menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_MEDIA_PAUSE, NULL); // menu_item = gtk_image_menu_item_new_with_mnemonic(_("P_ause")); // image = gtk_image_new_from_stock (GTK_STOCK_MEDIA_PAUSE, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.pause = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); // Move to --- start --- menu_item = gtk_image_menu_item_new_with_mnemonic(_("_Move To")); image = gtk_image_new_from_stock (GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.move_to.item = menu_item; // Move to - submenu sub_menu = gtk_menu_new (); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, sub_menu); menubar->download.move_to.self = sub_menu; menubar->download.move_to.array = g_ptr_array_sized_new (16*2); // Move to --- end --- gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GO_UP, NULL); // menu_item = gtk_image_menu_item_new_with_mnemonic(_("Move _Up")); // image = gtk_image_new_from_stock (GTK_STOCK_GO_UP, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.move_up = menu_item; menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GO_DOWN, NULL); // menu_item = gtk_image_menu_item_new_with_mnemonic(_("Move _Down")); // image = gtk_image_new_from_stock (GTK_STOCK_GO_DOWN, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.move_down = menu_item; menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GOTO_TOP, NULL); // menu_item = gtk_image_menu_item_new_with_mnemonic(_("Move _Top")); // image = gtk_image_new_from_stock (GTK_STOCK_GOTO_TOP, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.move_top = menu_item; menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_GOTO_BOTTOM, NULL); // menu_item = gtk_image_menu_item_new_with_mnemonic(_("Move _Bottom")); // image = gtk_image_new_from_stock (GTK_STOCK_GOTO_BOTTOM, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.move_bottom = menu_item; gtk_menu_shell_append ((GtkMenuShell*)menu, gtk_separator_menu_item_new() ); menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_PROPERTIES, NULL); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->download.properties = menu_item; // ---------------------------------------------------- // UgHelpMenu menu = gtk_menu_new (); menu_item = gtk_menu_item_new_with_mnemonic(_("_Help")); gtk_menu_item_set_submenu ((GtkMenuItem*)menu_item, menu); gtk_menu_shell_append ((GtkMenuShell*)menubar->self, menu_item); // Get Help Online menu_item = gtk_image_menu_item_new_with_mnemonic(_("Get Help Online")); image = gtk_image_new_from_stock (GTK_STOCK_HELP, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.help_online = menu_item; // Documentation menu_item = gtk_image_menu_item_new_with_mnemonic(_("Documentation")); image = gtk_image_new_from_stock (GTK_STOCK_FILE, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.documentation = menu_item; // Support Forum menu_item = gtk_image_menu_item_new_with_mnemonic(_("Support Forum")); image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.support_forum = menu_item; // Submit Feedback menu_item = gtk_image_menu_item_new_with_mnemonic(_("Submit Feedback")); image = gtk_image_new_from_stock (GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.submit_feedback = menu_item; // Report a Bug menu_item = gtk_image_menu_item_new_with_mnemonic(_("Report a Bug")); image = gtk_image_new_from_stock (GTK_STOCK_CAPS_LOCK_WARNING, GTK_ICON_SIZE_MENU); gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.report_bug = menu_item; // Check for Updates menu_item = gtk_image_menu_item_new_with_mnemonic(_("Check for Updates")); // image = gtk_image_new_from_stock (GTK_STOCK_DND_MULTIPLE, GTK_ICON_SIZE_MENU); // gtk_image_menu_item_set_image ((GtkImageMenuItem*)menu_item, image); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.check_updates = menu_item; // About Uget menu_item = gtk_image_menu_item_new_from_stock (GTK_STOCK_ABOUT, NULL); gtk_menu_shell_append ((GtkMenuShell*)menu, menu_item); menubar->help.about_uget = menu_item; } uget-1.10.4/uget-gtk/UgDownloadWidget.h0000664000175000017500000001003112260761064014572 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_DOWNLOAD_WIDGET_H #define UG_DOWNLOAD_WIDGET_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgDownloadWidget UgDownloadWidget; // ---------------------------------------------------------------------------- // UgDownloadWidget // struct UgDownloadWidget { GtkWidget* self; // (GtkScrolledWindow) container widget for view GtkTreeView* view; GtkTreeModel* model; // GtkTreeModelFilter or GtkTreeModelSort struct { gint nth; // enum UgDownloadViewColumn GtkSortType order; } sort; gboolean signal_connected; guint changed_count; // sync with UgDownloadColumnSetting.changed_count }; void ug_download_widget_init (UgDownloadWidget* dwidget, GtkTreeModel* model); void ug_download_widget_finalize (UgDownloadWidget* dwidget); void ug_download_widget_set_filter (UgDownloadWidget* dwidget, GtkTreeModel* model, GtkTreeModelFilterVisibleFunc func, gpointer data); void ug_download_widget_use_sortable (UgDownloadWidget* dwidget, GtkTreeModel* model); // (UgDataset*) list->data GList* ug_download_widget_get_selected (UgDownloadWidget* dwidget); // GPOINTER_TO_INT (link->data) GList* ug_download_widget_get_selected_indices (UgDownloadWidget* dwidget); gint ug_download_widget_count_selected (UgDownloadWidget* dwidget); UgDataset* ug_download_widget_get_cursor (UgDownloadWidget* dwidget); // ---------------------------------------------------------------------------- // GtkTreeView for UgDataset // GtkTreeViewColumn* column; // column = gtk_tree_view_get_column (tree_view, UG_DOWNLOAD_COLUMN_NAME); // gtk_tree_view_column_set_visible (column, TRUE); enum UgDownloadViewColumn { UG_DOWNLOAD_COLUMN_NAME, UG_DOWNLOAD_COLUMN_COMPLETE, UG_DOWNLOAD_COLUMN_SIZE, UG_DOWNLOAD_COLUMN_PERCENT, UG_DOWNLOAD_COLUMN_ELAPSED, // consuming time UG_DOWNLOAD_COLUMN_LEFT, // remaining time UG_DOWNLOAD_COLUMN_SPEED, UG_DOWNLOAD_COLUMN_UPLOAD_SPEED,// torrent UG_DOWNLOAD_COLUMN_UPLOADED, // torrent UG_DOWNLOAD_COLUMN_RATIO, // torrent UG_DOWNLOAD_COLUMN_RETRY, UG_DOWNLOAD_COLUMN_CATEGORY, // category name UG_DOWNLOAD_COLUMN_URL, UG_DOWNLOAD_COLUMN_ADDED_ON, UG_DOWNLOAD_COLUMN_COMPLETED_ON, UG_DOWNLOAD_N_COLUMN }; GtkTreeView* ug_download_view_new (void); void ug_download_view_use_all_icon (GtkTreeView* view, gboolean visible_all); void ug_download_view_set_sort_order (GtkTreeView* view, guint nth_column, GtkSortType order); #ifdef __cplusplus } #endif #endif // End of UG_DOWNLOAD_WIDGET_H uget-1.10.4/uget-gtk/UgBatchForm.c0000664000175000017500000003146712260761064013537 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include // static functions static void ug_batch_form_preview_init (struct UgBatchFormPreview* preview); static void ug_batch_form_preview_show (struct UgBatchFormPreview* preview, const gchar* message); // signal handlers static void on_radio1_clicked (GtkWidget* widget, UgBatchForm* bform); static void on_radio2_clicked (GtkWidget* widget, UgBatchForm* bform); void ug_batch_form_init (UgBatchForm* bform) { GtkGrid* grid; GtkWidget* label; GtkWidget* entry; GtkWidget* widget; GtkAdjustment* spin_adj; // top widget bform->self = gtk_grid_new (); grid = (GtkGrid*) bform->self; gtk_grid_set_row_homogeneous (grid, FALSE); // URL entry entry = gtk_entry_new (); label = gtk_label_new_with_mnemonic (_("_URL:")); bform->entry = GTK_ENTRY (entry); gtk_label_set_mnemonic_widget(GTK_LABEL (label), entry); gtk_entry_set_activates_default (bform->entry, TRUE); g_object_set (label, "margin", 3, NULL); g_object_set (entry, "margin", 3, "hexpand", TRUE, NULL); gtk_grid_attach (grid, label, 0, 0, 1, 1); gtk_grid_attach (grid, entry, 1, 0, 5, 1); g_signal_connect_swapped (GTK_EDITABLE (entry), "changed", G_CALLBACK (ug_batch_form_update_preview), bform); // e.g. label = gtk_label_new (_("e.g.")); g_object_set (label, "margin", 3, NULL); gtk_grid_attach (grid, label, 0, 1, 1, 1); label = gtk_label_new ("http://for.example/path/pre*.jpg"); g_object_set (label, "margin", 3, NULL); gtk_grid_attach (grid, label, 1, 1, 5, 1); widget = gtk_separator_new (GTK_ORIENTATION_HORIZONTAL); gtk_grid_attach (grid, widget, 0, 2, 6, 1); // ------------------------------------------------------- // radio "From" bform->radio = gtk_radio_button_new_with_mnemonic (NULL, _("_From:")); g_object_set (bform->radio, "margin", 3, NULL); gtk_grid_attach (grid, bform->radio, 0, 3, 1, 1); g_signal_connect (bform->radio, "clicked", G_CALLBACK (on_radio1_clicked), bform); // spin "From" spin_adj = (GtkAdjustment *) gtk_adjustment_new (0.0, 0.0, 99999.0, 1.0, 5.0, 0.0); bform->spin_from = gtk_spin_button_new (spin_adj, 1.0, 0); g_object_set (bform->spin_from, "margin", 3, "hexpand", TRUE, NULL); gtk_grid_attach (grid, bform->spin_from, 1, 3, 1, 1); g_signal_connect_swapped (bform->spin_from, "value-changed", G_CALLBACK (ug_batch_form_update_preview), bform); // spin "To" spin_adj = (GtkAdjustment *) gtk_adjustment_new (10.0, 1.0, 99999.0, 1.0, 5.0, 0.0); bform->spin_to = gtk_spin_button_new (spin_adj, 1.0, 0); g_object_set (bform->spin_to, "margin", 3, "hexpand", TRUE, NULL); gtk_grid_attach (grid, bform->spin_to, 3, 3, 1, 1); g_signal_connect_swapped (bform->spin_to, "value-changed", G_CALLBACK (ug_batch_form_update_preview), bform); // label "To" label = gtk_label_new_with_mnemonic (_("To:")); g_object_set (label, "margin", 3, NULL); gtk_grid_attach (grid, label, 2, 3, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), bform->spin_to); bform->label_to = label; // spin "digits" spin_adj = (GtkAdjustment *) gtk_adjustment_new (2.0, 1.0, 20.0, 1.0, 5.0, 0.0); bform->spin_digits = gtk_spin_button_new (spin_adj, 1.0, 0); g_object_set (bform->spin_digits, "margin", 3, "hexpand", TRUE, NULL); gtk_grid_attach (grid, bform->spin_digits, 5, 3, 1, 1); g_signal_connect_swapped (bform->spin_digits, "value-changed", G_CALLBACK (ug_batch_form_update_preview), bform); // label "digits" label = gtk_label_new_with_mnemonic (_("digits:")); g_object_set (label, "margin", 3, NULL); gtk_grid_attach (grid, label, 4, 3, 1, 1); gtk_label_set_mnemonic_widget (GTK_LABEL (label), bform->spin_digits); bform->label_digits = label; // ------------------------------------------------------- // radio "From" bform->radio = gtk_radio_button_new_with_mnemonic_from_widget ( GTK_RADIO_BUTTON (bform->radio), _("F_rom:")); g_object_set (bform->radio, "margin", 3, NULL); gtk_grid_attach (grid, bform->radio, 0, 4, 1, 1); g_signal_connect (bform->radio, "clicked", G_CALLBACK (on_radio2_clicked), bform); // entry "From" entry = gtk_entry_new (); bform->entry_from = GTK_ENTRY (entry); gtk_entry_set_text (bform->entry_from, "a"); gtk_entry_set_max_length (bform->entry_from, 1); gtk_entry_set_width_chars (bform->entry_from, 2); gtk_widget_set_sensitive (entry, FALSE); g_object_set (entry, "margin", 3, "hexpand", TRUE, NULL); gtk_grid_attach (grid, entry, 1, 4, 1, 1); g_signal_connect_swapped (GTK_EDITABLE (entry), "changed", G_CALLBACK (ug_batch_form_update_preview), bform); // entry "To" entry = gtk_entry_new (); bform->entry_to = GTK_ENTRY (entry); gtk_entry_set_text (bform->entry_to, "z"); gtk_entry_set_max_length (bform->entry_to, 1); gtk_entry_set_width_chars (bform->entry_to, 2); gtk_widget_set_sensitive (entry, FALSE); g_object_set (entry, "margin", 3, "hexpand", TRUE, NULL); gtk_grid_attach (grid, entry, 3, 4, 1, 1); g_signal_connect_swapped (GTK_EDITABLE (bform->entry_to), "changed", G_CALLBACK(ug_batch_form_update_preview), bform); // label case-sensitive label = gtk_label_new (_("case-sensitive")); gtk_widget_set_sensitive (label, FALSE); g_object_set (label, "margin", 3, NULL); gtk_grid_attach (grid, label, 4, 4, 2, 1); bform->label_case = label; // ------------------------------------------------------- // preview ug_batch_form_preview_init (&bform->preview); g_object_set (bform->preview.self, "margin", 3, "expand", TRUE, NULL); gtk_grid_attach (grid, bform->preview.self, 0, 7, 6, 1); ug_batch_form_update_preview (bform); gtk_widget_show_all (bform->self); } void ug_batch_form_update_preview (UgBatchForm* bform) { GtkTreeIter iter; GList* list; GList* link; list = ug_batch_form_get_list (bform, TRUE); if (list == NULL) { if (bform->preview.status == 1) { ug_batch_form_preview_show (&bform->preview, _("No wildcard(*) character in URL entry.")); } else if (bform->preview.status == 2) { ug_batch_form_preview_show (&bform->preview, _("URL is not valid.")); } else if (bform->preview.status == 3) { ug_batch_form_preview_show (&bform->preview, _("No character in 'From' or 'To' entry.")); } // notify if (bform->notify.func) bform->notify.func (bform->notify.data, FALSE); return; } gtk_list_store_clear (bform->preview.store); for (link = list; link; link = link->next) { gtk_list_store_append (bform->preview.store, &iter); gtk_list_store_set (bform->preview.store, &iter, 0, link->data, -1); } g_list_foreach (list, (GFunc) g_free, NULL); g_list_free (list); // notify if (bform->notify.func) bform->notify.func (bform->notify.data, TRUE); return; } GList* ug_batch_form_get_list (UgBatchForm* bform, gboolean preview) { GString* gstr; GList* list; gint from, to, cur, digits; gboolean char_mode; const gchar* string; gint offset; string = gtk_entry_get_text (bform->entry); offset = strcspn (string, "*"); if (string [offset] == 0) { bform->preview.status = 1; return NULL; } if (ug_uri_scheme_len (string) == 0) { bform->preview.status = 2; return NULL; } // char or digit char_mode = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (bform->radio)); if (char_mode) { // char from = *gtk_entry_get_text (bform->entry_from); to = *gtk_entry_get_text (bform->entry_to); digits = 1; if (from == 0 || to == 0) { bform->preview.status = 3; return NULL; } } else { // digit from = gtk_spin_button_get_value_as_int ((GtkSpinButton*) bform->spin_from); to = gtk_spin_button_get_value_as_int ((GtkSpinButton*) bform->spin_to); digits = gtk_spin_button_get_value_as_int ((GtkSpinButton*) bform->spin_digits); } // swap from & to if (from > to) { cur = from; from = to; to = cur; } // create URI list list = NULL; gstr = g_string_sized_new (80); g_string_append_len (gstr, string, offset); for (cur = to; cur >= from; cur--) { if (preview && from < to -4 && cur == to -2) { list = g_list_prepend (list, g_strdup (" ...")); cur = from + 1; } if (char_mode) g_string_append_printf (gstr, "%c", cur); else g_string_append_printf (gstr, "%.*d", digits, cur); g_string_append (gstr, string + offset + 1); list = g_list_prepend (list, g_strdup (gstr->str)); g_string_truncate (gstr, offset); } g_string_free (gstr, TRUE); bform->preview.status = 0; return list; } // ---------------------------------------------------------------------------- // static functions // static void ug_batch_form_preview_init (struct UgBatchFormPreview* preview) { GtkScrolledWindow* scrolled; GtkCellRenderer* renderer; GtkTreeViewColumn* column; GtkTreeSelection* selection; preview->view = (GtkTreeView*) gtk_tree_view_new (); preview->store = gtk_list_store_new (1, G_TYPE_STRING); gtk_tree_view_set_model (preview->view, (GtkTreeModel*) preview->store); // gtk_tree_view_set_fixed_height_mode (preview->view, TRUE); gtk_widget_set_size_request ((GtkWidget*) preview->view, 140, 140); selection = gtk_tree_view_get_selection (preview->view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_NONE); // It will free UgBatchForm.preview_store when UgBatchForm.preview_view destroy. g_object_unref (preview->store); renderer = gtk_cell_renderer_text_new (); column = gtk_tree_view_column_new_with_attributes ( _("Preview"), renderer, "text", 0, NULL); // gtk_tree_view_column_set_sizing (column, GTK_TREE_VIEW_COLUMN_FIXED); gtk_tree_view_append_column (preview->view, column); preview->self = gtk_scrolled_window_new (NULL, NULL); scrolled = GTK_SCROLLED_WINDOW (preview->self); gtk_scrolled_window_set_shadow_type (scrolled, GTK_SHADOW_IN); gtk_scrolled_window_set_policy (scrolled, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_container_add (GTK_CONTAINER (scrolled), GTK_WIDGET (preview->view)); } static void ug_batch_form_preview_show (struct UgBatchFormPreview* preview, const gchar* message) { GtkTreeIter iter; gtk_list_store_clear (preview->store); // skip first row gtk_list_store_append (preview->store, &iter); // show message in second row gtk_list_store_append (preview->store, &iter); gtk_list_store_set (preview->store, &iter, 0, message, -1); } // ---------------------------------------------------------------------------- // signal handler // static void on_radio1_clicked (GtkWidget* widget, UgBatchForm* bform) { // digit gtk_widget_set_sensitive (bform->spin_from, TRUE); gtk_widget_set_sensitive (bform->spin_to, TRUE); gtk_widget_set_sensitive (bform->spin_digits, TRUE); gtk_widget_set_sensitive (bform->label_to, TRUE); gtk_widget_set_sensitive (bform->label_digits, TRUE); // character gtk_widget_set_sensitive (GTK_WIDGET (bform->entry_from), FALSE); gtk_widget_set_sensitive (GTK_WIDGET (bform->entry_to), FALSE); gtk_widget_set_sensitive (bform->label_case, FALSE); ug_batch_form_update_preview (bform); } static void on_radio2_clicked (GtkWidget* widget, UgBatchForm* bform) { // digit gtk_widget_set_sensitive (bform->spin_from, FALSE); gtk_widget_set_sensitive (bform->spin_to, FALSE); gtk_widget_set_sensitive (bform->spin_digits, FALSE); gtk_widget_set_sensitive (bform->label_to, FALSE); gtk_widget_set_sensitive (bform->label_digits, FALSE); // character gtk_widget_set_sensitive (GTK_WIDGET (bform->entry_from), TRUE); gtk_widget_set_sensitive (GTK_WIDGET (bform->entry_to), TRUE); gtk_widget_set_sensitive (bform->label_case, TRUE); ug_batch_form_update_preview (bform); } uget-1.10.4/AUTHORS0000664000175000017500000000046711740440107010541 00000000000000uGet - A download manager with GUI. ============================================= Active Developer: ------------------ C.H. Huang(plushuang.tw@gmail.com) - Maintainer Artists: -------- Michael Tunnell - Logo Designer saf1 (linuxac.org) - Former Logo Designer Skeleton_Eel (linuxac.org) - Former Logo improver uget-1.10.4/configure.ac0000664000175000017500000001323112260757050011756 00000000000000AC_PREREQ([2.60]) AC_INIT([uget],[1.10.4]) ## Use automake (add automake to autogen.sh) AM_INIT_AUTOMAKE ## Use config.h (add autoheader to autogen.sh) AC_CONFIG_HEADERS([config.h]) ## Enable platform related extensions AC_USE_SYSTEM_EXTENSIONS ## Determine a C compiler to use. AC_PROG_CC ## Check C compiler -c -o options. AM_PROG_CC_C_O ## Use library (static library) AC_PROG_RANLIB ## Use libtool (share and static library) (add libtoolize to autogen.sh) # AC_PROG_LIBTOOL # LT_PREREQ([2.2.6]) # LT_INIT ## ---------------------------------------------- ## L10N (add intltoolize to autogen.sh) AC_PROG_INTLTOOL ## replace ALL_LINGUAS with po/LINGUAS # ALL_LINGUAS="" GETTEXT_PACKAGE="$PACKAGE" AC_SUBST(GETTEXT_PACKAGE) AM_GLIB_GNU_GETTEXT AM_GLIB_DEFINE_LOCALEDIR(LOCALEDIR) ## Use AM_GLIB_DEFINE_LOCALEDIR with AC_CONFIG_HEADERS ## ---------------------------------------------- ## GTK+ related PKG_CHECK_MODULES(GTK, gtk+-3.0 >= 3.4) PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.32) PKG_CHECK_MODULES(GTHREAD, gthread-2.0) PKG_CHECK_MODULES(GMODULE, gmodule-2.0) PKG_CHECK_MODULES(GIO, gio-2.0) ## ---------------- ## libnotify AC_ARG_ENABLE( [notify], AC_HELP_STRING([--disable-notify], [Disable libnotify support.]), [enable_notify="$enableval"], [enable_notify="yes"] ) if test "x$enable_notify" = "xyes"; then PKG_CHECK_MODULES(LIBNOTIFY, libnotify) AC_DEFINE(HAVE_LIBNOTIFY, 1, [Define to 1 if libnotify support is required.]) # for ArchLinux AC_SUBST(LIBNOTIFY_CFLAGS) AC_SUBST(LIBNOTIFY_LIBS) fi ## ---------------- ## appindicator AC_ARG_ENABLE( [appindicator], AS_HELP_STRING([--enable-appindicator[=@<:@no/auto/yes@:>@]],[Build support for application indicators.]), [enable_appindicator=$enableval], [enable_appindicator="auto"] ) if test x$enable_appindicator = xauto ; then PKG_CHECK_EXISTS([appindicator3-0.1], [enable_appindicator="yes"], [enable_appindicator="no"]) fi if test x$enable_appindicator = xyes ; then PKG_CHECK_MODULES(APP_INDICATOR, appindicator3-0.1) AC_SUBST(APP_INDICATOR_CFLAGS) AC_SUBST(APP_INDICATOR_LIBS) AC_DEFINE(HAVE_APP_INDICATOR, 1, [Have AppIndicator]) fi AM_CONDITIONAL(HAVE_APP_INDICATOR, test x"$enable_appindicator" = xyes) ## ---------------- ## gstreamer AC_ARG_ENABLE( [gstreamer], AC_HELP_STRING([--disable-gstreamer], [Disable GStreamer audio support.]), [enable_gstreamer="$enableval"], [enable_gstreamer="yes"] ) if test "x$enable_gstreamer" = "xyes"; then PKG_CHECK_EXISTS([gstreamer-1.0], [enable_gstreamer1="yes"], [enable_gstreamer1="no"]) fi if test "x$enable_gstreamer1" = "xyes"; then PKG_CHECK_MODULES(GSTREAMER, gstreamer-1.0) AC_DEFINE(HAVE_GSTREAMER, 1, [Define to 1 if gstreamer support is required.]) # for ArchLinux AC_SUBST(GSTREAMER_CFLAGS) AC_SUBST(GSTREAMER_LIBS) elif test "x$enable_gstreamer" = "xyes"; then PKG_CHECK_MODULES(GSTREAMER, gstreamer-0.10) AC_DEFINE(HAVE_GSTREAMER, 1, [Define to 1 if gstreamer support is required.]) # for ArchLinux AC_SUBST(GSTREAMER_CFLAGS) AC_SUBST(GSTREAMER_LIBS) fi ## ---------------- ## LFS AC_PATH_PROG(GETCONF, getconf) if test "x$GETCONF" != "x" ; then LFS_CFLAGS=`$GETCONF LFS_CFLAGS` LFS_LDFLAGS=`$GETCONF LFS_LDFLAGS` fi AC_SUBST(LFS_CFLAGS) AC_SUBST(LFS_LDFLAGS) ## ---------------- ## cURL AC_PATH_PROG(CURL_CONFIG, curl-config) if test "x$CURL_CONFIG" = "x" ; then AC_MSG_ERROR(Unable to find curl-config, please install libcurl) fi CURL_CFLAGS=`$CURL_CONFIG --cflags` CURL_LIBS=`$CURL_CONFIG --libs` let CURL_VERNUM=0x0`$CURL_CONFIG --vernum` let CURL_VERMIN=0x071301 # 7.19.1 if test $CURL_VERNUM -lt $CURL_VERMIN; then AC_MSG_ERROR(Requires libcurl version >= 7.19.1) fi AC_SUBST(CURL_CFLAGS) AC_SUBST(CURL_LIBS) ## ---------------- ## cURL plug-in AC_ARG_ENABLE( [plugin-curl], AC_HELP_STRING([--disable-plugin-curl], [Disable cURL plug-in.]), [plugin_curl="$enableval"], [plugin_curl="yes"] ) if test "x$plugin_curl" = "xyes"; then AC_DEFINE(HAVE_PLUGIN_CURL, 1, [Define to 1 to enable cURL plug-in.]) fi ## ---------------- ## GnuTLS AC_ARG_ENABLE( [gnutls], AC_HELP_STRING([--enable-gnutls], [Enable GnuTLS support.]), [enable_gnutls="$enableval"], [enable_gnutls="no"] ) if test "x$enable_gnutls" = "xyes"; then PKG_CHECK_MODULES(GNUTLS, gnutls) AC_DEFINE(HAVE_GNUTLS, 1, [Define to 1 if gnutls support is required.]) # for ArchLinux AC_SUBST(GNUTLS_CFLAGS) AC_SUBST(GNUTLS_LIBS) fi ## ----------------- ## aria2 plug-in AC_ARG_ENABLE( [plugin-aria2], AC_HELP_STRING([--disable-plugin-aria2], [Disable aria2 plug-in.]), [plugin_aria2="$enableval"], [plugin_aria2="yes"] ) if test "x$plugin_aria2" = "xyes"; then AC_DEFINE(HAVE_PLUGIN_ARIA2, 1, [Define to 1 to enable aria2 plug-in.]) fi ## ----------------- ## libpwmd AC_ARG_ENABLE( [pwmd], AC_HELP_STRING([--enable-pwmd], [Enable pwmd support.]), [enable_pwmd="$enableval"], [enable_pwmd="no"] ) if test "x$enable_pwmd" = "xyes"; then PKG_CHECK_MODULES(LIBPWMD, [libpwmd-7.0 >= 7.0.0]) AC_DEFINE(HAVE_LIBPWMD, 1, [Define to 1 if libpwmd support is required.]) fi AM_CONDITIONAL([WITH_LIBPWMD], [test "x$enable_pwmd" = "xyes"]) ## ----------------- ## HIDE_TEMPORARY_FILE AC_ARG_ENABLE( [hidden], AC_HELP_STRING([--enable-hidden], [Make temporary files hidden.]), [hide_tempfiles="$enableval"], [hide_tempfiles="no"] ) if test "x$hide_tempfiles" = "xyes"; then AC_DEFINE(HIDE_TEMPORARY_FILE, 1, [Define to 1 to make temporary download files hidden.]) fi ## ---------------------------------------------- ## output AC_CONFIG_FILES([ Makefile uglib/Makefile uget-gtk/Makefile uget-cmd/Makefile tests/Makefile pixmaps/Makefile sounds/Makefile po/Makefile.in Windows/Makefile ]) AC_OUTPUT uget-1.10.4/uglib/0000775000175000017500000000000012260772030010645 500000000000000uget-1.10.4/uglib/UgCategory.h0000664000175000017500000001666112260761064013026 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_CATEGORY_H #define UG_CATEGORY_H #include #include #ifdef __cplusplus extern "C" { #endif // interface address for UgDataset #define UgetRelationInfo uget_relation_iface_pointer typedef struct UgCategory UgCategory; typedef struct UgCategoryFuncs UgCategoryFuncs; typedef enum UgCategoryHints UgCategoryHints; typedef struct UgetRelation UgetRelation; typedef void (*UgCategoryAddFunc) (UgCategory* category, UgDataset* dataset); typedef GList* (*UgCategoryGetAllFunc) (UgCategory* category); typedef GList* (*UgCategoryGetTasksFunc)(UgCategory* category); typedef void (*UgCategoryChangedFunc) (UgCategory* category, UgDataset* dataset); extern const UgDataInterface ug_category_iface; extern const UgDataInterface uget_relation_iface; extern const UgDataInterface* ug_category_iface_pointer; extern const UgDataInterface* uget_relation_iface_pointer; // ---------------------------------------------------------------------------- // UgCategory // UgData // | // `- UgCategory struct UgCategory { const UgDataInterface* iface; // for UgMarkup parse/write const UgCategoryFuncs* funcs; // functions gchar* name; // limit guint active_limit; guint finished_limit; // finished: completed and paused guint recycled_limit; // default setting of UgDataset UgDataset* defaults; // used when program save/load file GList* indices; // call destroy.func(destroy.data) when destroying. struct { UgNotifyFunc func; gpointer data; } destroy; // used by user application struct { gpointer category; gpointer storage; gpointer position; gpointer data; } user; }; struct UgCategoryFuncs { UgCategoryAddFunc add; // used by ug_category_list_link() UgCategoryGetAllFunc get_all; // used by ug_category_list_save() UgCategoryGetTasksFunc get_tasks; // used to get runnable tasks UgCategoryChangedFunc changed; // notify category that it's dataset was changed. }; UgCategory* ug_category_new (void); void ug_category_free (UgCategory* category); void ug_category_init (UgCategory* category); void ug_category_finalize (UgCategory* category); // add dataset to category and increase reference count of dataset. void ug_category_add (UgCategory* category, UgDataset* dataset); // get all tasks(UgDataset) in this category. // To free the returned value, use g_list_free (list). GList* ug_category_get_all (UgCategory* category); // get queuing tasks(UgDataset) in this category. // This function should be noticed UgCategory::active_limit, because // application will try to activate all returned dataset. // To free the returned value, use g_list_free (list). GList* ug_category_get_tasks (UgCategory* category); // used to notify category that it's dataset was changed. // It may change hints and switch dataset to another internal queue of category. void ug_category_changed (UgCategory* category, UgDataset* dataset); // ------------------------------------ // UgCategoryHints enum UgCategoryHints { // UG_HINT_QUEUING = 1 << 0, UG_HINT_PAUSED = 1 << 1, UG_HINT_DOWNLOADING = 1 << 2, UG_HINT_ERROR = 1 << 3, UG_HINT_COMPLETED = 1 << 4, // Download completed only UG_HINT_UPLOADING = 1 << 5, // reserved UG_HINT_FINISHED = 1 << 6, // Download completed, uget will not use it in future. UG_HINT_RECYCLED = 1 << 7, // Download will be deleted. UG_HINT_ACTIVE = UG_HINT_DOWNLOADING | UG_HINT_UPLOADING, UG_HINT_INACTIVE = UG_HINT_PAUSED | UG_HINT_ERROR, UG_HINT_UNRUNNABLE = UG_HINT_PAUSED | UG_HINT_ERROR | UG_HINT_FINISHED | UG_HINT_RECYCLED, }; // ---------------------------------------------------------------------------- // CategoryList // Before calling ug_category_list_load(), user must register data interface of UgCategory. // Before calling ug_category_list_save(), user must call ug_download_list_save() to save all download in all category. GList* ug_category_list_load (const gchar* filename); gboolean ug_category_list_save (GList* category_list, const gchar* filename); void ug_category_list_link (GList* category_list, GList* download_list); // ---------------------------------------------------------------------------- // DownloadList // ug_download_list_load() load file and return list of newly-created UgDataset. // To free the return value, use: // g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); // g_list_free (list); // Before calling ug_download_list_load(), user must register data interface of UgetRelation. GList* ug_download_list_load (const gchar* filename); gboolean ug_download_list_save (GList* download_list, const gchar* filename); // Below utility functions can be used by g_list_foreach() gboolean ug_download_create_attachment (UgDataset* dataset, gboolean force); gboolean ug_download_assign_attachment (UgDataset* dataset, UgDataset* src); void ug_download_complete_data (UgDataset* dataset); void ug_download_delete_temp (UgDataset* dataset); // ---------------------------------------------------------------------------- // UgetRelation : relation of UgCategory, UgDataset, and UgPlugin. // UgData // | // `- UgDatalist // | // `- UgetRelation struct UgetRelation { UG_DATALIST_MEMBERS (UgetRelation); // const UgDataInterface* iface; // UgetRelation* next; // UgetRelation* prev; // category UgCategoryHints hints; UgCategory* category; // use index when program save/load file. guint index; // attachment struct { gchar* folder; guint stamp; } attached; // plug-in and message were used by UgRunning. UgPlugin* plugin; struct { UgMessageType type; gchar* string; } message; // call destroy.func(destroy.data) when destroying. struct { UgNotifyFunc func; gpointer data; } destroy; // used by user application struct { gpointer category; gpointer storage; gpointer position; gpointer data; } user; }; #ifdef __cplusplus } #endif #endif // UG_CATEGORY_H uget-1.10.4/uglib/UgStdio.c0000664000175000017500000001113312260761064012313 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef _WIN32 #define _CRT_SECURE_NO_DEPRECATE // avoid some warning (MS VC 2005) #include #endif #include #include #ifdef _WIN32 int ug_fd_open (const gchar* filename_utf8, int flags, int mode) { int retval; int save_errno; if (G_WIN32_HAVE_WIDECHAR_API ()) { wchar_t *wfilename = g_utf8_to_utf16 (filename_utf8, -1, NULL, NULL, NULL); if (wfilename == NULL) { errno = EINVAL; return -1; } retval = _wopen (wfilename, flags, mode); save_errno = errno; g_free (wfilename); } else { gchar *cp_filename = g_locale_from_utf8 (filename_utf8, -1, NULL, NULL, NULL); if (cp_filename == NULL) { errno = EINVAL; return -1; } retval = _open (cp_filename, flags, mode); save_errno = errno; g_free (cp_filename); } errno = save_errno; return retval; } int ug_fd_truncate (int fd, gint64 length) { HANDLE h_file; if (ug_fd_seek (fd, length, SEEK_SET) == 0) { h_file = (HANDLE)_get_osfhandle(fd); if (SetEndOfFile (h_file)) return 0; } return -1; } #if !defined(__MINGW32__) FILE* ug_fopen (const gchar *filename, const gchar *mode) { FILE *retval; int save_errno; if (G_WIN32_HAVE_WIDECHAR_API ()) { wchar_t *wfilename = g_utf8_to_utf16 (filename, -1, NULL, NULL, NULL); wchar_t *wmode; if (wfilename == NULL) { errno = EINVAL; return NULL; } wmode = g_utf8_to_utf16 (mode, -1, NULL, NULL, NULL); if (wmode == NULL) { g_free (wfilename); errno = EINVAL; return NULL; } retval = _wfopen (wfilename, wmode); save_errno = errno; g_free (wfilename); g_free (wmode); } else { gchar *cp_filename = g_locale_from_utf8 (filename, -1, NULL, NULL, NULL); if (cp_filename == NULL) { errno = EINVAL; return NULL; } retval = fopen (cp_filename, mode); save_errno = errno; g_free (cp_filename); } errno = save_errno; return retval; } #endif // End of !defined(__MINGW32__) #else // UNIX int ug_fd_open (const gchar* filename_utf8, int flags, int mode) { if (g_get_filename_charsets (NULL)) return g_open (filename_utf8, flags, mode); else { gchar *cp_filename = g_filename_from_utf8 (filename_utf8, -1, NULL, NULL, NULL); int retval; int save_errno; if (cp_filename == NULL) { errno = EINVAL; return -1; } retval = g_open (cp_filename, flags, mode); save_errno = errno; g_free (cp_filename); errno = save_errno; return retval; } } FILE* ug_fopen (const gchar *filename, const gchar *mode) { if (g_get_filename_charsets (NULL)) return g_fopen (filename, mode); else { gchar *cp_filename = g_filename_from_utf8 (filename, -1, NULL, NULL, NULL); FILE *retval; int save_errno; if (cp_filename == NULL) { errno = EINVAL; return NULL; } retval = g_fopen (cp_filename, mode); save_errno = errno; g_free (cp_filename); errno = save_errno; return retval; } } #endif // End of _WIN32 int ug_fs_truncate (FILE* file, gint64 size) { int fd; ug_fs_flush (file); ug_fs_seek (file, size, SEEK_SET); fd = ug_fs_get_fd (file); return ug_fd_truncate (fd, size); } uget-1.10.4/uglib/UgMessage.c0000664000175000017500000002552212260761064012624 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include // uglib #include #include // ---------------------------------------------- // common message string & data // UG_MESSAGE_INFO static const gchar* common_info[] = { NULL, // UG_MESSAGE_INFO_CUSTOM N_("Connecting..."), // UG_MESSAGE_INFO_CONNECT N_("Transmitting..."), // UG_MESSAGE_INFO_TRANSMIT, N_("Retry"), // UG_MESSAGE_INFO_RETRY, N_("Download completed"), // UG_MESSAGE_INFO_COMPLETE, N_("Finished"), // UG_MESSAGE_INFO_FINISH, // resumable N_("Resumable"), // UG_MESSAGE_INFO_RESUMABLE, N_("Not Resumable"), // UG_MESSAGE_INFO_NOT_RESUMABLE, }; static const guint common_info_count = sizeof (common_info) / sizeof (gchar*); // UG_MESSAGE_WARNING static const gchar* common_warning[] = { NULL, // UG_MESSAGE_WARNING_CUSTOM N_("Output file can't be renamed."), // UG_MESSAGE_WARNING_FILE_RENAME_FAILED }; static const guint common_warning_count = sizeof (common_warning) / sizeof (gchar*); // UG_MESSAGE_ERROR static const gchar* common_error[] = { NULL, // UG_MESSAGE_ERROR_CUSTOM N_("couldn't connect to host."), // UG_MESSAGE_ERROR_CONNECT_FAILED N_("Folder can't be created."), // UG_MESSAGE_ERROR_FOLDER_CREATE_FAILED N_("File can't be created (bad filename or file exist)."), // UG_MESSAGE_ERROR_FILE_CREATE_FAILED N_("File can't be opened."), // UG_MESSAGE_ERROR_FILE_OPEN_FAILED N_("Unable to create thread, reduce number of download."), // UG_MESSAGE_ERROR_THREAD_CREATE_FAILED N_("Out of resource (disk full or run out of memory)."), // UG_MESSAGE_ERROR_OUT_OF_RESOURCE N_("No output file."), // UG_MESSAGE_ERROR_NO_OUTPUT_FILE N_("No output setting."), // UG_MESSAGE_ERROR_NO_OUTPUT_SETTING N_("Too many retries."), // UG_MESSAGE_ERROR_TOO_MANY_RETRIES N_("Unsupported scheme (protocol)."), // UG_MESSAGE_ERROR_UNSUPPORTED_SCHEME N_("Unsupported file."), // UG_MESSAGE_ERROR_UNSUPPORTED_FILE }; static const guint common_error_count = sizeof (common_error) / sizeof (gchar*); // UG_MESSAGE_DATA static guint common_data[] = { UG_TYPE_STRING, // UG_MESSAGE_DATA_FILE_CHANGED // filename UG_TYPE_STRING, // UG_MESSAGE_DATA_URL_CHANGED // URL }; static guint common_data_count = sizeof (common_data) / sizeof (guint); // ---------------------------------------------- // HTTP message string static const gchar* http_error[] = { NULL, // UG_MESSAGE_ERROR_HTTP_MEMBER_CUSTOM N_("Too many redirections."), // UG_MESSAGE_ERROR_HTTP_MEMBER_TOO_MANY_REDIRECTIONS N_("Failed to open posted file."), // UG_MESSAGE_ERROR_HTTP_MEMBER_OPEN_POSTED_FILE_FAILED }; static const guint http_error_count = sizeof (http_error) / sizeof (gchar*); // UG_MESSAGE_DATA static guint http_data[] = { UG_TYPE_STRING, // UG_MESSAGE_DATA_HTTP_MEMBER_LOCATION == UG_MESSAGE_DATA_HTTP_MEMBER_REDIRECTION UG_TYPE_STRING, // UG_MESSAGE_DATA_HTTP_MEMBER_CONTENT_LOCATION UG_TYPE_STRING, // UG_MESSAGE_DATA_HTTP_MEMBER_CONTENT_DISPOSITION }; static guint http_data_count = sizeof (http_data) / sizeof (guint); // ---------------------------------------------------------------------------- // UgMessage static void ug_message_finalize (UgMessage* message); static void ug_message_assign (UgMessage* message, UgMessage* src); static const UgDataEntry ug_message_entry[] = { {"type", G_STRUCT_OFFSET (UgMessage, type), UG_TYPE_UINT, NULL, NULL}, {"code", G_STRUCT_OFFSET (UgMessage, code), UG_TYPE_UINT, NULL, NULL}, {"string", G_STRUCT_OFFSET (UgMessage, string), UG_TYPE_STRING, NULL, NULL}, {NULL}, // null-terminated }; // extern const UgDataInterface ug_message_iface = { sizeof (UgMessage), // instance_size "message", // name ug_message_entry, // entry (UgInitFunc) NULL, (UgFinalizeFunc) ug_message_finalize, (UgAssignFunc) ug_message_assign, }; static void ug_message_finalize (UgMessage* message) { g_free (message->string); if (message->data_type == UG_TYPE_STRING) g_free (message->data.v_string); else if (message->data_type == UG_TYPE_INSTANCE) ug_data_free (message->data.v_instance); } static void ug_message_assign (UgMessage* message, UgMessage* src) { message->type = src->type; message->code = src->code; if (src->string) message->string = src->string; else message->string = NULL; message->data_type = src->data_type; if (src->data_type == UG_TYPE_STRING) message->data.v_string = g_strdup (src->data.v_string); else if (src->data_type == UG_TYPE_INSTANCE) message->data.v_instance = ug_data_copy (src->data.v_instance); else message->data = src->data; } UgMessage* ug_message_new (UgMessageType type) { UgMessage* message; message = ug_data_new (&ug_message_iface); message->type = type; return message; } UgMessage* ug_message_new_state (gint state) { UgMessage* message; message = ug_message_new (UG_MESSAGE_STATE); message->data_type = UG_TYPE_INT; message->data.v_int = state; return message; } UgMessage* ug_message_new_progress (void) { return ug_message_new (UG_MESSAGE_PROGRESS); } UgMessage* ug_message_new_info (guint info_code, const gchar* string) { UgMessage* message; guint message_domain; guint message_member; const gchar* native_string; message = ug_data_new (&ug_message_iface); message->type = UG_MESSAGE_INFO; message->code = info_code; // use native or user string if (string) { message->string = g_strdup (string); return message; } // get native string by info_code native_string = NULL; message_domain = UG_MESSAGE_CODE_DOMAIN (info_code); message_member = UG_MESSAGE_CODE_MEMBER (info_code); switch (message_domain) { case UG_MESSAGE_DOMAIN_COMMON: if (message_member < common_info_count) native_string = common_info [message_member]; break; default: break; } if (native_string) message->string = g_strdup (gettext (native_string)); return message; } UgMessage* ug_message_new_warning (guint warning_code, const gchar* string) { UgMessage* message; guint message_domain; guint message_member; const gchar* native_string; message = ug_data_new (&ug_message_iface); message->type = UG_MESSAGE_WARNING; message->code = warning_code; // use native or user string if (string) { message->string = g_strdup (string); return message; } // get native string by warning_code native_string = NULL; message_domain = UG_MESSAGE_CODE_DOMAIN (warning_code); message_member = UG_MESSAGE_CODE_MEMBER (warning_code); switch (message_domain) { case UG_MESSAGE_DOMAIN_COMMON: if (message_member < common_warning_count) native_string = common_warning [message_member]; break; default: break; } if (native_string) message->string = g_strdup (gettext (native_string)); return message; } UgMessage* ug_message_new_error (guint error_code, const gchar* string) { UgMessage* message; guint message_domain; guint message_member; const gchar* native_string; message = ug_data_new (&ug_message_iface); message->type = UG_MESSAGE_ERROR; message->code = error_code; // use native or user string if (string) { message->string = g_strdup (string); return message; } // get native string by error_code native_string = NULL; message_domain = UG_MESSAGE_CODE_DOMAIN (error_code); message_member = UG_MESSAGE_CODE_MEMBER (error_code); switch (message_domain) { case UG_MESSAGE_DOMAIN_COMMON: if (message_member < common_error_count) native_string = common_error [message_member]; break; case UG_MESSAGE_DOMAIN_HTTP: if (message_member < http_error_count) native_string = http_error [message_member]; break; default: break; } if (native_string) message->string = g_strdup (gettext (native_string)); return message; } UgMessage* ug_message_new_data (guint data_code, ...) { UgMessage* message; guint message_domain; guint message_member; UgType data_type; va_list args; message = ug_data_new (&ug_message_iface); message->type = UG_MESSAGE_DATA; message->code = data_code; message_domain = UG_MESSAGE_CODE_DOMAIN (data_code); message_member = UG_MESSAGE_CODE_MEMBER (data_code); data_type = UG_TYPE_NONE; switch (message_domain) { case UG_MESSAGE_DOMAIN_COMMON: if (message_member < common_data_count) data_type = common_data [message_member]; break; case UG_MESSAGE_DOMAIN_HTTP: if (message_member < http_data_count) data_type = http_data [message_member]; break; default: break; } va_start (args, data_code); ug_message_set_data_v (message, data_type, args); va_end (args); return message; } void ug_message_set_data (UgMessage* message, UgType data_type, ...) { va_list args; va_start (args, data_type); ug_message_set_data_v (message, data_type, args); va_end (args); } void ug_message_set_data_v (UgMessage* message, UgType data_type, va_list args) { switch (data_type) { case UG_TYPE_STRING: message->data.v_string = g_strdup (va_arg (args, gchar*)); break; case UG_TYPE_INT: message->data.v_int = va_arg (args, gint); break; case UG_TYPE_UINT: message->data.v_uint = va_arg (args, guint); break; case UG_TYPE_INT64: message->data.v_int64 = va_arg (args, gint64); break; case UG_TYPE_DOUBLE: message->data.v_double = va_arg (args, gdouble); break; case UG_TYPE_INSTANCE: message->data.v_instance = ug_data_copy (va_arg (args, UgData*)); break; default: break; } } uget-1.10.4/uglib/UgString.c0000664000175000017500000001576212260761064012513 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef _MSC_VER #define _CRT_SECURE_NO_WARNINGS #endif #include #include // ---------------------------------------------------------------------------- // string functions /* This function works like strcspn () * If string_len == -1, string is null-terminated. * It return the index of the first character in string that is in charset. * If none of the characters in string is in charset, then the return value is the length of string. */ unsigned int ug_str_find_charset (const char* string, int string_len, unsigned int offset, const char* charset) { const char* string_end; const char* string_cur; const char* ch; if (string_len == -1) string_len = (int) strlen (string); string_end = string + string_len; for (string_cur = string + offset; string_cur < string_end; string_cur++) { for (ch = charset; *ch; ch++) { if (*string_cur == *ch) return (unsigned int) (string_cur - string); } } return string_len; } /* * This function try to skip specified character from offset in string. * If found other than specified character, return current offset. * Otherwise return original offset. */ unsigned int ug_str_skip_charset (const char* string, int string_len, unsigned int offset, const char* charset) { const char* string_cur; const char* string_end; const char* ch; if (string_len == -1) string_len = (int) strlen (string); string_end = string + string_len; for (string_cur = string + offset; string_cur < string_end; string_cur++) { for (ch = charset; ; ch++) { if (*ch == 0) goto exit; if (*string_cur == *ch) break; } } exit: return (unsigned int) (string_cur - string); } /* * This function try to clear specified character from tail of string. (set character to '\0') * return new string_len. */ unsigned int ug_str_clear_tail_charset (char* string, int string_len, const char* charset) { const char* ch; char* string_cur; if (string_len == -1) string_len = (int) strlen (string); for (string_cur = string +string_len -1; string_cur >= string; string_cur--) { for (ch = charset; ; ch++) { if (*ch == 0) goto exit; if (*string_cur == *ch) { *string_cur = 0; break; } } } exit: return (unsigned int) (string_cur - string + 1); } /* * count line length until character '\r' , '\n' ,or end of string from offset in string. * return : length of line exclude line terminator. */ unsigned int ug_str_line_len (const char* string, int string_len, unsigned int offset) { unsigned int retval; retval = ug_str_find_charset(string, string_len, offset, "\r\n"); if (retval > offset) return retval - offset; return 0; } /* * return : offset of next line in string. * return string_len if no next line. */ unsigned int ug_str_line_next (const char* string, int string_len, unsigned int offset) { const char* string_end; const char* string_cur; if (string_len == -1) string_len = (int) strlen (string); string_end = string + string_len; for (string_cur = string + offset; string_cur < string_end; string_cur++) { if (*string_cur == '\n') return (unsigned int) (string_cur - string) + 1; } return string_len; } /* * It free original string that point by string_pointer and copy a new src string to string_pointer. * If src_len is -1, src string is null-terminated. * If src is NULL, *string_pointer will set NULL. * * char* temp_str = strdup ("123"); * * ug_str_set (&temp_str, "45678", -1); // temp_str will set "45678" */ void ug_str_set (char** string_pointer, const char* src, int src_len) { g_free (*string_pointer); if (src == NULL || *src == 0) { *string_pointer = NULL; return; } if (src_len == -1) *string_pointer = g_strdup (src); else *string_pointer = g_strndup (src, src_len); } /* * convert double to string * If value large than 1024, it will append unit string like "KiB", "MiB", "GiB", "TiB", or "PiB" to string. */ gchar* ug_str_dtoa_unit (gdouble value, gint precision, const gchar* tail) { static const gchar* unit_array[] = {"", " KiB", " MiB", " GiB", " TiB", " PiB"}; static const guint unit_array_len = sizeof (unit_array) / sizeof (gchar*); guint index; for (index=0; index < unit_array_len -1; index++) { if (value < 1024.0) break; value /= 1024.0; } if (index == 0) precision = 0; return g_strdup_printf ("%.*f%s%s", precision, value, unit_array[index], (tail) ? tail : ""); } /* * convert seconds to string (hh:mm:ss) */ gchar* ug_str_from_seconds (guint seconds, gboolean limit_99_99_99) { guint hour, minute; guint day, year; minute = seconds / 60; hour = minute / 60; minute = minute % 60; seconds = seconds % 60; if (hour < 100) return g_strdup_printf ("%.2u:%.2u:%.2u", hour, minute, seconds); else if (limit_99_99_99) return g_strdup ("99:99:99"); else { day = hour / 24; year = day / 365; if (year) return g_strdup ("> 1 year"); else return g_strdup_printf ("%u days", day); } } /* * convert time_t to string */ gchar* ug_str_from_time (time_t ptt, gboolean date_only) { GString* gstr; struct tm* timem; timem = localtime (&ptt); if (date_only) gstr = g_string_sized_new (11); else gstr = g_string_sized_new (11 + 9); g_string_append_printf (gstr, "%.4d-%.2d-%.2d", timem->tm_year + 1900, timem->tm_mon + 1, timem->tm_mday); if (date_only == FALSE) { g_string_append_printf (gstr, " %.2d:%.2d:%.2d", timem->tm_hour, timem->tm_min, timem->tm_sec); } return g_string_free (gstr, FALSE); } uget-1.10.4/uglib/UgDataset.h0000664000175000017500000001067212260761064012632 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ // UgDataset collection of all UgDatalist-based instance // UgData // | // `- UgDataset #ifndef UG_DATASET_H #define UG_DATASET_H #include #include #ifdef __cplusplus extern "C" { #endif // These macro is for internal use only. // use ug_dataset_get(dataset, UgetCommonInfo, 0) to instead UG_DATASET_COMMON(dataset) #define UG_DATASET_COMMON(dataset) ( (UgetCommon*)((dataset)->data[0]) ) #define UG_DATASET_PROXY(dataset) ( (UgetProxy*) ((dataset)->data[2]) ) #define UG_DATASET_PROGRESS(dataset) ( (UgetProgress*) ((dataset)->data[4]) ) #define UG_DATASET_RELATION(dataset) ( (UgetRelation*) ((dataset)->data[6]) ) typedef struct UgDataset UgDataset; // collection of all UgDatalist-based instance extern const UgDataInterface ug_dataset_iface; // ---------------------------------------------------------------------------- // UgDataset : collection of all UgDatalist-based instance. struct UgDataset { const UgDataInterface* iface; // for UgMarkup parse/write UgDatalist** data; const UgDataInterface** key; unsigned int data_len; unsigned int alloc_len; unsigned int ref_count; // call destroy.func(destroy.data) when destroying. struct { UgNotifyFunc func; gpointer data; } destroy; struct { gpointer pointer; gpointer data; } user; }; UgDataset* ug_dataset_new (void); void ug_dataset_ref (UgDataset* dataset); void ug_dataset_unref (UgDataset* dataset); // Gets the element at the given position in a list. gpointer ug_dataset_get (UgDataset* dataset, const UgDataInterface* iface, guint nth); // Removes the element at the given position in a list. void ug_dataset_remove (UgDataset* dataset, const UgDataInterface* iface, guint nth); // If nth instance of data_interface exist, return nth instance. // If nth instance of data_interface not exist, alloc new instance in tail and return it. gpointer ug_dataset_realloc (UgDataset* dataset, const UgDataInterface* iface, guint nth); gpointer ug_dataset_alloc_front (UgDataset* dataset, const UgDataInterface* iface); gpointer ug_dataset_alloc_back (UgDataset* dataset, const UgDataInterface* iface); // ------------------------------------ // UgDataset list functions guint ug_dataset_list_length (UgDataset* dataset, const UgDataInterface* iface); UgDatalist** ug_dataset_alloc_list (UgDataset* dataset, const UgDataInterface* iface); UgDatalist** ug_dataset_get_list (UgDataset* dataset, const UgDataInterface* iface); // free old list in dataset and set list with new_list. void ug_dataset_set_list (UgDataset* dataset, const UgDataInterface* iface, gpointer new_list); // Cuts the element at the given position in a list. //UgDatalist* ug_dataset_cut_list (UgDataset* dataset, const UgDataInterface* iface, guint nth); gpointer ug_dataset_cut_list (UgDataset* dataset, const UgDataInterface* iface, guint nth); #ifdef __cplusplus } #endif #endif // UG_DATASET_H uget-1.10.4/uglib/UgUri.c0000664000175000017500000001734012260761064011776 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #include #include #include // ---------------------------------------------------------------------------- // UgUri int ug_uri_init (UgUri* upart, const char* uri) { const char* cur; const char* tmp; upart->uri = uri; // scheme cur = strpbrk (uri, ":/?#"); // make sure ':' before '/', '?', and '#' if (cur && cur[0] == ':') { upart->schemeLength = cur - uri; cur++; } else { upart->schemeLength = 0; cur = uri; } // authority & path if (upart->schemeLength && cur[0] == '/' && cur[1] == '/') { cur += 2; upart->authority = cur - uri; cur += strcspn (cur, "/"); } else upart->authority = -1; upart->path = cur - uri; // file upart->file = -1; if (cur[0]) { for (; ; ) { tmp = strpbrk (cur, "/?#"); if (tmp == NULL || tmp[0] != '/') { upart->file = cur - uri; break; } cur = tmp + 1; } } // query if ((tmp = strchr (cur, '?')) == NULL) upart->query = -1; else { cur = tmp + 1; upart->query = cur - uri; } // fragment if ((tmp = strrchr (cur, '#')) == NULL) upart->fragment = -1; else { cur = tmp + 1; upart->fragment = cur - uri; } // host & port upart->port = -1; if (upart->authority == -1) upart->host = -1; else { upart->host = upart->authority; tmp = uri + upart->authority; for (cur = uri + upart->path -1; cur >= tmp; cur--) { if (cur[0] == '@') { upart->host = cur - uri + 1; break; } if (cur[0] == ':') upart->port = cur - uri + 1; } } return upart->schemeLength; } int ug_uri_part_scheme (UgUri* uuri, const char** scheme) { if (scheme && uuri->schemeLength) *scheme = uuri->uri; return uuri->schemeLength; } int ug_uri_part_file (UgUri* uuri, const char** file) { if (uuri->file != -1) { if (file) *file = uuri->uri + uuri->file; if (uuri->query != -1) return uuri->query - uuri->file - 1; // - '?' if (uuri->fragment != -1) return uuri->fragment - uuri->file - 1; // - '#' return strlen (uuri->uri + uuri->file); } return 0; } int ug_uri_part_file_ext (UgUri* uuri, const char** ext) { const char* beg; const char* end; int len; if (uuri->file != -1) { len = ug_uri_part_file (uuri, &beg); end = uuri->uri + uuri->file + len -1; for (; end >= beg; end--) { if (end[0] == '.') { end += 1; // + '.' if (ext) *ext = end; return len - (end - beg); } } } return 0; } int ug_uri_part_query (UgUri* uuri, const char** query) { if (uuri->query != -1) { if (query) *query = uuri->uri + uuri->query; if (uuri->fragment != -1) return uuri->fragment - uuri->query -1; // - '#' return strlen (uuri->uri + uuri->query); } return 0; } int ug_uri_part_fragment (UgUri* uuri, const char** fragment) { if (uuri->fragment != -1) { if (fragment) *fragment = uuri->uri + uuri->fragment; return strlen (uuri->uri + uuri->fragment); } return 0; } int ug_uri_part_referrer (UgUri* uuri, const char** referrer) { if (referrer) *referrer = uuri->uri; if (uuri->file == -1) return uuri->path; return uuri->file; } int ug_uri_part_user (UgUri* uuri, const char** user) { const char* beg; const char* end; if (uuri->authority == uuri->host) return 0; beg = uuri->uri + uuri->authority; end = uuri->uri + uuri->host - 1; // - '@' if (user) *user = beg; for (; beg < end; beg++) { if (beg[0] == ':') break; } return beg - uuri->uri - uuri->authority; } int ug_uri_part_password (UgUri* uuri, const char** password) { const char* tmp; int length; length = ug_uri_part_user (uuri, &tmp); if (length && tmp[length] == ':') { tmp += length + 1; // + ':' if (password) *password = tmp; return uuri->host - (tmp - uuri->uri) - 1; // - '@' } return 0; } int ug_uri_part_host (UgUri* uuri, const char** host) { if (uuri->host != -1) { if (host) *host = uuri->uri + uuri->host; if (uuri->port != -1) return uuri->port - uuri->host - 1; // - ':' else return uuri->path - uuri->host; } return 0; } int ug_uri_part_port (UgUri* uuri, const char** port) { if (uuri->port != -1) { if (port) *port = uuri->uri + uuri->port; return uuri->path - uuri->port; } return 0; } int ug_uri_get_port (UgUri* uuri) { if (uuri->port != -1) return strtol (uuri->uri + uuri->port, NULL, 10); return -1; } // -------------------------------------------------------- // Convenience Functions for UgUri gchar* ug_uri_get_file (UgUri* upart) { const char* str; char* name; int len; if ((len = ug_uri_part_file (upart, &str)) == 0) return NULL; name = g_uri_unescape_segment (str, str+len, NULL); if (name == NULL) name = g_strndup (str, len); // check encoding if (g_utf8_validate (name, -1, NULL) == FALSE) { str = g_locale_to_utf8 (name, -1, NULL, NULL, NULL); if (str == NULL) { str = g_uri_escape_string (name, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH_ELEMENT, FALSE); } g_free (name); return (gchar*) str; } return name; } // -------------------------------------------------------- // Convenience Functions for UgUri gchar* ug_uri_get_user (UgUri* upart) { const char* str = NULL; int len; if ((len = ug_uri_part_user (upart, &str)) != 0) return g_strndup (str, len); return NULL; } gchar* ug_uri_get_password (UgUri* upart) { const char* str; int len; if ((len = ug_uri_part_password (upart, &str)) != 0) return g_strndup (str, len); return NULL; } // ---------------------------------------------------------------------------- // Other URI functions guint ug_uri_scheme_len (const gchar* uri) { gchar* scheme; guint scheme_len; scheme = g_uri_parse_scheme (uri); if (scheme) { scheme_len = strlen (scheme); // This check Windows/DOS path like "C:\\" // It doesn't need to check length of uri in this case. if (scheme_len == 1 && scheme[scheme_len + 2] == '\\') scheme_len = 0; g_free (scheme); return scheme_len; } return 0; } // get length of referrer guint ug_uri_referrer_len (const gchar* uri) { UgUri upart; ug_uri_init (&upart, uri); return ug_uri_part_referrer ((UgUri*) &upart, NULL); } gchar* ug_uri_get_filename (const gchar* str) { UgUri upart; ug_uri_init (&upart, str); return ug_uri_get_file ((UgUri*) &upart); } uget-1.10.4/uglib/UgApp-base.h0000664000175000017500000000413112260761064012666 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_APP_BASE_H #define UG_APP_BASE_H #include // uglib #include #include #include #ifdef __cplusplus extern "C" { #endif // ------------------------------------------------------------------ // UgAppBase: reserve typedef struct UgAppBase UgAppBase; // ------------------------------------------------------------------ // register/unregister interfaces gboolean uglib_init (void); void uglib_finalize (void); #ifdef __cplusplus } #endif #endif // UG_APP_BASE_H uget-1.10.4/uglib/UgOption.h0000664000175000017500000001163212260761064012512 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ // collect result of GOptionContext to UgDataset #ifndef UG_OPTION_H #define UG_OPTION_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgOption UgOption; typedef struct UgOptionEntry UgOptionEntry; typedef struct UgOptionMainData UgOptionMainData; typedef gboolean (*UgOptionEntryGet) (const UgOptionEntry* oentry, UgDataset* dataset); // ---------------------------------------------------------------------------- // UgOption: integrate GOptionContext, GOptionGroup, and UgOptionEntry // struct UgOption { GOptionContext* context; GOptionGroup* group; // main group UgOptionMainData* data; // main data GList* list; // list of UgOption }; void ug_option_init (UgOption* uopt); // if group is NULL, option->entry will add to main group. void ug_option_add (UgOption* uopt, const UgOptionEntry* option, GOptionGroup* group); // show help message and exit void ug_option_help (UgOption* uopt, const char* progname, const char* help_option); // This parse arguments and return list of newly-created UgDataset. // To free the returned value, use: // g_list_foreach (list, (GFunc) ug_dataset_unref, NULL); // g_list_free (list); GList* ug_option_parse (UgOption* uopt, GPtrArray* args); const UgOptionEntry* ug_option_get_main_entry (void); // ---------------------------------------------------------------------------- // UgOptionEntry // struct UgOptionEntry { const gchar* name; gpointer reserve; // reserve for GModule-related code GOptionEntry* entry; // for g_option_group_add_entries() gpointer data; // argument data guint data_size; // size of argument data UgInitFunc init; // initialize UgOption::data UgOptionEntryGet get; // get argument data and set it to UgDataset }; // These functions can use with g_list_foreach(). // g_list_foreach (UgOption_list, (GFunc) ug_option_entry_get, dataset); // g_list_foreach (UgOption_list, (GFunc) ug_option_entry_clear, NULL); void ug_option_entry_get (const UgOptionEntry* oentry, UgDataset* dataset); void ug_option_entry_clear (const UgOptionEntry* oentry); // --------------------------------------------------------------------------- // UgOptionMainData: main argument data // struct UgOptionMainData { // option_entry->arg_data place below gboolean version; gint offline; gboolean quiet; gint category_index; gchar* input_file; gchar* folder; gchar* file; gchar* user; gchar* password; struct { gint type; gchar* host; guint port; gchar* user; gchar* password; } proxy; struct { gchar* user; gchar* password; gchar* referrer; gchar* user_agent; gchar* cookie_data; gchar* cookie_file; gchar* post_data; gchar* post_file; } http; struct { gchar* user; gchar* password; } ftp; }; // ------------------------------------ // argument functions, free or copy GPtrArray from ug_ipc_peek() and ug_ipc_pop() // GPtrArray* ug_arg_new (int argc, char** argv, gboolean copy_strings); void ug_arg_free (GPtrArray* args, gboolean free_strings); GPtrArray* ug_arg_copy (GPtrArray* args, gboolean copy_strings); // find -?, -h, --help, or --help- in command-line options and return it. char* ug_arg_find_help (int argc, char** argv); // find -V, --version char* ug_arg_find_version (int argc, char** argv); #ifdef __cplusplus } #endif #endif // UG_OPTION_H uget-1.10.4/uglib/UgetData.c0000664000175000017500000003360312260761064012441 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include // uglib #include #include #include // ---------------------------------------------------------------------------- // UgetCommon static void uget_common_init (UgetCommon* common); static void uget_common_final (UgetCommon* common); static void uget_common_assign (UgetCommon* common, UgetCommon* src); static const UgDataEntry uget_common_entry[] = { {"name", G_STRUCT_OFFSET (UgetCommon, name), UG_TYPE_STRING, NULL, NULL}, {"url", G_STRUCT_OFFSET (UgetCommon, url), UG_TYPE_STRING, NULL, NULL}, {"mirrors", G_STRUCT_OFFSET (UgetCommon, mirrors), UG_TYPE_STRING, NULL, NULL}, {"file", G_STRUCT_OFFSET (UgetCommon, file), UG_TYPE_STRING, NULL, NULL}, {"folder", G_STRUCT_OFFSET (UgetCommon, folder), UG_TYPE_STRING, NULL, NULL}, {"user", G_STRUCT_OFFSET (UgetCommon, user), UG_TYPE_STRING, NULL, NULL}, {"password", G_STRUCT_OFFSET (UgetCommon, password), UG_TYPE_STRING, NULL, NULL}, {"ConnectTimeout", G_STRUCT_OFFSET (UgetCommon, connect_timeout), UG_TYPE_UINT, NULL, NULL}, {"TransmitTimeout", G_STRUCT_OFFSET (UgetCommon, transmit_timeout), UG_TYPE_UINT, NULL, NULL}, {"RetryDelay", G_STRUCT_OFFSET (UgetCommon, retry_delay), UG_TYPE_UINT, NULL, NULL}, {"RetryLimit", G_STRUCT_OFFSET (UgetCommon, retry_limit), UG_TYPE_UINT, NULL, NULL}, {"MaxConnections", G_STRUCT_OFFSET (UgetCommon, max_connections), UG_TYPE_UINT, NULL, NULL}, {"MaxUploadSpeed", G_STRUCT_OFFSET (UgetCommon, max_upload_speed), UG_TYPE_INT64, NULL, NULL}, {"MaxDownloadSpeed", G_STRUCT_OFFSET (UgetCommon, max_download_speed), UG_TYPE_INT64, NULL, NULL}, {"RetrieveTimestamp", G_STRUCT_OFFSET (UgetCommon, retrieve_timestamp), UG_TYPE_INT, NULL, NULL}, {NULL} // null-terminated }; // extern const UgDataInterface uget_common_iface = { sizeof (UgetCommon), // instance_size "common", // name uget_common_entry, // entry (UgInitFunc) uget_common_init, (UgFinalizeFunc) uget_common_final, (UgAssignFunc) uget_common_assign, }; static void uget_common_init (UgetCommon* common) { common->retrieve_timestamp = TRUE; common->connect_timeout = 30; common->transmit_timeout = 30; common->retry_delay = 6; common->retry_limit = 99; common->max_connections = 1; } static void uget_common_final (UgetCommon* common) { g_free (common->name); g_free (common->url); g_free (common->mirrors); g_free (common->file); g_free (common->folder); g_free (common->user); g_free (common->password); } static void uget_common_assign (UgetCommon* common, UgetCommon* src) { if (common->keeping.name == FALSE) ug_str_set (&common->name, src->name, -1); if (common->keeping.url == FALSE) ug_str_set (&common->url, src->url, -1); if (common->keeping.mirrors == FALSE) ug_str_set (&common->mirrors, src->mirrors, -1); if (common->keeping.file == FALSE) ug_str_set (&common->file, src->file, -1); if (common->keeping.folder == FALSE) ug_str_set (&common->folder, src->folder, -1); if (common->keeping.user == FALSE) ug_str_set (&common->user, src->user, -1); if (common->keeping.password == FALSE) ug_str_set (&common->password, src->password, -1); // timeout if (common->keeping.connect_timeout == FALSE) common->connect_timeout = src->connect_timeout; if (common->keeping.transmit_timeout == FALSE) common->transmit_timeout = src->transmit_timeout; // retry if (common->keeping.retry_delay == FALSE) common->retry_delay = src->retry_delay; if (common->keeping.retry_limit == FALSE) common->retry_limit = src->retry_limit; // max connections if (common->keeping.max_connections == FALSE) common->max_connections = src->max_connections; // speed if (common->keeping.max_upload_speed == FALSE) common->max_upload_speed = src->max_upload_speed; if (common->keeping.max_download_speed == FALSE) common->max_download_speed = src->max_download_speed; // Retrieve timestamp if (common->keeping.retrieve_timestamp == FALSE) common->retrieve_timestamp = src->retrieve_timestamp; if (common->keeping.debug_level == FALSE) common->debug_level = src->debug_level; common->keeping = src->keeping; } // ---------------------------------------------------------------------------- // UgetProxy static void uget_proxy_final (UgetProxy* proxy); static void uget_proxy_assign (UgetProxy* proxy, UgetProxy* src); static const UgDataEntry uget_proxy_entry[] = { {"host", G_STRUCT_OFFSET (UgetProxy, host), UG_TYPE_STRING, NULL, NULL}, {"port", G_STRUCT_OFFSET (UgetProxy, port), UG_TYPE_UINT, NULL, NULL}, {"type", G_STRUCT_OFFSET (UgetProxy, type), UG_TYPE_UINT, NULL, NULL}, {"user", G_STRUCT_OFFSET (UgetProxy, user), UG_TYPE_STRING, NULL, NULL}, {"password", G_STRUCT_OFFSET (UgetProxy, password), UG_TYPE_STRING, NULL, NULL}, #ifdef HAVE_LIBPWMD {"pwmd-socket", G_STRUCT_OFFSET (UgetProxy, pwmd.socket), UG_TYPE_STRING, NULL, NULL}, {"pwmd-socket-args", G_STRUCT_OFFSET (UgetProxy, pwmd.socket_args), UG_TYPE_STRING, NULL, NULL}, {"pwmd-file", G_STRUCT_OFFSET (UgetProxy, pwmd.file), UG_TYPE_STRING, NULL, NULL}, {"pwmd-element",G_STRUCT_OFFSET (UgetProxy, pwmd.element),UG_TYPE_STRING, NULL, NULL}, #endif {NULL}, // null-terminated }; // extern const UgDataInterface uget_proxy_iface = { sizeof (UgetProxy), // instance_size "proxy", // name uget_proxy_entry, // entry (UgInitFunc) NULL, (UgFinalizeFunc) uget_proxy_final, (UgAssignFunc) uget_proxy_assign, }; static void uget_proxy_final (UgetProxy* proxy) { g_free (proxy->host); g_free (proxy->user); g_free (proxy->password); #ifdef HAVE_LIBPWMD g_free(proxy->pwmd.socket); g_free(proxy->pwmd.socket_args); g_free(proxy->pwmd.file); g_free(proxy->pwmd.element); #endif // HAVE_LIBPWMD } static void uget_proxy_assign (UgetProxy* proxy, UgetProxy* src) { if (proxy->keeping.host == FALSE) ug_str_set (&proxy->host, src->host, -1); if (proxy->keeping.port == FALSE) proxy->port = src->port; if (proxy->keeping.type == FALSE) proxy->type = src->type; if (proxy->keeping.user == FALSE) ug_str_set (&proxy->user, src->user, -1); if (proxy->keeping.password == FALSE) ug_str_set (&proxy->password, src->password, -1); #ifdef HAVE_LIBPWMD if (proxy->pwmd.keeping.socket == FALSE) ug_str_set (&proxy->pwmd.socket, src->pwmd.socket, -1); if (proxy->pwmd.keeping.socket_args == FALSE) ug_str_set (&proxy->pwmd.socket_args, src->pwmd.socket_args, -1); if (proxy->pwmd.keeping.file == FALSE) ug_str_set (&proxy->pwmd.file, src->pwmd.file, -1); if (proxy->pwmd.keeping.element == FALSE) ug_str_set (&proxy->pwmd.element, src->pwmd.element, -1); #endif // HAVE_LIBPWMD proxy->keeping = src->keeping; } // ---------------------------------------------------------------------------- // UgetProgress static void uget_progress_assign (UgetProgress* progress, UgetProgress* src); static const UgDataEntry uget_progress_entry[] = { {"complete", G_STRUCT_OFFSET (UgetProgress, complete), UG_TYPE_INT64, NULL, NULL}, {"total", G_STRUCT_OFFSET (UgetProgress, total), UG_TYPE_INT64, NULL, NULL}, {"percent", G_STRUCT_OFFSET (UgetProgress, percent), UG_TYPE_DOUBLE, NULL, NULL}, {"elapsed", G_STRUCT_OFFSET (UgetProgress, consume_time), UG_TYPE_DOUBLE, NULL, NULL}, {"uploaded", G_STRUCT_OFFSET (UgetProgress, uploaded), UG_TYPE_INT64, NULL, NULL}, {"ratio", G_STRUCT_OFFSET (UgetProgress, ratio), UG_TYPE_DOUBLE, NULL, NULL}, {NULL}, // null-terminated }; // extern const UgDataInterface uget_progress_iface = { sizeof (UgetProgress), // instance_size "progress", // name uget_progress_entry, // entry (UgInitFunc) NULL, (UgFinalizeFunc) NULL, (UgAssignFunc) uget_progress_assign, }; static void uget_progress_assign (UgetProgress* progress, UgetProgress* src) { // copy without private member memcpy ( ((guint8*) progress) + sizeof (UgDatalist), ((guint8*) src) + sizeof (UgDatalist), sizeof (UgetProgress) - sizeof (UgDatalist) ); } // --------------------------------------------------------------------------- // UgetHttp static void uget_http_init (UgetHttp* http); static void uget_http_final (UgetHttp* http); static void uget_http_assign (UgetHttp* http, UgetHttp* src); static const UgDataEntry uget_http_entry[] = { {"user", G_STRUCT_OFFSET (UgetHttp, user), UG_TYPE_STRING, NULL, NULL}, {"password", G_STRUCT_OFFSET (UgetHttp, password), UG_TYPE_STRING, NULL, NULL}, {"referrer", G_STRUCT_OFFSET (UgetHttp, referrer), UG_TYPE_STRING, NULL, NULL}, {"UserAgent", G_STRUCT_OFFSET (UgetHttp, user_agent), UG_TYPE_STRING, NULL, NULL}, {"PostData", G_STRUCT_OFFSET (UgetHttp, post_data), UG_TYPE_STRING, NULL, NULL}, {"PostFile", G_STRUCT_OFFSET (UgetHttp, post_file), UG_TYPE_STRING, NULL, NULL}, {"CookieData", G_STRUCT_OFFSET (UgetHttp, cookie_data), UG_TYPE_STRING, NULL, NULL}, {"CookieFile", G_STRUCT_OFFSET (UgetHttp, cookie_file), UG_TYPE_STRING, NULL, NULL}, {"RedirectionLimit", G_STRUCT_OFFSET (UgetHttp, redirection_limit), UG_TYPE_UINT, NULL, NULL}, {"RedirectionCount", G_STRUCT_OFFSET (UgetHttp, redirection_count), UG_TYPE_UINT, NULL, NULL}, {NULL}, // null-terminated }; // extern const UgDataInterface uget_http_iface = { sizeof (UgetHttp), // instance_size "http", // name uget_http_entry, // entry (UgInitFunc) uget_http_init, (UgFinalizeFunc) uget_http_final, (UgAssignFunc) uget_http_assign, }; static void uget_http_init (UgetHttp* http) { http->redirection_limit = 30; } static void uget_http_final (UgetHttp* http) { g_free (http->user); g_free (http->password); g_free (http->referrer); g_free (http->user_agent); g_free (http->post_data); g_free (http->post_file); g_free (http->cookie_data); g_free (http->cookie_file); } static void uget_http_assign (UgetHttp* http, UgetHttp* src) { if (http->keeping.user == FALSE) ug_str_set (&http->user, src->user, -1); if (http->keeping.password == FALSE) ug_str_set (&http->password, src->password, -1); if (http->keeping.referrer == FALSE) ug_str_set (&http->referrer, src->referrer, -1); if (http->keeping.user_agent == FALSE) ug_str_set (&http->user_agent, src->user_agent, -1); if (http->keeping.post_data == FALSE) ug_str_set (&http->post_data, src->post_data, -1); if (http->keeping.post_file == FALSE) ug_str_set (&http->post_file, src->post_file, -1); if (http->keeping.cookie_data == FALSE) ug_str_set (&http->cookie_data, src->cookie_data, -1); if (http->keeping.cookie_file == FALSE) ug_str_set (&http->cookie_file, src->cookie_file, -1); if (http->keeping.redirection_limit == FALSE) http->redirection_limit = src->redirection_limit; http->keeping = src->keeping; } // --------------------------------------------------------------------------- // UgetFtp // static void uget_ftp_final (UgetFtp* ftp); static void uget_ftp_assign (UgetFtp* ftp, UgetFtp* src); static const UgDataEntry uget_ftp_entry[] = { {"user", G_STRUCT_OFFSET (UgetFtp, user), UG_TYPE_STRING, NULL, NULL}, {"password", G_STRUCT_OFFSET (UgetFtp, password), UG_TYPE_STRING, NULL, NULL}, {"ActiveMode", G_STRUCT_OFFSET (UgetFtp, active_mode), UG_TYPE_INT,NULL, NULL}, {NULL}, // null-terminated }; // extern const UgDataInterface uget_ftp_iface = { sizeof (UgetFtp), // instance_size "ftp", // name uget_ftp_entry, // entry (UgInitFunc) NULL, (UgFinalizeFunc) uget_ftp_final, (UgAssignFunc) uget_ftp_assign, }; static void uget_ftp_final (UgetFtp* ftp) { g_free (ftp->user); g_free (ftp->password); } static void uget_ftp_assign (UgetFtp* ftp, UgetFtp* src) { if (ftp->keeping.user == FALSE) ug_str_set (&ftp->user, src->user, -1); if (ftp->keeping.password == FALSE) ug_str_set (&ftp->password, src->password, -1); if (ftp->keeping.active_mode == FALSE) ftp->active_mode = src->active_mode; ftp->keeping = src->keeping; } // --------------------------------------------------------------------------- // UgetLog // static void uget_log_final (UgetLog* log); static const UgDataEntry uget_log_entry[] = { {"AddedOn", G_STRUCT_OFFSET (UgetLog, added_on), UG_TYPE_STRING, NULL, NULL}, {"CompletedOn", G_STRUCT_OFFSET (UgetLog, completed_on), UG_TYPE_STRING, NULL, NULL}, {NULL}, // null-terminated }; // extern const UgDataInterface uget_log_iface = { sizeof (UgetLog), // instance_size "log", // name uget_log_entry, // entry (UgInitFunc) NULL, (UgFinalizeFunc) uget_log_final, (UgAssignFunc) NULL, }; static void uget_log_final (UgetLog* log) { g_free (log->added_on); g_free (log->completed_on); } uget-1.10.4/uglib/UgPlugin.h0000664000175000017500000001744712260761064012512 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ // define plug-ins struct and interface #ifndef UG_PLUGIN_H #define UG_PLUGIN_H #include #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgPlugin UgPlugin; typedef struct UgPluginInterface UgPluginInterface; typedef enum UgResult UgResult; typedef enum UgState UgState; typedef gboolean (*UgGlobalInitFunc) (void); typedef void (*UgGlobalFinalizeFunc) (void); typedef UgResult (*UgGlobalSetFunc) (guint parameter, gpointer data); typedef UgResult (*UgGlobalGetFunc) (guint parameter, gpointer data); typedef gboolean (*UgPluginInitFunc) (UgPlugin* plugin, UgDataset* dataset); typedef void (*UgPluginCallback) (UgPlugin* plugin, const UgMessage* message, gpointer user_data); typedef UgResult (*UgSetStateFunc) (gpointer instance, UgState state); typedef UgResult (*UgGetStateFunc) (gpointer instance, UgState* state); typedef UgResult (*UgSetFunc) (gpointer instance, guint parameter, gpointer data); typedef UgResult (*UgGetFunc) (gpointer instance, guint parameter, gpointer data); typedef void (*UgOutputFunc) (gpointer instance, const char* buffer, gint length, gint64 offset); enum UgResult { UG_RESULT_ERROR, UG_RESULT_REFUSED, UG_RESULT_OK, UG_RESULT_FAILED, // UG_RESULT_PENDING, UG_RESULT_UNSUPPORT, }; enum UgState { UG_STATE_NULL, // file and memory resource is NULL UG_STATE_READY, // file and memory resource ready, but stop. UG_STATE_PAUSED, UG_STATE_ACTIVE, }; // --------------------------------------------------------------------------- // UgPluginInterface struct UgPluginInterface { unsigned int instance_size; const char* name; const char** schemes; const char** file_types; UgGlobalInitFunc global_init; UgGlobalFinalizeFunc global_finalize; UgGlobalSetFunc global_set; UgGlobalGetFunc global_get; UgPluginInitFunc init; UgFinalizeFunc finalize; UgSetStateFunc set_state; UgGetStateFunc get_state; UgSetFunc set; UgGetFunc get; }; void ug_plugin_interface_register (const UgPluginInterface* iface); void ug_plugin_interface_unregister (const UgPluginInterface* iface); // if type is NULL, find plug-in by name. // if type is "scheme.", find plug-in by schemes. // if type is "file.", find plug-in by file_types. const UgPluginInterface* ug_plugin_interface_find (const gchar* name, const gchar* type); // --------------------------------------------------------------------------- // UgPlugin : UgPlugin is a base structure for downloading. #define UG_PLUGIN_CAST(instance) ((UgPlugin*)(instance)) #define UG_PLUGIN_MEMBERS \ const UgPluginInterface* iface; \ unsigned int ref_count; \ UgMessage* messages; \ UgState state; \ GMutex lock struct UgPlugin { UG_PLUGIN_MEMBERS; // const UgPluginInterface* iface; // unsigned int ref_count; // UgMessage* messages; // UgState state; // GMutex lock; }; UgPlugin* ug_plugin_new (const UgPluginInterface* iface, UgDataset* dataset); UgPlugin* ug_plugin_new_by_name (const gchar* name, UgDataset* dataset); UgPlugin* ug_plugin_new_by_data (UgDataset* dataset); void ug_plugin_ref (UgPlugin* plugin); void ug_plugin_unref (UgPlugin* plugin); void ug_plugin_lock (UgPlugin* plugin); void ug_plugin_unlock (UgPlugin* plugin); // for retry delay // delay millisecond. If plug-in state changed, this function will return. void ug_plugin_delay (UgPlugin* plugin, guint millisecond); // post one message to queue/pop all messages from queue. void ug_plugin_post (UgPlugin* plugin, UgMessage* message); UgMessage* ug_plugin_pop_all (UgPlugin* plugin); // dispatch message for simple program. // return TRUE if plug-in is running. // Example : // while (ug_plugin_dispatch (plugin, NULL, NULL)) // ug_plugin_delay (plugin, 1000); gboolean ug_plugin_dispatch (UgPlugin* plugin, UgPluginCallback callback, gpointer user_data); // concatenate folder and file to new path and try create folder and empty file. // If folder create failed, post UG_MESSAGE_ERROR_FOLDER_CREATE_FAILED. // If file exist, it will change filename and post UG_MESSAGE_DATA_FILE_CHANGED. // if function succeeded, return new path and it's folder length. // // folder_utf8 : UTF-8 encoded folder name, it can set NULL. // file_utf8 : UTF-8 encoded file name, it can set NULL. // folder_len : folder length of new path. set NULL to ignore. // Return : concatenated path include folder and file. call g_free() to free it. // // e.g. // // gchar* path; // gchar* path_folder; // guint path_folder_len; // gchar* path_file; // // // below 3 line has the same result. // path = ug_plugin_create_file (plugin, "var", "temp/filename.ext", &path_folder_len); // path = ug_plugin_create_file (plugin, NULL, "var/temp/filename.ext", &path_folder_len); // path = ug_plugin_create_file (plugin, "var/temp/filename.ext", NULL, &path_folder_len); // // if (path) { // path_folder = g_strndup (path, path_folder_len); // path_file = path + path_folder_len; // } // // result: // If path "var/temp/filename.ext" exist, result list below. // path = "var/temp/filename(0).ext" // path_folder = "var/temp/" // path_file = "filename(0).ext" // // gchar* ug_plugin_create_file (UgPlugin* plugin, const gchar* folder_utf8, const gchar* file_utf8, guint* folder_len); // rename file from old_utf8 to new_utf8. // If file rename fail, it will post UG_MESSAGE_WARNING_FILE_RENAME_FAILED and return FALSE. gboolean ug_plugin_rename_file (UgPlugin* plugin, const gchar* old_utf8, const gchar* new_utf8); gchar* ug_plugin_create_and_hide (UgPlugin* plugin, const gchar* folder, const gchar* file, guint* folder_len); gboolean ug_plugin_rename_and_unhide (UgPlugin* plugin, const gchar* old_utf8, const gchar* new_utf8); // --- virtual functions --- UgResult ug_plugin_global_set (const UgPluginInterface* iface, guint parameter, gpointer data); UgResult ug_plugin_global_get (const UgPluginInterface* iface, guint parameter, gpointer data); UgResult ug_plugin_set_state (UgPlugin* plugin, UgState state); UgResult ug_plugin_get_state (UgPlugin* plugin, UgState* state); UgResult ug_plugin_set (UgPlugin* plugin, guint parameter, gpointer data); UgResult ug_plugin_get (UgPlugin* plugin, guint parameter, gpointer data); #ifdef __cplusplus } #endif #endif // UG_PLUGIN_H uget-1.10.4/uglib/UgXmlrpc.c0000664000175000017500000005100312260761064012476 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_PLUGIN_ARIA2 #include #include #include #include #include // ---------------------------------------------------------------------------- // UgXmlrpc: XML-RPC // static void ug_xmlrpc_add_value (UgXmlrpc* xmlrpc, UgXmlrpcValue* value); static void ug_xmlrpc_add_array (UgXmlrpc* xmlrpc, UgXmlrpcValue* value); static void ug_xmlrpc_add_struct (UgXmlrpc* xmlrpc, UgXmlrpcValue* value); static size_t ug_xmlrpc_curl_write (char* buffer, size_t size, size_t nmemb, UgXmlrpc* xmlrpc); static void ug_str_unescape_text (gchar* text); // parser static void ug_xmltag_parse_unknown (UgXmltag* xmltag, gpointer data); static void ug_xmltag_parse_response (UgXmltag* xmltag, UgXmlrpc* xmlrpc); static void ug_xmltag_parse_param_top (UgXmltag* xmltag, UgXmlrpcValue* value); static void ug_xmltag_parse_value (UgXmltag* xmltag, UgXmlrpcValue* value); static void ug_xmltag_parse_value_top (UgXmltag* xmltag, UgXmlrpcValue* value); static void ug_xmltag_parse_array (UgXmltag* xmltag, UgXmlrpcValue* value); static void ug_xmltag_parse_array_data (UgXmltag* xmltag, UgXmlrpcValue* value); static void ug_xmltag_parse_struct (UgXmltag* xmltag, UgXmlrpcValue* value); static void ug_xmltag_parse_struct_member (UgXmltag* xmltag, UgXmlrpcValue* value); void ug_xmlrpc_init (UgXmlrpc* xmlrpc) { struct curl_slist* clist; // libcurl clist = NULL; clist = curl_slist_append (clist, "Content-Type: text/xml; charset=utf-8"); xmlrpc->curl_slist = clist; xmlrpc->curl = curl_easy_init (); curl_easy_setopt (xmlrpc->curl, CURLOPT_HTTPHEADER, clist); xmlrpc->uri = NULL; xmlrpc->user_agent = NULL; xmlrpc->buffer = g_string_sized_new (1024); xmlrpc->chunk = g_string_chunk_new (4096); ug_xmltag_init (&xmlrpc->xmltag); ug_xmlrpc_value_init (&xmlrpc->value); } void ug_xmlrpc_finalize (UgXmlrpc* xmlrpc) { // libcurl curl_easy_cleanup (xmlrpc->curl); curl_slist_free_all (xmlrpc->curl_slist); g_free (xmlrpc->uri); g_free (xmlrpc->user_agent); g_string_free (xmlrpc->buffer, TRUE); g_string_chunk_free (xmlrpc->chunk); ug_xmltag_finalize (&xmlrpc->xmltag); ug_xmlrpc_value_clear (&xmlrpc->value); } void ug_xmlrpc_use_client (UgXmlrpc* xmlrpc, const gchar* uri, const gchar* user_agent) { if (xmlrpc->uri) g_free (xmlrpc->uri); if (xmlrpc->user_agent) g_free (xmlrpc->user_agent); xmlrpc->uri = g_strdup (uri); xmlrpc->user_agent = g_strdup (user_agent ? user_agent : "uGet/1.7"); curl_easy_setopt (xmlrpc->curl, CURLOPT_URL, xmlrpc->uri); curl_easy_setopt (xmlrpc->curl, CURLOPT_USERAGENT, xmlrpc->user_agent); } static size_t ug_xmlrpc_curl_write (char* buffer, size_t size, size_t nmemb, UgXmlrpc* xmlrpc) { size = size * nmemb; ug_xmltag_parse (&xmlrpc->xmltag, buffer, size); return size; } // ---------------------------------------------------------------------------- // functions used to write UgXmlrpc.buffer // UgXmlrpcResponse ug_xmlrpc_call (UgXmlrpc* xmlrpc, const gchar* methodName, ...) { GString* buffer; va_list args; union { long response; gchar* str; UgXmlrpcValue* value; } temp; buffer = xmlrpc->buffer; g_string_assign (buffer, "" "" ""); g_string_append (buffer, methodName); g_string_append (buffer, "" ""); va_start (args, methodName); for (;;) { g_string_append (buffer, "" ""); switch (va_arg (args, int)) { case UG_XMLRPC_INT: g_string_append_printf (buffer, "%d", va_arg (args, int)); break; case UG_XMLRPC_INT64: g_string_append_printf (buffer, "%lld", (long long) va_arg (args, gint64)); break; case UG_XMLRPC_BOOLEAN: g_string_append_printf (buffer, "%d", va_arg (args, int)); break; case UG_XMLRPC_STRING: temp.str = g_markup_escape_text (va_arg (args, char*), -1); g_string_append_printf (buffer, "%s", temp.str); g_free (temp.str); break; case UG_XMLRPC_DOUBLE: g_string_append_printf (buffer, "%f", va_arg (args, double)); break; case UG_XMLRPC_DATETIME: g_string_append_printf (buffer, "%s", va_arg (args, char*)); break; case UG_XMLRPC_BINARY: temp.value = va_arg (args, UgXmlrpcValue*); temp.str = g_base64_encode (temp.value->c.binary, temp.value->len); g_string_append_printf (buffer, "%s", temp.str); g_free (temp.str); break; case UG_XMLRPC_NIL: (void) va_arg (args, void*); g_string_append (buffer, ""); break; case UG_XMLRPC_ARRAY: ug_xmlrpc_add_array (xmlrpc, va_arg (args, UgXmlrpcValue*)); break; case UG_XMLRPC_STRUCT: ug_xmlrpc_add_struct (xmlrpc, va_arg (args, UgXmlrpcValue*)); break; default: // buffer->len - strlen ("") g_string_truncate (buffer, buffer->len -14); goto break_for_loop; } g_string_append (buffer, "" ""); } break_for_loop: va_end (args); g_string_append (buffer, "" ""); temp.response = 0; xmlrpc->index = 0; xmlrpc->response = UG_XMLRPC_OK; xmlrpc->xmltag.user.storage = xmlrpc->chunk; g_string_chunk_clear (xmlrpc->chunk); ug_xmlrpc_value_clear (&xmlrpc->value); ug_xmltag_push (&xmlrpc->xmltag, (UgXmltagFunc) ug_xmltag_parse_response, xmlrpc); curl_easy_setopt (xmlrpc->curl, CURLOPT_POST, TRUE); curl_easy_setopt (xmlrpc->curl, CURLOPT_POSTFIELDS, buffer->str); curl_easy_setopt (xmlrpc->curl, CURLOPT_POSTFIELDSIZE, buffer->len); curl_easy_setopt (xmlrpc->curl, CURLOPT_WRITEFUNCTION, (curl_write_callback) ug_xmlrpc_curl_write); curl_easy_setopt (xmlrpc->curl, CURLOPT_WRITEDATA, xmlrpc); curl_easy_perform (xmlrpc->curl); curl_easy_getinfo (xmlrpc->curl, CURLINFO_RESPONSE_CODE, &temp.response); if (temp.response != 200) return UG_XMLRPC_ERROR; if (ug_xmltag_clear (&xmlrpc->xmltag) == FALSE) return UG_XMLRPC_ERROR; return xmlrpc->response; } static void ug_xmlrpc_add_value (UgXmlrpc* xmlrpc, UgXmlrpcValue* value) { GString* buffer; gchar* temp; buffer = xmlrpc->buffer; g_string_append (buffer, ""); switch (value->type) { case UG_XMLRPC_INT: g_string_append_printf (buffer, "%d", value->c.int_); break; case UG_XMLRPC_INT64: g_string_append_printf (buffer, "%lld", (long long) value->c.int64); break; case UG_XMLRPC_BOOLEAN: g_string_append_printf (buffer, "%d", value->c.boolean); break; case UG_XMLRPC_STRING: temp = g_markup_escape_text (value->c.string, -1); g_string_append_printf (buffer, "%s", temp); g_free (temp); break; case UG_XMLRPC_DOUBLE: g_string_append_printf (buffer, "%f", value->c.double_); break; case UG_XMLRPC_DATETIME: g_string_append_printf (buffer, "%s", value->c.string); break; case UG_XMLRPC_BINARY: temp = g_base64_encode (value->c.binary, value->len); g_string_append_printf (buffer, "%s", temp); g_free (temp); break; case UG_XMLRPC_NIL: g_string_append (buffer, ""); break; case UG_XMLRPC_ARRAY: ug_xmlrpc_add_array (xmlrpc, value); break; case UG_XMLRPC_STRUCT: ug_xmlrpc_add_struct (xmlrpc, value); break; default: break; } g_string_append (buffer, ""); } static void ug_xmlrpc_add_array (UgXmlrpc* xmlrpc, UgXmlrpcValue* value) { UgXmlrpcValue* cur; UgXmlrpcValue* end; cur = value->data; end = cur + value->len; g_string_append (xmlrpc->buffer, "" ""); for (; cur < end; cur++) ug_xmlrpc_add_value (xmlrpc, cur); g_string_append (xmlrpc->buffer, "" ""); } static void ug_xmlrpc_add_struct (UgXmlrpc* xmlrpc, UgXmlrpcValue* value) { GString* buffer; UgXmlrpcValue* cur; UgXmlrpcValue* end; buffer = xmlrpc->buffer; cur = value->data; end = cur + value->len; g_string_append (buffer, ""); for (; cur < end; cur++) { g_string_append (buffer, "" ""); g_string_append (buffer, cur->name); g_string_append (buffer, ""); ug_xmlrpc_add_value (xmlrpc, cur); g_string_append (buffer, ""); } g_string_append (buffer, ""); } // ---------------------------------------------------------------------------- // functions used to parse UgXmlrpc.buffer // UgXmlrpcValue* ug_xmlrpc_get_value (UgXmlrpc* xmlrpc) { switch (xmlrpc->response) { case UG_XMLRPC_OK: if (xmlrpc->index < xmlrpc->value.len) return xmlrpc->value.data + xmlrpc->index++; else return NULL; case UG_XMLRPC_FAULT: return &xmlrpc->value; default: // case UG_XMLRPC_ERROR: break; } return NULL; } // parser --------- static void ug_xmltag_parse_unknown (UgXmltag* xmltag, gpointer data) { ug_xmltag_push (xmltag, ug_xmltag_parse_unknown, NULL); } static void ug_xmltag_parse_response (UgXmltag* xmltag, UgXmlrpc* xmlrpc) { switch (xmltag->beg[0]) { // methodResponse case 'm': ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_response, xmlrpc); break; // params case 'p': xmlrpc->response = UG_XMLRPC_OK; xmlrpc->value.type = UG_XMLRPC_PARAMS; ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_param_top, ug_xmlrpc_value_alloc (&xmlrpc->value)); break; // fault case 'f': xmlrpc->response = UG_XMLRPC_FAULT; ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_value_top, &xmlrpc->value); break; default: ug_xmltag_push (xmltag, ug_xmltag_parse_unknown, NULL); break; } } static void ug_xmltag_parse_param_top (UgXmltag* xmltag, UgXmlrpcValue* value) { if (memcmp (xmltag->beg, "param", xmltag->end - xmltag->beg) == 0) ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_value_top, value); else ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_unknown, value); } static void ug_xmltag_parse_value (UgXmltag* xmltag, UgXmlrpcValue* value) { const char* tag = xmltag->beg; const char* text = xmltag->end + 1; gsize temp; if (xmltag->next == NULL) return; switch (tag[0]) { case 'i': // int, i4, i8 if (tag[1] == '8') { value->type = UG_XMLRPC_INT64; #ifdef _WIN32 value->c.int64 = _atoi64 (text); #else value->c.int64 = atoll (text); #endif } else { value->type = UG_XMLRPC_INT; value->c.int_ = atoi (text); } break; case 's': // string or struct if (memcmp (tag, "struct", xmltag->end - xmltag->beg) == 0) { value->type = UG_XMLRPC_STRUCT; ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_struct, value); return; } else { value->type = UG_XMLRPC_STRING; value->c.string = g_string_chunk_insert_len (xmltag->user.storage, text, xmltag->next - text); ug_str_unescape_text (value->c.string); } break; case 'b': // boolean or base64 if (tag[1] == 'o') { value->type = UG_XMLRPC_BOOLEAN; value->c.boolean = atoi (text); } else { value->type = UG_XMLRPC_BINARY; value->c.string = g_string_chunk_insert_len (xmltag->user.storage, text, xmltag->next - text); value->c.binary = g_base64_decode_inplace (value->c.string, &temp); value->len = temp; } break; case 'd': // double or dateTime.iso8601 if (tag[1] == 'o') value->c.double_ = atof (text); else value->c.datetime = g_string_chunk_insert_len (xmltag->user.storage, text, xmltag->next - text); break; case 'a': // array value->type = UG_XMLRPC_ARRAY; ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_array, value); return; case 'n': // nil value->type = UG_XMLRPC_NIL; // value->c.tag = NULL; break; default: break; } ug_xmltag_push (xmltag, ug_xmltag_parse_unknown, NULL); } static void ug_xmltag_parse_value_top (UgXmltag* xmltag, UgXmlrpcValue* value) { // if (xmltag->next && xmltag->next[1] == '/') { // value->type = UG_XMLRPC_STRING; // value->c.string = g_string_chunk_insert_len (xmltag->user.storage, // xmltag->end+1, xmltag->next - (xmltag->end+1)); // } ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_value, value); } static void ug_xmltag_parse_array (UgXmltag* xmltag, UgXmlrpcValue* value) { if (memcmp (xmltag->beg, "data", xmltag->end - xmltag->beg) == 0) ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_array_data, value); else ug_xmltag_push (xmltag, ug_xmltag_parse_unknown, NULL); } static void ug_xmltag_parse_array_data (UgXmltag* xmltag, UgXmlrpcValue* value) { ug_xmltag_parse_value_top (xmltag, ug_xmlrpc_value_alloc (value)); } static void ug_xmltag_parse_struct (UgXmltag* xmltag, UgXmlrpcValue* value) { if (memcmp (xmltag->beg, "member", xmltag->end - xmltag->beg) == 0) { ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_struct_member, ug_xmlrpc_value_alloc (value)); } else ug_xmltag_push (xmltag, (UgXmltagFunc) ug_xmltag_parse_unknown, NULL); } static void ug_xmltag_parse_struct_member (UgXmltag* xmltag, UgXmlrpcValue* value) { switch (xmltag->beg[0]) { // name case 'n': if (xmltag->next) { value->name = g_string_chunk_insert_len (xmltag->user.storage, xmltag->end+1, xmltag->next - (xmltag->end+1)); } ug_xmltag_push (xmltag, ug_xmltag_parse_unknown, NULL); break; // value case 'v': ug_xmltag_parse_value_top (xmltag, value); break; } } // ---------------------------------------------------------------------------- // UgXmltag: simple parser for XML-RPC // void ug_xmltag_init (UgXmltag* xmltag) { xmltag->parser.data = NULL; xmltag->parser.allocated = 0; xmltag->parser.len = 0; xmltag->buffer = g_string_sized_new (2048); } void ug_xmltag_finalize (UgXmltag* xmltag) { g_string_free (xmltag->buffer, TRUE); g_free (xmltag->parser.data); } static void ug_xmltag_parse_in (UgXmltag* xmltag, const char* string, int len, gboolean terminate) { gpointer* parser; UgXmltagFunc func; gpointer data; xmltag->beg = string; // the next character of '<' string = string + len; // point to end for (;;) { if (xmltag->parser.len == 0) return; if ((xmltag->end = memchr (xmltag->beg, '>', string - xmltag->beg)) == NULL) break; if ((xmltag->next = memchr (xmltag->end+1, '<', string - xmltag->end -1)) == NULL && terminate == FALSE) break; switch (xmltag->beg[0]) { case '/': ug_xmltag_pop (xmltag); break; case '?': break; default: parser = xmltag->parser.data + xmltag->parser.len; func = *(parser-2); data = *(parser-1); func (xmltag, data); if (xmltag->end[-1] == '/') ug_xmltag_pop (xmltag); break; } if (xmltag->next == NULL) break; xmltag->beg = xmltag->next + 1; } } gboolean ug_xmltag_parse (UgXmltag* xmltag, const gchar* string, int len) { GString* buffer; const gchar* temp; buffer = xmltag->buffer; temp = memchr (string, '<', len); if (buffer->len) { if (temp == NULL) { g_string_append_len (buffer, string, len); return TRUE; } else { g_string_append_len (buffer, string, temp +1 -string); ug_xmltag_parse_in (xmltag, buffer->str, buffer->len, FALSE); buffer->len = 0; } } if (temp) { temp++; // the next character of '<' string = string + len; // point to end ug_xmltag_parse_in (xmltag, temp, string -temp, FALSE); g_string_overwrite_len (buffer, 0, xmltag->beg, string - xmltag->beg); } return TRUE; } gboolean ug_xmltag_clear (UgXmltag* xmltag) { gboolean retval; ug_xmltag_parse_in (xmltag, xmltag->buffer->str, xmltag->buffer->len, TRUE); xmltag->buffer->len = 0; // Because user push parser and data before running ug_xmltag_parse(), // xmltag->parser.len must be 2 if (xmltag->parser.len == 2) retval = TRUE; else retval = FALSE; xmltag->parser.len = 0; return retval; } void ug_xmltag_push (UgXmltag* xmltag, UgXmltagFunc func, gpointer data) { if (xmltag->parser.allocated == xmltag->parser.len) { if (xmltag->parser.allocated == 0) xmltag->parser.allocated = 32 * 2; else xmltag->parser.allocated *= 2; xmltag->parser.data = g_realloc (xmltag->parser.data, sizeof (gpointer) * xmltag->parser.allocated); } xmltag->parser.data [xmltag->parser.len++] = func; xmltag->parser.data [xmltag->parser.len++] = data; } void ug_xmltag_pop (UgXmltag* xmltag) { if (xmltag->parser.len > 1) xmltag->parser.len -= 2; } // ---------------------------------------------------------------------------- // UgXmlrpcValue: XML-RPC // UgXmlrpcValue* ug_xmlrpc_value_new (void) { return g_slice_new0 (UgXmlrpcValue); } UgXmlrpcValue* ug_xmlrpc_value_new_data (UgXmlrpcType type, guint preallocated_size) { UgXmlrpcValue* value; value = g_slice_new0 (UgXmlrpcValue); value->type = type; if (type >= UG_XMLRPC_ARRAY) { value->data = g_malloc (sizeof (UgXmlrpcValue) * preallocated_size); value->allocated = preallocated_size; } return value; } void ug_xmlrpc_value_free (UgXmlrpcValue* value) { ug_xmlrpc_value_clear (value); g_slice_free1 (sizeof (UgXmlrpcValue), value); } void ug_xmlrpc_value_clear (UgXmlrpcValue* value) { UgXmlrpcValue* cur; UgXmlrpcValue* end; if (value->data) { cur = value->data; end = cur + value->len; // free array data or struct members for (; cur < end; cur++) { if (cur->type >= UG_XMLRPC_ARRAY) ug_xmlrpc_value_clear (cur); } g_free (value->data); value->data = NULL; value->len = 0; value->allocated = 0; // free Balanced Binary Trees if (value->c.tree) { g_tree_destroy (value->c.tree); value->c.tree = NULL; } } } UgXmlrpcValue* ug_xmlrpc_value_alloc (UgXmlrpcValue* value) { UgXmlrpcValue* newone; if (value->type >= UG_XMLRPC_ARRAY) { if (value->len == value->allocated) { if (value->allocated == 0) value->allocated = 16; else value->allocated *= 2; value->data = g_realloc (value->data, sizeof (UgXmlrpcValue) * value->allocated); } newone = value->data + value->len++; // memset (newone, 0, sizeof (UgXmlrpcValue)); ug_xmlrpc_value_init (newone); return newone; } return NULL; } UgXmlrpcValue* ug_xmlrpc_value_find (UgXmlrpcValue* value, const gchar* name) { UgXmlrpcValue* cur; UgXmlrpcValue* end; if (value->type == UG_XMLRPC_STRUCT) { if (value->c.tree == NULL) { value->c.tree = g_tree_new ((GCompareFunc) g_strcmp0); cur = value->data; end = cur + value->len; for (; cur < end; cur++) g_tree_insert (value->c.tree, cur->name, cur); } return g_tree_lookup (value->c.tree, name); } return NULL; } // ---------------------------------------------------------------------------- // utility // static void ug_str_unescape_text (gchar* text) { gchar* beg; gchar* end; guint len; if ((text = strchr (text, '&')) == NULL) return; end = text; // beg end // v v // " for (;;) { for (beg = end; *beg; beg++) { if (*beg == '&') break; } while (end < beg) *text++ = *end++; if ((end = strchr (beg, ';')) == NULL) break; len = end - (beg += 1); if (strncmp (beg, "quot", len) == 0) *text++ = '\"'; else if (strncmp (beg, "amp", len) == 0) *text++ = '&'; else if (strncmp (beg, "lt", len) == 0) *text++ = '<'; else if (strncmp (beg, "gt", len) == 0) *text++ = '>'; end++; } *text = 0; } #endif // HAVE_PLUGIN_ARIA2 uget-1.10.4/uglib/pwmd.c0000664000175000017500000001141312247742234011710 00000000000000/* Copyright (C) 2011-2013 Ben Kibbey 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 Place, Suite 330, Boston, MA 02110-1301 USA */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include "pwmd.h" static gpg_error_t knownhost_cb(void *data, const char *host, const char *key, size_t len) { pwm_t *pwm = data; gpg_error_t rc; char *buf = g_strdup_printf(_("Password Manager Daemon: uget\n\nWhile attempting an SSH connection to %s there was a problem verifying it's hostkey against the known and trusted hosts file because it's hostkey was not found.\n\nWould you like to treat this connection as trusted for this and future connections by adding %s's hostkey to the known hosts file?"), host, host); rc = pwmd_setopt(pwm, PWMD_OPTION_PINENTRY_DESC, buf); g_free(buf); if (rc) return rc; rc = pwmd_getpin(pwm, NULL, NULL, NULL, PWMD_PINENTRY_CONFIRM); (void)pwmd_getpin(pwm, NULL, NULL, NULL, PWMD_PINENTRY_CLOSE); return rc; } gpg_error_t ug_set_pwmd_proxy_options(struct pwmd_proxy_s *pwmd, UgetProxy *proxy) { gpg_error_t rc; pwm_t *pwm = NULL; gchar *result; gchar *path = NULL; gint i; gchar **args = NULL; pwmd->port = 80; if (proxy->pwmd.element) { pwmd->path = path = g_strdup_printf("%s\t", proxy->pwmd.element); for (i = 0; path[i]; i++) { if (path[i] == '^') path[i] = '\t'; } } pwmd_init(); rc = pwmd_new("uget", &pwm); if (rc) goto fail; rc = pwmd_setopt (pwm, PWMD_OPTION_SOCKET_TIMEOUT, 120); if (!rc) rc = pwmd_setopt(pwm, PWMD_OPTION_KNOWNHOST_CB, knownhost_cb); if (!rc && proxy->pwmd.socket_args && *proxy->pwmd.socket_args) args = g_strsplit (proxy->pwmd.socket_args, ",", 0); if (!rc) rc = pwmd_connect(pwm, proxy->pwmd.socket, g_strv_length (args) > 0 ? args[0] : NULL, g_strv_length (args) > 1 ? args[1] : NULL, g_strv_length (args) > 2 ? args[2] : NULL, g_strv_length (args) > 3 ? args[3] : NULL, g_strv_length (args) > 4 ? args[4] : NULL, g_strv_length (args) > 5 ? args[5] : NULL, g_strv_length (args) > 6 ? args[6] : NULL, g_strv_length (args) > 7 ? args[7] : NULL ); if (rc) goto fail; rc = pwmd_setopt(pwm, PWMD_OPTION_PINENTRY_DESC, NULL); if (!rc) rc = pwmd_command(pwm, NULL, NULL, NULL, NULL, "OPTION lock-timeout=100"); if (rc) goto fail; rc = pwmd_open(pwm, proxy->pwmd.file, NULL, NULL); if (rc) goto fail; rc = pwmd_command(pwm, &result, NULL, NULL, NULL, "GET %stype", path ? path : ""); if (rc) goto fail; pwmd->type = result; rc = pwmd_command(pwm, &result, NULL, NULL, NULL, "GET %shostname", path ? path : ""); if (rc) goto fail; pwmd->hostname = result; rc = pwmd_command(pwm, &result, NULL, NULL, NULL, "GET %sport", path ? path : ""); if (rc && gpg_err_code (rc) != GPG_ERR_ELEMENT_NOT_FOUND) goto fail; pwmd->port = atoi(result); pwmd_free(result); rc = pwmd_command(pwm, &result, NULL, NULL, NULL, "GET %susername", path ? path : ""); if (rc && gpg_err_code (rc) != GPG_ERR_ELEMENT_NOT_FOUND && gpg_err_code (rc) != GPG_ERR_NO_DATA) goto fail; if (!rc) pwmd->username = result; rc = pwmd_command(pwm, &result, NULL, NULL, NULL, "GET %spassword", path ? path : ""); if (rc && gpg_err_code (rc) != GPG_ERR_ELEMENT_NOT_FOUND && gpg_err_code (rc) != GPG_ERR_NO_DATA) goto fail; if (!rc) pwmd->password = result; rc = 0; fail: if (args) g_strfreev (args); if (pwm) pwmd_close(pwm); return rc; } void ug_close_pwmd(struct pwmd_proxy_s *pwmd) { pwmd_free(pwmd->type); pwmd_free(pwmd->hostname); pwmd_free(pwmd->username); pwmd_free(pwmd->password); g_free(pwmd->path); } uget-1.10.4/uglib/UgPlugin-curl.h0000664000175000017500000000574412260761064013452 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_PLUGIN_CURL_H #define UG_PLUGIN_CURL_H // #define CURL_NO_OLDIES #include #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgPluginCurl UgPluginCurl; extern const UgPluginInterface ug_plugin_curl_iface; // ---------------------------------------------------------------------------- // uGet plug-ins for libcurl. // UgPlugin // | // `--- UgPluginCurl struct UgPluginCurl { UG_PLUGIN_MEMBERS; // const UgPluginInterface* iface; // unsigned int ref_count; // UgMessage* messages; // UgState state; // GMutex* lock; // supported data UgetCommon* common; UgetProxy* proxy; UgetHttp* http; UgetFtp* ftp; // status guint scheme; gboolean resumable; gboolean keep_filename; // progress guint progress_count; gdouble file_beg; gdouble file_end; // file size // file output gchar* path; guint path_folder_len; // folder length for path gchar* path_tmp; FILE* file_stream; // ug_plugin_curl_open_file () // curl_off_t file_offset; // curl_off_t file_offset_old; gint64 file_offset; // avoid problem that file size larger than 2GB in some 32bit system. gint64 file_offset_old; // file input FILE* file_stream_in; // libcurl // variables for libcurl runtime CURL* curl; gchar curl_error_string[CURL_ERROR_SIZE]; }; #ifdef __cplusplus } #endif #endif // UG_PLUGIN_CURL_H uget-1.10.4/uglib/UgRegistry.c0000664000175000017500000001706712260761064013055 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include //#include #include #include static GHashTable* registry_hash = NULL; //static GStaticMutex registry_mutex = G_STATIC_MUTEX_INIT; void ug_registry_insert (const char* key, const void* value) { GList* list; if (registry_hash == NULL) registry_hash = g_hash_table_new (g_str_hash, g_str_equal); list = g_hash_table_lookup (registry_hash, key); // if key doesn't exist in registry_hash, duplicate it. if (list == NULL) key = g_strdup (key); // add value to list and update list in registry_hash. list = g_list_prepend (list, (gpointer) value); g_hash_table_insert (registry_hash, (gpointer) key, list); } void ug_registry_remove (const char* key, const void* value) { GList* list; gpointer orig_key; if (registry_hash == NULL) return; list = g_hash_table_lookup (registry_hash, key); if (list) { // remove specified value from list list = g_list_remove (list, value); // if list has data, use new list instead of old one. // otherwise key and value must be removed. if (list) g_hash_table_insert (registry_hash, (gpointer) key, list); else { // the original key must be freed. g_hash_table_lookup_extended (registry_hash, key, &orig_key, NULL); g_hash_table_remove (registry_hash, key); g_free (orig_key); } } } int ug_registry_exist (const char* key, const void* value) { GList* list; if (registry_hash) { list = g_hash_table_lookup (registry_hash, key); if (g_list_find (list, value)) return TRUE; } return FALSE; } void* ug_registry_find (const char* key) { GList* list; if (registry_hash) { list = g_hash_table_lookup (registry_hash, key); if (list) return list->data; } return NULL; } // --------------------------------------------------------------------------- // counting static GHashTable* counting_hash = NULL; //static GStaticMutex counting_mutex = G_STATIC_MUTEX_INIT; unsigned int ug_counting_current (const void* key) { if (counting_hash) return GPOINTER_TO_UINT (g_hash_table_lookup (counting_hash, key)); return 0; } unsigned int ug_counting_increase (const void* key) { unsigned int value; if (counting_hash == NULL) counting_hash = g_hash_table_new (g_direct_hash, g_direct_equal); value = GPOINTER_TO_UINT (g_hash_table_lookup (counting_hash, key)) + 1; g_hash_table_insert (counting_hash, (gpointer) key, GUINT_TO_POINTER (value)); return value; } unsigned int ug_counting_decrease (const void* key) { unsigned int value; if (counting_hash) { value = GPOINTER_TO_UINT (g_hash_table_lookup (counting_hash, key)); if (value) { value-- ; g_hash_table_insert (counting_hash, (gpointer) key, GUINT_TO_POINTER (value)); } return value; } return 0; } // --------------------------------------------------------------------------- // attachment static GHashTable* attachment_hash = NULL; static char* attachment_dir = NULL; int ug_attachment_init (const char* dir) { if (attachment_hash == NULL) attachment_hash = g_hash_table_new (g_direct_hash, g_direct_equal); // directory if (dir) attachment_dir = g_strdup (dir); else { attachment_dir = g_build_filename (g_get_user_config_dir (), "uGet", "attachment", NULL); } if (ug_create_dir_all (attachment_dir, -1) == -1) return FALSE; else return TRUE; } char* ug_attachment_alloc (unsigned int* stamp) { GString* gstr; guint length; guint count; guint value; if (attachment_dir == NULL) ug_attachment_init (NULL); // create new attachment dir gstr = g_string_new (attachment_dir); g_string_append_c (gstr, G_DIR_SEPARATOR); length = gstr->len; for (count = 0; count < 30; count++) { value = g_random_int (); if (value) { g_string_truncate (gstr, length); g_string_append_printf (gstr, "%x", value); if (ug_create_dir (gstr->str) == 0) { *stamp = value; ug_attachment_ref (value); return g_string_free (gstr, FALSE); } } } g_string_free (gstr, TRUE); return NULL; } void ug_attachment_destroy (unsigned int stamp) { gchar* dir; g_hash_table_remove (attachment_hash, GUINT_TO_POINTER (stamp)); dir = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "%x", attachment_dir, stamp); ug_delete_dir_recursive (dir); g_free (dir); } void ug_attachment_ref (unsigned int stamp) { guint count; gpointer pointer; if (attachment_hash == NULL) attachment_hash = g_hash_table_new (g_direct_hash, g_direct_equal); if (stamp == 0) return; pointer = g_hash_table_lookup (attachment_hash, GUINT_TO_POINTER (stamp)); count = GPOINTER_TO_UINT (pointer) + 1; g_hash_table_insert (attachment_hash, GUINT_TO_POINTER (stamp), GUINT_TO_POINTER (count)); } void ug_attachment_unref (unsigned int stamp) { guint count; gpointer pointer; if (attachment_hash == NULL || stamp == 0) return; pointer = g_hash_table_lookup (attachment_hash, GUINT_TO_POINTER (stamp)); if (pointer) { count = GPOINTER_TO_UINT (pointer) - 1; if (count == 0) ug_attachment_destroy (stamp); else { g_hash_table_insert (attachment_hash, GUINT_TO_POINTER (stamp), GUINT_TO_POINTER (count)); } } } void ug_attachment_sync (void) { GDir* dir; guint stamp; gchar* path; gchar* name; gchar* locale_dir; if (g_get_filename_charsets (NULL)) { locale_dir = NULL; dir = g_dir_open (attachment_dir, 0, NULL); } else { locale_dir = g_filename_from_utf8 (attachment_dir, -1, NULL, NULL, NULL); dir = g_dir_open (locale_dir, 0, NULL); } if (dir == NULL) { g_free (locale_dir); return; } for (;;) { name = (gchar*) g_dir_read_name (dir); if (name == NULL) break; stamp = strtoul (name, NULL, 16); if (g_hash_table_lookup (attachment_hash, GUINT_TO_POINTER (stamp))) continue; // delete directory if (locale_dir == NULL) path = g_build_filename (attachment_dir, name, NULL); else { name = g_build_filename (locale_dir, name, NULL); path = g_filename_to_utf8 (name, -1, NULL, NULL, NULL); g_free (name); } ug_delete_dir_recursive (path); g_free (path); } g_free (locale_dir); g_dir_close (dir); } uget-1.10.4/uglib/UgRunning.h0000664000175000017500000000710412260761064012661 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ // a group contains all running tasks #ifndef UG_RUNNING_H #define UG_RUNNING_H #include #include #ifdef __cplusplus extern "C" { #endif typedef struct UgRunning UgRunning; typedef gboolean (*UgWatchFunc) (gpointer instance, UgMessage* message, UgDataset* dataset, gpointer data); // ---------------------------------------------------------------------------- // UgRunning: a group for active tasks (UgDataset) // struct UgRunning { GQueue group; gint64 down_speed_limit; gint64 up_speed_limit; // global watch function struct { UgWatchFunc func; gpointer data; } watch; }; void ug_running_init (UgRunning* running); void ug_running_finalize (UgRunning* running); UgRunning* ug_running_new (void); void ug_running_free (UgRunning* running); gboolean ug_running_add (UgRunning* running, UgDataset* dataset); void ug_running_remove (UgRunning* running, UgDataset* dataset); gboolean ug_running_add_tasks (UgRunning* running, GList* list); void ug_running_remove_tasks (UgRunning* running, GList* list); void ug_running_clear (UgRunning* running); GList* ug_running_get_inactive (UgRunning* running); guint ug_running_get_n_tasks (UgRunning* running); void ug_running_get_speed (UgRunning* running, gint64* down_speed, gint64* up_speed); void ug_running_set_speed (UgRunning* running, gint64 down_limit, gint64 up_limit); // This is a GSourceFunc, you can use it with GSource. // It can adjust speed of all task. gboolean ug_running_do_speed_limit (UgRunning* running); // This is a GSourceFunc, you can use it with GSource. // It can dispatch all messages from all tasks. gboolean ug_running_dispatch (UgRunning* running); // It only dispatch messages from one of tasks. void ug_running_dispatch_1 (UgRunning* running, UgDataset* dataset); //void ug_running_foreach(UgRunning* running, GFunc func, gpointer data); #define ug_running_foreach(running, gfunc, data) g_queue_foreach (&running->group, gfunc, data) #ifdef __cplusplus } #endif #endif // UG_RUNNING_H uget-1.10.4/uglib/UgUtils.h0000664000175000017500000000764712260761064012355 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifndef UG_UTILS_H #define UG_UTILS_H #include #include #ifdef __cplusplus extern "C" { #endif // ------------------------------------------------------------------ // file & directory functions // All files and directories name are UTF-8 encoding. // all functions returns 0 if the directory was successfully, -1 if an error occurred #ifdef _WIN32 # define ug_rename g_rename # define ug_unlink g_unlink # define ug_create_dir(dir) g_mkdir(dir,0755) # define ug_delete_dir g_rmdir #endif #ifndef _WIN32 int ug_rename (const gchar *old_file_utf8, const gchar *new_file_utf8); int ug_unlink (const gchar *file_utf8); int ug_create_dir (const gchar *dir_utf8); int ug_delete_dir (const gchar *dir_utf8); #endif #define ug_rename_file ug_rename #define ug_delete_file ug_unlink int ug_copy_file (const gchar *src_file_utf8, const gchar *new_file_utf8); // Create or check all elements of the specified directories. // Return 0 if all elements of directory was exist or created successfully. // Return -1 if error occurred. // dir : use UTF-8 encoding. // len : length of dir. if len == -1, dir is null-terminated string. int ug_create_dir_all (const gchar *dir_utf8, gint len); // Remove a File or Directory Recursively int ug_delete_dir_recursive (const gchar *dir_utf8); // Change the modified time of file int ug_modify_file_time (const gchar *file_utf8, time_t mod_time); // ------------------------------------------------------------------ // URI list functions // To get URIs from text file, error is G_FILE_ERROR. GList* ug_text_file_get_uris (const gchar* file_utf8, GError** error); // get URIs from text GList* ug_text_get_uris (const gchar* text, gint text_len); // remove URIs from list by scheme GList* ug_uri_list_remove_scheme (GList* uris, const gchar* scheme); // ------------------------------------------------------------------ // check BOM in file header and set it's encoding. // return encoding string. const char* ug_io_channel_decide_encoding (GIOChannel* channel); // ------------------------------------------------------------------ // others // gboolean ug_launch_uri (const gchar* uri); gboolean ug_launch_default_app (const gchar* folder, const gchar* file); void ug_shutdown (void); gchar* ug_sys_release (void); #ifdef __cplusplus } #endif #endif // UG_UTILS_H uget-1.10.4/uglib/pwmd.h0000664000175000017500000000217112247742234011716 00000000000000/* Copyright (C) 2011-2013 Ben Kibbey 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 Place, Suite 330, Boston, MA 02110-1301 USA */ #ifndef PWMD_H #define PWMD_H #include #include "UgetData.h" struct pwmd_proxy_s { gchar *hostname; gchar *username; gchar *password; gchar *type; gchar *path; gint port; }; gpg_error_t ug_set_pwmd_proxy_options(struct pwmd_proxy_s *, UgetProxy *); void ug_close_pwmd(struct pwmd_proxy_s *); #endif uget-1.10.4/uglib/Makefile.am0000664000175000017500000000205612247742234012634 00000000000000# To enable LFS (Large File Support) in 32bit platform # add `getconf LFS_CFLAGS` to CFLAGS # add `getconf LFS_LDFLAGS` to LDFLAGS # static library --- # lib_LIBRARIES = libuglib.a noinst_LIBRARIES = libuglib.a libuglib_a_CPPFLAGS = -I$(top_srcdir)/uglib libuglib_a_CFLAGS = @LFS_CFLAGS@ @GLIB_CFLAGS@ @GIO_CFLAGS@ @GTHREAD_CFLAGS@ @CURL_CFLAGS@ @LIBPWMD_CFLAGS@ libuglib_a_SOURCES = \ UgOption.c UgMarkup.c UgIpc.c UgRegistry.c \ UgStdio.c UgString.c UgUri.c UgUtils.c UgHtml.c UgXmlrpc.c \ UgData.c UgDataset.c UgetData.c UgCategory.c UgMessage.c \ UgRunning.c UgPlugin.c UgPlugin-aria2.c UgPlugin-curl.c \ UgApp-base.c noinst_HEADERS = \ UgOption.h UgMarkup.h UgIpc.h UgRegistry.h \ UgStdio.h UgString.h UgUri.h UgUtils.h UgHtml.h UgXmlrpc.h \ UgData.h UgDataset.h UgetData.h UgCategory.h UgMessage.h \ UgRunning.h UgPlugin.h UgPlugin-aria2.h UgPlugin-curl.h \ UgApp-base.h if WITH_LIBPWMD libuglib_a_CFLAGS += @LIBPWMD_CFLAGS@ libuglib_a_SOURCES += pwmd.c noinst_HEADERS += pwmd.h endif uget-1.10.4/uglib/UgApp-base.c0000664000175000017500000000704212260761064012665 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef HAVE_CONFIG_H #include #endif #include #include #include #include #include #ifdef HAVE_PLUGIN_CURL #include #endif #ifdef HAVE_PLUGIN_ARIA2 #include #endif // ------------------------------------------------------------------ gboolean uglib_init (void) { // data ug_data_interface_register (&uget_common_iface); ug_data_interface_register (&uget_proxy_iface); ug_data_interface_register (&uget_progress_iface); ug_data_interface_register (&uget_http_iface); ug_data_interface_register (&uget_ftp_iface); ug_data_interface_register (&uget_log_iface); // category ug_data_interface_register (&ug_category_iface); ug_data_interface_register (&uget_relation_iface); // message ug_data_interface_register (&ug_message_iface); // plug-ins #ifdef HAVE_PLUGIN_ARIA2 // If plug-in failed to initialize, don't register it. if (ug_plugin_aria2_iface.global_init ()) ug_plugin_interface_register (&ug_plugin_aria2_iface); #endif #ifdef HAVE_PLUGIN_CURL if (ug_plugin_curl_iface.global_init ()) ug_plugin_interface_register (&ug_plugin_curl_iface); #endif return TRUE; } void uglib_finalize (void) { // data ug_data_interface_unregister (&uget_common_iface); ug_data_interface_unregister (&uget_proxy_iface); ug_data_interface_unregister (&uget_progress_iface); ug_data_interface_unregister (&uget_http_iface); ug_data_interface_unregister (&uget_ftp_iface); ug_data_interface_unregister (&uget_log_iface); // category ug_data_interface_unregister (&ug_category_iface); ug_data_interface_unregister (&uget_relation_iface); // message ug_data_interface_unregister (&ug_message_iface); // plug-ins #ifdef HAVE_PLUGIN_ARIA2 ug_plugin_interface_unregister (&ug_plugin_aria2_iface); ug_plugin_aria2_iface.global_finalize (); #endif #ifdef HAVE_PLUGIN_CURL ug_plugin_interface_unregister (&ug_plugin_curl_iface); ug_plugin_curl_iface.global_finalize (); #endif } uget-1.10.4/uglib/UgPlugin-aria2.c0000664000175000017500000011510412260761064013466 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_PLUGIN_ARIA2 #include #include // uglib #include #include #include #include #ifdef HAVE_LIBPWMD #include "pwmd.h" #endif #include #define ARIA2_XMLRPC_URI "http://localhost:6800/rpc" // functions for UgPluginInterface static gboolean ug_plugin_aria2_global_init (void); static void ug_plugin_aria2_global_finalize (void); static UgResult ug_plugin_aria2_global_set (guint parameter, gpointer data); static gboolean ug_plugin_aria2_init (UgPluginAria2* plugin, UgDataset* dataset); static void ug_plugin_aria2_finalize (UgPluginAria2* plugin); static UgResult ug_plugin_aria2_set_state (UgPluginAria2* plugin, UgState state); static UgResult ug_plugin_aria2_get_state (UgPluginAria2* plugin, UgState* state); static UgResult ug_plugin_aria2_set (UgPluginAria2* plugin, guint parameter, gpointer data); static UgResult ug_plugin_aria2_get (UgPluginAria2* plugin, guint parameter, gpointer data); // thread function static gpointer ug_plugin_aria2_thread (UgPluginAria2* plugin); // aria2 methods static gboolean ug_plugin_aria2_add_uri (UgPluginAria2* plugin); static gboolean ug_plugin_aria2_add_torrent (UgPluginAria2* plugin); static gboolean ug_plugin_aria2_add_metalink(UgPluginAria2* plugin); static gboolean ug_plugin_aria2_remove (UgPluginAria2* plugin); static gboolean ug_plugin_aria2_get_version (UgPluginAria2* plugin); static gboolean ug_plugin_aria2_get_servers (UgPluginAria2* plugin); static gboolean ug_plugin_aria2_tell_status (UgPluginAria2* plugin); static gboolean ug_plugin_aria2_change_option(UgPluginAria2* plugin, UgXmlrpcValue* options); static gboolean ug_plugin_aria2_response (UgPluginAria2* plugin, UgXmlrpcResponse response, const gchar* method); static void ug_plugin_aria2_post_error (UgPluginAria2* plugin, int code); // setup functions static void ug_plugin_aria2_set_scheme (UgPluginAria2* plugin); static void ug_plugin_aria2_set_common (UgPluginAria2* plugin, UgXmlrpcValue* options); static void ug_plugin_aria2_set_http (UgPluginAria2* plugin, UgXmlrpcValue* options); static gboolean ug_plugin_aria2_set_proxy (UgPluginAria2* plugin, UgXmlrpcValue* options); #ifdef HAVE_LIBPWMD static gboolean ug_plugin_aria2_set_proxy_pwmd (UgPluginAria2 *plugin, UgXmlrpcValue* options); #endif // utility static gint64 ug_xmlrpc_value_get_int64 (UgXmlrpcValue* value); static int ug_xmlrpc_value_get_int (UgXmlrpcValue* value); static gpointer ug_load_binary (const gchar* file, guint* size); enum Aria2Status { ARIA2_WAITING, ARIA2_PAUSED, ARIA2_ACTIVE, ARIA2_ERROR, ARIA2_COMPLETE, ARIA2_REMOVED, }; // static data for UgPluginInterface static const char* supported_schemes[] = {"http", "https", "ftp", "magnet", NULL}; static const char* supported_filetypes[] = {"torrent", "metalink", "meta4", NULL}; static char* xmlrpc_uri; // extern const UgPluginInterface ug_plugin_aria2_iface = { sizeof (UgPluginAria2), // instance_size "aria2", // name supported_schemes, // schemes supported_filetypes, // file_types (UgGlobalInitFunc) ug_plugin_aria2_global_init, // global_init (UgGlobalFinalizeFunc) ug_plugin_aria2_global_finalize, // global_finalize (UgGlobalSetFunc) ug_plugin_aria2_global_set, // global_set (UgGlobalGetFunc) NULL, // global_get (UgPluginInitFunc) ug_plugin_aria2_init, // init (UgFinalizeFunc) ug_plugin_aria2_finalize, // finalize (UgSetStateFunc) ug_plugin_aria2_set_state, // set_state (UgGetStateFunc) ug_plugin_aria2_get_state, // get_state (UgSetFunc) ug_plugin_aria2_set, // set (UgGetFunc) ug_plugin_aria2_get, // get }; // ---------------------------------------------------------------------------- // functions for UgPluginInterface static gboolean ug_plugin_aria2_global_init (void) { xmlrpc_uri = g_strdup (ARIA2_XMLRPC_URI); return TRUE; } static void ug_plugin_aria2_global_finalize (void) { g_free (xmlrpc_uri); } static UgResult ug_plugin_aria2_global_set (guint parameter, gpointer data) { if (parameter != UG_TYPE_STRING) return UG_RESULT_UNSUPPORT; g_free (xmlrpc_uri); xmlrpc_uri = g_strdup (data); return UG_RESULT_OK; } static gboolean ug_plugin_aria2_init (UgPluginAria2* plugin, UgDataset* dataset) { UgetCommon* common; UgetHttp* http; // get data common = ug_dataset_get (dataset, UgetCommonInfo, 0); http = ug_dataset_get (dataset, UgetHttpInfo, 0); // check data if (common == NULL) return FALSE; // reset data if (common) common->retry_count = 0; if (http) http->redirection_count = 0; // copy supported data plugin->common = ug_datalist_copy (ug_dataset_get (dataset, UgetCommonInfo, 0)); plugin->proxy = ug_datalist_copy (ug_dataset_get (dataset, UgetProxyInfo, 0)); plugin->http = ug_datalist_copy (ug_dataset_get (dataset, UgetHttpInfo, 0)); plugin->ftp = ug_datalist_copy (ug_dataset_get (dataset, UgetFtpInfo, 0)); // xmlrpc ug_xmlrpc_init (&plugin->xmlrpc); ug_xmlrpc_use_client (&plugin->xmlrpc, xmlrpc_uri, NULL); // others plugin->string = g_string_sized_new (128); plugin->chunk = g_string_chunk_new (512); return TRUE; } static void ug_plugin_aria2_finalize (UgPluginAria2* plugin) { // free data ug_datalist_free (plugin->common); ug_datalist_free (plugin->proxy); ug_datalist_free (plugin->http); ug_datalist_free (plugin->ftp); // free filename g_free (plugin->local_file); // xmlrpc ug_xmlrpc_finalize (&plugin->xmlrpc); // others g_string_free (plugin->string, TRUE); g_string_chunk_free (plugin->chunk); } static UgResult ug_plugin_aria2_set_state (UgPluginAria2* plugin, UgState state) { UgState old_state; GThread* thread; old_state = plugin->state; // change plug-in status if (state != old_state) { if (state == UG_STATE_ACTIVE && old_state < UG_STATE_ACTIVE) { // call ug_plugin_unref () by ug_plugin_aria2_thread () ug_plugin_ref ((UgPlugin*) plugin); // create thread thread = g_thread_try_new ("uget-aria2", (GThreadFunc) ug_plugin_aria2_thread, plugin, NULL); if (thread == NULL) { ug_plugin_unref ((UgPlugin*) plugin); return UG_RESULT_ERROR; } g_thread_unref (thread); } plugin->state = state; ug_plugin_post ((UgPlugin*) plugin, ug_message_new_state (state)); } return UG_RESULT_OK; } static UgResult ug_plugin_aria2_get_state (UgPluginAria2* plugin, UgState* state) { if (state) { *state = plugin->state; return UG_RESULT_OK; } return UG_RESULT_ERROR; } UgResult ug_plugin_aria2_set (UgPluginAria2* plugin, guint parameter, gpointer data) { UgXmlrpcValue* options; UgXmlrpcValue* member; gint64 speed_limit; if (parameter != UG_TYPE_INT64) return UG_RESULT_UNSUPPORT; speed_limit = *(gint64*)data; options = ug_xmlrpc_value_new_struct (2); // max-download-limit member = ug_xmlrpc_value_alloc (options); member->name = "max-download-limit"; member->type = UG_XMLRPC_STRING; member->c.string = g_strdup_printf ("%d", (int) speed_limit); // max-upload-limit member = ug_xmlrpc_value_alloc (options); member->name = "max-upload-limit"; member->type = UG_XMLRPC_STRING; member->c.string = g_strdup_printf ("%d", (int) speed_limit); ug_plugin_aria2_change_option (plugin, options); g_free (ug_xmlrpc_value_at (options, 0)->c.string); g_free (ug_xmlrpc_value_at (options, 1)->c.string); ug_xmlrpc_value_free (options); return UG_RESULT_OK; } static UgResult ug_plugin_aria2_get (UgPluginAria2* plugin, guint parameter, gpointer data) { UgetProgress* progress; if (parameter != UG_TYPE_INSTANCE) return UG_RESULT_UNSUPPORT; if (data == NULL || ((UgData*)data)->iface != UgetProgressInfo) return UG_RESULT_UNSUPPORT; progress = data; progress->download_speed = plugin->downloadSpeed; progress->upload_speed = plugin->uploadSpeed; progress->complete = plugin->completedLength; progress->uploaded = plugin->uploadLength; progress->total = plugin->totalLength; progress->consume_time = plugin->consumeTime; // ratio if (progress->uploaded && progress->complete) progress->ratio = (double)progress->uploaded / (double)progress->complete; else progress->ratio = 0.0; // If total size is unknown, don't calculate percent. if (progress->total) progress->percent = (gdouble) (progress->complete * 100 / progress->total); else progress->percent = 0; // If total size and average speed is unknown, don't calculate remain time. if (progress->download_speed > 0 && progress->total > 0) progress->remain_time = (gdouble) ((progress->total - progress->complete) / progress->download_speed); return UG_RESULT_OK; } // ---------------------------------------------------------------------------- // thread function // static gpointer ug_plugin_aria2_thread (UgPluginAria2* plugin) { UgetCommon* common; UgMessage* message; char* string; const char* temp; char ext; time_t startingTime; gboolean redirection; g_string_chunk_clear (plugin->chunk); startingTime = time (NULL); redirection = TRUE; common = plugin->common; if (ug_plugin_aria2_get_version (plugin) == FALSE) goto exit; // uri, torrent, or metalink string = plugin->common->url; if (strncmp (string, "file:", 5) == 0) { string = g_filename_from_uri (string, NULL, NULL); temp = strrchr (string, G_DIR_SEPARATOR); if (temp == NULL) temp = string; temp = strrchr (temp, '.'); ext = temp ? temp[1] : 0; plugin->local_file = string; switch (ext) { // torrent case 'T': case 't': if (ug_plugin_aria2_add_torrent (plugin) == FALSE) goto exit; break; // metalink case 'M': case 'm': if (ug_plugin_aria2_add_metalink (plugin) == FALSE) goto exit; break; default: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "unsupported file type"); ug_plugin_post ((UgPlugin*) plugin, message); goto exit; } } else { if (ug_plugin_aria2_add_uri (plugin) == FALSE) goto exit; } // loop for (;;) { if (plugin->state != UG_STATE_ACTIVE) { ug_plugin_aria2_remove (plugin); break; } plugin->consumeTime = (double) (time(NULL) - startingTime); ug_plugin_aria2_tell_status (plugin); if (plugin->totalLength > 0) ug_plugin_post ((UgPlugin*)plugin, ug_message_new_progress ()); if (redirection && plugin->followed == NULL) { if (plugin->completedLength) redirection = FALSE; ug_plugin_aria2_get_servers (plugin); } switch (plugin->aria2Status) { case ARIA2_COMPLETE: if (plugin->renamed == FALSE && plugin->common->file && plugin->local_file == NULL) { string = g_strdup_printf ("%.*s%s", plugin->path_folder_len, plugin->path, plugin->common->file); if (ug_rename (plugin->path, string) == 0) { ug_plugin_post ((UgPlugin*) plugin, ug_message_new_warning (UG_MESSAGE_WARNING_FILE_RENAME_FAILED, NULL)); } g_free (string); plugin->renamed = TRUE; } // if current download is metalink or torrent file if (plugin->followed) { if (plugin->gid == plugin->followed->data) plugin->followed = g_list_delete_link (plugin->followed, plugin->followed); if (plugin->followed) { plugin->gid = plugin->followed->data; break; } } // post completed message ug_plugin_post ((UgPlugin*) plugin, ug_message_new_info (UG_MESSAGE_INFO_COMPLETE, NULL)); ug_plugin_post ((UgPlugin*) plugin, ug_message_new_info (UG_MESSAGE_INFO_FINISH, NULL)); goto break_while; case ARIA2_ERROR: // tell aria2 to remove this gid // ug_plugin_aria2_remove (plugin); // download speed was too slow if (plugin->errorCode == 5 && plugin->local_file == NULL) { // retry if (common->retry_count < common->retry_limit) { common->retry_count++; ug_plugin_post ((UgPlugin*) plugin, ug_message_new_info (UG_MESSAGE_INFO_RETRY, NULL)); ug_plugin_delay ((UgPlugin*) plugin, common->retry_delay * 1000); // clear data g_string_chunk_clear (plugin->chunk); g_list_free (plugin->followed); plugin->followed = NULL; // restart download if (ug_plugin_aria2_add_uri (plugin) == FALSE) goto exit; break; } else { ug_plugin_post ((UgPlugin*) plugin, ug_message_new_error (UG_MESSAGE_ERROR_TOO_MANY_RETRIES, NULL)); } } else { // post other error message ug_plugin_aria2_post_error (plugin, plugin->errorCode); } goto break_while; } // delay 0.5 seconds ug_plugin_delay ((UgPlugin*) plugin, 500); } break_while: // clear followed list if task is stopped by user or error occurred. g_list_free (plugin->followed); plugin->followed = NULL; exit: if (plugin->state == UG_STATE_ACTIVE) ug_plugin_aria2_set_state (plugin, UG_STATE_READY); // call ug_plugin_ref () by ug_plugin_aria2_set_state () ug_plugin_unref ((UgPlugin*) plugin); return NULL; } // ---------------------------------------------------------------------------- // aria2 methods // static gboolean ug_plugin_aria2_add_uri (UgPluginAria2* plugin) { UgXmlrpcValue* uris; // UG_XMLRPC_ARRAY UgXmlrpcValue* options; // UG_XMLRPC_STRUCT UgXmlrpcValue* value; UgetCommon* common; UgXmlrpcResponse response; char* curr; char* prev; common = plugin->common; // URIs array ug_plugin_aria2_set_scheme (plugin); uris = ug_xmlrpc_value_new_array (6); value = ug_xmlrpc_value_alloc (uris); value->type = UG_XMLRPC_STRING; value->c.string = common->url; // URIs array (mirrors) for (curr = common->mirrors; curr && curr[0];) { // skip space ' ' while (curr[0] == ' ') curr++; prev = curr; curr = curr + strcspn (curr, " "); value = ug_xmlrpc_value_alloc (uris); value->type = UG_XMLRPC_STRING; value->c.string = g_string_chunk_insert_len (plugin->chunk, prev, curr - prev); } // options struct options = ug_xmlrpc_value_new_struct (16); ug_plugin_aria2_set_common (plugin, options); ug_plugin_aria2_set_proxy (plugin, options); ug_plugin_aria2_set_http (plugin, options); // aria2.addUri response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.addUri", UG_XMLRPC_ARRAY, uris, UG_XMLRPC_STRUCT, options, UG_XMLRPC_NONE); // clear uris, options, and string chunk ug_xmlrpc_value_free (uris); ug_xmlrpc_value_free (options); g_string_chunk_clear (plugin->chunk); // message if (ug_plugin_aria2_response (plugin, response, "aria2.addUri") == FALSE) return FALSE; // get gid value = ug_xmlrpc_get_value (&plugin->xmlrpc); plugin->gid = g_string_chunk_insert (plugin->chunk, value->c.string); return TRUE; } static gboolean ug_plugin_aria2_add_torrent (UgPluginAria2* plugin) { UgXmlrpcValue* torrent; UgXmlrpcValue* options; UgXmlrpcValue* uris; UgXmlrpcValue* value; UgXmlrpcResponse response; // options struct options = ug_xmlrpc_value_new_struct (16); ug_plugin_aria2_set_common (plugin, options); ug_plugin_aria2_set_proxy (plugin, options); // uri array uris = ug_xmlrpc_value_new_array (1); value = ug_xmlrpc_value_alloc (uris); value->type = UG_XMLRPC_STRING; value->c.string = ""; // torrent binary torrent = ug_xmlrpc_value_new (); torrent->type = UG_XMLRPC_BINARY; torrent->c.binary = ug_load_binary (plugin->local_file, &torrent->len); if (torrent->c.binary == NULL) response = UG_XMLRPC_ERROR; else { response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.addTorrent", UG_XMLRPC_BINARY, torrent, UG_XMLRPC_ARRAY, uris, UG_XMLRPC_STRUCT, options, UG_XMLRPC_NONE); } // free resource g_free (torrent->c.binary); ug_xmlrpc_value_free (torrent); ug_xmlrpc_value_free (options); ug_xmlrpc_value_free (uris); // message if (ug_plugin_aria2_response (plugin, response, "aria2.addTorrent") == FALSE) return FALSE; // get gid torrent = ug_xmlrpc_get_value (&plugin->xmlrpc); plugin->gid = g_string_chunk_insert (plugin->chunk, torrent->c.string); return TRUE; } static gboolean ug_plugin_aria2_add_metalink (UgPluginAria2* plugin) { UgXmlrpcValue* meta; UgXmlrpcValue* options; UgXmlrpcResponse response; // options struct options = ug_xmlrpc_value_new_struct (16); ug_plugin_aria2_set_common (plugin, options); ug_plugin_aria2_set_proxy (plugin, options); ug_plugin_aria2_set_http (plugin, options); // metalink binary meta = ug_xmlrpc_value_new (); meta->type = UG_XMLRPC_BINARY; meta->c.binary = ug_load_binary (plugin->local_file, &meta->len); if (meta->c.binary == NULL) response = UG_XMLRPC_ERROR; else { response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.addMetalink", UG_XMLRPC_BINARY, meta, UG_XMLRPC_STRUCT, options, UG_XMLRPC_NONE); } // free resource g_free (meta->c.binary); ug_xmlrpc_value_free (meta); ug_xmlrpc_value_free (options); // message if (ug_plugin_aria2_response (plugin, response, "aria2.addMetalink") == FALSE) return FALSE; // get gid meta = ug_xmlrpc_get_value (&plugin->xmlrpc); meta = ug_xmlrpc_value_at (meta, 0); plugin->gid = g_string_chunk_insert (plugin->chunk, meta->c.string); return TRUE; } static gboolean ug_plugin_aria2_remove (UgPluginAria2* plugin) { UgXmlrpcResponse response; response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.remove", UG_XMLRPC_STRING, plugin->gid, UG_XMLRPC_NONE); // message if (ug_plugin_aria2_response (plugin, response, "aria2.remove") == FALSE) return FALSE; return TRUE; } static gboolean ug_plugin_aria2_get_version (UgPluginAria2* plugin) { UgXmlrpcValue* vdata; // UG_XMLRPC_STRUCT UgXmlrpcValue* value; // UG_XMLRPC_STRUCT UgXmlrpcResponse response; const char* temp; response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.getVersion", UG_XMLRPC_NONE); if (ug_plugin_aria2_response (plugin, response, "aria2.getVersion") == FALSE) return FALSE; vdata = ug_xmlrpc_get_value (&plugin->xmlrpc); if (vdata->type == UG_XMLRPC_STRUCT) { value = ug_xmlrpc_value_find (vdata, "version"); temp = value->c.string; plugin->major_version = atoi (temp); temp = strchr (temp, '.'); temp = temp ? temp+1 : ""; plugin->minor_version = atoi (temp); } return TRUE; } static gboolean ug_plugin_aria2_get_servers (UgPluginAria2* plugin) { UgXmlrpcValue* array; // UG_XMLRPC_ARRAY UgXmlrpcValue* servers; // UG_XMLRPC_STRUCT UgXmlrpcValue* member; UgXmlrpcResponse response; response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.getServers", UG_XMLRPC_STRING, plugin->gid, UG_XMLRPC_NONE); if (response != UG_XMLRPC_OK) return FALSE; // get servers array = ug_xmlrpc_get_value (&plugin->xmlrpc); if (array->type == UG_XMLRPC_ARRAY && array->len) { servers = ug_xmlrpc_value_at (array, 0); member = ug_xmlrpc_value_find (servers, "currentUri"); if (member && strcmp (plugin->common->url, member->c.string) != 0) { g_free (plugin->common->url); plugin->common->url = g_strdup (member->c.string); ug_plugin_post ((UgPlugin*) plugin, ug_message_new_data (UG_MESSAGE_DATA_URL_CHANGED, member->c.string)); } } return TRUE; } static gboolean ug_plugin_aria2_tell_status (UgPluginAria2* plugin) { UgXmlrpcValue* keys; // UG_XMLRPC_ARRAY UgXmlrpcValue* progress; // UG_XMLRPC_STRUCT UgXmlrpcValue* value; UgXmlrpcResponse response; gchar* string; guint index; // set keys array keys = ug_xmlrpc_value_new_array (16); value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "status"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "totalLength"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "completedLength"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "uploadLength"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "downloadSpeed"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "uploadSpeed"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "errorCode"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "files"; value = ug_xmlrpc_value_alloc (keys); value->type = UG_XMLRPC_STRING; value->c.string = "followedBy"; response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.tellStatus", UG_XMLRPC_STRING, plugin->gid, UG_XMLRPC_ARRAY, keys, UG_XMLRPC_NONE); // clear keys array ug_xmlrpc_value_free (keys); // message if (ug_plugin_aria2_response (plugin, response, "aria2.tellStatus") == FALSE) return FALSE; // get progress struct progress = ug_xmlrpc_get_value (&plugin->xmlrpc); if (progress->type != UG_XMLRPC_STRUCT) return FALSE; // status value = ug_xmlrpc_value_find (progress, "status"); if (value && value->c.string) { switch (value->c.string[0]) { case 'a': // active plugin->aria2Status = ARIA2_ACTIVE; break; case 'p': // paused plugin->aria2Status = ARIA2_PAUSED; break; default: case 'w': // waiting plugin->aria2Status = ARIA2_WAITING; break; case 'e': // error plugin->aria2Status = ARIA2_ERROR; break; case 'c': // complete plugin->aria2Status = ARIA2_COMPLETE; break; case 'r': // removed plugin->aria2Status = ARIA2_REMOVED; break; } } // errorCode value = ug_xmlrpc_value_find (progress, "errorCode"); plugin->errorCode = ug_xmlrpc_value_get_int (value); // totalLength value = ug_xmlrpc_value_find (progress, "totalLength"); plugin->totalLength = ug_xmlrpc_value_get_int64 (value); // completedLength value = ug_xmlrpc_value_find (progress, "completedLength"); plugin->completedLength = ug_xmlrpc_value_get_int64 (value); // uploadLength value = ug_xmlrpc_value_find (progress, "uploadLength"); plugin->uploadLength = ug_xmlrpc_value_get_int64 (value); // downloadSpeed value = ug_xmlrpc_value_find (progress, "downloadSpeed"); plugin->downloadSpeed = ug_xmlrpc_value_get_int (value); // uploadSpeed value = ug_xmlrpc_value_find (progress, "uploadSpeed"); plugin->uploadSpeed = ug_xmlrpc_value_get_int (value); // followedBy value = ug_xmlrpc_value_find (progress, "followedBy"); if (value) { for (index = 0; index < value->len; index++) { keys = ug_xmlrpc_value_at (value, index); string = g_string_chunk_insert (plugin->chunk, keys->c.string); plugin->followed = g_list_append (plugin->followed, string); } } // files value = ug_xmlrpc_value_find (progress, "files"); if (plugin->local_file == FALSE && plugin->followed == NULL) { keys = ug_xmlrpc_value_at (value, 0); keys = ug_xmlrpc_value_find (keys, "path"); // UG_XMLRPC_STRUCT if (keys && g_strcmp0 (keys->c.string, plugin->path)) { plugin->path = g_string_chunk_insert (plugin->chunk, keys->c.string); string = strrchr (plugin->path, '/'); string = string ? string+1 : plugin->path; plugin->path_folder_len = string - plugin->path; if (string[0] && plugin->common->file == NULL) { ug_plugin_post ((UgPlugin*) plugin, ug_message_new_data (UG_MESSAGE_DATA_FILE_CHANGED, string)); } } } return TRUE; } static gboolean ug_plugin_aria2_change_option (UgPluginAria2* plugin, UgXmlrpcValue* options) { UgXmlrpcResponse response; response = ug_xmlrpc_call (&plugin->xmlrpc, "aria2.changeOption", UG_XMLRPC_STRING, plugin->gid, UG_XMLRPC_STRUCT, options, UG_XMLRPC_NONE); // message if (ug_plugin_aria2_response (plugin, response, "aria2.changeOption") == FALSE) return FALSE; return TRUE; } static gboolean ug_plugin_aria2_response (UgPluginAria2* plugin, UgXmlrpcResponse response, const gchar* method) { UgMessage* message; gchar* temp; switch (response) { case UG_XMLRPC_ERROR: temp = g_strconcat (method, " result error", NULL); message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, temp); g_free (temp); ug_plugin_post ((UgPlugin*)plugin, message); return FALSE; case UG_XMLRPC_FAULT: temp = g_strconcat (method, " response fault", NULL); message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, temp); g_free (temp); ug_plugin_post ((UgPlugin*)plugin, message); return FALSE; case UG_XMLRPC_OK: break; } return TRUE; } static void ug_plugin_aria2_post_error (UgPluginAria2* plugin, int code) { UgMessage* message; gchar* string; switch (code) { case 1: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: an unknown error occurred."); break; case 2: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: time out occurred."); break; case 3: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: resource was not found."); break; case 4: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2 saw the specfied number of 'resource not found' error. See --max-file-not-found option"); break; case 5: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: speed was too slow."); break; case 6: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: network problem occurred."); break; case 7: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: unfinished downloads."); break; case 8: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, _("Not Resumable")); break; case 9: message = ug_message_new_error (UG_MESSAGE_ERROR_OUT_OF_RESOURCE, NULL); break; case 10: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: piece length was different from one in .aria2 control file."); break; case 11: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2 was downloading same file."); break; case 12: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2 was downloading same info hash torrent."); break; case 13: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: file already existed. See --allow-overwrite option."); break; case 14: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, _("Output file can't be renamed.")); break; case 15: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: could not open existing file."); break; case 16: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: could not create new file or truncate existing file."); break; case 17: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: file I/O error occurred."); break; case 18: message = ug_message_new_error (UG_MESSAGE_ERROR_FOLDER_CREATE_FAILED, NULL); break; case 19: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: name resolution failed."); break; case 20: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: could not parse Metalink document."); break; case 21: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: FTP command failed."); break; case 22: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: HTTP response header was bad or unexpected."); break; case 23: message = ug_message_new_error (UG_MESSAGE_ERROR_HTTP_TOO_MANY_REDIRECTIONS, NULL); break; case 24: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: HTTP authorization failed."); break; case 25: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: could not parse bencoded file(usually .torrent file)."); break; case 26: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: torrent file was corrupted or missing information."); break; case 27: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: Magnet URI was bad."); break; case 28: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: bad/unrecognized option was given or unexpected option argument was given."); break; case 29: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: remote server was unable to handle the request."); break; case 30: message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, "aria2: could not parse JSON-RPC request."); break; default: string = g_strdup_printf ("aria2 error code: %u", plugin->errorCode); message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, string); g_free (string); break; } ug_plugin_post ((UgPlugin*) plugin, message); } // ---------------------------------------------------------------------------- // aria2 setup functions // static void ug_plugin_aria2_set_scheme (UgPluginAria2* plugin) { UgetCommon* common; UgetHttp* http; UgetFtp* ftp; UgUri* uuri; GString* str_uri; gchar* user; gchar* password; common = plugin->common; http = plugin->http; ftp = plugin->ftp; user = NULL; password = NULL; if (common->user || common->password) { user = common->user ? common->user : ""; password = common->password ? common->password : ""; } if (g_ascii_strncasecmp (common->url, "http", 4) == 0) { // set HTTP user & password if (http && (http->user || http->password) ) { user = http->user ? http->user : ""; password = http->password ? http->password : ""; } } else if (g_ascii_strncasecmp (common->url, "ftp", 3) == 0) { // set FTP user & password if (ftp && (ftp->user || ftp->password)) { user = ftp->user ? ftp->user : ""; password = ftp->password ? ftp->password : ""; } } if (user) { uuri = g_slice_new (UgUri); ug_uri_init (uuri, common->url); if (uuri->authority) { str_uri = g_string_sized_new (100); g_string_append_len (str_uri, common->url, uuri->authority); g_string_append (str_uri, user); g_string_append_c (str_uri, ':'); g_string_append (str_uri, password); g_string_append_c (str_uri, '@'); g_string_append (str_uri, uuri->uri + uuri->host); g_free (common->url); common->url = g_string_free (str_uri, FALSE); } g_slice_free (UgUri, uuri); } } static void ug_plugin_aria2_set_common (UgPluginAria2* plugin, UgXmlrpcValue* options) { UgXmlrpcValue* value; UgetCommon* common; GString* string; common = plugin->common; string = plugin->string; if (common->folder) { value = ug_xmlrpc_value_alloc (options); value->name = "dir"; value->type = UG_XMLRPC_STRING; value->c.string = common->folder; } // continue value = ug_xmlrpc_value_alloc (options); value->name = "continue"; value->type = UG_XMLRPC_STRING; value->c.string = "true"; // remote-time value = ug_xmlrpc_value_alloc (options); value->name = "remote-time"; value->type = UG_XMLRPC_STRING; if (common->retrieve_timestamp) value->c.string = "true"; else value->c.string = "false"; // retry-wait (since aria2 v1.11.0) if (plugin->major_version >= 1 && plugin->minor_version >= 11) { value = ug_xmlrpc_value_alloc (options); value->name = "retry-wait"; value->type = UG_XMLRPC_STRING; g_string_printf (string, "%u", common->retry_delay); value->c.string = g_string_chunk_insert (plugin->chunk, string->str); } // max-tries value = ug_xmlrpc_value_alloc (options); value->name = "max-tries"; value->type = UG_XMLRPC_STRING; g_string_printf (string, "%u", common->retry_limit); value->c.string = g_string_chunk_insert (plugin->chunk, string->str); // max-download-limit value = ug_xmlrpc_value_alloc (options); value->name = "max-download-limit"; value->type = UG_XMLRPC_STRING; g_string_printf (string, "%u", (guint) common->max_download_speed); value->c.string = g_string_chunk_insert (plugin->chunk, string->str); // max-upload-limit value = ug_xmlrpc_value_alloc (options); value->name = "max-upload-limit"; value->type = UG_XMLRPC_STRING; g_string_printf (string, "%u", (guint) common->max_upload_speed); value->c.string = g_string_chunk_insert (plugin->chunk, string->str); // lowest-speed-limit value = ug_xmlrpc_value_alloc (options); value->name = "lowest-speed-limit"; value->type = UG_XMLRPC_STRING; g_string_printf (string, "%u", 512); value->c.string = g_string_chunk_insert (plugin->chunk, string->str); // max-connection-per-server (since aria2 v1.10.0) if (plugin->major_version >= 1 && plugin->minor_version >= 10) { value = ug_xmlrpc_value_alloc (options); value->name = "max-connection-per-server"; value->type = UG_XMLRPC_STRING; g_string_printf (string, "%u", common->max_connections); value->c.string = g_string_chunk_insert (plugin->chunk, string->str); } // max-concurrent-downloads // value = ug_xmlrpc_value_alloc (options); // value->name = "max-concurrent-downloads"; // value->type = UG_XMLRPC_STRING; // g_string_printf (string, "%u", common->max_connections); // value->c.string = g_string_chunk_insert (plugin->chunk, string->str); } static void ug_plugin_aria2_set_http (UgPluginAria2* plugin, UgXmlrpcValue* options) { UgXmlrpcValue* value; UgetHttp* http; http = plugin->http; if (http) { if (http->referrer) { value = ug_xmlrpc_value_alloc (options); value->name = "referer"; value->type = UG_XMLRPC_STRING; value->c.string = http->referrer; } if (http->cookie_file) { // value = ug_xmlrpc_value_alloc (options); // value->name = "load-cookies"; // value->type = UG_XMLRPC_STRING; // value->c.string = http->cookie_file; } if (http->user_agent) { value = ug_xmlrpc_value_alloc (options); value->name = "user-agent"; value->type = UG_XMLRPC_STRING; value->c.string = http->user_agent; } } } static gboolean ug_plugin_aria2_set_proxy (UgPluginAria2* plugin, UgXmlrpcValue* options) { UgXmlrpcValue* value; UgetProxy* proxy; proxy = plugin->proxy; if (proxy == NULL) return TRUE; #ifdef HAVE_LIBPWMD if (proxy->type == UGET_PROXY_PWMD) { if (ug_plugin_aria2_set_proxy_pwmd (plugin, options) == FALSE) return FALSE; } #endif // host if (proxy->host) { value = ug_xmlrpc_value_alloc (options); value->name = "all-proxy"; value->type = UG_XMLRPC_STRING; if (proxy->port) value->c.string = proxy->host; else { g_string_printf (plugin->string, "%s:%u", proxy->host, proxy->port); value->c.string = g_string_chunk_insert (plugin->chunk, plugin->string->str); } // proxy user and password if (proxy->user || proxy->password) { // user value = ug_xmlrpc_value_alloc (options); value->name = "all-proxy-user"; value->type = UG_XMLRPC_STRING; value->c.string = proxy->user ? proxy->user : ""; // password value = ug_xmlrpc_value_alloc (options); value->name = "all-proxy-password"; value->type = UG_XMLRPC_STRING; value->c.string = proxy->password ? proxy->password : ""; } } return TRUE; } // ---------------------------------------------------------------------------- // PWMD // #ifdef HAVE_LIBPWMD static gboolean ug_plugin_aria2_set_proxy_pwmd (UgPluginAria2 *plugin, UgXmlrpcValue* options) { struct pwmd_proxy_s pwmd; gpg_error_t rc; UgMessage *message; memset(&pwmd, 0, sizeof(pwmd)); rc = ug_set_pwmd_proxy_options(&pwmd, plugin->proxy); if (rc) goto fail; // proxy host and port // host UgXmlrpcValue *value = ug_xmlrpc_value_alloc (options); value->name = "all-proxy"; value->type = UG_XMLRPC_STRING; if (pwmd.port == 0) value->c.string = g_string_chunk_insert (plugin->chunk, pwmd.hostname); else { g_string_printf (plugin->string, "%s:%u", pwmd.hostname, pwmd.port); value->c.string = g_string_chunk_insert (plugin->chunk, plugin->string->str); } // proxy user and password if (pwmd.username || pwmd.password) { // user value = ug_xmlrpc_value_alloc (options); value->name = "all-proxy-user"; value->type = UG_XMLRPC_STRING; value->c.string = g_string_chunk_insert (plugin->chunk, pwmd.username ? pwmd.username : ""); // password value = ug_xmlrpc_value_alloc (options); value->name = "all-proxy-password"; value->type = UG_XMLRPC_STRING; value->c.string = g_string_chunk_insert (plugin->chunk, pwmd.password ? pwmd.password : ""); } ug_close_pwmd(&pwmd); return TRUE; fail: ug_close_pwmd(&pwmd); gchar *e = g_strdup_printf("Pwmd ERR %i: %s", rc, gpg_strerror(rc)); message = ug_message_new_error (UG_MESSAGE_ERROR_CUSTOM, e); ug_plugin_post ((UgPlugin*) plugin, message); fprintf(stderr, "%s\n", e); g_free(e); return FALSE; } #endif // HAVE_LIBPWMD // ---------------------------------------------------------------------------- // utility // static gint64 ug_xmlrpc_value_get_int64 (UgXmlrpcValue* value) { if (value) { switch (value->type) { case UG_XMLRPC_STRING: #ifdef _WIN32 return _atoi64 (value->c.string); #else return atoll (value->c.string); #endif case UG_XMLRPC_INT64: return value->c.int64; case UG_XMLRPC_DOUBLE: return (gint64) value->c.double_; default: break; } } return 0; } static int ug_xmlrpc_value_get_int (UgXmlrpcValue* value) { if (value) { switch (value->type) { case UG_XMLRPC_STRING: return atoi (value->c.string); case UG_XMLRPC_INT: return value->c.int_; case UG_XMLRPC_DOUBLE: return (int) value->c.double_; default: break; } } return 0; } static gpointer ug_load_binary (const gchar* file, guint* filesize) { int fd; int size; gpointer buffer; // fd = open (file, O_RDONLY | O_BINARY, S_IREAD); fd = ug_fd_open (file, UG_FD_O_READONLY | UG_FD_O_BINARY, UG_FD_S_IREAD); if (fd == -1) return NULL; // lseek (fd, 0, SEEK_END); ug_fd_seek (fd, 0, SEEK_END); // size = tell (fd); size = (int) ug_fd_tell (fd); buffer = g_malloc (size); // lseek (fd, 0, SEEK_SET); ug_fd_seek (fd, 0, SEEK_SET); // if (read (fd, buffer, size) != size) if (ug_fd_read (fd, buffer, size) != size) { g_free (buffer); buffer = NULL; size = 0; } // close (fd); ug_fd_close (fd); *filesize = size; return buffer; } #endif // HAVE_PLUGIN_ARIA2 uget-1.10.4/uglib/UgStdio.h0000664000175000017500000001500312260761064012320 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ // Enhanced version of gstdio.h // Support LFS(Large File Support) and UTF-8 filename // It can compile with MS Visual C++, Mingw, Unix...etc. // To enable LFS (Large File Support) in UNIX platform // add `getconf LFS_CFLAGS` to CFLAGS // add `getconf LFS_LDFLAGS` to LDFLAGS #ifndef UG_STDIO_H #define UG_STDIO_H #ifdef _WIN32 #include #else #include #endif #include // for O_* flags //#include #include // for S_* mode //#include #include #include #ifdef __cplusplus extern "C" { #endif // To enable LFS (Large File Support) in UNIX platform // add `getconf LFS_CFLAGS` to CFLAGS // add `getconf LFS_LDFLAGS` to LDFLAGS // ------------------------------------------------------------------ // low level file I/O // wrapper functions/definitions for file descriptor. // redefine flags: O_APPEND, O_RDONLY, O_WRONLY, O_RDWR, O_CREAT, O_EXCL // redefine mode: S_IREAD, S_IWRITE #if defined(_WIN32) // flags # define UG_FD_O_APPEND _O_APPEND # define UG_FD_O_BINARY _O_BINARY // Text is the default in MS platform # define UG_FD_O_TEXT _O_TEXT // Text is the default in MS platform # define UG_FD_O_RDONLY _O_RDONLY # define UG_FD_O_WRONLY _O_WRONLY # define UG_FD_O_RDWR _O_RDWR # define UG_FD_O_CREAT _O_CREAT # define UG_FD_O_EXCL _O_EXCL // Use with _O_CREAT, return error if file exist. // mnemonic flags # define UG_FD_O_READONLY _O_RDONLY # define UG_FD_O_WRITEONLY _O_WRONLY # define UG_FD_O_READWRITE _O_RDWR # define UG_FD_O_CREATE _O_CREAT // mode # define UG_FD_S_IREAD _S_IREAD // Use with _O_CREAT # define UG_FD_S_IWRITE _S_IWRITE // Use with _O_CREAT # define UG_FD_S_IRGRP 0 // Use with _O_CREAT # define UG_FD_S_IWGRP 0 // Use with _O_CREAT # define UG_FD_S_IROTH 0 // Use with _O_CREAT # define UG_FD_S_IWOTH 0 // Use with _O_CREAT #else // flags # define UG_FD_O_APPEND O_APPEND # ifdef O_BINARY # define UG_FD_O_BINARY O_BINARY // Text is the default in MS platform # define UG_FD_O_TEXT O_TEXT // Text is the default in MS platform # else # define UG_FD_O_BINARY 0 // Text is the default in MS platform # define UG_FD_O_TEXT 0 // Text is the default in MS platform # endif # define UG_FD_O_RDONLY O_RDONLY # define UG_FD_O_WRONLY O_WRONLY # define UG_FD_O_RDWR O_RDWR # define UG_FD_O_CREAT O_CREAT # define UG_FD_O_EXCL O_EXCL // Use with O_CREAT, return error if file exist. // mnemonic flags # define UG_FD_O_READONLY O_RDONLY # define UG_FD_O_WRITEONLY O_WRONLY # define UG_FD_O_READWRITE O_RDWR # define UG_FD_O_CREATE O_CREAT // mode # define UG_FD_S_IREAD S_IREAD // Use with O_CREAT # define UG_FD_S_IWRITE S_IWRITE // Use with O_CREAT # define UG_FD_S_IRGRP S_IRGRP // Use with O_CREAT // GROUP READ # define UG_FD_S_IWGRP S_IWGRP // Use with O_CREAT // GROUP WRITE # define UG_FD_S_IROTH S_IROTH // Use with O_CREAT // OTHERS READ # define UG_FD_S_IWOTH S_IWOTH // Use with O_CREAT // OTHERS WRITE #endif // ug_fd_open () // Returns : a new file descriptor, or -1 if an error occurred. #if defined(__MINGW32__) #define ug_fd_open g_open #else int ug_fd_open (const gchar* filename_utf8, int flags, int mode); #endif #if defined(_WIN32) int ug_fd_truncate (int fd, gint64 length); #endif #ifdef _WIN32 # define ug_fd_close _close # define ug_fd_read _read # define ug_fd_write _write # define ug_fd_seek _lseeki64 // for MS VC # define ug_fd_tell _telli64 // for MS VC #else # define ug_fd_close close # define ug_fd_read read # define ug_fd_write write # define ug_fd_seek lseek # define ug_fd_tell(fd) lseek(fd, 0L, SEEK_CUR) # define ug_fd_truncate ftruncate #endif // ------------------------------------------------------------------ // streaming file I/O // wrapper functions/definitions for file stream. (struct FILE) #if defined(_WIN32) # if defined(__MINGW32__) # define ug_fopen g_fopen # define ug_fseek fseeko64 # define ug_ftell ftello64 # else // __MSVC__ # define ug_fseek _fseeki64 # define ug_ftell _ftelli64 # endif # define ug_fileno _fileno #else # define ug_fseek fseek # define ug_ftell ftell # define ug_fileno fileno #endif #if !defined(__MINGW32__) FILE* ug_fopen (const gchar *filename_utf8, const gchar *mode); #endif int ug_fs_truncate (FILE* file, gint64 size); #define ug_fs_open ug_fopen #define ug_fs_close fclose #define ug_fs_read(file,data,len) fread (data, len, 1, file) #define ug_fs_write(file,data,len) fwrite (data, len, 1, file) #define ug_fs_printf fprintf #define ug_fs_puts(file,string) fputs (string, file) #define ug_fs_putc(file,character) fputc (character, file) #define ug_fs_gets(file,buf,len) fgets (buf, len, file) #define ug_fs_getc(file) fgetc (file) #define ug_fs_flush fflush #define ug_fs_seek ug_fseek #define ug_fs_tell ug_ftell #define ug_fs_get_fd ug_fileno #ifdef __cplusplus } #endif #endif // UG_STDIO_H uget-1.10.4/uglib/UgHtml.c0000664000175000017500000003613712260761064012150 00000000000000/* * * Copyright (C) 2005-2014 by C.H. Huang * plushuang.tw@gmail.com * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * * --- * * In addition, as a special exception, the copyright holders give * permission to link the code of portions of this program with the * OpenSSL library under certain conditions as described in each * individual source file, and distribute linked combinations * including the two. * You must obey the GNU Lesser General Public License in all respects * for all of the code used other than OpenSSL. If you modify * file(s) with this exception, you may extend this exception to your * version of the file(s), but you are not obligated to do so. If you * do not wish to do so, delete this exception statement from your * version. If you delete this exception statement from all source * files in the program, then also delete it here. * */ #include #include #include #define TAG_LEN_MAX 4095 typedef struct UgHtmlContextPrivate UgHtmlContextPrivate; typedef enum UgHtmlContextState UgHtmlContextState; typedef enum UgHtmlTagState UgHtmlTagState; enum UgHtmlContextState { UG_HTML_CONTEXT_NULL, UG_HTML_CONTEXT_TEXT, UG_HTML_CONTEXT_TAG, // UG_HTML_CONTEXT_TAG_PASS, // }; enum UgHtmlTagState { UG_HTML_TAG_ERROR, // (0 << 0) UG_HTML_TAG_START, // (1 << 0) UG_HTML_TAG_END, // (1 << 1) }; // ---------------------------------------------------------------------------- // UgHtmlContextPrivate : simple and uncompleted parser. struct UgHtmlContextPrivate { char* base_href; char* charset; const char* element_name; // index 0, 2, 4, 6... : UgHtmlParser* parser // index 1, 3, 5, 7... : gpointer user_data GPtrArray* parser; // attribute name & value // used by ug_html_context_parse_tag() GPtrArray* attr_names; GPtrArray* attr_values; UgHtmlContextState state; UgHtmlTagState tag_state; // GHashTable* hash_table; // key = tag_name, value = list of UgHtmlFilter GList* filter; int tag_len; char tag[TAG_LEN_MAX + 1]; }; static UgHtmlParser default_parser; static UgHtmlParser script_parser; static UgHtmlParser head_parser; UgHtmlContext* ug_html_context_new (void) { UgHtmlContextPrivate* context; context = g_malloc (sizeof (UgHtmlContextPrivate)); context->base_href = NULL; context->charset = NULL; context->element_name = context->tag; context->parser = g_ptr_array_sized_new (16); context->attr_names = g_ptr_array_sized_new (16); context->attr_values= g_ptr_array_sized_new (16); context->state = UG_HTML_CONTEXT_NULL; context->filter = NULL; context->tag[0] = 0; context->tag_len = 0; ug_html_context_push_parser ((UgHtmlContext*)context, &default_parser, NULL); return (UgHtmlContext*) context; } void ug_html_context_free (UgHtmlContext* context_pub) { UgHtmlContextPrivate* context = (UgHtmlContextPrivate*) context_pub; g_free (context->base_href); g_free (context->charset); g_ptr_array_free (context->parser, TRUE); g_ptr_array_free (context->attr_names, TRUE); g_ptr_array_free (context->attr_values, TRUE); g_list_foreach (context->filter, (GFunc) ug_html_filter_unref, NULL); g_list_free (context->filter); g_free (context); } void ug_html_context_add_filter (UgHtmlContext* context_pub, UgHtmlFilter* filter) { UgHtmlContextPrivate* context = (UgHtmlContextPrivate*) context_pub; context->filter = g_list_prepend (context->filter, filter); ug_html_filter_ref (filter); filter->context = context_pub; } void ug_html_context_push_parser (UgHtmlContext* context_pub, UgHtmlParser* parser, gpointer user_data) { UgHtmlContextPrivate* context = (UgHtmlContextPrivate*) context_pub; g_ptr_array_add (context->parser, parser); g_ptr_array_add (context->parser, user_data); } void ug_html_context_pop_parser (UgHtmlContext* context_pub) { UgHtmlContextPrivate* context = (UgHtmlContextPrivate*) context_pub; GPtrArray* parser_array; parser_array = context->parser; if (parser_array->len >= 2) g_ptr_array_set_size (parser_array, parser_array->len -2); } // parse context->tag, separate attribute names and values. // output: context->element_name, context->attr_names, context->attr_values, context->tag_state static void ug_html_context_parse_tag (UgHtmlContextPrivate* context) { gchar* attr_name = NULL; gchar* attr_value = NULL; gchar* tag_cur; gchar inside_chr = 0; gint inside_level; g_ptr_array_set_size (context->attr_names, 0); g_ptr_array_set_size (context->attr_values, 0); // tag name for (tag_cur=context->tag; tag_cur[0]; tag_cur++) { if (tag_cur[0] == ' ') { tag_cur[0] = 0; tag_cur++; break; } } if (context->tag[0] == 0) { context->tag_state = UG_HTML_TAG_ERROR; return; } if (context->tag[0] == '/') { context->element_name = context->tag + 1; context->tag_state = UG_HTML_TAG_END; return; } // attribute names & values while (tag_cur[0]) { // skip space while (tag_cur[0] == ' ') tag_cur++; // attribute name attr_name = tag_cur; for(; tag_cur[0]; tag_cur++) { if (tag_cur[0] == '=') { tag_cur[0] = 0; // null-terminated tag_cur++; break; } else if (tag_cur[0] == ' ') { // wrong attribute attr_name = NULL; break; } } if (attr_name==NULL) continue; // attribute value attr_value = tag_cur; inside_level = 0; inside_chr = 0; for (; ; tag_cur++) { switch (tag_cur[0]) { case 0: goto break_forLoop; case '"': case '\'': // handle if (inside_chr == tag_cur[0]) { inside_chr = (inside_chr=='"') ? '\'' : '"'; inside_level--; } else { if (inside_level==0) attr_value = tag_cur +1; // ignore first character inside_chr = tag_cur[0]; inside_level++; } if (inside_level==0) { tag_cur[0] = 0; // null-terminated tag_cur++; goto break_forLoop; } break; case '/': if (inside_level == 0) { inside_chr = '/'; tag_cur[0] = 0; // tag_cur++; goto break_forLoop; } break; case ' ': if (inside_level == 0) { tag_cur[0] = 0; tag_cur++; goto break_forLoop; } break; default: break; } } break_forLoop: // add attribute name & value g_ptr_array_add (context->attr_names, attr_name); g_ptr_array_add (context->attr_values, attr_value); } // null-terminated g_ptr_array_add (context->attr_names, NULL); g_ptr_array_add (context->attr_values, NULL); context->element_name = context->tag; if (inside_chr == '/') context->tag_state = UG_HTML_TAG_START | UG_HTML_TAG_END; else context->tag_state = UG_HTML_TAG_START; } gboolean ug_html_context_parse (UgHtmlContext* context_pub, const char* buffer, int buffer_len) { UgHtmlContextPrivate* context = (UgHtmlContextPrivate*) context_pub; UgHtmlParser* parser; gpointer user_data; const char* buffer_cur; const char* buffer_end; if (buffer_len == -1) buffer_len = strlen (buffer); buffer_end = buffer + buffer_len; for (buffer_cur = buffer; buffer_cur < buffer_end; buffer_cur++) { switch (*buffer_cur) { case '<': if (context->state == UG_HTML_CONTEXT_TEXT && buffer < buffer_cur) { parser = g_ptr_array_index (context->parser, context->parser->len -2); user_data = g_ptr_array_index (context->parser, context->parser->len -1); if (parser->text) parser->text (context_pub, buffer, buffer_cur -buffer, user_data); } context->state = UG_HTML_CONTEXT_TAG; context->tag_len = 0; break; case '>': if (context->state == UG_HTML_CONTEXT_TAG) { context->tag[context->tag_len++] = 0; // null-terminated ug_html_context_parse_tag (context); if (context->tag_state & UG_HTML_TAG_START) { parser = g_ptr_array_index (context->parser, context->parser->len -2); user_data = g_ptr_array_index (context->parser, context->parser->len -1); if (parser->start_element) { parser->start_element ((UgHtmlContext*) context, context->tag, (const char**) context->attr_names->pdata, (const char**) context->attr_values->pdata, user_data); } } if (context->tag_state & UG_HTML_TAG_END) { parser = g_ptr_array_index (context->parser, context->parser->len -2); user_data = g_ptr_array_index (context->parser, context->parser->len -1); if (parser->end_element) parser->end_element ((UgHtmlContext*) context, context->element_name, user_data); } } context->state = UG_HTML_CONTEXT_TEXT; context->tag_len = 0; buffer = buffer_cur + 1; break; case '\r': case '\n': // skip break; default: if (context->state == UG_HTML_CONTEXT_TAG) { if (context->tag_len == TAG_LEN_MAX) { context->state = UG_HTML_CONTEXT_NULL; context->tag_len = 0; } else context->tag[context->tag_len++] = *buffer_cur; } break; } } // text if (context->state == UG_HTML_CONTEXT_TEXT && buffer < buffer_cur) { parser = g_ptr_array_index (context->parser, context->parser->len -2); user_data = g_ptr_array_index (context->parser, context->parser->len -1); if (parser->text) parser->text (context_pub, buffer, buffer_cur -buffer, user_data); } return TRUE; } gboolean ug_html_context_parse_file (UgHtmlContext* context, const char* file_utf8) { char* buf; gint buf_len; gint fd; // fd = open (file_utf8, O_RDONLY | O_TEXT, S_IREAD); fd = ug_fd_open (file_utf8, UG_FD_O_READONLY | UG_FD_O_TEXT, UG_FD_S_IREAD); if (fd == -1) return FALSE; buf = g_malloc (4096); for (;;) { // buf_len = read (fd, buf, 4096); buf_len = ug_fd_read (fd, buf, 4096); if (buf_len <= 0) break; ug_html_context_parse (context, buf, buf_len); } g_free (buf); // close (fd); ug_fd_close (fd); return TRUE; } // ---------------------------------------------------------------------------- // UgHtmlFilter UgHtmlFilter* ug_html_filter_new (char* element_name, char* attr_name) { UgHtmlFilter* filter; filter = g_malloc0 (sizeof (UgHtmlFilter)); filter->tag_name = g_strdup (element_name); filter->attr_name = g_strdup (attr_name); // filter->attr_values = NULL; filter->ref_count = 1; return filter; } void ug_html_filter_ref (UgHtmlFilter* filter) { filter->ref_count++; } void ug_html_filter_unref (UgHtmlFilter* filter) { filter->ref_count--; if (filter->ref_count == 0) { g_free (filter->tag_name); g_free (filter->attr_name); g_list_foreach (filter->attr_values, (GFunc) g_free, NULL); g_free (filter); } } // ---------------------------------------------------------------------------- // default parser static void cb_start_element (UgHtmlContextPrivate* context, const char* element_name, const char** attribute_names, const char** attribute_values, gpointer user_data) { UgHtmlFilter* filter; GList* link; if (g_ascii_strcasecmp (element_name, "script") == 0) { ug_html_context_push_parser ((UgHtmlContext*) context, &script_parser, NULL); return; } if (g_ascii_strcasecmp (element_name, "head") == 0) { ug_html_context_push_parser ((UgHtmlContext*) context, &head_parser, NULL); return; } // filter for (link = context->filter; link; link = link->next) { filter = link->data; if (g_ascii_strcasecmp (element_name, filter->tag_name) != 0) continue; for (; *attribute_names; attribute_names++, attribute_values++) { if (g_ascii_strcasecmp (*attribute_names, filter->attr_name) != 0) continue; if (filter->callback) filter->callback (filter, *attribute_values, filter->callback_data); else filter->attr_values = g_list_prepend (filter->attr_values, g_strdup (*attribute_values)); } } } static UgHtmlParser default_parser = { (gpointer) cb_start_element, (gpointer) NULL, (gpointer) NULL, }; // ---------------------------------------------------------------------------- // parser -