static gboolean delegate_set_current_folder (GtkFileChooser *chooser, GFile *file, GError **error) { return gtk_file_chooser_set_current_folder_file (get_delegate (chooser), file, error); }
static void open_cb (GSimpleAction *action, GVariant *parameter, gpointer app) { GtkWidget *dialog; GtkWindow *win; const char *home_path; GFile *home; GtkFileFilter *filter_audio; GtkFileFilter *filter_all; gchar *uri = NULL; win = gtk_application_get_active_window (app); dialog = gtk_file_chooser_dialog_new ( _("Open Audio File"), win, GTK_FILE_CHOOSER_ACTION_OPEN, _("_Cancel"), GTK_RESPONSE_CANCEL, _("_Open"), GTK_RESPONSE_ACCEPT, NULL); /* Set current folder to user's home directory */ home_path = g_get_home_dir (); home = g_file_new_for_path (home_path); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), home, NULL); filter_audio = gtk_file_filter_new (); filter_all = gtk_file_filter_new (); gtk_file_filter_set_name (filter_audio, _("Audio files")); gtk_file_filter_set_name (filter_all, _("All files")); gtk_file_filter_add_mime_type (filter_audio, "audio/*"); gtk_file_filter_add_pattern (filter_all, "*"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter_audio); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter_all); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (dialog), filter_audio); if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) { uri = gtk_file_chooser_get_uri (GTK_FILE_CHOOSER (dialog)); } g_object_unref (home); gtk_widget_destroy (dialog); if (uri) { pt_window_open_file (PT_WINDOW (win), uri); g_free (uri); } }
static void set_default_values (GtkWidget *dlg, GFile *base_file) { SaveAsData *sd; sd = (SaveAsData*) g_object_get_data (G_OBJECT (dlg), "data"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (sd->counter_spin), 0.0); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (sd->replace_spaces_check), FALSE); if (base_file != NULL) { gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (sd->dir_chooser), base_file, NULL); } /*gtk_dialog_set_response_sensitive (GTK_DIALOG (dlg), GTK_RESPONSE_OK, FALSE);*/ request_preview_update (dlg); }
void activate_action_open (GtkAction *action, gpointer data) { GtkWidget *file_sel; FrWindow *window = data; GtkFileFilter *filter; int i; file_sel = gtk_file_chooser_dialog_new (_("Open"), GTK_WINDOW (window), GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (file_sel), GTK_RESPONSE_OK); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (file_sel), FALSE); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (file_sel), fr_window_get_open_default_dir (window), NULL); _gtk_dialog_add_to_window_group (GTK_DIALOG (file_sel)); gtk_window_set_modal (GTK_WINDOW (file_sel), TRUE); filter = gtk_file_filter_new (); gtk_file_filter_set_name (filter, _("All archives")); for (i = 0; open_type[i] != -1; i++) gtk_file_filter_add_mime_type (filter, mime_type_desc[open_type[i]].mime_type); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_sel), filter); gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (file_sel), filter); filter = gtk_file_filter_new (); gtk_file_filter_set_name (filter, _("All files")); gtk_file_filter_add_pattern (filter, "*"); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (file_sel), filter); /**/ g_object_set_data (G_OBJECT (file_sel), "fr_window", window); g_signal_connect (G_OBJECT (file_sel), "response", G_CALLBACK (open_file_response_cb), file_sel); gtk_widget_show (file_sel); }
static gboolean gtk_file_chooser_native_set_current_folder (GtkFileChooser *chooser, GFile *file, GError **error) { GtkFileChooserNative *self = GTK_FILE_CHOOSER_NATIVE (chooser); gboolean res; res = gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (self->dialog), file, error); if (res) { g_set_object (&self->current_folder, file); g_clear_object (&self->current_file); } return res; }
static void gth_import_preferences_dialog_init (GthImportPreferencesDialog *self) { GtkWidget *content; GFile *destination; GthSubfolderType subfolder_type; char *custom_format; self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GTH_TYPE_IMPORT_PREFERENCES_DIALOG, GthImportPreferencesDialogPrivate); self->priv->builder = _gtk_builder_new_from_file ("import-preferences.ui", "importer"); self->priv->settings = g_settings_new (GTHUMB_IMPORTER_SCHEMA); self->priv->help_visible = FALSE; gtk_window_set_title (GTK_WINDOW (self), _("Preferences")); gtk_window_set_resizable (GTK_WINDOW (self), FALSE); gtk_window_set_modal (GTK_WINDOW (self), TRUE); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), 5); gtk_container_set_border_width (GTK_CONTAINER (self), 5); content = _gtk_builder_get_widget (self->priv->builder, "import_preferences"); gtk_container_set_border_width (GTK_CONTAINER (content), 5); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (self))), content, TRUE, TRUE, 0); /* subfolder type */ self->priv->subfolder_type_list = _gtk_combo_box_new_with_texts (_("File date"), _("Current date"), NULL); gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_type_list), 0); gtk_widget_show (self->priv->subfolder_type_list); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("subfolder_type_box")), self->priv->subfolder_type_list, TRUE, TRUE, 0); /*gtk_label_set_mnemonic_widget (GTK_LABEL (GET_WIDGET ("subfolder_label")), self->priv->subfolder_type_list);*/ /* subfolder format */ self->priv->subfolder_format_list = _gtk_combo_box_new_with_texts (_("year-month-day"), _("year-month"), _("year"), _("custom format"), NULL); gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_format_list), 0); gtk_widget_show (self->priv->subfolder_format_list); gtk_box_pack_start (GTK_BOX (GET_WIDGET ("subfolder_type_box")), self->priv->subfolder_format_list, TRUE, TRUE, 0); gtk_dialog_add_button (GTK_DIALOG (self), _GTK_LABEL_CLOSE, GTK_RESPONSE_CLOSE); /* set widget data */ destination = gth_import_preferences_get_destination (); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (GET_WIDGET ("destination_filechooserbutton")), destination, NULL); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("single_subfolder_checkbutton")), g_settings_get_boolean (self->priv->settings, PREF_IMPORTER_SUBFOLDER_SINGLE)); subfolder_type = g_settings_get_enum (self->priv->settings, PREF_IMPORTER_SUBFOLDER_TYPE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("autosubfolder_checkbutton")), subfolder_type != GTH_SUBFOLDER_TYPE_NONE); gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_type_list), (subfolder_type == 0) ? 0 : subfolder_type - 1); gtk_combo_box_set_active (GTK_COMBO_BOX (self->priv->subfolder_format_list), g_settings_get_enum (self->priv->settings, PREF_IMPORTER_SUBFOLDER_FORMAT)); custom_format = g_settings_get_string (self->priv->settings, PREF_IMPORTER_SUBFOLDER_CUSTOM_FORMAT); if (custom_format != NULL) { gtk_entry_set_text (GTK_ENTRY (GET_WIDGET ("custom_format_entry")), custom_format); g_free (custom_format); } update_destination (self); g_signal_connect (self->priv->subfolder_type_list, "changed", G_CALLBACK (subfolder_type_list_changed_cb), self); g_signal_connect (self->priv->subfolder_format_list, "changed", G_CALLBACK (subfolder_format_list_changed_cb), self); g_signal_connect (GET_WIDGET ("destination_filechooserbutton"), "selection_changed", G_CALLBACK (destination_selection_changed_cb), self); g_signal_connect (GET_WIDGET ("single_subfolder_checkbutton"), "toggled", G_CALLBACK (subfolder_hierarchy_checkbutton_toggled_cb), self); g_signal_connect (self, "map-event", G_CALLBACK (preferences_dialog_map_event_cb), self); g_signal_connect (self, "delete-event", G_CALLBACK (preferences_dialog_delete_event_cb), self); g_signal_connect (GET_WIDGET ("autosubfolder_checkbutton"), "toggled", G_CALLBACK (autosubfolder_checkbutton_toggled_cb), self); g_signal_connect (GET_WIDGET ("custom_format_entry"), "changed", G_CALLBACK (custom_format_entry_changed_cb), self); g_signal_connect (GET_WIDGET ("custom_format_entry"), "icon-press", G_CALLBACK (custom_format_entry_icon_press_cb), self); g_signal_connect (self, "response", G_CALLBACK (dialog_response_cb), self); g_object_unref (destination); }
void gimp_export_dialog_set_image (GimpExportDialog *dialog, Gimp *gimp, GimpImage *image) { GFile *dir_file = NULL; GFile *name_file = NULL; GFile *ext_file = NULL; gchar *basename; g_return_if_fail (GIMP_IS_EXPORT_DIALOG (dialog)); g_return_if_fail (GIMP_IS_IMAGE (image)); GIMP_FILE_DIALOG (dialog)->image = image; gimp_file_dialog_set_file_proc (GIMP_FILE_DIALOG (dialog), NULL); /* * Priority of default paths for Export: * * 1. Last Export path * 2. Path of import source * 3. Path of XCF source * 4. Last path of any save to XCF * 5. Last Export path of any document * 6. The default path (usually the OS 'Documents' path) */ dir_file = gimp_image_get_exported_file (image); if (! dir_file) dir_file = g_object_get_data (G_OBJECT (image), "gimp-image-source-file"); if (! dir_file) dir_file = gimp_image_get_imported_file (image); if (! dir_file) dir_file = gimp_image_get_file (image); if (! dir_file) dir_file = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_SAVE_LAST_FILE_KEY); if (! dir_file) dir_file = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_EXPORT_LAST_FILE_KEY); if (! dir_file) dir_file = gimp_export_dialog_get_default_folder (gimp); /* Priority of default basenames for Export: * * 1. Last Export name * 3. Save URI * 2. Source file name * 3. 'Untitled' */ name_file = gimp_image_get_exported_file (image); if (! name_file) name_file = gimp_image_get_file (image); if (! name_file) name_file = gimp_image_get_imported_file (image); if (! name_file) name_file = gimp_image_get_untitled_file (image); /* Priority of default type/extension for Export: * * 1. Type of last Export * 2. Type of the image Import * 3. Type of latest Export of any document * 4. .png */ ext_file = gimp_image_get_exported_file (image); if (! ext_file) ext_file = gimp_image_get_imported_file (image); if (! ext_file) ext_file = g_object_get_data (G_OBJECT (gimp), GIMP_FILE_EXPORT_LAST_FILE_KEY); if (ext_file) g_object_ref (ext_file); else ext_file = g_file_new_for_uri ("file:///we/only/care/about/extension.png"); if (ext_file) { GFile *tmp_file = file_utils_file_with_new_ext (name_file, ext_file); basename = g_path_get_basename (gimp_file_get_utf8_name (tmp_file)); g_object_unref (tmp_file); g_object_unref (ext_file); } else { basename = g_path_get_basename (gimp_file_get_utf8_name (name_file)); } if (g_file_query_file_type (dir_file, G_FILE_QUERY_INFO_NONE, NULL) == G_FILE_TYPE_DIRECTORY) { gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), dir_file, NULL); } else { GFile *parent_file = g_file_get_parent (dir_file); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), parent_file, NULL); g_object_unref (parent_file); } gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), basename); }
static void ide_editor_view_actions_save (GSimpleAction *action, GVariant *param, gpointer user_data) { IdeEditorView *self = user_data; IdeContext *context; IdeBufferManager *buffer_manager; IdeFile *file; IdeProgress *progress = NULL; IdeVcs *vcs; GFile *workdir; g_assert (IDE_IS_EDITOR_VIEW (self)); file = ide_buffer_get_file (IDE_BUFFER (self->document)); context = ide_buffer_get_context (IDE_BUFFER (self->document)); buffer_manager = ide_context_get_buffer_manager (context); vcs = ide_context_get_vcs (context); workdir = ide_vcs_get_working_directory (vcs); if (ide_file_get_is_temporary (file)) { GtkDialog *dialog; GtkWidget *toplevel; GtkWidget *suggested; toplevel = gtk_widget_get_toplevel (GTK_WIDGET (self)); dialog = g_object_new (GTK_TYPE_FILE_CHOOSER_DIALOG, "action", GTK_FILE_CHOOSER_ACTION_SAVE, "do-overwrite-confirmation", TRUE, "local-only", FALSE, "modal", TRUE, "select-multiple", FALSE, "show-hidden", FALSE, "transient-for", toplevel, "title", _("Save Document"), NULL); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (dialog), workdir, NULL); gtk_dialog_add_buttons (GTK_DIALOG (dialog), _("Cancel"), GTK_RESPONSE_CANCEL, _("Save"), GTK_RESPONSE_OK, NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); suggested = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); gtk_style_context_add_class (gtk_widget_get_style_context (suggested), GTK_STYLE_CLASS_SUGGESTED_ACTION); g_signal_connect (dialog, "response", G_CALLBACK (save_temp_response), g_object_ref (self)); gtk_window_present (GTK_WINDOW (dialog)); return; } ide_buffer_manager_save_file_async (buffer_manager, IDE_BUFFER (self->document), file, &progress, NULL, save_file_cb, g_object_ref (self)); g_object_bind_property (progress, "fraction", self->progress_bar, "fraction", G_BINDING_SYNC_CREATE); gtk_widget_show (GTK_WIDGET (self->progress_bar)); g_clear_object (&progress); }
static void screenshot_ready_cb (GdkPixbuf *pixbuf, gpointer user_data) { SaveData *save_data = user_data; GtkWidget *file_sel; if (pixbuf == NULL) { _gtk_error_dialog_from_gerror_show (GTK_WINDOW (save_data->browser), _("Could not take a screenshot"), NULL); save_date_free (save_data); return; } save_data->image = gth_image_new_for_pixbuf (pixbuf); file_sel = gth_file_chooser_dialog_new (_("Save Image"), GTK_WINDOW (save_data->browser), "image-saver"); gtk_window_set_modal (GTK_WINDOW (file_sel), TRUE); { char *last_uri; GFile *last_folder; GthFileData *file_data; char *prefix; char *display_name; int attempt; last_uri = g_settings_get_string (save_data->settings, PREF_GSTREAMER_TOOLS_SCREESHOT_LOCATION); if ((last_uri == NULL) || (strcmp (last_uri, "~") == 0) || (strcmp (last_uri, "file://~") == 0)) { const char *dir; dir = g_get_user_special_dir (G_USER_DIRECTORY_PICTURES); if (dir != NULL) last_folder = g_file_new_for_path (dir); else last_folder = g_file_new_for_uri (get_home_uri ()); } else last_folder = g_file_new_for_uri (last_uri); gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (file_sel), last_folder, NULL); file_data = gth_media_viewer_page_get_file_data (save_data->page); prefix = _g_utf8_remove_extension (g_file_info_get_display_name (file_data->info)); if (prefix == NULL) prefix = g_strdup (C_("Filename", "Screenshot")); display_name = NULL; for (attempt = 1; attempt < MAX_ATTEMPTS; attempt++) { GFile *proposed_file; g_free (display_name); display_name = g_strdup_printf ("%s-%02d.jpeg", prefix, attempt); proposed_file = g_file_get_child_for_display_name (last_folder, display_name, NULL); if ((proposed_file != NULL) && ! g_file_query_exists (proposed_file, NULL)) { g_object_unref (proposed_file); break; } } if (display_name != NULL) { gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (file_sel), display_name); g_free (display_name); } g_free (prefix); g_object_unref (last_folder); g_free (last_uri); } g_signal_connect (GTK_DIALOG (file_sel), "response", G_CALLBACK (save_as_response_cb), save_data); gtk_widget_show (file_sel); }
/* Finish up the user's Export iFiction Record command. This is a callback and the GDK lock is held when entering this function. */ void i7_story_save_ifiction(I7Story *story) { /* Work out where the file should be */ GFile *project_file = i7_document_get_file(I7_DOCUMENT(story)); if(project_file == NULL) { g_warning("Tried to save iFiction record of story without associated file"); return; /* This shouldn't happen because the file is saved before compilation */ } GFile *ifiction_file = g_file_get_child(project_file, "Metadata.iFiction"); /* Prompt user to save iFiction file if it exists */ if(g_file_query_exists(ifiction_file, NULL)) { /* Make a file filter */ GtkFileFilter *filter = gtk_file_filter_new(); gtk_file_filter_set_name(filter, _("iFiction records (.iFiction)")); gtk_file_filter_add_pattern(filter, "*.iFiction"); /* Make up a default file name */ gchar *name = i7_document_get_display_name(I7_DOCUMENT(story)); /* project_file is not NULL so neither is name */ *(strrchr(name, '.')) = '\0'; gchar *filename = g_strconcat(name, ".iFiction", NULL); g_free(name); /* Create a file chooser */ GtkWidget *dialog = gtk_file_chooser_dialog_new(_("Save iFiction record"), GTK_WINDOW(story), GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(dialog), TRUE); gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename); g_free(filename); GFile *parent_file = g_file_get_parent(project_file); /* Ignore error */ gtk_file_chooser_set_current_folder_file(GTK_FILE_CHOOSER(dialog), parent_file, NULL); g_object_unref(parent_file); gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter); /* Copy the finished file to the chosen location */ if (gtk_dialog_run(GTK_DIALOG(dialog)) == GTK_RESPONSE_ACCEPT) { GFile *dest_file = gtk_file_chooser_get_file(GTK_FILE_CHOOSER(dialog)); GError *error = NULL; if(!g_file_copy(ifiction_file, dest_file, G_FILE_COPY_OVERWRITE, NULL, NULL, NULL, &error)) { IO_ERROR_DIALOG(GTK_WINDOW(story), dest_file, error, _("copying iFiction record")); } g_object_unref(dest_file); } gtk_widget_destroy(dialog); } else error_dialog(GTK_WINDOW(story), NULL, _("The compiler failed to create an iFiction record; check the " "results page to see why.")); g_object_unref(ifiction_file); g_object_unref(project_file); }
static void dlg_extract__common (FrWindow *window, GList *selected_files, char *base_dir_for_selection) { DialogData *data; data = g_new0 (DialogData, 1); data->settings = g_settings_new (FILE_ROLLER_SCHEMA_EXTRACT); data->window = window; data->selected_files = selected_files; data->base_dir_for_selection = base_dir_for_selection; data->extract_clicked = FALSE; data->dialog = gtk_file_chooser_dialog_new (C_("Window title", "Extract"), GTK_WINDOW (data->window), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER, _GTK_LABEL_CANCEL, GTK_RESPONSE_CANCEL, _GTK_LABEL_EXTRACT, GTK_RESPONSE_OK, NULL); gtk_window_set_default_size (GTK_WINDOW (data->dialog), 530, 510); gtk_file_chooser_set_select_multiple (GTK_FILE_CHOOSER (data->dialog), FALSE); gtk_file_chooser_set_local_only (GTK_FILE_CHOOSER (data->dialog), FALSE); gtk_file_chooser_set_create_folders (GTK_FILE_CHOOSER (data->dialog), TRUE); gtk_dialog_set_default_response (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK); data->builder = _gtk_builder_new_from_resource ("extract-dialog-options.ui"); if (data->builder == NULL) return; gtk_file_chooser_set_extra_widget (GTK_FILE_CHOOSER (data->dialog), GET_WIDGET ("extra_widget")); /* Set widgets data. */ gtk_file_chooser_set_current_folder_file (GTK_FILE_CHOOSER (data->dialog), fr_window_get_extract_default_dir (window), NULL); if (data->selected_files != NULL) gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("selected_files_radiobutton")), TRUE); else { gtk_widget_set_sensitive (GET_WIDGET ("selected_files_radiobutton"), FALSE); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("all_files_radiobutton")), TRUE); } gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_newer_checkbutton")), g_settings_get_boolean (data->settings, PREF_EXTRACT_SKIP_NEWER)); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (GET_WIDGET ("keep_structure_checkbutton")), g_settings_get_boolean (data->settings, PREF_EXTRACT_RECREATE_FOLDERS)); /* Set the signals handlers. */ g_signal_connect (G_OBJECT (data->dialog), "destroy", G_CALLBACK (file_selector_destroy_cb), data); g_signal_connect (G_OBJECT (data->dialog), "response", G_CALLBACK (file_selector_response_cb), data); g_signal_connect (G_OBJECT (GET_WIDGET ("file_pattern_entry")), "changed", G_CALLBACK (files_entry_changed_cb), data); /* Run dialog. */ gtk_window_set_modal (GTK_WINDOW (data->dialog),TRUE); gtk_widget_show (data->dialog); }
/*! * \fn G_MODULE_EXPORT void openAssistantNewCsu(GtkWidget *widget, gpointer data) * Open the assistant for a new csu file * \param[in] widget the widget which send the signal * \param[in] data the globalData */ G_MODULE_EXPORT void openAssistantNewCsu(GtkWidget *widget, gpointer data) { globalData *user_data = (globalData*) data; char home_path[SIZE_MAX_FILE_NAME]=""; gchar system_path[SIZE_MAX_FILE_NAME]=""; list_game_config *ptr_list_config; gint i; #ifndef PORTABLE readHomePathSlash(home_path); readSystemPath(system_path); #else readHomePath(system_path); #endif // PORTABLE /* creating of the assistant */ user_data->ptr_new_csu_file_assistant = gtk_assistant_new(); /* Set the assistant windows */ gtk_window_set_transient_for(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GTK_WINDOW(user_data->ptr_main_window)); gtk_window_set_gravity(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GDK_GRAVITY_CENTER); gtk_window_set_position(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GTK_WIN_POS_CENTER_ON_PARENT); gtk_window_set_modal(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),TRUE); gtk_window_set_type_hint(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),GDK_WINDOW_TYPE_HINT_DIALOG); gtk_window_resize(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),700,400); gtk_window_set_title(GTK_WINDOW(user_data->ptr_new_csu_file_assistant),_("New csu file assistant")); /*Set the signal of the assistant */ g_signal_connect(user_data->ptr_new_csu_file_assistant,"delete-event", G_CALLBACK(deleteEventAssistantNewCsu),user_data); g_signal_connect(user_data->ptr_new_csu_file_assistant,"cancel", G_CALLBACK(deleteAssistantNewCsu),user_data); g_signal_connect(user_data->ptr_new_csu_file_assistant,"prepare", G_CALLBACK(preparePageAssistantNewCsu),user_data); g_signal_connect(user_data->ptr_new_csu_file_assistant,"close", G_CALLBACK(endAssistantNewCsu),user_data); /* Set the first page */ GtkWidget *grid_1 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_1"); gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1); gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,GTK_ASSISTANT_PAGE_INTRO); gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_1,_("General information")); /* Configure the file chooser */ gtk_entry_set_max_length(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid_1),1,0)),SIZE_MAX_FILE_NAME/8); gtk_file_chooser_set_current_folder_file(GTK_FILE_CHOOSER(gtk_grid_get_child_at(GTK_GRID(grid_1),1,1)),g_file_new_for_path(g_locale_to_utf8(system_path,-1,NULL,NULL,NULL)),NULL); /* Set the combo box of the game configuration */ GtkWidget *combo_config = gtk_combo_box_text_new(); ptr_list_config = readConfigListFile(home_path); for (i=0 ; i<ptr_list_config->nb_config ; i++) gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),i,NULL,ptr_list_config->name_game_config[i]); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),ptr_list_config->nb_config,NULL,_("Add a new game configuration")); gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(combo_config),ptr_list_config->nb_config +1,NULL,_("Use an other game configuration")); gtk_grid_attach(GTK_GRID(grid_1),combo_config,1,3,1,1); g_signal_connect(combo_config,"changed", G_CALLBACK(chooseGameConfigurationNewAssistant),user_data); closeListGameConfig(ptr_list_config); /* Set the second page */ GtkWidget *scrolled_window_name = getWidgetFromBuilder(user_data->ptr_builder,"scrolled_window_new_csu_file_assistant_2"); gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name); gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name,GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),scrolled_window_name,_("Player's names")); /* Set the grid */ GtkWidget *grid_name = gtk_grid_new(); gtk_grid_set_column_spacing(GTK_GRID(grid_name),10); gtk_grid_set_row_spacing(GTK_GRID(grid_name),10); gtk_grid_set_column_homogeneous(GTK_GRID(grid_name),TRUE); #if GTK_MINOR_VERSION >= 12 gtk_widget_set_margin_end(grid_name,10); gtk_widget_set_margin_start(grid_name,10); #else gtk_widget_set_margin_right(grid_name,10); gtk_widget_set_margin_left(grid_name,10); #endif // GTK_MINOR_VERSION gtk_widget_set_margin_top(grid_name,10); gtk_widget_set_margin_bottom(grid_name,10); gtk_container_add(GTK_CONTAINER(gtk_bin_get_child(GTK_BIN(scrolled_window_name))),grid_name); /* Set the third page */ GtkWidget *grid_3 = getWidgetFromBuilder(user_data->ptr_builder,"grid_new_csu_file_assistant_3"); gtk_assistant_append_page(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3); gtk_assistant_set_page_type(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3,GTK_ASSISTANT_PAGE_CONFIRM); gtk_assistant_set_page_title(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),grid_3,_("Distributor and validation")); GtkWidget *combo_distributor = gtk_combo_box_text_new(); gtk_grid_attach(GTK_GRID(grid_3),combo_distributor,1,0,1,1); g_signal_connect(combo_distributor,"changed", G_CALLBACK(validAssistantNewCsuThree),user_data); cleanAssistantNewCsu(user_data); gtk_widget_show_all(user_data->ptr_new_csu_file_assistant); }