summaryrefslogtreecommitdiff
path: root/app/wlib/gtklib/tooltip.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-19 19:55:58 +0100
commitd1a8285f818eb7e5c3d6a05709ea21a808490b8c (patch)
tree326578f0505cbed07cfe60de530022822dc237ac /app/wlib/gtklib/tooltip.c
parent16e9630b79f0a7a90c6cedb6781175bb8b337dc1 (diff)
New upstream version 5.1.0upstream/5.1.0
Diffstat (limited to 'app/wlib/gtklib/tooltip.c')
-rw-r--r--app/wlib/gtklib/tooltip.c31
1 files changed, 17 insertions, 14 deletions
diff --git a/app/wlib/gtklib/tooltip.c b/app/wlib/gtklib/tooltip.c
index 15b46d2..20a1ba9 100644
--- a/app/wlib/gtklib/tooltip.c
+++ b/app/wlib/gtklib/tooltip.c
@@ -45,7 +45,7 @@ static int enableBalloonHelp = TRUE;
static GtkWidget * balloonF; /**< balloon help control for hotbar item */
static GtkWidget * balloonPI;
-static const char * balloonMsg = NULL;
+static char balloonMsg[100] = "";
static wControl_p balloonB;
static wPos_t balloonDx, balloonDy;
static wBool_t balloonVisible = FALSE;
@@ -136,54 +136,56 @@ void wControlSetBalloon( wControl_p b, wPos_t dx, wPos_t dy, const char * msg )
wPos_t w, h;
wPos_t xx, yy;
const char * msgConverted;
- GtkAllocation size;
+ GtkRequisition size;
/* return if there is nothing to do */
if (balloonVisible && balloonB == b &&
- balloonDx == dx && balloonDy == dy && msg != NULL && balloonMsg != NULL)
+ balloonDx == dx && balloonDy == dy && msg != NULL && !balloonMsg[0])
if (strcmp(msg,balloonMsg)==0)
return;
/* hide the tooltip */
if ( msg == NULL ) {
- if ( balloonF != NULL ) {
+ if ( balloonF != NULL && balloonVisible) {
gtk_widget_hide( balloonF );
balloonVisible = FALSE;
}
- balloonMsg = "";
+ balloonMsg[0] = '\0';
return;
}
msgConverted = wlibConvertInput(msg);
if ( balloonF == NULL ) {
- GtkWidget *alignment;
+ //GtkWidget *alignment;
- balloonF = gtk_window_new( GTK_WINDOW_TOPLEVEL );
+ balloonF = gtk_window_new( GTK_WINDOW_POPUP );
gtk_window_set_type_hint( GTK_WINDOW( balloonF), GDK_WINDOW_TYPE_HINT_TOOLTIP );
gtk_window_set_decorated (GTK_WINDOW (balloonF), FALSE );
gtk_window_set_resizable( GTK_WINDOW (balloonF), FALSE );
+ gtk_window_set_accept_focus(GTK_WINDOW( balloonF), FALSE);
- alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
+ GtkWidget * alignment = gtk_alignment_new (0.5, 0.5, 1.0, 1.0);
gtk_alignment_set_padding( GTK_ALIGNMENT(alignment), 6, 6, 6, 6 );
-
+
gtk_container_add (GTK_CONTAINER (balloonF), alignment);
+
gtk_widget_show (alignment);
balloonPI = gtk_label_new(msgConverted);
gtk_container_add( GTK_CONTAINER(alignment), balloonPI );
- gtk_widget_show( balloonPI );
+ gtk_widget_show_all( balloonPI );
}
gtk_label_set_text( GTK_LABEL(balloonPI), msgConverted );
balloonDx = dx;
balloonDy = dy;
balloonB = b;
- balloonMsg = msg;
- gtk_widget_get_allocation(balloonPI, &size );
+ snprintf(balloonMsg, sizeof(balloonMsg), "%s", msg);
+ gtk_widget_get_requisition(balloonPI, &size );
w = size.width;
h = size.height;
- gdk_window_get_origin( gtk_widget_get_window( GTK_WIDGET(b->parent->gtkwin)), &x, &y );
+ gtk_window_get_position( GTK_WINDOW(b->parent->gtkwin), &x, &y);
x += b->realX + dx;
y += b->realY + b->h - dy;
@@ -200,7 +202,8 @@ void wControlSetBalloon( wControl_p b, wPos_t dx, wPos_t dy, const char * msg )
y = yy - h ;
}
gtk_window_move( GTK_WINDOW( balloonF ), x, y );
- gtk_widget_show( balloonF );
+ gtk_widget_show_all( balloonF );
+ gtk_widget_show( balloonPI );
balloonVisible = TRUE;
}