[Goodies-commits] r4749 - xfce4-taskmanager/trunk/src

Mike Massonnet mmassonnet at xfce.org
Fri May 9 13:01:32 CEST 2008


Author: mmassonnet
Date: 2008-05-09 11:01:32 +0000 (Fri, 09 May 2008)
New Revision: 4749

Added:
   xfce4-taskmanager/trunk/src/menu-positions.c
   xfce4-taskmanager/trunk/src/menu-positions.h
Modified:
   xfce4-taskmanager/trunk/src/Makefile.am
   xfce4-taskmanager/trunk/src/callbacks.c
Log:
Properly position the main menu


Modified: xfce4-taskmanager/trunk/src/Makefile.am
===================================================================
--- xfce4-taskmanager/trunk/src/Makefile.am	2008-05-09 11:01:28 UTC (rev 4748)
+++ xfce4-taskmanager/trunk/src/Makefile.am	2008-05-09 11:01:32 UTC (rev 4749)
@@ -12,6 +12,8 @@
 	main.c								\
 	callbacks.c							\
 	callbacks.h							\
+	menu-positions.c						\
+	menu-positions.h						\
 	functions.c							\
 	functions.h							\
 	interface.c							\

Modified: xfce4-taskmanager/trunk/src/callbacks.c
===================================================================
--- xfce4-taskmanager/trunk/src/callbacks.c	2008-05-09 11:01:28 UTC (rev 4748)
+++ xfce4-taskmanager/trunk/src/callbacks.c	2008-05-09 11:01:32 UTC (rev 4749)
@@ -19,13 +19,14 @@
  */
 
 #include "callbacks.h"
+#include "menu-positions.h"
 
 void on_button1_button_press_event(GtkButton *button, GdkEventButton *event)
 {
 	GdkEventButton *mouseevent = (GdkEventButton *)event;
 	if(mainmenu == NULL)
-		mainmenu = create_mainmenu ();
-	gtk_menu_popup(GTK_MENU(mainmenu), NULL, NULL, NULL, NULL, mouseevent->button, mouseevent->time);
+		mainmenu = create_mainmenu();
+	gtk_menu_popup(GTK_MENU(mainmenu), NULL, NULL, (GtkMenuPositionFunc)position_mainmenu, button, mouseevent->button, mouseevent->time);
 }
 
 void on_button3_toggled_event(GtkButton *button, GdkEventButton *event)

Added: xfce4-taskmanager/trunk/src/menu-positions.c
===================================================================
--- xfce4-taskmanager/trunk/src/menu-positions.c	                        (rev 0)
+++ xfce4-taskmanager/trunk/src/menu-positions.c	2008-05-09 11:01:32 UTC (rev 4749)
@@ -0,0 +1,39 @@
+/*
+ *  xfce4-taskmanager - very simple taskmanger
+ *
+ *  Copyright (c) 2008  Mike Massonnet <mmassonnet at xfce.org>
+ *
+ *  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 Library  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 "menu-positions.h"
+
+void position_mainmenu(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data)
+{
+	GtkWidget *widget;
+	GtkRequisition requisition;
+
+	widget = user_data;
+	gtk_widget_size_request(GTK_WIDGET(menu), &requisition);
+	gdk_window_get_origin(widget->window, x, y);
+
+	*x += widget->allocation.x;
+	*y += widget->allocation.y;
+
+	if(*y + requisition.height > gdk_screen_height ())
+		*y = gdk_screen_height () - requisition.height;
+	else if(*y < 0)
+		*y = 0;
+}

Added: xfce4-taskmanager/trunk/src/menu-positions.h
===================================================================
--- xfce4-taskmanager/trunk/src/menu-positions.h	                        (rev 0)
+++ xfce4-taskmanager/trunk/src/menu-positions.h	2008-05-09 11:01:32 UTC (rev 4749)
@@ -0,0 +1,35 @@
+/*
+ *  xfce4-taskmanager - very simple taskmanger
+ *
+ *  Copyright (c) 2006 Johannes Zellner, <webmaster at nebulon.de>
+ *
+ *  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 Library 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.
+ */
+
+#ifndef __MENU_POSITIONS_H_
+#define __MENU_POSITIONS_H_
+
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+#include "functions.h"
+#include "interface.h"
+
+void position_mainmenu(GtkMenu *menu, gint *x, gint *y, gboolean *push_in, gpointer user_data);
+
+#endif




More information about the Goodies-commits mailing list