Пример #1
0
extern void auto_select_algorithms(gtk_widgets_t *data, char *cipher, char *hash, char *mode)
{
	/*
	 * ciphers
	 */
	const char **ciphers = list_of_ciphers();
	unsigned slctd_cipher = 0;

	gtk_combo_box_text_remove_all((GtkComboBoxText *)data->crypto_combo);
	gtk_combo_box_text_append_text((GtkComboBoxText *)data->crypto_combo, SELECT_CIPHER);
	for (unsigned i = 0; ciphers[i]; i++)
	{
		if (cipher && !strcasecmp(ciphers[i], cipher))
			slctd_cipher = i + 1;
		gtk_combo_box_text_append_text((GtkComboBoxText *)data->crypto_combo, ciphers[i]);
	}
	gtk_combo_box_set_active((GtkComboBox *)data->crypto_combo, slctd_cipher);

	/*
	 * hashes
	 */
	const char **hashes = list_of_hashes();
	unsigned slctd_hash = 0;
	gtk_combo_box_text_remove_all((GtkComboBoxText *)data->hash_combo);
	gtk_combo_box_text_append_text((GtkComboBoxText *)data->hash_combo, SELECT_HASH);
	for (unsigned i = 0; hashes[i]; i++)
	{
		if (hash && !strcasecmp(hashes[i], hash))
			slctd_hash = i + 1;
		gtk_combo_box_text_append_text((GtkComboBoxText *)data->hash_combo, hashes[i]);
	}
	gtk_combo_box_set_active((GtkComboBox *)data->hash_combo, slctd_hash);

	/*
	 * modes
	 */
	const char **modes = list_of_modes();
	unsigned slctd_mode = 0;
	gtk_combo_box_text_remove_all((GtkComboBoxText *)data->mode_combo);
	gtk_combo_box_text_append_text((GtkComboBoxText *)data->mode_combo, SELECT_MODE);
	for (unsigned i = 0; modes[i]; i++)
	{
		if (mode && !strcasecmp(modes[i], mode))
			slctd_mode = i + 1;
		gtk_combo_box_text_append_text((GtkComboBoxText *)data->mode_combo, modes[i]);
	}
	gtk_combo_box_set_active((GtkComboBox *)data->mode_combo, slctd_mode);

	return;
}
Пример #2
0
static VALUE
rg_remove_all(VALUE self)
{
    gtk_combo_box_text_remove_all(_SELF(self));

    return self;
}
Пример #3
0
void
glade_gtk_combo_box_text_set_property (GladeWidgetAdaptor *adaptor,
                                       GObject            *object,
                                       const gchar        *id,
                                       const GValue       *value)
{
  if (!strcmp (id, "glade-items"))
    {
      GList *string_list, *l;
      GladeString *string;
      gint active;

      string_list = g_value_get_boxed (value);

      active = gtk_combo_box_get_active (GTK_COMBO_BOX (object));

      /* Update comboboxtext items */
      gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (object));

      for (l = string_list; l; l = l->next)
        {
          string = l->data;

          gtk_combo_box_text_append (GTK_COMBO_BOX_TEXT (object), string->id, string->string);
        }

      gtk_combo_box_set_active (GTK_COMBO_BOX (object),
                                CLAMP (active, 0, g_list_length (string_list) - 1));
    }
  else
    GWA_GET_CLASS (GTK_TYPE_COMBO_BOX)->set_property (adaptor, object, id, value);
}
Пример #4
0
static void fill_combo_box_entry(GtkComboBox *box, uint32_t count, GList *items, gboolean *multi)
{
  gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(box));

  if(count == 0)
  {
    gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(box))), "");
    *multi = FALSE;
    return;
  }

  if(count > 1)
  {
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(box),
                                   _("<leave unchanged>")); // FIXME: should be italic!
    gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(box), GTK_SENSITIVITY_AUTO);
    *multi = TRUE;
  }
  else
  {
    gtk_combo_box_set_button_sensitivity(GTK_COMBO_BOX(box), GTK_SENSITIVITY_OFF);
    *multi = FALSE;
  }
  for(GList *iter = items; iter; iter = g_list_next(iter))
  {
    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(box), iter->data); // FIXME: dt segfaults when there
                                                                         // are illegal characters in the
                                                                         // string.
  }
  gtk_combo_box_set_active(GTK_COMBO_BOX(box), 0);
}
Пример #5
0
static void
e_webdav_discover_content_fill_calendar_emails (GtkComboBox *combo_box,
						GSList *calendar_user_addresses)
{
	GtkComboBoxText *text_combo;
	gboolean any_added = FALSE;
	GSList *link;

	/* It's okay to pass NULL here */
	if (!combo_box)
		return;

	g_return_if_fail (GTK_IS_COMBO_BOX_TEXT (combo_box));

	text_combo = GTK_COMBO_BOX_TEXT (combo_box);

	gtk_combo_box_text_remove_all (text_combo);

	for (link = calendar_user_addresses; link; link = g_slist_next (link)) {
		const gchar *address = link->data;

		if (address && *address) {
			gtk_combo_box_text_append_text (text_combo, address);
			any_added = TRUE;
		}
	}

	if (any_added)
		gtk_combo_box_set_active (combo_box, 0);
}
Пример #6
0
void fl_set_working_dir(const gchar *dir)
{
	gchar *aux;

	if (dir == NULL || strcmp(working_dir->str, dir) == 0)
		return;

	/* set the new working_dir */
	g_string_assign(working_dir, dir);
	expand_dir(working_dir);

	aux = str_filename_to_utf8(working_dir->str, NULL);
	if (aux == NULL) {
		/* if we can't convert to UTF-8, leave it as is
		   (let Gtk do the complaining...) */
		g_string_assign(working_dir_utf8, dir);
	}
	else {
		g_string_assign(working_dir_utf8, aux);
		free(aux);
	}
	
	gtk_entry_set_text(ent_wd, working_dir_utf8->str);
	
	/* update the directory mru list */
	mru_add(dir_mru, working_dir_utf8->str);

	gtk_combo_box_text_remove_all(combo_wd);
	g_list_foreach(GLIST(dir_mru->list), glist_2_combo, combo_wd);

	if (check_working_dir())
		load_file_list();
	else
		clear_file_list();
}
Пример #7
0
void updateMoves()
{
	gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(cbt_move));
	for(int i=0; i<moveFile.header.count; i++) {
		gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(cbt_move), currMove,
			moveFile.moves[i].name);
	}
}
Пример #8
0
static void
setComboContent(GtkComboBoxText * combo, const std::list<std::string> & content)
{
	gtk_combo_box_text_remove_all(combo);
	std::list<std::string>::const_iterator iter(content.begin());
	for(; iter != content.end(); iter++) {
		gtk_combo_box_text_append_text(combo, iter->c_str());
	}
}
Пример #9
0
static void cs3d_prop_activate_lcb(GtkWidget * widget, Tcs3_diag *diag) {
	Tcs3_arr *tmp;
	gchar *tmpstr;

	gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(diag->value))), "");
