示例#1
0
static gchar *
ft_manager_format_progress_bytes_and_percentage (guint64 current,
                                                 guint64 total,
                                                 gdouble speed,
                                                 int *percentage)
{
  char *total_str, *current_str, *retval;
  char *speed_str = NULL;

  total_str = g_format_size (total);
  current_str = g_format_size (current);

  if (speed > 0)
    speed_str = g_format_size ((goffset) speed);

  /* translators: first %s is the currently processed size, second %s is
   * the total file size */
  retval = speed_str ?
    g_strdup_printf (_("%s of %s at %s/s"), current_str, total_str, speed_str) :
    g_strdup_printf (_("%s of %s"), current_str, total_str);

  g_free (total_str);
  g_free (current_str);
  g_free (speed_str);

  if (percentage != NULL)
    {
      if (total != 0)
        *percentage = current * 100 / total;
      else
        *percentage = -1;
    }

  return retval;
}
static void
photos_export_dialog_guess_sizes (GObject *source_object, GAsyncResult *res, gpointer user_data)
{
  PhotosExportDialog *self;
  PhotosBaseItem *item = PHOTOS_BASE_ITEM (source_object);
  GError *error;
  gchar *size_str;
  gsize sizes[2];

  error = NULL;
  if (!photos_base_item_save_guess_sizes_finish (item, res, &sizes[0], &sizes[1], &error))
    {
      if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_CANCELLED))
        g_warning ("Unable to guess sizes: %s", error->message);
      g_error_free (error);
      return;
    }

  self = PHOTOS_EXPORT_DIALOG (user_data);

  size_str = g_format_size ((guint64) sizes[0]);
  gtk_label_set_text (GTK_LABEL (self->full_label), size_str);
  g_free (size_str);

  if (self->reduced_zoom > 0.0)
    {
      gsize reduced_size;

      reduced_size = (gsize) (sizes[1] + (sizes[0] - sizes[1]) * (self->reduced_zoom - 0.5) / (1.0 - 0.5) + 0.5);
      size_str = g_format_size ((guint64) reduced_size);
      gtk_label_set_text (GTK_LABEL (self->reduced_label), size_str);
      g_free (size_str);
    }
}
示例#3
0
gboolean Mpc_Header_Display_File_Info_To_UI (gchar *filename_utf8, ET_File_Info *ETFileInfo)
{
    gchar *text;
    gchar *time  = NULL;
    gchar *time1 = NULL;
    gchar *size  = NULL;
    gchar *size1 = NULL;

    /* Mode changed to profile name  */
    text = g_strdup_printf(_("Profile:"));
    gtk_label_set_text(GTK_LABEL(ModeLabel),text);
    g_free(text);
    text = g_strdup_printf("%s (SV%d)",ETFileInfo->mpc_profile,ETFileInfo->version);
    gtk_label_set_text(GTK_LABEL(ModeValueLabel),text);
    g_free(text);

    /* Bitrate */
    text = g_strdup_printf(_("%d kb/s"),ETFileInfo->bitrate);
    gtk_label_set_text(GTK_LABEL(BitrateValueLabel),text);
    g_free(text);

    /* Samplerate */
    text = g_strdup_printf(_("%d Hz"),ETFileInfo->samplerate);
    gtk_label_set_text(GTK_LABEL(SampleRateValueLabel),text);
    g_free(text);

    /* Version changed to encoder version */
    text = g_strdup_printf(_("Encoder:"));
    gtk_label_set_text(GTK_LABEL(VersionLabel),text);
    g_free(text);

    text = g_strdup_printf("%s",ETFileInfo->mpc_version);
    gtk_label_set_text(GTK_LABEL(VersionValueLabel),text);
    g_free(text);

    /* Size */
    size  = g_format_size (ETFileInfo->size);
    size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
    text  = g_strdup_printf("%s (%s)",size,size1);
    gtk_label_set_text(GTK_LABEL(SizeValueLabel),text);
    g_free(size);
    g_free(size1);
    g_free(text);

    /* Duration */
    time  = Convert_Duration(ETFileInfo->duration);
    time1 = Convert_Duration(ETCore->ETFileDisplayedList_TotalDuration);
    text  = g_strdup_printf("%s (%s)",time,time1);
    gtk_label_set_text(GTK_LABEL(DurationValueLabel),text);
    g_free(time);
    g_free(time1);
    g_free(text);

    return TRUE;
}
示例#4
0
static void
fill_props_model (GtkListStore *store)
{
	GtkTreeIter iter;
	guint lo;
	glibtop_mountlist mountlist;
	glibtop_mountentry *mountentry, *mountentry_tofree;
	guint64 fstotal, fsavail;

	mountentry_tofree = glibtop_get_mountlist (&mountlist, 0);

	for (lo = 0, mountentry = mountentry_tofree;
	     lo < mountlist.number;
	     lo++, mountentry++) {
		glibtop_fsusage fsusage;
		gchar * total, *avail;
		GFile *file;
		gchar *uri;
		gboolean excluded;

		struct stat buf;
		if (g_stat (mountentry->devname,&buf) == -1)
			continue;

		glibtop_get_fsusage (&fsusage, mountentry->mountdir);
		fstotal = fsusage.blocks * fsusage.block_size;
		fsavail = fsusage.bfree * fsusage.block_size;
		
			total = g_format_size(fstotal);
			avail = g_format_size(fsavail);
		
		file = g_file_new_for_path (mountentry->mountdir);
		uri = g_file_get_uri (file);
		excluded = baobab_is_excluded_location (file);

		gtk_list_store_append (store, &iter);
		gtk_list_store_set (store, &iter,
				    COL_CHECK, !excluded,
				    COL_DEVICE, mountentry->devname,
				    COL_MOUNT_D, mountentry->mountdir,
				    COL_MOUNT, uri,
				    COL_TYPE, mountentry->type,
				    COL_FS_SIZE, total,
				    COL_FS_AVAIL, avail,
				    -1);
		g_free(total);
		g_free(avail);
		g_free(uri);
		g_object_unref(file);
	}

	g_free (mountentry_tofree);
}
void gtkhash_hash_file_report_cb(void *data, goffset file_size,
	goffset total_read, GTimer *timer)
{
	gdk_threads_enter();

	struct page_s *page = data;

	gtk_progress_bar_set_fraction(page->progressbar,
		(double)total_read /
		(double)file_size);

	double elapsed = g_timer_elapsed(timer, NULL);
	if (elapsed <= 1)
		goto out;

	// Update progressbar text...
	unsigned int s = elapsed / total_read * (file_size - total_read);
#if ((GLIB_MAJOR_VERSION == 2) && (GLIB_MINOR_VERSION < 30))
	char *total_read_str = g_format_size_for_display(total_read);
	char *file_size_str = g_format_size_for_display(file_size);
	char *speed_str = g_format_size_for_display(total_read / elapsed);
#else
	char *total_read_str = g_format_size(total_read);
	char *file_size_str = g_format_size(file_size);
	char *speed_str = g_format_size(total_read / elapsed);
#endif
	char *text;
	if (s > 60) {
		unsigned int m = s / 60;
		if (m == 1)
			text = g_strdup_printf(_("%s of %s - 1 minute left (%s/sec)"),
				total_read_str, file_size_str, speed_str);
		else
			text = g_strdup_printf(_("%s of %s - %u minutes left (%s/sec)"),
				total_read_str, file_size_str, m, speed_str);
	} else {
		if (s == 1)
			text = g_strdup_printf(_("%s of %s - 1 second left (%s/sec)"),
				total_read_str, file_size_str, speed_str);
		else
			text = g_strdup_printf(_("%s of %s - %u seconds left (%s/sec)"),
				total_read_str, file_size_str, s, speed_str);
	}
	gtk_progress_bar_set_text(page->progressbar, text);
	g_free(text);
	g_free(speed_str);
	g_free(file_size_str);
	g_free(total_read_str);

out:
	gdk_threads_leave();
}
示例#6
0
static void
gimp_image_prop_view_label_set_filesize (GtkWidget *label,
                                         GimpImage *image)
{
  GFile *file = gimp_image_get_any_file (image);

  if (file)
    {
      GFileInfo *info = g_file_query_info (file,
                                           G_FILE_ATTRIBUTE_STANDARD_SIZE,
                                           G_FILE_QUERY_INFO_NONE,
                                           NULL, NULL);

      if (info)
        {
          goffset  size = g_file_info_get_size (info);
          gchar   *str  = g_format_size (size);

          gtk_label_set_text (GTK_LABEL (label), str);
          g_free (str);

          g_object_unref (info);
        }
      else
        {
          gtk_label_set_text (GTK_LABEL (label), NULL);
        }
    }
  else
    {
      gtk_label_set_text (GTK_LABEL (label), NULL);
    }
}
示例#7
0
static void
gimp_image_prop_view_label_set_filesize (GtkWidget *label,
                                         GimpImage *image)
{
  gchar *filename = gimp_image_get_filename (image);

  if (filename)
    {
      struct stat  buf;

      if (g_stat (filename, &buf) == 0)
        {
          gchar *str = g_format_size (buf.st_size);

          gtk_label_set_text (GTK_LABEL (label), str);
          g_free (str);
        }
      else
        {
          gtk_label_set_text (GTK_LABEL (label), NULL);
        }

      g_free (filename);
    }
  else
    {
      gtk_label_set_text (GTK_LABEL (label), NULL);
    }
}
示例#8
0
static void
update_album_list (DialogData *data)
{
	GtkTreeIter  iter;
	GList       *scan;

	gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("album_liststore")));
	for (scan = data->albums; scan; scan = scan->next) {
		PicasaWebAlbum *album = scan->data;
		char           *used_bytes;

		used_bytes = g_format_size (album->used_bytes);

		gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter);
		gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter,
				    ALBUM_DATA_COLUMN, album,
				    ALBUM_ICON_COLUMN, "file-catalog-symbolic",
				    ALBUM_NAME_COLUMN, album->title,
				    ALBUM_SIZE_COLUMN, used_bytes,
				    -1);

		g_free (used_bytes);
	}

	gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog), GTK_RESPONSE_OK, FALSE);
	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("album_combobox")), -1);
}
示例#9
0
static void
update_account_list (DialogData *data)
{
	int           current_account_idx;
	OAuthAccount *current_account;
	int           idx;
	GList        *scan;
	GtkTreeIter   iter;
	char         *free_space;

	gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("account_liststore")));

	current_account_idx = 0;
	current_account = web_service_get_current_account (WEB_SERVICE (data->service));
	for (scan = web_service_get_accounts (WEB_SERVICE (data->service)), idx = 0; scan; scan = scan->next, idx++) {
		OAuthAccount *account = scan->data;

		if (oauth_account_cmp (current_account, account) == 0)
			current_account_idx = idx;

		gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("account_liststore")), &iter);
		gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("account_liststore")), &iter,
				    ACCOUNT_DATA_COLUMN, account,
				    ACCOUNT_NAME_COLUMN, account->name,
				    -1);
	}
	gtk_combo_box_set_active (GTK_COMBO_BOX (GET_WIDGET ("account_combobox")), current_account_idx);

	free_space = g_format_size (FLICKR_ACCOUNT (current_account)->max_bandwidth - FLICKR_ACCOUNT (current_account)->used_bandwidth);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("free_space_label")), free_space);
	g_free (free_space);
}
示例#10
0
static void
update_selection_status (DialogData *data)
{
	GList    *file_list;
	int       n_selected;
	goffset   size_selected;
	GList    *scan;
	char     *size_selected_formatted;
	char     *text_selected;

	file_list = get_files_to_download (data);
	n_selected = 0;
	size_selected = 0;
	for (scan = file_list; scan; scan = scan->next) {
		GthFileData *file_data = scan->data;

		n_selected++;
		size_selected += g_file_info_get_size (file_data->info);
	}

	size_selected_formatted = g_format_size (size_selected);
	text_selected = g_strdup_printf (g_dngettext (NULL, "%d file (%s)", "%d files (%s)", n_selected), n_selected, size_selected_formatted);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("images_info_label")), text_selected);

	g_free (text_selected);
	g_free (size_selected_formatted);
	_g_object_list_unref (file_list);
}
示例#11
0
文件: confirm.c 项目: GNOME/dia
/*!
 * \brief Check and - if huge - let the user confirm the diagram size before export
 */
