Example #1
0
// remember to use "%%" in the format string to output a literal '%'
void mystatus(const char *format, ...)
{
    va_list args;
    gchar buffer[200];
    va_start(args, format);
    g_vsnprintf(buffer, 200, format, args);
    gnome_appbar_set_status(GNOME_APPBAR(glade_xml_get_widget(my_glade_xml, "appbar1")), buffer);
    va_end(args);
}
Example #2
0
void curve_save_cb (void)
{
	g_free (filename);
	filename = gtk_file_selection_get_filename (fileselection);
	gtk_widget_hide (fileselection);
	gtk_window_set_title (app,filename);
	gnome_appbar_set_status (lookup_widget(app,"appbar1"),"Curve saved.");
	curve_save(filename,0);
}
Example #3
0
void
on_button_save_clicked                 (GtkButton       *button,
                                        gpointer         user_data)
{
	if (filename)
	{
		gnome_appbar_set_status (lookup_widget(app,"appbar1"),"Curve saved.");
		curve_save(filename,0);
	}
	else select_file ("Save Curve As",curve_save_cb);
}
Example #4
0
void
on_button_new_clicked                  (GtkButton       *button,
                                        gpointer         user_data)
{
	gtk_curve_reset (lookup_widget(app,"curve"));
	g_free (filename);
	filename = NULL;
	
	gnome_appbar_set_status (lookup_widget(app,"appbar1"),"Curve reset.");
	gtk_window_set_title (app,"Untitled curve");
}
Example #5
0
void
report_gnome_vfs_error (GnomeVFSResult error, gboolean popup)
{
	if (popup) {
		GtkWidget *dialog;

		if (!error) return;
		
		dialog = gtk_message_dialog_new (GTK_WINDOW(main_window), GTK_DIALOG_MODAL,
				GTK_MESSAGE_ERROR, GTK_BUTTONS_OK,
				_("Error occured: %s"), gnome_vfs_result_to_string (error));

	} 
	
	gnome_appbar_set_status (app_bar,
		gnome_vfs_result_to_string (error));
	

}
void
c2_html_gtkhtml_on_url (GtkHTML *gtkhtml, const gchar *url, gpointer data)
{
	C2Mutex *mutex;
	
	if (!GNOME_IS_APPBAR (C2_HTML (gtkhtml)->appbar))
		return;

	mutex = C2_HTML (gtkhtml)->appbar_lock;
	
	if (mutex)
	{
		if (c2_mutex_trylock (mutex))
			return;
	}

	gnome_appbar_set_status (GNOME_APPBAR (C2_HTML (gtkhtml)->appbar),
							url ? url : "");

	c2_mutex_unlock (mutex);
}
Example #7
0
int
main (int argc, char *argv [])
{
	GtkWidget *label;
	GnomeClient *client;

	gnome_score_init("same-gnome");

	bindtextdomain (PACKAGE, GNOMELOCALEDIR);
	textdomain (PACKAGE);

	gnome_init_with_popt_table ("same-gnome", VERSION, argc, argv, options, 0, NULL);

	gnome_window_icon_set_default_from_file (GNOME_ICONDIR"/gnome-gsame.png");
	client= gnome_master_client ();

	gtk_signal_connect (GTK_OBJECT (client), "save_yourself",
			    GTK_SIGNAL_FUNC (save_state), argv[0]);
	gtk_signal_connect (GTK_OBJECT (client), "die",
			    GTK_SIGNAL_FUNC (client_die), NULL);

	if (GNOME_CLIENT_RESTARTED (client)){
		gnome_config_push_prefix (gnome_client_get_config_prefix (client));
	    
		restart ();
		restarted = 1;
		
		gnome_config_pop_prefix ();
	}

	srand (time (NULL));

	app = gnome_app_new("same-gnome", _("Same Gnome"));

        gtk_window_set_policy(GTK_WINDOW(app), FALSE, FALSE, TRUE);
	gtk_signal_connect (GTK_OBJECT(app), "delete_event",
			    (GtkSignalFunc)game_quit_callback, NULL);

	appbar = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER);
	gnome_app_set_statusbar(GNOME_APP (app), GTK_WIDGET(appbar));

	gnome_appbar_set_status(GNOME_APPBAR (appbar),
				_("Welcome to Same Gnome!"));

	gnome_app_create_menus(GNOME_APP(app), mainmenu);

	gnome_app_install_menu_hints(GNOME_APP (app), mainmenu);
  
        vb = gtk_vbox_new (FALSE, 0);
	gnome_app_set_contents (GNOME_APP (app), vb);

	if (!fname) {
		fname = gnome_config_get_string
			("/same-gnome/Preferences/Scenario=stones.png");
	}

	create_same_board (fname);

	label = gtk_label_new (_("Score: "));
	scorew = gtk_label_new ("");
	set_score (score);

	gtk_box_pack_start(GTK_BOX(appbar), label, FALSE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(appbar), scorew, FALSE, TRUE, 0);
	
	if (!restarted)
		new_game ();
	
	g_free (fname);

	gtk_widget_show (vb);
	gtk_widget_show (GTK_WIDGET(label));
	gtk_widget_show (GTK_WIDGET(scorew));
        gtk_widget_show (app);

	gtk_main ();
	return 0;
}
Example #8
0
void *
check_pop_main (Account *account) {
  char *buf = NULL, *buf2, *buf3;
  C2ResolveNode *resolve;
  int sock;
  int timedout = FALSE;
  struct sockaddr_in server;
  
  int messages = 0, bytes = 0, downloaded_bytes = 0, i = 0, password_errors = 3;
  
  GList *download[DOWNLOAD_LIST_LAST], *uidl_search = NULL, *top_search = NULL;
  GList *list;
  gboolean supports_uidl = FALSE;
  
  mid_t mid;
  
  FILE *index;
  FILE *mail;

  Message message;
  char *mailbox;
  Mailbox *mbox;
  GString *strmsg;
  char *header[HEADER_LAST];
  gboolean reading_header = TRUE;
  gboolean with_attachs = FALSE;
  char *content_type;

  char *row[8];
  GtkStyle *style, *style2;
  gboolean clisted = FALSE;
  
  g_return_val_if_fail (account, NULL);
  g_return_val_if_fail (account->type == C2_ACCOUNT_POP, NULL);

  download[DOWNLOAD_LIST_TOTAL] = NULL;
  download[DOWNLOAD_LIST_UIDL] = NULL;
  download[DOWNLOAD_LIST_TOP] = NULL;  

  resolve = c2_resolve (account->protocol.pop.host, &buf);
  if (buf) {
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    return NULL;
  }

  sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
  if (sock < 0) {
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, _("Failed to create socket"));
    gdk_threads_leave ();
    return NULL;
  }

  server.sin_family	= AF_INET;
  server.sin_port	= htons (account->protocol.pop.host_port);
  server.sin_addr.s_addr= inet_addr (resolve->ip);

  if (connect (sock, (struct sockaddr *)&server, sizeof (server)) < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    return NULL;
  }

  /* Guten Morgen, Herr Server! */
  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
    goto bye_bye_server;
  }
  c2_free (buf);

  /* Log In */
  gdk_threads_enter ();
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
     		_("Logging in..."));
  gdk_threads_leave ();

