added "show-tooltip" and "hide-tooltip" signals. Connect to each menu

2006-03-09  Michael Natterer  <mitch@gimp.org>

	* app/widgets/gimpuimanager.[ch]: added "show-tooltip" and
	"hide-tooltip" signals. Connect to each menu item's
	enter-notify-event and leave-notify-event. On enter, emit
	show-tooltip, on leave emit hide-tooltip.

	* app/display/gimpdisplayshell.c: connect to the menubar ui
	manager's show-tooltip and hide-tooltip signals and show the tip
	in the display's status bar.
This commit is contained in:
Michael Natterer 2006-03-09 15:26:33 +00:00 committed by Michael Natterer
parent 578de6bb49
commit 6a01bb2306
4 changed files with 158 additions and 47 deletions

View File

@ -1,3 +1,14 @@
2006-03-09 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpuimanager.[ch]: added "show-tooltip" and
"hide-tooltip" signals. Connect to each menu item's
enter-notify-event and leave-notify-event. On enter, emit
show-tooltip, on leave emit hide-tooltip.
* app/display/gimpdisplayshell.c: connect to the menubar ui
manager's show-tooltip and hide-tooltip signals and show the tip
in the display's status bar.
2006-03-09 Sven Neumann <sven@gimp.org>
* plug-ins/common/psd.c: create empty layers of image size instead

View File