gboolean
confirm_export_size (Diagram *dia, GtkWindow *parent, guint flags)
{
  GtkWidget *dialog;
  int pages = 0;
  gint64 bytes = 0;
  gchar *size, *msg;
  gboolean ret;

  pages = ceil((dia->data->extents.right - dia->data->extents.left) / dia->data->paper.width)
        * ceil((dia->data->extents.bottom - dia->data->extents.top) /  dia->data->paper.height);
  /* three guesses: 4 bytes per pixel, 20 pixels per cm; using * dia->data->paper.scaling  */
  bytes = (gint64)4
        * ceil((dia->data->extents.right - dia->data->extents.left) * dia->data->paper.scaling * 20)
        * ceil((dia->data->extents.bottom - dia->data->extents.top) * dia->data->paper.scaling * 20);

  if ((flags & CONFIRM_PRINT) && (pages < 10)) /* hardcoded limits for the dialog to show */
    return TRUE;
  else if ((flags & CONFIRM_MEMORY) && (bytes < (G_GINT64_CONSTANT(100)<<16)))
    return TRUE; /* smaller than 100MB  */
  else if ((flags & CONFIRM_PAGES) && (pages < 50))
    return TRUE;

  /* message and limits depend on the flags give */
  size = g_format_size (bytes);
  /* See: https://live.gnome.org/TranslationProject/DevGuidelines/Plurals */
  if (flags & CONFIRM_PRINT)
    msg = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
		"You are about to print a diagram with %d page.", /* not triggered */
		"You are about to print a diagram with %d pages.", pages), pages);
  else if ((flags & ~CONFIRM_PAGES) == 0)
    msg = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
		"You are about to export a diagram with %d page.",  /* not triggered */
		"You are about to export a diagram with %d pages.", pages), pages);
  else
    msg = g_strdup_printf (g_dngettext (GETTEXT_PACKAGE,
		"You are about to export a diagram which may require %s of memory.(%d page).",
		"You are about to export a diagram which may require %s of memory.(%d pages).", pages),
		size, pages);
  dialog = gtk_message_dialog_new (parent, /* diagrams display 'shell' */
				   GTK_DIALOG_MODAL|GTK_DIALOG_DESTROY_WITH_PARENT,
				   GTK_MESSAGE_WARNING,
				   GTK_BUTTONS_OK_CANCEL,
				   "%s", msg);
  gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
					    _("You can adjust the size of the diagram by changing "
					      "the 'Scaling' in the 'Page Setup' dialog.\n"
					      "Alternatively use 'Best Fit' "
					      "to move objects/handles into the intended bounds."));
  gtk_window_set_title (GTK_WINDOW (dialog), _("Confirm Diagram Size"));
  g_free (size);

  g_signal_connect(G_OBJECT (dialog), "response",
		   G_CALLBACK(confirm_respond), NULL);

  ret = (GTK_RESPONSE_OK == gtk_dialog_run (GTK_DIALOG (dialog)));
  gtk_widget_destroy(dialog);
  return ret;
}
示例#12
0
static void
gimp_image_prop_view_label_set_memsize (GtkWidget  *label,
                                        GimpObject *object)
{
  gchar *str = g_format_size (gimp_object_get_memsize (object, NULL));
  gtk_label_set_text (GTK_LABEL (label), str);
  g_free (str);
}
示例#13
0
EtFileHeaderFields *
et_mac_header_display_file_info_to_ui (const ET_File *ETFile)
{
    EtFileHeaderFields *fields;
    ET_File_Info *info;
    gchar *time  = NULL;
    gchar *time1 = NULL;
    gchar *size  = NULL;
    gchar *size1 = NULL;

    info = ETFile->ETFileInfo;
    fields = g_slice_new (EtFileHeaderFields);

    fields->description = _("Monkey's Audio File");

    /* Mode changed to profile name  */
    fields->mode_label = _("Profile:");
    fields->mode = info->mpc_profile;

    /* Bitrate */
    fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);

    /* Samplerate */
    fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);

    /* Version changed to encoder version */
    fields->version_label = _("Encoder:");
    fields->version = g_strdup_printf ("%i.%i", info->version / 1000,
                                       info->version % 1000);

    /* Size */
    size = g_format_size (info->size);
    size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
    fields->size = g_strdup_printf ("%s (%s)", size, size1);
    g_free (size);
    g_free (size1);

    /* Duration */
    time = Convert_Duration (info->duration);
    time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
    fields->duration = g_strdup_printf ("%s (%s)", time, time1);
    g_free (time);
    g_free (time1);

    return fields;
}
示例#14
0
/*
 * et_opus_header_display_file_info_to_ui:
 * @ETFile: ET_File to display information
 *
 * Display header info from ET_File.
 *
 * Returns: a new #EtFileHeaderFields, free with
 * et_opus_file_header_fields_free()
 */