retry_login:
  if (sock_printf (sock, "USER %s\r\n", account->protocol.pop.usr_name) < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    goto bye_bye_server;
  }

  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
    goto bye_bye_server;
  }
  c2_free (buf);

  if (sock_printf (sock, "PASS %s\r\n", account->protocol.pop.pass) < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    goto bye_bye_server;
  }

  buf = sock_read (sock, &timedout);
  if (strnne (buf, "+OK", 3)) {
    if (--password_errors < 0) {
      if (pop_check_answer (buf, account, timedout) < 0) {
	if (timedout) goto run_for_your_life;
	goto bye_bye_server;
      }
    }
    gdk_threads_enter ();
    if (!gui_ask_password (account)) {
      gdk_threads_leave ();
      if (pop_check_answer (buf, account, timedout) < 0) {
	if (timedout) goto run_for_your_life;
	goto bye_bye_server;
      }
    } else {
      gdk_threads_leave ();
      goto retry_login;
    }
  }
  c2_free (buf);

  /* STAT */
  gdk_threads_enter ();
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      		_("Checking for number of mails in server..."));
  gdk_threads_leave ();

  if (sock_printf (sock, "STAT\r\n") < 0) {
    buf = g_strerror (errno);
    gdk_threads_enter ();
    window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
    gdk_threads_leave ();
    goto bye_bye_server;
  }

  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
    goto bye_bye_server;
  }
  sscanf (buf, "+OK %d ", &messages);
  c2_free (buf);
 
  if (!messages) {
    gdk_threads_enter ();
    gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      		_("No messages in server"));
    window_checking_report (C2_CHECK_OK, account->acc_name, _("No messages to download"));
    gdk_threads_leave ();
    clisted = TRUE;
    goto bye_bye_server;
  }
  else if (messages != 1)
    buf = g_strdup_printf (_("%d messages in server"), messages);
  else
    buf = g_strdup_printf (_("1 message in server"));
  gdk_threads_enter ();
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      		buf);
  gdk_threads_leave ();
  c2_free (buf);

  /* UIDL */
  if (!account->keep_copy) {
dont_use_uidl:
    /* Without UIDL*/
    for (i = 1; i <= messages; i++) {
      buf = g_strdup_printf ("%d", i);
      download[DOWNLOAD_LIST_UIDL] = g_list_append (download[DOWNLOAD_LIST_UIDL], (gpointer) buf);
    }
  } else {
    /* With UIDL */
    if (sock_printf (sock, "UIDL\r\n") < 0) {
      buf = g_strerror (errno);
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
      gdk_threads_leave ();
      goto bye_bye_server;
    }
    
    for (i = 0;; i++) {
      buf = sock_read (sock, &timedout);
      if (!i && strnne (buf, "+OK", 3)) {
	/* UIDL is optional for POP servers,
	 * so I won't complain if server doesn't like it */
	buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support UIDL."),
	    	account->acc_name);
	gdk_threads_enter ();
	gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2);
	gdk_threads_leave ();
	supports_uidl = FALSE;
	goto dont_use_uidl;
      }
      supports_uidl = TRUE;
      if (!i) continue;
      if (streq (buf, ".\r\n")) break;

      buf2 = str_get_word (1, buf, ' ');
      buf3 = str_strip (buf2, '\r');
      buf2 = str_strip (buf3, '\n');
      if (!uidl_check (buf2, account->acc_name)) {
	download[DOWNLOAD_LIST_UIDL] = g_list_append (download[DOWNLOAD_LIST_UIDL], buf);
      }
    }
  }
 
  /* TOP */
  if (!config->message_bigger) {
    /* Without TOP */
dont_use_list:
dont_use_top:
    for (i = 1; i <= messages; i++)
      	download[DOWNLOAD_LIST_TOP] = g_list_append (download[DOWNLOAD_LIST_TOP], (gpointer) i);
  } else {
    /* With TOP */
    char *subject, *from, *date, *kbytes;
    
    if (sock_printf (sock, "LIST\r\n") < 0) {
      buf = g_strerror (errno);
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
      gdk_threads_leave ();
      goto bye_bye_server;
    }
    
    for (i = 0;; i++) {
      buf = sock_read (sock, &timedout);
      if (!i && strnne (buf, "+OK", 3)) {
	buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support LIST."),
	    	account->acc_name);
	gdk_threads_enter ();
	gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2);
	gdk_threads_leave ();
	goto dont_use_list;
      }
      if (!i) continue;
      if (streq (buf, ".\r\n")) break;
      buf2 = str_get_word (1, buf, ' ');
      str_strip (buf2, '\r');
      str_strip (buf2, '\n');
      download[DOWNLOAD_LIST_TOP] = g_list_append (download[DOWNLOAD_LIST_TOP], buf);
      c2_free (buf2);
    }

    for (list = download[DOWNLOAD_LIST_TOP]; list; list = list->next) {
      if (sock_printf (sock, "TOP %d 0\r\n", atoi (CHAR (list->data))) < 0) {
	buf = g_strerror (errno);
	gdk_threads_enter ();
	window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
	gdk_threads_leave ();
	goto bye_bye_server;
      }

      strmsg = g_string_new (NULL);
      for (i = 0;; i++) {
	buf = sock_read (sock, &timedout);
	if (!i && strnne (buf, "+OK", 3)) {
	  buf2 = g_strdup_printf (_("The POP server of the account %s doesn't support TOP."),
	      account->acc_name);
	  gdk_threads_enter ();
	  gnome_appbar_set_status (GNOME_APPBAR (WMain->appbar), buf2);
	  gdk_threads_leave ();
	  goto dont_use_top;
	}
	if (!i) continue;
	if (streq (buf, ".\r\n")) break;
	g_string_append (strmsg, buf);
	c2_free (buf);
      }
      subject = message_get_header_field (NULL, strmsg->str, "\nSubject:");
      from = message_get_header_field (NULL, strmsg->str, "From:");
      date = message_get_header_field (NULL, strmsg->str, "\nDate:");
      kbytes = str_get_word (1, CHAR (list->data), ' '); str_strip (kbytes, '\r');str_strip (kbytes, '\n');
      gdk_threads_enter ();
      if ((atoi (kbytes) >= config->message_bigger*1024) &&
	  (!gui_message_big_new (from, subject, date, account->acc_name, kbytes))) {
	gdk_threads_leave ();
	c2_free (list->data);
	list->data = NULL;
	download[DOWNLOAD_LIST_TOP] = g_list_remove_link (download[DOWNLOAD_LIST_TOP], list);
      } else gdk_threads_leave ();
    }
  }

  /* Learn messages to download */
  if (!account->keep_copy && !config->message_bigger) {		/* !UIDL AND !TOP */
    download[DOWNLOAD_LIST_TOTAL] = download[DOWNLOAD_LIST_UIDL];
  }
  else if (account->keep_copy && !config->message_bigger) {	/*  UIDL AND !TOP */
    for (list = download[DOWNLOAD_LIST_UIDL]; list; list = list->next) {
      download[DOWNLOAD_LIST_TOTAL] = g_list_append (download[DOWNLOAD_LIST_TOTAL], 
	 					str_get_word (0, CHAR (list->data), ' '));
    }
  }
  else if (!account->keep_copy && config->message_bigger) {	/* !UIDL AND  TOP */
    download[DOWNLOAD_LIST_TOTAL] = download[DOWNLOAD_LIST_TOP];
  }
  else if (account->keep_copy && config->message_bigger) {	/*  UIDL AND  TOP */
    for (uidl_search = download[DOWNLOAD_LIST_UIDL]; !uidl_search; uidl_search = uidl_search->next) {
      for (top_search = download[DOWNLOAD_LIST_TOP]; !top_search; top_search = top_search->next) {
	printf ("%d %d\n", (int) uidl_search->data, (int) top_search->data); /* TODO */
      }
    }
  }

  messages = g_list_length (download[DOWNLOAD_LIST_TOTAL]);
  gdk_threads_enter ();
  gtk_progress_configure (GTK_PROGRESS (window_checking->mail_progress), 0, 0, messages);
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      				_("%p%% downloaded (%v of %u messages)"));
  gdk_threads_leave ();

  strmsg = g_string_new (NULL);
  message.message = message.header = NULL;
  for (list = download[DOWNLOAD_LIST_TOTAL]; list; list = list->next) {
    buf = str_get_word (0, CHAR (list->data), ' ');
    i = atoi (buf);
    c2_free (buf);
    /* Ask for the mail */
    if (sock_printf (sock, "RETR %d\r\n", i) < 0) {
      buf = g_strerror (errno);
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
      gdk_threads_leave ();
      goto bye_bye_server;
    }

    /* Read the first line */
    buf = sock_read (sock, &timedout);
    if (pop_check_answer (buf, account, timedout) < 0) {
      if (timedout) goto run_for_your_life;
      goto bye_bye_server;
    }
    /* Learn bytes in the messages */
    sscanf (buf, "+OK %d octets\r\n", &bytes);
    if (bytes) {
      gdk_threads_enter ();
      gtk_progress_configure (GTK_PROGRESS (window_checking->bytes_progress), 0, 0, bytes);
      gtk_widget_show (window_checking->bytes_progress);
      gdk_threads_leave ();
    } else {
      gdk_threads_enter ();
      gtk_widget_hide (window_checking->bytes_progress);
      gdk_threads_leave ();
    }
    c2_free (buf);
    
    /* Get the mail */
    reading_header = TRUE;
    for (;;) {
      buf = sock_read (sock, &timedout);
      if (bytes) {
	downloaded_bytes += strlen (buf);
	gdk_threads_enter ();
	gtk_progress_set_value (GTK_PROGRESS (window_checking->bytes_progress), downloaded_bytes);
	gdk_threads_leave ();
      }
      if (streq (buf, ".\r\n")) {
	message.message = g_strdup (strmsg->str);
	g_string_assign (strmsg, "");
	str_strip (message.message, '\r');
	break;
      }
      if (reading_header && strlen (buf) > 2) {
	char *buf2;
	buf2 = decode_8bit (buf);
	c2_free (buf);
	buf = buf2;
      }
      if (reading_header && strlen (buf) == 2) { /* Still reading header and is an empty line */
	buf2 = g_strdup_printf ("X-CronosII-Account: %s\r\n", account->acc_name);
	g_string_append (strmsg, buf2);
	c2_free (buf2);
	reading_header = FALSE;
      }
      g_string_append (strmsg, buf);
    }
    gtk_progress_set_percentage (GTK_PROGRESS (window_checking->bytes_progress), 1);

    /* Write to the mail file */
    mailbox = account->mailbox->name;
#if USE_PLUGINS
    c2_dynamic_module_signal_emit (C2_DYNAMIC_MODULE_MESSAGE_DOWNLOAD_POP, &message,
      				 	&mailbox, NULL, NULL, NULL);
#endif
    mbox = search_mailbox_name (config->mailbox_head, mailbox);
    if (!mbox) {
      /* Mailbox couldn't be found, going with the default */
      mbox = account->mailbox;
    }
    mid = c2_mailbox_get_next_mid (mbox);
    buf = c2_mailbox_mail_path (mailbox, mid);
    if ((mail = fopen (buf, "w")) == NULL) {
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name,
	  _("Error opening the file where to store the new mail"));
      cronos_error (errno, _("Opening the mail file"), ERROR_WARNING);
      gdk_threads_leave ();
      c2_free (buf);
      continue;
    }
    c2_free (buf);
    fprintf (mail, "%s", message.message);
    fclose (mail);

    /* Write to the index file */
    buf = c2_mailbox_index_path (mailbox);
    if ((index = fopen (buf, "a")) == NULL) {
      gdk_threads_enter ();
      window_checking_report (C2_CHECK_ERR, account->acc_name,
	  _("Error opening the main DB file to store the new mail"));
      cronos_error (errno, _("Opening the main DB file"), ERROR_WARNING);
      gdk_threads_leave ();
      c2_free (buf);
      goto bye_bye_server;
    }
    header[HEADER_SUBJECT]	= message_get_header_field (&message, NULL, "\nSubject:");
    header[HEADER_FROM]		= message_get_header_field (&message, NULL, "\nFrom:");
    header[HEADER_DATE]		= message_get_header_field (&message, NULL, "\nDate:");
    content_type		= message_get_header_field (&message, NULL, "\nContent-Type:");
    with_attachs		= FALSE;
