static void assistant_instert_book_options_page (hierarchy_data *data) { kvp_frame *slots = qof_book_get_slots (gnc_get_current_book ()); GtkWidget *vbox = gtk_vbox_new (FALSE, 0); data->options = gnc_option_db_new_for_type (QOF_ID_BOOK); gnc_option_db_load_from_kvp (data->options, slots); gnc_option_db_clean (data->options); data->optionwin = gnc_options_dialog_new_modal (TRUE, _("New Book Options")); gnc_options_dialog_build_contents_full (data->optionwin, data->options, FALSE); gnc_options_dialog_set_close_cb (data->optionwin, book_options_dialog_close_cb, (gpointer)data->options); gnc_options_dialog_set_new_book_option_values (data->options); gtk_widget_reparent (gnc_options_dialog_notebook (data->optionwin), vbox); gtk_widget_show_all (vbox); gtk_assistant_insert_page (GTK_ASSISTANT(data->dialog), vbox, 2); gtk_assistant_set_page_title (GTK_ASSISTANT(data->dialog), vbox, _("New Book Options")); gtk_assistant_set_page_complete (GTK_ASSISTANT(data->dialog), vbox, TRUE); }
static NPWPage* npw_druid_add_new_page (NPWDruid* druid) { gint current; NPWPage* page; /* Get page in cache */ current = gtk_assistant_get_current_page (GTK_ASSISTANT (druid->window)); page = g_queue_peek_nth (druid->page_list, current - (druid->no_selection ? 0 : 1) + 1); if (page == NULL) { /* Page not found in cache, create */ GtkBuilder *builder; GtkWidget *widget; GtkAssistantPageType type; GtkWidget *table; GtkAssistant *assistant; /* Build another complete wizard dialog from the gtk builder file * but keep only the property assistant page */ builder = gtk_builder_new (); if (!gtk_builder_add_from_file (builder, GTK_BUILDER_UI_FILE, NULL)) { g_warn_if_reached (); g_object_unref (builder); return NULL; } assistant = GTK_ASSISTANT (gtk_builder_get_object (builder, NEW_PROJECT_DIALOG)); widget = GTK_WIDGET (gtk_builder_get_object (builder, PROPERTY_PAGE)); table = GTK_WIDGET (gtk_builder_get_object (builder, PROPERTY_TABLE)); type = gtk_assistant_get_page_type (assistant, widget); gtk_container_remove (GTK_CONTAINER (assistant), widget); gtk_assistant_insert_page (GTK_ASSISTANT (druid->window), widget, current + 1); gtk_assistant_set_page_type (GTK_ASSISTANT (druid->window), widget, type); gtk_assistant_set_page_complete (GTK_ASSISTANT (druid->window), widget, TRUE); gtk_widget_destroy (GTK_WIDGET (assistant)); /* Builder get reference on all built widget, so unref it when all work is done */ g_object_unref (builder); /* Create new page */ page = npw_page_new (druid->values); npw_page_set_widget (page, table); /* Add page in cache */ g_queue_push_tail (druid->page_list, page); } return page; }
void glade_gtk_assistant_replace_child (GladeWidgetAdaptor * adaptor, GObject * container, GObject * current, GObject * new_object) { GtkAssistant *assistant = GTK_ASSISTANT (container); GtkWidget *page = GTK_WIDGET (new_object), *old_page = GTK_WIDGET (current); gint pos = glade_gtk_assistant_get_page (assistant, old_page); gboolean set_current = gtk_assistant_get_current_page (assistant) == pos; assistant_remove_child (assistant, old_page); gtk_assistant_insert_page (assistant, page, pos); glade_gtk_assistant_update_page_type (assistant); if (set_current) gtk_assistant_set_current_page (assistant, pos); }
void glade_gtk_assistant_set_child_property (GladeWidgetAdaptor * adaptor, GObject * container, GObject * child, const gchar * property_name, const GValue * value) { if (strcmp (property_name, "position") == 0) { GtkAssistant *assistant = GTK_ASSISTANT (container); GtkWidget *widget = GTK_WIDGET (child); gint pos; gboolean set_current; if ((pos = g_value_get_int (value)) < 0) return; if (pos == glade_gtk_assistant_get_page (assistant, widget)) return; set_current = gtk_assistant_get_current_page (assistant) == glade_gtk_assistant_get_page (assistant, widget); g_object_ref (child); assistant_remove_child (assistant, widget); gtk_assistant_insert_page (assistant, widget, pos); g_object_unref (child); if (set_current) gtk_assistant_set_current_page (assistant, pos); glade_gtk_assistant_update_page_type (assistant); glade_gtk_assistant_update_position (assistant); return; } /* Chain Up */ GWA_GET_CLASS (GTK_TYPE_WINDOW)->child_set_property (adaptor, container, child, property_name, value); }
JNIEXPORT jint JNICALL Java_org_gnome_gtk_GtkAssistant_gtk_1assistant_1insert_1page ( JNIEnv* env, jclass cls, jlong _self, jlong _page, jint _position ) { gint result; jint _result; GtkAssistant* self; GtkWidget* page; gint position; // convert parameter self self = (GtkAssistant*) _self; // convert parameter page page = (GtkWidget*) _page; // convert parameter position position = (gint) _position; // call function result = gtk_assistant_insert_page(self, page, position); // cleanup parameter self // cleanup parameter page // cleanup parameter position // translate return value to JNI type _result = (jint) result; // and finally return _result; }
static VALUE rg_insert_page(VALUE self, VALUE page, VALUE position) { return INT2NUM(gtk_assistant_insert_page(_SELF(self), GTK_WIDGET(RVAL2GOBJ(page)), NUM2INT(position))); }
/* Fill project selection page */ static gboolean npw_druid_fill_selection_page (NPWDruid* druid, GFile *templates) { gchar* dir; const gchar * const * sys_dir; /* Remove all previous data */ gtk_notebook_remove_page(druid->project_book, 0); npw_header_list_free (druid->header_list); anjuta_autogen_clear_library_path (druid->gen); /* Create list of projects */ druid->header_list = npw_header_list_new (); if (templates != NULL) { if (g_file_query_file_type (templates, 0, NULL) == G_FILE_TYPE_DIRECTORY) { /* Read project template only in specified directory, * other directories can still be used to get included * files */ gchar *directory = g_file_get_path (templates); npw_header_list_readdir (&druid->header_list, directory); anjuta_autogen_set_library_path (druid->gen, directory); g_free (directory); } else { /* templates is a file, so read only it as a project template */ gchar *filename = g_file_get_path (templates); npw_header_list_read (&druid->header_list, filename); g_free (filename); } } dir = g_build_filename (g_get_user_data_dir (), "anjuta", "templates", NULL); if (templates == NULL) { /* Read project template in user directory, * normally ~/.local/share/anjuta/templates, * the first template read override the others */ npw_header_list_readdir (&druid->header_list, dir); } anjuta_autogen_set_library_path (druid->gen, dir); g_free (dir); for (sys_dir = g_get_system_data_dirs (); *sys_dir != NULL; sys_dir++) { dir = g_build_filename (*sys_dir, "anjuta", "templates", NULL); if (templates == NULL) { /* Read project template in system directory */ npw_header_list_readdir (&druid->header_list, dir); } anjuta_autogen_set_library_path (druid->gen, dir); g_free (dir); } if (templates == NULL) { /* Read anjuta installation directory */ npw_header_list_readdir (&druid->header_list, PROJECT_WIZARD_DIRECTORY); } anjuta_autogen_set_library_path (druid->gen, PROJECT_WIZARD_DIRECTORY); switch (g_list_length (druid->header_list)) { case 0: anjuta_util_dialog_error (GTK_WINDOW (ANJUTA_PLUGIN (druid->plugin)->shell),_("Unable to find any project template in %s"), PROJECT_WIZARD_DIRECTORY); return FALSE; case 1: druid->header = (NPWHeader *)((GList *)druid->header_list->data)->data; druid->no_selection = TRUE; gtk_container_remove (GTK_CONTAINER (druid->window), druid->project_page); gtk_assistant_insert_page (GTK_ASSISTANT (druid->window), druid->progress_page, 0); npw_druid_set_busy (druid, FALSE); break; default: /* Add all necessary notebook page */ druid->no_selection = FALSE; g_list_foreach (druid->header_list, cb_druid_insert_project_page, druid); gtk_widget_show_all (GTK_WIDGET (druid->project_book)); } return TRUE; }
/* Fill dialog page */ static void npw_druid_fill_error_page (NPWDruid* druid, GtkWidget *extra_widget, GtkMessageType type, const gchar *detail, const gchar *mesg,...) { GtkAssistant *assistant; GtkWidget *page; va_list args; gchar *message; const gchar *stock_id = NULL; const gchar *title = NULL; assistant = GTK_ASSISTANT (druid->window); /* Add page to assistant after current one */ page = druid->error_page; gtk_assistant_insert_page (assistant, page, gtk_assistant_get_current_page (assistant) + 1); /* Set dialog kind */ switch (type) { case GTK_MESSAGE_INFO: stock_id = GTK_STOCK_DIALOG_INFO; title = _("Information"); break; case GTK_MESSAGE_QUESTION: stock_id = GTK_STOCK_DIALOG_QUESTION; title = _("Warning"); break; case GTK_MESSAGE_WARNING: stock_id = GTK_STOCK_DIALOG_WARNING; title = _("Warning"); break; case GTK_MESSAGE_ERROR: stock_id = GTK_STOCK_DIALOG_ERROR; title = _("Error"); break; case GTK_MESSAGE_OTHER: title = _("Message"); break; default: g_warning ("Unknown GtkMessageType %u", type); break; } gtk_label_set_text (GTK_LABEL (druid->error_title), title); gtk_assistant_set_page_title (assistant, page, title); if (type == GTK_MESSAGE_ERROR) { gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_CONTENT); gtk_assistant_set_page_complete (assistant, page, FALSE); } else { gtk_assistant_set_page_type (assistant, page, GTK_ASSISTANT_PAGE_PROGRESS); gtk_assistant_set_page_complete (assistant, page, TRUE); } gtk_image_set_from_stock (druid->error_icon, stock_id, GTK_ICON_SIZE_DIALOG); /* Set message */ va_start (args, mesg); message = g_strdup_vprintf (mesg, args); va_end (args); gtk_label_set_markup (druid->error_message, message); g_free (message); /* Set detail */ if (detail == NULL) { gtk_widget_hide (druid->error_detail); } else { GtkLabel *label; gtk_widget_show (druid->error_detail); label = GTK_LABEL (gtk_bin_get_child (GTK_BIN (druid->error_detail))); gtk_label_set_text (label, detail); } if (druid->error_extra_widget) gtk_widget_destroy (druid->error_extra_widget); druid->error_extra_widget = NULL; /* Set extra widget */ if (extra_widget) { gtk_box_pack_start (GTK_BOX (druid->error_vbox), extra_widget, FALSE, FALSE, 10); gtk_widget_show (extra_widget); druid->error_extra_widget = extra_widget; } }
static void on_druid_real_prepare (GtkAssistant* assistant, GtkWidget *page, NPWDruid* druid) { if (page == druid->progress_page) { gint previous; gboolean last_warning; previous = gtk_assistant_get_current_page (assistant) - 1; last_warning = gtk_assistant_get_nth_page (assistant, previous) == druid->error_page; if (last_warning) { /* Remove warning page */ gtk_container_remove (GTK_CONTAINER (assistant), druid->error_page); previous--; } if (druid->no_selection) previous++; /* Generate the next page */ if (previous == PROJECT_PAGE_INDEX) { const gchar* new_project; new_project = npw_header_get_filename (druid->header); if (druid->project_file != new_project) { npw_druid_remove_following_page (druid); /* Check if necessary programs for this project is installed */ if (!last_warning && !check_and_warn_missing (druid)) { gtk_assistant_set_current_page (assistant, gtk_assistant_get_current_page (assistant) + 1); return; } /* Change project */ druid->project_file = new_project; anjuta_autogen_set_input_file (druid->gen, druid->project_file, "[+","+]"); } } else { if (!npw_druid_save_valid_values (druid)) { /* Display error */ gtk_assistant_set_current_page (assistant, gtk_assistant_get_current_page (assistant) + 1); return; } } if (g_queue_peek_nth (druid->page_list, previous) == NULL) { /* Regenerate new page */ gtk_assistant_set_page_complete (assistant, page, FALSE); if (druid->parser != NULL) npw_page_parser_free (druid->parser); druid->parser = npw_page_parser_new (npw_druid_add_new_page (druid), druid->project_file, previous); anjuta_autogen_set_output_callback (druid->gen, on_druid_parse_page, druid->parser, NULL); anjuta_autogen_write_definition_file (druid->gen, druid->values, NULL); anjuta_autogen_execute (druid->gen, on_druid_get_new_page, druid, NULL); } else { /* Page is already in cache, change the page to display it */ on_druid_get_new_page (NULL, druid); } } else if (page == druid->finish_page) { npw_druid_set_busy (druid, FALSE); gtk_container_remove (GTK_CONTAINER (assistant), druid->error_page); gtk_container_remove (GTK_CONTAINER (assistant), druid->progress_page); } else { npw_druid_set_busy (druid, FALSE); if (page != druid->error_page) gtk_container_remove (GTK_CONTAINER (assistant), druid->error_page); /* Move progress page */ gtk_container_remove (GTK_CONTAINER (assistant), druid->progress_page); gtk_assistant_insert_page (assistant, druid->progress_page, gtk_assistant_get_current_page (assistant) + 1); gtk_assistant_set_page_title (assistant, druid->progress_page, "..."); } }