Example #1
0
/*--------------------------------------------------------------------------*/
static void
no_download( void )
{
	gchar *date_min, *date_max, *finish_msg;
	gbTableModel     *table_model;

	gb_debug (DEBUG_UPDATE, "START");

	/* customize finish page for this outcome */
	gnome_druid_page_edge_set_title( GNOME_DRUID_PAGE_EDGE(finish_page),
					 _( "No new data available" ) );
	table_model = gb_table_get_model ();
	date_min = gb_date_fmt (gb_table_model_get_rdate_min (table_model));
	date_max = gb_date_fmt (gb_table_model_get_rdate_max (table_model));
	finish_msg = g_strdup_printf(
		_( "No new redemption data available from selected\n"
		   "download site.\n\n"
		   "GBonds is still configured with redemption data\n"
		   "for %s - %s.\n" ),
		date_min, date_max );
	gnome_druid_page_edge_set_text( GNOME_DRUID_PAGE_EDGE(finish_page), finish_msg );
	g_free( date_min );
	g_free( date_max );
	g_free( finish_msg );

	remote_dir_handle = NULL;

	/* Now jump to the finish page */
	gnome_druid_set_page( GNOME_DRUID(update_druid),
			      GNOME_DRUID_PAGE(finish_page) );

	gb_debug (DEBUG_UPDATE, "END");
}
Example #2
0
/*--------------------------------------------------------------------------*/
static void
add_finish_page( GnomeDruid *wdruid, GdkPixbuf *logo )
{
	GdkColor   druid_bg_color = DRUID_BG_COLOR;
	GdkColor   druid_title_color = DRUID_TITLE_COLOR;

	gb_debug (DEBUG_UPDATE, "START");

	finish_page = gnome_druid_page_edge_new_with_vals (GNOME_EDGE_FINISH,
							   TRUE,
							   _("done"),
							   _("Done."),
							   logo,
							   NULL,
							   NULL);
	gnome_druid_page_edge_set_bg_color(GNOME_DRUID_PAGE_EDGE(finish_page),
					   &druid_bg_color);
	gnome_druid_page_edge_set_logo_bg_color (GNOME_DRUID_PAGE_EDGE(finish_page),
						 &druid_bg_color );
	gnome_druid_page_edge_set_title_color (GNOME_DRUID_PAGE_EDGE(finish_page),
					       &druid_title_color );
	gnome_druid_append_page( wdruid, GNOME_DRUID_PAGE(finish_page) );

	g_signal_connect_after( G_OBJECT(finish_page), "prepare",
				G_CALLBACK(prepare_finish_page), NULL );

	g_signal_connect( G_OBJECT(finish_page), "finish",
			  G_CALLBACK(finish_cb), NULL );

	gb_debug (DEBUG_UPDATE, "END");
}
Example #3
0
/*
 * Adds menu items to a context menu which is just about to appear!
 * Add commands to aid in editing a GnomeDruid, with signals pointing to
 * other functions in this file.
 */
