Add gtk_status_icon_get_screen and gtk_status_icon_set_screen.

2006-12-27  Tor Lillqvist  <tml@novell.com>

	* gtk/gtk.symbols: Add gtk_status_icon_get_screen and
	gtk_status_icon_set_screen.

	* gtk/gtkstatusicon.c: Implement gtk_status_icon_position_menu()
	on Windows. Keep track of where the last button click on the
	taskbar icon took place, and return that. Obviously not correct if
	no button has ever been clicked on the icon, or if the geometry of
	the taskbar has changed since. But for most use cases where a menu
	is going to be displayed as a direct result of a button click on
	the status icon, works fine. (#377349)

	Implement getting the orientation property on Windows.

	(gtk_status_icon_embedded_changed)
	(gtk_status_icon_orientation_changed): Ifdefify these functions
	that are used only on X11.
This commit is contained in:
Tor Lillqvist 2006-12-27 18:20:10 +00:00 committed by Tor Lillqvist
parent 6d9dac29d0
commit cc89cf541f
3 changed files with 59 additions and 13 deletions

View File

@ -1,3 +1,22 @@
2006-12-27 Tor Lillqvist <tml@novell.com>
* gtk/gtk.symbols: Add gtk_status_icon_get_screen and
gtk_status_icon_set_screen.
* gtk/gtkstatusicon.c: Implement gtk_status_icon_position_menu()
on Windows. Keep track of where the last button click on the
taskbar icon took place, and return that. Obviously not correct if
no button has ever been clicked on the icon, or if the geometry of
the taskbar has changed since. But for most use cases where a menu
is going to be displayed as a direct result of a button click on
the status icon, works fine. (#377349)
Implement getting the orientation property on Windows.
(gtk_status_icon_embedded_changed)
(gtk_status_icon_orientation_changed): Ifdefify these functions
that are used only on X11.
2006-12-27 Tor Lillqvist <tml@novell.com>
* gtk/gtkfilesystemwin32.c (execute_callbacks): Fix

View File

@ -1062,9 +1062,11 @@ gtk_status_icon_set_from_stock
gtk_status_icon_set_from_icon_name
gtk_status_icon_get_storage_type
gtk_status_icon_get_pixbuf
gtk_status_icon_get_screen
gtk_status_icon_get_stock
gtk_status_icon_get_icon_name
gtk_status_icon_get_size
gtk_status_icon_set_screen
gtk_status_icon_set_tooltip
gtk_status_icon_set_visible
gtk_status_icon_get_visible

View File

@ -99,6 +99,8 @@ struct _GtkStatusIconPrivate
#ifdef GDK_WINDOWING_WIN32
GtkWidget *dummy_widget;
NOTIFYICONDATAW nid;
gint last_click_x, last_click_y;
GtkOrientation orientation;
#endif
#ifdef GDK_WINDOWING_QUARTZ
@ -354,9 +356,10 @@ gtk_status_icon_class_init (GtkStatusIconClass *class)
#ifdef GDK_WINDOWING_WIN32
static void
build_button_event (GdkEventButton *e,
GdkEventType type,
guint button)
build_button_event (GtkStatusIconPrivate *priv,
GdkEventButton *e,
GdkEventType type,
guint button)
{
POINT pos;
GdkRectangle monitor0;
@ -368,8 +371,8 @@ build_button_event (GdkEventButton *e,
e->send_event = TRUE;
e->time = GetTickCount ();
GetCursorPos (&pos);
e->x = pos.x + monitor0.x;
e->y = pos.y + monitor0.y;
priv->last_click_x = e->x = pos.x + monitor0.x;
priv->last_click_y = e->y = pos.y + monitor0.y;
e->axes = NULL;
e->state = 0;
e->button = button;
@ -393,7 +396,7 @@ wndproc (HWND hwnd,
{
case WM_LBUTTONDOWN:
case WM_RBUTTONDOWN:
build_button_event (&e, GDK_BUTTON_PRESS,
build_button_event (status_icon->priv, &e, GDK_BUTTON_PRESS,
(lparam == WM_LBUTTONDOWN) ? 1 : 3);
gtk_status_icon_button_press (status_icon, &e);
break;
@ -488,21 +491,19 @@ gtk_status_icon_init (GtkStatusIcon *status_icon)
#ifdef GDK_WINDOWING_WIN32
/* Code to get position and orientation of Windows taskbar. Not needed
* currently, kept for reference.
*/
#if 0
/* Get position and orientation of Windows taskbar. */
{
APPBARDATA abd;
abd.cbSize = sizeof (abd);
SHAppBarMessage (ABM_GETTASKBARPOS, &abd);
if (abd.rc.bottom - abd.rc.top > abd.rc.right - abd.rc.left)
orientation = GTK_ORIENTATION_VERTICAL;
priv->orientation = GTK_ORIENTATION_VERTICAL;
else
orientation = GTK_ORIENTATION_HORIZONTAL;
priv->orientation = GTK_ORIENTATION_HORIZONTAL;
}
#endif
priv->last_click_x = priv->last_click_y = 0;
/* Are the system tray icons always 16 pixels square? */
priv->size = 16;
@ -669,7 +670,12 @@ gtk_status_icon_get_property (GObject *object,
g_value_set_boolean (value, gtk_status_icon_is_embedded (status_icon));
break;
case PROP_ORIENTATION:
#ifdef GDK_WINDOWING_X11
g_value_set_enum (value, _gtk_tray_icon_get_orientation (status_icon->priv->tray_icon));
#endif
#ifdef GDK_WINDOWING_WIN32
g_value_set_enum (value, status_icon->priv->orientation);
#endif
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@ -1124,6 +1130,8 @@ gtk_status_icon_screen_changed (GtkStatusIcon *status_icon,
#endif
#ifdef GDK_WINDOWING_X11
static void
gtk_status_icon_embedded_changed (GtkStatusIcon *status_icon)
{
@ -1136,6 +1144,8 @@ gtk_status_icon_orientation_changed (GtkStatusIcon *status_icon)
g_object_notify (G_OBJECT (status_icon), "orientation");
}
#endif
static gboolean
gtk_status_icon_button_press (GtkStatusIcon *status_icon,
GdkEventButton *event)
@ -1864,6 +1874,21 @@ gtk_status_icon_position_menu (GtkMenu *menu,
*push_in = FALSE;
#endif /* GDK_WINDOWING_X11 */
#ifdef GDK_WINDOWING_WIN32
GtkStatusIcon *status_icon;
GtkStatusIconPrivate *priv;
g_return_if_fail (GTK_IS_MENU (menu));
g_return_if_fail (GTK_IS_STATUS_ICON (user_data));
status_icon = GTK_STATUS_ICON (user_data);
priv = status_icon->priv;
*x = priv->last_click_x;
*y = priv->last_click_y;
*push_in = TRUE;
#endif
}
/**