Changeset 12638
- Timestamp:
- Aug 7, 2011, 4:42:38 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r12578 r12638 51 51 ## 52 52 ## 53 GLIB_MINIMUM=2.8.054 AC_SUBST(GLIB_MINIMUM)55 53 GTK_MINIMUM=2.8.0 56 54 AC_SUBST(GTK_MINIMUM) 55 GLIB_MINIMUM=2.26.0 56 AC_SUBST(GLIB_MINIMUM) 57 GIO_MINIMUM=2.26.0 58 AC_SUBST(GIO_MINIMUM) 57 59 58 60 ## … … 61 63 ## 62 64 ## 63 # inhibit hibernation when a torrent is active... 64 DBUS_GLIB_MINIMUM=0.70 65 AC_SUBST(DBUS_GLIB_MINIMUM) 66 # implement "watch" directories to use new .torrent files... 67 GIO_MINIMUM=2.15.5 68 AC_SUBST(GIO_MINIMUM) 65 69 66 # create the tray icon with AppIndicator 70 67 LIBAPPINDICATOR_MINIMUM=0.0.11 … … 244 241 [gtk+-2.0 >= $GTK_MINIMUM 245 242 glib-2.0 >= $GLIB_MINIMUM 243 gio-2.0 >= $GIO_MINIMUM], 246 244 gmodule-2.0 >= $GLIB_MINIMUM 247 245 gthread-2.0 >= $GLIB_MINIMUM], … … 253 251 [want_gtk=${have_gtk}]) 254 252 build_gtk=no 255 use_gio=no256 253 use_libappindicator=no 257 use_dbus_glib=no258 254 if test "x$want_gtk" = "xyes" ; then 259 255 if test "x$have_gtk" = "xyes"; then … … 266 262 267 263 if test "x$build_gtk" = "xyes"; then 268 269 PKG_CHECK_MODULES([GIO],270 [gio-2.0 >= $GIO_MINIMUM],271 [use_gio=yes],272 [use_gio=no])273 if test "x$use_gio" = "xyes"; then274 AC_DEFINE([HAVE_GIO], 1)275 fi276 264 277 265 PKG_CHECK_MODULES([LIBAPPINDICATOR], … … 291 279 LIBAPPINDICATOR_CFLAGS= 292 280 LIBAPPINDICATOR_LIBS= 293 fi294 fi295 296 PKG_CHECK_MODULES([DBUS_GLIB],297 [dbus-glib-1 >= $DBUS_GLIB_MINIMUM],298 [use_dbus_glib=yes],299 [use_dbus_glib=no])300 if test "x$use_dbus_glib" = "xyes"; then301 AC_DEFINE([HAVE_DBUS_GLIB], 1)302 fi303 if test "x$use_dbus_glib" = "xyes"; then304 AC_PATH_PROG(DBUS_BINDING_TOOL, dbus-binding-tool, no)305 if test "x$DBUS_BINDING_TOOL" = xno; then306 AC_MSG_WARN([Cannot find dbus-binding-tool])307 use_dbus_glib="no (dbus-binding-tool not found)"308 281 fi 309 282 fi … … 462 435 463 436 Build libtransmission: yes 464 465 437 * optimized for low-resource systems: ${enable_lightweight} 466 438 * µTP enabled: ${build_utp} … … 469 441 470 442 Build GTK+ client: ${build_gtk} 471 472 Optional dependencies for GTK+ client:473 474 * dbus support: ${use_dbus_glib}475 * gio for watchdir and mime-type support: ${use_gio}476 443 * libappindicator for an Ubuntu-style tray: ${use_libappindicator} 477 444 -
trunk/gtk/Makefile.am
r12578 r12638 18 18 @GTK_CFLAGS@ \ 19 19 @LIBCURL_CFLAGS@ \ 20 @GIO_CFLAGS@ \21 @DBUS_GLIB_CFLAGS@ \22 20 @OPENSSL_CFLAGS@ \ 23 21 @ZLIB_CFLAGS@ \ … … 51 49 torrent-cell-renderer.h \ 52 50 tr-core.h \ 53 tr-core-dbus.h \54 51 tr-icon.h \ 55 52 tr-prefs.h \ … … 59 56 60 57 bin_PROGRAMS = transmission-gtk 61 62 dbus_generated_sources = tr-core-dbus.h63 58 64 59 transmission_gtk_SOURCES = \ … … 84 79 tr-prefs.c \ 85 80 tr-window.c \ 86 util.c \ 87 $(dbus_generated_sources) 81 util.c 88 82 89 83 dist_man_MANS = transmission-gtk.1 … … 96 90 @LIBUTP_LIBS@ \ 97 91 @GTK_LIBS@ \ 98 @GIO_LIBS@ \99 92 @LIBAPPINDICATOR_LIBS@ \ 100 93 @LIBEVENT_LIBS@ \ 101 @DBUS_GLIB_LIBS@ \102 94 @LIBCURL_LIBS@ \ 103 95 @OPENSSL_LIBS@ \ … … 118 110 $(DESKTOP_IN_FILES) \ 119 111 marshal.list \ 120 tr-core-dbus.xml \121 112 transmission.png 122 113 123 114 DISTCLEANFILES = \ 124 115 transmission-gtk.desktop 125 126 CLEANFILES = $(dbus_generated_sources)127 128 $(srcdir)/tr-core.c: tr-core-dbus.h129 130 tr-core-dbus.h: $(srcdir)/tr-core-dbus.xml131 $(DBUS_BINDING_TOOL) --mode=glib-server --prefix=gtr_core $< > $(@F)132 116 133 117 if WIN32 … … 139 123 setransmission.res 140 124 141 CLEANFILES += \125 CLEANFILES = \ 142 126 transmission.res 143 127 -
trunk/gtk/actions.c
r12611 r12638 133 133 { "queue-move-up", GTK_STOCK_GO_UP, N_( "Move _Up" ), NULL, NULL, G_CALLBACK( action_cb ) }, 134 134 { "queue-move-down", GTK_STOCK_GO_DOWN, N_( "Move _Down" ), NULL, NULL, G_CALLBACK( action_cb ) }, 135 { "queue-move-bottom", GTK_STOCK_GOTO_BOTTOM, N_( "Move to _Bottom" ), NULL, NULL, G_CALLBACK( action_cb ) } 135 { "queue-move-bottom", GTK_STOCK_GOTO_BOTTOM, N_( "Move to _Bottom" ), NULL, NULL, G_CALLBACK( action_cb ) }, 136 { "present-main-window", NULL, N_( "Present Main Window" ), NULL, NULL, G_CALLBACK( action_cb ) } 136 137 }; 137 138 -
trunk/gtk/conf.c
r12578 r12638 56 56 gl_confdir = g_strdup( configDir ); 57 57 58 if( g tr_mkdir_with_parents( gl_confdir, 0755 ) )58 if( g_mkdir_with_parents( gl_confdir, 0755 ) ) 59 59 return TRUE; 60 60 … … 153 153 cf_check_older_configs( ); 154 154 155 #ifdef HAVE_GIO156 155 str = NULL; 157 156 if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD ); … … 160 159 tr_bencDictAddStr ( d, PREF_KEY_DIR_WATCH, str ); 161 160 tr_bencDictAddBool( d, PREF_KEY_DIR_WATCH_ENABLED, FALSE ); 162 #endif163 161 164 162 tr_bencDictAddBool( d, PREF_KEY_USER_HAS_GIVEN_INFORMED_CONSENT, FALSE ); … … 192 190 tr_bencDictAddInt( d, PREF_KEY_MAIN_WINDOW_Y, 50 ); 193 191 194 str = NULL; 195 #if GLIB_CHECK_VERSION( 2, 14, 0 ) 196 if( !str ) str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD ); 197 #endif 198 if( !str ) str = tr_getDefaultDownloadDir( ); 192 str = g_get_user_special_dir( G_USER_DIRECTORY_DOWNLOAD ); 199 193 tr_bencDictAddStr( d, TR_PREFS_KEY_DOWNLOAD_DIR, str ); 200 194 -
trunk/gtk/favicon.c
r12306 r12638 18 18 19 19 #include "favicon.h" 20 #include "util.h" /* gtr_ mkdir_with_parents(), gtr_idle_add() */20 #include "util.h" /* gtr_idle_add() */ 21 21 22 22 #define IMAGE_TYPES 4 … … 51 51 "favicons", 52 52 NULL ); 53 g tr_mkdir_with_parents( dir, 0777 );53 g_mkdir_with_parents( dir, 0777 ); 54 54 } 55 55 -
trunk/gtk/icons.c
r11709 r12638 12 12 #include "icons.h" 13 13 14 #ifdef HAVE_GIO 15 #if GTK_CHECK_VERSION( 2, 12, 0 ) 16 #define USE_GIO_ICONS 17 #endif 14 #if GTK_CHECK_VERSION( 2, 12, 0 ) 15 #define USE_GIO_ICONS 18 16 #endif 19 17 -
trunk/gtk/main.c
r12611 r12638 36 36 #include <glib/gi18n.h> 37 37 #include <glib/gstdio.h> 38 #ifdef HAVE_GIO 39 #include <gio/gio.h> 40 #endif 38 #include <gio/gio.h> 41 39 #include <gtk/gtk.h> 42 40 … … 377 375 register_magnet_link_handler( void ) 378 376 { 379 #ifdef HAVE_GIO380 377 GAppInfo * app_info = g_app_info_get_default_for_uri_scheme( "magnet" ); 381 378 if( app_info == NULL ) … … 391 388 } 392 389 } 393 #endif394 390 } 395 391 … … 748 744 /* ensure the directories are created */ 749 745 if(( str = gtr_pref_string_get( TR_PREFS_KEY_DOWNLOAD_DIR ))) 750 g tr_mkdir_with_parents( str, 0777 );746 g_mkdir_with_parents( str, 0777 ); 751 747 if(( str = gtr_pref_string_get( TR_PREFS_KEY_INCOMPLETE_DIR ))) 752 g tr_mkdir_with_parents( str, 0777 );748 g_mkdir_with_parents( str, 0777 ); 753 749 754 750 /* initialize the libtransmission session */ … … 884 880 885 881 static void 882 presentMainWindow( struct cbdata * cbdata ) 883 { 884 GtkWindow * window = cbdata->wind; 885 886 if( cbdata->is_iconified ) 887 { 888 cbdata->is_iconified = false; 889 890 gtk_window_set_skip_taskbar_hint( window, FALSE ); 891 } 892 893 if( !gtk_widget_get_visible( GTK_WIDGET( window ) ) ) 894 { 895 gtk_window_resize( window, gtr_pref_int_get( PREF_KEY_MAIN_WINDOW_WIDTH ), 896 gtr_pref_int_get( PREF_KEY_MAIN_WINDOW_HEIGHT ) ); 897 gtk_window_move( window, gtr_pref_int_get( PREF_KEY_MAIN_WINDOW_X ), 898 gtr_pref_int_get( PREF_KEY_MAIN_WINDOW_Y ) ); 899 gtr_widget_set_visible( GTK_WIDGET( window ), TRUE ); 900 } 901 gtr_window_present( window ); 902 } 903 904 static void 905 hideMainWindow( struct cbdata * cbdata ) 906 { 907 GtkWindow * window = cbdata->wind; 908 gtk_window_set_skip_taskbar_hint( window, TRUE ); 909 gtr_widget_set_visible( GTK_WIDGET( window ), FALSE ); 910 cbdata->is_iconified = true; 911 } 912 913 static void 886 914 toggleMainWindow( struct cbdata * cbdata ) 887 915 { 888 GtkWindow * window = cbdata->wind; 889 const int doShow = cbdata->is_iconified; 890 static int x = 0; 891 static int y = 0; 892 893 if( doShow ) 894 { 895 cbdata->is_iconified = 0; 896 gtk_window_set_skip_taskbar_hint( window, FALSE ); 897 gtk_window_move( window, x, y ); 898 gtr_widget_set_visible( GTK_WIDGET( window ), TRUE ); 899 gtr_window_present( window ); 900 } 916 if( cbdata->is_iconified ) 917 presentMainWindow( cbdata ); 901 918 else 902 { 903 gtk_window_get_position( window, &x, &y ); 904 gtk_window_set_skip_taskbar_hint( window, TRUE ); 905 gtr_widget_set_visible( GTK_WIDGET( window ), FALSE ); 906 cbdata->is_iconified = 1; 907 } 919 hideMainWindow( cbdata ); 908 920 } 909 921 … … 1761 1773 toggleMainWindow( data ); 1762 1774 } 1775 else if( !strcmp( action_name, "present-main-window" ) ) 1776 { 1777 presentMainWindow( data ); 1778 } 1763 1779 else g_error ( "Unhandled action: %s", action_name ); 1764 1780 -
trunk/gtk/makemeta-ui.c
r12412 r12638 368 368 getDefaultSavePath( void ) 369 369 { 370 const char * path; 371 #if GLIB_CHECK_VERSION( 2,14,0 ) 372 path = g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP ); 373 #else 374 path = g_get_home_dir( ); 375 #endif 376 return path; 370 return g_get_user_special_dir( G_USER_DIRECTORY_DESKTOP ); 377 371 } 378 372 -
trunk/gtk/torrent-cell-renderer.c
r12611 r12638 982 982 p->progress_renderer = gtk_cell_renderer_progress_new( ); 983 983 p->icon_renderer = gtk_cell_renderer_pixbuf_new( ); 984 g tr_object_ref_sink( p->text_renderer );985 g tr_object_ref_sink( p->progress_renderer );986 g tr_object_ref_sink( p->icon_renderer );984 g_object_ref_sink( p->text_renderer ); 985 g_object_ref_sink( p->progress_renderer ); 986 g_object_ref_sink( p->icon_renderer ); 987 987 988 988 p->bar_height = DEFAULT_BAR_HEIGHT; -
trunk/gtk/tr-core.c
r12611 r12638 28 28 #include <gtk/gtk.h> 29 29 #include <glib/gi18n.h> 30 #ifdef HAVE_GIO 31 #include <gio/gio.h> 32 #endif 33 #ifdef HAVE_DBUS_GLIB 34 #include <dbus/dbus-glib.h> 35 #endif 30 #include <gio/gio.h> 36 31 37 32 #include <event2/buffer.h> … … 47 42 #include "notify.h" 48 43 #include "tr-core.h" 49 #ifdef HAVE_DBUS_GLIB50 #include "tr-core-dbus.h"51 #endif52 44 #include "tr-prefs.h" 53 45 #include "util.h" … … 74 66 static void core_maybe_inhibit_hibernation( TrCore * core ); 75 67 76 static gboolean our_instance_adds_remote_torrents = FALSE;77 78 68 struct TrCorePrivate 79 69 { 80 #ifdef HAVE_GIO81 70 GFileMonitor * monitor; 82 71 gulong monitor_tag; … … 84 73 GSList * monitor_files; 85 74 guint monitor_idle_tag; 86 #endif 75 87 76 gboolean adding_from_watch_dir; 88 77 gboolean inhibit_allowed; … … 90 79 gboolean dbus_error; 91 80 guint inhibit_cookie; 81 guint dbus_session_owner_id; 82 guint dbus_display_owner_id; 92 83 gint busy_count; 93 84 GtkTreeModel * raw_model; … … 200 191 G_TYPE_NONE, 201 192 1, G_TYPE_STRING ); 202 203 #ifdef HAVE_DBUS_GLIB 204 { 205 DBusGConnection * bus = dbus_g_bus_get( DBUS_BUS_SESSION, NULL ); 206 DBusGProxy * bus_proxy = NULL; 207 if( bus ) 208 bus_proxy = 209 dbus_g_proxy_new_for_name( bus, "org.freedesktop.DBus", 210 "/org/freedesktop/DBus", 211 "org.freedesktop.DBus" ); 212 if( bus_proxy ) 193 } 194 195 static void 196 handle_dbus_method( GDBusConnection * connection UNUSED, 197 const gchar * sender UNUSED, 198 const gchar * object_path, 199 const gchar * interface_name, 200 const gchar * method_name, 201 GVariant * parameters, 202 GDBusMethodInvocation * invocation, 203 gpointer core ) 204 { 205 gboolean handled = false; 206 207 if( !g_strcmp0( interface_name, TR_DBUS_SESSION_INTERFACE ) ) 208 { 209 if( !g_strcmp0( method_name, "TorrentAdd" ) ) 213 210 { 214 int result = 0; 215 dbus_g_proxy_call( bus_proxy, "RequestName", NULL, 216 G_TYPE_STRING, 217 "com.transmissionbt.Transmission", 218 G_TYPE_UINT, 0, 219 G_TYPE_INVALID, 220 G_TYPE_UINT, &result, 221 G_TYPE_INVALID ); 222 if( ( our_instance_adds_remote_torrents = result == 1 ) ) 223 dbus_g_object_type_install_info( 224 TR_CORE_TYPE, 225 &dbus_glib_gtr_core_object_info ); 211 GVariant * args = g_variant_get_child_value( parameters, 0 ); 212 GVariant * filename_variant = g_variant_lookup_value ( args, "filename", G_VARIANT_TYPE_STRING ); 213 char * filename = g_variant_dup_string( filename_variant, NULL ); 214 GSList * files = g_slist_append( NULL, filename ); 215 gtr_core_add_list_defaults( TR_CORE( core ), files, TRUE ); 216 g_dbus_method_invocation_return_value( invocation, g_variant_new( "(b)", true ) ); 217 handled = true; 226 218 } 227 219 } 228 #endif 220 else if( !g_strcmp0( interface_name, TR_DBUS_DISPLAY_INTERFACE ) ) 221 { 222 if( !g_strcmp0( method_name, "PresentWindow" ) ) 223 { 224 gtr_action_activate( "present-main-window" ); 225 g_dbus_method_invocation_return_value( invocation, NULL ); 226 handled = true; 227 } 228 } 229 230 if( !handled ) 231 g_warning( "Unhandled method call:\n\tObject Path: %s\n\tInterface Name: %s\n\tMethod Name: %s", 232 object_path, interface_name, method_name ); 233 }; 234 235 static void 236 on_session_registered_in_dbus( GDBusConnection *connection, const gchar *name UNUSED, gpointer core ) 237 { 238 GError * err = NULL; 239 GDBusNodeInfo * node_info; 240 GDBusInterfaceVTable vtable; 241 const char * interface_xml = "<node>" 242 " <interface name='" TR_DBUS_SESSION_INTERFACE "'>" 243 " <method name='TorrentAdd'>" 244 " <arg type='a{sv}' name='args' direction='in'/>" 245 " <arg type='b' name='response' direction='out'/>" 246 " </method>" 247 " </interface>" 248 "</node>"; 249 250 node_info = g_dbus_node_info_new_for_xml( interface_xml, &err ); 251 252 vtable.method_call = handle_dbus_method; 253 vtable.get_property = NULL; 254 vtable.set_property = NULL; 255 256 g_dbus_connection_register_object ( connection, 257 TR_DBUS_SESSION_OBJECT_PATH, 258 node_info->interfaces[0], 259 &vtable, 260 core, 261 NULL, 262 &err ); 263 264 if( err != NULL ) { 265 g_warning( "%s:%d Error registering object: %s", __FILE__, __LINE__, err->message ); 266 g_error_free( err ); 267 } 268 } 269 270 static void 271 on_display_registered_in_dbus( GDBusConnection *connection, const gchar *name UNUSED, gpointer core ) 272 { 273 GError * err = NULL; 274 const char * interface_xml = "<node>" 275 " <interface name='" TR_DBUS_DISPLAY_INTERFACE "'>" 276 " <method name='PresentWindow'>" 277 " </method>" 278 " </interface>" 279 "</node>"; 280 GDBusInterfaceVTable vtable = { .method_call=handle_dbus_method }; 281 GDBusNodeInfo * node_info = g_dbus_node_info_new_for_xml( interface_xml, &err ); 282 283 g_dbus_connection_register_object ( connection, 284 TR_DBUS_DISPLAY_OBJECT_PATH, 285 node_info->interfaces[0], 286 &vtable, 287 core, 288 NULL, 289 &err ); 290 291 if( err != NULL ) { 292 g_warning( "%s:%d Error registering object: %s", __FILE__, __LINE__, err->message ); 293 g_error_free( err ); 294 } 229 295 } 230 296 … … 266 332 g_object_unref( p->raw_model ); 267 333 268 #ifdef HAVE_DBUS_GLIB 269 if( our_instance_adds_remote_torrents ) 270 { 271 DBusGConnection * bus = dbus_g_bus_get( DBUS_BUS_SESSION, NULL ); 272 if( bus ) 273 dbus_g_connection_register_g_object( 274 bus, 275 "/com/transmissionbt/Transmission", 276 G_OBJECT( self ) ); 277 } 278 #endif 334 p->dbus_session_owner_id = g_bus_own_name( G_BUS_TYPE_SESSION, 335 TR_DBUS_SESSION_SERVICE_NAME, 336 G_BUS_NAME_OWNER_FLAGS_NONE, 337 NULL, 338 on_session_registered_in_dbus, 339 NULL, 340 self, 341 NULL ); 342 343 p->dbus_display_owner_id = g_bus_own_name( G_BUS_TYPE_SESSION, 344 TR_DBUS_DISPLAY_SERVICE_NAME, 345 G_BUS_NAME_OWNER_FLAGS_NONE, 346 NULL, 347 on_display_registered_in_dbus, 348 NULL, 349 self, 350 NULL ); 279 351 } 280 352 … … 634 706 ***/ 635 707 636 #ifdef HAVE_GIO637 638 708 struct watchdir_file 639 709 { … … 804 874 } 805 875 806 #endif807 808 876 /*** 809 877 **** … … 834 902 core_maybe_inhibit_hibernation( core ); 835 903 } 836 #ifdef HAVE_GIO837 904 else if( !strcmp( key, PREF_KEY_DIR_WATCH ) 838 905 || !strcmp( key, PREF_KEY_DIR_WATCH_ENABLED ) ) … … 840 907 core_watchdir_update( core ); 841 908 } 842 #endif843 909 } 844 910 … … 876 942 tr_sessionClose( session ); 877 943 } 944 945 g_bus_unown_name( core->priv->dbus_display_owner_id ); 946 g_bus_unown_name( core->priv->dbus_session_owner_id ); 878 947 } 879 948 … … 1147 1216 core_apply_defaults( ctor ); 1148 1217 core_add_ctor( core, ctor, do_prompt, do_notify ); 1149 }1150 1151 /* invoked remotely via dbus. */1152 gboolean1153 gtr_core_add_metainfo( TrCore * core,1154 const char * payload,1155 gboolean * setme_handled,1156 GError ** gerr UNUSED )1157 {1158 tr_session * session = gtr_core_session( core );1159 1160 if( !session )1161 {1162 *setme_handled = FALSE;1163 }1164 else if( gtr_is_supported_url( payload ) || gtr_is_magnet_link( payload ) )1165 {1166 gtr_core_add_from_url( core, payload );1167 *setme_handled = TRUE;1168 }1169 else /* base64-encoded metainfo */1170 {1171 int file_length;1172 tr_ctor * ctor;1173 char * file_contents;1174 gboolean do_prompt = gtr_pref_flag_get( PREF_KEY_OPTIONS_PROMPT );1175 1176 ctor = tr_ctorNew( session );1177 core_apply_defaults( ctor );1178 1179 file_contents = tr_base64_decode( payload, -1, &file_length );1180 tr_ctorSetMetainfo( ctor, (const uint8_t*)file_contents, file_length );1181 core_add_ctor( core, ctor, do_prompt, TRUE );1182 1183 tr_free( file_contents );1184 gtr_core_torrents_added( core );1185 *setme_handled = TRUE;1186 }1187 1188 return TRUE;1189 1218 } 1190 1219 … … 1522 1551 **/ 1523 1552 1524 #ifdef HAVE_DBUS_GLIB 1525 1526 static DBusGProxy* 1527 get_hibernation_inhibit_proxy( void ) 1528 { 1529 GError * error = NULL; 1530 const char * name = "org.gnome.SessionManager"; 1531 const char * path = "/org/gnome/SessionManager"; 1532 const char * interface = "org.gnome.SessionManager"; 1533 DBusGConnection * conn = dbus_g_bus_get( DBUS_BUS_SESSION, &error ); 1534 1535 if( error ) 1536 { 1537 g_warning ( "DBUS cannot connect : %s", error->message ); 1538 g_error_free ( error ); 1539 return NULL; 1540 } 1541 1542 return dbus_g_proxy_new_for_name ( conn, name, path, interface ); 1543 } 1553 #define SESSION_MANAGER_SERVICE_NAME "org.gnome.SessionManager" 1554 #define SESSION_MANAGER_INTERFACE "org.gnome.SessionManager" 1555 #define SESSION_MANAGER_OBJECT_PATH "/org/gnome/SessionManager" 1544 1556 1545 1557 static gboolean 1546 1558 gtr_inhibit_hibernation( guint * cookie ) 1547 1559 { 1548 gboolean success = FALSE; 1549 DBusGProxy * proxy = get_hibernation_inhibit_proxy( ); 1550 1551 if( proxy ) 1552 { 1553 GError * error = NULL; 1554 const int toplevel_xid = 0; 1555 const char * application = _( "Transmission Bittorrent Client" ); 1556 const char * reason = _( "BitTorrent Activity" ); 1557 const int flags = 4; /* Inhibit suspending the session or computer */ 1558 1559 success = dbus_g_proxy_call( proxy, "Inhibit", &error, 1560 G_TYPE_STRING, application, 1561 G_TYPE_UINT, toplevel_xid, 1562 G_TYPE_STRING, reason, 1563 G_TYPE_UINT, flags, 1564 G_TYPE_INVALID, /* sentinel - end of input args */ 1565 G_TYPE_UINT, cookie, 1566 G_TYPE_INVALID /* senitnel - end of output args */ ); 1567 1568 if( success ) 1569 tr_inf( "%s", _( "Disallowing desktop hibernation" ) ); 1570 else 1571 { 1572 tr_err( _( "Couldn't disable desktop hibernation: %s" ), 1573 error->message ); 1574 g_error_free( error ); 1575 } 1576 1577 g_object_unref( G_OBJECT( proxy ) ); 1578 } 1579 1580 return success != 0; 1560 gboolean success; 1561 GVariant * response; 1562 GDBusConnection * connection; 1563 GError * err = NULL; 1564 const char * application = "Transmission BitTorrent Client"; 1565 const char * reason = "BitTorrent Activity"; 1566 const int toplevel_xid = 0; 1567 const int flags = 4; /* Inhibit suspending the session or computer */ 1568 1569 connection = g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, &err ); 1570 1571 response = g_dbus_connection_call_sync( connection, 1572 SESSION_MANAGER_SERVICE_NAME, 1573 SESSION_MANAGER_OBJECT_PATH, 1574 SESSION_MANAGER_INTERFACE, 1575 "Inhibit", 1576 g_variant_new( "(susu)", application, toplevel_xid, reason, flags ), 1577 NULL, G_DBUS_CALL_FLAGS_NONE, 1578 1000, NULL, &err ); 1579 1580 *cookie = g_variant_get_uint32( g_variant_get_child_value( response, 0 ) ); 1581 1582 success = err == NULL; 1583 1584 /* logging */ 1585 if( success ) 1586 tr_inf( "%s", _( "Inhibiting desktop hibernation" ) ); 1587 else { 1588 tr_err( _( "Couldn't inhibit desktop hibernation: %s" ), err->message ); 1589 g_error_free( err ); 1590 } 1591 1592 /* cleanup */ 1593 g_variant_unref( response ); 1594 g_object_unref( connection ); 1595 return success; 1581 1596 } 1582 1597 … … 1584 1599 gtr_uninhibit_hibernation( guint inhibit_cookie ) 1585 1600 { 1586 DBusGProxy * proxy = get_hibernation_inhibit_proxy( ); 1587 1588 if( proxy ) 1589 { 1590 GError * error = NULL; 1591 gboolean success = dbus_g_proxy_call( proxy, "Uninhibit", &error, 1592 G_TYPE_UINT, inhibit_cookie, 1593 G_TYPE_INVALID, 1594 G_TYPE_INVALID ); 1595 if( success ) 1596 tr_inf( "%s", _( "Allowing desktop hibernation" ) ); 1597 else 1598 { 1599 g_warning( "Couldn't uninhibit the system from suspending: %s.", 1600 error->message ); 1601 g_error_free( error ); 1602 } 1603 1604 g_object_unref( G_OBJECT( proxy ) ); 1605 } 1606 } 1607 1608 #endif 1601 GVariant * response; 1602 GDBusConnection * connection; 1603 GError * err = NULL; 1604 1605 connection = g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, &err ); 1606 1607 response = g_dbus_connection_call_sync( connection, 1608 SESSION_MANAGER_SERVICE_NAME, 1609 SESSION_MANAGER_OBJECT_PATH, 1610 SESSION_MANAGER_INTERFACE, 1611 "Uninhibit", 1612 g_variant_new( "(u)", inhibit_cookie ), 1613 NULL, G_DBUS_CALL_FLAGS_NONE, 1614 1000, NULL, &err ); 1615 1616 /* logging */ 1617 if( err == NULL ) 1618 tr_inf( "%s", _( "Allowing desktop hibernation" ) ); 1619 else { 1620 g_warning( "Couldn't uninhibit desktop hibernation: %s.", err->message ); 1621 g_error_free( err ); 1622 } 1623 1624 /* cleanup */ 1625 g_variant_unref( response ); 1626 g_object_unref( connection ); 1627 } 1609 1628 1610 1629 static void 1611 1630 gtr_core_set_hibernation_allowed( TrCore * core, gboolean allowed ) 1612 1631 { 1613 #ifdef HAVE_DBUS_GLIB1614 1632 g_return_if_fail( core ); 1615 1633 g_return_if_fail( core->priv ); … … 1632 1650 core->priv->dbus_error = TRUE; 1633 1651 } 1634 #endif1635 1652 } 1636 1653 … … 1919 1936 } 1920 1937 } 1921 1922 gboolean1923 gtr_core_present_window( TrCore * core UNUSED,1924 gboolean * success,1925 GError ** err UNUSED )1926 {1927 /* Setting the toggle-main-window GtkCheckMenuItem to1928 make sure its state is correctly set */1929 gtr_action_set_toggled( "toggle-main-window", TRUE);1930 1931 *success = TRUE;1932 return TRUE;1933 } -
trunk/gtk/tr-core.h
r12607 r12638 117 117 gboolean do_notify ); 118 118 119 /** @brief Add a torrent. */120 gboolean gtr_core_add_metainfo( TrCore * core,121 const char * base64_metainfo,122 gboolean * setme_success,123 GError ** err );124 119 125 120 /** @brief Add a torrent from a URL */ … … 132 127 /** Add a torrent. */ 133 128 void gtr_core_add_torrent( TrCore*, tr_torrent*, gboolean do_notify ); 134 135 /** Present the main window */136 gboolean gtr_core_present_window( TrCore*, gboolean * setme_success, GError ** err );137 129 138 130 /** … … 208 200 }; 209 201 202 203 #define TR_DBUS_SESSION_SERVICE_NAME "com.transmissionbt.transmission.Session" 204 #define TR_DBUS_SESSION_INTERFACE "com.transmissionbt.transmission.Session" 205 #define TR_DBUS_SESSION_OBJECT_PATH "/com/transmissionbt/transmission/Session" 206 207 #define TR_DBUS_DISPLAY_SERVICE_NAME "com.transmissionbt.transmission.Display" 208 #define TR_DBUS_DISPLAY_INTERFACE "com.transmissionbt.transmission.Display" 209 #define TR_DBUS_DISPLAY_OBJECT_PATH "/com/transmissionbt/transmission/Display" 210 211 210 212 #endif /* GTR_CORE_H */ -
trunk/gtk/tr-prefs.c
r12636 r12638 338 338 hig_workarea_add_wide_control( t, &row, w ); 339 339 340 #ifdef HAVE_GIO341 340 s = _( "Automatically _add torrents from:" ); 342 341 l = new_check_button( s, PREF_KEY_DIR_WATCH_ENABLED, core ); 343 342 w = new_path_chooser_button( PREF_KEY_DIR_WATCH, core ); 344 gtk_widget_set_sensitive( GTK_WIDGET( w ), 345 gtr_pref_flag_get( PREF_KEY_DIR_WATCH_ENABLED ) ); 343 gtk_widget_set_sensitive( GTK_WIDGET( w ), gtr_pref_flag_get( PREF_KEY_DIR_WATCH_ENABLED ) ); 346 344 g_signal_connect( l, "toggled", G_CALLBACK( target_cb ), w ); 347 345 hig_workarea_add_row_w( t, &row, l, w, NULL ); 348 #endif349 346 350 347 hig_workarea_add_section_divider( t, &row ); -
trunk/gtk/util.c
r12592 r12638 23 23 #include <glib/gi18n.h> 24 24 #include <glib/gstdio.h> /* g_unlink() */ 25 #ifdef HAVE_GIO 26 #include <gio/gio.h> /* g_file_trash() */ 27 #endif 28 #ifdef HAVE_DBUS_GLIB 29 #include <dbus/dbus-glib.h> 30 #endif 25 #include <gio/gio.h> /* g_file_trash() */ 31 26 32 27 #include <libtransmission/transmission.h> /* TR_RATIO_NA, TR_RATIO_INF */ … … 36 31 37 32 #include "hig.h" 33 #include "tr-core.h" /* dbus names */ 38 34 #include "util.h" 39 35 … … 195 191 } 196 192 197 int198 gtr_mkdir_with_parents( const char * path, int mode )199 {200 #if GLIB_CHECK_VERSION( 2, 8, 0 )201 return !g_mkdir_with_parents( path, mode );202 #else203 return !tr_mkdirp( path, mode );204 #endif205 }206 207 193 /* pattern-matching text; ie, legaltorrents.com */ 208 194 void … … 362 348 } 363 349 364 gpointer365 gtr_object_ref_sink( gpointer object )366 {367 #if GLIB_CHECK_VERSION( 2, 10, 0 )368 g_object_ref_sink( object );369 #else370 g_object_ref( object );371 gtk_object_sink( GTK_OBJECT( object ) );372 #endif373 return object;374 }375 376 350 int 377 351 gtr_file_trash_or_remove( const char * filename ) … … 380 354 { 381 355 gboolean trashed = FALSE; 382 #ifdef HAVE_GIO383 356 GError * err = NULL; 384 357 GFile * file = g_file_new_for_path( filename ); … … 388 361 g_clear_error( &err ); 389 362 g_object_unref( G_OBJECT( file ) ); 390 #endif391 363 392 364 if( !trashed && g_remove( filename ) ) … … 421 393 char * uri = NULL; 422 394 423 #ifdef HAVE_GIO424 395 GFile * file = g_file_new_for_path( path ); 425 396 uri = g_file_get_uri( file ); 426 397 g_object_unref( G_OBJECT( file ) ); 427 #else 398 428 399 if( g_path_is_absolute( path ) ) 429 400 uri = g_strdup_printf( "file://%s", path ); … … 433 404 g_free( cwd ); 434 405 } 435 #endif436 406 437 407 gtr_open_uri( uri ); … … 451 421 #endif 452 422 453 #ifdef HAVE_GIO454 423 if( !opened ) 455 424 opened = g_app_info_launch_default_for_uri( uri, NULL, NULL ); 456 #endif457 425 458 426 if( !opened ) { … … 467 435 } 468 436 469 #define VALUE_SERVICE_NAME "com.transmissionbt.Transmission"470 #define VALUE_SERVICE_OBJECT_PATH "/com/transmissionbt/Transmission"471 #define VALUE_SERVICE_INTERFACE "com.transmissionbt.Transmission"472 473 437 gboolean 474 438 gtr_dbus_add_torrent( const char * filename ) 475 439 { 476 /* FIXME: why is this static? */ 477 static gboolean handled = FALSE; 478 479 #ifdef HAVE_DBUS_GLIB 480 char * payload; 481 gsize file_length; 482 char * file_contents = NULL; 483 484 /* If it's a file, load its contents and send them over the wire... 485 * it might be a temporary file that's going to disappear. */ 486 if( g_file_get_contents( filename, &file_contents, &file_length, NULL ) ) 487 payload = tr_base64_encode( file_contents, file_length, NULL ); 488 else if( gtr_is_supported_url( filename ) || gtr_is_magnet_link( filename ) ) 489 payload = tr_strdup( filename ); 490 else 491 payload = NULL; 492 493 if( payload != NULL ) 494 { 495 GError * err = NULL; 496 DBusGConnection * conn; 497 DBusGProxy * proxy = NULL; 498 499 if(( conn = dbus_g_bus_get( DBUS_BUS_SESSION, &err ))) 500 proxy = dbus_g_proxy_new_for_name (conn, VALUE_SERVICE_NAME, 501 VALUE_SERVICE_OBJECT_PATH, 502 VALUE_SERVICE_INTERFACE ); 503 else if( err ) 504 g_message( "err: %s", err->message ); 505 506 if( proxy ) 507 dbus_g_proxy_call( proxy, "AddMetainfo", &err, 508 G_TYPE_STRING, payload, 509 G_TYPE_INVALID, 510 G_TYPE_BOOLEAN, &handled, 511 G_TYPE_INVALID ); 512 if( err ) 513 g_message( "err: %s", err->message ); 514 515 if( proxy ) 516 g_object_unref( proxy ); 517 if( conn ) 518 dbus_g_connection_unref( conn ); 519 520 tr_free( payload ); 521 } 522 523 g_free( file_contents ); 524 525 #endif 440 GVariant * response; 441 GVariant * args; 442 GVariant * parameters; 443 GVariantBuilder * builder; 444 GDBusConnection * connection; 445 GError * err = NULL; 446 gboolean handled = FALSE; 447 448 /* "args" is a dict as described in the RPC spec's "torrent-add" section */ 449 builder = g_variant_builder_new( G_VARIANT_TYPE( "a{sv}" ) ); 450 g_variant_builder_add( builder, "{sv}", "filename", g_variant_new_string( filename ) ); 451 args = g_variant_builder_end( builder ); 452 parameters = g_variant_new_tuple( &args, 1 ); 453 g_variant_builder_unref( builder ); 454 455 connection = g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, &err ); 456 457 response = g_dbus_connection_call_sync( connection, 458 TR_DBUS_SESSION_SERVICE_NAME, 459 TR_DBUS_SESSION_OBJECT_PATH, 460 TR_DBUS_SESSION_INTERFACE, 461 "TorrentAdd", 462 parameters, 463 G_VARIANT_TYPE_TUPLE, 464 G_DBUS_CALL_FLAGS_NONE, 465 10000, /* wait 10 sec */ 466 NULL, 467 &err ); 468 469 470 handled = g_variant_get_boolean( g_variant_get_child_value( response, 0 ) ); 471 472 g_object_unref( connection ); 473 g_variant_unref( response ); 526 474 return handled; 527 475 } … … 530 478 gtr_dbus_present_window( void ) 531 479 { 532 static gboolean success = FALSE; 533 534 #ifdef HAVE_DBUS_GLIB 535 DBusGProxy * proxy = NULL; 536 GError * err = NULL; 537 DBusGConnection * conn; 538 if( ( conn = dbus_g_bus_get( DBUS_BUS_SESSION, &err ) ) ) 539 proxy = dbus_g_proxy_new_for_name ( conn, VALUE_SERVICE_NAME, 540 VALUE_SERVICE_OBJECT_PATH, 541 VALUE_SERVICE_INTERFACE ); 542 else if( err ) 543 g_message( "err: %s", err->message ); 544 if( proxy ) 545 dbus_g_proxy_call( proxy, "PresentWindow", &err, 546 G_TYPE_INVALID, 547 G_TYPE_BOOLEAN, &success, 548 G_TYPE_INVALID ); 549 if( err ) 550 g_message( "err: %s", err->message ); 551 552 g_object_unref( proxy ); 553 dbus_g_connection_unref( conn ); 554 #endif 480 gboolean success; 481 GDBusConnection * connection; 482 GError * err = NULL; 483 484 connection = g_bus_get_sync( G_BUS_TYPE_SESSION, NULL, &err ); 485 486 g_dbus_connection_call_sync( connection, 487 TR_DBUS_DISPLAY_SERVICE_NAME, 488 TR_DBUS_DISPLAY_OBJECT_PATH, 489 TR_DBUS_DISPLAY_INTERFACE, 490 "PresentWindow", 491 NULL, 492 NULL, G_DBUS_CALL_FLAGS_NONE, 493 1000, NULL, &err ); 494 495 success = err == NULL; 496 497 /* cleanup */ 498 if( err != NULL ) 499 g_error_free( err ); 500 g_object_unref( connection ); 555 501 return success; 556 502 } -
trunk/gtk/util.h
r12412 r12638 109 109 ***/ 110 110 111 /* backwards-compatible wrapper around g_mkdir_with_parents() */112 int gtr_mkdir_with_parents( const char *name, int mode );113 114 111 /* backwards-compatible wrapper around gdk_threads_add_timeout_seconds() */ 115 112 guint gtr_timeout_add_seconds( guint seconds, GSourceFunc func, gpointer data ); … … 129 126 /* backwards-compatible wrapper around gtk_widget_set_visible() */ 130 127 void gtr_widget_set_visible( GtkWidget *, gboolean ); 131 132 /* backwards-compatible wrapper around g_object_ref_sink() */133 gpointer gtr_object_ref_sink( gpointer object );134 128 135 129 void gtr_dialog_set_content( GtkDialog * dialog, GtkWidget * content ); -
trunk/transmission-gtk.spec.in
r12578 r12638 27 27 Requires: glib2 >= @GLIB_MINIMUM@ 28 28 Requires: gtk2 >= @GTK_MINIMUM@ 29 # OPTIONAL for the gtk+ client... see configure.ac for details30 BuildRequires: dbus-glib-devel >= @DBUS_GLIB_MINIMUM@31 Requires: dbus-glib >= @DBUS_GLIB_MINIMUM@32 29 33 30 Provides: %{name}
Note: See TracChangeset
for help on using the changeset viewer.