Author: rpmcruz
Date: Fri Mar 14 02:02:27 2008
New Revision: 45445
URL: http://svn.opensuse.org/viewcvs/yast?rev=45445&view=rev
Log:
* src/ygtkmenubutton.h/c: added API with a couple of align floats to better
place the popup.
* src/YGPackageSelector.cc (DiskView): center popup horizontally.
* src/ygtkmenubutton.h/c: bug fix: menu button not released for non-native
popups.
Modified:
trunk/gtk/ChangeLog
trunk/gtk/src/YGPackageSelector.cc
trunk/gtk/src/ygtkmenubutton.c
trunk/gtk/src/ygtkmenubutton.h
Modified: trunk/gtk/ChangeLog
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/ChangeLog?rev=45445&r1=45444&r2=45445&view=diff
==============================================================================
--- trunk/gtk/ChangeLog (original)
+++ trunk/gtk/ChangeLog Fri Mar 14 02:02:27 2008
@@ -17,6 +17,13 @@
* src/YGPackageSelector.cc & src/ygtkzyppwrapper.cc/h: modified PackagesView,
Collections::Pool (ie. Patterns) and zypp model to support the TreePool.
+ * src/ygtkmenubutton.h/c: added API with a couple of align floats to better
+ place the popup.
+ * src/YGPackageSelector.cc (DiskView): center popup horizontally.
+
+ * src/ygtkmenubutton.h/c: bug fix: menu button not released for non-native
+ popups.
+
2008-03-10 Ricardo Cruz
* src/YGUtils.cc: replaced specific GtkTextView-scroll set function by a
Modified: trunk/gtk/src/YGPackageSelector.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/YGPackageSelector.cc?rev=45445&r1=45444&r2=45445&view=diff
==============================================================================
--- trunk/gtk/src/YGPackageSelector.cc (original)
+++ trunk/gtk/src/YGPackageSelector.cc Fri Mar 14 02:02:27 2008
@@ -2013,7 +2013,7 @@
gtk_container_add (GTK_CONTAINER (button), gtk_image_new_from_pixbuf (NULL));
#if 1
- menu = ygtk_popup_window_new (createView (model, false));
+ menu = createView (model, false);
#else
menu = gtk_menu_new();
Ypp::Disk *disk = Ypp::get()->getDisk();
@@ -2032,7 +2032,7 @@
gtk_widget_show_all (item);
}
#endif
- ygtk_menu_button_set_popup (YGTK_MENU_BUTTON (button), menu);
+ ygtk_menu_button_set_popup_align (YGTK_MENU_BUTTON (button), menu, 0.5, 1.0);
return button;
}
};
Modified: trunk/gtk/src/ygtkmenubutton.c
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkmenubutton.c?rev=45445&r1=45444&r2=45445&view=diff
==============================================================================
--- trunk/gtk/src/ygtkmenubutton.c (original)
+++ trunk/gtk/src/ygtkmenubutton.c Fri Mar 14 02:02:27 2008
@@ -123,7 +123,6 @@
static void ygtk_menu_button_init (YGtkMenuButton *button)
{
- button->popup = NULL;
}
static void ygtk_menu_button_free_popup (YGtkMenuButton *button)
@@ -141,39 +140,46 @@
G_OBJECT_CLASS (ygtk_menu_button_parent_class)->finalize (object);
}
-static void ygtk_menu_button_get_menu_pos (GtkMenu *menu, gint *x, gint *y,
- gboolean *push_in, gpointer pointer)
+static void ygtk_menu_button_get_popup_pos (YGtkMenuButton *button, gint *x, gint *y)
{
- GtkWidget *widget = (GtkWidget*) pointer;
+ GtkWidget *widget = GTK_WIDGET (button);
+ GtkAllocation *button_alloc = &widget->allocation;
+
+ GtkRequisition req;
+ gtk_widget_size_request (button->popup, &req);
+ int popup_width = req.width, popup_height = req.height;
+ if (button_alloc->width > req.width) {
+ gtk_widget_set_size_request (button->popup, button_alloc->width, -1);
+ popup_width = button_alloc->width;
+ }
+
gdk_window_get_origin (widget->window, x, y);
- *x += widget->allocation.x;
- *y += widget->allocation.y + widget->allocation.height;
+ *x += button_alloc->x - popup_width*button->xalign;
+ *y += (button_alloc->y-popup_height) + (button_alloc->height+popup_height)*button->yalign;
+}
+
+static void ygtk_menu_button_get_menu_pos (GtkMenu *menu, gint *x, gint *y,
+ gboolean *push_in, gpointer data)
+{
+ ygtk_menu_button_get_popup_pos (YGTK_MENU_BUTTON (data), x, y);
*push_in = TRUE;
}
static void ygtk_menu_button_show_popup (YGtkMenuButton *button)
{
- GtkWidget *widget = GTK_WIDGET (button);
GtkWidget *popup = button->popup;
if (!popup)
return;
guint activate_time = gtk_get_current_event_time();
-
if (GTK_IS_MENU (popup))
gtk_menu_popup (GTK_MENU (popup), NULL, NULL, ygtk_menu_button_get_menu_pos,
- widget, 0, activate_time);
+ button, 0, activate_time);
else { // GTK_IS_WINDOW
gint x, y;
- gdk_window_get_origin (GDK_WINDOW (widget->window), &x, &y);
- x += widget->allocation.x;
- y += widget->allocation.y + widget->allocation.height;
-
+ ygtk_menu_button_get_popup_pos (button, &x, &y);
ygtk_popup_window_popup (popup, x, y, activate_time);
}
-
- if (widget->allocation.width > popup->allocation.width)
- gtk_widget_set_size_request (popup, widget->allocation.width, -1);
}
static void ygtk_menu_button_hide_popup (YGtkMenuButton *button)
@@ -238,9 +244,12 @@
static void menu_button_hide_popup (GtkWidget *widget, YGtkMenuButton *button)
{ ygtk_menu_button_hide_popup (button); }
-void ygtk_menu_button_set_popup (YGtkMenuButton *button, GtkWidget *popup)
+void ygtk_menu_button_set_popup_align (YGtkMenuButton *button, GtkWidget *popup,
+ gfloat xalign, gfloat yalign)
{
ygtk_menu_button_free_popup (button);
+ button->xalign = xalign;
+ button->yalign = yalign;
if (!GTK_IS_MENU (popup) && !IS_YGTK_POPUP_WINDOW (popup)) {
// install widget on a YGtkPopupMenu
@@ -249,13 +258,16 @@
else
button->popup = popup;
- g_object_ref (G_OBJECT (button->popup));
- gtk_object_sink (GTK_OBJECT (button->popup));
-
- g_signal_connect (G_OBJECT (popup), "hide",
+ g_object_ref_sink (G_OBJECT (button->popup));
+ g_signal_connect (G_OBJECT (button->popup), "hide",
G_CALLBACK (menu_button_hide_popup), button);
}
+void ygtk_menu_button_set_popup (YGtkMenuButton *button, GtkWidget *popup)
+{
+ ygtk_menu_button_set_popup_align (button, popup, 0.0, 1.0);
+}
+
static void ygtk_menu_button_class_init (YGtkMenuButtonClass *klass)
{
ygtk_menu_button_parent_class = g_type_class_peek_parent (klass);
Modified: trunk/gtk/src/ygtkmenubutton.h
URL: http://svn.opensuse.org/viewcvs/yast/trunk/gtk/src/ygtkmenubutton.h?rev=45445&r1=45444&r2=45445&view=diff
==============================================================================
--- trunk/gtk/src/ygtkmenubutton.h (original)
+++ trunk/gtk/src/ygtkmenubutton.h Fri Mar 14 02:02:27 2008
@@ -70,6 +70,7 @@
// private:
GtkWidget *label, *popup;
+ gfloat xalign, yalign;
} YGtkMenuButton;
typedef struct _YGtkMenuButtonClass
@@ -86,6 +87,8 @@
/* Popup must be either a GtkMenu or a YGtkPopupWindow. */
// You may hide your popup "manually" issueing a gtk_widget_hide() on it
void ygtk_menu_button_set_popup (YGtkMenuButton *button, GtkWidget *popup);
+void ygtk_menu_button_set_popup_align (YGtkMenuButton *button, GtkWidget *popup,
+ gfloat xalign, gfloat yalign);
G_END_DECLS
#endif /*YGTK_MENU_BUTTON_H*/
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org