/*    if (content_type) {
      message_mime_parse_content_type (content_type, &type, &subtype, &parameter);
      if (streq (type, "multipart")) {
	GList *s;
	MimeHash *mime;
	message_mime_parse (&message, NULL);
	for (s = message.mime; s != NULL; s = s->next) {
	  mime = MIMEHASH (s->data);
	  if (!mime) continue;
	  if (strneq (mime->disposition, "attachment", 10)) with_attachs = TRUE;
	}
      }
    }*/

    if (!header[HEADER_SUBJECT]) header[HEADER_SUBJECT] = "";
    if (!header[HEADER_FROM]) header[HEADER_FROM] = "";
    if (!header[HEADER_DATE]) header[HEADER_DATE] = "";
    fprintf (index, "N\r\r%s\r%s\r%s\r%s\r%s\r%d\n",
		with_attachs ? "1" : "", header[HEADER_SUBJECT], header[HEADER_FROM], header[HEADER_DATE],
		account->acc_name, mid);
    fclose (index);
    c2_free (message.message);
    c2_free (message.header);
    message.message = message.header = NULL;

    if (!account->keep_copy) {
      /* Delete the message */
      if (sock_printf (sock, "DELE %d\r\n", i) < 0) {
	buf = g_strerror (errno);
	gdk_threads_enter ();
	window_checking_report (C2_CHECK_ERR, account->acc_name, buf);
	gdk_threads_leave ();
	goto bye_bye_server;
      }
      buf = sock_read (sock, &timedout);
      if (pop_check_answer (buf, account, timedout) < 0) {
	if (timedout) goto run_for_your_life;
	goto bye_bye_server;
      }
    }
    
    if (streq (selected_mbox, mailbox)) {
      row[0] = "";
      row[1] = "";
      row[2] = "";
      row[3] = header[HEADER_SUBJECT];
      row[4] = header[HEADER_FROM];
      row[5] = header[HEADER_DATE];
      row[6] = account->acc_name;
      row[7] = g_strdup_printf ("%d", mid);
      
      gdk_threads_enter ();
      gtk_clist_freeze (GTK_CLIST (WMain->clist));
      gtk_clist_append (GTK_CLIST (WMain->clist), row);
      style = gtk_widget_get_style (WMain->clist);
      style2 = gtk_style_copy (style);
      style2->font = font_unread;
      gtk_clist_set_row_style (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, style2);
      gtk_clist_set_pixmap (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, 0, pixmap_unread, mask_unread);
      if (with_attachs) gtk_clist_set_pixmap (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, 2, pixmap_attach, mask_attach);
      new_messages++;
      gtk_clist_thaw (GTK_CLIST (WMain->clist));
      gtk_clist_set_row_data (GTK_CLIST (WMain->clist), GTK_CLIST (WMain->clist)->rows-1, (gpointer) "N");
      update_wm_title ();
      gtk_progress_set_value (GTK_PROGRESS (window_checking->mail_progress), i);
      gdk_threads_leave ();
      clisted = TRUE;
    }
    gdk_threads_enter ();
    gtk_progress_set_value (GTK_PROGRESS (window_checking->mail_progress),
		gtk_progress_get_value (GTK_PROGRESS (window_checking->mail_progress))+1);
    gdk_threads_leave ();
  }
  if (supports_uidl) {
    GList *llist;
    for (llist = download[DOWNLOAD_LIST_UIDL]; llist != NULL; llist = llist->next) {
      char *uidl;
      uidl = CHAR (llist->data);
      buf2 = str_get_word (1, uidl, ' ');
      buf3 = str_strip (buf2, '\r');
      buf2 = str_strip (buf3, '\n');
      if (buf2) {
	uidl_register (buf2, account->acc_name);
      }
    }
  }
        
  if (messages != 1)
    buf = g_strdup_printf (_("%d messages downloaded."), messages);
  else
    buf = g_strdup_printf (_("1 message downloaded."));
  gdk_threads_enter ();
  gtk_progress_configure (GTK_PROGRESS (window_checking->mail_progress), messages, 0, messages);
  gtk_progress_set_format_string (GTK_PROGRESS (window_checking->mail_progress),
      				buf);
  window_checking_report (C2_CHECK_OK, account->acc_name, buf);
  gdk_threads_leave ();
  
