summaryrefslogtreecommitdiff
path: root/src/eom-statusbar.c
diff options
context:
space:
mode:
authorPerberos <[email protected]>2011-11-06 19:30:49 -0300
committerPerberos <[email protected]>2011-11-06 19:30:49 -0300
commita8d28a6ce7e0c56dacba5d527d9134573a008902 (patch)
tree8852602004b5a13cc5d1ce3ecd7a314be81d1198 /src/eom-statusbar.c
downloadeom-a8d28a6ce7e0c56dacba5d527d9134573a008902.tar.bz2
eom-a8d28a6ce7e0c56dacba5d527d9134573a008902.tar.xz
inicial
Diffstat (limited to 'src/eom-statusbar.c')
-rw-r--r--src/eom-statusbar.c157
1 files changed, 157 insertions, 0 deletions
diff --git a/src/eom-statusbar.c b/src/eom-statusbar.c
new file mode 100644
index 0000000..7b4b993
--- /dev/null
+++ b/src/eom-statusbar.c
@@ -0,0 +1,157 @@
+/* Eye of Mate - Statusbar
+ *
+ * Copyright (C) 2000-2006 The Free Software Foundation
+ *
+ * Author: Federico Mena-Quintero <[email protected]>
+ * Jens Finke <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "eom-statusbar.h"
+
+#include <string.h>
+#include <glib/gi18n.h>
+#include <gtk/gtk.h>
+
+#define EOM_STATUSBAR_GET_PRIVATE(object) \
+ (G_TYPE_INSTANCE_GET_PRIVATE ((object), EOM_TYPE_STATUSBAR, EomStatusbarPrivate))
+
+G_DEFINE_TYPE (EomStatusbar, eom_statusbar, GTK_TYPE_STATUSBAR)
+
+struct _EomStatusbarPrivate
+{
+ GtkWidget *progressbar;
+ GtkWidget *img_num_statusbar;
+};
+
+static void
+eom_statusbar_class_init (EomStatusbarClass *klass)
+{
+ GObjectClass *g_object_class = G_OBJECT_CLASS (klass);
+
+ g_type_class_add_private (g_object_class, sizeof (EomStatusbarPrivate));
+}
+
+static void
+eom_statusbar_init (EomStatusbar *statusbar)
+{
+ EomStatusbarPrivate *priv;
+ GtkWidget *vbox;
+
+ statusbar->priv = EOM_STATUSBAR_GET_PRIVATE (statusbar);
+ priv = statusbar->priv;
+
+ gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), TRUE);
+
+ priv->img_num_statusbar = gtk_statusbar_new ();
+ gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (priv->img_num_statusbar), FALSE);
+ gtk_widget_set_size_request (priv->img_num_statusbar, 100, 10);
+ gtk_widget_show (priv->img_num_statusbar);
+
+ gtk_box_pack_end (GTK_BOX (statusbar),
+ priv->img_num_statusbar,
+ FALSE,
+ TRUE,
+ 0);
+
+ vbox = gtk_vbox_new (FALSE, 0);
+
+ gtk_box_pack_end (GTK_BOX (statusbar),
+ vbox,
+ FALSE,
+ FALSE,
+ 2);
+
+ statusbar->priv->progressbar = gtk_progress_bar_new ();
+
+ gtk_box_pack_end (GTK_BOX (vbox),
+ priv->progressbar,
+ TRUE,
+ TRUE,
+ 2);
+
+ gtk_widget_set_size_request (priv->progressbar, -1, 10);
+
+ gtk_widget_show (vbox);
+
+ gtk_widget_hide (statusbar->priv->progressbar);
+
+}
+
+GtkWidget *
+eom_statusbar_new (void)
+{
+ return GTK_WIDGET (g_object_new (EOM_TYPE_STATUSBAR, NULL));
+}
+
+void
+eom_statusbar_set_image_number (EomStatusbar *statusbar,
+ gint num,
+ gint tot)
+{
+ gchar *msg;
+
+ g_return_if_fail (EOM_IS_STATUSBAR (statusbar));
+
+ gtk_statusbar_pop (GTK_STATUSBAR (statusbar->priv->img_num_statusbar), 0);
+
+ /* Translators: This string is displayed in the statusbar.
+ * The first token is the image number, the second is total image
+ * count.
+ *
+ * Translate to "%Id" if you want to use localized digits, or
+ * translate to "%d" otherwise.
+ *
+ * Note that translating this doesn't guarantee that you get localized
+ * digits. That needs support from your system and locale definition
+ * too.*/
+ msg = g_strdup_printf (_("%d / %d"), num, tot);
+
+ gtk_statusbar_push (GTK_STATUSBAR (statusbar->priv->img_num_statusbar), 0, msg);
+
+ g_free (msg);
+}
+
+void
+eom_statusbar_set_progress (EomStatusbar *statusbar,
+ gdouble progress)
+{
+ g_return_if_fail (EOM_IS_STATUSBAR (statusbar));
+
+ gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (statusbar->priv->progressbar),
+ progress);
+
+ if (progress > 0 && progress < 1) {
+ gtk_widget_show (statusbar->priv->progressbar);
+ gtk_widget_hide (statusbar->priv->img_num_statusbar);
+ } else {
+ gtk_widget_hide (statusbar->priv->progressbar);
+ gtk_widget_show (statusbar->priv->img_num_statusbar);
+ }
+}
+
+void
+eom_statusbar_set_has_resize_grip (EomStatusbar *statusbar, gboolean has_resize_grip)
+{
+ g_return_if_fail (EOM_IS_STATUSBAR (statusbar));
+
+ gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar),
+ has_resize_grip);
+}