5
5
* Copyright (C) 2004 Michael Natterer <mitch@gimp.org>
7
* This program is free software; you can redistribute it and/or modify
7
* This program is free software: you can redistribute it and/or modify
8
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 2 of the License, or
9
* the Free Software Foundation; either version 3 of the License, or
10
10
* (at your option) any later version.
12
12
* This program is distributed in the hope that it will be useful,
15
15
* GNU General Public License for more details.
17
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
22
21
#include "config.h"
24
23
#include <string.h>
26
27
#include <gtk/gtk.h>
27
28
#include <gdk/gdkkeysyms.h>
194
193
manager->gimp = NULL;
198
gimp_ui_manager_constructor (GType type,
200
GObjectConstructParam *params)
197
gimp_ui_manager_constructed (GObject *object)
203
GimpUIManager *manager;
205
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
207
manager = GIMP_UI_MANAGER (object);
199
GimpUIManager *manager = GIMP_UI_MANAGER (object);
201
if (G_OBJECT_CLASS (parent_class)->constructed)
202
G_OBJECT_CLASS (parent_class)->constructed (object);
209
204
if (manager->name)
690
686
GimpUIManagerUIEntry *entry,
689
gchar *filename = NULL;
690
const gchar *menus_dir_override = g_getenv ("GIMP_TESTING_MENUS_DIR");
695
filename = g_build_filename (gimp_data_directory (), "menus",
696
entry->basename, NULL);
692
/* In order for test cases to be able to run without GIMP being
693
* installed yet, allow them to override the menus directory to the
694
* menus dir in the source root
696
if (menus_dir_override)
697
filename = g_build_filename (menus_dir_override, entry->basename, NULL);
699
filename = g_build_filename (gimp_data_directory (), "menus",
700
entry->basename, NULL);
698
702
if (manager->gimp->be_verbose)
699
703
g_print ("loading menu '%s' for %s\n",
909
913
gimp_ui_manager_menu_item_select (GtkWidget *widget,
910
914
GimpUIManager *manager)
912
GtkAction *action = gtk_widget_get_action (widget);
917
gtk_activatable_get_related_action (GTK_ACTIVATABLE (widget));
918
g_object_get (action, "tooltip", &tooltip, NULL);
921
const gchar *tooltip = gtk_action_get_tooltip (action);
922
g_signal_emit (manager, manager_signals[SHOW_TOOLTIP], 0,
924
g_signal_emit (manager, manager_signals[SHOW_TOOLTIP], 0, tooltip);
1073
1071
child_location_foreach (GtkWidget *child,
1077
1075
struct ChildLocation *child_loc = data;
1079
1077
/* Ignore invisible widgets */
1080
if (!GTK_WIDGET_DRAWABLE (child))
1078
if (! gtk_widget_is_drawable (child))
1083
1081
/* (child_loc->x, child_loc->y) are relative to
1084
1082
* child_loc->container's allocation.
1087
if (!child_loc->child &&
1085
if (! child_loc->child &&
1088
1086
gtk_widget_translate_coordinates (child_loc->container, child,
1089
child_loc->x, child_loc->y,
1087
child_loc->x, child_loc->y,
1090
GtkAllocation child_allocation;
1092
gtk_widget_get_allocation (child, &child_allocation);
1092
1094
#ifdef DEBUG_TOOLTIP
1093
1095
g_print ("candidate: %s alloc=[(%d,%d) %dx%d] (%d, %d)->(%d, %d)\n",
1094
gtk_widget_get_name (child),
1095
child->allocation.x,
1096
child->allocation.y,
1097
child->allocation.width,
1098
child->allocation.height,
1099
child_loc->x, child_loc->y,
1096
gtk_widget_get_name (child),
1099
child_allocation.width,
1100
child_allocation.height,
1101
child_loc->x, child_loc->y,
1101
1103
#endif /* DEBUG_TOOLTIP */
1103
1105
/* (x, y) relative to child's allocation. */
1104
if (x >= 0 && x < child->allocation.width
1105
&& y >= 0 && y < child->allocation.height)
1106
if (x >= 0 && x < child_allocation.width
1107
&& y >= 0 && y < child_allocation.height)
1107
if (GTK_IS_CONTAINER (child))
1109
struct ChildLocation tmp = { NULL, NULL, 0, 0 };
1111
/* Take (x, y) relative the child's allocation and
1116
tmp.container = child;
1118
gtk_container_forall (GTK_CONTAINER (child),
1119
child_location_foreach, &tmp);
1122
child_loc->child = tmp.child;
1124
child_loc->child = child;
1127
child_loc->child = child;
1109
if (GTK_IS_CONTAINER (child))
1111
struct ChildLocation tmp = { NULL, NULL, 0, 0 };
1113
/* Take (x, y) relative the child's allocation and
1118
tmp.container = child;
1120
gtk_container_forall (GTK_CONTAINER (child),
1121
child_location_foreach, &tmp);
1124
child_loc->child = tmp.child;
1126
child_loc->child = child;
1130
child_loc->child = child;
1136
1140
window_to_alloc (GtkWidget *dest_widget,
1146
GtkAllocation dest_allocation;
1148
gtk_widget_get_allocation (dest_widget, &dest_allocation);
1142
1150
/* Translate from window relative to allocation relative */
1143
if (!GTK_WIDGET_NO_WINDOW (dest_widget) && dest_widget->parent)
1151
if (gtk_widget_get_has_window (dest_widget) &&
1152
gtk_widget_get_parent (dest_widget))
1146
gdk_window_get_position (dest_widget->window, &wx, &wy);
1156
gdk_window_get_position (gtk_widget_get_window (dest_widget), &wx, &wy);
1148
1158
/* Offset coordinates if widget->window is smaller than
1149
1159
* widget->allocation.
1151
src_x += wx - dest_widget->allocation.x;
1152
src_y += wy - dest_widget->allocation.y;
1161
src_x += wx - dest_allocation.x;
1162
src_y += wy - dest_allocation.y;
1156
src_x -= dest_widget->allocation.x;
1157
src_y -= dest_widget->allocation.y;
1166
src_x -= dest_allocation.x;
1167
src_y -= dest_allocation.y;
1166
1176
static GtkWidget *
1167
1177
find_widget_under_pointer (GdkWindow *window,
1171
1181
GtkWidget *event_widget;
1172
1182
struct ChildLocation child_loc = { NULL, NULL, 0, 0 };
1174
1184
gdk_window_get_user_data (window, (void **)&event_widget);
1179
1189
#ifdef DEBUG_TOOLTIP
1180
1190
g_print ("event window %p (belonging to %p (%s)) (%d, %d)\n",
1181
window, event_widget, gtk_widget_get_name (event_widget),
1191
window, event_widget, gtk_widget_get_name (event_widget),
1185
1195
/* Coordinates are relative to event window */
1213
1223
* relative coordinates.
1215
1225
window_to_alloc (event_widget,
1216
child_loc.x, child_loc.y,
1217
&child_loc.x, &child_loc.y);
1226
child_loc.x, child_loc.y,
1227
&child_loc.x, &child_loc.y);
1219
1229
if (GTK_IS_CONTAINER (event_widget))
1224
1234
child_loc.child = NULL;
1226
1236
gtk_container_forall (GTK_CONTAINER (event_widget),
1227
child_location_foreach, &child_loc);
1237
child_location_foreach, &child_loc);
1229
1239
/* Here we have a widget, with coordinates relative to
1230
1240
* child_loc.container's allocation.
1233
1243
if (child_loc.child)
1234
event_widget = child_loc.child;
1244
event_widget = child_loc.child;
1235
1245
else if (child_loc.container)
1236
event_widget = child_loc.container;
1246
event_widget = child_loc.container;
1238
1248
/* Translate to event_widget's allocation */
1239
1249
gtk_widget_translate_coordinates (container, event_widget,
1240
child_loc.x, child_loc.y,
1241
&child_loc.x, &child_loc.y);
1250
child_loc.x, child_loc.y,
1251
&child_loc.x, &child_loc.y);