EtFileHeaderFields *
et_opus_header_display_file_info_to_ui (const ET_File *ETFile)
{
    EtFileHeaderFields *fields;
    ET_File_Info *info;
    gchar *time = NULL;
    gchar *time1 = NULL;
    gchar *size = NULL;
    gchar *size1 = NULL;

    info = ETFile->ETFileInfo;
    fields = g_slice_new (EtFileHeaderFields);

    fields->description = _("Opus File");

    /* Encoder version */
    fields->version_label = _("Encoder:");
    fields->version = g_strdup_printf ("%d", info->version);

    /* Bitrate */
    fields->bitrate = g_strdup_printf (_("%d kb/s"), info->bitrate);

    /* Samplerate */
    fields->samplerate = g_strdup_printf (_("%d Hz"), info->samplerate);

    /* Mode */
    fields->mode_label = _("Channels:");
    fields->mode = g_strdup_printf ("%d", info->mode);

    /* Size */
    size = g_format_size (info->size);
    size1 = g_format_size (ETCore->ETFileDisplayedList_TotalSize);
    fields->size = g_strdup_printf ("%s (%s)", size, size1);
    g_free (size);
    g_free (size1);

    /* Duration */
    time = Convert_Duration (info->duration);
    time1 = Convert_Duration (ETCore->ETFileDisplayedList_TotalDuration);
    fields->duration = g_strdup_printf ("%s (%s)", time, time1);
    g_free (time);
    g_free (time1);

    return fields;
}
示例#15
0
文件: castget.c 项目: mlj/castget
static void _print_item_update(const enclosure *enclosure, const gchar *filename)
{
  if (enclosure->length > 0) {
    gchar *size = g_format_size(enclosure->length);
    g_printf(" * %s (%s)\n", enclosure->url, size);
    g_free(size);
  } else
    g_printf(" * %s (unknown size)\n", filename);
}
static const gchar *
xfdesktop_special_file_icon_peek_tooltip(XfdesktopIcon *icon)
{
    XfdesktopSpecialFileIcon *special_file_icon = XFDESKTOP_SPECIAL_FILE_ICON(icon);

    if(!special_file_icon->priv->tooltip) {
        GFileInfo *info = xfdesktop_file_icon_peek_file_info(XFDESKTOP_FILE_ICON(icon));

        if(!info)
            return NULL;

        if(XFDESKTOP_SPECIAL_FILE_ICON_TRASH == special_file_icon->priv->type) {
            if(special_file_icon->priv->trash_item_count == 0) {
                special_file_icon->priv->tooltip = g_strdup(_("Trash is empty"));
            } else {
                special_file_icon->priv->tooltip = g_strdup_printf(g_dngettext(GETTEXT_PACKAGE,
                                                                               _("Trash contains one item"),
                                                                               _("Trash contains %d items"),
                                                                               special_file_icon->priv->trash_item_count),

                                                                   special_file_icon->priv->trash_item_count);
            }
        } else {
            const gchar *description;
            gchar *size_string, *time_string;
            guint64 size, mtime;

            if(special_file_icon->priv->type == XFDESKTOP_SPECIAL_FILE_ICON_FILESYSTEM)
                description = _("File System");
            else if(special_file_icon->priv->type == XFDESKTOP_SPECIAL_FILE_ICON_HOME)
                description = _("Home");
            else {
                description = g_file_info_get_attribute_string(info,
                                                               G_FILE_ATTRIBUTE_STANDARD_DESCRIPTION);
            }

            size = g_file_info_get_attribute_uint64(info,
                                                    G_FILE_ATTRIBUTE_STANDARD_SIZE);

            size_string = g_format_size(size);

            mtime = g_file_info_get_attribute_uint64(info,
                                                     G_FILE_ATTRIBUTE_TIME_MODIFIED);
            time_string = xfdesktop_file_utils_format_time_for_display(mtime);

            special_file_icon->priv->tooltip =
                g_strdup_printf(_("%s\nSize: %s\nLast modified: %s"),
                                description, size_string, time_string);

            g_free(size_string);
            g_free(time_string);
        }
    }

    return special_file_icon->priv->tooltip;
}
示例#17
0
static gchar *
gnac_properties_get_property_from_value(const gchar  *name,
                                        const GValue *value)
{
  if (LIBGNAC_METADATA_TAG_IS_DURATION(name)) {
    guint64 duration = g_value_get_uint64(value);
    return gnac_utils_format_duration_for_display(duration);
  }

  if (LIBGNAC_METADATA_TAG_IS_BITRATE(name)) {
    return gnac_properties_dup_bitrate(value);
  }

  if (LIBGNAC_METADATA_TAG_IS_FILE_SIZE(name)) {
    gint64 val = g_value_get_int64(value);
    if (val == 0) return NULL;
    gchar *size = g_format_size(val);
    return size;
  }

  if (LIBGNAC_METADATA_TAG_IS_RATE(name)) {
    return gnac_properties_dup_rate(value);
  }

  if (LIBGNAC_METADATA_TAG_IS_FRAMERATE(name)) {
    return gnac_properties_dup_framerate(value);
  }

  if (LIBGNAC_METADATA_TAG_IS_CHANNELS(name)) {
    return gnac_properties_dup_channels(value);
  }

  if (LIBGNAC_METADATA_TAG_IS_TRACK_GAIN(name) ||
      LIBGNAC_METADATA_TAG_IS_TRACK_PEAK(name))
  {
    gdouble val = g_value_get_double(value);
    if (val == 0) return NULL;
    else return g_strdup_printf("%g", val);
  }

  if (LIBGNAC_METADATA_TAG_IS_AUDIO_CODEC(name) ||
      LIBGNAC_METADATA_TAG_IS_CONTAINER(name)   ||
      LIBGNAC_METADATA_TAG_IS_ENCODER(name)     ||
      LIBGNAC_METADATA_TAG_IS_FILENAME(name)    ||
      LIBGNAC_METADATA_TAG_IS_LOCATION(name)    ||
      LIBGNAC_METADATA_TAG_IS_MODE(name)        ||
      LIBGNAC_METADATA_TAG_IS_VIDEO_CODEC(name))
  {
    const gchar *str = g_value_get_string(value);
    if (!str) return NULL;
    return g_markup_escape_text(str, -1);
  }

  return NULL;
}
示例#18
0
static void
update_album_list (DialogData *data)
{
	GtkTreeIter  iter;
	GList       *scan;
	char        *free_space;

	free_space = g_format_size (picasa_web_service_get_free_space (PICASA_WEB_SERVICE (data->service)));
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("free_space_label")), free_space);
	g_free (free_space);

	gtk_list_store_clear (GTK_LIST_STORE (GET_WIDGET ("album_liststore")));
	for (scan = data->albums; scan; scan = scan->next) {
		PicasaWebAlbum *album = scan->data;
		char           *n_photos_remaining;
		char           *used_bytes;

		n_photos_remaining = g_strdup_printf ("%d", album->n_photos_remaining);
		used_bytes = g_format_size (album->used_bytes);

		gtk_list_store_append (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter);
		gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter,
				    ALBUM_DATA_COLUMN, album,
				    ALBUM_ICON_COLUMN, "file-catalog",
				    ALBUM_NAME_COLUMN, album->title,
				    ALBUM_REMAINING_IMAGES_COLUMN, n_photos_remaining,
				    ALBUM_USED_BYTES_COLUMN, used_bytes,
				    -1);

		if (album->access == PICASA_WEB_ACCESS_PRIVATE)
			gtk_list_store_set (GTK_LIST_STORE (GET_WIDGET ("album_liststore")), &iter,
					    ALBUM_EMBLEM_COLUMN, "emblem-readonly",
					    -1);

		g_free (used_bytes);
		g_free (n_photos_remaining);
	}

	gtk_dialog_set_response_sensitive (GTK_DIALOG (data->dialog),
					   GTK_RESPONSE_OK,
					   FALSE);
}
示例#19
0
static void
fwupd_pad_kv_siz (GString *str, const gchar *key, guint64 value)
{
	g_autofree gchar *tmp = NULL;

	/* ignore */
	if (value == 0)
		return;
	tmp = g_format_size (value);
	fwupd_pad_kv_str (str, key, tmp);
}
示例#20
0
static gboolean
gimp_thumb_box_auto_thumbnail (GimpThumbBox *box)
{
  Gimp          *gimp  = box->context->gimp;
  GimpThumbnail *thumb = gimp_imagefile_get_thumbnail (box->imagefile);
  const gchar   *uri   = gimp_object_get_name (box->imagefile);

  box->idle_id = 0;

  if (thumb->image_state == GIMP_THUMB_STATE_NOT_FOUND)
    return FALSE;

  switch (thumb->thumb_state)
    {
    case GIMP_THUMB_STATE_NOT_FOUND:
    case GIMP_THUMB_STATE_OLD:
      if (thumb->image_filesize < gimp->config->thumbnail_filesize_limit &&
          ! gimp_thumbnail_has_failed (thumb)                            &&
          file_procedure_find_by_extension (gimp->plug_in_manager->load_procs,
                                            uri))
        {
          if (thumb->image_filesize > 0)
            {
              gchar *size;
              gchar *text;

              size = g_format_size (thumb->image_filesize);
              text = g_strdup_printf ("%s\n%s",
                                      size, _("Creating preview..."));

              gtk_label_set_text (GTK_LABEL (box->info), text);

              g_free (text);
              g_free (size);
            }
          else
            {
              gtk_label_set_text (GTK_LABEL (box->info),
                                  _("Creating preview..."));
            }

          gimp_imagefile_create_thumbnail_weak (box->imagefile, box->context,
                                                GIMP_PROGRESS (box),
                                                gimp->config->thumbnail_size,
                                                TRUE);
        }
      break;

    default:
      break;
    }

  return FALSE;
}
static gchar*
net_get_tooltip(SysinfoPlugin* plugin)
{
  NetData* data = (NetData*)plugin->plugin_data;
  gchar* in = g_format_size(data->rate[NET_IN]);
  gchar* out = g_format_size(data->rate[NET_OUT]);
  gchar* local = g_format_size(data->rate[NET_LOCAL]);

  g_snprintf(
    data->tooltip,
    TOOLTIP_SIZE,
    "== Network Traffic ==\nIn: %s/s\nOut: %s/s\nLocal: %s/s",
    in, out, local
  );

  g_free(in);
  g_free(out);
  g_free(local);

  return data->tooltip;
}
示例#22
0
static void
dump_summary_ref (const char   *ref_name,
                  guint64       commit_size,
                  GVariant     *csum_v,
                  GVariantIter *metadata)
{
  const guchar *csum_bytes;
  GError *csum_error = NULL;
  g_autofree char *size = NULL;
  GVariant *value;
  char *key;

  g_print ("* %s\n", ref_name);

  size = g_format_size (commit_size);
  g_print ("    Latest Commit (%s):\n", size);

  csum_bytes = ostree_checksum_bytes_peek_validate (csum_v, &csum_error);
  if (csum_error == NULL)
    {
      char csum[OSTREE_SHA256_STRING_LEN+1];

      ostree_checksum_inplace_from_bytes (csum_bytes, csum);
      g_print ("      %s\n", csum);
    }
  else
    {
      g_print ("      %s\n", csum_error->message);
      g_clear_error (&csum_error);
    }

  while (g_variant_iter_loop (metadata, "{sv}", &key, &value))
    {
      g_autofree gchar *value_str = NULL;
      const gchar *pretty_key = NULL;

      if (g_strcmp0 (key, OSTREE_COMMIT_TIMESTAMP) == 0)
        {
          pretty_key = "Timestamp";
          value_str = uint64_secs_to_iso8601 (GUINT64_FROM_BE (g_variant_get_uint64 (value)));
        }
      else
        {
          value_str = g_variant_print (value, FALSE);
        }

      /* Print out. */
      if (pretty_key != NULL)
        g_print ("    %s (%s): %s\n", pretty_key, key, value_str);
      else
        g_print ("    %s: %s\n", key, value_str);
    }
}
示例#23
0
static MechTextBuffer *
create_buffer (guint n_paragraphs)
{
  GTimer *timer = g_timer_new ();
  MechTextBuffer *buffer;
  gchar *formatted_size;
  gsize size;
  guint i;

  buffer = mech_text_buffer_new ();

  for (i = 0; i < n_paragraphs; i++)
    {
      MechTextIter iter;
      gchar *str;

      mech_text_buffer_get_bounds (buffer, NULL, &iter);
      str = g_strdup_printf ("Paragraph %d: Lorem ipsum dolor sit amet, consectetur "
                             "elit. Sed fermentum accumsan nisi, nec commodo neque "
                             "dictum vitae. Suspendisse vitae ligula felis, id "
                             "dictum risus. Suspendisse semper eros ac massa "
                             "imperdiet sagittis. Vestibulum sem dolor, lobortis "
                             "sit amet lobortis porta, cursus a sem. Nam mattis "
                             "rutrum dignissim. Phasellus hendrerit mauris eget "
                             "massa placerat luctus. Nam rutrum dapibus justo ac "
                             "ornare. Phasellus adipiscing tempor massa, vel "
                             "ultricies nulla fermentum non. Proin in lacus "
                             "bibendum lectus aliquam gravida eget id erat. "
                             "Etiam tincidunt sodales urna, eget fermentum orci "
                             "venenatis eu. Donec id sollicitudin augue. Ut turpis "
                             "odio, convallis sit amet euismod eu, elementum non "
                             "neque.\n\n", i);
      mech_text_buffer_insert (buffer, &iter, str, -1);
      g_free (str);
    }

  size = mech_text_buffer_get_byte_offset (buffer, NULL, NULL);
  formatted_size = g_format_size (size);

  g_print ("Buffer with %d paragraphs created in %f, %ld bytes (%s)\n",
           n_paragraphs, g_timer_elapsed (timer, NULL),
           mech_text_buffer_get_byte_offset (buffer, NULL, NULL),
           formatted_size);

  g_timer_destroy (timer);
  g_free (formatted_size);

  return buffer;
}
示例#24
0
static gchar *
photos_export_dialog_create_size_str (gint height, gint width, guint64 size)
{
  g_autofree gchar *size_str = NULL;
  gchar *ret_val;

  size_str = g_format_size (size);

  /* Translators: this is the estimated size of the exported image in
   * the form "1600×1067 (0.6 GB)".
   */
  ret_val = g_strdup_printf (_("%d×%d (%s)"), width, height, size_str);

  return ret_val;
}
static const gchar *
xfdesktop_volume_icon_peek_tooltip(XfdesktopIcon *icon)
{
    XfdesktopVolumeIcon *volume_icon = XFDESKTOP_VOLUME_ICON(icon);
    GFileInfo *fs_info = xfdesktop_file_icon_peek_filesystem_info(XFDESKTOP_FILE_ICON(icon));
    GFile *file = xfdesktop_file_icon_peek_file(XFDESKTOP_FILE_ICON(icon));
    
    if(!volume_icon->priv->tooltip) {
        guint64 size, free_space;
        gchar *mount_point = NULL, *size_string = NULL, *free_space_string = NULL;

        if(file && fs_info) {
            mount_point = g_file_get_parse_name(file);

            size = g_file_info_get_attribute_uint64(fs_info,
                                                    G_FILE_ATTRIBUTE_FILESYSTEM_SIZE);
            free_space = g_file_info_get_attribute_uint64(fs_info,
                                                          G_FILE_ATTRIBUTE_FILESYSTEM_FREE);

            size_string = g_format_size(size);
            free_space_string = g_format_size(free_space);

            volume_icon->priv->tooltip =
                g_strdup_printf(_("Removable Volume\nMounted in \"%s\"\n%s left (%s total)"),
                                mount_point, free_space_string, size_string);
    
            g_free(free_space_string);
            g_free(size_string);
            g_free(mount_point);
        } else {
            volume_icon->priv->tooltip = g_strdup(_("Removable Volume\nNot mounted yet"));
        }
    }

    return volume_icon->priv->tooltip;
}
示例#26
0
static void
attachment_paned_update_status (EAttachmentPaned *paned)
{
	EAttachmentView *view;
	EAttachmentStore *store;
	GtkExpander *expander;
	GtkLabel *label;
	guint num_attachments;
	guint64 total_size;
	gchar *display_size;
	gchar *markup;

	view = E_ATTACHMENT_VIEW (paned);
	store = e_attachment_view_get_store (view);
	expander = GTK_EXPANDER (paned->priv->expander);
	label = GTK_LABEL (paned->priv->status_label);

	num_attachments = e_attachment_store_get_num_attachments (store);
	total_size = e_attachment_store_get_total_size (store);
	display_size = g_format_size (total_size);

	if (total_size > 0)
		markup = g_strdup_printf (
			"<b>%d</b> %s (%s)", num_attachments, ngettext (
			"Attachment", "Attachments", num_attachments),
			display_size);
	else
		markup = g_strdup_printf (
			"<b>%d</b> %s", num_attachments, ngettext (
			"Attachment", "Attachments", num_attachments));
	gtk_label_set_markup (label, markup);
	g_free (markup);

	g_free (display_size);

	if (num_attachments > 0) {
		gtk_widget_show (paned->priv->status_icon);
		gtk_widget_show (paned->priv->status_label);
		gtk_expander_set_expanded (expander, TRUE);
	} else {
		gtk_widget_hide (paned->priv->status_icon);
		gtk_widget_hide (paned->priv->status_label);
		gtk_expander_set_expanded (expander, FALSE);
	}
}
示例#27
0
static VALUE
rbglib_m_format_size(int argc, VALUE *argv, G_GNUC_UNUSED VALUE self)
{
    VALUE rb_size, rb_options;

    rb_scan_args(argc, argv, "11", &rb_size, &rb_options);
    if (NIL_P(rb_options)) {
      return CSTR2RVAL_FREE(g_format_size(NUM2ULONG(rb_size)));
    } else {
      VALUE rb_flags;
      rbg_scan_options(rb_options,
                       "flags", &rb_flags,
                       NULL);

      return CSTR2RVAL_FREE(g_format_size_full(NUM2ULONG(rb_size),
                                               RVAL2GFORMATSIZEFLAGS(rb_flags)));
    }
}
示例#28
0
static void
attachment_bar_update_status (EAttachmentBar *bar)
{
	EAttachmentStore *store;
	GtkActivatable *activatable;
	GtkAction *action;
	GtkLabel *label;
	gint num_attachments;
	guint64 total_size;
	gchar *display_size;
	gchar *markup;

	store = E_ATTACHMENT_STORE (bar->priv->model);
	label = GTK_LABEL (bar->priv->status_label);

	num_attachments = e_attachment_store_get_num_attachments (store);
	total_size = e_attachment_store_get_total_size (store);
	display_size = g_format_size (total_size);

	if (total_size > 0)
		markup = g_strdup_printf (
			"<b>%d</b> %s (%s)", num_attachments, ngettext (
			"Attachment", "Attachments", num_attachments),
			display_size);
	else
		markup = g_strdup_printf (
			"<b>%d</b> %s", num_attachments, ngettext (
			"Attachment", "Attachments", num_attachments));
	gtk_label_set_markup (label, markup);
	g_free (markup);

	activatable = GTK_ACTIVATABLE (bar->priv->save_all_button);
	action = gtk_activatable_get_related_action (activatable);
	gtk_action_set_visible (action, (num_attachments > 1));

	activatable = GTK_ACTIVATABLE (bar->priv->save_one_button);
	action = gtk_activatable_get_related_action (activatable);
	gtk_action_set_visible (action, (num_attachments == 1));

	g_free (display_size);
}
static gchar*
gsd_ldsm_dialog_get_primary_text (GsdLdsmDialog *dialog)
{
        gchar *primary_text, *free_space;
	
        g_return_val_if_fail (GSD_IS_LDSM_DIALOG (dialog), NULL);
	
        free_space = g_format_size (dialog->priv->space_remaining);
	
        if (dialog->priv->other_partitions) {
                primary_text = g_strdup_printf (_("The volume \"%s\" has only %s disk space remaining."),
                                                dialog->priv->partition_name, free_space);
        } else {
                primary_text = g_strdup_printf (_("This computer has only %s disk space remaining."),
                                                free_space);
        }
	
        g_free (free_space);
	
        return primary_text;	
}
示例#30
0
static void
update_status (DialogData *data)
{
	GtkWidget *file_view;
	int        n_selected;
	goffset    size;
	GList     *selected;
	GList     *file_list;
	GList     *scan;
	char      *ssize;
	char      *status;

	file_view = gth_file_list_get_view (GTH_FILE_LIST (data->file_list));
	selected = gth_file_selection_get_selected (GTH_FILE_SELECTION (file_view));
	if (selected != NULL)
		file_list = gth_file_list_get_files (GTH_FILE_LIST (data->file_list), selected);
	else
		file_list = gth_file_store_get_visibles (GTH_FILE_STORE (gth_file_view_get_model (GTH_FILE_VIEW (file_view))));

	n_selected = 0;
	size = 0;
	for (scan = file_list; scan; scan = scan->next) {
		GthFileData *file_data = scan->data;

		size += g_file_info_get_size (file_data->info);
		n_selected += 1;
	}
	ssize = g_format_size (size);
	/* translators: %d is the number of files, %s the total size */
	status = g_strdup_printf (_("Files to import: %d (%s)"), n_selected, ssize);
	gtk_label_set_text (GTK_LABEL (GET_WIDGET ("status_label")), status);

	g_free (status);
	g_free (ssize);

	_g_object_list_unref (file_list);
	_gtk_tree_path_list_free (selected);
}