evince r3308 - in trunk: . shell



Author: carlosgc
Date: Sat Dec 27 18:37:33 2008
New Revision: 3308
URL: http://svn.gnome.org/viewvc/evince?rev=3308&view=rev

Log:
2008-12-27  Carlos Garcia Campos  <carlosgc gnome org>

	* shell/Makefile.am:
	* shell/ev-progress-message-area.[ch]:
	* shell/ev-message-area.[ch]: (ev_message_area_init),
	(ev_message_area_set_image_from_stock):

	Add EvProgressMessageArea derived from EvMessageArea to show
	progress information in the message area.

Added:
   trunk/shell/ev-progress-message-area.c
   trunk/shell/ev-progress-message-area.h
Modified:
   trunk/ChangeLog
   trunk/shell/Makefile.am
   trunk/shell/ev-message-area.c
   trunk/shell/ev-message-area.h

Modified: trunk/shell/Makefile.am
==============================================================================
--- trunk/shell/Makefile.am	(original)
+++ trunk/shell/Makefile.am	Sat Dec 27 18:37:33 2008
@@ -63,6 +63,8 @@
 	ev-pixbuf-cache.h		\
 	ev-print-operation.h		\
 	ev-print-operation.c		\
+	ev-progress-message-area.h	\
+	ev-progress-message-area.c	\
 	ev-properties-dialog.c		\
 	ev-properties-dialog.h		\
 	ev-properties-fonts.c		\

Modified: trunk/shell/ev-message-area.c
==============================================================================
--- trunk/shell/ev-message-area.c	(original)
+++ trunk/shell/ev-message-area.c	Sat Dec 27 18:37:33 2008
@@ -101,10 +101,13 @@
 static void
 ev_message_area_init (EvMessageArea *area)
 {
+	GtkWidget *main_box;
 	GtkWidget *hbox, *vbox;
 	
 	area->priv = EV_MESSAGE_AREA_GET_PRIVATE (area);
 
+	main_box = gtk_vbox_new (FALSE, 12);
+	
 	hbox = gtk_hbox_new (FALSE, 12);
 	vbox = gtk_vbox_new (FALSE, 12);
 	
@@ -133,8 +136,11 @@
 	gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, TRUE, 0);
 	gtk_widget_show (vbox);
 
-	gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (area), hbox);
+	gtk_box_pack_start (GTK_BOX (main_box), hbox, TRUE, TRUE, 0);
 	gtk_widget_show (hbox);
+	
+	gedit_message_area_set_contents (GEDIT_MESSAGE_AREA (area), main_box);
+	gtk_widget_show (main_box);
 }
 
 static void
@@ -281,6 +287,18 @@
 }
 
 void
+ev_message_area_set_image_from_stock (EvMessageArea *area,
+				      const gchar   *stock_id)
+{
+	g_return_if_fail (EV_IS_MESSAGE_AREA (area));
+	g_return_if_fail (stock_id != NULL);
+	
+	gtk_image_set_from_stock (GTK_IMAGE (area->priv->image),
+				  stock_id,
+				  GTK_ICON_SIZE_DIALOG);
+}
+
+void
 ev_message_area_set_text (EvMessageArea *area,
 			  const gchar   *str)
 {

Modified: trunk/shell/ev-message-area.h
==============================================================================
--- trunk/shell/ev-message-area.h	(original)
+++ trunk/shell/ev-message-area.h	Sat Dec 27 18:37:33 2008
@@ -52,17 +52,19 @@
 	GeditMessageAreaClass parent_class;
 };
 
-GType      ev_message_area_get_type           (void) G_GNUC_CONST;
-GtkWidget *ev_message_area_new                (GtkMessageType type,
-					       const gchar   *text,
-					       const gchar   *first_button_text,
-					       ...);
-void       ev_message_area_set_image          (EvMessageArea *area,
-					       GtkWidget     *image);
-void       ev_message_area_set_text           (EvMessageArea *area,
-					       const gchar   *str);
-void       ev_message_area_set_secondary_text (EvMessageArea *area,
-					       const gchar   *str);
+GType      ev_message_area_get_type             (void) G_GNUC_CONST;
+GtkWidget *ev_message_area_new                  (GtkMessageType type,
+						 const gchar   *text,
+						 const gchar   *first_button_text,
+						 ...);
+void       ev_message_area_set_image            (EvMessageArea *area,
+						 GtkWidget     *image);
+void       ev_message_area_set_image_from_stock (EvMessageArea *area,
+						 const gchar   *stock_id);
+void       ev_message_area_set_text             (EvMessageArea *area,
+						 const gchar   *str);
+void       ev_message_area_set_secondary_text   (EvMessageArea *area,
+						 const gchar   *str);
 
 G_END_DECLS
 