#if GTK_CHECK_VERSION(3,0,0)
			gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(diag->value));
#else
			GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(diag->value)));
  			gtk_list_store_clear(store);
#endif
	tmpstr = gtk_editable_get_chars(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(diag->property))), 0, -1);
	tmp = cs3_arr_from_property(tmpstr);
	g_free(tmpstr);
	if (tmp) {
		GList *list, *tmplist;
		list = pointer_arr2glist(tmp->possibilities);
		if (list) {
			gchar *tmpstr2=NULL;
			if (!tmp->force_pos) {
					tmpstr2 = gtk_editable_get_chars(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(diag->value))), 0, -1);
			}

			for (tmplist=g_list_first(list);tmplist;tmplist=g_list_next(tmplist)) {
				if (tmplist->data) {
					gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(diag->value),tmplist->data);
				}
			}
			g_list_free(list);
			if (tmpstr2) {
				gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(diag->value))), tmpstr2);
				g_free(tmpstr2);
			}
			switch(tmp->buttype) {
			case but_color:
				gtk_widget_set_sensitive(diag->extra_but, TRUE);
			break;
			default:
				gtk_widget_set_sensitive(diag->extra_but, FALSE);
			break;
			}
		} else {
				gtk_widget_set_sensitive(diag->extra_but, FALSE);
		}
		gtk_editable_set_editable(GTK_EDITABLE(gtk_bin_get_child(GTK_BIN(diag->value))), !tmp->force_pos);
	} else {
		gtk_widget_set_sensitive(diag->extra_but, FALSE);
	}
}
Пример #10
0
void loadTypes(char *filename)
{
	typeFile_t typeFile;

	gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(cbt_type));

	pk_openTypeFile(&typeFile, filename);

	for(int i=0; i<typeFile.header.count; i++) {
		gtk_combo_box_text_insert_text(GTK_COMBO_BOX_TEXT(cbt_type), i,
			typeFile.types[i].header.name);
	}

	pk_freeTypeFile(&typeFile);
}
Пример #11
0
void
gl_combo_util_set_strings (GtkComboBoxText   *combo,
                           GList             *list)
{
	GList        *p;

	g_return_if_fail (list);

        gtk_combo_box_text_remove_all (combo);

	for (p=list; p!=NULL; p=p->next) {
		if (p->data) {
			gtk_combo_box_text_append_text (combo, p->data);
		}
	}
}
Пример #12
0
static void cs3d_html5_clicked_lcb(GtkWidget * widget, Tcs3_diag *diag) {
	GList *tmplist, *list;
	list = glist_with_html_tags(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(diag->html5)));