bye_bye_server:
  if (sock_printf (sock, "QUIT\r\n") < 0) {
    buf = g_strerror (errno);
  }
  
  buf = sock_read (sock, &timedout);
  if (pop_check_answer (buf, account, timedout) < 0) {
    if (timedout) goto run_for_your_life;
  }
run_for_your_life:
  close (sock);
  return NULL;
}
Example #9
0
inline
void
set_status_text(const gchar *txt)
{
    gnome_appbar_set_status(GNOME_APPBAR(sp->status), txt);
}
Example #10
0
/**
 * @fn GtkWidget* create_mainwin (void)
 * Crea la ventana principal
 */
GtkWidget* create_mainwin (void)
{
	GtkWidget *app1;
	GtkWidget *dock1;
	GtkWidget *eventbox1;
	GtkWidget *viewport1;
	GtkWidget *vbox_main;
	GtkWidget *vbox_paned;
	GtkWidget *scrolledwindow;
	GtkWidget *paned;
	GtkWidget *text;
	GtkWidget *inputline;
	GtkWidget *sw;
	GtkWidget *ahbox;

	app1 = gnome_app_new ( PACKAGE, "Tenes Empanadas Graciela");
	gtk_object_set_data (GTK_OBJECT (app1), "app1", app1);
	gtk_window_set_default_size (GTK_WINDOW (app1), 664, 640);
	gtk_window_set_policy (GTK_WINDOW (app1), TRUE, TRUE, FALSE);

	dock1 = GNOME_APP (app1)->dock;
	gtk_widget_ref (dock1);
	gtk_object_set_data_full (GTK_OBJECT (app1), "dock1", dock1,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (dock1);

	gnome_app_create_menus (GNOME_APP (app1), menubar_uiinfo);
	gnome_app_create_toolbar(GNOME_APP(app1), toolbar_main);

	/* TODO: ask in GNOME if this is wanted */
	/* gtk_menu_item_right_justify( GTK_MENU_ITEM(menubar_uiinfo[4].widget)); */

	gtk_widget_realize (app1);

	gtk_signal_connect ( GTK_OBJECT(app1), "destroy",
		GTK_SIGNAL_FUNC( on_exit_activate ), NULL );

	gtk_signal_connect ( GTK_OBJECT(app1), "delete_event",
		GTK_SIGNAL_FUNC( on_exit_activate ), NULL );


	SensiData.connect_button = toolbar_main[0].widget;
	SensiData.start_button = toolbar_main[1].widget;
	/* 2 is a separator */
	SensiData.enviarfichas_button = toolbar_main[3].widget;
	SensiData.reagrupe_button = toolbar_main[4].widget;
	SensiData.getcard_button = toolbar_main[5].widget;
	SensiData.endturn_button = toolbar_main[6].widget;
	/* 7 is a separator */
	SensiData.status_button = toolbar_main[8].widget;

	eventbox1 = gtk_event_box_new ();
	gtk_widget_ref (eventbox1);
	gtk_object_set_data_full (GTK_OBJECT (app1), "eventbox1", eventbox1,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (eventbox1);
	gnome_app_set_contents (GNOME_APP (app1), eventbox1);

	viewport1 = gtk_viewport_new (NULL, NULL);
	gtk_widget_show (viewport1);
	gtk_container_add (GTK_CONTAINER (eventbox1), viewport1);

	vbox_main = gtk_vbox_new (FALSE, 0);
	gtk_widget_show (vbox_main);
	gtk_container_add (GTK_CONTAINER (viewport1), vbox_main);

	/* status map */
	if( mainstatus_create(&window_mainstatus) != TEG_STATUS_SUCCESS )
		goto error;
	gtk_box_pack_start( GTK_BOX(vbox_main), window_mainstatus, FALSE,FALSE,0);

	/* paned */
	paned = gtk_vpaned_new();
	gtk_box_pack_start( GTK_BOX( vbox_main ), paned, TRUE, TRUE, 0 );
	vbox_paned = gtk_vbox_new (FALSE, 0);
	gtk_paned_add1(GTK_PANED(paned), vbox_paned);
	gtk_widget_show (vbox_paned);

	/* map */
	scrolledwindow = gtk_scrolled_window_new (NULL, NULL);
	gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(scrolledwindow),
			GTK_POLICY_AUTOMATIC,
			GTK_POLICY_AUTOMATIC);
	gtk_widget_set_usize(scrolledwindow, 640, 394);

	if( canvas_create_map() != TEG_STATUS_SUCCESS )
		goto error;

	gtk_container_add(GTK_CONTAINER(scrolledwindow), canvas_map);
	gtk_container_add(GTK_CONTAINER(vbox_paned),scrolledwindow);
	gtk_widget_show (canvas_map);
	gtk_widget_show (scrolledwindow);


	/* text */
	ahbox = gtk_hbox_new(FALSE, 2);
	gtk_paned_pack2(GTK_PANED(paned), ahbox, TRUE, TRUE);

	sw = gtk_scrolled_window_new(NULL, NULL);

	gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), GTK_POLICY_AUTOMATIC,
					 GTK_POLICY_ALWAYS);
	gtk_box_pack_start(GTK_BOX(ahbox), sw, TRUE, TRUE, 0);

	gtk_widget_set_size_request(sw, 620, 60);

	text = gtk_text_view_new();
	gtk_text_view_set_editable(GTK_TEXT_VIEW(text), FALSE);
	gtk_container_add(GTK_CONTAINER(sw), text);

	gtk_widget_set_name(text, "chatline");

	gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(text), GTK_WRAP_WORD);
	gtk_widget_realize(text);
	gtk_text_view_set_left_margin(GTK_TEXT_VIEW(text), 5);

	main_message_area = GTK_TEXT_VIEW(text);

