Improve tooltips sizing
This commit is contained in:
parent
943214dee3
commit
739dbafa97
@ -27,16 +27,6 @@ static void sugar_menu_init (SugarMenu *menu);
|
||||
|
||||
G_DEFINE_TYPE(SugarMenu, sugar_menu, GTK_TYPE_MENU)
|
||||
|
||||
static void
|
||||
sugar_menu_class_init(SugarMenuClass *menu_class)
|
||||
{
|
||||
}
|
||||
|
||||
static void
|
||||
sugar_menu_init(SugarMenu *menu)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
sugar_menu_popup(SugarMenu *menu,
|
||||
int x,
|
||||
@ -69,3 +59,33 @@ sugar_menu_popdown(SugarMenu *menu)
|
||||
gtk_widget_hide(window);
|
||||
}
|
||||
|
||||
void
|
||||
sugar_menu_set_min_width (SugarMenu *menu,
|
||||
int min_width)
|
||||
{
|
||||
menu->min_width = min_width;
|
||||
}
|
||||
|
||||
static void
|
||||
sugar_menu_size_request (GtkWidget *widget,
|
||||
GtkRequisition *requisition)
|
||||
{
|
||||
SugarMenu *menu = SUGAR_MENU(widget);
|
||||
|
||||
(* GTK_WIDGET_CLASS (sugar_menu_parent_class)->size_request) (widget, requisition);
|
||||
|
||||
requisition->width = MAX(requisition->width, menu->min_width);
|
||||
}
|
||||
|
||||
static void
|
||||
sugar_menu_class_init(SugarMenuClass *menu_class)
|
||||
{
|
||||
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(menu_class);
|
||||
|
||||
widget_class->size_request = sugar_menu_size_request;
|
||||
}
|
||||
|
||||
static void
|
||||
sugar_menu_init(SugarMenu *menu)
|
||||
{
|
||||
}
|
||||
|
@ -36,17 +36,21 @@ typedef struct _SugarMenuClass SugarMenuClass;
|
||||
|
||||
struct _SugarMenu {
|
||||
GtkMenu base_instance;
|
||||
|
||||
int min_width;
|
||||
};
|
||||
|
||||
struct _SugarMenuClass {
|
||||
GtkMenuClass base_class;
|
||||
};
|
||||
|
||||
GType sugar_menu_get_type (void);
|
||||
void sugar_menu_popup (SugarMenu *menu,
|
||||
int x,
|
||||
int y);
|
||||
void sugar_menu_popdown (SugarMenu *menu);
|
||||
GType sugar_menu_get_type (void);
|
||||
void sugar_menu_popup (SugarMenu *menu,
|
||||
int x,
|
||||
int y);
|
||||
void sugar_menu_set_min_width (SugarMenu *menu,
|
||||
int min_width);
|
||||
void sugar_menu_popdown (SugarMenu *menu);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
|
@ -26,6 +26,15 @@
|
||||
|
||||
;; From sugar-menu.h
|
||||
|
||||
(define-method set_min_width
|
||||
(of-object "SugarMenu")
|
||||
(c-name "sugar_menu_set_min_width")
|
||||
(return-type "none")
|
||||
(parameters
|
||||
'("gint" "width")
|
||||
)
|
||||
)
|
||||
|
||||
(define-method popup
|
||||
(of-object "SugarMenu")
|
||||
(c-name "sugar_menu_popup")
|
||||
|
@ -77,6 +77,7 @@ class Palette(gobject.GObject):
|
||||
self._popdown_anim.add(_PopdownAnimation(self))
|
||||
|
||||
self._menu = _sugarext.Menu()
|
||||
self._menu.set_min_width(units.grid_to_pixels(1))
|
||||
|
||||
self._primary = _PrimaryMenuItem(label, accel_path)
|
||||
self._menu.append(self._primary)
|
||||
@ -275,6 +276,7 @@ class Palette(gobject.GObject):
|
||||
class _PrimaryMenuItem(gtk.MenuItem):
|
||||
def __init__(self, label, accel_path):
|
||||
gtk.MenuItem.__init__(self)
|
||||
self.set_border_width(units.points_to_pixels(1))
|
||||
self._set_label(label, accel_path)
|
||||
|
||||
def set_label(self, label, accel_path):
|
||||
|
Loading…
Reference in New Issue
Block a user