/** * glade_cursor_set: * @window: a #GdkWindow * @type: a #GladeCursorType * * Sets the cursor for @window to something appropriate based on @type. * (also sets the cursor on all visible project widgets) */ void glade_cursor_set (GladeProject *project, GdkWindow *window, GladeCursorType type) { GladeWidgetAdaptor *adaptor; GdkCursor *the_cursor = NULL; g_return_if_fail (cursor != NULL); switch (type) { case GLADE_CURSOR_SELECTOR: the_cursor = cursor->selector; break; case GLADE_CURSOR_ADD_WIDGET: if ((adaptor = glade_project_get_add_item (project)) != NULL) { g_object_get (adaptor, "cursor", &the_cursor, NULL); if (the_cursor == NULL) the_cursor = cursor->add_widget; } else the_cursor = cursor->add_widget; break; case GLADE_CURSOR_RESIZE_TOP_LEFT: the_cursor = cursor->resize_top_left; break; case GLADE_CURSOR_RESIZE_TOP_RIGHT: the_cursor = cursor->resize_top_right; break; case GLADE_CURSOR_RESIZE_BOTTOM_LEFT: the_cursor = cursor->resize_bottom_left; break; case GLADE_CURSOR_RESIZE_BOTTOM_RIGHT: the_cursor = cursor->resize_bottom_right; break; case GLADE_CURSOR_RESIZE_LEFT: the_cursor = cursor->resize_left; break; case GLADE_CURSOR_RESIZE_RIGHT: the_cursor = cursor->resize_right; break; case GLADE_CURSOR_RESIZE_TOP: the_cursor = cursor->resize_top; break; case GLADE_CURSOR_RESIZE_BOTTOM: the_cursor = cursor->resize_bottom; break; case GLADE_CURSOR_DRAG: the_cursor = cursor->drag; break; default: break; } if (the_cursor != gdk_window_get_cursor (window)) { set_cursor (project, cursor->selector); gdk_window_set_cursor (window, the_cursor); } }
static GtkWidget * glade_popup_create_menu (GladeWidget *widget, GladePlaceholder *placeholder, GladeProject *project, gboolean packing) { GtkWidget *popup_menu; GtkWidget *separator; gboolean sensitive; GladeWidgetAdaptor *adaptor; popup_menu = gtk_menu_new (); adaptor = glade_project_get_add_item (project); if (adaptor) { RootAddData *data = g_new (RootAddData, 1); data->adaptor = adaptor; data->project = project; data->parent = placeholder ? glade_placeholder_get_parent (placeholder) : widget; data->placeholder = placeholder; g_object_set_data_full (G_OBJECT (popup_menu), "root-data-destroy-me", data, (GDestroyNotify)g_free); glade_popup_append_item (popup_menu, _("_Add widget here"), data->parent != NULL, glade_popup_widget_add_cb, data); glade_popup_append_item (popup_menu, _("Add widget as _toplevel"), TRUE, glade_popup_root_add_cb, data); separator = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator); gtk_widget_show (separator); } sensitive = (widget != NULL); glade_popup_append_item (popup_menu, _("_Select"), sensitive, glade_popup_select_cb, widget); glade_popup_append_item (popup_menu, _("Cu_t"), sensitive, glade_popup_cut_cb, widget); glade_popup_append_item (popup_menu, _("_Copy"), sensitive, glade_popup_copy_cb, widget); /* paste is placholder specific when the popup is on a placeholder */ sensitive = glade_clipboard_get_has_selection (glade_app_get_clipboard ()); if (placeholder) glade_popup_append_item (popup_menu, _("_Paste"), sensitive, glade_popup_placeholder_paste_cb, placeholder); else if (widget) glade_popup_append_item (popup_menu, _("_Paste"), sensitive, glade_popup_paste_cb, widget); else glade_popup_append_item (popup_menu, _("_Paste"), sensitive, glade_popup_paste_cb, NULL); glade_popup_append_item (popup_menu, _("_Delete"), (widget != NULL), glade_popup_delete_cb, widget); /* packing actions are a little different on placholders */ if (placeholder) { if (widget && glade_widget_get_actions (widget)) { GtkWidget *separator = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator); gtk_widget_show (separator); glade_popup_action_populate_menu_real (popup_menu, widget, glade_widget_get_actions (widget), G_CALLBACK (glade_popup_menuitem_activated), widget); } if (glade_placeholder_packing_actions (placeholder)) { GtkWidget *separator = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator); gtk_widget_show (separator); glade_popup_action_populate_menu_real (popup_menu, widget, glade_placeholder_packing_actions (placeholder), G_CALLBACK (glade_popup_menuitem_ph_packing_activated), placeholder); } } else if (widget && (glade_widget_get_actions (widget) || (packing && glade_widget_get_pack_actions (widget)))) { GtkWidget *separator = gtk_separator_menu_item_new (); gtk_menu_shell_append (GTK_MENU_SHELL (popup_menu), separator); gtk_widget_show (separator); glade_popup_action_populate_menu (popup_menu, widget, NULL, packing); } return popup_menu; }