2001-06-03 03:41:36 -04:00
|
|
|
/* 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.
|
|
|
|
*/
|
|
|
|
|
2002-06-10 06:47:56 -04:00
|
|
|
#include <config.h>
|
2001-06-03 03:41:36 -04:00
|
|
|
#include "fixedtip.h"
|
|
|
|
|
|
|
|
static GtkWidget *tip = NULL;
|
|
|
|
static GtkWidget *label = NULL;
|
2002-05-11 01:09:54 -04:00
|
|
|
static int screen_width = 0;
|
|
|
|
static int screen_height = 0;
|
2001-06-03 03:41:36 -04:00
|
|
|
|
|
|
|
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
|
2002-05-08 12:24:28 -04:00
|
|
|
meta_fixed_tip_show (Display *xdisplay, int screen_number,
|
2001-06-30 19:17:52 -04:00
|
|
|
int root_x, int root_y,
|
2001-06-03 03:41:36 -04:00
|
|
|
const char *markup_text)
|
|
|
|
{
|
2002-05-11 01:09:54 -04:00
|
|
|
int w, h;
|
|
|
|
|
2001-06-03 03:41:36 -04:00
|
|
|
if (tip == NULL)
|
2002-05-11 01:09:54 -04:00
|
|
|
{
|
2001-06-03 03:41:36 -04:00
|
|
|
tip = gtk_window_new (GTK_WINDOW_POPUP);
|
2002-05-11 01:09:54 -04:00
|
|
|
{
|
|
|
|
GdkScreen *gdk_screen;
|
|
|
|
|
2002-06-25 03:08:18 -04:00
|
|
|
gdk_screen = gdk_display_get_screen (gdk_display_get_default (),
|
2002-05-11 01:09:54 -04:00
|
|
|
screen_number);
|
|
|
|
gtk_window_set_screen (GTK_WINDOW (tip),
|
|
|
|
gdk_screen);
|
|
|
|
screen_width = gdk_screen_get_width (gdk_screen);
|
|
|
|
screen_height = gdk_screen_get_height (gdk_screen);
|
|
|
|
}
|
|
|
|
|
2001-06-03 03:41:36 -04:00
|
|
|
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);
|
|
|
|
|
A load of fixes of issues reported by sparse. Closes bug #152849
2004-09-17 Kjartan Maraas <kmaraas@gnome.org>
* src/bell.c: (meta_bell_flash_screen):
* src/compositor.c:
* src/effects.c: (meta_effects_draw_box_animation):
* src/fixedtip.c: (meta_fixed_tip_show):
* src/frame.c: (find_argb_visual):
* src/frames.c: (unsigned_long_hash), (meta_frames_manage_window),
(meta_frames_apply_shapes):
* src/iconcache.c: (find_largest_sizes), (find_best_size):
* src/keybindings.c: (meta_spawn_command_line_async_on_screen):
* src/main.c: (main):
* src/menu.c: (meta_window_menu_new):
* src/prefs.c: (meta_prefs_get_visual_bell),
(meta_prefs_bell_is_audible), (meta_prefs_get_visual_bell_type),
(meta_prefs_get_action_double_click_titlebar),
(meta_prefs_get_auto_raise), (meta_prefs_get_auto_raise_delay),
(meta_prefs_get_reduced_resources):
* src/screen.c: (meta_create_offscreen_window):
* src/tabpopup.c: (meta_ui_tab_popup_get_selected):
* src/theme-parser.c: (meta_theme_load):
* src/theme.c: (meta_gtk_widget_get_font_desc):
* src/tools/metacity-mag.c: (mouse_press), (begin_area_grab):
* src/util.c: (meta_unsigned_long_hash): A load of fixes of issues
reported by sparse. Closes bug #152849
2004-09-16 19:18:22 -04:00
|
|
|
g_signal_connect_swapped (tip, "expose_event",
|
|
|
|
G_CALLBACK (expose_handler), NULL);
|
2001-06-03 03:41:36 -04:00
|
|
|
|
|
|
|
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);
|
|
|
|
|
A load of fixes of issues reported by sparse. Closes bug #152849
2004-09-17 Kjartan Maraas <kmaraas@gnome.org>
* src/bell.c: (meta_bell_flash_screen):
* src/compositor.c:
* src/effects.c: (meta_effects_draw_box_animation):
* src/fixedtip.c: (meta_fixed_tip_show):
* src/frame.c: (find_argb_visual):
* src/frames.c: (unsigned_long_hash), (meta_frames_manage_window),
(meta_frames_apply_shapes):
* src/iconcache.c: (find_largest_sizes), (find_best_size):
* src/keybindings.c: (meta_spawn_command_line_async_on_screen):
* src/main.c: (main):
* src/menu.c: (meta_window_menu_new):
* src/prefs.c: (meta_prefs_get_visual_bell),
(meta_prefs_bell_is_audible), (meta_prefs_get_visual_bell_type),
(meta_prefs_get_action_double_click_titlebar),
(meta_prefs_get_auto_raise), (meta_prefs_get_auto_raise_delay),
(meta_prefs_get_reduced_resources):
* src/screen.c: (meta_create_offscreen_window):
* src/tabpopup.c: (meta_ui_tab_popup_get_selected):
* src/theme-parser.c: (meta_theme_load):
* src/theme.c: (meta_gtk_widget_get_font_desc):
* src/tools/metacity-mag.c: (mouse_press), (begin_area_grab):
* src/util.c: (meta_unsigned_long_hash): A load of fixes of issues
reported by sparse. Closes bug #152849
2004-09-16 19:18:22 -04:00
|
|
|
g_signal_connect (tip, "destroy",
|
|
|
|
G_CALLBACK (gtk_widget_destroyed), &tip);
|
2001-06-03 03:41:36 -04:00
|
|
|
}
|
2002-05-11 01:09:54 -04:00
|
|
|
|
2001-06-03 03:41:36 -04:00
|
|
|
gtk_label_set_markup (GTK_LABEL (label), markup_text);
|
2002-05-11 01:09:54 -04:00
|
|
|
|
|
|
|
/* FIXME should also handle Xinerama here, just to be
|
|
|
|
* really cool
|
|
|
|
*/
|
|
|
|
gtk_window_get_size (GTK_WINDOW (tip), &w, &h);
|
|
|
|
if ((root_x + w) > screen_width)
|
|
|
|
root_x -= (root_x + w) - screen_width;
|
|
|
|
|
|
|
|
gtk_window_move (GTK_WINDOW (tip), root_x, root_y);
|
2001-06-03 03:41:36 -04:00
|
|
|
|
|
|
|
gtk_widget_show (tip);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
meta_fixed_tip_hide (void)
|
|
|
|
{
|
2001-06-30 19:17:52 -04:00
|
|
|
if (tip)
|
|
|
|
{
|
|
|
|
gtk_widget_destroy (tip);
|
|
|
|
tip = NULL;
|
|
|
|
}
|
2001-06-03 03:41:36 -04:00
|
|
|
}
|