static void export_completed_with_success (DialogData *data) { GtkWidget *dialog; gth_task_dialog (GTH_TASK (data->service), TRUE, NULL); dialog = _gtk_message_dialog_new (GTK_WINDOW (data->browser), GTK_DIALOG_MODAL, NULL, _("Files successfully uploaded to the server."), NULL, _GTK_LABEL_CLOSE, GTK_RESPONSE_CLOSE, _("_Open in the Browser"), _OPEN_IN_BROWSER_RESPONSE, NULL); g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (dialog, "response", G_CALLBACK (completed_messagedialog_response_cb), data); gtk_window_present (GTK_WINDOW (dialog)); }
void show_help_dialog (GtkWindow *parent, const char *section) { char *uri; GError *error = NULL; uri = g_strconcat ("help:engrampa", section ? "/" : NULL, section, NULL); if (! gtk_show_uri_on_window (parent, uri, GDK_CURRENT_TIME, &error)) { GtkWidget *dialog; dialog = _gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, "dialog-error", _("Could not display help"), error->message, "gtk-ok", GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_widget_show (dialog); g_clear_error (&error); } g_free (uri); }
void gth_browser_activate_action_catalog_remove (GtkAction *action, GthBrowser *browser) { GthFileData *file_data; GSettings *settings; file_data = gth_browser_get_folder_popup_file_data (browser); settings = g_settings_new (GTHUMB_MESSAGES_SCHEMA); if (g_settings_get_boolean (settings, PREF_MSG_CONFIRM_DELETION)) { char *prompt; GtkWidget *d; prompt = g_strdup_printf (_("Are you sure you want to remove \"%s\"?"), g_file_info_get_display_name (file_data->info)); d = _gtk_message_dialog_new (GTK_WINDOW (browser), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, prompt, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_REMOVE, GTK_RESPONSE_YES, NULL); g_signal_connect (d, "response", G_CALLBACK (remove_catalog_response_cb), file_data); gtk_widget_show (d); g_free (prompt); } else { remove_catalog (GTK_WINDOW (browser), file_data); g_object_unref (file_data); } g_object_unref (settings); }
void _gtk_error_dialog_run (GtkWindow *parent, const gchar *main_message, const gchar *format, ...) { GtkWidget *d; char *message; va_list args; va_start (args, format); message = g_strdup_vprintf (format, args); va_end (args); d = _gtk_message_dialog_new (parent, GTK_DIALOG_MODAL, "dialog-error", main_message, message, "gtk-close", GTK_RESPONSE_CANCEL, NULL); g_free (message); g_signal_connect (G_OBJECT (d), "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (d); }
static void show_authentication_error_dialog (WebService *self, GError **error) { GtkWidget *dialog; if (g_error_matches (*error, WEB_SERVICE_ERROR, WEB_SERVICE_ERROR_TOKEN_EXPIRED)) { web_service_ask_authorization (self); return; } dialog = _gtk_message_dialog_new (GTK_WINDOW (self->priv->browser), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_ERROR, _("Could not connect to the server"), (*error)->message, _("Choose _Account..."), WEB_AUTHENTICATION_RESPONSE_CHOOSE_ACCOUNT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); gth_task_dialog (GTH_TASK (self), TRUE, dialog); g_signal_connect (dialog, "delete-event", G_CALLBACK (gtk_true), NULL); g_signal_connect (dialog, "response", G_CALLBACK (authentication_error_dialog_response_cb), self); gtk_widget_show (dialog); g_clear_error (error); }
void dlg_package_installer (FrWindow *window, FrArchive *archive, FrAction action) { InstallerData *idata; GType command_type; FrCommand *command; idata = g_new0 (InstallerData, 1); idata->window = g_object_ref (window); idata->archive = g_object_ref (archive); idata->action = action; command_type = get_preferred_command_for_mime_type (idata->archive->content_type, FR_COMMAND_CAN_READ_WRITE); if (command_type == 0) command_type = get_preferred_command_for_mime_type (idata->archive->content_type, FR_COMMAND_CAN_READ); if (command_type == 0) { package_installer_terminated (idata, FR_PROC_ERROR_GENERIC, _("Archive type not supported.")); return; } command = g_object_new (command_type, 0); idata->packages = fr_command_get_packages (command, idata->archive->content_type); g_object_unref (command); if (idata->packages == NULL) { package_installer_terminated (idata, FR_PROC_ERROR_GENERIC, _("Archive type not supported.")); return; } #ifdef ENABLE_PACKAGEKIT { char *secondary_text; GtkWidget *dialog; secondary_text = g_strdup_printf (_("There is no command installed for %s files.\nDo you want to search for a command to open this file?"), g_content_type_get_description (idata->archive->content_type)); dialog = _gtk_message_dialog_new (GTK_WINDOW (idata->window), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_ERROR, _("Could not open this file type"), secondary_text, GTK_STOCK_CANCEL, GTK_RESPONSE_NO, _("_Search Command"), GTK_RESPONSE_YES, NULL); g_signal_connect (dialog, "response", G_CALLBACK (confirm_search_dialog_response_cb), idata); gtk_widget_show (dialog); g_free (secondary_text); } #else /* ! ENABLE_PACKAGEKIT */ package_installer_terminated (idata, FR_PROC_ERROR_GENERIC, _("Archive type not supported.")); #endif /* ENABLE_PACKAGEKIT */ }
void extensions__dlg_preferences_apply (GtkWidget *dialog, GthBrowser *browser, GtkBuilder *dialog_builder) { BrowserData *data; GList *active_extensions; GthExtensionManager *manager; GList *extension_names; GList *scan; data = g_object_get_data (G_OBJECT (dialog), BROWSER_DATA_KEY); g_return_if_fail (data != NULL); active_extensions = NULL; manager = gth_main_get_default_extension_manager (); extension_names = gth_extension_manager_get_extensions (manager); for (scan = extension_names; scan; scan = scan->next) { char *extension_name = scan->data; GthExtensionDescription *description; description = gth_extension_manager_get_description (manager, extension_name); if ((description == NULL) || description->mandatory || description->hidden) continue; if (gth_extension_description_is_active (description)) active_extensions = g_list_prepend (active_extensions, g_strdup (extension_name)); } active_extensions = g_list_reverse (active_extensions); _g_settings_set_string_list (data->settings, PREF_GENERAL_ACTIVE_EXTENSIONS, active_extensions); if (! list_equal (active_extensions, data->active_extensions)) { GtkWidget *dialog; int response; dialog = _gtk_message_dialog_new (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, _GTK_ICON_NAME_DIALOG_WARNING, _("Restart required"), _("You need to restart gthumb for these changes to take effect"), _("_Continue"), GTK_RESPONSE_CANCEL, _("_Restart"), GTK_RESPONSE_OK, NULL); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_OK) gth_quit (TRUE); } g_list_foreach (active_extensions, (GFunc) g_free, NULL); g_list_free (active_extensions); g_list_free (extension_names); }
static void delete_script_cb (GtkButton *button, DialogData *data) { GtkWidget *d; int result; GtkTreeSelection *selection; GtkTreeModel *model = GTK_TREE_MODEL (data->list_store); GtkTreeIter iter; GthScript *script; GthScriptFile *script_file; d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, _("Are you sure you want to delete the selected command?"), NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_DELETE, GTK_RESPONSE_OK, NULL); result = gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); if (result != GTK_RESPONSE_OK) return; selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (data->list_view)); if (! gtk_tree_selection_get_selected (selection, &model, &iter)) return; gtk_tree_model_get (model, &iter, COLUMN_SCRIPT, &script, -1); if (script == NULL) return; /* update the script file */ script_file = gth_script_file_get (); g_signal_handlers_block_by_func (script_file, scripts_changed_cb, data); gth_script_file_remove (script_file, script); gth_script_file_save (script_file, NULL); g_signal_handlers_unblock_by_func (script_file, scripts_changed_cb, data); /* update the script list */ g_signal_handlers_block_by_func (data->list_store, row_deleted_cb, data); gtk_list_store_remove (data->list_store, &iter); g_signal_handlers_unblock_by_func (data->list_store, row_deleted_cb, data); g_object_unref (script); }
void fm__gth_browser_folder_tree_drag_data_received_cb (GthBrowser *browser, GthFileData *destination, GList *file_list, GdkDragAction action) { GthFileSource *file_source; GthTask *task; if (destination == NULL) return; file_source = gth_main_get_file_source (destination->file); if (file_source == NULL) return; if ((action == GDK_ACTION_MOVE) && ! gth_file_source_can_cut (file_source, (GFile *) file_list->data)) { GtkWidget *dialog; int response; dialog = _gtk_message_dialog_new (GTK_WINDOW (browser), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, _("Could not move the files"), _("Files cannot be moved to the current location, as alternative you can choose to copy them."), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_COPY, GTK_RESPONSE_OK, NULL); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_CANCEL) return; action = GDK_ACTION_COPY; } task = gth_copy_task_new (file_source, destination, (action == GDK_ACTION_MOVE), file_list, -1); gth_browser_exec_task (browser, task, FALSE); g_object_unref (task); g_object_unref (file_source); }
static void nautilus_cache_remove_old_previews_async (gboolean recursive, gboolean clear_all) { NautilusCacheRemoveData *ncrd; const char *message; if (clear_all) message = _("Deleting all thumbnails, wait please..."); else message = _("Deleting old thumbnails, wait please..."); ncrd = g_new0 (NautilusCacheRemoveData, 1); ncrd->recursive = recursive; ncrd->clear_all = clear_all; ncrd->dirs = NULL; ncrd->visited_dirs = NULL; ncrd->interrupted = FALSE; ncrd->process_timeout = 0; ncrd->handle = NULL; ncrd->nautilus_thumb_dir = g_strconcat (g_get_home_dir (), "/.thumbnails", NULL); ncrd->nautilus_thumb_dir_l = strlen (ncrd->nautilus_thumb_dir); ncrd->dialog = _gtk_message_dialog_new (NULL, GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, message, NULL, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL); g_signal_connect (G_OBJECT (ncrd->dialog), "response", G_CALLBACK (ncrop_interrupt_cb), ncrd); gtk_widget_show (ncrd->dialog); visit_dir_async (ncrd->nautilus_thumb_dir, ncrd); }
void _gtk_error_dialog_from_gerror_show (GtkWindow *parent, const char *title, GError **gerror) { GtkWidget *d; d = _gtk_message_dialog_new (parent, GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_DIALOG_ERROR, title, (gerror != NULL) ? (*gerror)->message : NULL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); g_signal_connect (d, "response", G_CALLBACK (error_dialog_response_cb), NULL); gtk_window_present (GTK_WINDOW (d)); if (gerror != NULL) g_clear_error (gerror); }
void _gtk_error_dialog_from_gerror_run (GtkWindow *parent, const char *title, GError **gerror) { GtkWidget *d; g_return_if_fail (*gerror != NULL); d = _gtk_message_dialog_new (parent, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_DIALOG_ERROR, title, (*gerror)->message, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (d); g_clear_error (gerror); }
static void add_clicked_cb (GtkWidget *widget, DialogData *data) { FrWindow *window = data->window; char *archive_name; char *archive_dir; char *archive_file; char *tmp; const char *archive_ext; gboolean do_not_add = FALSE; GError *error = NULL; data->add_clicked = TRUE; /* Collect data */ archive_name = g_uri_escape_string (gtk_entry_get_text (GTK_ENTRY (data->a_add_to_entry)), NULL, FALSE); /* Check whether the user entered a valid archive name. */ if ((archive_name == NULL) || (*archive_name == '\0')) { GtkWidget *d; d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Could not create the archive"), "%s", _("You have to specify an archive name.")); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (archive_name); return; } else if (strchrs (archive_name, BAD_CHARS)) { GtkWidget *d; char *utf8_name = g_filename_display_name (archive_name); d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Could not create the archive"), _("The name \"%s\" is not valid because it cannot contain the characters: %s\n\n%s"), utf8_name, BAD_CHARS, _("Please use a different name.")); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (utf8_name); g_free (archive_name); return; } /* Check directory existence. */ archive_dir = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (data->a_location_filechooserbutton)); if (archive_dir == NULL) { g_free (archive_dir); g_free (archive_name); return; } if (! check_permissions (archive_dir, R_OK|W_OK|X_OK)) { GtkWidget *d; d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Could not create the archive"), "%s", _("You don't have the right permissions to create an archive in the destination folder.")); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (archive_dir); g_free (archive_name); return; } if (! uri_is_dir (archive_dir)) { GtkWidget *d; int r; char *folder_name; char *msg; folder_name = g_filename_display_name (archive_dir); msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name); g_free (folder_name); d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, msg, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Create _Folder"), GTK_RESPONSE_YES, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES); r = gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (msg); do_not_add = (r != GTK_RESPONSE_YES); } if (! do_not_add && ! ensure_dir_exists (archive_dir, 0755, &error)) { GtkWidget *d; d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Could not create the archive"), _("Could not create the destination folder: %s."), error->message); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_error_free (error); g_free (archive_dir); g_free (archive_name); return; } if (do_not_add) { GtkWidget *d; d = _gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_DIALOG_WARNING, _("Archive not created"), NULL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (archive_dir); g_free (archive_name); return; } /**/ archive_ext = get_ext (data); tmp = archive_name; archive_name = g_strconcat (tmp, archive_ext, NULL); g_free (tmp); archive_file = g_strconcat (archive_dir, "/", archive_name, NULL); if (uri_is_dir (archive_file)) { GtkWidget *d; d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Could not create the archive"), "%s", _("You have to specify an archive name.")); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (archive_name); g_free (archive_dir); g_free (archive_file); return; } if (uri_exists (archive_file)) { GtkWidget *d; int r; d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, _("The archive is already present. Do you want to overwrite it?"), NULL, GTK_STOCK_NO, GTK_RESPONSE_NO, _("_Overwrite"), GTK_RESPONSE_YES, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES); r = gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); if (r == GTK_RESPONSE_YES) { GFile *file; GError *err = NULL; /* FIXME: convert this code in a function in file-utils.c */ file = g_file_new_for_uri (archive_file); g_file_delete (file, NULL, &err); if (err != NULL) { g_warning ("Failed to delete file %s: %s", archive_file, err->message); g_clear_error (&err); } g_object_unref (file); } else { g_free (archive_name); g_free (archive_dir); g_free (archive_file); return; } } set_archive_options (data); gtk_widget_destroy (data->dialog); fr_window_archive_new (window, archive_file); g_free (archive_name); g_free (archive_dir); g_free (archive_file); }
static int goo_application_command_line (GApplication *application, GApplicationCommandLine *command_line) { char **argv; int argc; GOptionContext *options_context; GError *error = NULL; GtkWidget *window; argv = g_application_command_line_get_arguments (command_line, &argc); options_context = goo_application_create_option_context (); if (! g_option_context_parse (options_context, &argc, &argv, &error)) { g_critical ("Failed to parse arguments: %s", error->message); g_error_free (error); g_option_context_free (options_context); return goo_application_command_line_finished (application, EXIT_FAILURE); } g_option_context_free (options_context); /* check the gstreamer plugins */ if (! required_gstreamer_plugins_available ()) { GtkWidget *d; d = _gtk_message_dialog_new (NULL, 0, _GTK_ICON_NAME_DIALOG_ERROR, _("Cannot start the CD player"), _("In order to read CDs you have to install the gstreamer base plugins"), _GTK_LABEL_OK, GTK_RESPONSE_OK, NULL); g_signal_connect_swapped (G_OBJECT (d), "response", G_CALLBACK (gtk_widget_destroy), d); gtk_window_set_application (GTK_WINDOW (d), GTK_APPLICATION (application)); gtk_widget_show (d); return goo_application_command_line_finished (application, EXIT_FAILURE); } /* execute the command line */ window = _gtk_application_get_current_window (GTK_APPLICATION (application)); if (window == NULL) window = goo_window_new (NULL); gtk_window_present (GTK_WINDOW (window)); if (arg_auto_play) { goo_window_play (GOO_WINDOW (window)); } else if (arg_toggle_play) { goo_window_toggle_play (GOO_WINDOW (window)); } else if (arg_stop) { goo_window_stop (GOO_WINDOW (window)); } else if (arg_next) { goo_window_next (GOO_WINDOW (window)); } else if (arg_prev) { goo_window_prev (GOO_WINDOW (window)); } else if (arg_eject) { goo_window_eject (GOO_WINDOW (window)); } else if (arg_toggle_visibility) { goo_window_toggle_visibility (GOO_WINDOW (window)); } else if (arg_quit) { goo_window_close (GOO_WINDOW (window)); } else if (arg_device != NULL) { BraseroDrive *drive; drive = main_get_drive_for_device (arg_device); window = main_get_window_from_device (arg_device); if (window == NULL) { window = goo_window_new (drive); gtk_widget_show (window); } else goo_window_set_drive (GOO_WINDOW (window), drive); g_object_unref (drive); g_free (arg_device); arg_device = NULL; } return goo_application_command_line_finished (application, EXIT_SUCCESS); }
static void gth_file_list_drag_data_received (GtkWidget *file_view, GdkDragContext *context, int x, int y, GtkSelectionData *selection_data, guint info, guint time, gpointer user_data) { GthBrowser *browser = user_data; gboolean success = FALSE; char **uris; GList *selected_files; GdkDragAction action; g_signal_stop_emission_by_name (file_view, "drag-data-received"); action = gdk_drag_context_get_suggested_action (context); if (action == GDK_ACTION_COPY || action == GDK_ACTION_MOVE) { success = TRUE; } if (action == GDK_ACTION_ASK) { GdkDragAction actions = _gtk_menu_ask_drag_drop_action (file_view, gdk_drag_context_get_actions (context), time); gdk_drag_status (context, actions, time); success = gdk_drag_context_get_selected_action (context) != 0; } if (gtk_selection_data_get_data_type (selection_data) == XDND_ACTION_DIRECT_SAVE_ATOM) { const guchar *data; int format; int length; data = gtk_selection_data_get_data (selection_data); format = gtk_selection_data_get_format (selection_data); length = gtk_selection_data_get_length (selection_data); if ((format == 8) && (length == 1) && (data[0] == 'S')) { success = TRUE; } else { gdk_property_change (gdk_drag_context_get_dest_window (context), XDND_ACTION_DIRECT_SAVE_ATOM, TEXT_PLAIN_ATOM, 8, GDK_PROP_MODE_REPLACE, (const guchar *) "", 0); success = FALSE; } gtk_drag_finish (context, success, FALSE, time); return; } gtk_drag_finish (context, success, FALSE, time); if (! success) return; uris = gtk_selection_data_get_uris (selection_data); selected_files = _g_file_list_new_from_uriv (uris); if (selected_files != NULL) { if (gtk_drag_get_source_widget (context) == file_view) { GList *file_data_list; GList *visible_files; BrowserData *data; GthTask *task; file_data_list = gth_file_store_get_visibles (gth_browser_get_file_store (browser)); visible_files = gth_file_data_list_to_file_list (file_data_list); data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); task = gth_reorder_task_new (gth_browser_get_location_source (browser), gth_browser_get_location_data (browser), visible_files, selected_files, data->drop_pos); gth_browser_exec_task (browser, task, FALSE); g_object_unref (task); _g_object_list_unref (visible_files); _g_object_list_unref (file_data_list); } else { GthFileSource *file_source; gboolean cancel = FALSE; gboolean move; file_source = gth_browser_get_location_source (browser); move = gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE; if (move && ! gth_file_source_can_cut (file_source, (GFile *) selected_files->data)) { GtkWidget *dialog; int response; dialog = _gtk_message_dialog_new (GTK_WINDOW (browser), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, _("Could not move the files"), _("Files cannot be moved to the current location, as alternative you can choose to copy them."), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_COPY, GTK_RESPONSE_OK, NULL); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_CANCEL) cancel = TRUE; move = FALSE; } if (! cancel) { GthFileSource *location_source; BrowserData *data; GthTask *task; location_source = gth_main_get_file_source (gth_browser_get_location (browser)); data = g_object_get_data (G_OBJECT (browser), BROWSER_DATA_KEY); task = gth_copy_task_new (location_source, gth_browser_get_location_data (browser), move, selected_files, data->drop_pos); gth_browser_exec_task (browser, task, FALSE); g_object_unref (task); g_object_unref (location_source); } } } _g_object_list_unref (selected_files); g_strfreev (uris); }
static void clipboard_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer user_data) { PasteData *paste_data = user_data; GthBrowser *browser = paste_data->browser; const char *raw_data; char **clipboard_data; int i; GtkTreePath *path; int position; GthTask *task; raw_data = (const char *) gtk_selection_data_get_data (selection_data); if (raw_data == NULL) { paste_data_free (paste_data); return; } clipboard_data = g_strsplit_set (raw_data, "\n\r", -1); if ((clipboard_data == NULL) || (clipboard_data[0] == NULL)) { g_strfreev (clipboard_data); paste_data_free (paste_data); return; } paste_data->cut = strcmp (clipboard_data[0], "cut") == 0; paste_data->files = NULL; for (i = 1; clipboard_data[i] != NULL; i++) if (strcmp (clipboard_data[i], "") != 0) paste_data->files = g_list_prepend (paste_data->files, g_file_new_for_uri (clipboard_data[i])); paste_data->files = g_list_reverse (paste_data->files); paste_data->file_source = gth_main_get_file_source (paste_data->destination->file); if (paste_data->cut && ! gth_file_source_can_cut (paste_data->file_source, paste_data->files->data)) { GtkWidget *dialog; int response; dialog = _gtk_message_dialog_new (GTK_WINDOW (browser), GTK_DIALOG_MODAL, _GTK_ICON_NAME_DIALOG_QUESTION, _("Could not move the files"), _("Files cannot be moved to the current location, as alternative you can choose to copy them."), _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL, _("Copy"), GTK_RESPONSE_OK, NULL); response = gtk_dialog_run (GTK_DIALOG (dialog)); gtk_widget_destroy (dialog); if (response == GTK_RESPONSE_CANCEL) { paste_data_free (paste_data); return; } paste_data->cut = FALSE; } position = -1; path = gth_file_selection_get_last_selected (GTH_FILE_SELECTION (gth_browser_get_file_list_view (browser))); if (path != NULL) { int *indices; indices = gtk_tree_path_get_indices (path); if (indices != NULL) position = indices[0] + 1; gtk_tree_path_free (path); } task = gth_copy_task_new (paste_data->file_source, paste_data->destination, paste_data->cut, paste_data->files, position); gth_browser_exec_task (browser, task, GTH_TASK_FLAGS_DEFAULT); g_object_unref (task); paste_data_free (paste_data); }
static void file_buffer_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { InstallerData *idata = user_data; GFile *file; char *buffer; gsize buffer_size; GError *error = NULL; char *uri; const char *mime_type; gboolean result_uncertain; GType archive_type; FrArchive *preferred_archive; file = G_FILE (source_object); if (! _g_file_load_buffer_finish (file, result, &buffer, &buffer_size, &error)) { package_installer_terminated (idata, FR_ERROR_GENERIC, error->message); g_error_free (error); return; } uri = g_file_get_uri (file); mime_type = g_content_type_guess (uri, (guchar *) buffer, buffer_size, &result_uncertain); if (result_uncertain) { mime_type = _g_mime_type_get_from_content (buffer, buffer_size); if (mime_type == NULL) mime_type = _g_mime_type_get_from_filename (file); } g_free (uri); g_free (buffer); archive_type = get_preferred_archive_for_mime_type (mime_type, FR_ARCHIVE_CAN_READ_WRITE); if (archive_type == 0) archive_type = get_preferred_archive_for_mime_type (mime_type, FR_ARCHIVE_CAN_READ); if (archive_type == 0) { package_installer_terminated (idata, FR_ERROR_GENERIC, _("Archive type not supported.")); return; } preferred_archive = g_object_new (archive_type, 0); idata->packages = fr_archive_get_packages (preferred_archive, mime_type); g_object_unref (preferred_archive); if (idata->packages == NULL) { package_installer_terminated (idata, FR_ERROR_GENERIC, _("Archive type not supported.")); return; } #ifdef ENABLE_PACKAGEKIT { char *secondary_text; GtkWidget *dialog; secondary_text = g_strdup_printf (_("There is no command installed for %s files.\nDo you want to search for a command to open this file?"), g_content_type_get_description (mime_type)); dialog = _gtk_message_dialog_new (GTK_WINDOW (idata->window), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_ERROR, _("Could not open this file type"), secondary_text, GTK_STOCK_CANCEL, GTK_RESPONSE_NO, _("_Search Command"), GTK_RESPONSE_YES, NULL); g_signal_connect (dialog, "response", G_CALLBACK (confirm_search_dialog_response_cb), idata); gtk_widget_show (dialog); g_free (secondary_text); } #else /* ! ENABLE_PACKAGEKIT */ package_installer_terminated (idata, FR_ERROR_GENERIC, _("Archive type not supported.")); #endif /* ENABLE_PACKAGEKIT */ }
static int extract_cb (GtkWidget *w, DialogData *data) { FrWindow *window = data->window; gboolean do_not_extract = FALSE; char *extract_to_dir; gboolean overwrite; gboolean skip_newer; gboolean selected_files; gboolean pattern_files; gboolean junk_paths; GList *file_list; char *base_dir = NULL; GError *error = NULL; data->extract_clicked = TRUE; /* collect extraction options. */ extract_to_dir = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (data->dialog)); /* check directory existence. */ if (! uri_is_dir (extract_to_dir)) { if (! ForceDirectoryCreation) { GtkWidget *d; int r; char *folder_name; char *msg; folder_name = g_filename_display_name (extract_to_dir); msg = g_strdup_printf (_("Destination folder \"%s\" does not exist.\n\nDo you want to create it?"), folder_name); g_free (folder_name); d = _gtk_message_dialog_new (GTK_WINDOW (data->dialog), GTK_DIALOG_MODAL, GTK_STOCK_DIALOG_QUESTION, msg, NULL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("Create _Folder"), GTK_RESPONSE_YES, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_YES); r = gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (msg); if (r != GTK_RESPONSE_YES) do_not_extract = TRUE; } if (! do_not_extract && ! ensure_dir_exists (extract_to_dir, 0755, &error)) { GtkWidget *d; d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Extraction not performed"), _("Could not create the destination folder: %s."), error->message); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_error_free (error); return FALSE; } } if (do_not_extract) { GtkWidget *d; d = _gtk_message_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_DIALOG_WARNING, _("Extraction not performed"), NULL, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (d), GTK_RESPONSE_OK); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); if (fr_window_is_batch_mode (data->window)) gtk_widget_destroy (data->dialog); return FALSE; } /* check extraction directory permissions. */ if (uri_is_dir (extract_to_dir) && ! check_permissions (extract_to_dir, R_OK | W_OK)) { GtkWidget *d; char *utf8_path; utf8_path = g_filename_display_name (extract_to_dir); d = _gtk_error_dialog_new (GTK_WINDOW (window), GTK_DIALOG_DESTROY_WITH_PARENT, NULL, _("Extraction not performed"), _("You don't have the right permissions to extract archives in the folder \"%s\""), utf8_path); gtk_dialog_run (GTK_DIALOG (d)); gtk_widget_destroy (GTK_WIDGET (d)); g_free (utf8_path); g_free (extract_to_dir); return FALSE; } fr_window_set_extract_default_dir (window, extract_to_dir, TRUE); overwrite = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_overwrite_checkbutton)); skip_newer = ! gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton)) && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton)); junk_paths = ! gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_recreate_dir_checkbutton)); g_settings_set_boolean (data->settings, PREF_EXTRACT_OVERWRITE, overwrite); if (! gtk_toggle_button_get_inconsistent (GTK_TOGGLE_BUTTON (data->e_not_newer_checkbutton))) g_settings_set_boolean (data->settings, PREF_EXTRACT_SKIP_NEWER, skip_newer); g_settings_set_boolean (data->settings, PREF_EXTRACT_RECREATE_FOLDERS, ! junk_paths); selected_files = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_selected_radiobutton)); pattern_files = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (data->e_files_radiobutton)); /* create the file list. */ file_list = NULL; if (selected_files) { file_list = data->selected_files; data->selected_files = NULL; /* do not the list when destroying the dialog. */ } else if (pattern_files) { const char *pattern; pattern = gtk_entry_get_text (GTK_ENTRY (data->e_files_entry)); file_list = fr_window_get_file_list_pattern (window, pattern); if (file_list == NULL) { gtk_widget_destroy (data->dialog); g_free (extract_to_dir); return FALSE; } } if (selected_files) { base_dir = data->base_dir_for_selection; data->base_dir_for_selection = NULL; } else base_dir = NULL; /* close the dialog. */ gtk_widget_destroy (data->dialog); /* extract ! */ fr_window_archive_extract (window, file_list, extract_to_dir, base_dir, skip_newer, overwrite ? FR_OVERWRITE_YES : FR_OVERWRITE_NO, junk_paths, TRUE); path_list_free (file_list); g_free (extract_to_dir); g_free (base_dir); return TRUE; }