#if GTK_CHECK_VERSION(3,0,0)
			gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(diag->selector));
#else
			GtkListStore *store = GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(diag->selector)));
  			gtk_list_store_clear(store);
#endif
	for (tmplist=g_list_first(list);tmplist;tmplist=g_list_next(tmplist)) {
		if (tmplist->data) {
			gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(diag->selector),tmplist->data);
		}
	}
	gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(diag->selector))), "");
	g_list_free(list);
	g_list_free(tmplist);
	tmplist = NULL;
}
Пример #13
0
static void
g_paste_settings_ui_stack_private_refill_histories (GPasteSettingsUiStackPrivate *priv)
{
    G_PASTE_CLEANUP_ERROR_FREE GError *error = NULL;
    GStrv histories = g_paste_client_list_histories_sync (priv->client, &error);

    if (g_paste_settings_ui_check_connection_error (error))
        return;

    GtkComboBoxText *targets = priv->targets;

    gtk_combo_box_text_remove_all (targets);

    for (guint i = 0; histories[i]; ++i)
        gtk_combo_box_text_append (targets, histories[i], histories[i]);

    gtk_combo_box_set_active_id (GTK_COMBO_BOX (targets),
                                 g_paste_settings_get_history_name (priv->settings));
}
Пример #14
0
void fl_set_working_dir_utf8(const gchar *dir)
{
	gchar *aux;

	if (dir == NULL || strcmp(working_dir_utf8->str, dir) == 0)
		return;

	/* set the new working_dir */
	g_string_assign(working_dir_utf8, dir);

	aux = str_filename_from_utf8(working_dir_utf8->str, NULL);
	if (aux == NULL) {
		/* if we can't convert from UTF-8, leave it as is
		   (loading from the filesystem will just fail) */
		g_string_assign(working_dir, dir);
	}
	else {
		g_string_assign(working_dir, aux);
		free(aux);
	}
	
	if (expand_dir(working_dir)) {
		// need to reflect back to utf
		aux = str_filename_to_utf8(working_dir->str, NULL);
		if (aux != NULL)
			g_string_assign(working_dir_utf8, aux);
		free(aux);
	}
	
	gtk_entry_set_text(ent_wd, working_dir_utf8->str);
	
	/* update the directory mru list */
	mru_add(dir_mru, working_dir_utf8->str);
	gtk_combo_box_text_remove_all(combo_wd);
	g_list_foreach(GLIST(dir_mru->list), glist_2_combo, combo_wd);


	if (check_working_dir())
		load_file_list();
	else
		clear_file_list();
}
Пример #15
0
static void
icon_sources_populate_store (GladeEPropIconSources * eprop_sources)
{
  GladeIconSources *sources = NULL;
  GladeProperty *property;

  gtk_tree_store_clear (eprop_sources->store);
  gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (eprop_sources->combo));

  property = glade_editor_property_get_property (GLADE_EDITOR_PROPERTY (eprop_sources));
  if (!property)
    return;

  glade_property_get (property, &sources);

  if (sources)
    g_hash_table_foreach (sources->sources, (GHFunc) populate_store_foreach,
                          eprop_sources);

}
Пример #16
0
/**
 * e_webdav_discover_content_refresh:
 * @content: a WebDAV discovery content, created by e_webdav_discover_content_new()
 * @display_name: (allow-none): optional display name to use for scratch sources
 * @cancellable: (allow-none): optional #GCancellable object, or %NULL
 * @callback: (scope async): a #GAsyncReadyCallback to call when the request
 *            is satisfied
 * @user_data: (closure): data to pass to the callback function
 *
 * Asynchronously starts refresh of the @content. This means to access the server
 * and search it for available sources. The @content shows a feedback and a Cancel
 * button during the operation.
 *
 * The @display_name is used only if the @content wasn't created with an #ESource and
 * it's shown in the password prompts, if there are required any.
 *
 * When the operation is finished, @callback will be called. You can then
 * call e_webdav_discover_content_refresh_finish() to get the result of the operation.
 *
 * Since: 3.18
 **/
