コード例 #1
0
static void
cb_gn_if_detect_ok_clicked (GtkWidget *widget, gpointer data)
{
	gchar			*ifname = NULL;
	GtkTreeModel		*model = NULL;
	GtkTreeSelection	*selection = NULL;
	GtkTreeIter		iter;
	gboolean		status = FALSE;

	model = gtk_tree_view_get_model (GTK_TREE_VIEW(if_detect_treeview));
	selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(if_detect_treeview));
	if ( FALSE == gtk_tree_selection_get_selected (selection, &model, &iter) )
		return;
	gtk_tree_model_get (model, &iter, 1, &ifname, 3, &status, -1);
	if (status == TRUE)
	{
		gn_error (_("The selected interface is already configured. Please select another interface"));
		return;
	}
	else
	{
		gtk_entry_set_text (GTK_ENTRY(gn_nif_name_entry), ifname);
		gtk_widget_hide (if_detect_dlg);
		if (fwnet_is_wireless_device(ifname))
			gn_message (_("Gnetconfig has detected that the selected interface is a wireless device."));
	}	
	
	return;
}
コード例 #2
0
ファイル: netconf.c プロジェクト: Elentir/fwife
int add_interface(GtkWidget *button, gpointer data)
{
	fwnet_interface_t *newinterface = NULL;
	GtkWidget *cellview;
	GdkPixbuf *connectimg;
	char *ptr=NULL;
	char *nettype=NULL;
	char *iface=NULL;

	GtkTreeIter iter;
	GtkTreeModel *model;
	gtk_combo_box_get_active_iter(GTK_COMBO_BOX(intercombo), &iter);
	model = gtk_combo_box_get_model(GTK_COMBO_BOX(intercombo));
	gtk_tree_model_get (model, &iter, 0, &iface, -1);

	int i;
	for(i=0;i<g_list_length(interfaceslist); i+=2)
	{
		if(!strcmp((char*)g_list_nth_data(interfaceslist, i), iface))
		{
			fwife_error("This interface has been already configured!");
			return -1;
		}
	}
	
	if((newinterface = (fwnet_interface_t*)malloc(sizeof(fwnet_interface_t))) == NULL)
		return(-1);
	memset(newinterface, 0, sizeof(fwnet_interface_t));
	
	snprintf(newinterface->name, IF_NAMESIZE, iface);
	
	nettype = ask_nettype();
	if(nettype == NULL)
		return -1;

	if(strcmp(nettype, "lo"))
	{
		interfaceslist = g_list_append(interfaceslist, strdup(iface));
		interfaceslist = g_list_append(interfaceslist, newinterface);

		GtkTreeView *treeview = (GtkTreeView *)data;
  		model = gtk_tree_view_get_model (treeview);

		cellview = gtk_cell_view_new ();
	    	connectimg = gtk_widget_render_icon (cellview, GTK_STOCK_NETWORK,
					GTK_ICON_SIZE_BUTTON, NULL);
	   	gtk_widget_destroy (cellview);

		gtk_list_store_append (GTK_LIST_STORE (model), &iter);
		gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IMAGE, connectimg, COLUMN_NET_NAME, iface, -1);		
	}

	if(strcmp(nettype, "lo") && fwnet_is_wireless_device(iface))
	{
		switch(fwife_question(_("It seems that this network card has a wireless extension.\n\nConfigure your wireless now?")))
					{
						case GTK_RESPONSE_YES:
							configure_wireless(newinterface);
							break;
						case GTK_RESPONSE_NO:
							break;
					}
	}
	
	if(!strcmp(nettype, "dhcp"))
	{
		ptr = fwife_entry(_("Set DHCP hostname"), _("Some network providers require that the DHCP hostname be\n"
			"set in order to connect.\n If so, they'll have assigned a hostname to your machine.\n If you were"
			"assigned a DHCP hostname, please enter it below.\n If you do not have a DHCP hostname, just"
			"hit enter."), NULL);
		if(strlen(ptr))
			snprintf(newinterface->dhcp_opts, PATH_MAX, "-t 10 -h %s\n", ptr);
		else
			newinterface->dhcp_opts[0]='\0';
		newinterface->options = g_list_append(newinterface->options, strdup("dhcp"));
		gtk_list_store_set (GTK_LIST_STORE (model), &iter, COLUMN_NET_IP, "dhcp", COLUMN_NET_NAMESERV, ptr, -1);
		FREE(ptr);
	}
	else if(!strcmp(nettype, "static"))
	{
		configure_static(newinterface, iter);
	}

	return 0;
}