Esempio n. 1
0
void setUri( GtkWidget *mainSearchBox, gpointer button){
	//Checking if the web address already has http attached to if, if not it is attached to the address
	uri = gtk_entry_get_text(GTK_ENTRY(mainSearchBox));

	//These if constructs ensure that the url is in order
	//If address is online or on user's machine
	if( (uri[0] == 'h' && uri[1] == 't' && uri[2] == 't' && uri[3] == 'p') || (uri[0] == 'f' && uri[1] == 'i' && uri[2] == 'l' && uri[3] == 'e')){
		//The address is in the correct format
		uri = gtk_entry_get_text(GTK_ENTRY(mainSearchBox));
	}
	else{

		if( uri[0] == 'w' && uri[1] == 'w' && uri[2] == 'w'){
			//address lacks http://, which is added
			gtk_entry_prepend_text(GTK_ENTRY(mainSearchBox),"http://");
			uri = gtk_entry_get_text(GTK_ENTRY(mainSearchBox));
		}
		else{
			
			if(  strstr(uri, ".com") && uri[0] != '.'){
				//if address ends with .com like youtube.com
				gtk_entry_prepend_text(GTK_ENTRY(mainSearchBox),"http://www.");
				uri = gtk_entry_get_text(GTK_ENTRY(mainSearchBox));
			}
			else{
				//if address has none of the above, google is used to search for the user's text
				gtk_entry_prepend_text(GTK_ENTRY(mainSearchBox),"http://www.google.com/");
				uri = gtk_entry_get_text(GTK_ENTRY(mainSearchBox));
			}
		}
	}
	gtk_entry_progress_pulse(GTK_ENTRY(mainSearchBox));
}
Esempio n. 2
0
//Internet Functions
void InputConnect( GtkWidget* widget,gpointer* wid)
{
	
/*	char url[35]="http://";
	Widget InputText = GTK_WIDGET(wid);
	uri = gtk_entry_get_text(GTK_ENTRY(InputText));
	strcat(url,uri);
	gtk_entry_set_text(GTK_ENTRY(UrlText),url);
	gtk_entry_progress_pulse(GTK_ENTRY(UrlText));
	webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web),url);
*/
	//Checking if the web address already has http attached to if, if not it is attached to the address
	Widget Input = GTK_WIDGET(wid);
	uri = gtk_entry_get_text(GTK_ENTRY(Input));

	//These if constructs ensure that the url is in order
	//If address is online or on user's machine
		//seting the count of the notebook

	
	
	if( (uri[0] == 'h' && uri[1] == 't' && uri[2] == 't' && uri[3] == 'p') || (uri[0] == 'f' && uri[1] == 'i' && uri[2] == 'l' && uri[3] == 'e')){
		//The address is in the correct format
//		uri = gtk_entry__text(GTK_ENTRY(InputText));
	}
	else{

		if( uri[0] == 'w' && uri[1] == 'w' && uri[2] == 'w'){
			//address lacks http://, which is added
			gtk_entry_prepend_text(GTK_ENTRY(Input),"http://");
			uri = gtk_entry_get_text(GTK_ENTRY(Input));
		}
		else{
			
			if(  strstr(uri, ".com") && uri[0] != '.'){
				//if address ends with .com like youtube.com
				gtk_entry_prepend_text(GTK_ENTRY(Input),"http://www.");
				uri = gtk_entry_get_text(GTK_ENTRY(Input));
			}
			else{
				//if address has none of the above, google is used to search for the user's text
				gtk_entry_prepend_text(GTK_ENTRY(Input),"http://www.google.com/");
				uri = gtk_entry_get_text(GTK_ENTRY(Input));
				
			}
		}
	}
	gtk_entry_set_text(GTK_ENTRY(UrlText),uri);
	//gtk_entry_set_text(GTK_ENTRY(Input),".");
	gtk_entry_progress_pulse(GTK_ENTRY(UrlText));
	webkit_web_view_load_uri(WEBKIT_WEB_VIEW(web[count]),uri);
} 
Esempio n. 3
0
File: tools.c Progetto: dimkr/beaver
void refresh_converter (GtkWidget *Widget, gint EntryID)
{
  gchar *NumberString;
  gint i = 0, j = 1;
  gulong Number = 0;

  NumberString = gtk_entry_get_text (GTK_ENTRY (Entry[EntryID-1]));
  if (EntryID == 1)
    {
      if ((strlen (NumberString) == 10) &&
	  (g_strcasecmp (NumberString, "4294967295") > 0))
	{
	  if (g_strcasecmp (NumberString, "9999999999") <= 0)
	    {
	      Number = ~0; /* <-- Max Unsigned Long Integer */
	    }
	  else
	    {
	      Number = 0; /* <-- Min Unsigned Long Integer */
	    }
	}
      else
	{
	  g_strreverse (NumberString);
	  while ((NumberString[i] >= '0') && (NumberString[i] <= '9'))
	    {
	      Number = Number + (NumberString[i] - '0')*j;
	      j *= 10;
	      i++;
	    }
	  if (NumberString[i] != '\0')
	    Number = 0; /* <-- Min Unsigned Long Integer */
	}
    }
  if (EntryID == 2)
    {
      g_strreverse (NumberString);

      while ((NumberString[i] == '0') || (NumberString[i] == '1'))
	{
	  Number = Number + (NumberString[i] - '0')*j;
	  j *= 2;
	  i++;
	}
      if (NumberString[i] != '\0')
	Number = 0; /* <-- Min Unsigned Long Integer */
    }
  if (EntryID == 3)
    {
      if ((strlen (NumberString) == 11) &&
	  (g_strcasecmp (NumberString, "37777777777") > 0))
	{
	  if (g_strcasecmp (NumberString, "77777777777") <= 0)
	    {
	      Number = ~0; /* <-- Max Unsigned Long Integer */
	    }
	  else
	    {
	      Number = 0; /* <-- Min Unsigned Long Integer */
	    }
	}
      else
	{
	  g_strreverse (NumberString);
	  while ((NumberString[i] >= '0') && (NumberString[i] <= '7'))
	    {
	      Number = Number + (NumberString[i] - '0')*j;
	      j *= 8;
	      i++;
	    }
	  if (NumberString[i] != '\0')
	    Number = 0; /* <-- Min Unsigned Long Integer */
	}
    }
  if (EntryID == 4)
    {
      gint Zero;

      g_strreverse (NumberString);
      while (((NumberString[i] >= '0') && (NumberString[i] <= '9')) ||
	     ((NumberString[i] >= 'a') && (NumberString[i] <= 'f')) ||
	     ((NumberString[i] >= 'A') && (NumberString[i] <= 'F')))
	{
	  if ((NumberString[i] >= '0') && (NumberString[i] <= '9'))
	    Zero = '0';
	  else if ((NumberString[i] >= 'a') && (NumberString[i] <= 'f'))
	    Zero = 'a' - 10;
	  else
	    Zero = 'A' - 10;
	  Number = Number + (NumberString[i] - Zero)*j;
	  j *= 16;
	  i++;
	}
      if (NumberString[i] != '\0')
	Number = 0; /* <-- Min Unsigned Long Integer */
    }
  gtk_entry_set_text (GTK_ENTRY (Entry[0]),
		      g_strdup_printf ("%lu", Number));
  gtk_entry_set_text (GTK_ENTRY (Entry[2]),
		      g_strdup_printf ("%lo", Number));
  gtk_entry_set_text (GTK_ENTRY (Entry[3]),
		      g_strdup_printf ("%lx", Number));
  if (Number)
    {
      gint Bit;

      gtk_entry_set_text (GTK_ENTRY (Entry[1]), "");
      while (Number > 0)
	{
	  Bit = Number % 2;
	  Number = Number / 2;
	  gtk_entry_prepend_text (GTK_ENTRY (Entry[1]),
				  g_strdup_printf ("%d", Bit));
	}
    }
  else
    gtk_entry_set_text (GTK_ENTRY (Entry[1]), "0");
  (void)Widget; /* avoid the "unused parameter" warning */
}