void
e_webdav_discover_content_refresh (GtkWidget *content,
				   const gchar *display_name,
				   GCancellable *cancellable,
				   GAsyncReadyCallback callback,
				   gpointer user_data)
{
	EWebDAVDiscoverContentData *data;
	RefreshData *rd;
	ESource *source;
	SoupURI *soup_uri;
	GtkWidget *label;

	g_return_if_fail (GTK_IS_GRID (content));

	data = g_object_get_data (G_OBJECT (content), WEBDAV_DISCOVER_CONTENT_DATA_KEY);
	g_return_if_fail (data != NULL);
	g_return_if_fail (data->base_url != NULL);

	soup_uri = soup_uri_new (data->base_url);
	if (!soup_uri) {
		GSimpleAsyncResult *simple;

		simple = g_simple_async_result_new (G_OBJECT (content), callback, user_data, e_webdav_discover_content_refresh);
		g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
			_("Invalid URL"));
		g_simple_async_result_complete_in_idle (simple);
		g_object_unref (simple);

		return;
	}

	if (!soup_uri_get_user (soup_uri)) {
		GSimpleAsyncResult *simple;

		soup_uri_free (soup_uri);

		simple = g_simple_async_result_new (G_OBJECT (content), callback, user_data, e_webdav_discover_content_refresh);
		g_simple_async_result_set_error (simple, G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT,
			_("User name not filled"));
		g_simple_async_result_complete_in_idle (simple);
		g_object_unref (simple);

		return;
	}

	rd = g_new0 (RefreshData, 1);
	rd->content = g_object_ref (content);
	rd->cancellable = cancellable ? g_object_ref (cancellable) : g_cancellable_new ();
	rd->simple = g_simple_async_result_new (G_OBJECT (content), callback, user_data, e_webdav_discover_content_refresh);
	rd->base_url = g_strdup (data->base_url);
	rd->credentials = NULL;

	if (data->source) {
		source = g_object_ref (data->source);
	} else {
		ESourceWebdav *webdav_extension;
		ESourceAuthentication *auth_extension;

		source = e_source_new_with_uid (data->base_url, NULL, NULL);
		g_return_if_fail (source != NULL);

		webdav_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_WEBDAV_BACKEND);
		auth_extension = e_source_get_extension (source, E_SOURCE_EXTENSION_AUTHENTICATION);

		if (display_name && *display_name)
			e_source_set_display_name (source, display_name);
		e_source_webdav_set_soup_uri (webdav_extension, soup_uri);
		e_source_authentication_set_host (auth_extension, soup_uri_get_host (soup_uri));
		e_source_authentication_set_port (auth_extension, soup_uri_get_port (soup_uri));
		e_source_authentication_set_user (auth_extension, soup_uri_get_user (soup_uri));
	}

	gtk_list_store_clear (GTK_LIST_STORE (gtk_tree_view_get_model (data->sources_tree_view)));
	if (data->email_addresses_combo)
		gtk_combo_box_text_remove_all (GTK_COMBO_BOX_TEXT (data->email_addresses_combo));

	if (data->info_bar)
		gtk_widget_destroy (GTK_WIDGET (data->info_bar));

	data->info_bar = GTK_INFO_BAR (gtk_info_bar_new_with_buttons (_("Cancel"), GTK_RESPONSE_CANCEL, NULL));
	gtk_info_bar_set_message_type (data->info_bar, GTK_MESSAGE_INFO);
	gtk_info_bar_set_show_close_button (data->info_bar, FALSE);
	label = gtk_label_new (_("Searching server sources..."));
	gtk_container_add (GTK_CONTAINER (gtk_info_bar_get_content_area (data->info_bar)), label);
	gtk_widget_show (label);
	gtk_widget_show (GTK_WIDGET (data->info_bar));

	g_signal_connect (data->info_bar, "response", G_CALLBACK (e_webdav_discover_info_bar_response_cb), rd);

	gtk_widget_set_sensitive (GTK_WIDGET (data->sources_tree_view), FALSE);
	if (data->email_addresses_combo)
		gtk_widget_set_sensitive (GTK_WIDGET (data->email_addresses_combo), FALSE);

	gtk_grid_attach (GTK_GRID (content), GTK_WIDGET (data->info_bar), 0, 2, 1, 1);

	e_webdav_discover_sources (source, rd->base_url, E_WEBDAV_DISCOVER_SUPPORTS_NONE, rd->credentials, rd->cancellable,
		e_webdav_discover_content_refresh_done_cb, rd);

	g_object_unref (source);
	soup_uri_free (soup_uri);
}
Пример #17
0
void WindowApp::updateCombo(GtkWidget *widget, WindowApp *theApp){
	
	//gtk_widget_destroy(theApp->summary_combo);

	cout << "Updating Combo" << endl;
	gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(theApp->summary_combo));
	cout << "Removed Text" << endl;
	
	AppQueue* qCopy = new AppQueue(theApp->appQueue);
	
	//AppQueue* qCopy = theApp->appQueue.sortAll();
	if(theApp->allCourses){
		qCopy = qCopy->sortAll();
		
		gtk_widget_set_sensitive(theApp->admin_combo, FALSE);
	}
	else{
		const gchar* theCourse;
	 	theCourse = gtk_combo_box_text_get_active_text(GTK_COMBO_BOX_TEXT(theApp->admin_combo));
		string courseString;
		courseString = (theCourse);
		cout << courseString << endl;
		qCopy = theApp->appQueue.getPendingList(courseString);
		qCopy = qCopy->sortAll();
	}
	
			
	cout << "Got Pending List" << endl;
	//char s1[100], s2[100], s3[100], s4[100], s5[100], s6[100], s7[100];
	string s1,s2,s3,s4,s5,s6,s7 ,s8,s9,s10,s11;
	
	//int length = qCopy->size();
	
	char theInput[200];
	string input[100];//string array for each Application
	Application* tmpApp = NULL;
	Application* app;
    
	GradApp* ga = NULL;
	UndergradApp *uga = NULL;
	
	if(qCopy != NULL){
		app = (qCopy->popFront());
		cout << "Popped Front" << endl;
		
		
	}
	
	 int i = 0;
	//for(int i=0; i<length; i++){
	while(app != NULL){
		std::stringstream ss1; 
		std::stringstream ss2; 
		std::stringstream ss3;
		if(app->getType() == "grad"){
			ga = static_cast<GradApp*>(app);
			s1 = ga->getStuFirst();
			//cout << s1 << endl;
			s2 = ga->getStuLast();
			s6 = ga->getStuEmail();
			s7 = ga->getStuID();
			s9 = ga->getStuArea();
			s10 = ga->getStuProgram();
			s11 = ga->getStuSuper();
			input[i] = "Course: " + ga->getCourse() +  "   Grad:   " + s1 + " " + s2 +  "   |  Email: " + s6 + "   |   ID: " + s7 + "    |   Area:  " + s9 + "   |   Program:  "  + s10 + "  |   Supervisor:  " + s11;
		}
		else{

			uga = static_cast<UndergradApp*>(app);	
			s1 = uga->getStuFirst();
			cout << s1 << endl;
			s2 = uga->getStuLast();
				 
			ss1 << uga->getStuYrStanding();
			s3 = ss1.str();
			s4 = uga->getStuMajor();
			ss2 << uga->getStuCGPA();
			s5 = ss2.str();
			s6 = uga->getStuEmail();
			s7 = uga->getStuID();
			ss3 << uga->getStuMGPA();
			s8 = ss3.str();
			input[i] = "Course:  " + uga->getCourse() + "   Undergrad: " + s1 + " " + s2 + "   in Year: " + s3 + "    |   Major: " + s4 + "  |  CGPA: " + s5  + "   |  GPA:  " + s8 + "   |  Email: " + s6 + "   |   ID: " + s7;
		}

			
		 
		
		//theInput = input[i];
		strcpy(theInput,input[i].c_str());
		gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(theApp->summary_combo), theInput);
		i++;
		app = qCopy->popFront();	
		if(app != NULL){
			if(app->getType() == "grad"){
				ga = static_cast<GradApp*>(app);
				

			}
			else{
				uga = dynamic_cast<UndergradApp*>(app);
			}
		}
		
	}
	
	
	gtk_widget_show_all(theApp->window);

}
Пример #18
0
static void populate_MRUs(NEW_DATA *new_data)
{

        /* Create the list of previously used workout types
         * and connect them to the combo box
         */

        R2RDatabase *database = new_data->database;
        GtkComboBoxText *workout_type_entry = new_data->workout_type_entry;
        GtkComboBoxText *route_entry = new_data->route_entry;

        int i, j;
        gboolean already_in;
        gchar **types = NULL;
        guint ntypes = 0;
        for (i = 0; i < database->nruns; i++) {
                already_in = false;
                for (j = 0; j < ntypes; j++) {
                        if (g_strcmp0(database->run[i]->type, types[j]) == 0 ||
                            database->run[i]->type[0] == ' ' ||
                            database->run[i]->type[0] == '\0')
                                already_in = true;
                }
                if (!already_in) {
                        ntypes++;
                        types = g_realloc(types, ntypes * sizeof(gchar *));
                        types[ntypes - 1]  = g_malloc(database->run[i]->type_len + 1);
                        g_strlcpy(types[ntypes - 1], database->run[i]->type,
                                database->run[i]->type_len + 1);
                }
        }

        gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(workout_type_entry));
        for (i = 0; i < ntypes; i++) {
                gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(workout_type_entry),
                        NULL, types[i]);
                g_free(types[i]);
        }
        g_free(types);

        /* Create the list of previously used routes
         * and connect them to the combo box
         */
        gchar **routes = NULL;
        guint nroutes = 0;
        for (i = 0; i < database->nruns; i++) {
                already_in = false;
                for (j = 0; j < nroutes; j++) {
                        if (g_strcmp0(database->run[i]->route, routes[j]) == 0 ||
                            database->run[i]->route[0] == ' ' ||
                            database->run[i]->route[0] == '\0') 
                                already_in = true;
                }
                if (!already_in) {
                        nroutes++;
                        routes = g_realloc(routes, nroutes * sizeof(gchar *));
                        routes[nroutes - 1]  = g_malloc(database->run[i]->route_len + 1);
                        g_strlcpy(routes[nroutes - 1], database->run[i]->route,
                                database->run[i]->route_len + 1);
                }
        }

        gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(route_entry));
        for (i = 0; i < nroutes; i++) {
                gtk_combo_box_text_append(GTK_COMBO_BOX_TEXT(route_entry),
                        NULL, routes[i]);
                g_free(routes[i]);
        }
        g_free(routes);
}
Пример #19
0
/*!
 * \fn G_MODULE_EXPORT void preparePageAssistantNewCsu(GtkAssistant *assistant,GtkWidget *widget, gpointer data)
 *  Prepare the new pages
 * \param[in] assistant the GtkAssistant
 * \param[in] widget the widget which send the signal
 * \param[in] data the globalData
 */
