summaryrefslogtreecommitdiff
path: root/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
diff options
context:
space:
mode:
authormonsta <[email protected]>2016-11-23 18:15:54 +0300
committermonsta <[email protected]>2016-11-23 18:15:54 +0300
commitae5f4711a21508a70d7123dbc0efb610af1289a2 (patch)
tree54d4a9de3b092aa772ed8799fcf30e11e19ff93f /cut-n-paste/toolbar-editor/egg-toolbar-editor.c
parent7884bbe50fe8b8c26e68b8077c18047861c2dd0c (diff)
downloadatril-ae5f4711a21508a70d7123dbc0efb610af1289a2.tar.bz2
atril-ae5f4711a21508a70d7123dbc0efb610af1289a2.tar.xz
move to GTK+3 (>= 3.14), drop GTK+2 code and --with-gtk build option
and require caja >= 1.17.1
Diffstat (limited to 'cut-n-paste/toolbar-editor/egg-toolbar-editor.c')
-rw-r--r--cut-n-paste/toolbar-editor/egg-toolbar-editor.c101
1 files changed, 4 insertions, 97 deletions
diff --git a/cut-n-paste/toolbar-editor/egg-toolbar-editor.c b/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
index 328b0327..fa79318b 100644
--- a/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
+++ b/cut-n-paste/toolbar-editor/egg-toolbar-editor.c
@@ -28,12 +28,6 @@
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#if GTK_CHECK_VERSION (3, 0, 0)
-#define gdk_cursor_unref g_object_unref
-#define gtk_widget_render_icon(A,B,C,D) gtk_widget_render_icon_pixbuf(A,B,C)
-#define gtk_vbox_new(X,Y) gtk_box_new(GTK_ORIENTATION_VERTICAL,Y)
-#endif
-
static const GtkTargetEntry dest_drag_types[] = {
{EGG_TOOLBAR_ITEM_TYPE, GTK_TARGET_SAME_APP, 0},
};
@@ -68,11 +62,7 @@ struct EggToolbarEditorPrivate
GtkUIManager *manager;
EggToolbarsModel *model;
-#if GTK_CHECK_VERSION(3, 0, 0)
GtkWidget *grid;
-#else
- GtkWidget *table;
-#endif
GtkWidget *scrolled_window;
GList *actions_list;
GList *factory_list;
@@ -379,7 +369,7 @@ set_drag_cursor (GtkWidget *widget)
cursor = gdk_cursor_new_for_display (gdk_screen_get_display (screen),
GDK_HAND2);
gdk_window_set_cursor (gtk_widget_get_window (widget), cursor);
- gdk_cursor_unref (cursor);
+ g_object_unref (cursor);
}
static void
@@ -396,8 +386,8 @@ event_box_realize_cb (GtkWidget *widget, GtkImage *icon)
GdkPixbuf *pixbuf;
gtk_image_get_stock (icon, &stock_id, NULL);
- 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);
gtk_drag_source_set_icon_pixbuf (widget, pixbuf);
g_object_unref (pixbuf);
}
@@ -468,7 +458,7 @@ editor_create_item (EggToolbarEditor *editor,
G_CALLBACK (drag_end_cb), NULL);
}
- vbox = gtk_vbox_new (0, FALSE);
+ vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
gtk_widget_show (vbox);
gtk_container_add (GTK_CONTAINER (event_box), vbox);
@@ -545,7 +535,6 @@ editor_create_item_from_name (EggToolbarEditor *editor,
return item;
}
-#if GTK_CHECK_VERSION(3, 0, 0)
static gint
append_grid (GtkGrid *grid, GList *items, gint y, gint width)
{
@@ -590,52 +579,6 @@ append_grid (GtkGrid *grid, GList *items, gint y, gint width)
}
return y;
}
-#else
-static gint
-append_table (GtkTable *table, GList *items, gint y, gint width)
-{
- if (items != NULL)
- {
- gint x = 0, height;
- GtkWidget *alignment;
- GtkWidget *item;
-
- height = g_list_length (items) / width + 1;
- gtk_table_resize (table, height, width);
-
- if (y > 0)
- {
- item = gtk_hseparator_new ();
- alignment = gtk_alignment_new (0.5, 0.5, 1.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), item);
- gtk_widget_show (alignment);
- gtk_widget_show (item);
-
- gtk_table_attach_defaults (table, alignment, 0, width, y-1, y+1);
- }
-
- for (; items != NULL; items = items->next)
- {
- item = items->data;
- alignment = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
- gtk_container_add (GTK_CONTAINER (alignment), item);
- gtk_widget_show (alignment);
- gtk_widget_show (item);
-
- if (x >= width)
- {
- x = 0;
- y++;
- }
- gtk_table_attach_defaults (table, alignment, x, x+1, y, y+1);
- x++;
- }
-
- y++;
- }
- return y;
-}
-#endif
static void
update_editor_sheet (EggToolbarEditor *editor)
@@ -643,7 +586,6 @@ update_editor_sheet (EggToolbarEditor *editor)
gint y;
GPtrArray *items;
GList *to_move = NULL, *to_copy = NULL;
-#if GTK_CHECK_VERSION(3, 0, 0)
GtkWidget *grid;
GtkWidget *viewport;
@@ -656,20 +598,6 @@ update_editor_sheet (EggToolbarEditor *editor)
gtk_grid_set_row_spacing (GTK_GRID (grid), 24);
gtk_widget_show (grid);
gtk_drag_dest_set (grid, GTK_DEST_DEFAULT_ALL,
-#else
- GtkWidget *table;
- GtkWidget *viewport;
-
- g_return_if_fail (EGG_IS_TOOLBAR_EDITOR (editor));
-
- /* Create new table. */
- table = gtk_table_new (0, 0, TRUE);
- editor->priv->table = table;
- gtk_container_set_border_width (GTK_CONTAINER (table), 12);
- gtk_table_set_row_spacings (GTK_TABLE (table), 24);
- gtk_widget_show (table);
- gtk_drag_dest_set (table, GTK_DEST_DEFAULT_ALL,
-#endif
dest_drag_types, G_N_ELEMENTS (dest_drag_types),
GDK_ACTION_MOVE | GDK_ACTION_COPY);
@@ -701,7 +629,6 @@ update_editor_sheet (EggToolbarEditor *editor)
/* Add them to the sheet. */
y = 0;
-#if GTK_CHECK_VERSION(3, 0, 0)
y = append_grid (GTK_GRID (grid), to_move, y, 4);
y = append_grid (GTK_GRID (grid), to_copy, y, 4);
@@ -720,26 +647,6 @@ update_editor_sheet (EggToolbarEditor *editor)
/* Add grid to window. */
gtk_scrolled_window_add_with_viewport
(GTK_SCROLLED_WINDOW (editor->priv->scrolled_window), grid);
-#else
- y = append_table (GTK_TABLE (table), to_move, y, 4);
- y = append_table (GTK_TABLE (table), to_copy, y, 4);
-
- g_list_free (to_move);
- g_list_free (to_copy);
- g_ptr_array_free (items, TRUE);
-
- /* Delete old table. */
- viewport = gtk_bin_get_child (GTK_BIN (editor->priv->scrolled_window));
- if (viewport)
- {
- gtk_container_remove (GTK_CONTAINER (viewport),
- gtk_bin_get_child (GTK_BIN (viewport)));
- }
-
- /* Add table to window. */
- gtk_scrolled_window_add_with_viewport
- (GTK_SCROLLED_WINDOW (editor->priv->scrolled_window), table);
-#endif
}
static void