|
From: <pa...@us...> - 2008-08-04 01:17:16
|
Revision: 544
http://osmo-pim.svn.sourceforge.net/osmo-pim/?rev=544&view=rev
Author: pasp
Date: 2008-08-04 01:17:25 +0000 (Mon, 04 Aug 2008)
Log Message:
-----------
* Small modification
Modified Paths:
--------------
trunk/src/gui_utils.c
trunk/src/gui_utils.h
trunk/src/notes.c
Modified: trunk/src/gui_utils.c
===================================================================
--- trunk/src/gui_utils.c 2008-08-04 00:56:07 UTC (rev 543)
+++ trunk/src/gui_utils.c 2008-08-04 01:17:25 UTC (rev 544)
@@ -746,30 +746,4 @@
}
/*------------------------------------------------------------------------------*/
-/* routine by Allin Cottrell */
-gint
-gui_get_char_width (PangoFontDescription *pfd, const gchar *s) {
-
-GtkWidget *w;
-PangoContext *pc;
-PangoLayout *pl;
-gint width;
-
- w = gtk_label_new(NULL);
- pc = gtk_widget_get_pango_context(w);
- pango_context_set_font_description(pc, pfd);
-
- pl = pango_layout_new(pc);
- pango_layout_set_text(pl, s, 1);
- pango_layout_get_pixel_size(pl, &width, NULL);
-
- g_object_unref(G_OBJECT(pl));
- g_object_unref(G_OBJECT(pc));
- gtk_widget_destroy(w);
-
- return width;
-}
-
-/*------------------------------------------------------------------------------*/
-
Modified: trunk/src/gui_utils.h
===================================================================
--- trunk/src/gui_utils.h 2008-08-04 00:56:07 UTC (rev 543)
+++ trunk/src/gui_utils.h 2008-08-04 01:17:25 UTC (rev 544)
@@ -38,8 +38,6 @@
gchar* gui_text_buffer_get_text_with_tags (GtkTextBuffer *buffer);
void gui_text_buffer_set_text_with_tags (GtkTextBuffer *buffer, const gchar *text);
-gint gui_get_char_width (PangoFontDescription *pfd, const gchar *s);
-
void gui_change_bg_widget_state (GtkWidget *widget, gchar *color_str, GUI *appGUI);
GdkPixbuf* gui_create_color_swatch (gchar *color);
Modified: trunk/src/notes.c
===================================================================
--- trunk/src/notes.c 2008-08-04 00:56:07 UTC (rev 543)
+++ trunk/src/notes.c 2008-08-04 01:17:25 UTC (rev 544)
@@ -338,17 +338,28 @@
gint chars, i;
gchar tmpbuf[BUFFER_SIZE];
+GtkWidget *label;
+PangoLayout *layout;
+PangoRectangle logical_rect;
GUI *appGUI = (GUI *)data;
+ label = gtk_label_new(NULL);
+ layout = gtk_widget_create_pango_layout (widget, NULL);
tmpbuf[0] = config.text_separator;
tmpbuf[1] = 0;
- chars = (appGUI->nte->editor_textview)->allocation.width / gui_get_char_width (appGUI->nte->fd_notes_font, tmpbuf);
+ pango_layout_set_text (layout, tmpbuf, -1);
+ pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
+ chars = (appGUI->nte->editor_textview)->allocation.width / logical_rect.width;
+
if (chars > BUFFER_SIZE) {
chars = BUFFER_SIZE - 2; /* \n + null */
}
+ g_object_unref (G_OBJECT(layout));
+ gtk_widget_destroy (label);
+
i = 0;
tmpbuf[i++] = '\n';
while (i < chars) tmpbuf[i++] = config.text_separator;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|