/***************************************************************************************** * Check Subdirectories: * * check if dirs contain sub dir in another thread and make * the tree nodes expandable when needed. * * ****************************************************************************************/ void fm_dir_tree_model_item_queue_subdir_check (FmDirTreeModel *dir_tree_model, GList *item_list) { FmDirTreeItem *dir_tree_item = (FmDirTreeItem*)item_list->data; g_return_if_fail (dir_tree_item->file_info != NULL); g_mutex_lock (dir_tree_model->subdir_checks_mutex); g_queue_push_tail (&dir_tree_model->subdir_checks, item_list); // NO_DEBUG ("queue subdir check for %s\n", fm_file_info_get_disp_name (dir_tree_item->file_info)); if (!dir_tree_model->job_running) { dir_tree_model->job_running = TRUE; dir_tree_model->current_subdir_check = (GList*)g_queue_peek_head (&dir_tree_model->subdir_checks); g_cancellable_reset (dir_tree_model->subdir_cancellable); g_io_scheduler_push_job (subdir_check_job, g_object_ref (dir_tree_model), (GDestroyNotify)g_object_unref, G_PRIORITY_DEFAULT, dir_tree_model->subdir_cancellable); // NO_DEBUG ("push job\n"); } g_mutex_unlock (dir_tree_model->subdir_checks_mutex); }
void fileops_empty_trash () { GList* trash_list = NULL; GVolumeMonitor* vol_monitor = g_volume_monitor_get (); GList* mount_list = g_volume_monitor_get_mounts (vol_monitor); g_object_unref (vol_monitor); //iterate through all mounts GList* l; for (l = mount_list; l != NULL; l = l->next) { trash_list = g_list_concat (trash_list, _get_trash_dirs_for_mount (l->data)); } g_list_free_full (mount_list, g_object_unref); //add 'trash:' prefix trash_list = g_list_prepend (trash_list, g_file_new_for_uri ("trash:")); g_io_scheduler_push_job (_empty_trash_job, trash_list, NULL, 0, NULL); }
static void prepare_screenshot (void) { AsyncExistenceJob *job; job = g_slice_new0 (AsyncExistenceJob); job->base_uris[0] = last_save_dir; /* we'll have to free these two */ job->base_uris[1] = get_desktop_dir (); job->base_uris[2] = g_strconcat ("file://", g_get_tmp_dir (), NULL); job->iteration = 0; job->type = TEST_LAST_DIR; job->window = find_current_window (&window_title); job->rectangle = find_rectangle (); /* Check if the area selection was cancelled */ if (job->rectangle && (job->rectangle->width == 0 || job->rectangle->height == 0)) { async_existence_job_free (job); gtk_main_quit (); return; } g_io_scheduler_push_job (try_check_file, job, NULL, 0, NULL); }
static void fm_path_entry_changed(GtkEditable *editable, gpointer user_data) { FmPathEntry *entry = FM_PATH_ENTRY(editable); FmPathEntryPrivate *priv = FM_PATH_ENTRY_GET_PRIVATE(entry); GtkWidget* widget = GTK_WIDGET(entry); const gchar *path_str, *sep; /* find parent dir of current path */ path_str = gtk_entry_get_text( GTK_ENTRY(entry) ); sep = g_utf8_strrchr(path_str, -1, G_DIR_SEPARATOR); if(sep) /* we found a parent dir */ { int parent_len = (sep - path_str) + 1; /* includes the dir separator / */ if(!priv->parent_dir || priv->parent_len != parent_len || strncmp(priv->parent_dir, path_str, parent_len )) { /* parent dir has been changed, reload dir list */ ListSubDirNames* data = g_slice_new0(ListSubDirNames); g_free(priv->parent_dir); priv->parent_dir = g_strndup(path_str, parent_len); priv->parent_len = parent_len; /* g_debug("parent dir is changed to %s", priv->parent_dir); */ /* FIXME: convert utf-8 encoded path to on-disk encoding. */ data->entry = entry; if(priv->parent_dir[0] == '~') /* special case for home dir */ { char* expand = g_strconcat(g_get_home_dir(), priv->parent_dir + 1, NULL); data->dir = g_file_new_for_commandline_arg(expand); g_free(expand); } else data->dir = g_file_new_for_commandline_arg(priv->parent_dir); /* clear current model */ gtk_list_store_clear(GTK_LIST_STORE(priv->model)); /* cancel running dir-listing jobs */ if(priv->cancellable) { g_cancellable_cancel(priv->cancellable); g_object_unref(priv->cancellable); } /* launch a new job to do dir listing */ data->cancellable = g_cancellable_new(); priv->cancellable = (GCancellable*)g_object_ref(data->cancellable); g_io_scheduler_push_job(list_sub_dirs, data, (GDestroyNotify)list_sub_dir_names_free, G_PRIORITY_LOW, data->cancellable); } /* calculate the length of remaining part after / */ priv->typed_basename_len = strlen(sep + 1); } else /* clear all autocompletion thing. */ clear_completion(priv); }
static void storage_threaded_job_constructed (GObject *object) { StorageThreadedJob *job = STORAGE_THREADED_JOB (object); if (G_OBJECT_CLASS (storage_threaded_job_parent_class)->constructed != NULL) G_OBJECT_CLASS (storage_threaded_job_parent_class)->constructed (object); g_assert (g_thread_supported ()); g_io_scheduler_push_job (run_io_scheduler_job, job, NULL, G_PRIORITY_DEFAULT, storage_job_get_cancellable (STORAGE_JOB (job))); }
/** * sushi_new_ft_face_from_uri_async: (skip) * */ void sushi_new_ft_face_from_uri_async (FT_Library library, const gchar *uri, GAsyncReadyCallback callback, gpointer user_data) { FontLoadJob *job = font_load_job_new (library, uri, callback, user_data); g_io_scheduler_push_job (font_load_job, job, NULL, G_PRIORITY_DEFAULT, NULL); }
static void trash_empty_start (GtkWidget *parent) { struct { const char *name; gpointer *pointer; } widgets[] = { { "empty_trash", (gpointer *) &trash_empty_dialog }, { "progressbar", (gpointer *) &trash_empty_progress_bar }, { "location_label", (gpointer *) &trash_empty_location }, { "file_label", (gpointer *) &trash_empty_file } }; GCancellable *cancellable; GtkBuilder *builder; gint i; builder = gtk_builder_new (); gtk_builder_add_from_file (builder, GTK_BUILDERDIR "/trashapplet-empty-progress.ui", NULL); for (i = 0; i < G_N_ELEMENTS (widgets); i++) { GObject *object; object = gtk_builder_get_object (builder, widgets[i].name); if (object == NULL) { g_critical ("failed to parse trash-empty dialog markup"); if (trash_empty_dialog) gtk_object_destroy (GTK_OBJECT (trash_empty_dialog)); g_object_unref (builder); return; } *widgets[i].pointer = object; g_object_add_weak_pointer (object, widgets[i].pointer); } g_object_unref (builder); cancellable = g_cancellable_new (); g_signal_connect_object (trash_empty_dialog, "response", G_CALLBACK (g_cancellable_cancel), cancellable, G_CONNECT_SWAPPED); g_io_scheduler_push_job (trash_empty_job, NULL, NULL, 0, cancellable); g_object_unref (cancellable); gtk_window_set_screen (GTK_WINDOW (trash_empty_dialog), gtk_widget_get_screen (parent)); gtk_widget_show (GTK_WIDGET (trash_empty_dialog)); }
static void start_job (NemoJobQueue *self, Job *job) { self->priv->queued_jobs = g_list_remove (self->priv->queued_jobs, job); g_io_scheduler_push_job (job->job_func, job->user_data, NULL, // destroy notify 0, job->cancellable); self->priv->running_jobs = g_list_append (self->priv->running_jobs, job); }
static void ensure_thumbnail (FontViewModel *self, const gchar *path) { LoadThumbnailData *data; data = g_slice_new0 (LoadThumbnailData); data->self = g_object_ref (self); data->font_file = g_file_new_for_path (path); data->font_path = g_strdup (path); g_io_scheduler_push_job (ensure_thumbnail_job, data, NULL, G_PRIORITY_DEFAULT, NULL); }
static void nemo_preview_cover_art_fetcher_get_uri_for_track_async (NemoPreviewCoverArtFetcher *self, const gchar *artist, const gchar *album, GAsyncReadyCallback callback, gpointer user_data) { FetchUriJob *job; job = fetch_uri_job_new (self, artist, album, callback, user_data); g_io_scheduler_push_job (fetch_uri_job, job, NULL, G_PRIORITY_DEFAULT, NULL); }
void gd_queue_thumbnail_job_for_file_async (GFile *file, GAsyncReadyCallback callback, gpointer user_data) { GSimpleAsyncResult *result; result = g_simple_async_result_new (G_OBJECT (file), callback, user_data, gd_queue_thumbnail_job_for_file_async); g_io_scheduler_push_job (create_thumbnail, result, NULL, G_PRIORITY_DEFAULT, NULL); }
void tracker_db_backup_save (GFile *destination, TrackerDBBackupFinished callback, gpointer user_data, GDestroyNotify destroy) { BackupInfo *info = g_new0 (BackupInfo, 1); info->destination = g_object_ref (destination); info->callback = callback; info->user_data = user_data; info->destroy = destroy; g_io_scheduler_push_job (backup_job, info, NULL, 0, NULL); }
static void log_setup_load (LogviewLog *log, LogviewCreateCallback callback, gpointer user_data) { LoadJob *job; job = g_slice_new0 (LoadJob); job->callback = callback; job->user_data = user_data; job->log = log; job->err = NULL; /* push the loading job into another thread */ g_io_scheduler_push_job (log_load, job, NULL, 0, NULL); }
void hev_impathy_tls_verifier_verify_async(HevImpathyTLSVerifier *self, GAsyncReadyCallback callback, gpointer user_data) { HevImpathyTLSVerifierPrivate *priv = NULL; g_debug("%s:%d[%s]", __FILE__, __LINE__, __FUNCTION__); g_return_if_fail(HEV_IS_IMPATHY_TLS_VERIFIER(self)); priv = HEV_IMPATHY_TLS_VERIFIER_GET_PRIVATE(self); g_return_if_fail(NULL==priv->verify_result); priv->verify_result = g_simple_async_result_new(G_OBJECT(self), callback, user_data, NULL); g_io_scheduler_push_job(build_gnutls_ca_and_crl_lists, self, NULL, G_PRIORITY_DEFAULT, NULL); }
/* called from the main thread on start-up and every 10 minutes or so */ static gboolean on_housekeeping_timeout (gpointer user_data) { UDisksLinuxProvider *provider = UDISKS_LINUX_PROVIDER (user_data); G_LOCK (provider_lock); if (provider->housekeeping_running) goto out; provider->housekeeping_running = TRUE; g_io_scheduler_push_job (housekeeping_thread_func, g_object_ref (provider), (GDestroyNotify) g_object_unref, G_PRIORITY_DEFAULT, NULL); out: G_UNLOCK (provider_lock); return TRUE; /* keep timeout around */ }
static void ft_handler_read_async_cb (GObject *source, GAsyncResult *res, gpointer user_data) { GFileInputStream *stream; GError *error = NULL; HashingData *hash_data; EmpathyFTHandler *handler = user_data; EmpathyFTHandlerPriv *priv = handler->priv; (void)source; /* suppress unused-parameter warning */ DEBUG ("GFile read async CB."); stream = g_file_read_finish (priv->gfile, res, &error); if (error != NULL) { emit_error_signal (handler, error); g_clear_error (&error); return; } hash_data = g_slice_new0 (HashingData); hash_data->stream = G_INPUT_STREAM (stream); hash_data->total_bytes = priv->total_bytes; hash_data->handler = g_object_ref (handler); /* FIXME: MD5 is the only ContentHashType supported right now */ hash_data->checksum = g_checksum_new (G_CHECKSUM_MD5); tp_asv_set_uint32 (priv->request, TP_PROP_CHANNEL_TYPE_FILE_TRANSFER_CONTENT_HASH_TYPE, TP_FILE_HASH_TYPE_MD5); g_signal_emit (handler, signals[HASHING_STARTED], 0); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" g_io_scheduler_push_job (do_hash_job, hash_data, NULL, G_PRIORITY_DEFAULT, priv->cancellable); #pragma GCC diagnostic pop }
static VALUE rg_s_push_job(int argc, VALUE *argv, VALUE self) { VALUE rbio_priority, rbcancellable, block; gint io_priority; GCancellable *cancellable; rb_scan_args(argc, argv, "02", &rbio_priority, &rbcancellable); io_priority = RVAL2IOPRIORITYDEFAULT(rbio_priority); cancellable = RVAL2GCANCELLABLE(rbcancellable); block = rb_block_proc(); SAVE_BLOCK(block); g_io_scheduler_push_job(ioscheduler_job_callback, (gpointer)block, ioscheduler_job_callback_free, io_priority, cancellable); return self; }
static void check_hash_incoming (EmpathyFTHandler *handler) { HashingData *hash_data; EmpathyFTHandlerPriv *priv = GET_PRIV (handler); if (!EMP_STR_EMPTY (priv->content_hash)) { hash_data = g_slice_new0 (HashingData); hash_data->total_bytes = priv->total_bytes; hash_data->handler = g_object_ref (handler); hash_data->checksum = g_checksum_new (tp_file_hash_to_g_checksum (priv->content_hash_type)); g_signal_emit (handler, signals[HASHING_STARTED], 0); g_io_scheduler_push_job (do_hash_job_incoming, hash_data, NULL, G_PRIORITY_DEFAULT, priv->cancellable); } }
void logview_log_read_new_lines (LogviewLog *log, LogviewNewLinesCallback callback, gpointer user_data) { NewLinesJob *job; /* initialize the job struct with sensible values */ job = g_slice_new0 (NewLinesJob); job->callback = callback; job->user_data = user_data; job->log = g_object_ref (log); job->err = NULL; job->lines = NULL; job->new_days = NULL; /* push the fetching job into another thread */ g_io_scheduler_push_job (do_read_new_lines, job, NULL, 0, NULL); }
static void g_udisks_mount_guess_content_type (GMount* base, gboolean force_rescan, GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data) { GUDisksMount* mnt = G_UDISKS_MOUNT(base); GFile* root = g_udisks_mount_get_root(base); g_debug("guess content type"); if(root) { /* FIXME: this is not really cancellable. */ GuessContentData* data = g_slice_new(GuessContentData); /* NOTE: this should be an asynchronous action, but * g_content_type_guess_for_tree provided by glib is not * cancellable. So, we got some problems here. * If we really want a perfect asynchronous implementation, * another option is using fork() to implement this. */ data->mnt = g_object_ref(mnt); data->root = root; data->callback = callback; data->user_data = user_data; g_io_scheduler_push_job(guess_content_job, data, guess_content_data_free, G_PRIORITY_DEFAULT, cancellable); } }
static void check_hash_incoming (EmpathyFTHandler *handler) { HashingData *hash_data; EmpathyFTHandlerPriv *priv = handler->priv; if (!tp_str_empty (priv->content_hash)) { hash_data = g_slice_new0 (HashingData); hash_data->total_bytes = priv->total_bytes; hash_data->handler = g_object_ref (handler); hash_data->checksum = g_checksum_new (tp_file_hash_to_g_checksum (priv->content_hash_type)); g_signal_emit (handler, signals[HASHING_STARTED], 0); #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" g_io_scheduler_push_job (do_hash_job_incoming, hash_data, NULL, G_PRIORITY_DEFAULT, priv->cancellable); #pragma GCC diagnostic pop } }
static void handle_method_call_perform_writeback (TrackerController *controller, GDBusMethodInvocation *invocation, GVariant *parameters) { TrackerControllerPrivate *priv; TrackerDBusRequest *request; const gchar *subject; GPtrArray *results = NULL; GHashTableIter iter; gpointer key, value; GVariantIter *iter1, *iter2, *iter3; GArray *rdf_types_array; GStrv rdf_types; gchar *rdf_type = NULL; GList *writeback_handlers = NULL; WritebackData *data; priv = controller->priv; results = g_ptr_array_new_with_free_func ((GDestroyNotify) g_strfreev); g_variant_get (parameters, "(&sasaas)", &subject, &iter1, &iter2); rdf_types_array = g_array_new (TRUE, TRUE, sizeof (gchar *)); while (g_variant_iter_loop (iter1, "&s", &rdf_type)) { g_array_append_val (rdf_types_array, rdf_type); } rdf_types = (GStrv) rdf_types_array->data; g_array_free (rdf_types_array, FALSE); while (g_variant_iter_loop (iter2, "as", &iter3)) { GArray *row_array = g_array_new (TRUE, TRUE, sizeof (gchar *)); gchar *cell = NULL; while (g_variant_iter_loop (iter3, "&s", &cell)) { g_array_append_val (row_array, cell); } g_ptr_array_add (results, row_array->data); g_array_free (row_array, FALSE); } g_variant_iter_free (iter1); g_variant_iter_free (iter2); reset_shutdown_timeout (controller); request = tracker_dbus_request_begin (NULL, "%s (%s)", __FUNCTION__, subject); g_hash_table_iter_init (&iter, priv->modules); while (g_hash_table_iter_next (&iter, &key, &value)) { TrackerWritebackModule *module; const gchar * const *module_types; module = value; module_types = tracker_writeback_module_get_rdf_types (module); if (sparql_rdf_types_match (module_types, (const gchar * const *) rdf_types)) { TrackerWriteback *writeback; g_message (" Updating metadata for subject:'%s' using module:'%s'", subject, module->name); writeback = tracker_writeback_module_create (module); writeback_handlers = g_list_prepend (writeback_handlers, writeback); } } if (writeback_handlers != NULL) { data = writeback_data_new (controller, writeback_handlers, priv->connection, subject, results, invocation, request); g_io_scheduler_push_job (io_writeback_job, data, NULL, 0, data->cancellable); } else { g_dbus_method_invocation_return_error (invocation, TRACKER_DBUS_ERROR, TRACKER_DBUS_ERROR_UNSUPPORTED, "No module for rdf types"); } g_free (rdf_types); }
/* called with lock held */ static void handle_block_uevent_for_drive (UDisksLinuxProvider *provider, const gchar *action, UDisksLinuxDevice *device) { UDisksLinuxDriveObject *object; UDisksDaemon *daemon; const gchar *sysfs_path; gchar *vpd; vpd = NULL; daemon = udisks_provider_get_daemon (UDISKS_PROVIDER (provider)); sysfs_path = g_udev_device_get_sysfs_path (device->udev_device); if (g_strcmp0 (action, "remove") == 0) { object = g_hash_table_lookup (provider->sysfs_path_to_drive, sysfs_path); if (object != NULL) { GList *devices; udisks_linux_drive_object_uevent (object, action, device); g_warn_if_fail (g_hash_table_remove (provider->sysfs_path_to_drive, sysfs_path)); devices = udisks_linux_drive_object_get_devices (object); if (devices == NULL) { const gchar *existing_vpd; existing_vpd = g_object_get_data (G_OBJECT (object), "x-vpd"); g_dbus_object_manager_server_unexport (udisks_daemon_get_object_manager (daemon), g_dbus_object_get_object_path (G_DBUS_OBJECT (object))); g_warn_if_fail (g_hash_table_remove (provider->vpd_to_drive, existing_vpd)); } g_list_foreach (devices, (GFunc) g_object_unref, NULL); g_list_free (devices); } } else { if (!udisks_linux_drive_object_should_include_device (provider->gudev_client, device, &vpd)) goto out; if (vpd == NULL) { udisks_debug ("Ignoring block device %s with no serial or WWN", g_udev_device_get_sysfs_path (device->udev_device)); goto out; } object = g_hash_table_lookup (provider->vpd_to_drive, vpd); if (object != NULL) { if (g_hash_table_lookup (provider->sysfs_path_to_drive, sysfs_path) == NULL) g_hash_table_insert (provider->sysfs_path_to_drive, g_strdup (sysfs_path), object); udisks_linux_drive_object_uevent (object, action, device); } else { object = udisks_linux_drive_object_new (daemon, device); if (object != NULL) { g_object_set_data_full (G_OBJECT (object), "x-vpd", g_strdup (vpd), g_free); g_dbus_object_manager_server_export_uniquely (udisks_daemon_get_object_manager (daemon), G_DBUS_OBJECT_SKELETON (object)); g_hash_table_insert (provider->vpd_to_drive, g_strdup (vpd), object); g_hash_table_insert (provider->sysfs_path_to_drive, g_strdup (sysfs_path), object); /* schedule initial housekeeping for the drive unless coldplugging */ if (!provider->coldplug) { g_io_scheduler_push_job (perform_initial_housekeeping_for_drive, g_object_ref (object), (GDestroyNotify) g_object_unref, G_PRIORITY_DEFAULT, NULL); } } } } out: g_free (vpd); }
static void trash_empty_start () { GtkWidget *vbox1, *vbox2, *hbox; GtkWidget *label1, *label3; gchar *markup; GCancellable *cancellable; trash_empty_dialog = gtk_dialog_new (); gtk_window_set_default_size (GTK_WINDOW (trash_empty_dialog), 400, -1); gtk_window_set_icon_name (GTK_WINDOW (trash_empty_dialog), "user-trash"); gtk_window_set_title (GTK_WINDOW (trash_empty_dialog), _("Emptying the trash")); vbox1 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12); vbox2 = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0); hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0); label1 = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (label1), TRUE); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (label1), 0.0); gtk_label_set_yalign (GTK_LABEL (label1), 0.5); #else gtk_misc_set_alignment (GTK_MISC (label1), 0.0, 0.5); #endif label3 = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (label3), TRUE); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (label3), 0.0); gtk_label_set_yalign (GTK_LABEL (label3), 0.5); #else gtk_misc_set_alignment (GTK_MISC (label3), 0.0, 0.5); #endif gtk_widget_hide (label3); location_label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (location_label), TRUE); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (location_label), 0.0); gtk_label_set_yalign (GTK_LABEL (location_label), 0.5); #else gtk_misc_set_alignment (GTK_MISC (location_label), 0.0, 0.5); #endif file_label = gtk_label_new (NULL); gtk_label_set_line_wrap (GTK_LABEL (file_label), TRUE); #if GTK_CHECK_VERSION (3, 16, 0) gtk_label_set_xalign (GTK_LABEL (file_label), 0.0); gtk_label_set_yalign (GTK_LABEL (file_label), 0.5); #else gtk_misc_set_alignment (GTK_MISC (file_label), 0.0, 0.5); #endif progressbar = gtk_progress_bar_new (); gtk_progress_bar_set_pulse_step (GTK_PROGRESS_BAR (progressbar), 0.1); gtk_progress_bar_set_text (GTK_PROGRESS_BAR (progressbar), _("Preparing to empty trash…")); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (trash_empty_dialog))), vbox1, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox1), label1, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), label3, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (hbox), location_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox1), hbox, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox2), progressbar, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox2), file_label, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox1), vbox2, TRUE, TRUE, 0); gtk_widget_show (label1); gtk_widget_show (vbox1); gtk_widget_show_all (vbox2); gtk_widget_show (hbox); gtk_widget_show (location_label); gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (trash_empty_dialog))), 6); gtk_container_set_border_width (GTK_CONTAINER (vbox1), 6); gtk_dialog_add_button (GTK_DIALOG (trash_empty_dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); markup = g_markup_printf_escaped ("<big><b>%s</b></big>", _("Emptying the trash")); gtk_label_set_markup (GTK_LABEL (label1), markup); /* Translators: "Emptying trash from <device>" */ gtk_label_set_text (GTK_LABEL (label3), _("From: ")); cancellable = g_cancellable_new (); g_signal_connect_object (trash_empty_dialog, "response", G_CALLBACK (g_cancellable_cancel), cancellable, G_CONNECT_SWAPPED); g_io_scheduler_push_job (trash_empty_job, NULL, NULL, 0, cancellable); gtk_widget_show (trash_empty_dialog); g_free (markup); g_object_unref (cancellable); }
gint main (gint argc, gchar **argv) { GCancellable *cancellable; gchar *file = NULL, *oper = NULL; const gchar *title = NULL; gint ii; GError *error = NULL; #ifdef G_OS_WIN32 /* Reduce risks */ { typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName); t_SetDllDirectoryA p_SetDllDirectoryA; p_SetDllDirectoryA = GetProcAddress ( GetModuleHandle ("kernel32.dll"), "SetDllDirectoryA"); if (p_SetDllDirectoryA != NULL) p_SetDllDirectoryA (""); } #ifndef _WIN64 { typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags); t_SetProcessDEPPolicy p_SetProcessDEPPolicy; p_SetProcessDEPPolicy = GetProcAddress ( GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy"); if (p_SetProcessDEPPolicy) p_SetProcessDEPPolicy ( PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION); } #endif #endif bindtextdomain (GETTEXT_PACKAGE, EVOLUTION_LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); gtk_init_with_args ( &argc, &argv, NULL, options, GETTEXT_PACKAGE, &error); if (error != NULL) { g_printerr ("%s\n", error->message); g_error_free (error); exit (EXIT_FAILURE); } if (opt_remaining != NULL) { for (ii = 0; ii < g_strv_length (opt_remaining); ii++) { if (backup_op) { title = _("Evolution Back Up"); oper = _("Backing up to the folder %s"); d(g_message ("Backing up to the folder %s", (gchar *) opt_remaining[ii])); bk_file = g_strdup ((gchar *) opt_remaining[ii]); file = bk_file; } else if (restore_op) { title = _("Evolution Restore"); oper = _("Restoring from the folder %s"); d(g_message ("Restoring from the folder %s", (gchar *) opt_remaining[ii])); res_file = g_strdup ((gchar *) opt_remaining[ii]); file = res_file; } else if (check_op) { d(g_message ("Checking %s", (gchar *) opt_remaining[ii])); chk_file = g_strdup ((gchar *) opt_remaining[ii]); } } } cancellable = g_cancellable_new (); if (gui_arg && !check_op) { GtkWidget *widget, *container; GtkWidget *action_area; GtkWidget *content_area; const gchar *txt, *txt2; gchar *str = NULL; gchar *markup; gtk_window_set_default_icon_name ("evolution"); /* Backup / Restore only can have GUI. * We should restrict the rest. */ progress_dialog = gtk_dialog_new_with_buttons ( title, NULL, GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_REJECT, NULL); gtk_container_set_border_width ( GTK_CONTAINER (progress_dialog), 12); gtk_window_set_default_size ( GTK_WINDOW (progress_dialog), 450, 120); action_area = gtk_dialog_get_action_area ( GTK_DIALOG (progress_dialog)); content_area = gtk_dialog_get_content_area ( GTK_DIALOG (progress_dialog)); /* Override GtkDialog defaults */ gtk_box_set_spacing (GTK_BOX (content_area), 12); gtk_container_set_border_width (GTK_CONTAINER (content_area), 0); gtk_box_set_spacing (GTK_BOX (action_area), 12); gtk_container_set_border_width (GTK_CONTAINER (action_area), 0); if (oper && file) str = g_strdup_printf (oper, file); container = gtk_table_new (2, 3, FALSE); gtk_table_set_col_spacings (GTK_TABLE (container), 12); gtk_table_set_row_spacings (GTK_TABLE (container), 12); gtk_widget_show (container); gtk_box_pack_start ( GTK_BOX (content_area), container, FALSE, TRUE, 0); widget = gtk_image_new_from_stock ( GTK_STOCK_COPY, GTK_ICON_SIZE_DIALOG); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0); gtk_widget_show (widget); gtk_table_attach ( GTK_TABLE (container), widget, 0, 1, 0, 3, GTK_FILL, GTK_EXPAND | GTK_FILL, 0, 0); if (backup_op) { txt = _("Backing up Evolution Data"); txt2 = _("Please wait while Evolution is backing up your data."); } else if (restore_op) { txt = _("Restoring Evolution Data"); txt2 = _("Please wait while Evolution is restoring your data."); } else { g_return_val_if_reached (EXIT_FAILURE); } markup = g_markup_printf_escaped ("<b><big>%s</big></b>", txt); widget = gtk_label_new (markup); gtk_label_set_line_wrap (GTK_LABEL (widget), FALSE); gtk_label_set_use_markup (GTK_LABEL (widget), TRUE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.0); gtk_widget_show (widget); g_free (markup); gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 0, 1, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); markup = g_strconcat ( txt2, " ", _("This may take a while depending " "on the amount of data in your account."), NULL); widget = gtk_label_new (markup); gtk_label_set_line_wrap (GTK_LABEL (widget), TRUE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); gtk_widget_show (widget); g_free (markup); gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 1, 2, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); pbar = gtk_progress_bar_new (); if (str != NULL) { markup = g_markup_printf_escaped ("<i>%s</i>", str); widget = gtk_label_new (markup); gtk_label_set_use_markup (GTK_LABEL (widget), TRUE); gtk_misc_set_alignment (GTK_MISC (widget), 0.0, 0.5); g_free (markup); g_free (str); gtk_table_attach ( GTK_TABLE (container), widget, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); gtk_table_set_row_spacing (GTK_TABLE (container), 2, 6); gtk_table_attach ( GTK_TABLE (container), pbar, 1, 2, 3, 4, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); } else gtk_table_attach ( GTK_TABLE (container), pbar, 1, 2, 2, 3, GTK_EXPAND | GTK_FILL, GTK_FILL, 0, 0); g_signal_connect ( progress_dialog, "response", G_CALLBACK (dlg_response), cancellable); gtk_widget_show_all (progress_dialog); } else if (check_op) { /* For sanity we don't need gui */ check (chk_file, NULL); exit (result == 0 ? 0 : 1); } if (gui_arg) g_timeout_add_full ( G_PRIORITY_DEFAULT, 50, (GSourceFunc) pbar_update, g_object_ref (cancellable), (GDestroyNotify) g_object_unref); g_io_scheduler_push_job ( start_job, NULL, (GDestroyNotify) NULL, G_PRIORITY_DEFAULT, cancellable); gtk_main (); g_object_unref (cancellable); return result; }