/*	set_output_window_text(_("Tenes Empanadas Graciela")); */

	gtk_widget_show(text);
	gtk_widget_show(sw);
	gtk_widget_show(ahbox);
	gtk_widget_show(paned);

	/* the chat line */
	inputline = gtk_entry_new();
	gtk_box_pack_start( GTK_BOX( vbox_main ), inputline, FALSE, FALSE, 0 );
	gtk_widget_show(inputline);
	g_signal_connect(inputline, "activate", G_CALLBACK(inputline_return), NULL);


	chatline_init();


	/* status bar */
	statusbar = gnome_appbar_new (FALSE, TRUE, GNOME_PREFERENCES_NEVER);
	gtk_widget_ref (statusbar);
	gtk_object_set_data_full (GTK_OBJECT (app1), "statusbar", statusbar,
		(GtkDestroyNotify) gtk_widget_unref);
	gtk_widget_show (statusbar);
	gnome_app_set_statusbar (GNOME_APP (app1), statusbar);

	gtk_box_pack_start(GTK_BOX(statusbar),
		ministatus_build(), FALSE, TRUE, 0);


	gnome_appbar_set_status(GNOME_APPBAR(statusbar),
				_("Welcome to TEG!"));

	gnome_app_install_menu_hints( GNOME_APP(app1), menubar_uiinfo );

	/* icono */
	{
		GdkBitmap *mask;
		GdkPixmap *icono;
		#include "../teg_pix/teg_icono.xpm"
		gtk_widget_realize (app1);
		icono = gdk_pixmap_create_from_xpm_d( app1->window, &mask, &app1->style->bg[GTK_STATE_NORMAL],teg_icono_xpm );
		gdk_window_set_icon (app1->window, NULL, icono , mask );
	}

	gtk_widget_show(app1);
	return app1;

error:
	g_error(_("Unable to create map!"));
	return NULL;
}