static void
gb_gnome_druid_create_popup_menu (GtkWidget * widget,
				  GbWidgetCreateMenuData * data)
{
  GtkWidget *menuitem;
  GnomeDruid *druid;
  GList *children, *elem;

  if (data->child == NULL)
    return;

  g_return_if_fail (GNOME_IS_DRUID (data->child->parent));
  druid = GNOME_DRUID (data->child->parent);

  children = gtk_container_get_children (GTK_CONTAINER (widget));

  /* 'Add Start Page' is added if the druid has no pages or the first one
     is not a start page. */
  if (!children ||
      !(GNOME_IS_DRUID_PAGE_EDGE (children->data) &&
	GNOME_DRUID_PAGE_EDGE (children->data)->position == GNOME_EDGE_START))
    {
      menuitem = gtk_menu_item_new_with_label (_("Add Start Page"));
      gtk_widget_show (menuitem);
      gtk_menu_append (GTK_MENU (data->menu), menuitem);
      gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
			  GTK_SIGNAL_FUNC (gb_gnome_druid_add_start_page),
			  druid);
    }

  /* 'Add Finish Page' is added if the druid has no pages or the last one
     is not a finish page. */
  elem = g_list_last (children);
  if (!elem ||
      !(GNOME_IS_DRUID_PAGE_EDGE (elem->data) &&
	GNOME_DRUID_PAGE_EDGE (elem->data)->position == GNOME_EDGE_FINISH))
    {
      menuitem = gtk_menu_item_new_with_label (_("Add Finish Page"));
      gtk_widget_show (menuitem);
      gtk_menu_append (GTK_MENU (data->menu), menuitem);
      gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
			  GTK_SIGNAL_FUNC (gb_gnome_druid_add_finish_page),
			  druid);
    }

  g_list_free (children);

  /* 'Insert Page Before' is added if the current page is not the start page.
   */
  if (!(GNOME_IS_DRUID_PAGE_EDGE (data->child) &&
	GNOME_DRUID_PAGE_EDGE (data->child)->position == GNOME_EDGE_START))
    {
      menuitem = gtk_menu_item_new_with_label (_("Insert Page Before"));
      gtk_widget_show (menuitem);
      gtk_menu_append (GTK_MENU (data->menu), menuitem);
      gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
			  GTK_SIGNAL_FUNC (gb_gnome_druid_insert_page_before),
			  data->child);
    }

  /* 'Insert Page After' is added if the current page is not the finish page.
   */
  if (!(GNOME_IS_DRUID_PAGE_EDGE (data->child) &&
	GNOME_DRUID_PAGE_EDGE (data->child)->position == GNOME_EDGE_FINISH))
    {
      menuitem = gtk_menu_item_new_with_label (_("Insert Page After"));
      gtk_widget_show (menuitem);
      gtk_menu_append (GTK_MENU (data->menu), menuitem);
      gtk_signal_connect (GTK_OBJECT (menuitem), "activate",
			  GTK_SIGNAL_FUNC (gb_gnome_druid_insert_page_after),
			  data->child);
    }
}
Example #4
0
/*--------------------------------------------------------------------------*/
static void
download_done( DownloadCallbackData *data )
{
	GList            *p;
	GnomeVFSFileInfo *info, tmp_info = {0};
	gchar            *hash_name;
	gchar            *hash_path, *hash_text_uri;
	gchar            *file_path, *file_text_uri;
	gchar            *date_min, *date_max, *finish_msg;
	gchar            *data_dir;
	gbTableModel     *table_model;

	gb_debug (DEBUG_UPDATE, "START");

	/* Rename downloaded files (undo name hash) */
	data_dir = gb_util_get_home_data_dir();
	for ( p=data->list; p != NULL; p=p->next ) {
		info = (GnomeVFSFileInfo *)p->data;
		hash_name = hash_filename( info->name );
		hash_path = g_build_filename( data_dir, hash_name, NULL );
		hash_text_uri = gnome_vfs_get_uri_from_local_path( hash_path );
		file_path = g_build_filename( data_dir, info->name, NULL );
		file_text_uri = gnome_vfs_get_uri_from_local_path( file_path );
		gnome_vfs_get_file_info (hash_text_uri, &tmp_info, GNOME_VFS_FILE_INFO_DEFAULT);
		if ( info->size == tmp_info.size ) {
			gnome_vfs_move( hash_text_uri, file_text_uri, FALSE );
		} else {
			g_warning ("%s: Temporary file size (%"
				   GNOME_VFS_OFFSET_FORMAT_STR
				   ") does not match remote size (%"
				   GNOME_VFS_OFFSET_FORMAT_STR
				   ").",
				   info->name, tmp_info.size, info->size);
			gnome_vfs_unlink (hash_text_uri);
		}
		g_free( hash_name );
		g_free( hash_path );
		g_free( hash_text_uri );
		g_free( file_path );
		g_free( file_text_uri );
	}
	g_free( data_dir );

	/* Now reread redemption tables */
	table_model = gb_table_get_model ();
	gb_table_model_update (table_model);

	/* customize finish page for this outcome */
	gnome_druid_page_edge_set_title( GNOME_DRUID_PAGE_EDGE(finish_page),
					 _( "Download done" ) );
	date_min = gb_date_fmt (gb_table_model_get_rdate_min (table_model));
	date_max = gb_date_fmt (gb_table_model_get_rdate_max (table_model));
	finish_msg = g_strdup_printf(
		_( "GBonds has successfully downloaded "
		   "%d new redemption files.\n\n"
		   "GBonds is now configured with redemption data\n"
		   "for %s - %s.\n" ),
		data->n, date_min, date_max );
	gnome_druid_page_edge_set_text( GNOME_DRUID_PAGE_EDGE(finish_page), finish_msg );
	g_free( date_min );
	g_free( date_max );
	g_free( finish_msg );

	remote_dir_handle = NULL;

	/* Now jump to the finish page */
	gnome_druid_set_page( GNOME_DRUID(update_druid),
			      GNOME_DRUID_PAGE(finish_page) );

	gb_debug (DEBUG_UPDATE, "END");
}
Example #5
0
/*--------------------------------------------------------------------------*/
static void
add_start_page( GnomeDruid *wdruid, GdkPixbuf *logo )
{
	GtkWidget    *wpage;
	GdkColor      druid_bg_color = DRUID_BG_COLOR;
	GdkColor      druid_title_color = DRUID_TITLE_COLOR;
	gbDate        date_min, date_max, date_today;
	gchar        *date_min_string, *date_max_string, *date_today_string;
	gchar        *msg, *msg1;
	gbTableModel *table_model;

	gb_debug (DEBUG_UPDATE, "START");

	table_model = gb_table_get_model ();

	date_min   = gb_table_model_get_rdate_min (table_model);
	date_max   = gb_table_model_get_rdate_max (table_model);
	date_today = gb_table_model_get_rdate_today ();

	date_min_string   = gb_date_fmt( date_min );
	date_max_string   = gb_date_fmt( date_max );
	date_today_string = gb_date_fmt( date_today );

	if ( date_today == date_max ) {
		msg1 = g_strdup_printf(
			 _( "Current redemption data will expire at the end\n"
			    "of this month (%s)\n" ), date_today_string );
	}
	else {
		if ( date_today > date_max ) {
			msg1 = g_strdup( _( "Current redemption data has expired.\n" ) );
		}
		else {
			msg1 = g_strdup( "" );
		}
	}

	msg = g_strdup_printf(
		   _( "%s\n"
		      "GBonds is currently configured with redemption data\n"
		      "for %s - %s.\n\n"
		      "New redemption data is published by the U.S. Treasury\n"
		      "every six months.  This dialog will help you\n"
		      "download and install new redemption data.\n\n"
		      "You can hit cancel at any point to cancel this dialog."
		      ),
		   msg1, date_min_string, date_max_string );

	wpage = gnome_druid_page_edge_new_with_vals (GNOME_EDGE_START,
						     TRUE,
						     _("Update redemption tables"),
						     msg,
						     logo,
						     NULL,
						     NULL);
	gnome_druid_page_edge_set_bg_color (GNOME_DRUID_PAGE_EDGE(wpage),
					    &druid_bg_color);
	gnome_druid_page_edge_set_logo_bg_color (GNOME_DRUID_PAGE_EDGE(wpage),
						 &druid_bg_color);
	gnome_druid_page_edge_set_title_color (GNOME_DRUID_PAGE_EDGE(wpage),
					       &druid_title_color);

	gnome_druid_append_page( wdruid, GNOME_DRUID_PAGE(wpage) );

	g_free( date_min_string );
	g_free( date_max_string );
	g_free( date_today_string );
	g_free( msg );
	g_free( msg1 );

	gb_debug (DEBUG_UPDATE, "END");
}