예제 #1
0
파일: netconf.c 프로젝트: Elentir/fwife
int prerun(GList **config)
{
	int i;
	
	if(iflist == NULL)
	{
		iflist = fwnet_iflist();

		for(i=0; i<g_list_length(iflist); i+=2)
		{
			gtk_combo_box_append_text(GTK_COMBO_BOX(intercombo), (char*)g_list_nth_data(iflist, i));
		}
	}
	
	gtk_combo_box_set_active (GTK_COMBO_BOX (intercombo), 0);

	return 0;
}
int
gnetconfig_detect_interfaces (void)
{
	char 			*name = NULL;
	char			*desc = NULL;
	gint			n_if, i, l;
	GtkTreeModel 		*model;
	GtkListStore 		*store;
	GtkTreeIter		iter;
	GdkPixbuf		*yes_pixbuf;
	GdkPixbuf		*no_pixbuf;
	fwnet_interface_t	*interface;
	GList			*iflist = NULL;
	GList			*tlist = NULL;

	n_if = g_list_length (active_profile->interfaces);
	yes_pixbuf = gtk_widget_render_icon (GTK_WIDGET(if_detect_treeview),
					GTK_STOCK_YES,
					GTK_ICON_SIZE_MENU, NULL);
	no_pixbuf = gtk_widget_render_icon (GTK_WIDGET(if_detect_treeview),
					GTK_STOCK_NO,
					GTK_ICON_SIZE_MENU, NULL);
	model = gtk_tree_view_get_model (GTK_TREE_VIEW(if_detect_treeview));
	store = GTK_LIST_STORE (model);
	gtk_list_store_clear (store);
	iflist = fwnet_iflist ();
	if (iflist == NULL)
	{
		gn_error (_("Cannot populate interface list"));
		return 1;
	}
	tlist = iflist;

	for (l=0;l<(g_list_length(iflist)/2);l++)
	{
		name = (char*) tlist->data;
		tlist = g_list_next (tlist);
		desc = (char*) tlist->data;
		tlist = g_list_next (tlist);
		gboolean configured = FALSE;
		
		/* check if the interface is already present in our profile */
		for (i=0;i<n_if;i++)
		{
			interface = g_list_nth_data (active_profile->interfaces, i);
			if (!strcmp(name, interface->name))
			{
				configured = TRUE;
				break;
			}	
		}

		gtk_list_store_append (store, &iter);
		if (configured)
		{
			gtk_list_store_set (store, &iter,
					0, yes_pixbuf,
					1, name,
					2, desc,
					3, _("Configured"),
					4, TRUE, -1);
		}
		else
		{
			gtk_list_store_set (store, &iter,
					0, no_pixbuf,
					1, name,
					2, desc,
					3, _("Not Configured"),
					4, FALSE, -1);
		}
	}
	gtk_window_set_position (GTK_WINDOW(if_detect_dlg), GTK_WIN_POS_CENTER_ON_PARENT);
	gtk_widget_show_all (if_detect_dlg);
	return 0;
}