G_MODULE_EXPORT void preparePageAssistantNewCsu(GtkAssistant *assistant,GtkWidget *widget, gpointer data)
{
    globalData *user_data = (globalData*) data;
    gint page = gtk_assistant_get_current_page(assistant);
    gint nb_ligne=0;
    gint i;

    if (page == 1)
    {
        /* Calculate the number of line which already exist */
        GtkGrid *grid = GTK_GRID(gtk_bin_get_child(GTK_BIN(gtk_bin_get_child(GTK_BIN(widget)))));
        while(gtk_grid_get_child_at(grid,0,nb_ligne) != 0)
            nb_ligne++;

        /* Add the missing lines */
        for (i=nb_ligne ; i<user_data->ptr_csu_struct_tmp->nb_player ; i++)
        {
            gtk_grid_attach(grid,gtk_label_new(g_strdup_printf(_("Name of the %dth player"),i+1)),0,i,1,1);
            gtk_grid_attach(grid,gtk_entry_new(),1,i,1,1);
            gtk_entry_set_max_length(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,i)),SIZE_MAX_NAME);
            gtk_entry_set_placeholder_text(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,i)),g_strdup_printf(_("Type here the name of the %dth player"),i+1));
            gtk_entry_set_alignment(GTK_ENTRY(gtk_grid_get_child_at(GTK_GRID(grid),1,i)),0.5);
            g_signal_connect(gtk_grid_get_child_at(GTK_GRID(grid),1,i),"changed", G_CALLBACK(validAssistantNewCsuTwo),user_data);
        }

        /* Remove the unwanted lines */
        for (i = nb_ligne ; i > user_data->ptr_csu_struct_tmp->nb_player ; i--)
        {
            gtk_widget_destroy(gtk_grid_get_child_at(grid,0,i-1));
            gtk_widget_destroy(gtk_grid_get_child_at(grid,1,i-1));
        }
        validAssistantNewCsuTwo(NULL,user_data);
        gtk_widget_show_all(GTK_WIDGET(grid));
    }

    if (page == 2)
    {
        GtkGrid *grid = GTK_GRID(widget);

        /* If there is no distributor valid the page 3 */
        if (user_data->ptr_csu_struct_tmp->config.use_distributor == 0)
        {
            gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(gtk_grid_get_child_at(grid,1,0)));
            gtk_assistant_set_page_complete(GTK_ASSISTANT(user_data->ptr_new_csu_file_assistant),GTK_WIDGET(grid),TRUE);
        }
        /* Otherwise Create a combo box to choose the distributor */
        else
        {
            gint index = gtk_combo_box_get_active(GTK_COMBO_BOX(gtk_grid_get_child_at(grid,1,0)));
            gtk_combo_box_text_remove_all(GTK_COMBO_BOX_TEXT(gtk_grid_get_child_at(grid,1,0)));
            for (i = 0 ; i<user_data->ptr_csu_struct_tmp->nb_player ; i++)
                gtk_combo_box_text_insert(GTK_COMBO_BOX_TEXT(gtk_grid_get_child_at(grid,1,0)),i,NULL,user_data->ptr_csu_struct_tmp->player_names[i]);

            /* If the last distributor still exist, choose it */
            if (index <= user_data->ptr_csu_struct_tmp->nb_player)
                gtk_combo_box_set_active(GTK_COMBO_BOX(gtk_grid_get_child_at(grid,1,0)),index);

            validAssistantNewCsuThree(NULL,user_data);
        }
    }

    if (page == 0)
        validAssistantNewCsuOne(NULL,user_data);
}