static int
get_toolbar_position (EggEditableToolbar *etoolbar, GtkWidget *toolbar)
{
- return get_dock_position (etoolbar, toolbar->parent);
+ return get_dock_position (etoolbar, gtk_widget_get_parent (toolbar));
}
static int
EggEditableToolbar *etoolbar)
{
int pos, toolbar_pos;
+ GtkWidget *parent;
widget = gtk_widget_get_ancestor (widget, GTK_TYPE_TOOL_ITEM);
g_return_if_fail (widget != NULL);
g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar));
- pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (widget->parent),
+ parent = gtk_widget_get_parent (widget);
+ pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (parent),
GTK_TOOL_ITEM (widget));
- toolbar_pos = get_toolbar_position (etoolbar, widget->parent);
+ toolbar_pos = get_toolbar_position (etoolbar, parent);
egg_toolbars_model_remove_item (etoolbar->priv->model,
toolbar_pos, pos);
EggToolbarsModel *model;
const char *name;
char *data;
+ GdkAtom target;
g_return_if_fail (EGG_IS_EDITABLE_TOOLBAR (etoolbar));
model = egg_editable_toolbar_get_model (etoolbar);
g_return_if_fail (name != NULL);
}
- data = egg_toolbars_model_get_data (model, selection_data->target, name);
+ target = gtk_selection_data_get_target (selection_data);
+ data = egg_toolbars_model_get_data (model, target, name);
if (data != NULL)
{
- gtk_selection_data_set (selection_data, selection_data->target, 8, (unsigned char *)data, strlen (data));
+ gtk_selection_data_set (selection_data, target, 8, (unsigned char *)data, strlen (data));
g_free (data);
}
}
EggEditableToolbar *etoolbar)
{
GtkWidget *toolitem = gtk_widget_get_ancestor (egg_editable_toolbar_get_selected (etoolbar), GTK_TYPE_TOOL_ITEM);
+ GtkWidget *parent = gtk_widget_get_parent (toolitem);
int pos, toolbar_pos;
- toolbar_pos = get_toolbar_position (etoolbar, toolitem->parent);
- pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (toolitem->parent),
+ toolbar_pos = get_toolbar_position (etoolbar, parent);
+ pos = gtk_toolbar_get_item_index (GTK_TOOLBAR (parent),
GTK_TOOL_ITEM (toolitem));
egg_toolbars_model_remove_item (etoolbar->priv->model,
{
EggEditableToolbarPrivate *priv = etoolbar->priv;
GtkWidget *widget = GTK_WIDGET (item);
+ GdkWindow *window = gtk_widget_get_window (widget);
- if (widget->window != NULL)
+ if (window != NULL)
{
if (priv->edit_mode > 0)
{
cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen),
GDK_HAND2);
- gdk_window_set_cursor (widget->window, cursor);
- gdk_cursor_unref (cursor);
+ gdk_window_set_cursor (window, cursor);
+ g_object_unref (cursor);
gtk_drag_source_set (widget, GDK_BUTTON1_MASK, dest_drag_types,
G_N_ELEMENTS (dest_drag_types), GDK_ACTION_MOVE);
}
else if (stock_id)
{
- pixbuf = gtk_widget_render_icon (widget, stock_id,
- GTK_ICON_SIZE_LARGE_TOOLBAR, NULL);
+ pixbuf = gtk_widget_render_icon_pixbuf (widget, stock_id,
+ GTK_ICON_SIZE_LARGE_TOOLBAR);
}
g_free (icon_name);
g_free (stock_id);
}
else
{
- gdk_window_set_cursor (GTK_WIDGET(item)->window, NULL);
+ gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET(item)), NULL);
}
}
}
* actually add a new item to the toolbar.
*/
- GdkAtom type = selection_data->type;
- const char *data = (char *)selection_data->data;
+ GdkAtom type = gtk_selection_data_get_data_type (selection_data);
+ const char *data = (char *)gtk_selection_data_get_data (selection_data);
int ipos = -1;
char *name = NULL;
gboolean used = FALSE;
/* Find out where the drop is occuring, and the name of what is being dropped. */
- if (selection_data->length >= 0)
+ if (gtk_selection_data_get_length (selection_data) >= 0)
{
ipos = gtk_toolbar_get_drop_index (toolbar, x, y);
name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, FALSE);
etoolbar->priv->dnd_toolitem = NULL;
/* If we don't have a name to use yet, try to create one. */
- if (name == NULL && selection_data->length >= 0)
+ if (name == NULL && gtk_selection_data_get_length (selection_data) >= 0)
{
name = egg_toolbars_model_get_name (etoolbar->priv->model, type, data, TRUE);
}
{
gint tpos = get_toolbar_position (etoolbar, GTK_WIDGET (toolbar));
egg_toolbars_model_add_item (etoolbar->priv->model, tpos, ipos, name);
- gtk_drag_finish (context, TRUE, context->action == GDK_ACTION_MOVE, time);
+ gtk_drag_finish (context, TRUE,
+ gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE, time);
}
else
{
- gtk_drag_finish (context, FALSE, context->action == GDK_ACTION_MOVE, time);
+ gtk_drag_finish (context, FALSE,
+ gdk_drag_context_get_selected_action (context) == GDK_ACTION_MOVE, time);
}
}
etoolbar->priv->dnd_toolitem, ipos);
}
- gdk_drag_status (context, context->suggested_action, time);
+ gdk_drag_status (context, gdk_drag_context_get_suggested_action (context), time);
return TRUE;
}
priv->visibility_id = gtk_ui_manager_new_merge_id (priv->manager);
#if GTK_CHECK_VERSION(2,20,0)
- showing = gtk_widget_get_visible (etoolbar);
+ showing = gtk_widget_get_visible (GTK_WIDGET (etoolbar));
#else
showing = GTK_WIDGET_VISIBLE (etoolbar);
#endif
toolbar = etoolbar->priv->fixed_toolbar;
dock = get_dock_nth (etoolbar, 0);
- if (dock && toolbar->parent != NULL)
+ if (dock && gtk_widget_get_parent (toolbar) != NULL)
{
gtk_container_remove (GTK_CONTAINER (dock), toolbar);
}
toolbar = etoolbar->priv->fixed_toolbar;
dock = get_dock_nth (etoolbar, 0);
- if (dock && toolbar && toolbar->parent == NULL)
+ if (dock && toolbar && gtk_widget_get_parent (toolbar) == NULL)
{
gtk_box_pack_end (GTK_BOX (dock), toolbar, FALSE, TRUE, 0);
}
#define DEFAULT_ICON_HEIGHT 20
-#define DEFAULT_ICON_WIDTH 0
-
-static void
-fake_expose_widget (GtkWidget *widget,
- GdkPixmap *pixmap)
-{
- GdkWindow *tmp_window;
- GdkEventExpose event;
-
- event.type = GDK_EXPOSE;
- event.window = pixmap;
- event.send_event = FALSE;
- event.area = widget->allocation;
- event.region = NULL;
- event.count = 0;
-
- tmp_window = widget->window;
- widget->window = pixmap;
- gtk_widget_send_expose (widget, (GdkEvent *) &event);
- widget->window = tmp_window;
-}
/* We should probably experiment some more with this.
* Right now the rendered icon is pretty good for most
{
GtkWidget *window;
GdkPixbuf *pixbuf;
- GtkRequisition requisition;
- GtkAllocation allocation;
- GdkPixmap *pixmap;
- GdkVisual *visual;
- gint icon_width;
gint icon_height;
GdkScreen *screen;
- icon_width = DEFAULT_ICON_WIDTH;
-
screen = gtk_widget_get_screen (widget);
if (!gtk_icon_size_lookup_for_settings (gtk_settings_get_for_screen (screen),
icon_height = DEFAULT_ICON_HEIGHT;
}
- window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+ window = gtk_offscreen_window_new ();
+ /* Set the width to -1 as we want the separator to be as thin as possible. */
+ gtk_widget_set_size_request (widget, -1, icon_height);
gtk_container_add (GTK_CONTAINER (window), widget);
- gtk_widget_realize (window);
- gtk_widget_show (widget);
- gtk_widget_realize (widget);
- gtk_widget_map (widget);
-
- /* Gtk will never set the width or height of a window to 0. So setting the width to
- * 0 and than getting it will provide us with the minimum width needed to render
- * the icon correctly, without any additional window background noise.
- * This is needed mostly for pixmap based themes.
- */
- gtk_window_set_default_size (GTK_WINDOW (window), icon_width, icon_height);
- gtk_window_get_size (GTK_WINDOW (window),&icon_width, &icon_height);
-
- gtk_widget_size_request (window, &requisition);
- allocation.x = 0;
- allocation.y = 0;
- allocation.width = icon_width;
- allocation.height = icon_height;
- gtk_widget_size_allocate (window, &allocation);
- gtk_widget_size_request (window, &requisition);
-
- /* Create a pixmap */
- visual = gtk_widget_get_visual (window);
- pixmap = gdk_pixmap_new (NULL, icon_width, icon_height, visual->depth);
- gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), gtk_widget_get_colormap (window));
-
- /* Draw the window */
- gtk_widget_ensure_style (window);
- g_assert (window->style);
- g_assert (window->style->font_desc);
-
- fake_expose_widget (window, pixmap);
- fake_expose_widget (widget, pixmap);
-
- pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, icon_width, icon_height);
- gdk_pixbuf_get_from_drawable (pixbuf, pixmap, NULL, 0, 0, 0, 0, icon_width, icon_height);
+ gtk_widget_show_all (window);
+ /* Process the waiting events to have the widget actually drawn */
+ gdk_window_process_updates (gtk_widget_get_window (window), TRUE);
+ pixbuf = gtk_offscreen_window_get_pixbuf (GTK_OFFSCREEN_WINDOW (window));
gtk_widget_destroy (window);
return pixbuf;