summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Spilsbury <sam.spilsbury@canonical.com>2010-12-10 17:24:12 +0800
committerSam Spilsbury <sam.spilsbury@canonical.com>2010-12-10 17:24:12 +0800
commit45aa3b440a295102021d1efb52bafe1cdbd1fff4 (patch)
treefe241089a8fb7ea94e27991c03f5a66db98ce24a /src
parent05150cae0e2889a75e899719fcac8f34add16190 (diff)
downloadunity-window-decorator-45aa3b440a295102021d1efb52bafe1cdbd1fff4.tar.gz
unity-window-decorator-45aa3b440a295102021d1efb52bafe1cdbd1fff4.tar.bz2
Bye-Bye tooltips. It was good to have you on board but design says you are useless
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/events.c33
-rw-r--r--src/gtk-window-decorator.c11
-rw-r--r--src/gtk-window-decorator.h20
-rw-r--r--src/tooltip.c184
5 files changed, 16 insertions, 233 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9dca40f..c833e4c 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -119,7 +119,6 @@ if (BUILD_UNITY)
metacity.c
events.c
forcequit.c
- tooltip.c
actionmenu.c
settings.c
util.c
diff --git a/src/events.c b/src/events.c
index 6c3af32..0b2099b 100644
--- a/src/events.c
+++ b/src/events.c
@@ -1,4 +1,4 @@
-#include "gtk-window-decorator.h"
+#include "gtk-window-decorator.h"
void
move_resize_window (WnckWindow *win,
@@ -55,14 +55,11 @@ common_button_event (WnckWindow *win,
decor_event *gtkwd_event,
decor_event_type gtkwd_type,
int button,
- int max,
- char *tooltip)
+ int max)
{
decor_t *d = g_object_get_data (G_OBJECT (win), "decor");
guint state = d->button_states[button];
- handle_tooltip_event (win, gtkwd_event, gtkwd_type, state, tooltip);
-
if (d->frame_window && gtkwd_type == GEnterNotify)
{
GdkCursor* cursor;
@@ -105,7 +102,7 @@ close_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_CLOSE];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_CLOSE, 1, _("Close Window"));
+ BUTTON_CLOSE, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -128,10 +125,10 @@ max_button_event (WnckWindow *win,
if (wnck_window_is_maximized (win))
common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX,
- 3, _("Unmaximize Window"));
+ 3);
else
common_button_event (win, gtkwd_event, gtkwd_type, BUTTON_MAX,
- 3, _("Maximize Window"));
+ 3);
switch (gtkwd_type) {
case GButtonRelease:
@@ -177,7 +174,7 @@ min_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_MIN];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_MIN, 1, _("Minimize Window"));
+ BUTTON_MIN, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -197,7 +194,7 @@ menu_button_event (WnckWindow *win,
{
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_MENU, 1, _("Window Menu"));
+ BUTTON_MENU, 1);
switch (gtkwd_type) {
case GButtonPress:
@@ -220,7 +217,7 @@ shade_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_SHADE];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_SHADE, 1, _("Shade"));
+ BUTTON_SHADE, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -244,7 +241,7 @@ above_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_ABOVE];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_ABOVE, 1, _("Make Above"));
+ BUTTON_ABOVE, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -268,7 +265,7 @@ stick_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_STICK];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_STICK, 1, _("Stick"));
+ BUTTON_STICK, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -290,7 +287,7 @@ unshade_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_UNSHADE];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_UNSHADE, 1, _("Unshade"));
+ BUTTON_UNSHADE, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -312,7 +309,7 @@ unabove_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_UNABOVE];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_UNABOVE, 1, _("Unmake Above"));
+ BUTTON_UNABOVE, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -336,7 +333,7 @@ unstick_button_event (WnckWindow *win,
guint state = d->button_states[BUTTON_UNSTICK];
common_button_event (win, gtkwd_event, gtkwd_type,
- BUTTON_UNSTICK, 1, _("Unstick"));
+ BUTTON_UNSTICK, 1);
switch (gtkwd_type) {
case GButtonRelease:
@@ -928,9 +925,9 @@ event_filter_func (GdkXEvent *gdkxevent,
GdkScreen *g_screen = gdk_display_get_default_screen (gdkdisplay);
Window root = GDK_WINDOW_XWINDOW (gdk_screen_get_root_window (g_screen));
WnckScreen *screen;
-
+
screen = wnck_screen_get_for_root (root);
-
+
if (screen)
{
shadow_property_changed (screen);
diff --git a/src/gtk-window-decorator.c b/src/gtk-window-decorator.c
index 85963d9..53a1293 100644
--- a/src/gtk-window-decorator.c
+++ b/src/gtk-window-decorator.c
@@ -167,11 +167,6 @@ decor_color_t _title_color[2];
PangoContext *pango_context;
gint double_click_timeout = 250;
-GtkWidget *tip_window;
-GtkWidget *tip_label;
-GTimeVal tooltip_last_popdown = { 0, 0 };
-gint tooltip_timer_tag = 0;
-
GSList *draw_list = NULL;
guint draw_idle_id = 0;
@@ -385,12 +380,6 @@ main (int argc, char *argv[])
frame_table = g_hash_table_new (NULL, NULL);
- if (!create_tooltip_window ())
- {
- fprintf (stderr, "%s, Couldn't create tooltip window\n", argv[0]);
- return 1;
- }
-
screen = wnck_screen_get_default ();
wnck_set_client_type (WNCK_CLIENT_TYPE_PAGER);
diff --git a/src/gtk-window-decorator.h b/src/gtk-window-decorator.h
index 47f94f6..a34f5a2 100644
--- a/src/gtk-window-decorator.h
+++ b/src/gtk-window-decorator.h
@@ -443,11 +443,6 @@ extern decor_color_t _title_color[2];
extern PangoContext *pango_context;
extern gint double_click_timeout;
-extern GtkWidget *tip_window;
-extern GtkWidget *tip_label;
-extern GTimeVal tooltip_last_popdown;
-extern gint tooltip_timer_tag;
-
extern GSList *draw_list;
extern guint draw_idle_id;
@@ -770,8 +765,7 @@ common_button_event (WnckWindow *win,
decor_event *gtkwd_event,
decor_event_type gtkwd_type,
int button,
- int max,
- char *tooltip);
+ int max);
void
close_button_event (WnckWindow *win,
@@ -920,18 +914,6 @@ event_filter_func (GdkXEvent *gdkxevent,
GdkEvent *event,
gpointer data);
-/* tooltip.c */
-
-gboolean
-create_tooltip_window (void);
-
-void
-handle_tooltip_event (WnckWindow *win,
- decor_event *gtkwd_event,
- decor_event_type gtkwd_type,
- guint state,
- const char *tip);
-
/* forcequit.c */
void
diff --git a/src/tooltip.c b/src/tooltip.c
deleted file mode 100644
index 20c9aef..0000000
--- a/src/tooltip.c
+++ /dev/null
@@ -1,184 +0,0 @@
-#include "gtk-window-decorator.h"
-
-/* stolen from gtktooltip.c */
-
-#define DEFAULT_DELAY 500 /* Default delay in ms */
-#define STICKY_DELAY 0 /* Delay before popping up next tip
- * if we're sticky
- */
-#define STICKY_REVERT_DELAY 1000 /* Delay before sticky tooltips revert
- * to normal
- */
-
-static void
-show_tooltip (const char *text)
-{
- GdkDisplay *gdkdisplay;
- GtkRequisition requisition;
- gint x, y, w, h;
- GdkScreen *screen;
- gint monitor_num;
- GdkRectangle monitor;
-
- gdkdisplay = gdk_display_get_default ();
-
- gtk_label_set_text (GTK_LABEL (tip_label), text);
-
- gtk_widget_size_request (tip_window, &requisition);
-
- w = requisition.width;
- h = requisition.height;
-
- gdk_display_get_pointer (gdkdisplay, &screen, &x, &y, NULL);
-
- x -= (w / 2 + 4);
-
- monitor_num = gdk_screen_get_monitor_at_point (screen, x, y);
- gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor);
-
- if ((x + w) > monitor.x + monitor.width)
- x -= (x + w) - (monitor.x + monitor.width);
- else if (x < monitor.x)
- x = monitor.x;
-
- if ((y + h + 16) > monitor.y + monitor.height)
- y = y - h - 16;
- else
- y = y + 16;
-
- gtk_window_move (GTK_WINDOW (tip_window), x, y);
- gtk_widget_show (tip_window);
-}
-
-static void
-hide_tooltip (void)
-{
- if (gtk_widget_get_visible (tip_window))
- g_get_current_time (&tooltip_last_popdown);
-
- gtk_widget_hide (tip_window);
-
- if (tooltip_timer_tag)
- {
- g_source_remove (tooltip_timer_tag);
- tooltip_timer_tag = 0;
- }
-}
-
-static gboolean
-tooltip_recently_shown (void)
-{
- GTimeVal now;
- glong msec;
-
- g_get_current_time (&now);
-
- msec = now.tv_sec - tooltip_last_popdown.tv_sec;
- if (msec > STICKY_REVERT_DELAY / 1000)
- return FALSE;
-
- msec = msec * 1000 + (now.tv_usec - tooltip_last_popdown.tv_usec) / 1000;
-
- return (msec < STICKY_REVERT_DELAY);
-}
-
-static gint
-tooltip_timeout (gpointer data)
-{
- tooltip_timer_tag = 0;
-
- show_tooltip ((const char *) data);
-
- return FALSE;
-}
-
-static void
-tooltip_start_delay (const char *text)
-{
- guint delay = DEFAULT_DELAY;
-
- if (tooltip_timer_tag)
- return;
-
- if (tooltip_recently_shown ())
- delay = STICKY_DELAY;
-
- tooltip_timer_tag = g_timeout_add (delay,
- tooltip_timeout,
- (gpointer) text);
-}
-
-static gint
-tooltip_paint_window (GtkWidget *tooltip)
-{
- GtkRequisition req;
-
- gtk_widget_size_request (tip_window, &req);
- gtk_paint_flat_box (tip_window->style, tip_window->window,
- GTK_STATE_NORMAL, GTK_SHADOW_OUT,
- NULL, GTK_WIDGET (tip_window), "tooltip",
- 0, 0, req.width, req.height);
-
- return FALSE;
-}
-
-gboolean
-create_tooltip_window (void)
-{
- tip_window = gtk_window_new (GTK_WINDOW_POPUP);
-
- gtk_widget_set_app_paintable (tip_window, TRUE);
- gtk_window_set_resizable (GTK_WINDOW (tip_window), FALSE);
- gtk_widget_set_name (tip_window, "gtk-tooltips");
- gtk_container_set_border_width (GTK_CONTAINER (tip_window), 4);
-
-#if GTK_CHECK_VERSION (2, 10, 0)
- if (!gtk_check_version (2, 10, 0))
- gtk_window_set_type_hint (GTK_WINDOW (tip_window),
- GDK_WINDOW_TYPE_HINT_TOOLTIP);
-#endif
-
- g_signal_connect_swapped (tip_window,
- "expose_event",
- G_CALLBACK (tooltip_paint_window),
- 0);
-
- tip_label = gtk_label_new (NULL);
- gtk_label_set_line_wrap (GTK_LABEL (tip_label), TRUE);
- gtk_misc_set_alignment (GTK_MISC (tip_label), 0.5, 0.5);
- gtk_widget_show (tip_label);
-
- gtk_container_add (GTK_CONTAINER (tip_window), tip_label);
-
- gtk_widget_ensure_style (tip_window);
-
- return TRUE;
-}
-
-void
-handle_tooltip_event (WnckWindow *win,
- decor_event *gtkwd_event,
- decor_event_type gtkwd_type,
- guint state,
- const char *tip)
-{
- switch (gtkwd_type) {
- case GButtonPress:
- hide_tooltip ();
- break;
- case GButtonRelease:
- break;
- case GEnterNotify:
- if (!(state & PRESSED_EVENT_WINDOW))
- {
- if (wnck_window_is_active (win))
- tooltip_start_delay (tip);
- }
- break;
- case GLeaveNotify:
- hide_tooltip ();
- break;
- default:
- break;
- }
-}