aboutsummaryrefslogtreecommitdiffstats
path: root/shell/e-shell-folder-title-bar.c
diff options
context:
space:
mode:
authornobody <nobody@localhost>2003-04-02 01:15:53 +0800
committernobody <nobody@localhost>2003-04-02 01:15:53 +0800
commit2e5b2bbb530b642dda56b332cfd93810ac415098 (patch)
treee2b63c11a404a5dd99d407c989c8846fd0d5379d /shell/e-shell-folder-title-bar.c
parent5cda225087bfdc66e19edb703689e8af655e171c (diff)
downloadgsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.tar
gsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.tar.gz
gsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.tar.bz2
gsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.tar.lz
gsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.tar.xz
gsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.tar.zst
gsoc2013-evolution-2e5b2bbb530b642dda56b332cfd93810ac415098.zip
This commit was manufactured by cvs2svn to create tagEVOLUTION_1_2_4
'EVOLUTION_1_2_4'. svn path=/tags/EVOLUTION_1_2_4/; revision=20614
Diffstat (limited to 'shell/e-shell-folder-title-bar.c')
-rw-r--r--shell/e-shell-folder-title-bar.c272
1 files changed, 158 insertions, 114 deletions
diff --git a/shell/e-shell-folder-title-bar.c b/shell/e-shell-folder-title-bar.c
index 5c995f32d8..ee1fb91dc6 100644
--- a/shell/e-shell-folder-title-bar.c
+++ b/shell/e-shell-folder-title-bar.c
@@ -24,13 +24,12 @@
#include <config.h>
#endif
-#include <string.h>
-#include <gtk/gtkarrow.h>
#include <gtk/gtklabel.h>
-#include <gtk/gtkimage.h>
+#include <gtk/gtkpixmap.h>
#include <gtk/gtkrc.h>
#include <gtk/gtksignal.h>
#include <gtk/gtktogglebutton.h>
+#include <libgnome/gnome-defs.h>
#include <libgnome/gnome-i18n.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
@@ -39,7 +38,6 @@
#include "widgets/misc/e-clipped-label.h"
#include "e-shell-constants.h"
-#include "e-shell-marshal.h"
#include "e-shell-folder-title-bar.h"
@@ -85,8 +83,66 @@ enum {
static guint signals[LAST_SIGNAL] = { 0 };
+static const char *down_arrow_xpm[] = {
+ "11 5 2 1",
+ " c none",
+ ". c #ffffffffffff",
+ " ......... ",
+ " ....... ",
+ " ..... ",
+ " ... ",
+ " . ",
+};
+
+static const char *left_arrow_xpm[] = {
+ "11 7 2 1",
+ " c none",
+ ". c #ffffffffffff",
+ " . ",
+ " .. ",
+ " ........ ",
+ " ......... ",
+ " ........ ",
+ " .. ",
+ " . ",
+};
+
+static const char *right_arrow_xpm[] = {
+ "11 7 2 1",
+ " c none",
+ ". c #ffffffffffff",
+ " . ",
+ " .. ",
+ " ........ ",
+ " ......... ",
+ " ........ ",
+ " .. ",
+ " . ",
+};
+
+
/* Utility functions for managing icons and icon widgets. */
+static GtkWidget *
+create_pixmap_widget_from_xpm (const char **xpm)
+{
+ GdkPixbuf *pixbuf;
+ GdkPixmap *pixmap;
+ GdkBitmap *mask;
+ GtkWidget *widget;
+
+ pixbuf = gdk_pixbuf_new_from_xpm_data (xpm);
+
+ gdk_pixbuf_render_pixmap_and_mask (pixbuf, &pixmap, &mask, 127);
+
+ widget = gtk_pixmap_new (pixmap, mask);
+ gtk_widget_show (widget);
+
+ gdk_pixbuf_unref (pixbuf);
+
+ return widget;
+}
+
static GdkPixbuf *
new_empty_pixbuf (void)
{
@@ -102,9 +158,9 @@ new_empty_pixbuf (void)
}
static GtkWidget *
-new_empty_image_widget (void)
+new_empty_pixmap_widget (void)
{
- GtkWidget *image_widget;
+ GtkWidget *pixmap_widget;
GdkPixmap *pixmap;
GdkBitmap *mask;
GdkPixbuf *empty_pixbuf;
@@ -112,11 +168,28 @@ new_empty_image_widget (void)
empty_pixbuf = new_empty_pixbuf ();
gdk_pixbuf_render_pixmap_and_mask (empty_pixbuf, &pixmap, &mask, 127);
- image_widget = gtk_image_new_from_pixmap (pixmap, mask);
+ pixmap_widget = gtk_pixmap_new (pixmap, mask);
- g_object_unref (empty_pixbuf);
+ gdk_pixbuf_unref (empty_pixbuf);
- return image_widget;
+ return pixmap_widget;
+}
+
+
+static void
+set_title_bar_label_style (GtkWidget *widget)
+{
+ GtkRcStyle *rc_style;
+
+ rc_style = gtk_rc_style_new();
+
+ rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;
+ rc_style->fg[GTK_STATE_NORMAL].red = 0xffff;
+ rc_style->fg[GTK_STATE_NORMAL].green = 0xffff;
+ rc_style->fg[GTK_STATE_NORMAL].blue = 0xffff;
+
+ gtk_widget_modify_style (widget, rc_style);
+ gtk_rc_style_unref (rc_style);
}
@@ -125,9 +198,12 @@ new_empty_image_widget (void)
static int
get_max_clipped_label_width (EClippedLabel *clipped_label)
{
+ GdkFont *font;
int width;
- pango_layout_get_pixel_size (clipped_label->layout, &width, NULL);
+ font = GTK_WIDGET (clipped_label)->style->font;
+
+ width = gdk_string_width (font, clipped_label->label);
width += 2 * GTK_MISC (clipped_label)->xpad;
return width;
@@ -242,7 +318,7 @@ back_button_clicked_callback (GtkButton *button,
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data);
- g_signal_emit (folder_title_bar, signals[BACK_CLICKED], 0);
+ gtk_signal_emit (GTK_OBJECT (folder_title_bar), signals[BACK_CLICKED]);
}
static void
@@ -253,15 +329,15 @@ forward_button_clicked_callback (GtkButton *button,
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data);
- g_signal_emit (folder_title_bar, signals[FORWARD_CLICKED], 0);
+ gtk_signal_emit (GTK_OBJECT (folder_title_bar), signals[FORWARD_CLICKED]);
}
static void
add_navigation_buttons (EShellFolderTitleBar *folder_title_bar)
{
EShellFolderTitleBarPrivate *priv;
- GtkWidget *back_image;
- GtkWidget *forward_image;
+ GtkWidget *back_pixmap;
+ GtkWidget *forward_pixmap;
priv = folder_title_bar->priv;
@@ -269,21 +345,21 @@ add_navigation_buttons (EShellFolderTitleBar *folder_title_bar)
gtk_button_set_relief (GTK_BUTTON (priv->back_button), GTK_RELIEF_NONE);
GTK_WIDGET_UNSET_FLAGS (priv->back_button, GTK_CAN_FOCUS);
- back_image = gtk_arrow_new (GTK_ARROW_LEFT, GTK_SHADOW_NONE);
- gtk_container_add (GTK_CONTAINER (priv->back_button), back_image);
+ back_pixmap = create_pixmap_widget_from_xpm (left_arrow_xpm);
+ gtk_container_add (GTK_CONTAINER (priv->back_button), back_pixmap);
- g_signal_connect (priv->back_button, "clicked",
- G_CALLBACK (back_button_clicked_callback), folder_title_bar);
+ gtk_signal_connect (GTK_OBJECT (priv->back_button), "clicked",
+ GTK_SIGNAL_FUNC (back_button_clicked_callback), folder_title_bar);
priv->forward_button = gtk_button_new ();
gtk_button_set_relief (GTK_BUTTON (priv->forward_button), GTK_RELIEF_NONE);
GTK_WIDGET_UNSET_FLAGS (priv->forward_button, GTK_CAN_FOCUS);
- forward_image = gtk_arrow_new (GTK_ARROW_RIGHT, GTK_SHADOW_NONE);
- gtk_container_add (GTK_CONTAINER (priv->forward_button), forward_image);
+ forward_pixmap = create_pixmap_widget_from_xpm (right_arrow_xpm);
+ gtk_container_add (GTK_CONTAINER (priv->forward_button), forward_pixmap);
- g_signal_connect (priv->forward_button, "clicked",
- G_CALLBACK (forward_button_clicked_callback), folder_title_bar);
+ gtk_signal_connect (GTK_OBJECT (priv->forward_button), "clicked",
+ GTK_SIGNAL_FUNC (forward_button_clicked_callback), folder_title_bar);
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->back_button, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (folder_title_bar), priv->forward_button, FALSE, FALSE, 0);
@@ -302,33 +378,16 @@ title_button_toggled_cb (GtkToggleButton *title_button,
EShellFolderTitleBar *folder_title_bar;
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (data);
-
- g_signal_emit (folder_title_bar, signals[TITLE_TOGGLED], 0,
- gtk_toggle_button_get_active (title_button));
+ gtk_signal_emit (GTK_OBJECT (folder_title_bar),
+ signals[TITLE_TOGGLED],
+ gtk_toggle_button_get_active (title_button));
}
-/* GObject methods. */
-
-static void
-impl_dispose (GObject *object)
-{
- EShellFolderTitleBar *folder_title_bar;
- EShellFolderTitleBarPrivate *priv;
-
- folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (object);
- priv = folder_title_bar->priv;
-
- if (priv->icon != NULL) {
- g_object_unref (priv->icon);
- priv->icon = NULL;
- }
-
- (* G_OBJECT_CLASS (parent_class)->dispose) (object);
-}
+/* GtkObject methods. */
static void
-impl_finalize (GObject *object)
+impl_destroy (GtkObject *object)
{
EShellFolderTitleBar *folder_title_bar;
EShellFolderTitleBarPrivate *priv;
@@ -336,9 +395,11 @@ impl_finalize (GObject *object)
folder_title_bar = E_SHELL_FOLDER_TITLE_BAR (object);
priv = folder_title_bar->priv;
+ if (priv->icon != NULL)
+ gdk_pixbuf_unref (priv->icon);
g_free (priv);
- (* G_OBJECT_CLASS (parent_class)->finalize) (object);
+ (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
@@ -383,67 +444,43 @@ impl_size_allocate (GtkWidget *widget,
}
-static int
-impl_expose_event (GtkWidget *widget,
- GdkEventExpose *event)
-{
- gtk_paint_flat_box (widget->style, widget->window,
- GTK_STATE_ACTIVE, GTK_SHADOW_OUT,
- &event->area, widget, "EShellFolderTitleBar",
- widget->allocation.x,
- widget->allocation.y,
- widget->allocation.width,
- widget->allocation.height);
-
- (* GTK_WIDGET_CLASS (parent_class)->expose_event) (widget, event);
-
- return FALSE;
-}
-
-
static void
class_init (EShellFolderTitleBarClass *klass)
{
- GObjectClass *object_class;
+ GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
- object_class = G_OBJECT_CLASS (klass);
- object_class->dispose = impl_dispose;
- object_class->finalize = impl_finalize;
+ object_class = GTK_OBJECT_CLASS (klass);
+ object_class->destroy = impl_destroy;
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->size_allocate = impl_size_allocate;
- widget_class->expose_event = impl_expose_event;
-
- parent_class = g_type_class_ref(PARENT_TYPE);
-
- signals[TITLE_TOGGLED]
- = g_signal_new ("title_toggled",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShellFolderTitleBarClass, title_toggled),
- NULL, NULL,
- e_shell_marshal_NONE__BOOL,
- G_TYPE_NONE, 1,
- G_TYPE_BOOLEAN);
-
- signals[BACK_CLICKED]
- = g_signal_new ("back_clicked",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShellFolderTitleBarClass, back_clicked),
- NULL, NULL,
- e_shell_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
-
- signals[FORWARD_CLICKED]
- = g_signal_new ("forward_clicked",
- G_OBJECT_CLASS_TYPE (object_class),
- G_SIGNAL_RUN_FIRST,
- G_STRUCT_OFFSET (EShellFolderTitleBarClass, forward_clicked),
- NULL, NULL,
- e_shell_marshal_NONE__NONE,
- G_TYPE_NONE, 0);
+
+ parent_class = gtk_type_class (PARENT_TYPE);
+
+ signals[TITLE_TOGGLED] = gtk_signal_new ("title_toggled",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EShellFolderTitleBarClass, title_toggled),
+ gtk_marshal_NONE__BOOL,
+ GTK_TYPE_NONE, 1,
+ GTK_TYPE_BOOL);
+
+ signals[BACK_CLICKED] = gtk_signal_new ("back_clicked",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EShellFolderTitleBarClass, back_clicked),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ signals[FORWARD_CLICKED] = gtk_signal_new ("forward_clicked",
+ GTK_RUN_FIRST,
+ object_class->type,
+ GTK_SIGNAL_OFFSET (EShellFolderTitleBarClass, forward_clicked),
+ gtk_marshal_NONE__NONE,
+ GTK_TYPE_NONE, 0);
+
+ gtk_object_class_add_signals (object_class, signals, LAST_SIGNAL);
}
static void
@@ -493,25 +530,28 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar)
priv = folder_title_bar->priv;
widget = GTK_WIDGET (folder_title_bar);
- priv->title_icon = new_empty_image_widget ();
+ priv->title_icon = new_empty_pixmap_widget ();
gtk_misc_set_alignment (GTK_MISC (priv->title_icon), 1.0, .5);
gtk_misc_set_padding (GTK_MISC (priv->title_icon), 2, 0);
gtk_widget_show (priv->title_icon);
- priv->title_label = e_clipped_label_new ("", PANGO_WEIGHT_BOLD, 1.2);
+ priv->title_label = e_clipped_label_new ("");
gtk_misc_set_padding (GTK_MISC (priv->title_label), 0, 0);
gtk_misc_set_alignment (GTK_MISC (priv->title_label), 0.0, 0.5);
+ set_title_bar_label_style (priv->title_label);
- priv->title_button_label = e_clipped_label_new ("", PANGO_WEIGHT_BOLD, 1.2);
+ priv->title_button_label = e_clipped_label_new ("");
gtk_misc_set_padding (GTK_MISC (priv->title_button_label), 2, 0);
gtk_misc_set_alignment (GTK_MISC (priv->title_button_label), 0.0, 0.5);
gtk_widget_show (priv->title_button_label);
+ set_title_bar_label_style (priv->title_button_label);
- priv->folder_bar_label = e_clipped_label_new ("", PANGO_WEIGHT_NORMAL, 1.0);
+ priv->folder_bar_label = e_clipped_label_new ("");
gtk_misc_set_alignment (GTK_MISC (priv->folder_bar_label), 1.0, 0.5);
gtk_widget_show (priv->folder_bar_label);
+ set_title_bar_label_style (priv->folder_bar_label);
- priv->title_button_icon = new_empty_image_widget ();
+ priv->title_button_icon = new_empty_pixmap_widget ();
gtk_widget_show (priv->title_button_icon);
title_button_hbox = gtk_hbox_new (FALSE, 0);
@@ -519,7 +559,7 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar)
FALSE, TRUE, 2);
gtk_box_pack_start (GTK_BOX (title_button_hbox), priv->title_button_label,
TRUE, TRUE, 0);
- gtk_box_pack_start (GTK_BOX (title_button_hbox), gtk_arrow_new (GTK_ARROW_DOWN, GTK_SHADOW_NONE),
+ gtk_box_pack_start (GTK_BOX (title_button_hbox), create_pixmap_widget_from_xpm (down_arrow_xpm),
FALSE, TRUE, 2);
gtk_widget_show (title_button_hbox);
@@ -540,11 +580,11 @@ e_shell_folder_title_bar_construct (EShellFolderTitleBar *folder_title_bar)
as the padding is hardcoded in GtkButton too (see CHILD_SPACING in
gtkbutton.c). */
gtk_misc_set_padding (GTK_MISC (priv->title_label),
- GTK_WIDGET (priv->title_button)->style->xthickness,
- GTK_WIDGET (priv->title_button)->style->ythickness + 2);
+ GTK_WIDGET (priv->title_button)->style->klass->xthickness,
+ GTK_WIDGET (priv->title_button)->style->klass->ythickness + 2);
- g_signal_connect (priv->title_button, "toggled",
- G_CALLBACK (title_button_toggled_cb), folder_title_bar);
+ gtk_signal_connect (GTK_OBJECT (priv->title_button), "toggled",
+ GTK_SIGNAL_FUNC (title_button_toggled_cb), folder_title_bar);
add_navigation_buttons (folder_title_bar);
@@ -564,9 +604,13 @@ e_shell_folder_title_bar_new (void)
{
EShellFolderTitleBar *new;
- new = g_object_new (e_shell_folder_title_bar_get_type (), NULL);
+ gtk_widget_push_colormap (gdk_rgb_get_cmap ());
+ gtk_widget_push_visual (gdk_rgb_get_visual ());
+ new = gtk_type_new (e_shell_folder_title_bar_get_type ());
e_shell_folder_title_bar_construct (new);
+ gtk_widget_pop_visual ();
+ gtk_widget_pop_colormap ();
return GTK_WIDGET (new);
}
@@ -653,20 +697,20 @@ e_shell_folder_title_bar_set_icon (EShellFolderTitleBar *folder_title_bar,
if (icon == NULL) {
if (priv->icon != NULL)
- g_object_unref (priv->icon);
+ gdk_pixbuf_unref (priv->icon);
priv->icon = new_empty_pixbuf ();
} else {
- g_object_ref (icon);
+ gdk_pixbuf_ref (icon);
if (priv->icon != NULL)
- g_object_unref (priv->icon);
+ gdk_pixbuf_unref (priv->icon);
priv->icon = icon;
}
gdk_pixbuf_render_pixmap_and_mask (priv->icon, &pixmap, &mask, 127);
- gtk_image_set_from_pixmap (GTK_IMAGE (priv->title_button_icon), pixmap, mask);
+ gtk_pixmap_set (GTK_PIXMAP (priv->title_button_icon), pixmap, mask);
gdk_pixbuf_render_pixmap_and_mask (priv->icon, &pixmap, &mask, 127);
- gtk_image_set_from_pixmap (GTK_IMAGE (priv->title_icon), pixmap, mask);
+ gtk_pixmap_set (GTK_PIXMAP (priv->title_icon), pixmap, mask);
}