[prev in list] [next in list] [prev in thread] [next in thread]
List: sylpheed
Subject: [sylpheed:23868] Move the GTK Sh Ruler to GTK2
From: Alfons Hoogervorst <alfons () proteus ! demon ! nl>
Date: 2005-01-20 12:08:01
Message-ID: 20050120130801.58060926.alfons () proteus ! demon ! nl
[Download RAW message or body]
Lo Hiro,
This patch makes the GtkShRuler use pretty AA text.
Bye.
--
Ecuación algebraico sin solución posible,
a menos de poseer profundos conocimientos
en matemática - Revueltas (Ocho Por Radio)
["gtkshruler.patch" (text/plain)]
--- sylpheed-old/trunk/src/gtkshruler.c 2005-01-19 19:24:59.000000000 +0100
+++ sylpheed-new/trunk/src/gtkshruler.c 2005-01-20 13:04:14.000000000 +0100
@@ -43,10 +43,6 @@
static void gtk_shruler_class_init (GtkSHRulerClass *klass);
static void gtk_shruler_init (GtkSHRuler *hruler);
-#if 0
-static gint gtk_shruler_motion_notify (GtkWidget *widget,
- GdkEventMotion *event);
-#endif
static void gtk_shruler_draw_ticks (GtkRuler *ruler);
#if 0
static void gtk_shruler_draw_pos (GtkRuler *ruler);
@@ -73,7 +69,7 @@
(GInstanceInitFunc) gtk_shruler_init,
};
/* inherit from GtkHRuler */
- shruler_type = g_type_register_static ( GTK_TYPE_HRULER, "GtkSHRuler", &shruler_info, (GTypeFlags) 0 );
+ shruler_type = g_type_register_static (GTK_TYPE_HRULER, "GtkSHRuler", &shruler_info, (GTypeFlags)0);
}
return shruler_type;
}
@@ -118,22 +114,11 @@
return GTK_WIDGET( g_object_new( gtk_shruler_get_type(), NULL ) );
}
-#if 0
-static gint
-gtk_shruler_motion_notify(GtkWidget *widget,
- GdkEventMotion *event)
-{
- /* I could have perhaps set this to NULL */
- return FALSE;
-}
-#endif
-
static void
gtk_shruler_draw_ticks(GtkRuler *ruler)
{
GtkWidget *widget;
GdkGC *gc, *bg_gc;
- GdkFont *font;
gint i;
gint width, height;
gint xthickness;
@@ -150,7 +135,6 @@
gc = widget->style->fg_gc[GTK_STATE_NORMAL];
bg_gc = widget->style->bg_gc[GTK_STATE_NORMAL];
- font = gtk_style_get_font(widget->style);
xthickness = widget->style->xthickness;
ythickness = widget->style->ythickness;
@@ -173,24 +157,34 @@
#endif
/* assume ruler->max_size has the char width */
- /* i is increment of char_width, pos is label number */
+ /* i is increment of char_width, pos is label number
+ * y position is based on height of widget itself
+ */
for ( i = 0, pos = 0; i < widget->allocation.width - xthickness; i += ruler->max_size, pos++ ) {
- int length = ythickness / 2;
+ int length = height / 4;
- if ( pos % 10 == 0 ) length = ( 4 * ythickness );
- else if (pos % 5 == 0 ) length = ( 2 * ythickness );
+ if ( pos % 10 == 0 ) length = ( 3 * height / 4 );
+ else if (pos % 5 == 0 ) length = ( height / 2 );
gdk_draw_line(ruler->backing_store, gc,
- i, height + ythickness,
+ i, height,
i, height - length);
if ( pos % 10 == 0 ) {
- char buf[8];
+ gchar buf[8];
+ PangoLayout *layout;
+
/* draw label */
- sprintf(buf, "%d", (int) pos);
- gdk_draw_string(ruler->backing_store, font, gc,
- i + 2, ythickness + font->ascent - 1,
- buf);
+ g_snprintf(buf, sizeof buf, "%d", pos);
+
+ layout = gtk_widget_create_pango_layout
+ (GTK_WIDGET(ruler), buf);
+
+ gdk_draw_layout(ruler->backing_store, gc, i + 2,
+ (height / 12),
+ layout);
+
+ g_object_unref(layout);
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic