summaryrefslogtreecommitdiff
path: root/src/gtksnippet.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gtksnippet.c')
-rw-r--r--src/gtksnippet.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gtksnippet.c b/src/gtksnippet.c
index 177c086..15696dc 100644
--- a/src/gtksnippet.c
+++ b/src/gtksnippet.c
@@ -150,8 +150,9 @@ gtk_snippet_size_allocate(GtkWidget *widget,
static void
gtk_snippet_realize(GtkWidget *widget)
{
- GdkWindowAttr attributes;
- guint attributes_mask;
+ GdkWindowAttr attributes;
+ guint attributes_mask;
+ GdkColor white; /* Couleur de fond normale */
g_return_if_fail(widget != NULL);
g_return_if_fail(GTK_IS_SNIPPET(widget));
@@ -164,8 +165,6 @@ gtk_snippet_realize(GtkWidget *widget)
attributes.width = widget->allocation.width;
attributes.height = widget->allocation.height;
- printf("(%d x %d)\n", widget->allocation.width, widget->allocation.height);
-
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
@@ -178,8 +177,11 @@ gtk_snippet_realize(GtkWidget *widget)
gdk_window_set_user_data(widget->window, widget);
- widget->style = gtk_style_attach(widget->style, widget->window);
- gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
+ widget->style = gtk_style_attach(widget->style, widget->window);
+
+
+ gdk_color_white(gtk_widget_get_colormap(widget), &white);
+ gtk_widget_modify_bg(widget, GTK_STATE_NORMAL, &white);
GTK_SNIPPET(widget)->layout = gtk_widget_create_pango_layout(widget, NULL);
@@ -207,6 +209,7 @@ gtk_snippet_expose(GtkWidget *widget,
static void
gtk_snippet_paint(GtkWidget *widget)
{
+ /*
cairo_t *cr;
cr = gdk_cairo_create(widget->window);
@@ -236,9 +239,9 @@ gtk_snippet_paint(GtkWidget *widget)
cairo_destroy(cr);
printf("rendering...\n");
-
+ */
gdk_draw_layout(GDK_DRAWABLE(widget->window), GTK_SNIPPET(widget)->gc,
- 10, 100, GTK_SNIPPET(widget)->layout);
+ 0, 0, GTK_SNIPPET(widget)->layout);
}
@@ -357,6 +360,8 @@ void gtk_snippet_build_content(GtkSnippet *snippet)
AdressMode mode; /* Affichage des adresses */
unsigned int i; /* Boucle de traitement */
char buffer[CONTENT_BUFFER_LEN]; /* Zone tampon à utiliser */
+ int width; /* Largeur de l'objet actuelle */
+ int height; /* Hauteur de l'objet actuelle */
content_len = strlen("<tt>") + 1;
content = (char *)calloc(content_len, sizeof(char));
@@ -429,6 +434,9 @@ void gtk_snippet_build_content(GtkSnippet *snippet)
pango_layout_set_markup(snippet->layout, content, content_len - 1);
+ pango_layout_get_pixel_size(snippet->layout, &width, &height);
+ gtk_widget_set_size_request(GTK_WIDGET(snippet), width, height);
+
}