summaryrefslogtreecommitdiff
path: root/src/fixedtip.c
diff options
context:
space:
mode:
authorrhp <rhp>2001-06-03 07:41:36 +0000
committerrhp <rhp>2001-06-03 07:41:36 +0000
commit11fde3a11a88d8e13d6e6c99d8012c60b8ad6547 (patch)
tree808db94c6a90d94fe212729f576845a99e37dcf6 /src/fixedtip.c
parentc82a582a940e2a1cf71f53e48c27b998f4be316e (diff)
downloadmetacity-11fde3a11a88d8e13d6e6c99d8012c60b8ad6547.tar.gz
metacity-11fde3a11a88d8e13d6e6c99d8012c60b8ad6547.tar.bz2
...
Diffstat (limited to 'src/fixedtip.c')
-rw-r--r--src/fixedtip.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/src/fixedtip.c b/src/fixedtip.c
new file mode 100644
index 0000000..bb12e40
--- /dev/null
+++ b/src/fixedtip.c
@@ -0,0 +1,78 @@
+/* Metacity fixed tooltip routine */
+
+/*
+ * Copyright (C) 2001 Havoc Pennington
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include "fixedtip.h"
+
+static GtkWidget *tip = NULL;
+static GtkWidget *label = NULL;
+
+static gint
+expose_handler (GtkTooltips *tooltips)
+{
+ gtk_paint_flat_box (tip->style, tip->window,
+ GTK_STATE_NORMAL, GTK_SHADOW_OUT,
+ NULL, tip, "tooltip",
+ 0, 0, -1, -1);
+
+ return FALSE;
+}
+
+void
+meta_fixed_tip_show (int root_x, int root_y,
+ const char *markup_text)
+{
+ if (tip == NULL)
+ {
+ tip = gtk_window_new (GTK_WINDOW_POPUP);
+ gtk_widget_set_app_paintable (tip, TRUE);
+ gtk_window_set_policy (GTK_WINDOW (tip), FALSE, FALSE, TRUE);
+ gtk_widget_set_name (tip, "gtk-tooltips");
+ gtk_container_set_border_width (GTK_CONTAINER (tip), 4);
+
+ gtk_signal_connect_object (GTK_OBJECT (tip),
+ "expose_event",
+ GTK_SIGNAL_FUNC (expose_handler),
+ NULL);
+
+ label = gtk_label_new (NULL);
+ gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+ gtk_misc_set_alignment (GTK_MISC (label), 0.5, 0.5);
+ gtk_widget_show (label);
+
+ gtk_container_add (GTK_CONTAINER (tip), label);
+
+ gtk_signal_connect (GTK_OBJECT (tip),
+ "destroy",
+ GTK_SIGNAL_FUNC (gtk_widget_destroyed),
+ &tip);
+ }
+
+ gtk_widget_set_uposition (tip, root_x, root_y);
+ gtk_label_set_markup (GTK_LABEL (label), markup_text);
+
+ gtk_widget_show (tip);
+}
+
+void
+meta_fixed_tip_hide (void)
+{
+ gtk_widget_destroy (tip);
+}