@ -113,6 +113,11 @@ static void gimp_display_shell_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data);
static void gimp_display_shell_show_tooltip (GimpUIManager *manager,
const gchar *tooltip,
GimpDisplayShell *shell);
static void gimp_display_shell_hide_tooltip (GimpUIManager *manager,
GimpDisplayShell *shell);
G_DEFINE_TYPE (GimpDisplayShell, gimp_display_shell, GTK_TYPE_WINDOW);
@ -552,6 +557,22 @@ gimp_display_shell_menu_position (GtkMenu *menu,
gimp_button_menu_position (GTK_WIDGET (data), menu, GTK_POS_RIGHT, x, y);
}
static void
gimp_display_shell_show_tooltip (GimpUIManager *manager,
const gchar *tooltip,
GimpDisplayShell *shell)
{
gimp_statusbar_push (GIMP_STATUSBAR (shell->statusbar), "menu-tooltip",
tooltip);
}
static void
gimp_display_shell_hide_tooltip (GimpUIManager *manager,
GimpDisplayShell *shell)
{
gimp_statusbar_pop (GIMP_STATUSBAR (shell->statusbar), "menu-tooltip");
}
/* public functions */
@ -677,6 +698,13 @@ gimp_display_shell_new (GimpDisplay *gdisp,
gtk_window_add_accel_group (GTK_WINDOW (shell),
gtk_ui_manager_get_accel_group (GTK_UI_MANAGER (shell->menubar_manager)));
g_signal_connect (shell->menubar_manager, "show-tooltip",
G_CALLBACK (gimp_display_shell_show_tooltip),
shell);
g_signal_connect (shell->menubar_manager, "hide-tooltip",
G_CALLBACK (gimp_display_shell_hide_tooltip),
shell);
/* GtkTable widgets are not able to shrink a row/column correctly if
* widgets are attached with GTK_EXPAND even if those widgets have
* other rows/columns in their rowspan/colspan where they could

View File

@ -52,58 +52,66 @@ enum
enum
{
UPDATE,
SHOW_TOOLTIP,
HIDE_TOOLTIP,
LAST_SIGNAL
};
static GObject * gimp_ui_manager_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_ui_manager_dispose (GObject *object);
static void gimp_ui_manager_finalize (GObject *object);
static void gimp_ui_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_ui_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gimp_ui_manager_connect_proxy (GtkUIManager *manager,
GtkAction *action,
GtkWidget *proxy);
static GtkWidget * gimp_ui_manager_get_widget (GtkUIManager *manager,
const gchar *path);
static GtkAction * gimp_ui_manager_get_action (GtkUIManager *manager,
const gchar *path);
static void gimp_ui_manager_real_update (GimpUIManager *manager,
gpointer update_data);
static GObject * gimp_ui_manager_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_ui_manager_dispose (GObject *object);
static void gimp_ui_manager_finalize (GObject *object);
static void gimp_ui_manager_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_ui_manager_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec);
static void gimp_ui_manager_connect_proxy (GtkUIManager *manager,
GtkAction *action,
GtkWidget *proxy);
static GtkWidget * gimp_ui_manager_get_widget (GtkUIManager *manager,
const gchar *path);
static GtkAction * gimp_ui_manager_get_action (GtkUIManager *manager,
const gchar *path);
static void gimp_ui_manager_real_update (GimpUIManager *manager,
gpointer update_data);
static GimpUIManagerUIEntry *
gimp_ui_manager_entry_get (GimpUIManager *manager,
const gchar *ui_path);
static gboolean gimp_ui_manager_entry_load (GimpUIManager *manager,
GimpUIManagerUIEntry *entry,
GError **error);
gimp_ui_manager_entry_get (GimpUIManager *manager,
const gchar *ui_path);
static gboolean gimp_ui_manager_entry_load (GimpUIManager *manager,
GimpUIManagerUIEntry *entry,
GError **error);
static GimpUIManagerUIEntry *
gimp_ui_manager_entry_ensure (GimpUIManager *manager,
const gchar *path);
static void gimp_ui_manager_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data);
static void gimp_ui_manager_menu_pos (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer data);
gimp_ui_manager_entry_ensure (GimpUIManager *manager,
const gchar *path);
static void gimp_ui_manager_menu_position (GtkMenu *menu,
gint *x,
gint *y,
gpointer data);
static void gimp_ui_manager_menu_pos (GtkMenu *menu,
gint *x,
gint *y,
gboolean *push_in,
gpointer data);
static void
gimp_ui_manager_delete_popdown_data (GtkObject *object,
GimpUIManager *manager);
static void gimp_ui_manager_item_realize (GtkWidget *widget,
GimpUIManager *manager);
static gboolean gimp_ui_manager_item_key_press (GtkWidget *widget,
GdkEventKey *kevent,
GimpUIManager *manager);
gimp_ui_manager_delete_popdown_data (GtkObject *object,
GimpUIManager *manager);
static void gimp_ui_manager_item_realize (GtkWidget *widget,
GimpUIManager *manager);
static gboolean gimp_ui_manager_menu_item_enter (GtkWidget *widget,
GdkEvent *event,
GimpUIManager *manager);
static gboolean gimp_ui_manager_menu_item_leave (GtkWidget *widget,
GdkEvent *event,
GimpUIManager *manager);
static gboolean gimp_ui_manager_item_key_press (GtkWidget *widget,
GdkEventKey *kevent,
GimpUIManager *manager);
G_DEFINE_TYPE (GimpUIManager, gimp_ui_manager, GTK_TYPE_UI_MANAGER);
@ -141,6 +149,26 @@ gimp_ui_manager_class_init (GimpUIManagerClass *klass)
G_TYPE_NONE, 1,
G_TYPE_POINTER);
manager_signals[SHOW_TOOLTIP] =
g_signal_new ("show-tooltip",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpUIManagerClass, show_tooltip),
NULL, NULL,
gimp_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
manager_signals[HIDE_TOOLTIP] =
g_signal_new ("hide-tooltip",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpUIManagerClass, hide_tooltip),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0,
G_TYPE_NONE);
g_object_class_install_property (object_class, PROP_NAME,
g_param_spec_string ("name",
NULL, NULL,
@ -801,6 +829,13 @@ gimp_ui_manager_item_realize (GtkWidget *widget,
gimp_ui_manager_item_realize,
manager);
g_signal_connect (widget, "enter-notify-event",
G_CALLBACK (gimp_ui_manager_menu_item_enter),
manager);
g_signal_connect (widget, "leave-notify-event",
G_CALLBACK (gimp_ui_manager_menu_item_leave),
manager);
if (GTK_IS_MENU_SHELL (widget->parent))
{
static GQuark quark_key_press_connected = 0;
@ -830,6 +865,40 @@ gimp_ui_manager_item_realize (GtkWidget *widget,
GIMP_HELP_ID));
}
static gboolean
gimp_ui_manager_menu_item_enter (GtkWidget *widget,
GdkEvent *event,
GimpUIManager *manager)
{
GtkAction *action = g_object_get_data (G_OBJECT (widget), "gtk-action");
if (action)
{
gchar *tooltip;
g_object_get (action, "tooltip", &tooltip, NULL);
if (tooltip)
{
g_signal_emit (manager, manager_signals[SHOW_TOOLTIP], 0,
tooltip);
g_free (tooltip);
}
}
return FALSE;
}
static gboolean
gimp_ui_manager_menu_item_leave (GtkWidget *widget,
GdkEvent *event,
GimpUIManager *manager)
{
g_signal_emit (manager, manager_signals[HIDE_TOOLTIP], 0);
return FALSE;
}
static gboolean
gimp_ui_manager_item_key_press (GtkWidget *widget,
GdkEventKey *kevent,

View File

@ -62,8 +62,11 @@ struct _GimpUIManagerClass
GHashTable *managers;
void (* update) (GimpUIManager *manager,
gpointer update_data);
void (* update) (GimpUIManager *manager,
gpointer update_data);
void (* show_tooltip) (GimpUIManager *manager,
const gchar *tooltip);
void (* hide_tooltip) (GimpUIManager *manager);
};