Added: trunk/shell/ev-progress-message-area.c
==============================================================================
--- (empty file)
+++ trunk/shell/ev-progress-message-area.c	Sat Dec 27 18:37:33 2008
@@ -0,0 +1,198 @@
+/* ev-progress-message-area.c
+ *  this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2008 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * Evince 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.
+ *
+ * Evince 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.
+ */
+
+#include <config.h>
+
+#include <gtk/gtk.h>
+
+#include "ev-progress-message-area.h"
+
+#define EV_PROGRESS_MESSAGE_AREA_GET_PRIVATE(obj) \
+	(G_TYPE_INSTANCE_GET_PRIVATE ((obj), EV_TYPE_PROGRESS_MESSAGE_AREA, EvProgressMessageAreaPrivate))
+
+struct _EvProgressMessageAreaPrivate {
+	GtkWidget *label;
+	GtkWidget *progress_bar;
+};
+
+enum {
+	PROP_0,
+	PROP_STATUS,
+	PROP_FRACTION
+};
+
+static void ev_progress_message_area_set_property (GObject      *object,
+						   guint         prop_id,
+						   const GValue *value,
+						   GParamSpec   *pspec);
+static void ev_progress_message_area_get_property (GObject      *object,
+						   guint         prop_id,
+						   GValue       *value,
+						   GParamSpec   *pspec);
+
+G_DEFINE_TYPE (EvProgressMessageArea, ev_progress_message_area, EV_TYPE_MESSAGE_AREA)
+
+static void
+ev_progress_message_area_class_init (EvProgressMessageAreaClass *class)
+{
+	GObjectClass *gobject_class = G_OBJECT_CLASS (class);
+
+	gobject_class->set_property = ev_progress_message_area_set_property;
+	gobject_class->get_property = ev_progress_message_area_get_property;
+
+	g_object_class_install_property (gobject_class,
+					 PROP_STATUS,
+					 g_param_spec_string ("status",
+							      "Status",
+							      "The status text of the progress area",
+							      NULL,
+							      G_PARAM_READWRITE));
+	g_object_class_install_property (gobject_class,
+					 PROP_FRACTION,
+					 g_param_spec_double ("fraction",
+							      "Fraction",
+							      "The fraction of total work that has been completed",
+							      0.0, 1.0, 0.0,
+							      G_PARAM_READWRITE));
+
+	g_type_class_add_private (gobject_class, sizeof (EvProgressMessageAreaPrivate));
+}
+
+static void
+ev_progress_message_area_init (EvProgressMessageArea *area)
+{
+	GtkWidget *contents;
+	GtkWidget *vbox;
+	
+	area->priv = EV_PROGRESS_MESSAGE_AREA_GET_PRIVATE (area);
+
+	contents = gedit_message_area_get_contents (GEDIT_MESSAGE_AREA (area));
+	
+	vbox = gtk_vbox_new (FALSE, 6);
+	
+	area->priv->label = gtk_label_new (NULL);
+	gtk_label_set_use_markup (GTK_LABEL (area->priv->label), TRUE);
+	gtk_label_set_ellipsize (GTK_LABEL (area->priv->label),
+				 PANGO_ELLIPSIZE_END);
+	gtk_misc_set_alignment (GTK_MISC (area->priv->label), 0.0, 0.5);
+	gtk_box_pack_start (GTK_BOX (vbox), area->priv->label, TRUE, TRUE, 0);
+	gtk_widget_show (area->priv->label);
+
+	area->priv->progress_bar = gtk_progress_bar_new ();
+	gtk_widget_set_size_request (area->priv->progress_bar, -1, 15);
+	gtk_box_pack_start (GTK_BOX (vbox), area->priv->progress_bar, TRUE, FALSE, 0);
+	gtk_widget_show (area->priv->progress_bar);
+
+	gtk_box_pack_start (GTK_BOX (contents), vbox, TRUE, TRUE, 0);
+	gtk_widget_show (vbox);
+}
+
+static void
+ev_progress_message_area_set_property (GObject      *object,
+				       guint         prop_id,
+				       const GValue *value,
+				       GParamSpec   *pspec)
+{
+	EvProgressMessageArea *area = EV_PROGRESS_MESSAGE_AREA (object);
+
+	switch (prop_id) {
+	case PROP_STATUS:
+		ev_progress_message_area_set_status (area, g_value_get_string (value));
+		break;
+	case PROP_FRACTION:
+		ev_progress_message_area_set_fraction (area, g_value_get_double (value));
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
+}
+
+static void
+ev_progress_message_area_get_property (GObject    *object,
+				       guint       prop_id,
+				       GValue     *value,
+				       GParamSpec *pspec)
+{
+	EvProgressMessageArea *area = EV_PROGRESS_MESSAGE_AREA (object);
+
+	switch (prop_id) {
+	case PROP_STATUS:
+		g_value_set_string (value, gtk_label_get_label (GTK_LABEL (area->priv->label)));
+		break;
+	case PROP_FRACTION: {
+		gdouble fraction;
+
+		fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (area->priv->progress_bar));
+		g_value_set_double (value, fraction);
+	}
+		break;
+	default:
+		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+	}
+}
+
+GtkWidget *
+ev_progress_message_area_new (const gchar *stock_id,
+			      const gchar *text,
+			      const gchar *first_button_text,
+			      ...)
+{
+	GtkWidget *widget;
+
+	widget = g_object_new (EV_TYPE_PROGRESS_MESSAGE_AREA,
+			       "message-type", GTK_MESSAGE_OTHER,
+			       "text", text,
+			       NULL);
+	if (first_button_text) {
+		va_list args;
+		
+		va_start (args, first_button_text);
+		gedit_message_area_add_buttons_valist (GEDIT_MESSAGE_AREA (widget),
+						       first_button_text,
+						       args);
+		va_end (args);
+	}
+
+	ev_message_area_set_image_from_stock (EV_MESSAGE_AREA (widget), stock_id);
+
+	return widget;
+}
+
+void
+ev_progress_message_area_set_status (EvProgressMessageArea *area,
+				     const gchar           *str)
+{
+	g_return_if_fail (EV_IS_PROGRESS_MESSAGE_AREA (area));
+
+	gtk_label_set_text (GTK_LABEL (area->priv->label), str);
+
+	g_object_notify (G_OBJECT (area), "status");
+}
+
+void
+ev_progress_message_area_set_fraction (EvProgressMessageArea *area,
+				       gdouble                fraction)
+{
+	g_return_if_fail (EV_IS_PROGRESS_MESSAGE_AREA (area));
+	
+	gtk_progress_bar_set_fraction (GTK_PROGRESS_BAR (area->priv->progress_bar),
+				       fraction);
+	g_object_notify (G_OBJECT (area), "fraction");
+}

