From: Mark D. <the...@us...> - 2005-06-14 04:13:20
|
Update of /cvsroot/gaim/gaim/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16880/src Modified Files: gtkmain.c gtkft.c gtkft.h Log Message: sf patch #1207058, from Dave Ahlswede (with tweaks by me) Enable opening received files in GNOME by using gnome-open Thank to grim and rlaager for help testing. Index: gtkmain.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkmain.c,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -p -r1.26 -r1.27 --- gtkmain.c 25 Apr 2005 04:22:11 -0000 1.26 +++ gtkmain.c 14 Jun 2005 04:13:10 -0000 1.27 @@ -289,6 +289,7 @@ gaim_gtk_quit(void) gaim_gtk_status_uninit(); gaim_gtk_blist_uninit(); gaim_gtk_account_uninit(); + gaim_gtk_xfers_uninit(); /* and end it all... */ gtk_main_quit(); Index: gtkft.c =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkft.c,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -p -r1.63 -r1.64 --- gtkft.c 16 May 2005 00:47:41 -0000 1.63 +++ gtkft.c 14 Jun 2005 04:13:10 -0000 1.64 @@ -292,12 +292,20 @@ update_buttons(GaimGtkXferDialog *dialog gtk_widget_hide(dialog->stop_button); gtk_widget_show(dialog->remove_button); -#ifdef _WIN32 /* Only supported in Win32 right now */ +#ifdef _WIN32 + /* If using Win32... */ if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE) { gtk_widget_set_sensitive(dialog->open_button, TRUE); } else { gtk_widget_set_sensitive(dialog->open_button, FALSE); } +#else + /* If using GNOME, use gnome-open */ + if (gaim_xfer_get_type(xfer) == GAIM_XFER_RECEIVE && gaim_running_gnome()) { + gtk_widget_set_sensitive(dialog->open_button, TRUE); + } else { + gtk_widget_set_sensitive (dialog->open_button, FALSE); + } #endif gtk_widget_set_sensitive(dialog->pause_button, FALSE); gtk_widget_set_sensitive(dialog->resume_button, FALSE); @@ -406,14 +414,15 @@ selection_changed_cb(GtkTreeSelection *s static void open_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) { -#ifdef _WIN32 /* Only supported in Win32 right now */ +#ifdef _WIN32 + /* If using Win32... */ int code; if (G_WIN32_HAVE_WIDECHAR_API ()) { wchar_t *wc_filename = g_utf8_to_utf16( gaim_xfer_get_local_filename( dialog->selected_xfer), -1, NULL, NULL, NULL); - + code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, SW_SHOW); @@ -423,7 +432,7 @@ open_button_cb(GtkButton *button, GaimGt gaim_xfer_get_local_filename( dialog->selected_xfer), -1, NULL, NULL, NULL); - + code = (int) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, SW_SHOW); @@ -432,16 +441,49 @@ open_button_cb(GtkButton *button, GaimGt if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) { - gaim_notify_error(NULL, NULL, + gaim_notify_error(dialog, NULL, _("There is no application configured to open this type of file."), NULL); } else if (code < 32) { - gaim_notify_error(NULL, NULL, + gaim_notify_error(dialog, NULL, _("An error occurred while opening the file."), NULL); gaim_debug_warning("ft", "filename: %s; code: %d\n", gaim_xfer_get_local_filename(dialog->selected_xfer), code); } +#else + /* If using GNOME, use gnome-open */ + if (gaim_running_gnome()) + { + char *command = NULL; + char *tmp = NULL; + GError *error = NULL; + + command = g_strdup_printf("gnome-open \"%s\"", + gaim_xfer_get_local_filename(dialog->selected_xfer)); + + if (gaim_program_is_valid(command)) + { + gint exit_status; + if (!g_spawn_command_line_sync(command, NULL, NULL, &exit_status, &error)) + { + tmp = g_strdup_printf(_("Error launching %s: %s"), + gaim_xfer_get_local_filename(dialog->selected_xfer), + error->message); + gaim_notify_error(dialog, NULL, _("Unable to open file."), tmp); + g_free(tmp); + g_error_free(error); + } + if (exit_status != 0) + { + char *primary = g_strdup_printf(_("Error running %s"), command); + char *secondary = g_strdup_printf(_("Process returned error code %d"), + exit_status); + gaim_notify_error(dialog, NULL, primary, secondary); + g_free(tmp); + } + } + } #endif } @@ -785,6 +827,8 @@ gaim_gtkxfer_dialog_destroy(GaimGtkXferD { g_return_if_fail(dialog != NULL); + gaim_notify_close_with_handle(dialog); + gtk_widget_destroy(dialog->window); g_free(dialog); @@ -803,6 +847,8 @@ gaim_gtkxfer_dialog_hide(GaimGtkXferDial { g_return_if_fail(dialog != NULL); + gaim_notify_close_with_handle(dialog); + gtk_widget_hide(dialog->window); } @@ -1092,6 +1138,12 @@ gaim_gtk_xfers_init(void) } void +gaim_gtk_xfers_uninit(void) +{ + gaim_gtkxfer_dialog_destroy(xfer_dialog); +} + +void gaim_set_gtkxfer_dialog(GaimGtkXferDialog *dialog) { xfer_dialog = dialog; Index: gtkft.h =================================================================== RCS file: /cvsroot/gaim/gaim/src/gtkft.h,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -p -r1.13 -r1.14 --- gtkft.h 8 Aug 2004 05:37:58 -0000 1.13 +++ gtkft.h 14 Jun 2005 04:13:11 -0000 1.14 @@ -121,6 +121,11 @@ void gaim_gtkxfer_dialog_update_xfer(Gai void gaim_gtk_xfers_init(void); /** + * Uninitializes the GTK+ file transfer system. + */ +void gaim_gtk_xfers_uninit(void); + +/** * Sets gaim's main file transfer dialog. * * @param dialog The main dialog. |