summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libslab/app-resizer.c100
-rw-r--r--libslab/app-shell.c13
-rw-r--r--libslab/application-tile.c2
-rw-r--r--libslab/document-tile.c22
-rw-r--r--libslab/libslab-utils.c4
-rw-r--r--libslab/libslab.pc.in4
-rw-r--r--libslab/mate-utils.c4
-rw-r--r--libslab/nameplate-tile.c24
-rw-r--r--libslab/search-bar.c8
-rw-r--r--libslab/search-context-picker.c10
-rw-r--r--libslab/search-entry.c51
-rw-r--r--libslab/shell-window.c50
-rw-r--r--libslab/slab-section.c6
-rw-r--r--libslab/tile.c44
14 files changed, 285 insertions, 57 deletions
diff --git a/libslab/app-resizer.c b/libslab/app-resizer.c
index e7e3043f..17cac755 100644
--- a/libslab/app-resizer.c
+++ b/libslab/app-resizer.c
@@ -26,11 +26,16 @@
static void app_resizer_class_init (AppResizerClass *);
static void app_resizer_init (AppResizer *);
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void app_resizer_destroy (GtkObject *);
+#endif
static void app_resizer_size_allocate (GtkWidget * resizer, GtkAllocation * allocation);
-static gboolean app_resizer_paint_window (GtkWidget * widget, GdkEventExpose * event,
- AppShellData * app_data);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean app_resizer_paint_window (GtkWidget * widget, cairo_t * cr, AppShellData * app_data);
+#else
+static gboolean app_resizer_paint_window (GtkWidget * widget, GdkEventExpose * event, AppShellData * app_data);
+#endif
G_DEFINE_TYPE (AppResizer, app_resizer, GTK_TYPE_LAYOUT);
@@ -40,7 +45,9 @@ app_resizer_class_init (AppResizerClass * klass)
{
GtkWidgetClass *widget_class;
+#if !GTK_CHECK_VERSION (3, 0, 0)
((GtkObjectClass *) klass)->destroy = app_resizer_destroy;
+#endif
widget_class = GTK_WIDGET_CLASS (klass);
widget_class->size_allocate = app_resizer_size_allocate;
@@ -85,7 +92,12 @@ resize_table (GtkTable * table, gint columns, GList * launcher_list)
static void
relayout_table (GtkTable * table, GList * element_list)
{
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gint maxcols, maxrows;
+ gtk_table_get_size (GTK_TABLE (table), &maxrows, &maxcols);
+#else
gint maxcols = (GTK_TABLE (table))->ncols;
+#endif
gint row = 0, col = 0;
do
{
@@ -139,9 +151,11 @@ calculate_num_cols (AppResizer * resizer, gint avail_width)
GtkTable *table = GTK_TABLE (resizer->cached_tables_list->data);
GList *children = gtk_container_get_children (GTK_CONTAINER (table));
GtkWidget *table_element = GTK_WIDGET (children->data);
+ GtkAllocation *allocation;
g_list_free (children);
- resizer->cached_element_width = table_element->allocation.width;
+ gtk_widget_get_allocation (table_element, allocation);
+ resizer->cached_element_width = allocation->width;
resizer->cached_table_spacing = gtk_table_get_default_col_spacing (table);
}
@@ -190,11 +204,15 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
/* printf("ENTER - app_resizer_size_allocate\n"); */
AppResizer *resizer = APP_RESIZER (widget);
GtkWidget *child = GTK_WIDGET (APP_RESIZER (resizer)->child);
+ GtkAllocation *widget_allocation;
+ GtkRequisition *child_requisition;
static gboolean first_time = TRUE;
gint new_num_cols;
gint useable_area;
+ gtk_widget_get_allocation (child, widget_allocation);
+
if (first_time)
{
/* we are letting the first show be the "natural" size of the child widget so do nothing. */
@@ -202,11 +220,17 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
first_time = FALSE;
- gtk_layout_set_size (GTK_LAYOUT (resizer), child->allocation.width,
- child->allocation.height);
+ gtk_layout_set_size (GTK_LAYOUT (resizer), widget_allocation->width,
+ widget_allocation->height);
return;
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (child, child_requisition, NULL);
+#else
+ child_requisition = &child->requisition;
+#endif
+
if (!resizer->cached_tables_list) /* if everthing is currently filtered out - just return */
{
GtkAllocation child_allocation;
@@ -217,17 +241,24 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
/* We want the message to center itself and only scroll if it's bigger than the available real size. */
child_allocation.x = 0;
child_allocation.y = 0;
- child_allocation.width = MAX (allocation->width, child->requisition.width);
- child_allocation.height = MAX (allocation->height, child->requisition.height);
+ child_allocation.width = MAX (allocation->width, child_requisition->width);
+ child_allocation.height = MAX (allocation->height, child_requisition->height);
gtk_widget_size_allocate (child, &child_allocation);
gtk_layout_set_size (GTK_LAYOUT (resizer), child_allocation.width,
child_allocation.height);
return;
}
+ GtkRequisition *other_requisiton;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (resizer->cached_tables_list->data), other_requisiton, NULL);
+#else
+ other_requisiton = &GTK_WIDGET (resizer->cached_tables_list->data)->child_requisition;
+#endif
+
useable_area =
- allocation->width - (child->requisition.width -
- GTK_WIDGET (resizer->cached_tables_list->data)->requisition.width);
+ allocation->width - (child_requisition->width -
+ other_requisiton->width);
new_num_cols =
relayout_tables_if_needed (APP_RESIZER (resizer), useable_area,
resizer->cur_num_cols);
@@ -243,8 +274,8 @@ app_resizer_size_allocate (GtkWidget * widget, GtkAllocation * allocation)
if (GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate)
(*GTK_WIDGET_CLASS (app_resizer_parent_class)->size_allocate) (widget, allocation);
- gtk_layout_set_size (GTK_LAYOUT (resizer), child->allocation.width,
- child->allocation.height);
+ gtk_layout_set_size (GTK_LAYOUT (resizer), widget_allocation->width,
+ widget_allocation->height);
}
GtkWidget *
@@ -263,8 +294,11 @@ app_resizer_new (GtkVBox * child, gint initial_num_columns, gboolean homogeneous
widget->setting_style = FALSE;
widget->app_data = app_data;
- g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (app_resizer_paint_window),
- app_data);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect (G_OBJECT (widget), "draw", G_CALLBACK (app_resizer_paint_window), app_data);
+#else
+ g_signal_connect (G_OBJECT (widget), "expose-event", G_CALLBACK (app_resizer_paint_window), app_data);
+#endif
gtk_container_add (GTK_CONTAINER (widget), GTK_WIDGET (child));
widget->child = child;
@@ -272,24 +306,32 @@ app_resizer_new (GtkVBox * child, gint initial_num_columns, gboolean homogeneous
return GTK_WIDGET (widget);
}
+#if !GTK_CHECK_VERSION (3, 0, 0)
static void
app_resizer_destroy (GtkObject * obj)
{
}
+#endif
void
app_resizer_set_vadjustment_value (GtkWidget * widget, gdouble value)
{
GtkAdjustment *adjust = gtk_layout_get_vadjustment (GTK_LAYOUT (widget));
- if (value > adjust->upper - adjust->page_size)
+ gdouble upper = gtk_adjustment_get_upper (adjust);
+ gdouble page_size = gtk_adjustment_get_page_size (adjust);
+ if (value > upper - page_size)
{
- value = adjust->upper - adjust->page_size;
+ value = upper - page_size;
}
gtk_adjustment_set_value (adjust, value);
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+app_resizer_paint_window (GtkWidget * widget, cairo_t * cr, AppShellData * app_data)
+#else
app_resizer_paint_window (GtkWidget * widget, GdkEventExpose * event, AppShellData * app_data)
+#endif
{
/*
printf("ENTER - app_resizer_paint_window\n");
@@ -297,18 +339,46 @@ app_resizer_paint_window (GtkWidget * widget, GdkEventExpose * event, AppShellDa
printf("Allocation:%d, %d, %d, %d\n\n", widget->allocation.x, widget->allocation.y, widget->allocation.width, widget->allocation.height);
*/
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRectangle *rect;
+ gdk_cairo_get_clip_rectangle (cr, rect);
+
+ gdk_cairo_set_source_color (cr, gtk_widget_get_style (gtk_layout_get_bin_window (GTK_LAYOUT (widget)))->base);
+ cairo_set_line_width(cr, 1);
+
+ cairo_rectangle(cr, 0, 0, rect->width, rect->height);
+ cairo_stroke_preserve(cr);
+ cairo_fill(cr);
+
+#else
gdk_draw_rectangle (GTK_LAYOUT (widget)->bin_window,
widget->style->base_gc[GTK_STATE_NORMAL], TRUE, event->area.x, event->area.y,
event->area.width, event->area.height);
+#endif
if (app_data->selected_group)
{
GtkWidget *selected_widget = GTK_WIDGET (app_data->selected_group);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GtkAllocation *widget_allocation;
+ GtkAllocation *selected_widget_allocation;
+
+ gtk_widget_get_allocation (widget, widget_allocation);
+ gtk_widget_get_allocation (selected_widget, selected_widget_allocation);
+
+ gdk_cairo_set_source_color (cr, gtk_widget_get_style (selected_widget)->light);
+ cairo_set_line_width(cr, 1);
+
+ cairo_rectangle(cr, selected_widget_allocation->x, selected_widget_allocation->y, widget_allocation->width, selected_widget_allocation->height);
+ cairo_stroke_preserve(cr);
+ cairo_fill(cr);
+#else
gdk_draw_rectangle (selected_widget->window, /* drawing on child window and child coordinates */
selected_widget->style->light_gc[GTK_STATE_SELECTED], TRUE,
selected_widget->allocation.x, selected_widget->allocation.y,
widget->allocation.width, /* drawing with our coordinates here to draw all the way to the edge. */
selected_widget->allocation.height);
+#endif
}
return FALSE;
diff --git a/libslab/app-shell.c b/libslab/app-shell.c
index 0559d4f0..affaa8aa 100644
--- a/libslab/app-shell.c
+++ b/libslab/app-shell.c
@@ -24,7 +24,12 @@
#include <libmate-desktop/mate-desktop-item.h>
#include <gio/gio.h>
+#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
+#if GTK_CHECK_VERSION (3, 0, 0)
+#include <gdk/gdkkeysyms-compat.h>
+#define gtk_widget_hide_all gtk_widget_hide
+#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
@@ -337,7 +342,7 @@ relayout_shell_partial (gpointer user_data)
populate_groups_section (app_data);
gtk_widget_show_all (app_data->category_layout);
- gdk_window_set_cursor (app_data->shell->window, NULL);
+ gdk_window_set_cursor (gtk_widget_get_window (app_data->shell), NULL);
app_data->stop_incremental_relayout = TRUE;
return FALSE;
@@ -468,6 +473,7 @@ handle_group_clicked (Tile * tile, TileEvent * event, gpointer user_data)
{
AppShellData *app_data = (AppShellData *) user_data;
GtkWidget *section = NULL;
+ GtkAllocation *allocation;
gint clicked_pos =
GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tile), GROUP_POSITION_NUMBER_KEY));
@@ -489,7 +495,8 @@ handle_group_clicked (Tile * tile, TileEvent * event, gpointer user_data)
if (NULL != cat_data->filtered_launcher_list)
{
- total += GTK_WIDGET (cat_data->section)->allocation.height +
+ gtk_widget_get_allocation (GTK_WIDGET (cat_data->section), allocation);
+ total += allocation->height +
CATEGORY_SPACING;
}
}
@@ -557,7 +564,7 @@ handle_filter_changed_delayed (gpointer user_data)
gtk_widget_hide (app_data->category_layout);
app_data->busy_cursor =
gdk_cursor_new_for_display (gtk_widget_get_display (app_data->shell), GDK_WATCH);
- gdk_window_set_cursor (app_data->shell->window, app_data->busy_cursor);
+ gdk_window_set_cursor (gtk_widget_get_window (app_data->shell), app_data->busy_cursor);
gdk_cursor_unref (app_data->busy_cursor);
set_state (app_data, NULL);
diff --git a/libslab/application-tile.c b/libslab/application-tile.c
index c2c5ff31..5adf6b70 100644
--- a/libslab/application-tile.c
+++ b/libslab/application-tile.c
@@ -426,7 +426,7 @@ create_subheader (const gchar *desc)
gtk_widget_modify_fg (
subheader,
GTK_STATE_NORMAL,
- & subheader->style->fg [GTK_STATE_INSENSITIVE]);
+ & gtk_widget_get_style (subheader)->fg [GTK_STATE_INSENSITIVE]);
return subheader;
}
diff --git a/libslab/document-tile.c b/libslab/document-tile.c
index b2d934ae..673ab4da 100644
--- a/libslab/document-tile.c
+++ b/libslab/document-tile.c
@@ -710,7 +710,7 @@ create_subheader (const gchar *desc)
gtk_label_set_ellipsize (GTK_LABEL (subheader), PANGO_ELLIPSIZE_END);
gtk_misc_set_alignment (GTK_MISC (subheader), 0.0, 0.5);
gtk_widget_modify_fg (subheader, GTK_STATE_NORMAL,
- &subheader->style->fg[GTK_STATE_INSENSITIVE]);
+ &gtk_widget_get_style (subheader)->fg[GTK_STATE_INSENSITIVE]);
return subheader;
}
@@ -1069,6 +1069,17 @@ user_docs_trigger (Tile *tile, TileEvent *event, TileAction *action)
update_user_list_menu_item (this);
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+/*
+ * Set the DISPLAY variable, to be use by g_spawn_async.
+ */
+static void
+set_environment (gpointer display)
+{
+ g_setenv ("DISPLAY", display, TRUE);
+}
+#endif
+
static void
send_to_trigger (Tile *tile, TileEvent *event, TileAction *action)
{
@@ -1109,8 +1120,17 @@ send_to_trigger (Tile *tile, TileEvent *event, TileAction *action)
}
}
+#if GTK_CHECK_VERSION (3, 0, 0)
+ char *display;
+ display = gdk_screen_make_display_name (gtk_widget_get_screen (GTK_WIDGET (tile)));
+
+ g_spawn_async (NULL, argv, NULL, G_SPAWN_SEARCH_PATH, set_environment,
+ &display, NULL, &error);
+ g_free (display);
+#else
gdk_spawn_on_screen (gtk_widget_get_screen (GTK_WIDGET (tile)), NULL, argv, NULL,
G_SPAWN_SEARCH_PATH, NULL, NULL, NULL, &error);
+#endif
if (error)
handle_g_error (&error, "error in %s", G_STRFUNC);
diff --git a/libslab/libslab-utils.c b/libslab/libslab-utils.c
index 6e073b0e..5c553069 100644
--- a/libslab/libslab-utils.c
+++ b/libslab/libslab-utils.c
@@ -191,7 +191,11 @@ libslab_get_current_screen (void)
event = gtk_get_current_event ();
if (event) {
if (event->any.window)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ screen = gtk_window_get_screen (GTK_WINDOW (event->any.window));
+#else
screen = gdk_drawable_get_screen (GDK_DRAWABLE (event->any.window));
+#endif
gdk_event_free (event);
}
diff --git a/libslab/libslab.pc.in b/libslab/libslab.pc.in
index bbc8371c..8f341ed6 100644
--- a/libslab/libslab.pc.in
+++ b/libslab/libslab.pc.in
@@ -5,8 +5,8 @@ includedir=@includedir@
Name: libslab
Description: Beautiful App Slab
-Requires: glib-2.0 gobject-2.0 gio-2.0 gtk+-2.0 mate-desktop-2.0 libmate-menu
-Requires.private: gdk-2.0 librsvg-2.0
+Requires: glib-2.0 gobject-2.0 gio-2.0 gtk+-@GTK_API_VERSION@ mate-desktop-2.0 libmate-menu
+Requires.private: gdk-@GTK_API_VERSION@ librsvg-2.0
Version: @VERSION@
Libs: -L${libdir} -lslab
Cflags: -I${includedir}/libslab
diff --git a/libslab/mate-utils.c b/libslab/mate-utils.c
index f3c31c42..b94253ae 100644
--- a/libslab/mate-utils.c
+++ b/libslab/mate-utils.c
@@ -158,9 +158,9 @@ static void
section_header_style_set (GtkWidget * widget, GtkStyle * prev_style, gpointer user_data)
{
if (prev_style
- && widget->style->fg[GTK_STATE_SELECTED].green ==
+ && gtk_widget_get_style (widget)->fg[GTK_STATE_SELECTED].green ==
prev_style->fg[GTK_STATE_SELECTED].green)
return;
- gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &widget->style->bg[GTK_STATE_SELECTED]);
+ gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);
}
diff --git a/libslab/nameplate-tile.c b/libslab/nameplate-tile.c
index f3f45165..6e0da244 100644
--- a/libslab/nameplate-tile.c
+++ b/libslab/nameplate-tile.c
@@ -262,6 +262,9 @@ nameplate_tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
{
NameplateTile *this = NAMEPLATE_TILE (widget);
GtkImage *image;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ const gchar *name;
+#endif
(*GTK_WIDGET_CLASS (nameplate_tile_parent_class)->drag_begin) (widget, context);
@@ -270,6 +273,26 @@ nameplate_tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
image = GTK_IMAGE (this->image);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ switch (gtk_image_get_storage_type (image))
+ {
+ case GTK_IMAGE_PIXBUF:
+ if (gtk_image_get_pixbuf (image))
+ gtk_drag_set_icon_pixbuf (context, gtk_image_get_pixbuf (image), 0, 0);
+
+ break;
+
+ case GTK_IMAGE_ICON_NAME:
+ gtk_image_get_icon_name (image, name, NULL);
+ if (name)
+ gtk_drag_set_icon_name (context, name, 0, 0);
+
+ break;
+
+ default:
+ break;
+ }
+#else
switch (image->storage_type)
{
case GTK_IMAGE_PIXBUF:
@@ -287,4 +310,5 @@ nameplate_tile_drag_begin (GtkWidget * widget, GdkDragContext * context)
default:
break;
}
+#endif
}
diff --git a/libslab/search-bar.c b/libslab/search-bar.c
index 8e3f465b..750ace36 100644
--- a/libslab/search-bar.c
+++ b/libslab/search-bar.c
@@ -87,7 +87,7 @@ nld_search_bar_init (NldSearchBar * search_bar)
GtkWidget *alignment;
GtkWidget *entry;
- GTK_WIDGET_SET_FLAGS (search_bar, GTK_CAN_FOCUS);
+ gtk_widget_set_can_focus (GTK_WIDGET (search_bar), TRUE);
priv->hbox = gtk_hbox_new (FALSE, 3);
gtk_box_pack_start (GTK_BOX (search_bar), priv->hbox, TRUE, FALSE, 0);
@@ -129,7 +129,7 @@ nld_search_bar_has_focus (NldSearchBar * search_bar)
{
NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
- return GTK_WIDGET_HAS_FOCUS (GTK_WIDGET (priv->entry));
+ return gtk_widget_has_focus (GTK_WIDGET (priv->entry));
}
static void
@@ -187,7 +187,7 @@ nld_search_bar_get_show_contexts (NldSearchBar * search_bar)
{
NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
- return priv->context_picker && GTK_WIDGET_VISIBLE (priv->context_picker);
+ return priv->context_picker && gtk_widget_get_visible (GTK_WIDGET (priv->context_picker));
}
static NldSearchContextPicker *
@@ -344,7 +344,7 @@ nld_search_bar_get_context_id (NldSearchBar * search_bar)
{
NldSearchBarPrivate *priv = NLD_SEARCH_BAR_GET_PRIVATE (search_bar);
- if (priv->context_picker && GTK_WIDGET_VISIBLE (priv->context_picker))
+ if (priv->context_picker && gtk_widget_get_visible (GTK_WIDGET (priv->context_picker)))
return nld_search_context_picker_get_context (priv->context_picker);
else
return -1;
diff --git a/libslab/search-context-picker.c b/libslab/search-context-picker.c
index 449c6297..c19e5b1c 100644
--- a/libslab/search-context-picker.c
+++ b/libslab/search-context-picker.c
@@ -94,16 +94,18 @@ static void
menu_position_func (GtkMenu * menu, int *x, int *y, gboolean * push_in, gpointer picker)
{
GtkWidget *widget = GTK_WIDGET (picker);
+ GtkAllocation *allocation;
- gdk_window_get_origin (widget->window, x, y);
- *x += widget->allocation.x;
- *y += widget->allocation.y + widget->allocation.height;
+ gtk_widget_get_allocation (widget, allocation);
+ gdk_window_get_origin (gtk_widget_get_window (widget), x, y);
+ *x += allocation->x;
+ *y += allocation->y + allocation->height;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL)
{
GtkRequisition req;
gtk_widget_size_request (GTK_WIDGET (menu), &req);
- *x += widget->allocation.width - req.width;
+ *x += allocation->width - req.width;
}
*push_in = FALSE;
diff --git a/libslab/search-entry.c b/libslab/search-entry.c
index 7ef02e0e..bdab60f6 100644
--- a/libslab/search-entry.c
+++ b/libslab/search-entry.c
@@ -37,7 +37,11 @@ static void nld_search_entry_init (NldSearchEntry *);
static void nld_search_entry_finalize (GObject *);
static void nld_search_entry_realize (GtkWidget * widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean nld_search_entry_draw (GtkWidget * widget, cairo_t * cr);
+#else
static gboolean nld_search_entry_expose_event (GtkWidget * widget, GdkEventExpose * event);
+#endif
G_DEFINE_TYPE (NldSearchEntry, nld_search_entry, GTK_TYPE_ENTRY)
@@ -49,7 +53,11 @@ static void nld_search_entry_class_init (NldSearchEntryClass * nld_search_entry_
g_type_class_add_private (nld_search_entry_class, sizeof (NldSearchEntryPrivate));
widget_class->realize = nld_search_entry_realize;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = nld_search_entry_draw;
+#else
widget_class->expose_event = nld_search_entry_expose_event;
+#endif
g_obj_class->finalize = nld_search_entry_finalize;
}
@@ -87,16 +95,24 @@ nld_search_entry_realize (GtkWidget * widget)
GdkColor *gdkcolor;
char *svg, color[7];
RsvgHandle *rsvg;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRectangle text_area;
+#endif
GTK_WIDGET_CLASS (nld_search_entry_parent_class)->realize (widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+ height = text_area.height;
+#else
gdk_window_get_geometry (GTK_ENTRY (widget)->text_area, NULL, NULL, NULL, &height, NULL);
+#endif
if (height - 2 == priv->height)
return;
priv->height = height - 2;
- gdkcolor = &widget->style->fg[GTK_WIDGET_STATE (widget)];
+ gdkcolor = &gtk_widget_get_style (widget)->fg[gtk_widget_get_state (widget)];
snprintf (color, 6, "%02x%02x%02x", gdkcolor->red >> 8, gdkcolor->green >> 8,
gdkcolor->blue >> 8);
svg = g_strdup_printf (SEARCH_ENTRY_WATERMARK_SVG, color, color);
@@ -114,31 +130,52 @@ nld_search_entry_realize (GtkWidget * widget)
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+nld_search_entry_draw (GtkWidget * widget, cairo_t * cr)
+#else
nld_search_entry_expose_event (GtkWidget * widget, GdkEventExpose * event)
+#endif
{
NldSearchEntryPrivate *priv = NLD_SEARCH_ENTRY_GET_PRIVATE (widget);
+#if GTK_CHECK_VERSION (3, 0, 0)
+ GdkRectangle text_area;
+
+ gtk_entry_get_text_area (GTK_ENTRY (widget), &text_area);
+ GTK_WIDGET_CLASS (nld_search_entry_parent_class)->draw (widget, cr);
+#else
GTK_WIDGET_CLASS (nld_search_entry_parent_class)->expose_event (widget, event);
+#endif
+#if !GTK_CHECK_VERSION (3, 0, 0)
if (event->window == GTK_ENTRY (widget)->text_area)
{
+#endif
int width, height, x;
if (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR)
{
- #if GTK_CHECK_VERSION(3, 0, 0)
- width = gdk_window_get_width(event->window);
- height = gdk_window_get_height(event->window);
- #else
- gdk_drawable_get_size(event->window, &width, &height);
- #endif
+#if GTK_CHECK_VERSION(3, 0, 0)
+ width = text_area.width;
+ height = text_area.height;
+#else
+ gdk_drawable_get_size(event->window, &width, &height);
+#endif
x = width - priv->width - 1;
}
else
x = 1;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gdk_cairo_set_source_pixbuf (cr, priv->watermark, x, 1);
+ cairo_paint (cr);
+#else
gdk_draw_pixbuf (event->window, widget->style->fg_gc[GTK_WIDGET_STATE (widget)],
priv->watermark, 0, 0, x, 1, priv->width, priv->height,
GDK_RGB_DITHER_NORMAL, 0, 0);
+#endif
+
+#if !GTK_CHECK_VERSION (3, 0, 0)
}
+#endif
return FALSE;
}
diff --git a/libslab/shell-window.c b/libslab/shell-window.c
index 23656a50..3bedcc21 100644
--- a/libslab/shell-window.c
+++ b/libslab/shell-window.c
@@ -29,7 +29,11 @@ static void shell_window_init (ShellWindow *);
static void shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisition,
AppShellData * data);
+#if GTK_CHECK_VERSION (3, 0, 0)
+gboolean shell_window_paint_window (GtkWidget * widget, cairo_t * cr, gpointer data);
+#else
gboolean shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data);
+#endif
#define SHELL_WINDOW_BORDER_WIDTH 6
@@ -59,7 +63,11 @@ shell_window_new (AppShellData * app_data)
window->_hbox = GTK_BOX (gtk_hbox_new (FALSE, 0));
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (window->_hbox));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ g_signal_connect (G_OBJECT (window), "draw", G_CALLBACK (shell_window_paint_window),
+#else
g_signal_connect (G_OBJECT (window), "expose-event", G_CALLBACK (shell_window_paint_window),
+#endif
NULL);
window->resize_handler_id =
g_signal_connect (G_OBJECT (window), "size-request",
@@ -88,6 +96,13 @@ shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisiti
AppShellData * app_data)
{
gint height;
+ GtkRequisition *child_requisiton;
+
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child), child_requisiton, NULL);
+#else
+ child_requisiton = GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition;
+#endif
/*
Fixme - counting on this being called after the real size request is done.
@@ -98,15 +113,12 @@ shell_window_handle_size_request (GtkWidget * widget, GtkRequisition * requisiti
printf("right side width:%d\n", GTK_WIDGET(APP_RESIZER(app_data->category_layout)->child)->requisition.width);
*/
- requisition->width +=
- GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition.width;
+ requisition->width += child_requisiton->width;
/* use the left side as a minimum height, if the right side is taller,
use it up to SIZING_HEIGHT_PERCENT of the screen height
*/
- height =
- GTK_WIDGET (APP_RESIZER (app_data->category_layout)->child)->requisition.height +
- 10;
+ height = child_requisiton->height + 10;
if (height > requisition->height)
{
requisition->height =
@@ -131,17 +143,39 @@ shell_window_set_contents (ShellWindow * shell, GtkWidget * left_pane, GtkWidget
}
gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+shell_window_paint_window (GtkWidget * widget, cairo_t * cr, gpointer data)
+#else
shell_window_paint_window (GtkWidget * widget, GdkEventExpose * event, gpointer data)
+#endif
{
GtkWidget *left_pane, *right_pane;
+ GtkAllocation *allocation;
left_pane = SHELL_WINDOW (widget)->_left_pane;
right_pane = SHELL_WINDOW (widget)->_right_pane;
+ gtk_widget_get_allocation (left_pane, allocation);
+
/* draw left pane background */
- gtk_paint_flat_box (widget->style, widget->window, widget->state, GTK_SHADOW_NONE, NULL, widget, "",
- left_pane->allocation.x, left_pane->allocation.y, left_pane->allocation.width,
- left_pane->allocation.height);
+ gtk_paint_flat_box (
+ gtk_widget_get_style (widget),
+#if GTK_CHECK_VERSION (3, 0, 0)
+ cr,
+#else
+ gtk_widget_get_window (widget),
+#endif
+ gtk_widget_get_state (widget),
+ GTK_SHADOW_NONE,
+#if !GTK_CHECK_VERSION (3, 0, 0)
+ NULL,
+#endif
+ widget,
+ "",
+ allocation->x,
+ allocation->y,
+ allocation->width,
+ allocation->height);
return FALSE;
}
diff --git a/libslab/slab-section.c b/libslab/slab-section.c
index 6fbf7006..3235c59a 100644
--- a/libslab/slab-section.c
+++ b/libslab/slab-section.c
@@ -52,15 +52,15 @@ slab_section_set_title_color (GtkWidget * widget)
{
case Style1:
gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &widget->style->bg[GTK_STATE_SELECTED]);
+ &gtk_widget_get_style (widget)->bg[GTK_STATE_SELECTED]);
break;
case Style2:
if (SLAB_SECTION (widget)->selected)
gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &widget->style->dark[GTK_STATE_SELECTED]);
+ &gtk_widget_get_style (widget)->dark[GTK_STATE_SELECTED]);
else
gtk_widget_modify_fg (SLAB_SECTION (widget)->title, GTK_STATE_NORMAL,
- &widget->style->text[GTK_STATE_INSENSITIVE]);
+ &gtk_widget_get_style (widget)->text[GTK_STATE_INSENSITIVE]);
break;
default:
g_assert_not_reached ();
diff --git a/libslab/tile.c b/libslab/tile.c
index 870944d9..aaa4203e 100644
--- a/libslab/tile.c
+++ b/libslab/tile.c
@@ -47,7 +47,11 @@ static void tile_clicked (GtkButton *widget);
static gboolean tile_focus_in (GtkWidget *, GdkEventFocus *);
static gboolean tile_focus_out (GtkWidget *, GdkEventFocus *);
+#if GTK_CHECK_VERSION (3, 0, 0)
+static gboolean tile_draw (GtkWidget *, cairo_t *);
+#else
static gboolean tile_expose (GtkWidget *, GdkEventExpose *);
+#endif
static gboolean tile_button_release (GtkWidget *, GdkEventButton *);
static gboolean tile_key_release (GtkWidget *, GdkEventKey *);
static gboolean tile_popup_menu (GtkWidget *);
@@ -101,7 +105,11 @@ tile_class_init (TileClass * this_class)
widget_class->focus_in_event = tile_focus_in;
widget_class->focus_out_event = tile_focus_out;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ widget_class->draw = tile_draw;
+#else
widget_class->expose_event = tile_expose;
+#endif
widget_class->button_release_event = tile_button_release;
widget_class->key_release_event = tile_key_release;
widget_class->drag_begin = tile_drag_begin;
@@ -300,7 +308,7 @@ tile_enter (GtkButton * widget)
static void
tile_leave (GtkButton * widget)
{
- if (GTK_WIDGET_HAS_FOCUS (widget))
+ if (gtk_widget_has_focus (widget))
gtk_widget_set_state (GTK_WIDGET (widget), TILE_STATE_FOCUSED);
else
gtk_widget_set_state (GTK_WIDGET (widget), GTK_STATE_NORMAL);
@@ -343,20 +351,36 @@ tile_focus_out (GtkWidget * widget, GdkEventFocus * event)
}
static gboolean
+#if GTK_CHECK_VERSION (3, 0, 0)
+tile_draw (GtkWidget * widget, cairo_t * cr)
+#else
tile_expose (GtkWidget * widget, GdkEventExpose * event)
+#endif
{
/* FIXME: there ought to be a better way to prevent the focus from being rendered. */
gboolean has_focus;
gboolean retval;
- if ((has_focus = GTK_WIDGET_HAS_FOCUS (widget)))
+ if ((has_focus = gtk_widget_has_focus (widget)))
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_unset_state_flags (widget, GTK_STATE_FLAG_FOCUSED);
+#else
GTK_WIDGET_UNSET_FLAGS (widget, GTK_HAS_FOCUS);
+#endif
+#if GTK_CHECK_VERSION (3, 0, 0)
+ retval = (*GTK_WIDGET_CLASS (tile_parent_class)->draw) (widget, cr);
+#else
retval = (*GTK_WIDGET_CLASS (tile_parent_class)->expose_event) (widget, event);
+#endif
if (has_focus)
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_set_state_flags (widget, GTK_STATE_FLAG_FOCUSED, TRUE);
+#else
GTK_WIDGET_SET_FLAGS (widget, GTK_HAS_FOCUS);
+#endif
return retval;
}
@@ -414,7 +438,7 @@ tile_key_release (GtkWidget * widget, GdkEventKey * event)
{
TileEvent *tile_event;
- if (event->keyval == GDK_Return)
+ if (event->keyval == GDK_KEY_Return)
{
tile_event = g_new0 (TileEvent, 1);
tile_event->type = TILE_EVENT_ACTIVATED_KEYBOARD;
@@ -433,20 +457,26 @@ tile_popup_menu_position (GtkMenu * menu, gint * x, gint * y, gboolean * push_in
{
Tile *tile = TILE (data);
+ GtkAllocation all;
GtkRequisition req;
GtkWidget *top;
- if (!GTK_WIDGET_REALIZED (tile))
+ if (!gtk_widget_get_realized (GTK_WIDGET (tile)))
return;
+#if GTK_CHECK_VERSION (3, 0, 0)
+ gtk_widget_get_preferred_size (GTK_WIDGET (menu), &req, NULL);
+#else
gtk_widget_size_request (GTK_WIDGET (menu), &req);
+#endif
+ gtk_widget_get_allocation (GTK_WIDGET (menu), &all);
top = gtk_widget_get_toplevel (GTK_WIDGET (tile));
- gdk_window_get_origin (top->window, x, y);
+ gdk_window_get_origin (gtk_widget_get_window (top), x, y);
- *x += (top->allocation.width / 2) - (req.width / 2);
- *y += (top->allocation.height / 2) - (req.height / 2);
+ *x += (all.width / 2) - (req.width / 2);
+ *y += (all.height / 2) - (req.height / 2);
*push_in = FALSE;
}