Added: trunk/shell/ev-progress-message-area.h
==============================================================================
--- (empty file)
+++ trunk/shell/ev-progress-message-area.h	Sat Dec 27 18:37:33 2008
@@ -0,0 +1,64 @@
+/* ev-progress-message-area.h
+ *  this file is part of evince, a gnome document viewer
+ *
+ * Copyright (C) 2008 Carlos Garcia Campos <carlosgc gnome org>
+ *
+ * Evince 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.
+ *
+ * Evince 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.
+ */
+
+#ifndef EV_PROGRESS_MESSAGE_AREA_H
+#define EV_PROGRESS_MESSAGE_AREA_H
+
+#include <gtk/gtk.h>
+
+#include "ev-message-area.h"
+
+G_BEGIN_DECLS
+
+#define EV_TYPE_PROGRESS_MESSAGE_AREA                  (ev_progress_message_area_get_type ())
+#define EV_PROGRESS_MESSAGE_AREA(obj)                  (G_TYPE_CHECK_INSTANCE_CAST ((obj), EV_TYPE_PROGRESS_MESSAGE_AREA, EvProgressMessageArea))
+#define EV_PROGRESS_MESSAGE_AREA_CLASS(klass)          (G_TYPE_CHECK_CLASS_CAST ((klass), EV_TYPE_PROGRESS_MESSAGE_AREA, EvProgressMessageAreaClass))
+#define EV_IS_PROGRESS_MESSAGE_AREA(obj)               (G_TYPE_CHECK_INSTANCE_TYPE ((obj), EV_TYPE_PROGRESS_MESSAGE_AREA))
+#define EV_IS_PROGRESS_MESSAGE_AREA_CLASS(klass)       (G_TYPE_CHECK_CLASS_TYPE ((klass), EV_TYPE_PROGRESS_MESSAGE_AREA))
+#define EV_PROGRESS_MESSAGE_AREA_GET_CLASS(obj)        (G_TYPE_INSTANCE_GET_CLASS ((obj), EV_TYPE_PROGRESS_MESSAGE_AREA, EvProgressMessageAreaClass))
+
+typedef struct _EvProgressMessageArea        EvProgressMessageArea;
+typedef struct _EvProgressMessageAreaClass   EvProgressMessageAreaClass;
+typedef struct _EvProgressMessageAreaPrivate EvProgressMessageAreaPrivate;
+
+struct _EvProgressMessageArea {
+	EvMessageArea parent_instance;
+
+	/*< private >*/
+	EvProgressMessageAreaPrivate *priv;
+};
+
+struct _EvProgressMessageAreaClass {
+	EvMessageAreaClass parent_class;
+};
+
+GType      ev_progress_message_area_get_type        (void) G_GNUC_CONST;
+GtkWidget *ev_progress_message_area_new             (const gchar           *stock_id,
+						     const gchar           *text,
+						     const gchar           *first_button_text,
+						     ...);
+void       ev_progress_message_area_set_status      (EvProgressMessageArea *area,
+						     const gchar           *str);
+void       ev_progress_message_area_set_fraction    (EvProgressMessageArea *area,
+						     gdouble                fraction);
+
+G_END_DECLS
+
+#endif /* EV_PROGRESS_MESSAGE_AREA_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]