From ec92a520965f420af7d00ad8e347f62106bbc578 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 26 Oct 2012 18:12:05 +0200 Subject: [configure] bump GTK version to 2.24.0 About time, no? --- configure.in | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/configure.in b/configure.in index 66575b65..0b7e21ce 100644 --- a/configure.in +++ b/configure.in @@ -6,7 +6,7 @@ m4_define(glib_minver, 2.25.12) m4_define(gio_minver, 2.25.0) m4_define(mate_desktop_minver, 1.5.0) m4_define(pango_minver, 1.1.2) -m4_define(gtk_minver, 2.22.0) +m4_define(gtk_minver, 2.24.0) m4_define(xml_minver, 2.4.7) m4_define(exif_minver, 0.5.12) m4_define(exempi_minver, 1.99.2) @@ -26,7 +26,7 @@ dnl --------------------------------------------------------------------------- dnl GTK library version dnl --------------------------------------------------------------------------- GTK_API_VERSION=2.0 -GTK_REQUIRED=2.22.0 +GTK_REQUIRED=2.24.0 AC_MSG_CHECKING([which gtk+ version to compile against]) AC_ARG_WITH([gtk], @@ -42,7 +42,7 @@ AC_MSG_RESULT([$with_gtk]) case "$with_gtk" in 2.0) GTK_API_VERSION=2.0 - GTK_REQUIRED=2.18.0 + GTK_REQUIRED=2.24.0 ;; 3.0) GTK_API_VERSION=3.0 GTK_REQUIRED=3.0.0 -- cgit v1.2.1 From ea7bc87871154c2239f25d84191add2d4b630022 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 31 Oct 2012 07:16:33 +0200 Subject: [eel] Use GdkRegion on GTK2, cairo_region_t on GTK3 http://git.gnome.org/browse/nautilus/commit/?id=3b671558f1d8ac1ee72e8af13d4ede6ab549a400 --- eel/eel-canvas-rect-ellipse.c | 24 +++++++++++++++--------- eel/eel-canvas.c | 8 +++++++- eel/eel-editable-label.c | 14 ++++++++++---- 3 files changed, 32 insertions(+), 14 deletions(-) diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index c637769d..b78c47a7 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -1012,9 +1012,8 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose { if ((re->fill_color & 0xff) != 255) { - GdkRectangle *rectangles; gint i, n_rectangles; - GdkRectangle draw_rect; + GdkRectangle draw_rect, rect; GdkRectangle part; draw_rect.x = cx1; @@ -1024,13 +1023,19 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose /* For alpha mode, only render the parts of the region that are actually exposed */ - gdk_region_get_rectangles (expose->region, - &rectangles, - &n_rectangles); - +#if GTK_CHECK_VERSION(3, 0, 0) + n_rectangles = cairo_region_num_rectangles (expose->region); +#else + gdk_region_get_rectangles (expose->region, &rect, &n_rectangles); +#endif for (i = 0; i < n_rectangles; i++) { - if (gdk_rectangle_intersect (&rectangles[i], +#if GTK_CHECK_VERSION(3, 0, 0) + cairo_region_get_rectangle (expose->region, i, &rect); +#else + rect = &rect[i]; +#endif + if (gdk_rectangle_intersect (&rect, &draw_rect, &part)) { @@ -1041,8 +1046,9 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose re->fill_color); } } - - g_free (rectangles); +#if !GTK_CHECK_VERSION(3, 0, 0) + g_free (rect); +#endif } else { diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index a4d6612d..43c111f6 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -73,6 +73,12 @@ #include "eel-marshal.h" +/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ +#if !GTK_CHECK_VERSION (3, 0, 0) +#define cairo_region_contains_rectangle gdk_region_rect_in +#define CAIRO_REGION_OVERLAP_OUT GDK_OVERLAP_RECTANGLE_OUT +#endif + static void eel_canvas_request_update (EelCanvas *canvas); static void group_add (EelCanvasGroup *group, EelCanvasItem *item); @@ -1553,7 +1559,7 @@ eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, child_rect.width = child->x2 - child->x1 + 1; child_rect.height = child->y2 - child->y1 + 1; - if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT) + if (cairo_region_contains_rectangle (expose->region, &child_rect) != CAIRO_REGION_OVERLAP_OUT) (* EEL_CANVAS_ITEM_GET_CLASS (child)->draw) (child, drawable, expose); } } diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 7780fe7f..2c7ea7b0 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -37,6 +37,12 @@ #include #include +/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ +#if !GTK_CHECK_VERSION (3, 0, 0) +#define cairo_region_t GdkRegion +#define cairo_region_destroy gdk_region_destroy +#endif + enum { MOVE_CURSOR, @@ -1580,7 +1586,7 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof } else /* Block cursor */ { - GdkRegion *clip; + cairo_region_t *clip; gdk_draw_rectangle (gtk_widget_get_window (widget), label->primary_cursor_gc, TRUE, xoffset + PANGO_PIXELS (strong_pos.x), @@ -1608,7 +1614,7 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof NULL); gdk_gc_set_clip_region (label->primary_cursor_gc, NULL); - gdk_region_destroy (clip); + cairo_region_destroy (clip); } } } @@ -1650,7 +1656,7 @@ eel_editable_label_expose (GtkWidget *widget, { gint range[2]; const char *text; - GdkRegion *clip; + cairo_region_t *clip; GtkStateType state; range[0] = label->selection_anchor; @@ -1695,7 +1701,7 @@ eel_editable_label_expose (GtkWidget *widget, &style->base[state]); gdk_gc_set_clip_region (style->black_gc, NULL); - gdk_region_destroy (clip); + cairo_region_destroy (clip); } else if (gtk_widget_has_focus (widget)) eel_editable_label_draw_cursor (label, x, y); -- cgit v1.2.1 From 96ce55723c4916ed17bc8c69e12b99fdac2ad6af Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 30 Oct 2012 18:51:39 +0200 Subject: [src] remove 2 unused includes --- src/caja-navigation-window-menus.c | 1 - src/file-manager/fm-properties-window.c | 1 - 2 files changed, 2 deletions(-) diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c index 5cc77308..e6454f85 100644 --- a/src/caja-navigation-window-menus.c +++ b/src/caja-navigation-window-menus.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 7ec253c0..f44b4a43 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -45,7 +45,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.1 From cd3a526a667083e24dd0d98c9b33ee42dd85f081 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 04:07:50 +0200 Subject: [general] Adds option to open new tab in tab bar context menu http://git.gnome.org/browse/nautilus/commit/?id=8598d769993843e1e6529a661fea034785ca0091 --- src/caja-navigation-window-menus.c | 33 +-------------------------------- src/caja-navigation-window-pane.c | 20 ++++++++++++++++++++ src/caja-window.c | 35 +++++++++++++++++++++++++++++++++++ src/caja-window.h | 1 + 4 files changed, 57 insertions(+), 32 deletions(-) diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c index e6454f85..825bc8a5 100644 --- a/src/caja-navigation-window-menus.c +++ b/src/caja-navigation-window-menus.c @@ -620,40 +620,9 @@ action_new_tab_callback (GtkAction *action, gpointer user_data) { CajaWindow *window; - CajaWindowSlot *current_slot; - CajaWindowSlot *new_slot; - CajaWindowOpenFlags flags; - GFile *location; - int new_slot_position; - char *scheme; window = CAJA_WINDOW (user_data); - current_slot = window->details->active_pane->active_slot; - location = caja_window_slot_get_location (current_slot); - - if (location != NULL) - { - flags = 0; - - new_slot_position = g_settings_get_enum (caja_preferences, CAJA_PREFERENCES_NEW_TAB_POSITION); - if (new_slot_position == CAJA_NEW_TAB_POSITION_END) - { - flags = CAJA_WINDOW_OPEN_SLOT_APPEND; - } - - scheme = g_file_get_uri_scheme (location); - if (!strcmp (scheme, "x-caja-search")) - { - g_object_unref (location); - location = g_file_new_for_path (g_get_home_dir ()); - } - g_free (scheme); - - new_slot = caja_window_open_slot (current_slot->pane, flags); - caja_window_set_active_slot (window, new_slot); - caja_window_slot_go_to (new_slot, location, FALSE); - g_object_unref (location); - } + caja_window_new_tab (window); } static void diff --git a/src/caja-navigation-window-pane.c b/src/caja-navigation-window-pane.c index b4b6ceaf..da71661b 100644 --- a/src/caja-navigation-window-pane.c +++ b/src/caja-navigation-window-pane.c @@ -352,6 +352,16 @@ path_bar_button_drag_begin_callback (GtkWidget *widget, GINT_TO_POINTER (FALSE)); } +static void +notebook_popup_menu_new_tab_cb (GtkMenuItem *menuitem, + gpointer user_data) +{ + CajaWindowPane *pane; + + pane = CAJA_WINDOW_PANE (user_data); + caja_window_new_tab (pane->window); +} + static void path_bar_path_set_callback (GtkWidget *widget, GFile *location, @@ -442,6 +452,16 @@ notebook_popup_menu_show (CajaNavigationWindowPane *pane, popup = gtk_menu_new(); + item = gtk_menu_item_new_with_mnemonic (_("_New Tab")); + g_signal_connect (item, "activate", + G_CALLBACK (notebook_popup_menu_new_tab_cb), + pane); + gtk_menu_shell_append (GTK_MENU_SHELL (popup), + item); + + gtk_menu_shell_append (GTK_MENU_SHELL (popup), + gtk_separator_menu_item_new ()); + item = gtk_menu_item_new_with_mnemonic (_("Move Tab _Left")); g_signal_connect (item, "activate", G_CALLBACK (notebook_popup_menu_move_left_cb), diff --git a/src/caja-window.c b/src/caja-window.c index 29830511..8e9ed5bb 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -251,6 +251,41 @@ caja_window_go_up_signal (CajaWindow *window, gboolean close_behind) return TRUE; } +void +caja_window_new_tab (CajaWindow *window) +{ + CajaWindowSlot *current_slot; + CajaWindowSlot *new_slot; + CajaWindowOpenFlags flags; + GFile *location; + int new_slot_position; + char *scheme; + + current_slot = window->details->active_pane->active_slot; + location = caja_window_slot_get_location (current_slot); + + if (location != NULL) { + flags = 0; + + new_slot_position = g_settings_get_enum (caja_preferences, CAJA_PREFERENCES_NEW_TAB_POSITION); + if (new_slot_position == CAJA_NEW_TAB_POSITION_END) { + flags = CAJA_WINDOW_OPEN_SLOT_APPEND; + } + + scheme = g_file_get_uri_scheme (location); + if (!strcmp (scheme, "x-caja-search")) { + g_object_unref (location); + location = g_file_new_for_path (g_get_home_dir ()); + } + g_free (scheme); + + new_slot = caja_window_open_slot (current_slot->pane, flags); + caja_window_set_active_slot (window, new_slot); + caja_window_slot_go_to (new_slot, location, FALSE); + g_object_unref (location); + } +} + void caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab) { diff --git a/src/caja-window.h b/src/caja-window.h index 46b0fd44..d13129a7 100644 --- a/src/caja-window.h +++ b/src/caja-window.h @@ -141,6 +141,7 @@ void caja_window_go_to_with_selection (CajaWindow *window, GFile *location, GList *new_selection); void caja_window_go_home (CajaWindow *window); +void caja_window_new_tab (CajaWindow *window); void caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab); -- cgit v1.2.1 From 550088d1a2c753fde171f8cb2d6d2fa97ddef4ea Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 11:55:38 +0200 Subject: [eel] port EelBackground to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=28b6813b77c4776b789231d3c64be3be01748608 --- eel/eel-background.c | 37 ++++++++++++------------------------- 1 file changed, 12 insertions(+), 25 deletions(-) diff --git a/eel/eel-background.c b/eel/eel-background.c index 33803f58..98c85163 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -390,7 +390,6 @@ eel_background_ensure_realized (EelBackground *background, GdkWindow *window) background->details->default_color = style->bg[GTK_STATE_NORMAL]; } - gdk_rgb_find_color (style->colormap, &(background->details->default_color)); } /* If the window size is the same as last time, don't update */ @@ -491,10 +490,8 @@ eel_background_expose (GtkWidget *widget, int window_width; int window_height; GdkPixmap *pixmap; - GdkGC *gc; - GdkGCValues gc_values; - GdkGCValuesMask value_mask; GdkWindow *widget_window; + cairo_t *cr; EelBackground *background; @@ -511,30 +508,22 @@ eel_background_expose (GtkWidget *widget, pixmap = eel_background_get_pixmap_and_color (background, widget_window, &color); + cr = gdk_cairo_create (widget_window); - if (pixmap) - { - gc_values.tile = pixmap; - gc_values.ts_x_origin = 0; - gc_values.ts_y_origin = 0; - gc_values.fill = GDK_TILED; - value_mask = GDK_GC_FILL | GDK_GC_TILE | GDK_GC_TS_X_ORIGIN | GDK_GC_TS_Y_ORIGIN; + if (pixmap) { + gdk_cairo_set_source_pixmap (cr, pixmap, 0, 0); + cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); + } else { + gdk_cairo_set_source_color (cr, &color); } - else - { - gdk_rgb_find_color (gtk_widget_get_colormap (widget), &color); - gc_values.foreground = color; - gc_values.fill = GDK_SOLID; - value_mask = GDK_GC_FILL | GDK_GC_FOREGROUND; - } - - gc = gdk_gc_new_with_values (widget_window, &gc_values, value_mask); - gdk_gc_set_clip_rectangle (gc, &event->area); + gdk_cairo_rectangle (cr, &event->area); + cairo_clip (cr); - gdk_draw_rectangle (widget_window, gc, TRUE, 0, 0, window_width, window_height); + cairo_rectangle (cr, 0, 0, window_width, window_height); + cairo_fill (cr); - g_object_unref (gc); + cairo_destroy (cr); if (pixmap) { @@ -814,8 +803,6 @@ eel_background_set_up_widget (EelBackground *background, GtkWidget *widget) style = gtk_widget_get_style (widget); - gdk_rgb_find_color (style->colormap, &color); - if (EEL_IS_CANVAS (widget)) { window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); -- cgit v1.2.1 From 51cc028ce329709ad18a1bafcfeafe09d042e1f6 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 2 Nov 2012 17:47:27 +0200 Subject: [eel] port EelCanvasRE to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=820d4088a4d1768cf7e16de3c8ec0d7ff383f473 --- eel/eel-canvas-rect-ellipse.c | 404 +++++++----------------------------------- eel/eel-canvas-rect-ellipse.h | 9 - 2 files changed, 68 insertions(+), 345 deletions(-) diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index b78c47a7..7e2a6df8 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -60,8 +60,6 @@ enum PROP_OUTLINE_COLOR, PROP_OUTLINE_COLOR_GDK, PROP_OUTLINE_COLOR_RGBA, - PROP_FILL_STIPPLE, - PROP_OUTLINE_STIPPLE, PROP_WIDTH_PIXELS, PROP_WIDTH_UNITS }; @@ -189,12 +187,6 @@ eel_canvas_re_class_init (EelCanvasREClass *klass) 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property - (gobject_class, - PROP_FILL_STIPPLE, - g_param_spec_object ("fill-stipple", NULL, NULL, - GDK_TYPE_DRAWABLE, - G_PARAM_READWRITE)); - g_object_class_install_property (gobject_class, PROP_OUTLINE_COLOR, g_param_spec_string ("outline-color", NULL, NULL, @@ -213,12 +205,6 @@ eel_canvas_re_class_init (EelCanvasREClass *klass) 0, G_MAXUINT, 0, G_PARAM_READWRITE)); g_object_class_install_property - (gobject_class, - PROP_OUTLINE_STIPPLE, - g_param_spec_object ("outline-stipple", NULL, NULL, - GDK_TYPE_DRAWABLE, - G_PARAM_READWRITE)); - g_object_class_install_property (gobject_class, PROP_WIDTH_PIXELS, g_param_spec_uint ("width-pixels", NULL, NULL, @@ -261,14 +247,6 @@ eel_canvas_re_destroy (GtkObject *object) /* remember, destroy can be run multiple times! */ - if (re->fill_stipple) - g_object_unref (re->fill_stipple); - re->fill_stipple = NULL; - - if (re->outline_stipple) - g_object_unref (re->outline_stipple); - re->outline_stipple = NULL; - if (GTK_OBJECT_CLASS (re_parent_class)->destroy) (* GTK_OBJECT_CLASS (re_parent_class)->destroy) (object); } @@ -312,60 +290,6 @@ static void get_bounds (EelCanvasRE *re, double *px1, double *py1, double *px2, *py2 += 2; } -/* Convenience function to set a GC's foreground color to the specified pixel value */ -static void -set_gc_foreground (GdkGC *gc, gulong pixel) -{ - GdkColor c; - - if (!gc) - return; - - c.pixel = pixel; - gdk_gc_set_foreground (gc, &c); -} - -/* Sets the stipple pattern for the specified gc */ -static void -set_stipple (GdkGC *gc, GdkBitmap **internal_stipple, GdkBitmap *stipple, int reconfigure) -{ - if (*internal_stipple && !reconfigure) - g_object_unref (*internal_stipple); - - *internal_stipple = stipple; - if (stipple && !reconfigure) - g_object_ref (stipple); - - if (gc) - { - if (stipple) - { - gdk_gc_set_stipple (gc, stipple); - gdk_gc_set_fill (gc, GDK_STIPPLED); - } - else - gdk_gc_set_fill (gc, GDK_SOLID); - } -} - -/* Recalculate the outline width of the rectangle/ellipse and set it in its GC */ -static void -set_outline_gc_width (EelCanvasRE *re) -{ - int width; - - if (!re->outline_gc) - return; - - if (re->width_pixels) - width = (int) re->width; - else - width = (int) (re->width * re->item.canvas->pixels_per_unit + 0.5); - - gdk_gc_set_line_attributes (re->outline_gc, width, - GDK_LINE_SOLID, GDK_CAP_PROJECTING, GDK_JOIN_MITER); -} - static void eel_canvas_re_set_fill (EelCanvasRE *re, gboolean fill_set) { @@ -396,14 +320,12 @@ eel_canvas_re_set_property (GObject *object, EelCanvasRE *re; GdkColor color = { 0, 0, 0, 0, }; GdkColor *pcolor; - int have_pixel; g_return_if_fail (object != NULL); g_return_if_fail (EEL_IS_CANVAS_RE (object)); item = EEL_CANVAS_ITEM (object); re = EEL_CANVAS_RE (object); - have_pixel = FALSE; switch (param_id) { @@ -455,12 +377,7 @@ eel_canvas_re_set_property (GObject *object, if (pcolor) { - GdkColormap *colormap; - color = *pcolor; - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - gdk_rgb_find_color (colormap, &color); - have_pixel = TRUE; } re->fill_color = ((color.red & 0xff00) << 16 | @@ -477,13 +394,6 @@ eel_canvas_re_set_property (GObject *object, #ifdef VERBOSE g_print ("re fill color = %08x\n", re->fill_color); #endif - if (have_pixel) - re->fill_pixel = color.pixel; - else - re->fill_pixel = eel_canvas_get_color_pixel (item->canvas, re->fill_color); - - set_gc_foreground (re->fill_gc, re->fill_pixel); - eel_canvas_item_request_redraw (item); break; @@ -511,13 +421,7 @@ eel_canvas_re_set_property (GObject *object, if (pcolor) { - GdkColormap *colormap; - color = *pcolor; - colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - gdk_rgb_find_color (colormap, &color); - - have_pixel = TRUE; } re->outline_color = ((color.red & 0xff00) << 16 | @@ -534,30 +438,12 @@ eel_canvas_re_set_property (GObject *object, #ifdef VERBOSE g_print ("re outline color %x %x %x\n", color.red, color.green, color.blue); #endif - if (have_pixel) - re->outline_pixel = color.pixel; - else - re->outline_pixel = eel_canvas_get_color_pixel (item->canvas, - re->outline_color); - - set_gc_foreground (re->outline_gc, re->outline_pixel); - eel_canvas_item_request_redraw (item); break; - case PROP_FILL_STIPPLE: - set_stipple (re->fill_gc, &re->fill_stipple, (GdkBitmap *) g_value_get_object (value), FALSE); - - break; - - case PROP_OUTLINE_STIPPLE: - set_stipple (re->outline_gc, &re->outline_stipple, (GdkBitmap *) g_value_get_object (value), FALSE); - break; - case PROP_WIDTH_PIXELS: re->width = g_value_get_uint (value); re->width_pixels = TRUE; - set_outline_gc_width (re); eel_canvas_item_request_update (item); break; @@ -565,7 +451,6 @@ eel_canvas_re_set_property (GObject *object, case PROP_WIDTH_UNITS: re->width = fabs (g_value_get_double (value)); re->width_pixels = FALSE; - set_outline_gc_width (re); eel_canvas_item_request_update (item); break; @@ -583,10 +468,14 @@ static void get_color_value (EelCanvasRE *re, gulong pixel, GValue *value) { GdkColor color; - EelCanvasItem *item = (EelCanvasItem *) re; - GdkColormap *colormap = gtk_widget_get_colormap (GTK_WIDGET (item->canvas)); - gdk_colormap_query_color (colormap, pixel, &color); + color.red = (pixel >> 16) & 0xFF; + color.green = (pixel >> 8) & 0xFF; + color.blue = pixel & 0xFF; + color.red |= color.red << 8; + color.green |= color.green << 8; + color.blue |= color.blue << 8; + g_value_set_boxed (value, &color); } @@ -622,11 +511,11 @@ eel_canvas_re_get_property (GObject *object, break; case PROP_FILL_COLOR_GDK: - get_color_value (re, re->fill_pixel, value); + get_color_value (re, re->fill_color, value); break; case PROP_OUTLINE_COLOR_GDK: - get_color_value (re, re->outline_pixel, value); + get_color_value (re, re->outline_color, value); break; case PROP_FILL_COLOR_RGBA: @@ -637,30 +526,12 @@ eel_canvas_re_get_property (GObject *object, g_value_set_uint (value, re->outline_color); break; - case PROP_FILL_STIPPLE: - g_value_set_object (value, (GObject *) re->fill_stipple); - break; - - case PROP_OUTLINE_STIPPLE: - g_value_set_object (value, (GObject *) re->outline_stipple); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; } } -static void -set_colors_and_stipples (EelCanvasRE *re) -{ - set_gc_foreground (re->fill_gc, re->fill_pixel); - set_gc_foreground (re->outline_gc, re->outline_pixel); - set_stipple (re->fill_gc, &re->fill_stipple, re->fill_stipple, TRUE); - set_stipple (re->outline_gc, &re->outline_stipple, re->outline_stipple, TRUE); - set_outline_gc_width (re); -} - static void eel_canvas_re_update_shared (EelCanvasItem *item, double i2w_dx, double i2w_dy, int flags) { @@ -674,8 +545,6 @@ eel_canvas_re_update_shared (EelCanvasItem *item, double i2w_dx, double i2w_dy, if (re_parent_class->update) (* re_parent_class->update) (item, i2w_dx, i2w_dy, flags); - set_colors_and_stipples (re); - #ifdef OLD_XFORM recalc_bounds (re); #endif @@ -694,12 +563,6 @@ eel_canvas_re_realize (EelCanvasItem *item) if (re_parent_class->realize) (* re_parent_class->realize) (item); - re->fill_gc = gdk_gc_new (gtk_layout_get_bin_window (&item->canvas->layout)); - re->fill_pixel = eel_canvas_get_color_pixel (item->canvas, re->fill_color); - re->outline_gc = gdk_gc_new (gtk_layout_get_bin_window (&item->canvas->layout)); - re->outline_pixel = eel_canvas_get_color_pixel (item->canvas, re->outline_color); - set_colors_and_stipples (re); - #ifdef OLD_XFORM (* EEL_CANVAS_ITEM_CLASS (item->object.klass)->update) (item, NULL, NULL, 0); #endif @@ -712,11 +575,6 @@ eel_canvas_re_unrealize (EelCanvasItem *item) re = EEL_CANVAS_RE (item); - g_object_unref (re->fill_gc); - re->fill_gc = NULL; - g_object_unref (re->outline_gc); - re->outline_gc = NULL; - if (re_parent_class->unrealize) (* re_parent_class->unrealize) (item); } @@ -883,112 +741,21 @@ eel_canvas_rect_realize (EelCanvasItem *item) static void -render_rect_alpha (EelCanvasRect *rect, - GdkDrawable *drawable, - int x, int y, - int width, int height, - guint32 rgba) +eel_canvas_set_source_color (cairo_t *cr, + guint rgba) { - GdkPixbuf *pixbuf; - guchar *data; - int rowstride, i; - guchar r, g, b, a; - EelCanvasRectPrivate *priv; - - if (width <= 0 || height <= 0 ) - { - return; - } - - priv = rect->priv; - - r = (rgba >> 24) & 0xff; - g = (rgba >> 16) & 0xff; - b = (rgba >> 8) & 0xff; - a = (rgba >> 0) & 0xff; - -#ifdef HAVE_RENDER - /* Every visual is not guaranteed to have a matching - * XRenderPictFormat. So make sure that format is not null before - * trying to render using Xrender calls. - */ - if (priv->use_render && (priv->format != NULL)) - { - GdkDrawable *real_drawable; - int x_offset, y_offset; - - Display *dpy; - Picture pict; - XRenderPictureAttributes attributes; - XRenderColor color; - - gdk_window_get_internal_paint_info (drawable, &real_drawable, - &x_offset, &y_offset); - - dpy = gdk_x11_drawable_get_xdisplay (real_drawable); - - pict = XRenderCreatePicture (dpy, - gdk_x11_drawable_get_xid (real_drawable), - priv->format, - 0, - &attributes); - - - /* Convert to premultiplied alpha: */ - r = r * a / 255; - g = g * a / 255; - b = b * a / 255; - - color.red = (r << 8) + r; - color.green = (g << 8) + g; - color.blue = (b << 8) + b; - color.alpha = (a << 8) + a; - - XRenderFillRectangle (dpy, - PictOpOver, - pict, - &color, - x - x_offset, y - y_offset, - width, height); - - XRenderFreePicture (dpy, pict); - - return; - } -#endif - pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8, width, height); - data = gdk_pixbuf_get_pixels (pixbuf); - rowstride = gdk_pixbuf_get_rowstride (pixbuf); - - r = (rgba >> 24) & 0xff; - g = (rgba >> 16) & 0xff; - b = (rgba >> 8) & 0xff; - a = (rgba >> 0) & 0xff; - - for (i = 0; i < width*4; ) - { - data[i++] = r; - data[i++] = g; - data[i++] = b; - data[i++] = a; - } - - for (i = 1; i < height; i++) - { - memcpy (data + i*rowstride, data, width*4); - } - - gdk_draw_pixbuf (drawable, NULL, pixbuf, - 0, 0, x, y, width, height, - GDK_RGB_DITHER_NONE, 0, 0); - g_object_unref (pixbuf); + cairo_set_source_rgba (cr, + ((rgba >> 24) & 0xff) / 255., + ((rgba >> 16) & 0xff) / 255., + ((rgba >> 8) & 0xff) / 255., + ((rgba >> 0) & 0xff) / 255.); } - static void eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) { EelCanvasRE *re; + cairo_t *cr; double x1, y1, x2, y2; int cx1, cy1, cx2, cy2; double i2w_dx, i2w_dy; @@ -1008,75 +775,41 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose eel_canvas_w2c (item->canvas, x1, y1, &cx1, &cy1); eel_canvas_w2c (item->canvas, x2, y2, &cx2, &cy2); + if (cx2 <= cx1 || cy2 <= cy1 ) { + return; + } + + cr = gdk_cairo_create (drawable); + gdk_cairo_region (cr, expose->region); + cairo_clip (cr); + if (re->fill_set) { - if ((re->fill_color & 0xff) != 255) - { - gint i, n_rectangles; - GdkRectangle draw_rect, rect; - GdkRectangle part; - - draw_rect.x = cx1; - draw_rect.y = cy1; - draw_rect.width = cx2 - cx1 + 1; - draw_rect.height = cy2 - cy1 + 1; - - /* For alpha mode, only render the parts of the region - that are actually exposed */ -#if GTK_CHECK_VERSION(3, 0, 0) - n_rectangles = cairo_region_num_rectangles (expose->region); -#else - gdk_region_get_rectangles (expose->region, &rect, &n_rectangles); -#endif - for (i = 0; i < n_rectangles; i++) - { -#if GTK_CHECK_VERSION(3, 0, 0) - cairo_region_get_rectangle (expose->region, i, &rect); -#else - rect = &rect[i]; -#endif - if (gdk_rectangle_intersect (&rect, - &draw_rect, - &part)) - { - render_rect_alpha (EEL_CANVAS_RECT (item), - drawable, - part.x, part.y, - part.width, part.height, - re->fill_color); - } - } -#if !GTK_CHECK_VERSION(3, 0, 0) - g_free (rect); -#endif - } - else - { - if (re->fill_stipple) - eel_canvas_set_stipple_origin (item->canvas, re->fill_gc); - - gdk_draw_rectangle (drawable, - re->fill_gc, - TRUE, - cx1, cy1, - cx2 - cx1 + 1, - cy2 - cy1 + 1); - } + eel_canvas_set_source_color (cr, re->fill_color); + cairo_rectangle (cr, + cx1, cy1, + cx2 - cx1 + 1, + cy2 - cy1 + 1); + cairo_fill (cr); } if (re->outline_set) { - if (re->outline_stipple) - eel_canvas_set_stipple_origin (item->canvas, re->outline_gc); - - gdk_draw_rectangle (drawable, - re->outline_gc, - FALSE, - cx1, - cy1, - cx2 - cx1, - cy2 - cy1); + eel_canvas_set_source_color (cr, re->outline_color); + if (re->width_pixels) { + cairo_set_line_width (cr, (int) re->width); + } else { + cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5)); + } + + cairo_rectangle (cr, + cx1 + 0.5, cy1 + 0.5, + cx2 - cx1, + cy2 - cy1); + cairo_stroke (cr); } + + cairo_destroy (cr); } static double @@ -1325,6 +1058,7 @@ eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExp EelCanvasRE *re; int x1, y1, x2, y2; double i2w_dx, i2w_dy; + cairo_t *cr; re = EEL_CANVAS_RE (item); @@ -1343,37 +1077,35 @@ eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExp re->y2 + i2w_dy, &x2, &y2); + cr = gdk_cairo_create (drawable); + gdk_cairo_region (cr, expose->region); + cairo_clip (cr); + + cairo_save (cr); + cairo_translate (cr, (x1 + x2) / 2., (y1 + y2) / 2.); + cairo_scale (cr, (x2 - x1), (y2 - y1)); + cairo_arc (cr, 0, 0, 1, 0, 2 * G_PI); + cairo_restore (cr); + if (re->fill_set) { - if (re->fill_stipple) - eel_canvas_set_stipple_origin (item->canvas, re->fill_gc); - - gdk_draw_arc (drawable, - re->fill_gc, - TRUE, - x1, - y1, - x2 - x1, - y2 - y1, - 0 * 64, - 360 * 64); + eel_canvas_set_source_color (cr, re->fill_color); + cairo_fill_preserve (cr); } if (re->outline_set) { - if (re->outline_stipple) - eel_canvas_set_stipple_origin (item->canvas, re->outline_gc); - - gdk_draw_arc (drawable, - re->outline_gc, - FALSE, - x1, - y1, - x2 - x1, - y2 - y1, - 0 * 64, - 360 * 64); + eel_canvas_set_source_color (cr, re->outline_color); + if (re->width_pixels) { + cairo_set_line_width (cr, (int) re->width); + } else { + cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5)); + } + + cairo_stroke_preserve (cr); } + + cairo_destroy (cr); } static double diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h index eb78bf1a..7166df8f 100644 --- a/eel/eel-canvas-rect-ellipse.h +++ b/eel/eel-canvas-rect-ellipse.h @@ -81,15 +81,6 @@ extern "C" { { EelCanvasItem item; - GdkBitmap *fill_stipple; /* Stipple for fill */ - GdkBitmap *outline_stipple; /* Stipple for outline */ - - GdkGC *fill_gc; /* GC for filling */ - GdkGC *outline_gc; /* GC for outline */ - - gulong fill_pixel; /* Fill color */ - gulong outline_pixel; /* Outline color */ - double x1, y1, x2, y2; /* Corners of item */ double width; /* Outline width */ -- cgit v1.2.1 From adfba98c507fd731a96a0551176050b697c14379 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 12:26:02 +0200 Subject: [eel] port EelCanvas to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=759f3401bee333caf6d0ae6ae9820cdadda440e4 --- eel/eel-canvas.c | 77 +++++++------------------------------------------------- eel/eel-canvas.h | 13 ---------- 2 files changed, 9 insertions(+), 81 deletions(-) diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 43c111f6..7b1b39dd 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -2367,8 +2367,6 @@ eel_canvas_realize (GtkWidget *widget) /* Create our own temporary pixmap gc and realize all the items */ - canvas->pixmap_gc = gdk_gc_new (gtk_layout_get_bin_window (&canvas->layout)); - (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->realize) (canvas->root); } @@ -2388,9 +2386,6 @@ eel_canvas_unrealize (GtkWidget *widget) (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->unrealize) (canvas->root); - g_object_unref (canvas->pixmap_gc); - canvas->pixmap_gc = NULL; - if (GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (* GTK_WIDGET_CLASS (canvas_parent_class)->unrealize) (widget); } @@ -3067,14 +3062,16 @@ static void eel_canvas_draw_background (EelCanvas *canvas, int x, int y, int width, int height) { + cairo_t *cr; + + cr = gdk_cairo_create (gtk_layout_get_bin_window (&canvas->layout)); + /* By default, we use the style background. */ - gdk_gc_set_foreground (canvas->pixmap_gc, - >k_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]); - gdk_draw_rectangle (gtk_layout_get_bin_window (&canvas->layout), - canvas->pixmap_gc, - TRUE, - x, y, - width, height); + gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]); + cairo_rectangle (cr, x, y, width, height); + cairo_fill (cr); + + cairo_destroy (cr); } static void @@ -3685,8 +3682,6 @@ eel_canvas_world_to_window (EelCanvas *canvas, double worldx, double worldy, int eel_canvas_get_color (EelCanvas *canvas, const char *spec, GdkColor *color) { - GdkColormap *colormap; - g_return_val_if_fail (EEL_IS_CANVAS (canvas), FALSE); g_return_val_if_fail (color != NULL, FALSE); @@ -3701,63 +3696,9 @@ eel_canvas_get_color (EelCanvas *canvas, const char *spec, GdkColor *color) gdk_color_parse (spec, color); - colormap = gtk_widget_get_colormap (GTK_WIDGET (canvas)); - - gdk_rgb_find_color (colormap, color); - return TRUE; } -/** - * eel_canvas_get_color_pixel: - * @canvas: A canvas. - * @rgba: RGBA color specification. - * - * Allocates a color from the RGBA value passed into this function. The alpha - * opacity value is discarded, since normal X colors do not support it. - * - * Return value: Allocated pixel value corresponding to the specified color. - **/ -gulong -eel_canvas_get_color_pixel (EelCanvas *canvas, guint rgba) -{ - GdkColormap *colormap; - GdkColor color; - - g_return_val_if_fail (EEL_IS_CANVAS (canvas), 0); - - color.red = ((rgba & 0xff000000) >> 16) + ((rgba & 0xff000000) >> 24); - color.green = ((rgba & 0x00ff0000) >> 8) + ((rgba & 0x00ff0000) >> 16); - color.blue = (rgba & 0x0000ff00) + ((rgba & 0x0000ff00) >> 8); - color.pixel = 0; - - colormap = gtk_widget_get_colormap (GTK_WIDGET (canvas)); - - gdk_rgb_find_color (colormap, &color); - - return color.pixel; -} - - -/* FIXME: This function is not useful anymore */ -/** - * eel_canvas_set_stipple_origin: - * @canvas: A canvas. - * @gc: GC on which to set the stipple origin. - * - * Sets the stipple origin of the specified GC as is appropriate for the canvas, - * so that it will be aligned with other stipple patterns used by canvas items. - * This is typically only needed by item implementations. - **/ -void -eel_canvas_set_stipple_origin (EelCanvas *canvas, GdkGC *gc) -{ - g_return_if_fail (EEL_IS_CANVAS (canvas)); - g_return_if_fail (GDK_IS_GC (gc)); - - gdk_gc_set_ts_origin (gc, 0, 0); -} - static gboolean boolean_handled_accumulator (GSignalInvocationHint *ihint, GValue *return_accu, diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index 2f799c39..453cdaee 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -372,9 +372,6 @@ extern "C" { /* If non-NULL, the currently focused item */ EelCanvasItem *focused_item; - /* GC for temporary draw pixmap */ - GdkGC *pixmap_gc; - /* Event on which selection of current item is based */ GdkEvent pick_event; @@ -527,16 +524,6 @@ extern "C" { */ int eel_canvas_get_color (EelCanvas *canvas, const char *spec, GdkColor *color); - /* Allocates a color from the RGB value passed into this function. */ - gulong eel_canvas_get_color_pixel (EelCanvas *canvas, - guint rgba); - - - /* Sets the stipple origin of the specified gc so that it will be aligned with - * all the stipples used in the specified canvas. This is intended for use only - * by canvas item implementations. - */ - void eel_canvas_set_stipple_origin (EelCanvas *canvas, GdkGC *gc); #ifdef __cplusplus } -- cgit v1.2.1 From e68ea5c0a9cd2f4f1d88cc9fd38f1e80b2399291 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 12:31:22 +0200 Subject: [eel] port eel-debug-drawing to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=e716f82eea847e5298d773e2689642813db3d36e --- eel/eel-debug-drawing.c | 53 ++++++++++++++++++------------------------------- 1 file changed, 19 insertions(+), 34 deletions(-) diff --git a/eel/eel-debug-drawing.c b/eel/eel-debug-drawing.c index 50ea70a4..6c98748a 100644 --- a/eel/eel-debug-drawing.c +++ b/eel/eel-debug-drawing.c @@ -184,13 +184,9 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event) eel_gdk_pixbuf_draw_to_drawable (viewer->pixbuf, event->window, - gtk_widget_get_style (widget)->white_gc, clipped_bounds.x0 - bounds.x0, clipped_bounds.y0 - bounds.y0, - clipped_bounds, - GDK_RGB_DITHER_NONE, - GDK_PIXBUF_ALPHA_BILEVEL, - EEL_STANDARD_ALPHA_THRESHHOLD); + clipped_bounds); } } @@ -229,7 +225,7 @@ eel_debug_draw_rectangle_and_cross (GdkDrawable *drawable, guint32 color, gboolean draw_cross) { - GdkGC *gc; + cairo_t *cr; GdkColor color_gdk = { 0 }; int width; @@ -241,43 +237,32 @@ eel_debug_draw_rectangle_and_cross (GdkDrawable *drawable, width = rectangle.x1 - rectangle.x0; height = rectangle.y1 - rectangle.y0; - gc = gdk_gc_new (drawable); - gdk_gc_set_function (gc, GDK_COPY); + cr = gdk_cairo_create (drawable); color_gdk.red = ((color >> 16) & 0xff) << 8; color_gdk.green = ((color >> 8) & 0xff) << 8; color_gdk.blue = ((color ) & 0xff) << 8; - gdk_colormap_alloc_color ( - gdk_drawable_get_colormap (drawable), - &color_gdk, FALSE, FALSE); - gdk_gc_set_rgb_fg_color (gc, &color_gdk); - - gdk_draw_rectangle (drawable, - gc, - FALSE, - rectangle.x0, - rectangle.y0, - width - 1, - height - 1); + gdk_cairo_set_source_color (cr, &color_gdk); + cairo_set_line_width (cr, 1.0); + + cairo_rectangle (cr, + rectangle.x0 + 0.5, + rectangle.y0 + 0.5, + width, + height); if (draw_cross) { - gdk_draw_line (drawable, - gc, - rectangle.x0, - rectangle.y0, - rectangle.x0 + width - 1, - rectangle.y0 + height - 1); - - gdk_draw_line (drawable, - gc, - rectangle.x0 + width - 1, - rectangle.y0, - rectangle.x0, - rectangle.y0 + height - 1); + cairo_move_to (cr, rectangle.x0, rectangle.y0); + cairo_line_to (cr, rectangle.x0 + width, rectangle.y0 + height); + + cairo_move_to (cr, rectangle.x0 + width, rectangle.y0); + cairo_line_to (cr, rectangle.x0, rectangle.y0 + height); } - g_object_unref (gc); + cairo_stroke (cr); + + cairo_destroy (cr); } /** -- cgit v1.2.1 From 0fdc303dd11b419465d299b36307010ce3221cfa Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 13:12:33 +0200 Subject: [eel] port EelEditableLabel to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=6cb78fb15c89e53e60ee54dc8b773db6ca0def73 --- eel/eel-editable-label.c | 221 ++++++++++------------------------------------- eel/eel-editable-label.h | 3 - 2 files changed, 48 insertions(+), 176 deletions(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 2c7ea7b0..fb20af85 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -182,10 +182,6 @@ static void editable_real_set_position (GtkEditable *editable, gint position); static gint editable_get_position (GtkEditable *editable); -static GdkGC * make_cursor_gc (GtkWidget *widget, - const gchar *property_name, - GdkColor *fallback); - G_DEFINE_TYPE_WITH_CODE (EelEditableLabel, eel_editable_label, GTK_TYPE_MISC, G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, eel_editable_label_editable_init)); @@ -1169,7 +1165,6 @@ eel_editable_label_style_set (GtkWidget *widget, GtkStyle *previous_style) { EelEditableLabel *label; - static GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 }; g_assert (EEL_IS_EDITABLE_LABEL (widget)); @@ -1187,26 +1182,6 @@ eel_editable_label_style_set (GtkWidget *widget, style = gtk_widget_get_style (widget); gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]); - - if (label->primary_cursor_gc != NULL) - { - gtk_gc_release (label->primary_cursor_gc); - label->primary_cursor_gc = NULL; - } - - if (label->secondary_cursor_gc != NULL) - { - gtk_gc_release (label->secondary_cursor_gc); - label->secondary_cursor_gc = NULL; - } - - label->primary_cursor_gc = make_cursor_gc (widget, - "cursor-color", - &style->black); - - label->secondary_cursor_gc = make_cursor_gc (widget, - "secondary-cursor-color", - &gray); } } @@ -1409,96 +1384,6 @@ eel_editable_label_get_block_cursor_location (EelEditableLabel *label, /* These functions are copies from gtk+, as they are not exported from gtk+ */ -static GdkGC * -make_cursor_gc (GtkWidget *widget, - const gchar *property_name, - GdkColor *fallback) -{ - GdkGCValues gc_values; - GdkGCValuesMask gc_values_mask; - GdkColor *cursor_color; - GtkStyle *style; - - style = gtk_widget_get_style (widget); - gtk_widget_style_get (widget, property_name, &cursor_color, NULL); - - gc_values_mask = GDK_GC_FOREGROUND; - if (cursor_color) - { - gc_values.foreground = *cursor_color; - gdk_color_free (cursor_color); - } - else - gc_values.foreground = *fallback; - - gdk_rgb_find_color (style->colormap, &gc_values.foreground); - return gtk_gc_get (style->depth, style->colormap, &gc_values, gc_values_mask); -} - -static void -_eel_draw_insertion_cursor (GtkWidget *widget, - GdkDrawable *drawable, - GdkGC *gc, - GdkRectangle *location, - GtkTextDirection direction, - gboolean draw_arrow) -{ - gint stem_width; - gint arrow_width; - gint x, y; - gint i; - gfloat cursor_aspect_ratio; - gint offset; - - g_assert (direction != GTK_TEXT_DIR_NONE); - - gtk_widget_style_get (widget, "cursor-aspect-ratio", &cursor_aspect_ratio, NULL); - - stem_width = location->height * cursor_aspect_ratio + 1; - arrow_width = stem_width + 1; - - /* put (stem_width % 2) on the proper side of the cursor */ - if (direction == GTK_TEXT_DIR_LTR) - offset = stem_width / 2; - else - offset = stem_width - stem_width / 2; - - for (i = 0; i < stem_width; i++) - gdk_draw_line (drawable, gc, - location->x + i - offset, location->y, - location->x + i - offset, location->y + location->height - 1); - - if (draw_arrow) - { - if (direction == GTK_TEXT_DIR_RTL) - { - x = location->x - offset - 1; - y = location->y + location->height - arrow_width * 2 - arrow_width + 1; - - for (i = 0; i < arrow_width; i++) - { - gdk_draw_line (drawable, gc, - x, y + i + 1, - x, y + 2 * arrow_width - i - 1); - x --; - } - } - else if (direction == GTK_TEXT_DIR_LTR) - { - x = location->x + stem_width - offset; - y = location->y + location->height - arrow_width * 2 - arrow_width + 1; - - for (i = 0; i < arrow_width; i++) - { - gdk_draw_line (drawable, gc, - x, y + i + 1, - x, y + 2 * arrow_width - i - 1); - x++; - } - } - } -} - static void eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yoffset) { @@ -1567,10 +1452,9 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof cursor_location.width = 0; cursor_location.height = PANGO_PIXELS (cursor1->height); - _eel_draw_insertion_cursor (widget, gtk_widget_get_window (widget), - label->primary_cursor_gc, - &cursor_location, dir1, - dir2 != GTK_TEXT_DIR_NONE); + gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget), + NULL, &cursor_location, + TRUE, dir1, dir2 != GTK_TEXT_DIR_NONE); if (dir2 != GTK_TEXT_DIR_NONE) { @@ -1579,43 +1463,47 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof cursor_location.width = 0; cursor_location.height = PANGO_PIXELS (cursor2->height); - _eel_draw_insertion_cursor (widget, gtk_widget_get_window (widget), - label->secondary_cursor_gc, - &cursor_location, dir2, TRUE); + gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget), + NULL, &cursor_location, + FALSE, dir1, TRUE); } } else /* Block cursor */ { cairo_region_t *clip; + cairo_t *cr; - gdk_draw_rectangle (gtk_widget_get_window (widget), label->primary_cursor_gc, TRUE, - xoffset + PANGO_PIXELS (strong_pos.x), - yoffset + PANGO_PIXELS (strong_pos.y), - PANGO_PIXELS (strong_pos.width), - PANGO_PIXELS (strong_pos.height)); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_rectangle (cr, + xoffset + PANGO_PIXELS (strong_pos.x), + yoffset + PANGO_PIXELS (strong_pos.y), + PANGO_PIXELS (strong_pos.width), + PANGO_PIXELS (strong_pos.height)); if (!block_at_line_end) { clip = gdk_pango_layout_get_clip_region (label->layout, - xoffset, yoffset, - range, 1); + xoffset, yoffset, + range, 1); + + gdk_cairo_region (cr, clip); + cairo_clip (cr); /* FIXME should use gtk_paint, but it can't use a clip * region */ - gdk_gc_set_clip_region (label->primary_cursor_gc, clip); + gdk_cairo_set_source_color (cr, + >k_widget_get_style (widget)->base[GTK_STATE_NORMAL]); + cairo_move_to (cr, xoffset, yoffset); + pango_cairo_show_layout (cr, label->layout); - gdk_draw_layout_with_colors (gtk_widget_get_window (widget), - label->primary_cursor_gc, - xoffset, yoffset, - label->layout, - >k_widget_get_style (widget)->base[GTK_STATE_NORMAL], - NULL); - - gdk_gc_set_clip_region (label->primary_cursor_gc, NULL); cairo_region_destroy (clip); } + + cairo_destroy (cr); } } } @@ -1658,6 +1546,7 @@ eel_editable_label_expose (GtkWidget *widget, const char *text; cairo_region_t *clip; GtkStateType state; + cairo_t *cr; range[0] = label->selection_anchor; range[1] = label->selection_end; @@ -1677,30 +1566,26 @@ eel_editable_label_expose (GtkWidget *widget, range[1] = tmp; } + cr = gdk_cairo_create (gtk_widget_get_window (widget)); clip = gdk_pango_layout_get_clip_region (label->layout, x, y, range, 1); - - /* FIXME should use gtk_paint, but it can't use a clip - * region - */ - - gdk_gc_set_clip_region (style->black_gc, clip); - + gdk_cairo_region (cr, clip); + cairo_clip (cr); state = GTK_STATE_SELECTED; if (!gtk_widget_has_focus (widget)) state = GTK_STATE_ACTIVE; - gdk_draw_layout_with_colors (gtk_widget_get_window (widget), - style->black_gc, - x, y, - label->layout, - &style->text[state], - &style->base[state]); + gdk_cairo_set_source_color (cr, &style->base[state]); + cairo_paint (cr); + + gdk_cairo_set_source_color (cr, &style->text[state]); + cairo_move_to (cr, x, y); + pango_cairo_show_layout (cr, label->layout); - gdk_gc_set_clip_region (style->black_gc, NULL); + cairo_destroy (cr); cairo_region_destroy (clip); } else if (gtk_widget_has_focus (widget)) @@ -1709,13 +1594,18 @@ eel_editable_label_expose (GtkWidget *widget, if (label->draw_outline) { GtkAllocation allocation; + cairo_t *cr; + gtk_widget_get_allocation (widget, &allocation); - gdk_draw_rectangle (gtk_widget_get_window (widget), - style->text_gc [gtk_widget_get_state (widget)], - FALSE, - 0, 0, - allocation.width - 1, - allocation.height - 1); + cr = gdk_cairo_create (gtk_widget_get_window (widget)); + gdk_cairo_set_source_color (cr, &style->text [gtk_widget_get_state (widget)]); + cairo_set_line_width (cr, 1.0); + cairo_rectangle (cr, 0.5, 0.5, + allocation.width - 1, + allocation.height - 1); + cairo_stroke (cr); + + cairo_destroy (cr); } } @@ -1728,7 +1618,6 @@ eel_editable_label_realize (GtkWidget *widget) EelEditableLabel *label; GdkWindowAttr attributes; gint attributes_mask; - static GdkColor gray = { 0, 0x8888, 0x8888, 0x8888 }; GtkAllocation allocation; GdkWindow *window; GtkStyle *style; @@ -1772,14 +1661,6 @@ eel_editable_label_realize (GtkWidget *widget) gdk_window_set_background (gtk_widget_get_window (widget), &style->base[gtk_widget_get_state (widget)]); gtk_im_context_set_client_window (label->im_context, gtk_widget_get_window (widget)); - - label->primary_cursor_gc = make_cursor_gc (widget, - "cursor-color", - &style->black); - - label->secondary_cursor_gc = make_cursor_gc (widget, - "secondary-cursor-color", - &gray); } static void @@ -1789,12 +1670,6 @@ eel_editable_label_unrealize (GtkWidget *widget) label = EEL_EDITABLE_LABEL (widget); - gtk_gc_release (label->primary_cursor_gc); - label->primary_cursor_gc = NULL; - - gtk_gc_release (label->secondary_cursor_gc); - label->secondary_cursor_gc = NULL; - /* Strange. Copied from GtkEntry, should be NULL? */ gtk_im_context_set_client_window (label->im_context, NULL); diff --git a/eel/eel-editable-label.h b/eel/eel-editable-label.h index 249a3367..b19c2417 100644 --- a/eel/eel-editable-label.h +++ b/eel/eel-editable-label.h @@ -79,9 +79,6 @@ extern "C" { int preedit_length; /* length of preedit string, in bytes */ int preedit_cursor; /* offset of cursor within preedit string, in chars */ - GdkGC *primary_cursor_gc; - GdkGC *secondary_cursor_gc; - PangoFontDescription *font_desc; }; -- cgit v1.2.1 From 92ff8b1860812a2cb58bfb492765b109411d8fd5 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 13:22:16 +0200 Subject: [eel] port eel-gdk-extensions to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=917a27a6f69509720fadd0d50e40dbc87ae9f5d2 --- eel/eel-gdk-extensions.c | 92 ++++++++---------------------------------------- eel/eel-gdk-extensions.h | 5 --- 2 files changed, 14 insertions(+), 83 deletions(-) diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index 86a8600e..ab3972ef 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -538,59 +538,6 @@ eel_gdk_color_is_dark (GdkColor *color) return intensity < 128; } -/** - * eel_stipple_bitmap_for_screen: - * - * Get pointer to 50% stippled bitmap suitable for use - * on @screen. This is a global object; do not free. - */ -GdkBitmap * -eel_stipple_bitmap_for_screen (GdkScreen *screen) -{ - static char stipple_bits[] = { 0x02, 0x01 }; - static GPtrArray *stipples = NULL; - int screen_num, n_screens, i; - - if (stipples == NULL) - { - n_screens = gdk_display_get_n_screens ( - gdk_screen_get_display (screen)); - stipples = g_ptr_array_sized_new (n_screens); - - for (i = 0; i < n_screens; i++) - { - g_ptr_array_index (stipples, i) = NULL; - } - } - - screen_num = gdk_screen_get_number (screen); - - if (g_ptr_array_index (stipples, screen_num) == NULL) - { - g_ptr_array_index (stipples, screen_num) = - gdk_bitmap_create_from_data ( - gdk_screen_get_root_window (screen), - stipple_bits, 2, 2); - } - - return g_ptr_array_index (stipples, screen_num); -} - -/** - * eel_stipple_bitmap: - * - * Get pointer to 50% stippled bitmap suitable for use - * on the default screen. This is a global object; do - * not free. - * - * This method is not multiscreen safe. Do not use it. - */ -GdkBitmap * -eel_stipple_bitmap (void) -{ - return eel_stipple_bitmap_for_screen (gdk_screen_get_default ()); -} - /** * eel_gdk_window_bring_to_front: * @@ -677,28 +624,14 @@ eel_gdk_window_set_wm_hints_input (GdkWindow *window, gboolean status) void eel_gdk_window_set_invisible_cursor (GdkWindow *window) { - GdkBitmap *empty_bitmap; GdkCursor *cursor; - GdkColor useless; - char invisible_cursor_bits[] = { 0x0 }; - - useless.red = useless.green = useless.blue = 0; - useless.pixel = 0; - empty_bitmap = gdk_bitmap_create_from_data (window, - invisible_cursor_bits, - 1, 1); - - cursor = gdk_cursor_new_from_pixmap (empty_bitmap, - empty_bitmap, - &useless, - &useless, 0, 0); + cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (window), + GDK_BLANK_CURSOR); gdk_window_set_cursor (window, cursor); gdk_cursor_unref (cursor); - - g_object_unref (empty_bitmap); } EelGdkGeometryFlags @@ -748,22 +681,25 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return, void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, - GdkGC *gc, GdkColor *text_color, GdkColor *shadow_color, int x, int y, PangoLayout *layout) { - gdk_draw_layout_with_colors (drawable, gc, - x+1, y+1, - layout, - shadow_color, NULL); + cairo_t *cr; + + cr = gdk_cairo_create (drawable); + + gdk_cairo_set_source_color (cr, shadow_color); + cairo_move_to (cr, x+1, y+1); + pango_cairo_show_layout (cr, layout); + + gdk_cairo_set_source_color (cr, text_color); + cairo_move_to (cr, x, y); + pango_cairo_show_layout (cr, layout); - gdk_draw_layout_with_colors (drawable, gc, - x, y, - layout, - text_color, NULL); + cairo_destroy (cr); } #if ! defined (EEL_OMIT_SELF_CHECK) diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index 91518186..69f29e62 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -120,10 +120,6 @@ char * eel_gdk_rgb_to_color_spec (guint32 gboolean eel_gdk_color_is_dark (GdkColor *color); -/* A routine to get a 50% gray stippled bitmap for use in some types of highlighting. */ -GdkBitmap * eel_stipple_bitmap_for_screen (GdkScreen *screen); -GdkBitmap * eel_stipple_bitmap (void); - /* Misc GdkRectangle helper functions */ gboolean eel_gdk_rectangle_contains_rectangle (GdkRectangle outer, @@ -155,7 +151,6 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char guint *width_return, guint *height_return); void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, - GdkGC *gc, GdkColor *text_color, GdkColor *shadow_color, int x, -- cgit v1.2.1 From ef8b06eaa8c26e592e9028b8a93361653abfb8ed Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 13:26:31 +0200 Subject: [eel] port eel-gdk-pixbuf-extensions to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=172af77cfbdc4910034a100a99aa1ec2cb843495 --- eel/eel-gdk-pixbuf-extensions.c | 28 +++++++++------------------- eel/eel-gdk-pixbuf-extensions.h | 7 +------ 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index a75158db..62bc58eb 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -649,13 +649,9 @@ eel_gdk_pixbuf_unref_if_not_null (GdkPixbuf *pixbuf_or_null) void eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, GdkDrawable *drawable, - GdkGC *gc, int source_x, int source_y, - EelIRect destination_area, - GdkRgbDither dither, - GdkPixbufAlphaMode alpha_compositing_mode, - int alpha_threshold) + EelIRect destination_area) { EelDimensions dimensions; EelIRect target; @@ -664,15 +660,11 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, int target_height; int source_width; int source_height; + cairo_t *cr; g_return_if_fail (eel_gdk_pixbuf_is_valid (pixbuf)); g_return_if_fail (drawable != NULL); - g_return_if_fail (gc != NULL); g_return_if_fail (!eel_irect_is_empty (&destination_area)); - g_return_if_fail (alpha_threshold > EEL_OPACITY_FULLY_TRANSPARENT); - g_return_if_fail (alpha_threshold <= EEL_OPACITY_FULLY_OPAQUE); - g_return_if_fail (alpha_compositing_mode >= GDK_PIXBUF_ALPHA_BILEVEL); - g_return_if_fail (alpha_compositing_mode <= GDK_PIXBUF_ALPHA_FULL); dimensions = eel_gdk_pixbuf_get_dimensions (pixbuf); @@ -707,16 +699,14 @@ eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, target.x1 = target.x0 + MIN (target_width, source_width); target.y1 = target.y0 + MIN (target_height, source_height); - gdk_draw_pixbuf (drawable, gc, (GdkPixbuf *) pixbuf, - source.x0, - source.y0, - target.x0, - target.y0, + cr = gdk_cairo_create (drawable); + gdk_cairo_set_source_pixbuf (cr, (GdkPixbuf *) pixbuf, + source.x0 - target.x0, source.y0 - target.y0); + cairo_rectangle (cr, target.x0, target.y0, target.x1 - target.x0, - target.y1 - target.y0, - dither, - 0, - 0); + target.y1 - target.y0); + cairo_fill (cr); + cairo_destroy (cr); } /** diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h index 7d7956e4..ae649e55 100644 --- a/eel/eel-gdk-pixbuf-extensions.h +++ b/eel/eel-gdk-pixbuf-extensions.h @@ -31,7 +31,6 @@ #include #include -#define EEL_STANDARD_ALPHA_THRESHHOLD 128 #define EEL_OPACITY_FULLY_TRANSPARENT 0 #define EEL_OPACITY_FULLY_OPAQUE 255 @@ -100,13 +99,9 @@ void eel_gdk_pixbuf_unref_if_not_null (GdkPixbuf /* Copy a pixbuf to an area of a GdkDrawable */ void eel_gdk_pixbuf_draw_to_drawable (const GdkPixbuf *pixbuf, GdkDrawable *drawable, - GdkGC *gc, int source_x, int source_y, - EelIRect destination_area, - GdkRgbDither dither, - GdkPixbufAlphaMode alpha_compositing_mode, - int alpha_threshold); + EelIRect destination_area); /* Copy a pixbuf to an area of another pixbuf */ void eel_gdk_pixbuf_draw_to_pixbuf (const GdkPixbuf *pixbuf, -- cgit v1.2.1 From 7dd50ac5969408e7f1fd1d452c13537a45731c58 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 2 Nov 2012 22:32:24 +0200 Subject: [property-browser] use gtk_label_set_attributes, obsolete eel_gtk_label_set_scale Not upstream because property-browser removed. But as in upstream, eel_gtk_label_set_scale() is going away in next eel-gtk-extensions.[ch] cleanup. --- src/caja-property-browser.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c index c74177d3..92de4738 100644 --- a/src/caja-property-browser.c +++ b/src/caja-property-browser.c @@ -228,6 +228,7 @@ caja_property_browser_init (GtkObject *object) GtkWidget *widget, *temp_box, *temp_hbox, *temp_frame, *vbox; GtkWidget *temp_button; GtkWidget *viewport; + PangoAttrList *attrs; char *temp_str; property_browser = CAJA_PROPERTY_BROWSER (object); @@ -316,9 +317,12 @@ caja_property_browser_init (GtkObject *object) gtk_container_add(GTK_CONTAINER(temp_frame), temp_hbox); /* add the title label */ + attrs = pango_attr_list_new (); + pango_attr_list_insert (attrs, pango_attr_scale_new (PANGO_SCALE_X_LARGE)); + pango_attr_list_insert (attrs, pango_attr_weight_new (PANGO_WEIGHT_BOLD)); property_browser->details->title_label = gtk_label_new (""); - eel_gtk_label_set_scale (GTK_LABEL (property_browser->details->title_label), PANGO_SCALE_X_LARGE); - eel_gtk_label_make_bold (GTK_LABEL (property_browser->details->title_label)); + gtk_label_set_attributes (GTK_LABEL (property_browser->details->title_label), attrs); + pango_attr_list_unref (attrs); gtk_widget_show(property_browser->details->title_label); gtk_box_pack_start (GTK_BOX(temp_hbox), property_browser->details->title_label, FALSE, FALSE, 0); -- cgit v1.2.1 From 4822b93ad236a03564af286f8a65984e9020f53c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sun, 4 Nov 2012 15:58:07 +0200 Subject: [eel] add wrap_table_child_visible_in, replace eel_gtk_viewport_*_rect Not upstream, as wrap-table have been removed, and the said functions are marked for removal from eel-gtk-extensions --- eel/eel-wrap-table.c | 66 ++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 18 deletions(-) diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c index f7e8a6ad..36c6c718 100644 --- a/eel/eel-wrap-table.c +++ b/eel/eel-wrap-table.c @@ -98,6 +98,8 @@ static EelDimensions wrap_table_irect_max_dimensions (const EelDimensions *o static EelDimensions wrap_table_get_max_child_dimensions (const EelWrapTable *wrap_table); static EelDimensions wrap_table_get_content_dimensions (const EelWrapTable *wrap_table); static EelIRect wrap_table_get_content_bounds (const EelWrapTable *wrap_table); +static gboolean wrap_table_child_visible_in (GtkWidget *child, + GtkWidget *scrolled); static gboolean wrap_table_child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data); @@ -744,23 +746,55 @@ wrap_table_get_content_bounds (const EelWrapTable *wrap_table) return content_bounds; } +/** + * wrap_table_child_visible_in + * + * Get child position relative to parent, then determine whether + * the whole child rectangle is visible in the scrolled window + **/ +static gboolean +wrap_table_child_visible_in (GtkWidget *child, GtkWidget *scrolled) +{ + gint x, y; + GtkAllocation child_alloc, scroll_alloc; + + gtk_widget_translate_coordinates (child, scrolled, 0, 0, &x, &y); + gtk_widget_get_allocation(child, &child_alloc); + gtk_widget_get_allocation(scrolled, &scroll_alloc); + + return (x >= 0 && y >= 0) + && x + child_alloc.width <= scroll_alloc.width + && y + child_alloc.height <= scroll_alloc.height; +} + static gboolean wrap_table_child_focus_in (GtkWidget *widget, GdkEventFocus *event, gpointer data) { - GtkWidget *parent, *pparent; - GtkAllocation allocation; + gint x, y; + GtkWidget *container, *viewport; + GtkAdjustment *hadj, *vadj; + + container = gtk_widget_get_parent (widget); + if (container) + { + viewport = gtk_widget_get_parent (container); + } + g_assert (container && viewport); + g_assert (GTK_IS_VIEWPORT (viewport)); + g_return_val_if_fail (gtk_widget_get_realized (viewport), FALSE); + + if (!wrap_table_child_visible_in (widget, viewport)) + { + hadj = gtk_viewport_get_hadjustment (GTK_VIEWPORT (viewport)); + vadj = gtk_viewport_get_vadjustment (GTK_VIEWPORT (viewport)); - parent = gtk_widget_get_parent (widget); - if (parent) - pparent = gtk_widget_get_parent (parent); - g_assert (parent && pparent); - g_assert (GTK_IS_VIEWPORT (pparent)); + gtk_widget_translate_coordinates (widget, container, 0, 0, &x, &y); - gtk_widget_get_allocation (widget, &allocation); - eel_gtk_viewport_scroll_to_rect (GTK_VIEWPORT (pparent), - &allocation); + gtk_adjustment_set_value (hadj, MIN (x, hadj->upper - hadj->page_size)); + gtk_adjustment_set_value (vadj, MIN (y, vadj->upper - vadj->page_size)); + } return FALSE; } @@ -977,16 +1011,12 @@ void eel_wrap_table_set_homogeneous (EelWrapTable *wrap_table, gboolean homogeneous) { - g_return_if_fail (EEL_IS_WRAP_TABLE (wrap_table)); - - if (wrap_table->details->homogeneous == homogeneous) + if (EEL_IS_WRAP_TABLE (wrap_table) && + wrap_table->details->homogeneous != homogeneous) { - return; + wrap_table->details->homogeneous = homogeneous; + gtk_widget_queue_resize (GTK_WIDGET (wrap_table)); } - - wrap_table->details->homogeneous = homogeneous; - - gtk_widget_queue_resize (GTK_WIDGET (wrap_table)); } /** -- cgit v1.2.1 From 638df47ee07a8f5b3ad4cea9639ac05713ab328f Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 14 Nov 2012 07:20:41 +0200 Subject: [sidebar-title] try to use GtkStyle in _select_text_color() Hopefully this will play better with themes, when a custom (EelBackground) background is not set in the widget. --- src/caja-information-panel.c | 4 +- src/caja-sidebar-title.c | 126 ++++++++++++++++++++++++++++--------------- src/caja-sidebar-title.h | 3 +- 3 files changed, 84 insertions(+), 49 deletions(-) diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c index 35df28ca..8542b527 100644 --- a/src/caja-information-panel.c +++ b/src/caja-information-panel.c @@ -1072,9 +1072,7 @@ caja_information_panel_update_appearance (CajaInformationPanel *information_pane eel_background_set_image_uri (background, background_image); eel_background_set_color (background, background_color); - caja_sidebar_title_select_text_color - (information_panel->details->title, background, - !information_panel_has_background (information_panel)); + caja_sidebar_title_select_text_color (information_panel->details->title, background); } g_free (background_color); diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c index 15a761be..466d9873 100644 --- a/src/caja-sidebar-title.c +++ b/src/caja-sidebar-title.c @@ -51,12 +51,14 @@ #define MAX_TITLE_SIZE 256 #define MINIMUM_INFO_WIDTH 32 #define SIDEBAR_INFO_MARGIN 4 -#define SHADOW_OFFSET 1 #define MORE_INFO_FONT_SIZE 12 #define MIN_TITLE_FONT_SIZE 12 #define TITLE_PADDING 4 +#define DEFAULT_LIGHT_INFO_COLOR 0xFFFFFF +#define DEFAULT_DARK_INFO_COLOR 0x2A2A2A + static void caja_sidebar_title_class_init (CajaSidebarTitleClass *klass); static void caja_sidebar_title_destroy (GtkObject *object); static void caja_sidebar_title_init (CajaSidebarTitle *pixmap); @@ -72,20 +74,32 @@ static void style_set (GtkWidget GtkStyle *previous_style); static guint get_best_icon_size (CajaSidebarTitle *sidebar_title); +enum +{ + LABEL_COLOR, + LABEL_COLOR_HIGHLIGHT, + LABEL_COLOR_ACTIVE, + LABEL_COLOR_PRELIGHT, + LABEL_INFO_COLOR, + LABEL_INFO_COLOR_HIGHLIGHT, + LABEL_INFO_COLOR_ACTIVE, + LAST_LABEL_COLOR +}; + struct CajaSidebarTitleDetails { CajaFile *file; - guint file_changed_connection; - gboolean monitoring_count; + guint file_changed_connection; + gboolean monitoring_count; - char *title_text; + char *title_text; GtkWidget *icon; GtkWidget *title_label; GtkWidget *more_info_label; GtkWidget *emblem_box; - guint best_icon_size; - + GdkColor label_colors [LAST_LABEL_COLOR]; + guint best_icon_size; gboolean determined_icon; }; @@ -219,58 +233,82 @@ caja_sidebar_title_new (void) return gtk_widget_new (caja_sidebar_title_get_type (), NULL); } +static void +setup_gc_with_fg (CajaSidebarTitle *sidebar_title, int idx, guint32 color) +{ + sidebar_title->details->label_colors [idx] = eel_gdk_rgb_to_color (color); +} + void caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title, - EelBackground *background, - gboolean is_default) + EelBackground *background) { - char *sidebar_title_color; - char *sidebar_info_title_color; - char *sidebar_title_shadow_color; + GdkColor *light_info_color, *dark_info_color; + guint light_info_value, dark_info_value; + GtkStyle *style; - g_return_if_fail (background != NULL); + g_assert (CAJA_IS_SIDEBAR_TITLE (sidebar_title)); + g_return_if_fail (!gtk_widget_get_realized (GTK_WIDGET (sidebar_title))); - /* if the background is set to the default, the theme can explicitly - * define the title colors. Check if the background has been customized - * and if the theme specified any colors - */ - sidebar_title_color = NULL; - sidebar_info_title_color = NULL; - sidebar_title_shadow_color = NULL; + /* read the info colors from the current theme; use a reasonable default if undefined */ + gtk_widget_style_get (GTK_WIDGET (sidebar_title), + "light_info_color", &light_info_color, + "dark_info_color", &dark_info_color, + NULL); + style = gtk_widget_get_style (GTK_WIDGET (sidebar_title)); - /* FIXME bugzilla.gnome.org 42496: for now, both the title and info - * colors are the same - and hard coded */ - if (eel_background_is_dark (background)) + if (light_info_color) { - sidebar_title_color = g_strdup ("#FFFFFF"); - sidebar_info_title_color = g_strdup ("#FFFFFF"); - sidebar_title_shadow_color = g_strdup ("#000000"); + light_info_value = eel_gdk_color_to_rgb (light_info_color); + gdk_color_free (light_info_color); } else { - sidebar_title_color = g_strdup ("#000000"); - sidebar_info_title_color = g_strdup ("#000000"); - sidebar_title_shadow_color = g_strdup ("#FFFFFF"); + light_info_value = DEFAULT_LIGHT_INFO_COLOR; } - eel_gtk_widget_set_foreground_color (sidebar_title->details->title_label, - sidebar_title_color); - eel_gtk_widget_set_foreground_color (sidebar_title->details->more_info_label, - sidebar_info_title_color); - - eel_gtk_label_set_drop_shadow_color (GTK_LABEL (sidebar_title->details->title_label), - eel_parse_rgb_with_white_default (sidebar_title_shadow_color)); - eel_gtk_label_set_drop_shadow_color (GTK_LABEL (sidebar_title->details->more_info_label), - eel_parse_rgb_with_white_default (sidebar_title_shadow_color)); + if (dark_info_color) + { + dark_info_value = eel_gdk_color_to_rgb (dark_info_color); + gdk_color_free (dark_info_color); + } + else + { + dark_info_value = DEFAULT_DARK_INFO_COLOR; + } - eel_gtk_label_set_drop_shadow_offset (GTK_LABEL (sidebar_title->details->title_label), - SHADOW_OFFSET); - eel_gtk_label_set_drop_shadow_offset (GTK_LABEL (sidebar_title->details->more_info_label), - SHADOW_OFFSET); - g_free (sidebar_title_color); - g_free (sidebar_info_title_color); - g_free (sidebar_title_shadow_color); + setup_gc_with_fg (sidebar_title, LABEL_COLOR_HIGHLIGHT, + eel_gdk_color_to_rgb (&style->text[GTK_STATE_SELECTED])); + setup_gc_with_fg (sidebar_title, LABEL_COLOR_ACTIVE, + eel_gdk_color_to_rgb (&style->text[GTK_STATE_ACTIVE])); + setup_gc_with_fg (sidebar_title, LABEL_COLOR_PRELIGHT, + eel_gdk_color_to_rgb (&style->text[GTK_STATE_PRELIGHT])); + setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_HIGHLIGHT, + eel_gdk_color_is_dark (&style->base[GTK_STATE_SELECTED]) ? light_info_value : dark_info_value); + setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR_ACTIVE, + eel_gdk_color_is_dark (&style->base[GTK_STATE_ACTIVE]) ? light_info_value : dark_info_value); + + /* If EelBackground is not set in the widget, we can safely + * use the foreground color from the theme, because it will + * always be displayed against the gtk background */ + if (!eel_background_is_set(background)) + { + setup_gc_with_fg (sidebar_title, LABEL_COLOR, + eel_gdk_color_to_rgb (&style->text[GTK_STATE_NORMAL])); + setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, + eel_gdk_color_is_dark (&style->base[GTK_STATE_NORMAL]) ? light_info_value : dark_info_value); + } + else if (eel_background_is_dark (background)) + { + setup_gc_with_fg (sidebar_title, LABEL_COLOR, 0xEFEFEF); + setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, light_info_value); + } + else /* converse */ + { + setup_gc_with_fg (sidebar_title, LABEL_COLOR, 0x000000); + setup_gc_with_fg (sidebar_title, LABEL_INFO_COLOR, dark_info_value); + } } static char* diff --git a/src/caja-sidebar-title.h b/src/caja-sidebar-title.h index a677fdfc..757d5c3b 100644 --- a/src/caja-sidebar-title.h +++ b/src/caja-sidebar-title.h @@ -70,7 +70,6 @@ gboolean caja_sidebar_title_hit_test_icon (CajaSidebarTitle *sidebar_title int x, int y); void caja_sidebar_title_select_text_color (CajaSidebarTitle *sidebar_title, - EelBackground *background, - gboolean is_default); + EelBackground *background); #endif /* CAJA_SIDEBAR_TITLE_H */ -- cgit v1.2.1 From e96bb83cdc1ed0753d2547463a4e6ec61f41de12 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 14 Nov 2012 07:29:08 +0200 Subject: [sidebar-title] use gtk_label_set_attributes, obsolete eel_gtk_label_set_scale --- src/caja-sidebar-title.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c index 466d9873..beb30359 100644 --- a/src/caja-sidebar-title.c +++ b/src/caja-sidebar-title.c @@ -762,9 +762,16 @@ static GtkWidget * sidebar_title_create_more_info_label (void) { GtkWidget *more_info_label; + PangoAttrList *attrs; + + attrs = pango_attr_list_new (); + pango_attr_list_insert (attrs, pango_attr_scale_new (PANGO_SCALE_SMALL)); more_info_label = gtk_label_new (""); - eel_gtk_label_set_scale (GTK_LABEL (more_info_label), PANGO_SCALE_SMALL); + + gtk_label_set_attributes (GTK_LABEL (more_info_label), attrs); + pango_attr_list_unref (attrs); + gtk_label_set_justify (GTK_LABEL (more_info_label), GTK_JUSTIFY_CENTER); gtk_label_set_selectable (GTK_LABEL (more_info_label), TRUE); gtk_label_set_ellipsize (GTK_LABEL (more_info_label), PANGO_ELLIPSIZE_END); -- cgit v1.2.1 From f9c3a1bd9499c47db2b32a0487ad3c91dbafeea9 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 14 Nov 2012 07:30:55 +0200 Subject: [information-panel] don't use eel_point_in_widget() nor in sidebar-title. the eel function is deprecated. --- src/caja-information-panel.c | 14 +++++++++++++- src/caja-sidebar-title.c | 14 +++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c index 8542b527..086faaee 100644 --- a/src/caja-information-panel.c +++ b/src/caja-information-panel.c @@ -432,12 +432,24 @@ static InformationPanelPart hit_test (CajaInformationPanel *information_panel, int x, int y) { + GtkAllocation *allocation; + gboolean bg_hit; + if (caja_sidebar_title_hit_test_icon (information_panel->details->title, x, y)) { return ICON_PART; } - if (eel_point_in_widget (GTK_WIDGET (information_panel), x, y)) + allocation = g_new0 (GtkAllocation, 1); + gtk_widget_get_allocation (GTK_WIDGET (information_panel), allocation); + + bg_hit = allocation != NULL + && x >= allocation->x && y >= allocation->y + && x < allocation->x + allocation->width + && y < allocation->y + allocation->height; + g_free (allocation); + + if (bg_hit) { return BACKGROUND_PART; } diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c index beb30359..e02eaa9d 100644 --- a/src/caja-sidebar-title.c +++ b/src/caja-sidebar-title.c @@ -738,9 +738,21 @@ caja_sidebar_title_size_allocate (GtkWidget *widget, gboolean caja_sidebar_title_hit_test_icon (CajaSidebarTitle *sidebar_title, int x, int y) { + GtkAllocation *allocation; + gboolean icon_hit; + g_return_val_if_fail (CAJA_IS_SIDEBAR_TITLE (sidebar_title), FALSE); - return eel_point_in_widget (sidebar_title->details->icon, x, y); + allocation = g_new0 (GtkAllocation, 1); + gtk_widget_get_allocation (GTK_WIDGET (sidebar_title->details->icon), allocation); + g_return_val_if_fail (allocation != NULL, FALSE); + + icon_hit = x >= allocation->x && y >= allocation->y + && x < allocation->x + allocation->width + && y < allocation->y + allocation->height; + g_free (allocation); + + return icon_hit; } static GtkWidget * -- cgit v1.2.1 From ae0deb0d1da0060fa0bba24b0fb6a65e53dc94ee Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 31 Oct 2012 01:30:30 +0200 Subject: [eel-gtk-extensions] remove dead code As in the commit below, except move a few we still need around to eel-image-table, which has been removed upstream. Specifically moving: eel_gtk_widget_find_windowed_ancestor to: find_windowed_ancestor() eel_gtk_signal_connect_while_realized to: signal_connect_while_realized() Also move while_realized_disconnecter(), as it's needed by the latter. http://git.gnome.org/browse/nautilus/commit/?id=a904f4acd546151ab37ee03bcce87869a805c323 --- eel/eel-gtk-extensions.c | 553 ----------------------------------------------- eel/eel-gtk-extensions.h | 38 ---- eel/eel-image-table.c | 168 +++++++++++--- 3 files changed, 138 insertions(+), 621 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 94c4987d..7aab358e 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -430,30 +430,6 @@ eel_gtk_menu_insert_separator (GtkMenu *menu, int index) return GTK_MENU_ITEM (menu_item); } -void -eel_gtk_menu_set_item_visibility (GtkMenu *menu, int index, gboolean visible) -{ - GList *children; - GtkWidget *menu_item; - - g_return_if_fail (GTK_IS_MENU (menu)); - - children = gtk_container_get_children (GTK_CONTAINER (menu)); - g_return_if_fail (index >= 0 && index < (int) g_list_length (children)); - - menu_item = GTK_WIDGET (g_list_nth_data (children, index)); - if (visible) - { - gtk_widget_show (menu_item); - } - else - { - gtk_widget_hide (menu_item); - } - - g_list_free (children); -} - GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button) { @@ -474,37 +450,6 @@ eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button) return button; } -gboolean -eel_point_in_allocation (const GtkAllocation *allocation, - int x, int y) -{ - g_return_val_if_fail (allocation != NULL, FALSE); - return x >= allocation->x - && y >= allocation->y - && x < allocation->x + allocation->width - && y < allocation->y + allocation->height; -} - -/* FIXME this function is dangerous, because gtk_widget_get_window (widget) coords (or - * other window-belonging-to-widget coords) do not need to be in the - * same coordinate system as widget->allocation. - * If you use this function, be aware of that. Someone should probably - * audit all uses, too. - */ -gboolean -eel_point_in_widget (GtkWidget *widget, - int x, int y) -{ - GtkAllocation allocation; - if (widget == NULL) - { - return FALSE; - } - g_return_val_if_fail (GTK_IS_WIDGET (widget), FALSE); - gtk_widget_get_allocation (widget, &allocation); - return eel_point_in_allocation (&allocation, x, y); -} - /** * eel_gtk_widget_set_shown * @@ -603,167 +548,6 @@ eel_gtk_signal_connect_full_while_alive (GtkObject *object, info); } -typedef struct -{ - GtkObject *object; - guint object_destroy_handler; - - GtkWidget *realized_widget; - guint realized_widget_destroy_handler; - guint realized_widget_unrealized_handler; - - guint signal_handler; -} RealizeDisconnectInfo; - -static void -while_realized_disconnecter (GtkObject *object, - RealizeDisconnectInfo *info) -{ - g_assert (GTK_IS_OBJECT (object)); - g_assert (info != NULL); - g_assert (GTK_IS_OBJECT (info->object)); - g_assert (info->object_destroy_handler != 0); - g_assert (info->object_destroy_handler != 0); - g_assert (info->realized_widget_destroy_handler != 0); - g_assert (info->realized_widget_unrealized_handler != 0); - - g_signal_handler_disconnect (info->object, info->object_destroy_handler); - g_signal_handler_disconnect (info->object, info->signal_handler); - g_signal_handler_disconnect (info->realized_widget, info->realized_widget_destroy_handler); - g_signal_handler_disconnect (info->realized_widget, info->realized_widget_unrealized_handler); - g_free (info); -} - -/** - * eel_gtk_signal_connect_while_realized: - * - * @object: Object to connect to. - * @name: Name of signal to connect to. - * @callback: Caller's callback. - * @callback_data: Caller's callback_data. - * @realized_widget: Widget to monitor for realized state. Signal is connected - * while this wigget is realized. - * - * Connect to a signal of an object while another widget is realized. This is - * useful for non windowed widgets that need to monitor events in their ancestored - * windowed widget. The signal is automatically disconnected when &widget is - * unrealized. Also, the signal is automatically disconnected when either &object - * or &widget are destroyed. - **/ -void -eel_gtk_signal_connect_while_realized (GtkObject *object, - const char *name, - GCallback callback, - gpointer callback_data, - GtkWidget *realized_widget) -{ - RealizeDisconnectInfo *info; - - g_return_if_fail (GTK_IS_OBJECT (object)); - g_return_if_fail (name != NULL); - g_return_if_fail (name[0] != '\0'); - g_return_if_fail (callback != NULL); - g_return_if_fail (GTK_IS_WIDGET (realized_widget)); - g_return_if_fail (gtk_widget_get_realized (realized_widget)); - - info = g_new0 (RealizeDisconnectInfo, 1); - - info->object = object; - info->object_destroy_handler = - g_signal_connect (G_OBJECT (info->object), - "destroy", - G_CALLBACK (while_realized_disconnecter), - info); - - info->realized_widget = realized_widget; - info->realized_widget_destroy_handler = - g_signal_connect (G_OBJECT (info->realized_widget), - "destroy", - G_CALLBACK (while_realized_disconnecter), - info); - info->realized_widget_unrealized_handler = - g_signal_connect_after (G_OBJECT (info->realized_widget), - "unrealize", - G_CALLBACK (while_realized_disconnecter), - info); - - info->signal_handler = g_signal_connect (G_OBJECT (info->object), - name, callback, callback_data); -} - -/** - * eel_gtk_container_get_first_child. - * - * Returns the first child of a container. - * @container: The container. - **/ - -static void -get_first_callback (GtkWidget *widget, gpointer callback_data) -{ - GtkWidget **first_child_slot; - - g_assert (GTK_IS_WIDGET (widget)); - g_assert (callback_data != NULL); - - first_child_slot = callback_data; - - if (*first_child_slot == NULL) - { - *first_child_slot = widget; - /* We'd stop the iterating now if we could. */ - } - else - { - g_assert (GTK_IS_WIDGET (*first_child_slot)); - } -} - -GtkWidget * -eel_gtk_container_get_first_child (GtkContainer *container) -{ - GtkWidget *first_child; - - g_return_val_if_fail (GTK_IS_CONTAINER (container), NULL); - - first_child = NULL; - gtk_container_foreach (container, get_first_callback, &first_child); - g_assert (first_child == NULL || GTK_IS_WIDGET (first_child)); - return first_child; -} - -typedef struct -{ - GtkCallback callback; - gpointer callback_data; -} container_foreach_deep_callback_data; - -static void -container_foreach_deep_callback (GtkWidget *child, gpointer data) -{ - container_foreach_deep_callback_data *deep_data; - - deep_data = (container_foreach_deep_callback_data *) data; - - deep_data->callback (child, deep_data->callback_data); - - if (GTK_IS_CONTAINER (child)) - { - gtk_container_foreach (GTK_CONTAINER (child), container_foreach_deep_callback, data); - } -} - -void -eel_gtk_container_foreach_deep (GtkContainer *container, - GtkCallback callback, - gpointer callback_data) -{ - container_foreach_deep_callback_data deep_data; - deep_data.callback = callback; - deep_data.callback_data = callback_data; - gtk_container_foreach (container, container_foreach_deep_callback, &deep_data); -} - /* The standard gtk_adjustment_set_value ignores page size, which * disagrees with the logic used by scroll bars, for example. */ @@ -822,172 +606,6 @@ eel_gtk_label_make_bold (GtkLabel *label) pango_font_description_free (font_desc); } -/** - * eel_gtk_label_set_scale: - * @label: - * @num_steps: - * - * Function is broken, see eel_gtk_label_make_larger() for explanation - * - **/ -void -eel_gtk_label_set_scale (GtkLabel *label, - double scale_factor) -{ - PangoAttrList *old_attr_list; - PangoAttrList *attr_list; - - g_return_if_fail (GTK_IS_LABEL (label)); - g_return_if_fail (scale_factor > 0); - - old_attr_list = gtk_label_get_attributes (label); - attr_list = eel_pango_attr_list_apply_global_attribute (old_attr_list, - pango_attr_scale_new (scale_factor)); - gtk_label_set_attributes (label, attr_list); - pango_attr_list_unref (attr_list); -} - -static void -get_layout_location (GtkLabel *label, - gint *xp, - gint *yp) -{ - GtkMisc *misc; - GtkWidget *widget; - float xalign, yalign; - int x, y, xpad, ypad; - int shadow_offset; - GtkAllocation allocation; - GtkRequisition req; - - shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), - "eel-label-shadow-offset")); - - misc = GTK_MISC (label); - widget = GTK_WIDGET (label); - gtk_misc_get_alignment (misc, &xalign, &yalign); - gtk_misc_get_padding (misc, &xpad, &ypad); - - if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR) - xalign = 1.0 - xalign; - - gtk_widget_get_allocation (widget, &allocation); - gtk_widget_get_requisition (widget, &req); - x = floor (allocation.x + xpad - + ((allocation.width - req.width - shadow_offset) * xalign) - + 0.5); - - y = floor (allocation.y + ypad - + ((allocation.height - req.height - shadow_offset) * yalign) - + 0.5); - - - if (xp) - *xp = x; - - if (yp) - *yp = y; -} - -static gboolean -eel_gtk_label_expose_event (GtkLabel *label, GdkEventExpose *event, gpointer user_data) -{ - int x, y; - GdkColor color; - GtkWidget *widget; - GdkGC *gc; - guint32 shadow_color; - int shadow_offset; - - shadow_color = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), - "eel-label-shadow-color")); - shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), - "eel-label-shadow-offset")); - - color = eel_gdk_rgb_to_color (shadow_color); - - get_layout_location (label, &x, &y); - - widget = GTK_WIDGET (label); - if (shadow_offset > 0) - { - gc = gdk_gc_new (gtk_widget_get_window (widget)); - gdk_gc_set_rgb_fg_color (gc, &color); - gdk_gc_set_clip_rectangle (gc, &event->area); - - gdk_draw_layout (gtk_widget_get_window (widget), - gc, - x + shadow_offset, y + shadow_offset, - gtk_label_get_layout (label)); - g_object_unref (gc); - } - - gtk_paint_layout (gtk_widget_get_style (widget), - gtk_widget_get_window (widget), - gtk_widget_get_state (widget), - FALSE, - &event->area, - widget, - "label", - x, y, - gtk_label_get_layout (label)); - - return TRUE; -} - -static void -eel_gtk_label_size_request (GtkLabel *label, GtkRequisition *requisition, gpointer user_data) -{ - gint shadow_offset; - - shadow_offset = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (label), - "eel-label-shadow-offset")); - - requisition->width += shadow_offset; - requisition->height += shadow_offset; -} - -static void -set_up_label (GtkLabel *label) -{ - - if (g_object_get_data (G_OBJECT (label), "eel-label-set-up") != NULL) - { - return; - } - - g_signal_connect (label, "expose_event", - G_CALLBACK (eel_gtk_label_expose_event), NULL); - g_signal_connect_after (label, "size_request", - G_CALLBACK (eel_gtk_label_size_request), NULL); - - g_object_set_data (G_OBJECT (label), "eel-label-set-up", "eel-label-set-up"); -} - -void -eel_gtk_label_set_drop_shadow_color (GtkLabel *label, - guint32 color) -{ - set_up_label (label); - - g_object_set_data (G_OBJECT (label), "eel-label-shadow-color", - GINT_TO_POINTER (color)); - - gtk_widget_queue_draw (GTK_WIDGET (label)); -} - -void -eel_gtk_label_set_drop_shadow_offset (GtkLabel *label, - gint offset) -{ - set_up_label (label); - - g_object_set_data (G_OBJECT (label), "eel-label-shadow-offset", - GINT_TO_POINTER (offset)); - - gtk_widget_queue_draw (GTK_WIDGET (label)); -} - void eel_gtk_widget_set_background_color (GtkWidget *widget, const char *color_spec) @@ -1020,78 +638,6 @@ eel_gtk_widget_set_foreground_color (GtkWidget *widget, gtk_widget_modify_text (widget, GTK_STATE_ACTIVE, &color); } -GtkWidget * -eel_gtk_widget_find_windowed_ancestor (GtkWidget *widget) -{ - g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); - - while (widget && !gtk_widget_get_has_window (widget)) - { - widget = gtk_widget_get_parent (widget); - } - - return widget; -} - -/* eel_gtk_get_system_font: - * - * Return the system font as selected in the control center. Need to - * g_object_unref() the result when done with it. - * - * Perhaps there is a better way to figure out what that font is, but - * the following is simple enough and it works. - */ -PangoFontDescription * -eel_gtk_get_system_font (void) -{ - GtkWidget *label; - PangoFontDescription *font; - - label = gtk_label_new (""); - - gtk_widget_ensure_style (label); - - font = pango_font_description_copy (gtk_widget_get_style (label)->font_desc); - - g_object_ref_sink (label); - g_object_unref (label); - - return font; -} - -void -eel_gtk_widget_get_button_event_location (GtkWidget *widget, - const GdkEventButton *event, - int *x, - int *y) -{ - int window_x, window_y; - GtkAllocation allocation; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - g_return_if_fail (event != NULL); - - gdk_window_get_position (event->window, &window_x, &window_y); - gtk_widget_get_allocation (widget, &allocation); - if (x != NULL) - { - *x = event->x + window_x - allocation.x; - } - if (y != NULL) - { - *y = event->y + window_y - allocation.y; - } -} - -void -eel_gtk_widget_get_motion_event_location (GtkWidget *widget, - const GdkEventMotion *event, - int *x, - int *y) -{ - eel_gtk_widget_get_button_event_location (widget, (const GdkEventButton *) event, x, y); -} - static gboolean tree_view_button_press_callback (GtkWidget *tree_view, GdkEventButton *event, @@ -1146,102 +692,3 @@ eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view, GUINT_TO_POINTER (button_press_id)); } } - -gboolean -eel_gtk_viewport_get_visible_rect (GtkViewport *viewport, - GdkRectangle *rect) -{ - GdkRectangle viewport_rect; - GdkRectangle child_rect; - gboolean return_val; - - g_return_val_if_fail (GTK_IS_VIEWPORT (viewport), FALSE); - g_return_val_if_fail (rect != NULL, FALSE); - - if (gtk_widget_get_realized (GTK_WIDGET (viewport))) - { - viewport_rect.x = 0; - viewport_rect.y = 0; - -#if GTK_CHECK_VERSION(3, 0, 0) - viewport_rect.width = gdk_window_get_width(GDK_WINDOW(gtk_viewport_get_view_window(viewport))); - viewport_rect.height = gdk_window_get_height(GDK_WINDOW(gtk_viewport_get_view_window(viewport))); -#else - gdk_drawable_get_size(gtk_viewport_get_view_window(viewport), &viewport_rect.width, &viewport_rect.height); -#endif - - gdk_window_get_position (gtk_viewport_get_bin_window (viewport), - &child_rect.x, - &child_rect.y); - -#if GTK_CHECK_VERSION(3, 0, 0) - child_rect.width = gdk_window_get_width(GDK_WINDOW(gtk_viewport_get_view_window(viewport))); - child_rect.height = gdk_window_get_height(GDK_WINDOW(gtk_viewport_get_view_window(viewport))); -#else - gdk_drawable_get_size(gtk_viewport_get_bin_window(viewport), &child_rect.width, &child_rect.height); -#endif - - return_val = gdk_rectangle_intersect (&viewport_rect, - &child_rect, - rect); - rect->x -= child_rect.x; - rect->y -= child_rect.y; - - return return_val; - } - - rect->x = rect->y = rect->width = rect->height = 0; - return FALSE; -} - -void -eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport, - GdkRectangle *rect) -{ - GdkRectangle visible_rect; - int scroll_x; - int scroll_y; - GtkAdjustment *adjustment; - - g_return_if_fail (GTK_IS_VIEWPORT (viewport)); - g_return_if_fail (rect != NULL); - - if (eel_gtk_viewport_get_visible_rect (viewport, &visible_rect)) - { - scroll_x = -1; - scroll_y = -1; - - if (rect->x + rect->width > visible_rect.x + visible_rect.width) - { - scroll_x = rect->x - (visible_rect.width - rect->width); - } - if (rect->y + rect->height > visible_rect.y + visible_rect.height) - { - scroll_y = rect->y - (visible_rect.height - rect->height); - } - - if (rect->x < visible_rect.x) - { - scroll_x = rect->x; - } - - if (rect->y < visible_rect.y) - { - scroll_y = rect->y; - } - - adjustment = gtk_viewport_get_hadjustment (viewport); - if (adjustment && scroll_x != -1) - { - eel_gtk_adjustment_set_value (adjustment, - (double)scroll_x); - } - - adjustment = gtk_viewport_get_vadjustment (viewport); - if (adjustment && scroll_y != -1) - { - eel_gtk_adjustment_set_value (adjustment, - (double)scroll_y); - } - } -} diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index e286bf74..1da3e8f4 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -54,32 +54,10 @@ void eel_gtk_signal_connect_while_realized (GtkObject /* GtkWidget */ void eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown); -gboolean eel_point_in_allocation (const GtkAllocation *allocation, - int x, - int y); -gboolean eel_point_in_widget (GtkWidget *widget, - int x, - int y); void eel_gtk_widget_set_background_color (GtkWidget *widget, const char *color_spec); void eel_gtk_widget_set_foreground_color (GtkWidget *widget, const char *color_spec); -GtkWidget * eel_gtk_widget_find_windowed_ancestor (GtkWidget *widget); -PangoFontDescription *eel_gtk_get_system_font (void); -void eel_gtk_widget_get_button_event_location (GtkWidget *widget, - const GdkEventButton *event, - int *x, - int *y); -void eel_gtk_widget_get_motion_event_location (GtkWidget *widget, - const GdkEventMotion *event, - int *x, - int *y); - -/* GtkContainer */ -GtkWidget * eel_gtk_container_get_first_child (GtkContainer *container); -void eel_gtk_container_foreach_deep (GtkContainer *container, - GtkCallback callback, - gpointer callback_data); /* GtkWindow */ void eel_gtk_window_set_initial_geometry (GtkWindow *window, @@ -107,21 +85,12 @@ void eel_pop_up_context_menu (GtkMenu GtkMenuItem * eel_gtk_menu_append_separator (GtkMenu *menu); GtkMenuItem * eel_gtk_menu_insert_separator (GtkMenu *menu, int index); -void eel_gtk_menu_set_item_visibility (GtkMenu *menu, - int index, - gboolean visible); /* GtkMenuToolButton */ GtkWidget * eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button); /* GtkLabel */ void eel_gtk_label_make_bold (GtkLabel *label); -void eel_gtk_label_set_scale (GtkLabel *label, - double scale_factor); -void eel_gtk_label_set_drop_shadow_color (GtkLabel *label, - guint32 color); -void eel_gtk_label_set_drop_shadow_offset (GtkLabel *label, - gint offset); /* GtkAdjustment */ void eel_gtk_adjustment_set_value (GtkAdjustment *adjustment, float value); @@ -131,11 +100,4 @@ void eel_gtk_adjustment_clamp_value (GtkAdjust void eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view, gboolean should_activate); -/* GtkViewport */ -gboolean eel_gtk_viewport_get_visible_rect (GtkViewport *viewport, - GdkRectangle *rect); - -void eel_gtk_viewport_scroll_to_rect (GtkViewport *viewport, - GdkRectangle *rect); - #endif /* EEL_GTK_EXTENSIONS_H */ diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c index 8f87660b..54b3947d 100644 --- a/eel/eel-image-table.c +++ b/eel/eel-image-table.c @@ -88,6 +88,13 @@ static void image_table_emit_signal (EelImageTable *image_t guint state, GdkEvent *event); +/* Ancestor methods */ +GtkWidget * find_windowed_ancestor (GtkWidget *widget); +static void signal_connect_while_realized (GtkObject *object, + const char *name, + GCallback callback, + gpointer callback_data, + GtkWidget *realized_widget); /* Ancestor callbacks */ static int ancestor_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event, @@ -209,7 +216,7 @@ eel_image_table_realize (GtkWidget *widget) /* Chain realize */ EEL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget)); - windowed_ancestor = eel_gtk_widget_find_windowed_ancestor (widget); + windowed_ancestor = find_windowed_ancestor (widget); g_assert (GTK_IS_WIDGET (windowed_ancestor)); gtk_widget_add_events (windowed_ancestor, @@ -220,35 +227,35 @@ eel_image_table_realize (GtkWidget *widget) | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK); - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "enter_notify_event", - G_CALLBACK (ancestor_enter_notify_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "leave_notify_event", - G_CALLBACK (ancestor_leave_notify_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "motion_notify_event", - G_CALLBACK (ancestor_motion_notify_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "button_press_event", - G_CALLBACK (ancestor_button_press_event), - widget, - widget); - - eel_gtk_signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), - "button_release_event", - G_CALLBACK (ancestor_button_release_event), - widget, - widget); + signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + "enter_notify_event", + G_CALLBACK (ancestor_enter_notify_event), + widget, + widget); + + signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + "leave_notify_event", + G_CALLBACK (ancestor_leave_notify_event), + widget, + widget); + + signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + "motion_notify_event", + G_CALLBACK (ancestor_motion_notify_event), + widget, + widget); + + signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + "button_press_event", + G_CALLBACK (ancestor_button_press_event), + widget, + widget); + + signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + "button_release_event", + G_CALLBACK (ancestor_button_release_event), + widget, + widget); } static void @@ -401,6 +408,107 @@ image_table_handle_motion (EelImageTable *image_table, } } +GtkWidget * +find_windowed_ancestor (GtkWidget *widget) +{ + g_return_val_if_fail (GTK_IS_WIDGET (widget), NULL); + + while (widget && !gtk_widget_get_has_window (widget)) + { + widget = gtk_widget_get_parent (widget); + } + + return widget; +} + +typedef struct +{ + GtkObject *object; + guint object_destroy_handler; + + GtkWidget *realized_widget; + guint realized_widget_destroy_handler; + guint realized_widget_unrealized_handler; + + guint signal_handler; +} RealizeDisconnectInfo; + +static void +while_realized_disconnecter (GtkObject *object, + RealizeDisconnectInfo *info) +{ + g_assert (GTK_IS_OBJECT (object)); + g_assert (info != NULL); + g_assert (GTK_IS_OBJECT (info->object)); + g_assert (info->object_destroy_handler != 0); + g_assert (info->object_destroy_handler != 0); + g_assert (info->realized_widget_destroy_handler != 0); + g_assert (info->realized_widget_unrealized_handler != 0); + + g_signal_handler_disconnect (info->object, info->object_destroy_handler); + g_signal_handler_disconnect (info->object, info->signal_handler); + g_signal_handler_disconnect (info->realized_widget, info->realized_widget_destroy_handler); + g_signal_handler_disconnect (info->realized_widget, info->realized_widget_unrealized_handler); + g_free (info); +} + +/** + * signal_connect_while_realized: + * + * @object: Object to connect to. + * @name: Name of signal to connect to. + * @callback: Caller's callback. + * @callback_data: Caller's callback_data. + * @realized_widget: Widget to monitor for realized state. Signal is connected + * while this wigget is realized. + * + * Connect to a signal of an object while another widget is realized. This is + * useful for non windowed widgets that need to monitor events in their ancestored + * windowed widget. The signal is automatically disconnected when &widget is + * unrealized. Also, the signal is automatically disconnected when either &object + * or &widget are destroyed. + **/ +static void +signal_connect_while_realized (GtkObject *object, + const char *name, + GCallback callback, + gpointer callback_data, + GtkWidget *realized_widget) +{ + RealizeDisconnectInfo *info; + + g_return_if_fail (GTK_IS_OBJECT (object)); + g_return_if_fail (name != NULL); + g_return_if_fail (name[0] != '\0'); + g_return_if_fail (callback != NULL); + g_return_if_fail (GTK_IS_WIDGET (realized_widget)); + g_return_if_fail (gtk_widget_get_realized (realized_widget)); + + info = g_new0 (RealizeDisconnectInfo, 1); + + info->object = object; + info->object_destroy_handler = + g_signal_connect (G_OBJECT (info->object), + "destroy", + G_CALLBACK (while_realized_disconnecter), + info); + + info->realized_widget = realized_widget; + info->realized_widget_destroy_handler = + g_signal_connect (G_OBJECT (info->realized_widget), + "destroy", + G_CALLBACK (while_realized_disconnecter), + info); + info->realized_widget_unrealized_handler = + g_signal_connect_after (G_OBJECT (info->realized_widget), + "unrealize", + G_CALLBACK (while_realized_disconnecter), + info); + + info->signal_handler = g_signal_connect (G_OBJECT (info->object), + name, callback, callback_data); +} + static int ancestor_enter_notify_event (GtkWidget *widget, GdkEventCrossing *event, -- cgit v1.2.1 From 299c8466cdf47ae0468a216c2392b719330a1971 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 02:32:23 +0200 Subject: [eel-image-table] remove useless GdkGC clear_gc, and unrealize method Not upstream as image-table was removed. --- eel/eel-image-table.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c index 54b3947d..84dff9aa 100644 --- a/eel/eel-image-table.c +++ b/eel/eel-image-table.c @@ -46,7 +46,6 @@ struct EelImageTableDetails { GtkWidget *child_under_pointer; GtkWidget *child_being_pressed; - GdkGC *clear_gc; }; /* Signals */ @@ -71,7 +70,6 @@ static void eel_image_table_finalize (GObject *object) /* GtkWidgetClass methods */ static void eel_image_table_realize (GtkWidget *widget); -static void eel_image_table_unrealize (GtkWidget *widget); /* GtkContainerClass methods */ static void eel_image_table_remove (GtkContainer *container, @@ -126,7 +124,6 @@ eel_image_table_class_init (EelImageTableClass *image_table_class) /* GtkWidgetClass */ widget_class->realize = eel_image_table_realize; - widget_class->unrealize = eel_image_table_unrealize; /* GtkContainerClass */ container_class->remove = eel_image_table_remove; @@ -258,25 +255,6 @@ eel_image_table_realize (GtkWidget *widget) widget); } -static void -eel_image_table_unrealize (GtkWidget *widget) -{ - EelImageTable *image_table; - - g_assert (EEL_IS_IMAGE_TABLE (widget)); - - image_table = EEL_IMAGE_TABLE (widget); - - if (image_table->details->clear_gc != NULL) - { - g_object_unref (image_table->details->clear_gc); - image_table->details->clear_gc = NULL; - } - - /* Chain unrealize */ - EEL_CALL_PARENT (GTK_WIDGET_CLASS, unrealize, (widget)); -} - /* GtkContainerClass methods */ static void eel_image_table_remove (GtkContainer *container, -- cgit v1.2.1 From 3731b35d212b5efed3835efe7e50be55970dfe8e Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 14:02:27 +0200 Subject: [lc-p] port CajaCellRendererPixbufEmblem to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=dfbf8b9b5636dceb3d6291c980d2c349afc849d7 --- libcaja-private/caja-cell-renderer-pixbuf-emblem.c | 49 +++++++--------------- 1 file changed, 16 insertions(+), 33 deletions(-) diff --git a/libcaja-private/caja-cell-renderer-pixbuf-emblem.c b/libcaja-private/caja-cell-renderer-pixbuf-emblem.c index 4fec3a4a..63cbf3db 100644 --- a/libcaja-private/caja-cell-renderer-pixbuf-emblem.c +++ b/libcaja-private/caja-cell-renderer-pixbuf-emblem.c @@ -428,10 +428,10 @@ caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell, GdkPixbuf *pixbuf; GdkRectangle pix_rect; GdkRectangle pix_emblem_rect; - GdkRectangle draw_rect; gboolean stock_pixbuf = FALSE; gint xpad, ypad; gboolean is_expander, is_expanded; + cairo_t *cr; pixbuf = cellpixbuf->pixbuf; g_object_get (cell, @@ -476,22 +476,15 @@ caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell, pix_rect.width -= xpad * 2; pix_rect.height -= ypad * 2; - if (gdk_rectangle_intersect (cell_area, &pix_rect, &draw_rect) && - gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect)) - { - gdk_draw_pixbuf (window, - gtk_widget_get_style (widget)->black_gc, - pixbuf, - /* pixbuf 0, 0 is at pix_rect.x, pix_rect.y */ - draw_rect.x - pix_rect.x, - draw_rect.y - pix_rect.y, - draw_rect.x, - draw_rect.y, - draw_rect.width, - draw_rect.height, - GDK_RGB_DITHER_NORMAL, - 0, 0); - } + cr = gdk_cairo_create (window); + gdk_cairo_rectangle (cr, expose_area); + cairo_clip (cr); + gdk_cairo_rectangle (cr, cell_area); + cairo_clip (cr); + + gdk_cairo_set_source_pixbuf (cr, pixbuf, pix_rect.x, pix_rect.y); + gdk_cairo_rectangle (cr, &pix_rect); + cairo_fill (cr); if (cellpixbuf->pixbuf_emblem) { @@ -499,21 +492,11 @@ caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell, pix_emblem_rect.height = gdk_pixbuf_get_height (cellpixbuf->pixbuf_emblem); pix_emblem_rect.x = pix_rect.x; pix_emblem_rect.y = pix_rect.y + pix_rect.height - pix_emblem_rect.height; - if (gdk_rectangle_intersect (cell_area, &pix_emblem_rect, &draw_rect) && - gdk_rectangle_intersect (expose_area, &draw_rect, &draw_rect)) - { - gdk_draw_pixbuf (window, - gtk_widget_get_style (widget)->black_gc, - cellpixbuf->pixbuf_emblem, - /* pixbuf 0, 0 is at pix_emblem_rect.x, pix_emblem_rect.y */ - draw_rect.x - pix_emblem_rect.x, - draw_rect.y - pix_emblem_rect.y, - draw_rect.x, - draw_rect.y, - draw_rect.width, - draw_rect.height, - GDK_RGB_DITHER_NORMAL, - 0, 0); - } + gdk_cairo_set_source_pixbuf (cr, cellpixbuf->pixbuf_emblem, + pix_emblem_rect.x, pix_emblem_rect.y); + gdk_cairo_rectangle (cr, &pix_emblem_rect); + cairo_fill (cr); } + + cairo_destory (cr); } -- cgit v1.2.1 From fada3fccfa2e72360fc932a9d58a01268bff0fea Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 14:05:37 +0200 Subject: [lc-p] port CajaDirectoryBackground to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=6c691075c09ec23620484da00ffd43d3dfe0b75b --- libcaja-private/caja-directory-background.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libcaja-private/caja-directory-background.c b/libcaja-private/caja-directory-background.c index 05a0f8e5..21aea675 100644 --- a/libcaja-private/caja-directory-background.c +++ b/libcaja-private/caja-directory-background.c @@ -126,8 +126,6 @@ read_color (const char *key, GdkColor *color) { gdk_color_parse ("black", color); } - - gdk_rgb_find_color (gdk_rgb_get_colormap (), color); } static void -- cgit v1.2.1 From d51a2a8235d5d6dc380e0482d2fdddeb60b29dc1 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 14:47:33 +0200 Subject: [lc-p] port CajaIconCanvasItem to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=89bd44de6bb11450b88d9d160593b65d62467579 --- libcaja-private/caja-icon-canvas-item.c | 181 ++++++++++++++------------------ 1 file changed, 77 insertions(+), 104 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index db0b5280..cfb16105 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -243,8 +243,7 @@ static void draw_label_layout (CajaIconCanvasItem gboolean highlight, GdkColor *label_color, int x, - int y, - GdkGC *gc); + int y); static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item, EelIRect canvas_rect, GtkCornerType *corner); @@ -548,7 +547,6 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, GdkPixmap *pixmap; EelCanvas *canvas; GdkScreen *screen; - GdkGC *gc; int width, height; int item_offset_x, item_offset_y; EelIRect icon_rect; @@ -618,34 +616,21 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, GDK_INTERP_BILINEAR, 255); } - /* clear the pixmap */ + /* draw pixbuf to mask and pixmap */ cr = gdk_cairo_create (pixmap); - cairo_set_operator (cr, CAIRO_OPERATOR_CLEAR); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_paint (cr); cairo_destroy (cr); - gc = gdk_gc_new (pixmap); - gdk_draw_pixbuf (pixmap, gc, pixbuf, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NORMAL, - 0, 0); - g_object_unref (gc); - *mask = gdk_pixmap_new (gdk_screen_get_root_window (screen), width, height, 1); - gc = gdk_gc_new (*mask); - gdk_draw_rectangle (*mask, gc, - TRUE, - 0, 0, - width, height); - g_object_unref (gc); - - gdk_pixbuf_render_threshold_alpha (pixbuf, *mask, - 0, 0, 0, 0, - gdk_pixbuf_get_width (pixbuf), gdk_pixbuf_get_height (pixbuf), - 128); + cr = gdk_cairo_create (*mask); + cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); + gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); + cairo_paint (cr); + cairo_destroy (cr); draw_embedded_text (item, GDK_DRAWABLE (pixmap), item_offset_x, item_offset_y); @@ -1389,7 +1374,6 @@ draw_label_text (CajaIconCanvasItem *item, PangoLayout *editable_layout; PangoLayout *additional_layout; GdkColor *label_color; - GdkGC *gc; gboolean have_editable, have_additional; gboolean needs_frame, needs_highlight, prelight_label, is_rtl_label_beside; EelIRect text_rect; @@ -1400,8 +1384,6 @@ draw_label_text (CajaIconCanvasItem *item, return; #endif - gc = NULL; - canvas_item = EEL_CANVAS_ITEM (item); details = item->details; @@ -1497,7 +1479,7 @@ draw_label_text (CajaIconCanvasItem *item, } } - gc = caja_icon_container_get_label_color_and_gc + caja_icon_container_get_label_color (CAJA_ICON_CONTAINER (canvas_item->canvas), &label_color, TRUE, needs_highlight, prelight_label & item->details->is_prelit); @@ -1506,7 +1488,7 @@ draw_label_text (CajaIconCanvasItem *item, editable_layout, needs_highlight, label_color, x, - text_rect.y0 + TEXT_BACK_PADDING_Y, gc); + text_rect.y0 + TEXT_BACK_PADDING_Y); } if (have_additional) @@ -1514,7 +1496,7 @@ draw_label_text (CajaIconCanvasItem *item, additional_layout = get_label_layout (&item->details->additional_text_layout, item, item->details->additional_text); prepare_pango_layout_for_draw (item, additional_layout); - gc = caja_icon_container_get_label_color_and_gc + caja_icon_container_get_label_color (CAJA_ICON_CONTAINER (canvas_item->canvas), &label_color, FALSE, needs_highlight, FALSE); @@ -1523,7 +1505,7 @@ draw_label_text (CajaIconCanvasItem *item, additional_layout, needs_highlight, label_color, x, - text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y, gc); + text_rect.y0 + details->editable_text_height + LABEL_LINE_SPACING + TEXT_BACK_PADDING_Y); } if (!create_mask && item->details->is_highlighted_as_keyboard_focus) @@ -1615,11 +1597,10 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, const EelIRect *rect) { GtkWidget *widget; - GdkGC *gc; GdkPixbuf *knob_pixbuf; - GdkBitmap *stipple; int knob_width, knob_height; - GtkStyle *style; + double dash[2] = { 1.0, 1.0 }; + cairo_t *cr; if (!item->details->show_stretch_handles) { @@ -1627,44 +1608,41 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, } widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas); - style = gtk_widget_get_style (widget); - gc = gdk_gc_new (drawable); + cr = gdk_cairo_create (drawable); knob_pixbuf = get_knob_pixbuf (); knob_width = gdk_pixbuf_get_width (knob_pixbuf); knob_height = gdk_pixbuf_get_height (knob_pixbuf); - stipple = eel_stipple_bitmap_for_screen ( - gdk_drawable_get_screen (GDK_DRAWABLE (drawable))); - /* first draw the box */ - gdk_gc_set_rgb_fg_color (gc, &style->white); - gdk_draw_rectangle - (drawable, gc, FALSE, - rect->x0, - rect->y0, - rect->x1 - rect->x0 - 1, - rect->y1 - rect->y0 - 1); - - gdk_gc_set_rgb_fg_color (gc, &style->black); - gdk_gc_set_stipple (gc, stipple); - gdk_gc_set_fill (gc, GDK_STIPPLED); - gdk_draw_rectangle - (drawable, gc, FALSE, - rect->x0, - rect->y0, - rect->x1 - rect->x0 - 1, - rect->y1 - rect->y0 - 1); + cairo_set_source_rgb (cr, 1, 1, 1); + cairo_set_line_width (cr, 1.0); + cairo_rectangle (cr, + rect->x0 + 0.5, + rect->y0 + 0.5, + rect->x1 - rect->x0 - 1, + rect->y1 - rect->y0 - 1); + cairo_stroke (cr); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_set_dash (cr, dash, G_N_ELEMENTS (dash), 0); + cairo_rectangle (cr, + rect->x0 + 0.5, + rect->y0 + 0.5, + rect->x1 - rect->x0 - 1, + rect->y1 - rect->y0 - 1); + cairo_stroke (cr); /* draw the stretch handles themselves */ - draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y0); - draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height); - draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0); - draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height); - g_object_unref (knob_pixbuf); + gdk_cairo_set_source_pixbuf (cr, knob_pixbuf, rect->x0, rect->y0); + cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); + cairo_rectangle (cr, + rect->x1 - knob_width, rect->y1 - knob_height, + 2 * knob_width, 2 * knob_height); + cairo_fill (cr); - g_object_unref (gc); + cairo_destroy (cr); } static void @@ -1827,13 +1805,12 @@ emblem_layout_next (EmblemLayout *layout, static void draw_pixbuf (GdkPixbuf *pixbuf, GdkDrawable *drawable, int x, int y) { - /* FIXME bugzilla.gnome.org 40703: - * Dither would be better if we passed dither values. - */ - gdk_draw_pixbuf (drawable, NULL, pixbuf, 0, 0, x, y, - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - GDK_RGB_DITHER_NORMAL, 0, 0); + cairo_t *cr = gdk_cairo_create (drawable); + + gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); + cairo_paint (cr); + + cairo_destroy (cr); } /* shared code to highlight or dim the passed-in pixbuf */ @@ -2003,11 +1980,10 @@ draw_embedded_text (CajaIconCanvasItem *item, GdkDrawable *drawable, int x, int y) { - GdkGC *gc; - GdkRectangle clip_rect; PangoLayout *layout; PangoContext *context; PangoFontDescription *desc; + cairo_t *cr; if (item->details->embedded_text == NULL || item->details->embedded_text_rect.width == 0 || @@ -2036,22 +2012,22 @@ draw_embedded_text (CajaIconCanvasItem *item, } } - gc = gdk_gc_new (drawable); - - clip_rect.x = x + item->details->embedded_text_rect.x; - clip_rect.y = y + item->details->embedded_text_rect.y; - clip_rect.width = item->details->embedded_text_rect.width; - clip_rect.height = item->details->embedded_text_rect.height; - - gdk_gc_set_clip_rectangle (gc, &clip_rect); + cr = gdk_cairo_create (drawable); - gdk_draw_layout (drawable, gc, + cairo_rectangle (cr, x + item->details->embedded_text_rect.x, y + item->details->embedded_text_rect.y, - layout); + item->details->embedded_text_rect.width, + item->details->embedded_text_rect.height); + cairo_clip (cr); - g_object_unref (gc); - g_object_unref (layout); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_move_to (cr, + x + item->details->embedded_text_rect.x, + y + item->details->embedded_text_rect.y); + pango_cairo_show_layout (cr, layout); + + cairo_destroy (cr); } /* Draw the icon item for non-anti-aliased mode. */ @@ -2064,8 +2040,9 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, EelIRect icon_rect, emblem_rect; EmblemLayout emblem_layout; GdkPixbuf *emblem_pixbuf, *temp_pixbuf; - GdkRectangle draw_rect, pixbuf_rect; + GdkRectangle pixbuf_rect; gboolean is_rtl; + cairo_t *cr; icon_item = CAJA_ICON_CANVAS_ITEM (item); details = icon_item->details; @@ -2085,20 +2062,14 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, pixbuf_rect.y = icon_rect.y0; pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf); pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf); - if (gdk_rectangle_intersect (&(expose->area), &pixbuf_rect, &draw_rect)) - { - gdk_draw_pixbuf (drawable, - NULL, - temp_pixbuf, - draw_rect.x - pixbuf_rect.x, - draw_rect.y - pixbuf_rect.y, - draw_rect.x, - draw_rect.y, - draw_rect.width, - draw_rect.height, - GDK_RGB_DITHER_NORMAL, - 0,0); - } + + cr = gdk_cairo_create (drawable); + gdk_cairo_rectangle (cr, &expose->area); + cairo_clip (cr); + gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y); + gdk_cairo_rectangle (cr, &pixbuf_rect); + cairo_fill (cr); + cairo_destroy (cr); g_object_unref (temp_pixbuf); draw_embedded_text (icon_item, drawable, icon_rect.x0, icon_rect.y0); @@ -2239,8 +2210,7 @@ draw_label_layout (CajaIconCanvasItem *item, gboolean highlight, GdkColor *label_color, int x, - int y, - GdkGC *gc) + int y) { if (drawable == NULL) { @@ -2255,7 +2225,7 @@ draw_label_layout (CajaIconCanvasItem *item, if (!highlight && (CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows)) { /* draw a drop shadow */ - eel_gdk_draw_layout_with_drop_shadow (drawable, gc, + eel_gdk_draw_layout_with_drop_shadow (drawable, label_color, >k_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black, x, y, @@ -2263,9 +2233,12 @@ draw_label_layout (CajaIconCanvasItem *item, } else { - gdk_draw_layout (drawable, gc, - x, y, - layout); + cairo_t *cr = gdk_cairo_create (drawable); + + gdk_cairo_set_source_color (cr, label_color); + cairo_move_to (cr, x, y); + pango_cairo_show_layout (cr, layout); + cairo_destroy (cr); } } -- cgit v1.2.1 From a694648f1a1a373f96e97b632627bb30d1c5646b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 14:52:27 +0200 Subject: [lc-p] port CajaIconContainer to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=8eab39c06628da7cf919be77d922024198105f0a --- libcaja-private/caja-icon-container.c | 40 ++++------------------------------- 1 file changed, 4 insertions(+), 36 deletions(-) diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index e3457f31..b9a7dfc4 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4565,7 +4565,6 @@ size_allocate (GtkWidget *widget, static void realize (GtkWidget *widget) { - GdkBitmap *stipple; GtkAdjustment *vadj, *hadj; CajaIconContainer *container; @@ -4581,15 +4580,10 @@ realize (GtkWidget *widget) } /* Set up DnD. */ - caja_icon_dnd_init (container, NULL); + caja_icon_dnd_init (container); setup_label_gcs (container); - stipple = eel_stipple_bitmap_for_screen - (gdk_drawable_get_screen (GDK_DRAWABLE (gtk_widget_get_window (widget)))); - - caja_icon_dnd_set_stipple (container, stipple); - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (widget)); g_signal_connect (hadj, "value_changed", G_CALLBACK (handle_hadjustment_changed), widget); @@ -4603,20 +4597,10 @@ realize (GtkWidget *widget) static void unrealize (GtkWidget *widget) { - int i; CajaIconContainer *container; container = CAJA_ICON_CONTAINER (widget); - for (i = 0; i < LAST_LABEL_COLOR; i++) - { - if (container->details->label_gcs [i]) - { - g_object_unref (container->details->label_gcs [i]); - container->details->label_gcs [i] = NULL; - } - } - caja_icon_dnd_fini (container); if (container->details->typeselect_flush_timeout) @@ -9331,8 +9315,8 @@ caja_icon_container_set_single_click_mode (CajaIconContainer *container, /* update the label color when the background changes */ -GdkGC * -caja_icon_container_get_label_color_and_gc (CajaIconContainer *container, +void +caja_icon_container_get_label_color (CajaIconContainer *container, GdkColor **color, gboolean is_name, gboolean is_highlight, @@ -9388,28 +9372,12 @@ caja_icon_container_get_label_color_and_gc (CajaIconContainer *container, { *color = &container->details->label_colors [idx]; } - - return container->details->label_gcs [idx]; } static void setup_gc_with_fg (CajaIconContainer *container, int idx, guint32 color) { - GdkGC *gc; - GdkColor gcolor; - - gcolor = eel_gdk_rgb_to_color (color); - container->details->label_colors [idx] = gcolor; - - gc = gdk_gc_new (gtk_layout_get_bin_window (GTK_LAYOUT (container))); - gdk_gc_set_rgb_fg_color (gc, &gcolor); - - if (container->details->label_gcs [idx]) - { - g_object_unref (container->details->label_gcs [idx]); - } - - container->details->label_gcs [idx] = gc; + container->details->label_colors [idx] = eel_gdk_rgb_to_color (color); } static void -- cgit v1.2.1 From c28f508865f21658ad4319a561f999c87cf94703 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:00:30 +0200 Subject: [lc-p] port caja-icon-dnd to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=34a376c97717cb05187b3d880e991c2d23511109 --- libcaja-private/caja-icon-dnd.c | 46 +++++++---------------------------------- libcaja-private/caja-icon-dnd.h | 8 +------ 2 files changed, 9 insertions(+), 45 deletions(-) diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 12cc5cbf..204f9e80 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -98,7 +98,6 @@ create_selection_shadow (CajaIconContainer *container, { EelCanvasGroup *group; EelCanvas *canvas; - GdkBitmap *stipple; int max_x, max_y; int min_x, min_y; GList *p; @@ -115,9 +114,6 @@ create_selection_shadow (CajaIconContainer *container, return NULL; } - stipple = container->details->dnd_info->stipple; - g_return_val_if_fail (stipple != NULL, NULL); - canvas = EEL_CANVAS (container); gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); @@ -164,7 +160,6 @@ create_selection_shadow (CajaIconContainer *container, "x2", (double) x2, "y2", (double) y2, "outline_color", "black", - "outline_stipple", stipple, "width_pixels", 1, NULL); } @@ -1664,6 +1659,7 @@ drag_highlight_expose (GtkWidget *widget, { gint x, y, width, height; GdkWindow *window; + cairo_t *cr; x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget))); y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget))); @@ -1682,10 +1678,12 @@ drag_highlight_expose (GtkWidget *widget, NULL, widget, "dnd", x, y, width, height); - gdk_draw_rectangle (window, - (gtk_widget_get_style(widget))->black_gc, - FALSE, - x, y, width - 1, height - 1); + cr = gdk_cairo_create (window); + cairo_set_line_width (cr, 1.0); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1); + cairo_stroke (cr); + cairo_destroy (cr); return FALSE; } @@ -2029,25 +2027,7 @@ drag_data_received_callback (GtkWidget *widget, } void -caja_icon_dnd_set_stipple (CajaIconContainer *container, - GdkBitmap *stipple) -{ - if (stipple != NULL) - { - g_object_ref (stipple); - } - - if (container->details->dnd_info->stipple != NULL) - { - g_object_unref (container->details->dnd_info->stipple); - } - - container->details->dnd_info->stipple = stipple; -} - -void -caja_icon_dnd_init (CajaIconContainer *container, - GdkBitmap *stipple) +caja_icon_dnd_init (CajaIconContainer *container) { GtkTargetList *targets; int n_elements; @@ -2096,11 +2076,6 @@ caja_icon_dnd_init (CajaIconContainer *container, G_CALLBACK (drag_drop_callback), NULL); g_signal_connect (container, "drag_leave", G_CALLBACK (drag_leave_callback), NULL); - - if (stipple != NULL) - { - container->details->dnd_info->stipple = g_object_ref (stipple); - } } void @@ -2112,11 +2087,6 @@ caja_icon_dnd_fini (CajaIconContainer *container) { stop_auto_scroll (container); - if (container->details->dnd_info->stipple != NULL) - { - g_object_unref (container->details->dnd_info->stipple); - } - caja_drag_finalize (&container->details->dnd_info->drag_info); container->details->dnd_info = NULL; } diff --git a/libcaja-private/caja-icon-dnd.h b/libcaja-private/caja-icon-dnd.h index 1070c41f..6cf14aa0 100644 --- a/libcaja-private/caja-icon-dnd.h +++ b/libcaja-private/caja-icon-dnd.h @@ -39,19 +39,13 @@ typedef struct gboolean highlighted; - /* Stipple for drawing icon shadows during DnD. */ - GdkBitmap *stipple; - /* Shadow for the icons being dragged. */ EelCanvasItem *shadow; } CajaIconDndInfo; -void caja_icon_dnd_init (CajaIconContainer *container, - GdkBitmap *stipple); +void caja_icon_dnd_init (CajaIconContainer *container); void caja_icon_dnd_fini (CajaIconContainer *container); -void caja_icon_dnd_set_stipple (CajaIconContainer *container, - GdkBitmap *stipple); void caja_icon_dnd_begin_drag (CajaIconContainer *container, GdkDragAction actions, gint button, -- cgit v1.2.1 From 3b6a715fca493281fdb2d0c83d69ce28a21732dc Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:02:37 +0200 Subject: [lc-p] port caja-icon-private to cairo drawing http://git.gnome.org/browse/nautilus/commit/?id=cbdf5829637093c0a5c0a4ff4d303ad184847627 --- libcaja-private/caja-icon-private.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libcaja-private/caja-icon-private.h b/libcaja-private/caja-icon-private.h index 8258ca15..cf7ef592 100644 --- a/libcaja-private/caja-icon-private.h +++ b/libcaja-private/caja-icon-private.h @@ -219,7 +219,6 @@ struct CajaIconContainerDetails guint32 normal_icon_color_rgba; /* colors for text labels */ - GdkGC *label_gcs [LAST_LABEL_COLOR]; GdkColor label_colors [LAST_LABEL_COLOR]; /* State used so arrow keys don't wander if icons aren't lined up. @@ -327,10 +326,10 @@ gboolean caja_icon_container_scroll (CajaIconContainer void caja_icon_container_update_scroll_region (CajaIconContainer *container); /* label color for items */ -GdkGC *caja_icon_container_get_label_color_and_gc (CajaIconContainer *container, +void caja_icon_container_get_label_color (CajaIconContainer *container, GdkColor **color, gboolean first_line, gboolean needs_highlight, - gboolean is_prelit); + gboolean is_prelit); #endif /* CAJA_ICON_CONTAINER_PRIVATE_H */ -- cgit v1.2.1 From b8b05eb092ded402d9b0d1b0a80e0627ddbc657a Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:15:34 +0200 Subject: [lc-p] make drawing of resize knobs work again http://git.gnome.org/browse/nautilus/commit/?id=29d7b86087f6ab86f6abd6c3c08c4e1d94b92b36 --- libcaja-private/caja-icon-canvas-item.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index cfb16105..64ba3020 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1633,16 +1633,15 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, rect->y1 - rect->y0 - 1); cairo_stroke (cr); - /* draw the stretch handles themselves */ + cairo_destroy (cr); - gdk_cairo_set_source_pixbuf (cr, knob_pixbuf, rect->x0, rect->y0); - cairo_pattern_set_extend (cairo_get_source (cr), CAIRO_EXTEND_REPEAT); - cairo_rectangle (cr, - rect->x1 - knob_width, rect->y1 - knob_height, - 2 * knob_width, 2 * knob_height); - cairo_fill (cr); + /* draw the stretch handles themselves */ + draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y0); + draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height); + draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0); + draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height); - cairo_destroy (cr); + g_object_unref (knob_pixbuf); } static void -- cgit v1.2.1 From d602f60fa4df0d2913e2d6b45f32c4bb1020583a Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:18:56 +0200 Subject: [lc-p] properly dash the icon when resizing it http://git.gnome.org/browse/nautilus/commit/?id=b10d8c00395026719dc0840e9d82e682c7c4e436 --- libcaja-private/caja-icon-canvas-item.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 64ba3020..e35efec2 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1599,7 +1599,7 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, GtkWidget *widget; GdkPixbuf *knob_pixbuf; int knob_width, knob_height; - double dash[2] = { 1.0, 1.0 }; + double dash = { 2.0 }; cairo_t *cr; if (!item->details->show_stretch_handles) @@ -1615,17 +1615,9 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, knob_height = gdk_pixbuf_get_height (knob_pixbuf); /* first draw the box */ - cairo_set_source_rgb (cr, 1, 1, 1); - cairo_set_line_width (cr, 1.0); - cairo_rectangle (cr, - rect->x0 + 0.5, - rect->y0 + 0.5, - rect->x1 - rect->x0 - 1, - rect->y1 - rect->y0 - 1); - cairo_stroke (cr); - cairo_set_source_rgb (cr, 0, 0, 0); - cairo_set_dash (cr, dash, G_N_ELEMENTS (dash), 0); + cairo_set_dash (cr, &dash, 1, 0); + cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, rect->x0 + 0.5, rect->y0 + 0.5, -- cgit v1.2.1 From 250d31f0d9f533dee96c91859c54883179a896eb Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:24:25 +0200 Subject: [eel] add an 'outline-stippling' property to the rect item http://git.gnome.org/browse/nautilus/commit/?id=b453aaacb0b17392eacacd8a9e378b7227da6413 --- eel/eel-canvas-rect-ellipse.c | 24 ++++++++++++++++++++++++ eel/eel-canvas-rect-ellipse.h | 2 ++ 2 files changed, 26 insertions(+) diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index 7e2a6df8..9d738243 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -60,6 +60,7 @@ enum PROP_OUTLINE_COLOR, PROP_OUTLINE_COLOR_GDK, PROP_OUTLINE_COLOR_RGBA, + PROP_OUTLINE_STIPPLING, PROP_WIDTH_PIXELS, PROP_WIDTH_UNITS }; @@ -204,6 +205,11 @@ eel_canvas_re_class_init (EelCanvasREClass *klass) g_param_spec_uint ("outline-color-rgba", NULL, NULL, 0, G_MAXUINT, 0, G_PARAM_READWRITE)); + g_object_class_install_property + (gobject_class, + PROP_OUTLINE_STIPPLING, + g_param_spec_boolean ("outline-stippling", NULL, NULL, + FALSE, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_WIDTH_PIXELS, @@ -441,6 +447,12 @@ eel_canvas_re_set_property (GObject *object, eel_canvas_item_request_redraw (item); break; + case PROP_OUTLINE_STIPPLING: + re->outline_stippling = g_value_get_boolean (value); + + eel_canvas_item_request_redraw (item); + break; + case PROP_WIDTH_PIXELS: re->width = g_value_get_uint (value); re->width_pixels = TRUE; @@ -526,6 +538,10 @@ eel_canvas_re_get_property (GObject *object, g_value_set_uint (value, re->outline_color); break; + case PROP_OUTLINE_STIPPLING: + g_value_set_boolean (value, re->outline_stippling); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); break; @@ -751,6 +767,8 @@ eel_canvas_set_source_color (cairo_t *cr, ((rgba >> 0) & 0xff) / 255.); } +#define DASH_ON 0.8 +#define DASH_OFF 1.7 static void eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) { @@ -802,6 +820,12 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose cairo_set_line_width (cr, (int) (re->width * re->item.canvas->pixels_per_unit + 0.5)); } + if (re->outline_stippling) { + double dash[2] = { DASH_ON, DASH_OFF }; + + cairo_set_dash (cr, dash, G_N_ELEMENTS (dash), 0); + } + cairo_rectangle (cr, cx1 + 0.5, cy1 + 0.5, cx2 - cx1, diff --git a/eel/eel-canvas-rect-ellipse.h b/eel/eel-canvas-rect-ellipse.h index 7166df8f..aaccf560 100644 --- a/eel/eel-canvas-rect-ellipse.h +++ b/eel/eel-canvas-rect-ellipse.h @@ -87,6 +87,8 @@ extern "C" { guint fill_color; /* Fill color, RGBA */ guint outline_color; /* Outline color, RGBA */ + gboolean outline_stippling; + /* Configuration flags */ unsigned int fill_set : 1; /* Is fill color set? */ -- cgit v1.2.1 From dc5d53f773d3a7fa9a0c5ce4e99185cc97789960 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:25:58 +0200 Subject: [lc-p] use the 'outline-stippling' property on DnD http://git.gnome.org/browse/nautilus/commit/?id=aa43821e73d60804a3f0f2ebafb66aab53b440e1 --- libcaja-private/caja-icon-dnd.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 204f9e80..2e7dc32a 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -160,6 +160,7 @@ create_selection_shadow (CajaIconContainer *container, "x2", (double) x2, "y2", (double) y2, "outline_color", "black", + "outline-stippling", TRUE, "width_pixels", 1, NULL); } -- cgit v1.2.1 From 27a47dfbe833e8ae08ce6f1bab75e1e0edec09dd Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:47:17 +0200 Subject: [eel] remove unused eel-i18n.[ch] was: [eel] remove eel-i18n.[ch] http://git.gnome.org/browse/nautilus/commit/?id=742b9fb1550ceec9284f581c3741c0a864ca82fd --- eel/Makefile.am | 2 -- eel/eel-i18n.c | 52 ---------------------------------------------------- eel/eel-i18n.h | 55 ------------------------------------------------------- 3 files changed, 109 deletions(-) delete mode 100644 eel/eel-i18n.c delete mode 100644 eel/eel-i18n.h diff --git a/eel/Makefile.am b/eel/Makefile.am index a973fee8..e061e961 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -46,7 +46,6 @@ libeel_2_la_SOURCES = \ eel-graphic-effects.c \ eel-gtk-container.c \ eel-gtk-extensions.c \ - eel-i18n.c \ eel-image-table.c \ eel-labeled-image.c \ eel-lib-self-check-functions.c \ @@ -82,7 +81,6 @@ eel_headers = \ eel-gtk-container.h \ eel-gtk-extensions.h \ eel-gtk-macros.h \ - eel-i18n.h \ eel-image-table.h \ eel-labeled-image.h \ eel-pango-extensions.h \ diff --git a/eel/eel-i18n.c b/eel/eel-i18n.c deleted file mode 100644 index 9e7ef29b..00000000 --- a/eel/eel-i18n.c +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-i18n.c: I18n stuff for Eel. - - Copyright (C) 2002 MandrakeSoft. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Frederic Crozat -*/ - -#include -#include - -#include "eel-i18n.h" - -#ifdef ENABLE_NLS - -#include - -const char* _eel_gettext(const char* str) -{ - static gboolean _eel_gettext_initialized = FALSE; - - if (!_eel_gettext_initialized) - { - bindtextdomain(GETTEXT_PACKAGE, MATELOCALEDIR); - -#ifdef HAVE_BIND_TEXTDOMAIN_CODESET - bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); -#endif - - _eel_gettext_initialized = TRUE; - } - - return dgettext(GETTEXT_PACKAGE, str); -} - -#endif /* ENABLE_NLS */ diff --git a/eel/eel-i18n.h b/eel/eel-i18n.h deleted file mode 100644 index 68b71f11..00000000 --- a/eel/eel-i18n.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-i18n.h: I18n stuff for Eel. - - Copyright (C) 2002 MandrakeSoft - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Frederic Crozat -*/ - -#ifndef EEL_I18N_H -#define EEL_I18N_H - -#ifdef ENABLE_NLS - -#include - - -const char* _eel_gettext(const char* str) G_GNUC_FORMAT(1); - -#include -#define _(String) _eel_gettext(String) - -#ifdef gettext_noop -#define N_(String) gettext_noop(String) -#else -#define N_(String) (String) -#endif - -#else /* NLS is disabled */ -#define _(String) (String) -#define N_(String) (String) -#define textdomain(String) (String) -#define gettext(String) (String) -#define dgettext(Domain,String) (String) -#define dcgettext(Domain,String,Type) (String) -#define bindtextdomain(Domain,Directory) (Domain) -#endif - - -#endif /* EEL_I18N_H */ -- cgit v1.2.1 From 516b5208e0b3c368130334dbdf01b810486cd8d3 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 15:54:11 +0200 Subject: [eel] use glib's i18n API instead of eel's http://git.gnome.org/browse/nautilus/commit/?id=8447fd3670021530b6340829f27f1d689b633d3a --- eel/eel-alert-dialog.c | 4 +++- eel/eel-canvas.c | 2 +- eel/eel-editable-label.c | 2 +- eel/eel-glib-extensions.c | 1 - eel/eel-mate-extensions.c | 1 - eel/eel-stock-dialogs.c | 2 +- eel/eel-vfs-extensions.c | 2 +- eel/eel-xml-extensions.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/eel/eel-alert-dialog.c b/eel/eel-alert-dialog.c index 726e4c67..0bfdc81e 100644 --- a/eel/eel-alert-dialog.c +++ b/eel/eel-alert-dialog.c @@ -21,8 +21,10 @@ #include #include "eel-alert-dialog.h" -#include "eel-i18n.h" #include "eel-gtk-macros.h" + + +#include #include #include diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 7b1b39dd..ff38d197 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -68,8 +68,8 @@ #include #include #include +#include #include "eel-canvas.h" -#include "eel-i18n.h" #include "eel-marshal.h" diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index fb20af85..50329345 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -28,11 +28,11 @@ #include #include "eel-editable-label.h" -#include "eel-i18n.h" #include "eel-marshal.h" #include "eel-accessibility.h" #include +#include #include #include #include diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index 67986b32..e747eb46 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -30,7 +30,6 @@ #include "eel-debug.h" #include "eel-lib-self-check-functions.h" #include "eel-string.h" -#include "eel-i18n.h" #include #include #include diff --git a/eel/eel-mate-extensions.c b/eel/eel-mate-extensions.c index aca3cddf..006144dc 100644 --- a/eel/eel-mate-extensions.c +++ b/eel/eel-mate-extensions.c @@ -34,7 +34,6 @@ #include "eel-glib-extensions.h" #include "eel-gtk-extensions.h" #include "eel-stock-dialogs.h" -#include "eel-i18n.h" #include #include #include diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c index c9cadfb3..eb675733 100644 --- a/eel/eel-stock-dialogs.c +++ b/eel/eel-stock-dialogs.c @@ -29,7 +29,7 @@ #include "eel-glib-extensions.h" #include "eel-mate-extensions.h" #include "eel-string.h" -#include "eel-i18n.h" +#include #include #define TIMED_WAIT_STANDARD_DURATION 2000 diff --git a/eel/eel-vfs-extensions.c b/eel/eel-vfs-extensions.c index 27db2a46..300b4969 100644 --- a/eel/eel-vfs-extensions.c +++ b/eel/eel-vfs-extensions.c @@ -27,11 +27,11 @@ */ #include -#include "eel-i18n.h" #include "eel-vfs-extensions.h" #include "eel-glib-extensions.h" #include "eel-lib-self-check-functions.h" #include +#include #include #include "eel-string.h" diff --git a/eel/eel-xml-extensions.c b/eel/eel-xml-extensions.c index fe4a91a4..2bcd4477 100644 --- a/eel/eel-xml-extensions.c +++ b/eel/eel-xml-extensions.c @@ -26,8 +26,8 @@ #include "eel-xml-extensions.h" #include "eel-string.h" -#include "eel-i18n.h" #include +#include #include #include -- cgit v1.2.1 From 1e18c64a21b04f1ecb56d763614fb0da36a38408 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 04:36:53 +0200 Subject: [eel-gdk-pixbuf-extensions] don't include eel-art-gtk-extensions.h http://git.gnome.org/browse/nautilus/commit/?id=2bfd4e3694e2f726592bae5341d7e4c7464ec415 --- eel/eel-gdk-pixbuf-extensions.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index 62bc58eb..fed0eb45 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -26,8 +26,6 @@ #include #include "eel-gdk-pixbuf-extensions.h" -#include "eel-art-gtk-extensions.h" -#include "eel-debug-drawing.h" #include "eel-debug.h" #include "eel-gdk-extensions.h" #include "eel-glib-extensions.h" -- cgit v1.2.1 From f61503852a1ba50b0a258438e7ce3ca4c7545f45 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:07:45 +0200 Subject: [eel] remove unused code from eel-gdk-extensions http://git.gnome.org/browse/nautilus/commit/?id=6b2a053985b8c37aa1038e7a01ab05d7dd15aa2e --- eel/eel-gdk-extensions.c | 197 ----------------------------------------------- eel/eel-gdk-extensions.h | 27 ------- 2 files changed, 224 deletions(-) diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index ab3972ef..f9e28f6d 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -39,48 +39,6 @@ #define GRADIENT_BAND_SIZE 4 -/** - * eel_gdk_rectangle_contains_rectangle: - * @outer: Rectangle possibly containing another rectangle. - * @inner: Rectangle that might be inside. - * - * Retun TRUE if inner rectangle is contained inside outer rectangle - */ -gboolean -eel_gdk_rectangle_contains_rectangle (GdkRectangle outer, GdkRectangle inner) -{ - return outer.x <= inner.x && outer.x + outer.width >= inner.x + inner.width - && outer.y <= inner.y && outer.y + outer.height >= inner.y + inner.height; -} - -/** - * eel_interpolate_color: - * @ratio: Place on line between colors to interpolate. - * @start_color: Color for one end. - * @end_color: Color for the other end - * @interpolated_color: Result. - * - * Compute a color between @start_color and @end_color in color space. - * Currently, the color space used is RGB, but a future version could - * instead do the interpolation in the best color space for expressing - * human perception. - */ -guint32 -eel_interpolate_color (gdouble ratio, - guint32 start_rgb, - guint32 end_rgb) -{ - guchar red, green, blue; - - g_return_val_if_fail (ratio >= 0.0, 0); - g_return_val_if_fail (ratio <= 1.0, 0); - - red = ((start_rgb >> 16) & 0xFF) * (1.0 - ratio) + ((end_rgb >> 16) & 0xFF) * ratio; - green = ((start_rgb >> 8) & 0xFF) * (1.0 - ratio) + ((end_rgb >> 8) & 0xFF) * ratio; - blue = (start_rgb & 0xFF) * (1.0 - ratio) + (end_rgb & 0xFF) * ratio; - return (((red << 8) | green) << 8) | blue; -} - /** * eel_gradient_new * @start_color: Color for the top or left. @@ -387,26 +345,6 @@ eel_gdk_color_parse_with_white_default (const char *color_spec, } } -/** - * eel_parse_rgb_with_white_default - * @color_spec: A color spec, or NULL. - * Returns: An rgb value. - * - * The same as gdk_color_parse, except sets the color to white if - * the spec. can't be parsed instead of returning a boolean flag - * and returns a guint32 rgb value instead of a GdkColor. - */ -guint32 -eel_parse_rgb_with_white_default (const char *color_spec) -{ - GdkColor color; - - eel_gdk_color_parse_with_white_default (color_spec, &color); - return ((color.red << 8) & EEL_RGB_COLOR_RED) - | (color.green & EEL_RGB_COLOR_GREEN) - | ((color.blue >> 8) & EEL_RGB_COLOR_BLUE); -} - guint32 eel_rgb16_to_rgb (gushort r, gushort g, gushort b) { @@ -476,51 +414,6 @@ eel_gdk_rgb_to_color_spec (const guint32 color) return g_strdup_printf ("#%06X", (guint) (color & 0xFFFFFF)); } -static guint32 -eel_shift_color_component (guchar component, float shift_by) -{ - guint32 result; - if (shift_by > 1.0) - { - result = component * (2 - shift_by); - } - else - { - result = 0xff - shift_by * (0xff - component); - } - - return result & 0xff; -} - -/** - * eel_rgb_shift_color - * @color: A color. - * @shift_by: darken or lighten factor. - * Returns: An darkened or lightened rgb value. - * - * Darkens (@shift_by > 1) or lightens (@shift_by < 1) - * @color. - */ -guint32 -eel_rgb_shift_color (guint32 color, float shift_by) -{ - guint32 result; - - /* shift red by shift_by */ - result = eel_shift_color_component((color & 0x00ff0000) >> 16, shift_by); - result <<= 8; - /* shift green by shift_by */ - result |= eel_shift_color_component((color & 0x0000ff00) >> 8, shift_by); - result <<= 8; - /* shift blue by shift_by */ - result |= eel_shift_color_component((color & 0x000000ff), shift_by); - - /* alpha doesn't change */ - result |= (0xff000000 & color); - - return result; -} - /** * eel_gdk_color_is_dark: * @@ -538,26 +431,6 @@ eel_gdk_color_is_dark (GdkColor *color) return intensity < 128; } -/** - * eel_gdk_window_bring_to_front: - * - * Raise window and give it focus. - */ -void -eel_gdk_window_bring_to_front (GdkWindow *window) -{ - /* This takes care of un-iconifying the window and - * raising it if needed. - */ - gdk_window_show (window); - - /* If the window was already showing, it would not have - * the focus at this point. Do a little X trickery to - * ensure it is focused. - */ - eel_gdk_window_focus (window, GDK_CURRENT_TIME); -} - void eel_gdk_window_focus (GdkWindow *window, guint32 timestamp) { @@ -570,70 +443,6 @@ eel_gdk_window_focus (GdkWindow *window, guint32 timestamp) gdk_error_trap_pop (); } -void -eel_gdk_window_set_wm_protocols (GdkWindow *window, - GdkAtom *protocols, - int nprotocols) -{ - Atom *atoms; - int i; - - atoms = g_new (Atom, nprotocols); - for (i = 0; i < nprotocols; i++) - { - atoms[i] = gdk_x11_atom_to_xatom (protocols[i]); - } - - XSetWMProtocols (GDK_WINDOW_XDISPLAY (window), - GDK_WINDOW_XWINDOW (window), - atoms, nprotocols); - - g_free (atoms); -} - -/** - * eel_gdk_window_set_wm_hints_input: - * - * Set the WM_HINTS.input flag to the passed in value - */ -void -eel_gdk_window_set_wm_hints_input (GdkWindow *window, gboolean status) -{ - Display *dpy; - Window id; - XWMHints *wm_hints; - - g_return_if_fail (window != NULL); - - dpy = GDK_WINDOW_XDISPLAY (window); - id = GDK_WINDOW_XWINDOW (window); - - wm_hints = XGetWMHints (dpy, id); - if (wm_hints == 0) - { - wm_hints = XAllocWMHints (); - } - - wm_hints->flags |= InputHint; - wm_hints->input = (status == FALSE) ? False : True; - - XSetWMHints (dpy, id, wm_hints); - XFree (wm_hints); -} - -void -eel_gdk_window_set_invisible_cursor (GdkWindow *window) -{ - GdkCursor *cursor; - - cursor = gdk_cursor_new_for_display (gdk_drawable_get_display (window), - GDK_BLANK_CURSOR); - - gdk_window_set_cursor (window, cursor); - - gdk_cursor_unref (cursor); -} - EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return, guint *width_return, guint *height_return) @@ -733,12 +542,6 @@ eel_self_check_gdk_rgb_to_color (guint32 color) void eel_self_check_gdk_extensions (void) { - /* eel_interpolate_color */ - EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (0.0, 0, 0), 0); - EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (0.0, 0, 0xFFFFFF), 0); - EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (0.5, 0, 0xFFFFFF), 0x7F7F7F); - EEL_CHECK_INTEGER_RESULT (eel_interpolate_color (1.0, 0, 0xFFFFFF), 0xFFFFFF); - /* eel_gradient_new */ EEL_CHECK_STRING_RESULT (eel_gradient_new ("", "", FALSE), ""); EEL_CHECK_STRING_RESULT (eel_gradient_new ("a", "b", FALSE), "a-b"); diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index 69f29e62..ca253403 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -98,16 +98,8 @@ char * eel_gradient_set_bottom_color_spec (const char /* A version of parse_color that substitutes a default color instead of returning a boolean to indicate it cannot be parsed. */ -void eel_gdk_color_parse_with_default (const char *color_spec, - const GdkColor *default_color, - GdkColor *parsed_color); void eel_gdk_color_parse_with_white_default (const char *color_spec, GdkColor *parsed_color); -guint32 eel_parse_rgb_with_default (const char *color_spec, - guint32 default_rgb); -guint32 eel_parse_rgb_with_white_default (const char *color_spec); -guint32 eel_rgb_shift_color (guint32 color, - float shift_by); guint32 eel_rgb16_to_rgb (gushort r, gushort g, gushort b); @@ -121,28 +113,9 @@ char * eel_gdk_rgb_to_color_spec (guint32 gboolean eel_gdk_color_is_dark (GdkColor *color); -/* Misc GdkRectangle helper functions */ -gboolean eel_gdk_rectangle_contains_rectangle (GdkRectangle outer, - GdkRectangle inner); - - -/* A basic operation we use for drawing gradients is interpolating two colors.*/ -guint32 eel_interpolate_color (gdouble ratio, - guint32 start_rgb, - guint32 end_rgb); - /* Misc GdkWindow helper functions */ -void eel_gdk_window_bring_to_front (GdkWindow *window); -void eel_gdk_window_set_invisible_cursor (GdkWindow *window); void eel_gdk_window_focus (GdkWindow *window, guint32 timestamp); -void eel_gdk_window_set_wm_protocols (GdkWindow *window, - GdkAtom *protocols, - int nprotocols); - - -void eel_gdk_window_set_wm_hints_input (GdkWindow *w, - gboolean status); /* Wrapper for XParseGeometry */ EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, -- cgit v1.2.1 From 739bd11c7853e0e760c2373d44ff934729e5cbe0 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:23:26 +0200 Subject: [eel] remove unused eel_make_semitransparent() http://git.gnome.org/browse/nautilus/commit/?id=48c6012e89fb1362e418d4bf56c05614f1515eab --- eel/eel-graphic-effects.c | 84 ----------------------------------------------- eel/eel-graphic-effects.h | 4 --- 2 files changed, 88 deletions(-) diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c index b234b914..ffb5beba 100644 --- a/eel/eel-graphic-effects.c +++ b/eel/eel-graphic-effects.c @@ -47,22 +47,6 @@ create_new_pixbuf (GdkPixbuf *src) gdk_pixbuf_get_height (src)); } -static GdkPixbuf * -create_new_pixbuf_with_alpha (GdkPixbuf *src) -{ - g_assert (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB); - g_assert ((!gdk_pixbuf_get_has_alpha (src) - && gdk_pixbuf_get_n_channels (src) == 3) - || (gdk_pixbuf_get_has_alpha (src) - && gdk_pixbuf_get_n_channels (src) == 4)); - - return gdk_pixbuf_new (gdk_pixbuf_get_colorspace (src), - TRUE, - gdk_pixbuf_get_bits_per_sample (src), - gdk_pixbuf_get_width (src), - gdk_pixbuf_get_height (src)); -} - /* utility routine to bump the level of a color component with pinning */ static guchar @@ -351,71 +335,3 @@ eel_embed_image_in_frame (GdkPixbuf *source_image, GdkPixbuf *frame_image, int l return result_pixbuf; } - -/* this routine takes the source pixbuf and returns a new one that's semi-transparent, by - clearing every other pixel's alpha value in a checkerboard grip. We have to do the - checkerboard instead of reducing the alpha since it will be turned into an alpha-less - gdkpixmap and mask for the actual dragging */ - -GdkPixbuf * -eel_make_semi_transparent (GdkPixbuf *src) -{ - gint i, j, temp_alpha; - gint width, height, has_alpha, src_row_stride, dst_row_stride; - guchar *target_pixels, *original_pixels; - guchar *pixsrc, *pixdest; - guchar alpha_value; - GdkPixbuf *dest_pixbuf; - guchar start_alpha_value; - - g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL); - g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src) - && gdk_pixbuf_get_n_channels (src) == 3) - || (gdk_pixbuf_get_has_alpha (src) - && gdk_pixbuf_get_n_channels (src) == 4), NULL); - g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL); - - dest_pixbuf = create_new_pixbuf_with_alpha (src); - - has_alpha = gdk_pixbuf_get_has_alpha (src); - width = gdk_pixbuf_get_width (src); - height = gdk_pixbuf_get_height (src); - src_row_stride = gdk_pixbuf_get_rowstride (src); - dst_row_stride = gdk_pixbuf_get_rowstride (dest_pixbuf); - - /* set up pointers to the actual pixels */ - target_pixels = gdk_pixbuf_get_pixels (dest_pixbuf); - original_pixels = gdk_pixbuf_get_pixels (src); - - /* loop through the pixels to do the actual work, copying from the source to the destination */ - start_alpha_value = ~0; - for (i = 0; i < height; i++) - { - pixdest = target_pixels + i * dst_row_stride; - pixsrc = original_pixels + i * src_row_stride; - alpha_value = start_alpha_value; - for (j = 0; j < width; j++) - { - *pixdest++ = *pixsrc++; /* red */ - *pixdest++ = *pixsrc++; /* green */ - *pixdest++ = *pixsrc++; /* blue */ - - if (has_alpha) - { - temp_alpha = *pixsrc++; - } - else - { - temp_alpha = ~0; - } - *pixdest++ = temp_alpha & alpha_value; - - alpha_value = ~alpha_value; - } - - start_alpha_value = ~start_alpha_value; - } - - return dest_pixbuf; -} - diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h index 7ac627f1..6ae00421 100644 --- a/eel/eel-graphic-effects.h +++ b/eel/eel-graphic-effects.h @@ -59,8 +59,4 @@ GdkPixbuf *eel_embed_image_in_frame (GdkPixbuf *source_image, int right_offset, int bottom_offset); -/* return a semi-transparent pixbuf from the source pixbuf using a checkboard - stipple in the alpha channel (so it can be converted to an alpha-less pixmap) */ -GdkPixbuf *eel_make_semi_transparent (GdkPixbuf *source_pixbuf); - #endif /* EEL_GRAPHIC_EFFECTS_H */ -- cgit v1.2.1 From ac338998d82df4082b6092135fa03d0e55282e6b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:25:12 +0200 Subject: [eel] cleanup eel-mate-extensions http://git.gnome.org/browse/nautilus/commit/?id=fbccd9bfaa9c983dccc60d040b63b86521306788 --- eel/eel-mate-extensions.c | 19 ++----------------- eel/eel-mate-extensions.h | 4 ---- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/eel/eel-mate-extensions.c b/eel/eel-mate-extensions.c index 006144dc..2af5a941 100644 --- a/eel/eel-mate-extensions.c +++ b/eel/eel-mate-extensions.c @@ -29,25 +29,10 @@ #define MATE_DESKTOP_USE_UNSTABLE_API #include "eel-mate-extensions.h" -#include "eel-art-extensions.h" -#include "eel-gdk-extensions.h" -#include "eel-glib-extensions.h" -#include "eel-gtk-extensions.h" -#include "eel-stock-dialogs.h" -#include -#include -#include -#include + #include #include -#include -#include -#include -#include -#include -#include -#include -#include + /* Return a command string containing the path to a terminal on this system. */ diff --git a/eel/eel-mate-extensions.h b/eel/eel-mate-extensions.h index cabd4380..cb97e55b 100644 --- a/eel/eel-mate-extensions.h +++ b/eel/eel-mate-extensions.h @@ -29,10 +29,6 @@ #include -/* icon selection callback function. */ -typedef void (* EelIconSelectionFunction) (const char *icon_path, gpointer callback_data); - - /* Return a command string containing the path to a terminal on this system. */ char * eel_mate_make_terminal_command (const char *command); -- cgit v1.2.1 From 8a2b2890d08a7443f2272fdafce5f9c35c306add Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:29:02 +0200 Subject: [eel] cleanup eel-glib-extensions http://git.gnome.org/browse/nautilus/commit/?id=230581b5d58650c1f50f7d9fda9ab3a1f211361a --- eel/eel-glib-extensions.c | 89 ----------------------------------------------- eel/eel-glib-extensions.h | 18 ---------- 2 files changed, 107 deletions(-) diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index e747eb46..ea7ecbca 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -748,74 +748,6 @@ eel_round (double d) return val; } -GList * -eel_g_list_from_g_slist (GSList *slist) -{ - GList *list; - GSList *node; - - list = NULL; - for (node = slist; node != NULL; node = node->next) - { - list = g_list_prepend (list, node->data); - } - return g_list_reverse (list); -} - -GSList * -eel_g_slist_from_g_list (GList *list) -{ - GSList *slist; - GList *node; - - slist = NULL; - for (node = list; node != NULL; node = node->next) - { - slist = g_slist_prepend (slist, node->data); - } - return g_slist_reverse (slist); -} - -/* Return the operating system name: Linux, Solaris, etc. */ -char * -eel_get_operating_system_name (void) -{ - struct utsname buffer; - - if (uname (&buffer) != -1) - { - /* Check for special sysnames for which there is - * more accepted names. - */ - if (eel_str_is_equal (buffer.sysname, "SunOS")) - { - return g_strdup ("Solaris"); - } - - return g_strdup (buffer.sysname); - } - - return g_strdup ("Unix"); -} - -int -eel_compare_integer (gconstpointer a, - gconstpointer b) -{ - int int_a; - int int_b; - - int_a = GPOINTER_TO_INT (a); - int_b = GPOINTER_TO_INT (b); - - if (int_a == int_b) - { - return 0; - } - - return int_a < int_b ? -1 : 1; -} - /** * eel_g_object_list_ref * @@ -1339,27 +1271,6 @@ eel_self_check_glib_extensions (void) setlocale (LC_TIME, ""); g_free (huge_string); - - /* eel_shell_quote */ - EEL_CHECK_STRING_RESULT (g_shell_quote (""), "''"); - EEL_CHECK_STRING_RESULT (g_shell_quote ("a"), "'a'"); - EEL_CHECK_STRING_RESULT (g_shell_quote ("("), "'('"); - EEL_CHECK_STRING_RESULT (g_shell_quote ("'"), "''\\'''"); - EEL_CHECK_STRING_RESULT (g_shell_quote ("'a"), "''\\''a'"); - EEL_CHECK_STRING_RESULT (g_shell_quote ("a'"), "'a'\\'''"); - EEL_CHECK_STRING_RESULT (g_shell_quote ("a'a"), "'a'\\''a'"); - - /* eel_compare_integer */ - EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (0)), 0); - EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (1)), -1); - EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (1), GINT_TO_POINTER (0)), 1); - EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (-1), GINT_TO_POINTER (0)), -1); - EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (0), GINT_TO_POINTER (-1)), 1); - EEL_CHECK_INTEGER_RESULT (eel_compare_integer (GINT_TO_POINTER (-1), GINT_TO_POINTER (-1)), 0); - -#ifdef __linux__ - EEL_CHECK_STRING_RESULT (eel_get_operating_system_name (), "Linux"); -#endif } #endif /* !EEL_OMIT_SELF_CHECK */ diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index 1093e319..1a8bd3e8 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -33,13 +33,6 @@ /* A gboolean variant for bit fields. */ typedef guint eel_boolean_bit; -/* Callback functions that have user data. */ -typedef int (* EelCompareFunction) (gconstpointer a, - gconstpointer b, - gpointer callback_data); -typedef int (* EelSearchFunction) (gconstpointer item, - gpointer callback_data); - /* Predicate. */ typedef gboolean (* EelPredicateFunction) (gpointer data, gpointer callback_data); @@ -67,10 +60,6 @@ void eel_g_list_free_deep_custom (GList * GFunc element_free_func, gpointer user_data); -/* GSList functions. */ -GList * eel_g_list_from_g_slist (GSList *list); -GSList * eel_g_slist_from_g_list (GList *list); - /* List functions for slists of g_free'able objects. */ void eel_g_slist_free_deep (GSList *list); void eel_g_slist_free_deep_custom (GSList *list, @@ -111,13 +100,6 @@ gint64 eel_get_system_time (void); /* math */ int eel_round (double d); -/* A GCompareFunc for integers */ -int eel_compare_integer (gconstpointer a, - gconstpointer b); - -/* Return the operating system name: Linux, Solaris, etc. */ -char * eel_get_operating_system_name (void); - /* Better weak pointer functions */ void eel_add_weak_pointer (gpointer pointer_location); void eel_remove_weak_pointer (gpointer pointer_location); -- cgit v1.2.1 From aefeca5ceaf9350c7e7f4a89637dc775d4207d76 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:30:13 +0200 Subject: [eel] cleanup eel-vfs-extensions http://git.gnome.org/browse/nautilus/commit/?id=2f202206fee4e1917494e3f4652e22648097c765 --- eel/eel-vfs-extensions.c | 28 ---------------------------- eel/eel-vfs-extensions.h | 1 - 2 files changed, 29 deletions(-) diff --git a/eel/eel-vfs-extensions.c b/eel/eel-vfs-extensions.c index 300b4969..9c786965 100644 --- a/eel/eel-vfs-extensions.c +++ b/eel/eel-vfs-extensions.c @@ -99,34 +99,6 @@ eel_make_valid_utf8 (const char *name) return g_string_free (string, FALSE); } -/** - * eel_format_uri_for_display: - * - * Filter, modify, unescape and change URIs to make them appropriate - * to display to users. The conversion is done such that the roundtrip - * to UTf8 is reversible. - * - * Rules: - * file: URI's without fragments should appear as local paths - * file: URI's with fragments should appear as file: URI's - * All other URI's appear as expected - * - * @uri: a URI - * - * returns a g_malloc'd UTF8 string - **/ -char * -eel_format_uri_for_display (const char *uri) -{ - GFile *file; - char *res; - - file = g_file_new_for_uri (uri); - res = g_file_get_parse_name (file); - g_object_unref (file); - return res; -} - char * eel_filename_strip_extension (const char * filename_with_extension) { diff --git a/eel/eel-vfs-extensions.h b/eel/eel-vfs-extensions.h index a79df1c3..e564ca15 100644 --- a/eel/eel-vfs-extensions.h +++ b/eel/eel-vfs-extensions.h @@ -46,7 +46,6 @@ extern "C" { gboolean eel_uri_is_search(const char* uri); - char* eel_format_uri_for_display(const char* uri); char* eel_make_valid_utf8(const char* name); char* eel_filename_strip_extension(const char* filename); -- cgit v1.2.1 From cbdd65ce75e49a8c0cc4055bf0c02dad66cab0cd Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:43:59 +0200 Subject: [test] remove test-eel-image-scrolled http://git.gnome.org/browse/nautilus/commit/?id=931644a649175b1886dce5cc8e50c21380f8b8b0 --- test/Makefile.am | 2 - test/test-eel-image-scrolled.c | 187 ----------------------------------------- 2 files changed, 189 deletions(-) delete mode 100644 test/test-eel-image-scrolled.c diff --git a/test/Makefile.am b/test/Makefile.am index 9e3d2099..92b9fda0 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -21,7 +21,6 @@ noinst_PROGRAMS =\ test-caja-copy \ test-eel-background \ test-eel-editable-label \ - test-eel-image-scrolled \ test-eel-image-table \ test-eel-labeled-image \ test-eel-pixbuf-scale \ @@ -36,7 +35,6 @@ test_caja_search_engine_SOURCES = test-caja-search-engine.c test_caja_directory_async_SOURCES = test-caja-directory-async.c test_eel_background_SOURCES = test-eel-background.c -test_eel_image_scrolled_SOURCES = test-eel-image-scrolled.c test.c test.h test_eel_image_table_SOURCES = test-eel-image-table.c test.c test_eel_labeled_image_SOURCES = test-eel-labeled-image.c test.c test.h test_eel_pixbuf_scale_SOURCES = test-eel-pixbuf-scale.c test.c test.h diff --git a/test/test-eel-image-scrolled.c b/test/test-eel-image-scrolled.c deleted file mode 100644 index c89cfe9f..00000000 --- a/test/test-eel-image-scrolled.c +++ /dev/null @@ -1,187 +0,0 @@ -#include "test.h" - -#if 0 -typedef struct -{ - GtkWidget *window; - GtkWidget *vbox; - GtkWidget *entry; - GtkWidget *hbox; - GtkWidget *smooth_toggle; - GtkWidget *frame; - GtkWidget *label; -} Window; - -#if 0 -static void -toggle_smooth_callback (GtkWidget *widget, gpointer callback_data) -{ - Window *window; - EelLabel *label; - - window = (Window *) callback_data; - - if (!EEL_IS_LABEL (window->label)) { - return; - } - - label = GTK_LABEL (window->label); - - gtk_label_set_is_smooth (label, !gtk_label_get_is_smooth (label)); -} -#endif - -static Window * -window_new (const char *title, guint border_width) -{ - Window *window; - GtkWidget *main_vbox; - - window = g_new0 (Window, 1); - - window->window = test_window_new (title, border_width); - - main_vbox = gtk_vbox_new (FALSE, 0); - gtk_container_add (GTK_CONTAINER (window->window), main_vbox); - - window->vbox = gtk_vbox_new (FALSE, 0); - window->entry = gtk_entry_new (); - window->hbox = gtk_hbox_new (FALSE, 0); -// window->smooth_toggle = gtk_check_button_new_with_label ("Smooth"); - - gtk_box_pack_start (GTK_BOX (main_vbox), window->vbox, TRUE, TRUE, 0); - gtk_box_pack_start (GTK_BOX (main_vbox), window->hbox, FALSE, FALSE, 0); - gtk_box_pack_end (GTK_BOX (main_vbox), window->entry, FALSE, FALSE, 0); - -// gtk_box_pack_start (GTK_BOX (window->hbox), window->smooth_toggle, FALSE, FALSE, 0); - - gtk_widget_show (main_vbox); - gtk_widget_show (window->vbox); - gtk_widget_show (window->hbox); - gtk_widget_show (window->entry); - - return window; -} - -static Window * -label_window_new (const char *title, - guint border_width, - const char *file_name, - const char *tile_file_name) -{ - Window *window; - - window = window_new (title, border_width); - - window->frame = gtk_frame_new ("Foo"); - window->label = gtk_label_new (file_name); - - if (tile_file_name != NULL) { - gtk_label_set_tile_pixbuf_from_file_name (GTK_LABEL (window->label), - tile_file_name); - } - - gtk_container_add (GTK_CONTAINER (window->frame), window->label); - - gtk_box_pack_start (GTK_BOX (window->vbox), window->frame, TRUE, TRUE, 0); - - gtk_widget_show (window->label); - gtk_widget_show (window->frame); - - return window; -} -#endif - -static const char text[] = -"The Eel shell is under development; it's not " -"ready for daily use. Some features are not yet done, " -"partly done, or unstable. The program doesn't look " -"or act exactly the way it will in version 1.0." -"\n\n" -"If you do decide to test this version of Eel, " -"beware. The program could do something " -"unpredictable and may even delete or overwrite " -"files on your computer." -"\n\n" -"For more information, visit http://eel.eazel.com."; - -static GtkWidget * -label_window_new (void) -{ - GtkWidget *window; - GtkWidget *label; - EelBackground *background; - - window = test_window_new ("Scrolled Label Test", 10); - - background = eel_get_widget_background (GTK_WIDGET (window)); - eel_background_set_color (background, "white"); - - /* Label */ - label = gtk_label_new (text); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - - gtk_container_add (GTK_CONTAINER (window), label); - - gtk_widget_show (label); - - return window; -} - -static GtkWidget * -label_window_new_scrolled (void) -{ - GtkWidget *window; - GtkWidget *scrolled; - GtkWidget *viewport; - GtkWidget *label; - EelBackground *background; - - window = test_window_new ("Scrolled Label Test", 10); - - /* Scrolled window */ - scrolled = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scrolled), - GTK_POLICY_NEVER, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (window), scrolled); - - /* Viewport */ - viewport = gtk_viewport_new (NULL, NULL); - gtk_viewport_set_shadow_type (GTK_VIEWPORT (viewport), GTK_SHADOW_OUT); - gtk_container_add (GTK_CONTAINER (scrolled), viewport); - - background = eel_get_widget_background (GTK_WIDGET (viewport)); - eel_background_set_color (background, "white"); - - /* Label */ - label = gtk_label_new (text); - gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); - - gtk_container_add (GTK_CONTAINER (viewport), label); - - gtk_widget_show (label); - gtk_widget_show (viewport); - gtk_widget_show (scrolled); - - return window; -} - -int -main (int argc, char* argv[]) -{ - GtkWidget *label_window; - GtkWidget *scrolled_label_window; - - test_init (&argc, &argv); - - label_window = label_window_new (); - scrolled_label_window = label_window_new_scrolled (); - - gtk_widget_show (scrolled_label_window); - gtk_widget_show (label_window); - - gtk_main (); - - return 0; -} -- cgit v1.2.1 From 4c9e9bc2b097323bd7b0717f055d5ee034260d22 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 16:31:50 +0200 Subject: [lc-p|eel-gtk-extensions] Don't include eel-pango-extensions.h http://git.gnome.org/browse/nautilus/commit/?id=f080b86daeb571def4c092e1524e9adfc7700699 --- eel/eel-gtk-extensions.c | 1 - libcaja-private/caja-customization-data.c | 1 - libcaja-private/caja-file-operations.c | 1 - libcaja-private/caja-icon-canvas-item.c | 1 - 4 files changed, 4 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 7aab358e..7c75ef51 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -32,7 +32,6 @@ #include "eel-gdk-pixbuf-extensions.h" #include "eel-glib-extensions.h" #include "eel-mate-extensions.h" -#include "eel-pango-extensions.h" #include "eel-string.h" #include #include diff --git a/libcaja-private/caja-customization-data.c b/libcaja-private/caja-customization-data.c index f29eee40..aeeab942 100644 --- a/libcaja-private/caja-customization-data.c +++ b/libcaja-private/caja-customization-data.c @@ -31,7 +31,6 @@ #include "caja-file-utilities.h" #include #include -#include #include #include #include diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c index f89e00cc..55140e6b 100644 --- a/libcaja-private/caja-file-operations.c +++ b/libcaja-private/caja-file-operations.c @@ -46,7 +46,6 @@ #include #include -#include #include #include #include diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index e35efec2..d6bba70b 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.1 From 74206714b6a34f49d5fa8f0b7b50f845f3836924 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 13 Nov 2012 15:52:16 +0200 Subject: [sidebar-title] Use pango directly to set largest-fitting font size and don't include eel-pango-extensions, which is to be dropped. --- src/caja-sidebar-title.c | 48 +++++++++++++++++++++++++++++------------------- 1 file changed, 29 insertions(+), 19 deletions(-) diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c index e02eaa9d..86dd4e41 100644 --- a/src/caja-sidebar-title.c +++ b/src/caja-sidebar-title.c @@ -36,9 +36,8 @@ #include #include #include -#include -#include #include +#include #include #include #include @@ -399,15 +398,16 @@ update_icon (CajaSidebarTitle *sidebar_title) static void update_title_font (CajaSidebarTitle *sidebar_title) { - int available_width; - PangoFontDescription *title_font; - int largest_fitting_font_size; - int max_style_font_size; + int available_width, width; + int max_fit_font_size, max_style_font_size; GtkStyle *style; GtkAllocation allocation; + PangoFontDescription *title_font, *tmp_font; + PangoLayout *layout; /* Make sure theres work to do */ - if (eel_strlen (sidebar_title->details->title_text) < 1) + if (sidebar_title->details->title_text == NULL + || strlen (sidebar_title->details->title_text) < 1) { return; } @@ -430,19 +430,29 @@ update_title_font (CajaSidebarTitle *sidebar_title) max_style_font_size = MIN_TITLE_FONT_SIZE + 1; } - largest_fitting_font_size = eel_pango_font_description_get_largest_fitting_font_size ( - title_font, - gtk_widget_get_pango_context (sidebar_title->details->title_label), - sidebar_title->details->title_text, - available_width, - MIN_TITLE_FONT_SIZE, - max_style_font_size); - pango_font_description_set_size (title_font, largest_fitting_font_size * PANGO_SCALE); + /* Calculate largest-fitting font size */ + layout = pango_layout_new (gtk_widget_get_pango_context (sidebar_title->details->title_label)); + pango_layout_set_text (layout, sidebar_title->details->title_text, -1); + pango_layout_set_font_description (layout, title_font); + tmp_font = pango_font_description_new (); - pango_font_description_set_weight (title_font, PANGO_WEIGHT_BOLD); + max_fit_font_size = max_style_font_size; + for (; max_fit_font_size >= MIN_TITLE_FONT_SIZE; max_fit_font_size--) + { + pango_font_description_set_size (tmp_font, max_fit_font_size * PANGO_SCALE); + pango_layout_set_font_description (layout, tmp_font); + pango_layout_get_pixel_size (layout, &width, NULL); - gtk_widget_modify_font (sidebar_title->details->title_label, - title_font); + if (width <= available_width) + break; + } + + pango_font_description_free (tmp_font); + g_object_unref (layout); + + pango_font_description_set_size (title_font, max_fit_font_size * PANGO_SCALE); + pango_font_description_set_weight (title_font, PANGO_WEIGHT_BOLD); + gtk_widget_modify_font (sidebar_title->details->title_label, title_font); pango_font_description_free (title_font); } @@ -455,7 +465,7 @@ update_title (CajaSidebarTitle *sidebar_title) label = GTK_LABEL (sidebar_title->details->title_label); text = sidebar_title->details->title_text; - if (eel_strcmp (text, gtk_label_get_text (label)) == 0) + if (g_strcmp0 (text, gtk_label_get_text (label)) == 0) { return; } -- cgit v1.2.1 From c4e8827c8b614de43f10c7c6c3f50830b93b4fb9 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 3 Nov 2012 02:01:54 +0200 Subject: [eel] remove eel-pango-extensions http://git.gnome.org/browse/nautilus/commit/?id=e42ddad5109f193bf8a5b3c0c6cd7cf4b1408300 --- eel/Makefile.am | 2 - eel/eel-lib-self-check-functions.h | 1 - eel/eel-pango-extensions.c | 615 ------------------------------------- eel/eel-pango-extensions.h | 55 ---- eel/eel.h | 1 - 5 files changed, 674 deletions(-) delete mode 100644 eel/eel-pango-extensions.c delete mode 100644 eel/eel-pango-extensions.h diff --git a/eel/Makefile.am b/eel/Makefile.am index e061e961..d7b04129 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -49,7 +49,6 @@ libeel_2_la_SOURCES = \ eel-image-table.c \ eel-labeled-image.c \ eel-lib-self-check-functions.c \ - eel-pango-extensions.c \ eel-self-checks.c \ eel-stock-dialogs.c \ eel-string.c \ @@ -83,7 +82,6 @@ eel_headers = \ eel-gtk-macros.h \ eel-image-table.h \ eel-labeled-image.h \ - eel-pango-extensions.h \ eel-self-checks.h \ eel-stock-dialogs.h \ eel-string.h \ diff --git a/eel/eel-lib-self-check-functions.h b/eel/eel-lib-self-check-functions.h index 6c3e07d1..d14aa99e 100644 --- a/eel/eel-lib-self-check-functions.h +++ b/eel/eel-lib-self-check-functions.h @@ -43,7 +43,6 @@ void eel_run_lib_self_checks (void); macro (eel_self_check_gdk_extensions) \ macro (eel_self_check_gdk_pixbuf_extensions) \ macro (eel_self_check_glib_extensions) \ - macro (eel_self_check_pango_extensions) \ macro (eel_self_check_string) \ /* Add new self-check functions to the list above this line. */ diff --git a/eel/eel-pango-extensions.c b/eel/eel-pango-extensions.c deleted file mode 100644 index 68a9b08e..00000000 --- a/eel/eel-pango-extensions.c +++ /dev/null @@ -1,615 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-pango-extensions.h - interface for new functions that conceptually - belong in pango. Perhaps some of these will be - actually rolled into pango someday. - - Copyright (C) 2001 Anders Carlsson - - The Eel Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Eel Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Eel Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Anders Carlsson -*/ - -#include -#include "eel-pango-extensions.h" - -#if !defined (EEL_OMIT_SELF_CHECK) -#include "eel-lib-self-check-functions.h" -#endif - -#include -#include -#include - -PangoAttrList * -eel_pango_attr_list_copy_or_create (PangoAttrList *attr_list) -{ - if (attr_list != NULL) - { - return pango_attr_list_copy (attr_list); - } - return pango_attr_list_new (); -} - -PangoAttrList * -eel_pango_attr_list_apply_global_attribute (PangoAttrList *attr_list, - PangoAttribute *attr) -{ - PangoAttrList *new_attr_list; - - g_return_val_if_fail (attr != NULL, NULL); - - attr->start_index = 0; - attr->end_index = G_MAXINT; - - new_attr_list = eel_pango_attr_list_copy_or_create (attr_list); - pango_attr_list_change (new_attr_list, attr); - return new_attr_list; -} - -#define ELLIPSIS "..." - -/* Caution: this is an _expensive_ function */ -static int -measure_string_width (const char *string, - PangoLayout *layout) -{ - int width; - - pango_layout_set_text (layout, string, -1); - pango_layout_get_pixel_size (layout, &width, NULL); - - return width; -} - -/* this is also plenty slow */ -static void -compute_character_widths (const char *string, - PangoLayout *layout, - int *char_len_return, - int **widths_return, - int **cuts_return) -{ - int *widths; - int *offsets; - int *cuts; - int char_len; - int byte_len; - const char *p; - int i; - PangoLayoutIter *iter; - PangoLogAttr *attrs; - -#define BEGINS_UTF8_CHAR(x) (((x) & 0xc0) != 0x80) - - char_len = g_utf8_strlen (string, -1); - byte_len = strlen (string); - - widths = g_new (int, char_len); - offsets = g_new (int, byte_len); - - /* Create a translation table from byte index to char offset */ - p = string; - i = 0; - while (*p) - { - int byte_index = p - string; - - if (BEGINS_UTF8_CHAR (*p)) - { - offsets[byte_index] = i; - ++i; - } - else - { - offsets[byte_index] = G_MAXINT; /* segv if we try to use this */ - } - - ++p; - } - - /* Now fill in the widths array */ - pango_layout_set_text (layout, string, -1); - - iter = pango_layout_get_iter (layout); - - do - { - PangoRectangle extents; - int byte_index; - - byte_index = pango_layout_iter_get_index (iter); - - if (byte_index < byte_len) - { - pango_layout_iter_get_char_extents (iter, &extents); - - g_assert (BEGINS_UTF8_CHAR (string[byte_index])); - g_assert (offsets[byte_index] < char_len); - - widths[offsets[byte_index]] = PANGO_PIXELS (extents.width); - } - - } - while (pango_layout_iter_next_char (iter)); - - pango_layout_iter_free (iter); - - g_free (offsets); - - *widths_return = widths; - - /* Now compute character offsets that are legitimate places to - * chop the string - */ - attrs = g_new (PangoLogAttr, char_len + 1); - - pango_get_log_attrs (string, byte_len, -1, - pango_context_get_language ( - pango_layout_get_context (layout)), - attrs, - char_len + 1); - - cuts = g_new (int, char_len); - i = 0; - while (i < char_len) - { - cuts[i] = attrs[i].is_cursor_position; - - ++i; - } - - g_free (attrs); - - *cuts_return = cuts; - - *char_len_return = char_len; -} - - -static char * -eel_string_ellipsize_start (const char *string, PangoLayout *layout, int width) -{ - int resulting_width; - int *cuts; - int *widths; - int char_len; - const char *p; - int truncate_offset; - - /* Zero-length string can't get shorter - catch this here to - * avoid expensive calculations - */ - if (*string == '\0') - return g_strdup (""); - - /* I'm not sure if this short-circuit is a net win; it might be better - * to just dump this, and always do the compute_character_widths() etc. - * down below. - */ - resulting_width = measure_string_width (string, layout); - - if (resulting_width <= width) - { - /* String is already short enough. */ - return g_strdup (string); - } - - /* Remove width of an ellipsis */ - width -= measure_string_width (ELLIPSIS, layout); - - if (width < 0) - { - /* No room even for an ellipsis. */ - return g_strdup (""); - } - - /* Our algorithm involves removing enough chars from the string to bring - * the width to the required small size. However, due to ligatures, - * combining characters, etc., it's not guaranteed that the algorithm - * always works 100%. It's sort of a heuristic thing. It should work - * nearly all the time... but I wouldn't put in - * g_assert (width of resulting string < width). - * - * Hmm, another thing that this breaks with is explicit line breaks - * in "string" - */ - - compute_character_widths (string, layout, &char_len, &widths, &cuts); - - for (truncate_offset = 1; truncate_offset < char_len; truncate_offset++) - { - - resulting_width -= widths[truncate_offset]; - - if (resulting_width <= width && - cuts[truncate_offset]) - { - break; - } - } - - g_free (cuts); - g_free (widths); - - p = g_utf8_offset_to_pointer (string, truncate_offset); - - return g_strconcat (ELLIPSIS, p, NULL); -} - -static char * -eel_string_ellipsize_end (const char *string, PangoLayout *layout, int width) -{ - int resulting_width; - int *cuts; - int *widths; - int char_len; - const char *p; - int truncate_offset; - char *result; - - /* See explanatory comments in ellipsize_start */ - - if (*string == '\0') - return g_strdup (""); - - resulting_width = measure_string_width (string, layout); - - if (resulting_width <= width) - { - return g_strdup (string); - } - - width -= measure_string_width (ELLIPSIS, layout); - - if (width < 0) - { - return g_strdup (""); - } - - compute_character_widths (string, layout, &char_len, &widths, &cuts); - - for (truncate_offset = char_len - 1; truncate_offset > 0; truncate_offset--) - { - resulting_width -= widths[truncate_offset]; - if (resulting_width <= width && - cuts[truncate_offset]) - { - break; - } - } - - g_free (cuts); - g_free (widths); - - p = g_utf8_offset_to_pointer (string, truncate_offset); - - result = g_malloc ((p - string) + strlen (ELLIPSIS) + 1); - memcpy (result, string, (p - string)); - strcpy (result + (p - string), ELLIPSIS); - - return result; -} - -static char * -eel_string_ellipsize_middle (const char *string, PangoLayout *layout, int width) -{ - int resulting_width; - int *cuts; - int *widths; - int char_len; - int starting_fragment_byte_len; - int ending_fragment_byte_index; - int starting_fragment_length; - int ending_fragment_offset; - char *result; - - /* See explanatory comments in ellipsize_start */ - - if (*string == '\0') - return g_strdup (""); - - resulting_width = measure_string_width (string, layout); - - if (resulting_width <= width) - { - return g_strdup (string); - } - - width -= measure_string_width (ELLIPSIS, layout); - - if (width < 0) - { - return g_strdup (""); - } - - compute_character_widths (string, layout, &char_len, &widths, &cuts); - - starting_fragment_length = char_len / 2; - ending_fragment_offset = starting_fragment_length + 1; - - /* Shave off a character at a time from the first and the second half - * until we can fit - */ - resulting_width -= widths[ending_fragment_offset - 1]; - - /* depending on whether the original string length is odd or even, start by - * shaving off the characters from the starting or ending fragment - */ - if (char_len % 2) - { - goto shave_end; - } - - while (starting_fragment_length > 0 || ending_fragment_offset < char_len) - { - if (resulting_width <= width && - cuts[ending_fragment_offset] && - cuts[starting_fragment_length]) - { - break; - } - - if (starting_fragment_length > 0) - { - resulting_width -= widths[starting_fragment_length]; - starting_fragment_length--; - } - -shave_end: - if (resulting_width <= width && - cuts[ending_fragment_offset] && - cuts[starting_fragment_length]) - { - break; - } - - if (ending_fragment_offset < char_len) - { - resulting_width -= widths[ending_fragment_offset]; - ending_fragment_offset++; - } - } - - g_free (cuts); - g_free (widths); - - /* patch the two fragments together with an ellipsis */ - result = g_malloc (strlen (string) + strlen (ELLIPSIS) + 1); /* a bit wasteful, no biggie */ - - starting_fragment_byte_len = g_utf8_offset_to_pointer (string, starting_fragment_length) - string; - ending_fragment_byte_index = g_utf8_offset_to_pointer (string, ending_fragment_offset) - string; - - memcpy (result, string, starting_fragment_byte_len); - strcpy (result + starting_fragment_byte_len, ELLIPSIS); - strcpy (result + starting_fragment_byte_len + strlen (ELLIPSIS), string + ending_fragment_byte_index); - - return result; -} - - -/** - * eel_pango_layout_set_text_ellipsized - * - * @layout: a pango layout - * @string: A a string to be ellipsized. - * @width: Desired maximum width in points. - * @mode: The desired ellipsizing mode. - * - * Truncates a string if required to fit in @width and sets it on the - * layout. Truncation involves removing characters from the start, middle or end - * respectively and replacing them with "...". Algorithm is a bit - * fuzzy, won't work 100%. - * - */ -void -eel_pango_layout_set_text_ellipsized (PangoLayout *layout, - const char *string, - int width, - EelEllipsizeMode mode) -{ - char *s; - - g_return_if_fail (PANGO_IS_LAYOUT (layout)); - g_return_if_fail (string != NULL); - g_return_if_fail (width >= 0); - - switch (mode) - { - case EEL_ELLIPSIZE_START: - s = eel_string_ellipsize_start (string, layout, width); - break; - case EEL_ELLIPSIZE_MIDDLE: - s = eel_string_ellipsize_middle (string, layout, width); - break; - case EEL_ELLIPSIZE_END: - s = eel_string_ellipsize_end (string, layout, width); - break; - default: - g_return_if_reached (); - } - - pango_layout_set_text (layout, s, -1); - - g_free (s); -} - - -int -eel_pango_font_description_get_largest_fitting_font_size (const PangoFontDescription *font_desc, - PangoContext *context, - const char *text, - int available_width, - int minimum_acceptable_font_size, - int maximum_acceptable_font_size) -{ - int i; - int width; - PangoLayout *layout; - PangoFontDescription *font; - - g_return_val_if_fail (text != NULL, 0); - g_return_val_if_fail (text[0] != '\0', 0); - g_return_val_if_fail (available_width > 0, 0); - g_return_val_if_fail (minimum_acceptable_font_size > 0, 0); - g_return_val_if_fail (maximum_acceptable_font_size > 0, 0); - g_return_val_if_fail (maximum_acceptable_font_size > minimum_acceptable_font_size, 0); - - layout = pango_layout_new (context); - pango_layout_set_text (layout, text, -1); - pango_layout_set_font_description (layout, font_desc); - - font = pango_font_description_new (); - - for (i = maximum_acceptable_font_size; i >= minimum_acceptable_font_size; i--) - { - - pango_font_description_set_size (font, i * PANGO_SCALE); - pango_layout_set_font_description (layout, font); - pango_layout_get_pixel_size (layout, &width, NULL); - - if (width <= available_width) - { - pango_font_description_free (font); - g_object_unref (layout); - return i; - } - } - - pango_font_description_free (font); - g_object_unref (layout); - return i; -} - - -#if !defined (EEL_OMIT_SELF_CHECK) - -static PangoContext * -eel_create_bogus_test_pango_context (void) -{ - PangoContext *context; - - context = gdk_pango_context_get (); - pango_context_set_language (context, gtk_get_default_language ()); - - return context; -} - -/* Testing string truncation is tough because we do not know what font/ - * font metrics to expect on a given system. To work around this we use - * a substring of the original, measure it's length using the given font, - * add the length of the "..." string and use that for truncation. - * The result should then be the substring prepended with a "..." - */ -static char * -eel_self_check_ellipsize (const char *string, const char *truncate_to_length_string, EelEllipsizeMode mode) -{ - PangoContext *context; - int truncation_length; - char *result; - PangoLayout *layout; - - context = eel_create_bogus_test_pango_context (); - layout = pango_layout_new (context); - - /* measure the length we want to truncate to */ - truncation_length = measure_string_width (truncate_to_length_string, layout); - - eel_pango_layout_set_text_ellipsized (layout, string, truncation_length, mode); - - result = g_strdup (pango_layout_get_text (layout)); - - g_object_unref (G_OBJECT (context)); - g_object_unref (G_OBJECT (layout)); - - return result; -} - -static char * -eel_self_check_ellipsize_start (const char *string, const char *truncate_to_length_string) -{ - return eel_self_check_ellipsize (string, truncate_to_length_string, EEL_ELLIPSIZE_START); -} - -static char * -eel_self_check_ellipsize_middle (const char *string, const char *truncate_to_length_string) -{ - return eel_self_check_ellipsize (string, truncate_to_length_string, EEL_ELLIPSIZE_MIDDLE); -} - -static char * -eel_self_check_ellipsize_end (const char *string, const char *truncate_to_length_string) -{ - return eel_self_check_ellipsize (string, truncate_to_length_string, EEL_ELLIPSIZE_END); -} - -void -eel_self_check_pango_extensions (void) -{ - PangoContext *context; - - /* used to test ellipsize routines */ - context = eel_create_bogus_test_pango_context (); - - /* Turned off these tests because they are failing for me and I - * want the release to be able to pass "make check". We'll have - * to revisit this at some point. The failures started because - * I changed my default font and enabled Xft support. I presume - * this is simply the "fuzziness" Havoc mentions in his comments - * above. - * - Darin - */ - - if (0) - { - /* eel_string_ellipsize_start */ - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "0012345678"), "012345678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "012345678"), "012345678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...45678"), "...45678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...5678"), "...5678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...678"), "...678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...78"), "...78"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_start ("012345678", "...8"), "...8"); - - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "0123456789"), "012345678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "012345678"), "012345678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "012...78"), "012...78"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "01...78"), "01...78"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "01...8"), "01...8"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "0...8"), "0...8"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("012345678", "0..."), "0..."); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "0123456789"), "0123456789"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "012...789"), "012...789"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "012...89"), "012...89"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "01...89"), "01...89"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "01...9"), "01...9"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "0...9"), "0...9"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_middle ("0123456789", "0..."), "0..."); - - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "0123456789"), "012345678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "012345678"), "012345678"); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "01234..."), "01234..."); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "0123..."), "0123..."); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "012..."), "012..."); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "01..."), "01..."); - EEL_CHECK_STRING_RESULT (eel_self_check_ellipsize_end ("012345678", "0..."), "0..."); - } - - g_object_unref (context); -} - -#endif /* !EEL_OMIT_SELF_CHECK */ diff --git a/eel/eel-pango-extensions.h b/eel/eel-pango-extensions.h deleted file mode 100644 index 2be3a965..00000000 --- a/eel/eel-pango-extensions.h +++ /dev/null @@ -1,55 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-pango-extensions.h - interface for new functions that conceptually - belong in pango. Perhaps some of these will be - actually rolled into pango someday. - - Copyright (C) 2001 Anders Carlsson - - The Eel Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Eel Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Eel Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Anders Carlsson -*/ - -#ifndef EEL_PANGO_EXTENSIONS_H -#define EEL_PANGO_EXTENSIONS_H - -#include - -typedef enum -{ - EEL_ELLIPSIZE_START, - EEL_ELLIPSIZE_MIDDLE, - EEL_ELLIPSIZE_END -} EelEllipsizeMode; - -PangoAttrList *eel_pango_attr_list_copy_or_create (PangoAttrList *attr_list); -PangoAttrList *eel_pango_attr_list_apply_global_attribute (PangoAttrList *attr_list, - PangoAttribute *attr); -int eel_pango_font_description_get_largest_fitting_font_size (const PangoFontDescription *font_desc, - PangoContext *context, - const char *text, - int available_width, - int minimum_acceptable_font_size, - int maximum_acceptable_font_size); - -/* caution: this function is expensive. */ -void eel_pango_layout_set_text_ellipsized (PangoLayout *layout, - const char *string, - int width, - EelEllipsizeMode mode); - -#endif /* EEL_PANGO_EXTENSIONS_H */ diff --git a/eel/eel.h b/eel/eel.h index 615958ca..2a965a56 100644 --- a/eel/eel.h +++ b/eel/eel.h @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.1 From 6986f1b631d2979ce0af28dc138537eed1a7b26b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 20:24:12 +0200 Subject: [list-model] use GEmblemedIcon to render emblems Use GEmblemedIcon instead of other columns to render emblems. http://git.gnome.org/browse/nautilus/commit/?id=a187f8a4cdcc46f56c0cb03c31b9b7c92c747a88&context=6 --- src/file-manager/fm-list-model.c | 149 +++++++++++++-------------------------- src/file-manager/fm-list-model.h | 9 --- 2 files changed, 49 insertions(+), 109 deletions(-) diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c index f7288fe2..b814a313 100644 --- a/src/file-manager/fm-list-model.c +++ b/src/file-manager/fm-list-model.c @@ -166,13 +166,6 @@ fm_list_model_get_column_type (GtkTreeModel *tree_model, int index) case FM_LIST_MODEL_LARGE_ICON_COLUMN: case FM_LIST_MODEL_LARGER_ICON_COLUMN: case FM_LIST_MODEL_LARGEST_ICON_COLUMN: - case FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN: - case FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN: - case FM_LIST_MODEL_SMALL_EMBLEM_COLUMN: - case FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN: - case FM_LIST_MODEL_LARGE_EMBLEM_COLUMN: - case FM_LIST_MODEL_LARGER_EMBLEM_COLUMN: - case FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN: return GDK_TYPE_PIXBUF; case FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: return G_TYPE_BOOLEAN; @@ -277,10 +270,12 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column CajaFile *file; char *str; GdkPixbuf *icon, *rendered_icon; + GIcon *gicon, *emblemed_icon, *emblem_icon; + CajaIconInfo *icon_info; + GEmblem *emblem; + GList *emblem_icons, *l; int icon_size; - guint emblem_size; CajaZoomLevel zoom_level; - GList *emblem_pixbufs; CajaFile *parent_file; char *emblems_to_ignore[3]; int i; @@ -344,7 +339,51 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column } } - icon = caja_file_get_icon_pixbuf (file, icon_size, TRUE, flags); + gicon = caja_file_get_gicon (file, flags); + + /* render emblems with GEmblemedIcon */ + parent_file = caja_file_get_parent (file); + i = 0; + emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH; + if (parent_file) { + if (!caja_file_can_write (parent_file)) { + emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE; + } + caja_file_unref (parent_file); + } + emblems_to_ignore[i++] = NULL; + + emblem = NULL; + emblem_icons = caja_file_get_emblem_icons (file, + emblems_to_ignore); + + if (emblem_icons != NULL) { + emblem_icon = emblem_icons->data; + emblem = g_emblem_new (emblem_icon); + emblemed_icon = g_emblemed_icon_new (gicon, emblem); + + g_object_unref (emblem); + + for (l = emblem_icons->next; l != NULL; l = l->next) { + emblem_icon = l->data; + emblem = g_emblem_new (emblem_icon); + g_emblemed_icon_add_emblem + (G_EMBLEMED_ICON (emblemed_icon), emblem); + + g_object_unref (emblem); + } + + eel_g_object_list_free (emblem_icons); + + g_object_unref (gicon); + gicon = emblemed_icon; + } + + icon_info = caja_icon_info_lookup (gicon, icon_size); + icon = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size); + + g_object_unref (icon_info); + g_object_unref (gicon); if (model->details->highlight_files != NULL && g_list_find_custom (model->details->highlight_files, @@ -363,48 +402,6 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column g_object_unref (icon); } break; - case FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN: - case FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN: - case FM_LIST_MODEL_SMALL_EMBLEM_COLUMN: - case FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN: - case FM_LIST_MODEL_LARGE_EMBLEM_COLUMN: - case FM_LIST_MODEL_LARGER_EMBLEM_COLUMN: - case FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN: - g_value_init (value, GDK_TYPE_PIXBUF); - - if (file != NULL) - { - parent_file = caja_file_get_parent (file); - i = 0; - emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH; - if (parent_file) - { - if (!caja_file_can_write (parent_file)) - { - emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE; - } - caja_file_unref (parent_file); - } - emblems_to_ignore[i++] = NULL; - - zoom_level = fm_list_model_get_zoom_level_from_emblem_column_id (column); - icon_size = caja_get_icon_size_for_zoom_level (zoom_level); - emblem_size = caja_icon_get_emblem_size_for_icon_size (icon_size); - if (emblem_size != 0) - { - emblem_pixbufs = caja_file_get_emblem_pixbufs (file, - emblem_size, - TRUE, - emblems_to_ignore); - if (emblem_pixbufs != NULL) - { - icon = emblem_pixbufs->data; - g_value_set_object (value, icon); - } - eel_gdk_pixbuf_list_free (emblem_pixbufs); - } - } - break; case FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN: g_value_init (value, G_TYPE_BOOLEAN); @@ -1555,54 +1552,6 @@ fm_list_model_get_column_id_from_zoom_level (CajaZoomLevel zoom_level) g_return_val_if_reached (FM_LIST_MODEL_STANDARD_ICON_COLUMN); } -CajaZoomLevel -fm_list_model_get_zoom_level_from_emblem_column_id (int column) -{ - switch (column) - { - case FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_SMALLEST; - case FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_SMALLER; - case FM_LIST_MODEL_SMALL_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_SMALL; - case FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_STANDARD; - case FM_LIST_MODEL_LARGE_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_LARGE; - case FM_LIST_MODEL_LARGER_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_LARGER; - case FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN: - return CAJA_ZOOM_LEVEL_LARGEST; - } - - g_return_val_if_reached (CAJA_ZOOM_LEVEL_STANDARD); -} - -int -fm_list_model_get_emblem_column_id_from_zoom_level (CajaZoomLevel zoom_level) -{ - switch (zoom_level) - { - case CAJA_ZOOM_LEVEL_SMALLEST: - return FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN; - case CAJA_ZOOM_LEVEL_SMALLER: - return FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN; - case CAJA_ZOOM_LEVEL_SMALL: - return FM_LIST_MODEL_SMALL_EMBLEM_COLUMN; - case CAJA_ZOOM_LEVEL_STANDARD: - return FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN; - case CAJA_ZOOM_LEVEL_LARGE: - return FM_LIST_MODEL_LARGE_EMBLEM_COLUMN; - case CAJA_ZOOM_LEVEL_LARGER: - return FM_LIST_MODEL_LARGER_EMBLEM_COLUMN; - case CAJA_ZOOM_LEVEL_LARGEST: - return FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN; - } - - g_return_val_if_reached (FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN); -} - void fm_list_model_set_drag_view (FMListModel *model, GtkTreeView *view, diff --git a/src/file-manager/fm-list-model.h b/src/file-manager/fm-list-model.h index a44fb28a..2d4ff88b 100644 --- a/src/file-manager/fm-list-model.h +++ b/src/file-manager/fm-list-model.h @@ -54,13 +54,6 @@ enum FM_LIST_MODEL_LARGE_ICON_COLUMN, FM_LIST_MODEL_LARGER_ICON_COLUMN, FM_LIST_MODEL_LARGEST_ICON_COLUMN, - FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN, - FM_LIST_MODEL_SMALLER_EMBLEM_COLUMN, - FM_LIST_MODEL_SMALL_EMBLEM_COLUMN, - FM_LIST_MODEL_STANDARD_EMBLEM_COLUMN, - FM_LIST_MODEL_LARGE_EMBLEM_COLUMN, - FM_LIST_MODEL_LARGER_EMBLEM_COLUMN, - FM_LIST_MODEL_LARGEST_EMBLEM_COLUMN, FM_LIST_MODEL_FILE_NAME_IS_EDITABLE_COLUMN, FM_LIST_MODEL_NUM_COLUMNS }; @@ -115,8 +108,6 @@ void fm_list_model_sort_files (FMListModel *model, CajaZoomLevel fm_list_model_get_zoom_level_from_column_id (int column); int fm_list_model_get_column_id_from_zoom_level (CajaZoomLevel zoom_level); -CajaZoomLevel fm_list_model_get_zoom_level_from_emblem_column_id (int column); -int fm_list_model_get_emblem_column_id_from_zoom_level (CajaZoomLevel zoom_level); CajaFile * fm_list_model_file_for_path (FMListModel *model, GtkTreePath *path); gboolean fm_list_model_load_subdirectory (FMListModel *model, GtkTreePath *path, CajaDirectory **directory); -- cgit v1.2.1 From b88f11c7af8f45328425594b633144f723c2b276 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 20:49:48 +0200 Subject: [list-view] don't use NautilusCellRendererPixbufEmblem http://git.gnome.org/browse/nautilus/commit/?id=69740a3c7fd3a2e1cea99c0dc61b3c735993e4bb --- src/file-manager/fm-list-view.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index e8eb16a8..10586bd3 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -59,7 +59,6 @@ #include #include #include -#include #include struct FMListViewDetails @@ -1740,7 +1739,7 @@ create_and_set_up_tree_view (FMListView *view) if (!strcmp (name, "name")) { /* Create the file name column */ - cell = caja_cell_renderer_pixbuf_emblem_new (); + cell = gtk_cell_renderer_pixbuf_new (); view->details->pixbuf_cell = (GtkCellRendererPixbuf *)cell; view->details->file_name_column = gtk_tree_view_column_new (); @@ -1764,7 +1763,6 @@ create_and_set_up_tree_view (FMListView *view) gtk_tree_view_column_set_attributes (view->details->file_name_column, cell, "pixbuf", FM_LIST_MODEL_SMALLEST_ICON_COLUMN, - "pixbuf_emblem", FM_LIST_MODEL_SMALLEST_EMBLEM_COLUMN, NULL); cell = gtk_cell_renderer_text_new (); @@ -2734,7 +2732,7 @@ fm_list_view_set_zoom_level (FMListView *view, gboolean always_emit) { int icon_size; - int column, emblem_column; + int column; g_return_if_fail (FM_IS_LIST_VIEW (view)); g_return_if_fail (new_level >= CAJA_ZOOM_LEVEL_SMALLEST && @@ -2760,11 +2758,9 @@ fm_list_view_set_zoom_level (FMListView *view, /* Select correctly scaled icons. */ column = fm_list_model_get_column_id_from_zoom_level (new_level); - emblem_column = fm_list_model_get_emblem_column_id_from_zoom_level (new_level); gtk_tree_view_column_set_attributes (view->details->file_name_column, GTK_CELL_RENDERER (view->details->pixbuf_cell), "pixbuf", column, - "pixbuf_emblem", emblem_column, NULL); /* Scale text. */ -- cgit v1.2.1 From eb1623a8c930746536a6119be9b30cecc6bf782d Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 21:12:07 +0200 Subject: [tree-model] use GEmblemedIcon to render emblems. Use GEmblemedIcon instead of a separate column to render emblems. http://git.gnome.org/browse/nautilus/commit/?id=1694d7141bbe4a29e54cff77def697a6c9b4e118 --- src/file-manager/fm-tree-model.c | 135 ++++++++++++++------------------------- src/file-manager/fm-tree-model.h | 1 - 2 files changed, 49 insertions(+), 87 deletions(-) diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index 15071b8c..c7bcab10 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -67,7 +67,6 @@ struct TreeNode GMount *mount; GdkPixbuf *closed_pixbuf; GdkPixbuf *open_pixbuf; - GdkPixbuf *emblem_pixbuf; FMTreeModelRoot *root; @@ -221,7 +220,6 @@ tree_node_destroy (FMTreeModel *model, TreeNode *node) object_unref_if_not_NULL (node->icon); object_unref_if_not_NULL (node->closed_pixbuf); object_unref_if_not_NULL (node->open_pixbuf); - object_unref_if_not_NULL (node->emblem_pixbuf); g_assert (node->done_loading_id == 0); g_assert (node->files_added_id == 0); @@ -278,17 +276,63 @@ get_menu_icon_for_file (TreeNode *node, CajaFileIconFlags flags) { CajaIconInfo *info; + GIcon *gicon, *emblem_icon, *emblemed_icon; + GEmblem *emblem; GdkPixbuf *pixbuf, *retval; gboolean highlight; int size; FMTreeModel *model; + GList *emblem_icons, *l; + char *emblems_to_ignore[3]; + int i; size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); - info = caja_file_get_icon (file, size, flags); + gicon = caja_file_get_gicon (file, flags); + + i = 0; + emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH; + + if (node->parent && node->parent->file) { + if (!caja_file_can_write (node->parent->file)) { + emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE; + } + } + + emblems_to_ignore[i++] = NULL; + + emblem = NULL; + emblem_icons = caja_file_get_emblem_icons (node->file, + emblems_to_ignore); + + if (emblem_icons != NULL) { + emblem_icon = emblem_icons->data; + emblem = g_emblem_new (emblem_icon); + emblemed_icon = g_emblemed_icon_new (gicon, emblem); + + g_object_unref (emblem); + + for (l = emblem_icons->next; l != NULL; l = l->next) { + emblem_icon = l->data; + emblem = g_emblem_new (emblem_icon); + g_emblemed_icon_add_emblem + (G_EMBLEMED_ICON (emblemed_icon), emblem); + + g_object_unref (emblem); + } + + eel_g_object_list_free (emblem_icons); + + g_object_unref (gicon); + gicon = emblemed_icon; + } + + info = caja_icon_info_lookup (gicon, size); retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); model = node->root->model; + g_object_unref (gicon); + highlight = (g_list_find_custom (model->details->highlighted_files, file, (GCompareFunc) caja_file_compare_location) != NULL); @@ -353,67 +397,6 @@ tree_node_update_open_pixbuf (TreeNode *node) return tree_node_update_pixbuf (node, &node->open_pixbuf, CAJA_FILE_ICON_FLAGS_FOR_OPEN_FOLDER); } -static GdkPixbuf * -tree_node_get_emblem_pixbuf_internal (TreeNode *node) -{ - GdkPixbuf *pixbuf; - GList *emblem_pixbufs; - char *emblems_to_ignore[3]; - int i; - - i = 0; - emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_TRASH; - - if (node->parent && node->parent->file) - { - if (!caja_file_can_write (node->parent->file)) - { - emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE; - } - } - - emblems_to_ignore[i++] = NULL; - - emblem_pixbufs = caja_file_get_emblem_pixbufs (node->file, - caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU), - TRUE, - emblems_to_ignore); - - - if (emblem_pixbufs != NULL) - { - pixbuf = g_object_ref (emblem_pixbufs->data); - } - else - { - pixbuf = NULL; - } - - eel_gdk_pixbuf_list_free (emblem_pixbufs); - - return pixbuf; -} - -static gboolean -tree_node_update_emblem_pixbuf (TreeNode *node) -{ - GdkPixbuf *pixbuf; - - if (node->emblem_pixbuf == NULL) - { - return FALSE; - } - pixbuf = tree_node_get_emblem_pixbuf_internal (node); - if (pixbuf == node->emblem_pixbuf) - { - g_object_unref (pixbuf); - return FALSE; - } - g_object_unref (node->emblem_pixbuf); - node->emblem_pixbuf = pixbuf; - return TRUE; -} - static gboolean tree_node_update_display_name (TreeNode *node) { @@ -459,16 +442,6 @@ tree_node_get_open_pixbuf (TreeNode *node) return node->open_pixbuf; } -static GdkPixbuf * -tree_node_get_emblem_pixbuf (TreeNode *node) -{ - if (node->emblem_pixbuf == NULL) - { - node->emblem_pixbuf = tree_node_get_emblem_pixbuf_internal (node); - } - return node->emblem_pixbuf; -} - static const char * tree_node_get_display_name (TreeNode *node) { @@ -919,7 +892,6 @@ update_node_without_reporting (FMTreeModel *model, TreeNode *node) changed |= tree_node_update_display_name (node); changed |= tree_node_update_closed_pixbuf (node); changed |= tree_node_update_open_pixbuf (node); - changed |= tree_node_update_emblem_pixbuf (node); return changed; } @@ -1244,8 +1216,6 @@ fm_tree_model_get_column_type (GtkTreeModel *model, int index) return GDK_TYPE_PIXBUF; case FM_TREE_MODEL_OPEN_PIXBUF_COLUMN: return GDK_TYPE_PIXBUF; - case FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN: - return GDK_TYPE_PIXBUF; case FM_TREE_MODEL_FONT_STYLE_COLUMN: return PANGO_TYPE_STYLE; default: @@ -1412,18 +1382,11 @@ fm_tree_model_get_value (GtkTreeModel *model, GtkTreeIter *iter, int column, GVa g_value_init (value, GDK_TYPE_PIXBUF); g_value_set_object (value, node == NULL ? NULL : tree_node_get_open_pixbuf (node)); break; - case FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN: - g_value_init (value, GDK_TYPE_PIXBUF); - g_value_set_object (value, node == NULL ? NULL : tree_node_get_emblem_pixbuf (node)); - break; case FM_TREE_MODEL_FONT_STYLE_COLUMN: g_value_init (value, PANGO_TYPE_STYLE); - if (node == NULL) - { + if (node == NULL) { g_value_set_enum (value, PANGO_STYLE_ITALIC); - } - else - { + } else { g_value_set_enum (value, PANGO_STYLE_NORMAL); } break; diff --git a/src/file-manager/fm-tree-model.h b/src/file-manager/fm-tree-model.h index bfca06e4..2e459392 100644 --- a/src/file-manager/fm-tree-model.h +++ b/src/file-manager/fm-tree-model.h @@ -49,7 +49,6 @@ enum FM_TREE_MODEL_DISPLAY_NAME_COLUMN, FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN, FM_TREE_MODEL_OPEN_PIXBUF_COLUMN, - FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN, FM_TREE_MODEL_FONT_STYLE_COLUMN, FM_TREE_MODEL_NUM_COLUMNS }; -- cgit v1.2.1 From 8e93e7838483152c96e7451292f1336f4ff67b40 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 21:17:08 +0200 Subject: [tree-view] don't use NautilusCellRendererPixbufEmblem http://git.gnome.org/browse/nautilus/commit/?id=d2cbf993766d7b63f50431ab483035d01c267cdb --- src/file-manager/fm-tree-view.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c index 71ec5a95..cb27a07d 100644 --- a/src/file-manager/fm-tree-view.c +++ b/src/file-manager/fm-tree-view.c @@ -53,7 +53,6 @@ #include #include #include -#include #include #include #include @@ -1475,13 +1474,12 @@ create_tree (FMTreeView *view) /* Create column */ column = gtk_tree_view_column_new (); - cell = caja_cell_renderer_pixbuf_emblem_new (); + cell = gtk_cell_renderer_pixbuf_new (); gtk_tree_view_column_pack_start (column, cell, FALSE); gtk_tree_view_column_set_attributes (column, cell, "pixbuf", FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN, "pixbuf_expander_closed", FM_TREE_MODEL_CLOSED_PIXBUF_COLUMN, "pixbuf_expander_open", FM_TREE_MODEL_OPEN_PIXBUF_COLUMN, - "pixbuf_emblem", FM_TREE_MODEL_EMBLEM_PIXBUF_COLUMN, NULL); cell = gtk_cell_renderer_text_new (); -- cgit v1.2.1 From 4799c0deb39be1abc4fadc693e73cd44aa7c4d36 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 21:19:09 +0200 Subject: [ln-p] remove NautilusCellRendererPixbufEmblem it's useless now http://git.gnome.org/browse/nautilus/commit/?id=25b48e9d1f4c847e2fc95b9b9893e63ba7081658 --- libcaja-private/Makefile.am | 2 - libcaja-private/caja-cell-renderer-pixbuf-emblem.c | 502 --------------------- libcaja-private/caja-cell-renderer-pixbuf-emblem.h | 68 --- 3 files changed, 572 deletions(-) delete mode 100644 libcaja-private/caja-cell-renderer-pixbuf-emblem.c delete mode 100644 libcaja-private/caja-cell-renderer-pixbuf-emblem.h diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am index 6d1c343d..9d53c844 100644 --- a/libcaja-private/Makefile.am +++ b/libcaja-private/Makefile.am @@ -46,8 +46,6 @@ libcaja_private_la_SOURCES = \ caja-autorun.h \ caja-bookmark.c \ caja-bookmark.h \ - caja-cell-renderer-pixbuf-emblem.c \ - caja-cell-renderer-pixbuf-emblem.h \ caja-cell-renderer-text-ellipsized.c \ caja-cell-renderer-text-ellipsized.h \ caja-clipboard-monitor.c \ diff --git a/libcaja-private/caja-cell-renderer-pixbuf-emblem.c b/libcaja-private/caja-cell-renderer-pixbuf-emblem.c deleted file mode 100644 index 63cbf3db..00000000 --- a/libcaja-private/caja-cell-renderer-pixbuf-emblem.c +++ /dev/null @@ -1,502 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - - caja-cell-renderer-pixbuf-emblem.c: cell renderer which can render - an emblem on top of a pixbuf (for use in FMListView and FMTreeView) - - Copyright (C) 2003 Juerg Billeter - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - This is based on GtkCellRendererPixbuf written by - Jonathan Blandford - - Author: Juerg Billeter -*/ - -#include "caja-cell-renderer-pixbuf-emblem.h" - -static void caja_cell_renderer_pixbuf_emblem_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec); -static void caja_cell_renderer_pixbuf_emblem_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec); -static void caja_cell_renderer_pixbuf_emblem_init (CajaCellRendererPixbufEmblem *cellpixbuf); -static void caja_cell_renderer_pixbuf_emblem_class_init (CajaCellRendererPixbufEmblemClass *klass); -static void caja_cell_renderer_pixbuf_emblem_finalize (GObject *object); -static void caja_cell_renderer_pixbuf_emblem_create_stock_pixbuf (CajaCellRendererPixbufEmblem *cellpixbuf, - GtkWidget *widget); -static void caja_cell_renderer_pixbuf_emblem_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *rectangle, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); -static void caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags); - -enum -{ - PROP_ZERO, - PROP_PIXBUF, - PROP_PIXBUF_EXPANDER_OPEN, - PROP_PIXBUF_EXPANDER_CLOSED, - PROP_STOCK_ID, - PROP_STOCK_SIZE, - PROP_STOCK_DETAIL, - PROP_PIXBUF_EMBLEM -}; - -#define CELLINFO_KEY "caja-cell-renderer-pixbuf-emblem-info" - -typedef struct _CajaCellRendererPixbufEmblemInfo CajaCellRendererPixbufEmblemInfo; -struct _CajaCellRendererPixbufEmblemInfo -{ - gchar *stock_id; - GtkIconSize stock_size; - gchar *stock_detail; -}; - -G_DEFINE_TYPE (CajaCellRendererPixbufEmblem, caja_cell_renderer_pixbuf_emblem, GTK_TYPE_CELL_RENDERER); - -static void -caja_cell_renderer_pixbuf_emblem_init (CajaCellRendererPixbufEmblem *cellpixbuf) -{ - CajaCellRendererPixbufEmblemInfo *cellinfo; - - cellinfo = g_new0 (CajaCellRendererPixbufEmblemInfo, 1); - cellinfo->stock_size = GTK_ICON_SIZE_MENU; - g_object_set_data (G_OBJECT (cellpixbuf), CELLINFO_KEY, cellinfo); -} - -static void -caja_cell_renderer_pixbuf_emblem_class_init (CajaCellRendererPixbufEmblemClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS (klass); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); - - object_class->finalize = caja_cell_renderer_pixbuf_emblem_finalize; - - object_class->get_property = caja_cell_renderer_pixbuf_emblem_get_property; - object_class->set_property = caja_cell_renderer_pixbuf_emblem_set_property; - - cell_class->get_size = caja_cell_renderer_pixbuf_emblem_get_size; - cell_class->render = caja_cell_renderer_pixbuf_emblem_render; - - g_object_class_install_property (object_class, - PROP_PIXBUF, - g_param_spec_object ("pixbuf", - "Pixbuf Object", - "The pixbuf to render", - GDK_TYPE_PIXBUF, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_PIXBUF_EXPANDER_OPEN, - g_param_spec_object ("pixbuf_expander_open", - "Pixbuf Expander Open", - "Pixbuf for open expander", - GDK_TYPE_PIXBUF, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_PIXBUF_EXPANDER_CLOSED, - g_param_spec_object ("pixbuf_expander_closed", - "Pixbuf Expander Closed", - "Pixbuf for closed expander", - GDK_TYPE_PIXBUF, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); - - g_object_class_install_property (object_class, - PROP_STOCK_ID, - g_param_spec_string ("stock_id", - "Stock ID", - "The stock ID of the stock icon to render", - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_STOCK_SIZE, - g_param_spec_enum ("stock_size", - "Size", - "The size of the rendered icon", - GTK_TYPE_ICON_SIZE, - GTK_ICON_SIZE_MENU, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_STOCK_DETAIL, - g_param_spec_string ("stock_detail", - "Detail", - "Render detail to pass to the theme engine", - NULL, - G_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_PIXBUF_EMBLEM, - g_param_spec_object ("pixbuf_emblem", - "Pixbuf Emblem Object", - "The emblem to overlay", - GDK_TYPE_PIXBUF, - G_PARAM_READABLE | - G_PARAM_WRITABLE)); -} - -static void -caja_cell_renderer_pixbuf_emblem_finalize (GObject *object) -{ - CajaCellRendererPixbufEmblem *cellpixbuf = CAJA_CELL_RENDERER_PIXBUF_EMBLEM (object); - CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY); - - if (cellpixbuf->pixbuf && cellinfo->stock_id) - { - g_object_unref (cellpixbuf->pixbuf); - } - - if (cellinfo->stock_id) - { - g_free (cellinfo->stock_id); - } - - if (cellinfo->stock_detail) - { - g_free (cellinfo->stock_detail); - } - - g_free (cellinfo); - g_object_set_data (object, CELLINFO_KEY, NULL); - - (* G_OBJECT_CLASS (caja_cell_renderer_pixbuf_emblem_parent_class)->finalize) (object); -} - -static void -caja_cell_renderer_pixbuf_emblem_get_property (GObject *object, - guint param_id, - GValue *value, - GParamSpec *pspec) -{ - CajaCellRendererPixbufEmblem *cellpixbuf = CAJA_CELL_RENDERER_PIXBUF_EMBLEM (object); - CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY); - - switch (param_id) - { - case PROP_PIXBUF: - g_value_set_object (value, - cellpixbuf->pixbuf ? G_OBJECT (cellpixbuf->pixbuf) : NULL); - break; - case PROP_PIXBUF_EXPANDER_OPEN: - g_value_set_object (value, - cellpixbuf->pixbuf_expander_open ? G_OBJECT (cellpixbuf->pixbuf_expander_open) : NULL); - break; - case PROP_PIXBUF_EXPANDER_CLOSED: - g_value_set_object (value, - cellpixbuf->pixbuf_expander_closed ? G_OBJECT (cellpixbuf->pixbuf_expander_closed) : NULL); - break; - case PROP_STOCK_ID: - g_value_set_string (value, cellinfo->stock_id); - break; - case PROP_STOCK_SIZE: - g_value_set_enum (value, cellinfo->stock_size); - break; - case PROP_STOCK_DETAIL: - g_value_set_string (value, cellinfo->stock_detail); - break; - case PROP_PIXBUF_EMBLEM: - g_value_set_object (value, - cellpixbuf->pixbuf_emblem ? G_OBJECT (cellpixbuf->pixbuf_emblem) : NULL); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -static void -caja_cell_renderer_pixbuf_emblem_set_property (GObject *object, - guint param_id, - const GValue *value, - GParamSpec *pspec) -{ - GdkPixbuf *pixbuf; - CajaCellRendererPixbufEmblem *cellpixbuf = CAJA_CELL_RENDERER_PIXBUF_EMBLEM (object); - CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (object, CELLINFO_KEY); - - switch (param_id) - { - case PROP_PIXBUF: - pixbuf = (GdkPixbuf*) g_value_get_object (value); - if (pixbuf) - { - g_object_ref (pixbuf); - } - if (cellpixbuf->pixbuf) - { - g_object_unref (cellpixbuf->pixbuf); - } - cellpixbuf->pixbuf = pixbuf; - break; - case PROP_PIXBUF_EXPANDER_OPEN: - pixbuf = (GdkPixbuf*) g_value_get_object (value); - if (pixbuf) - { - g_object_ref (pixbuf); - } - if (cellpixbuf->pixbuf_expander_open) - { - g_object_unref (cellpixbuf->pixbuf_expander_open); - } - cellpixbuf->pixbuf_expander_open = pixbuf; - break; - case PROP_PIXBUF_EXPANDER_CLOSED: - pixbuf = (GdkPixbuf*) g_value_get_object (value); - if (pixbuf) - { - g_object_ref (pixbuf); - } - if (cellpixbuf->pixbuf_expander_closed) - { - g_object_unref (cellpixbuf->pixbuf_expander_closed); - } - cellpixbuf->pixbuf_expander_closed = pixbuf; - break; - case PROP_STOCK_ID: - if (cellinfo->stock_id) - { - g_free (cellinfo->stock_id); - } - cellinfo->stock_id = g_strdup (g_value_get_string (value)); - break; - case PROP_STOCK_SIZE: - cellinfo->stock_size = g_value_get_enum (value); - break; - case PROP_STOCK_DETAIL: - if (cellinfo->stock_detail) - { - g_free (cellinfo->stock_detail); - } - cellinfo->stock_detail = g_strdup (g_value_get_string (value)); - break; - case PROP_PIXBUF_EMBLEM: - pixbuf = (GdkPixbuf *) g_value_get_object (value); - if (pixbuf) - { - g_object_ref (pixbuf); - } - if (cellpixbuf->pixbuf_emblem) - { - g_object_unref (cellpixbuf->pixbuf_emblem); - } - cellpixbuf->pixbuf_emblem = pixbuf; - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec); - break; - } -} - -GtkCellRenderer * -caja_cell_renderer_pixbuf_emblem_new (void) -{ - return g_object_new (CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, NULL); -} - -static void -caja_cell_renderer_pixbuf_emblem_create_stock_pixbuf (CajaCellRendererPixbufEmblem *cellpixbuf, - GtkWidget *widget) -{ - CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (G_OBJECT (cellpixbuf), CELLINFO_KEY); - - if (cellpixbuf->pixbuf) - { - g_object_unref (cellpixbuf->pixbuf); - } - - cellpixbuf->pixbuf = gtk_widget_render_icon (widget, - cellinfo->stock_id, - cellinfo->stock_size, - cellinfo->stock_detail); -} - -static void -caja_cell_renderer_pixbuf_emblem_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) -{ - CajaCellRendererPixbufEmblem *cellpixbuf = (CajaCellRendererPixbufEmblem *) cell; - CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY); - gint pixbuf_width = 0; - gint pixbuf_height = 0; - gint calc_width; - gint calc_height; - gint xpad, ypad; - - if (!cellpixbuf->pixbuf && cellinfo->stock_id) - caja_cell_renderer_pixbuf_emblem_create_stock_pixbuf (cellpixbuf, widget); - - if (cellpixbuf->pixbuf) - { - pixbuf_width = gdk_pixbuf_get_width (cellpixbuf->pixbuf); - pixbuf_height = gdk_pixbuf_get_height (cellpixbuf->pixbuf); - } - if (cellpixbuf->pixbuf_expander_open) - { - pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_open)); - pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_open)); - } - if (cellpixbuf->pixbuf_expander_closed) - { - pixbuf_width = MAX (pixbuf_width, gdk_pixbuf_get_width (cellpixbuf->pixbuf_expander_closed)); - pixbuf_height = MAX (pixbuf_height, gdk_pixbuf_get_height (cellpixbuf->pixbuf_expander_closed)); - } - - gtk_cell_renderer_get_padding (cell, &xpad, &ypad); - calc_width = xpad * 2 + pixbuf_width; - calc_height = ypad * 2 + pixbuf_height; - - if (x_offset) *x_offset = 0; - if (y_offset) *y_offset = 0; - - if (cell_area && pixbuf_width > 0 && pixbuf_height > 0) - { - gfloat xalign, yalign; - - gtk_cell_renderer_get_alignment (cell, &xalign, &yalign); - if (x_offset) - { - *x_offset = (((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? - 1.0 - xalign : xalign) * - (cell_area->width - calc_width - 2 * xpad)); - *x_offset = MAX (*x_offset, 0) + xpad; - } - if (y_offset) - { - *y_offset = (yalign * - (cell_area->height - calc_height - 2 * ypad)); - *y_offset = MAX (*y_offset, 0) + ypad; - } - } - - if (width) - *width = calc_width; - - if (height) - *height = calc_height; -} - -static void -caja_cell_renderer_pixbuf_emblem_render (GtkCellRenderer *cell, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags) - -{ - CajaCellRendererPixbufEmblem *cellpixbuf = (CajaCellRendererPixbufEmblem *) cell; - CajaCellRendererPixbufEmblemInfo *cellinfo = g_object_get_data (G_OBJECT (cell), CELLINFO_KEY); - GdkPixbuf *pixbuf; - GdkRectangle pix_rect; - GdkRectangle pix_emblem_rect; - gboolean stock_pixbuf = FALSE; - gint xpad, ypad; - gboolean is_expander, is_expanded; - cairo_t *cr; - - pixbuf = cellpixbuf->pixbuf; - g_object_get (cell, - "is-expander", &is_expander, - "is-expanded", &is_expanded, - NULL); - if (is_expander) - { - if (is_expanded && - cellpixbuf->pixbuf_expander_open != NULL) - { - pixbuf = cellpixbuf->pixbuf_expander_open; - } - else if (!is_expanded && - cellpixbuf->pixbuf_expander_closed != NULL) - { - pixbuf = cellpixbuf->pixbuf_expander_closed; - } - } - - if (!pixbuf && !cellinfo->stock_id) - { - return; - } - else if (!pixbuf && cellinfo->stock_id) - { - stock_pixbuf = TRUE; - } - - caja_cell_renderer_pixbuf_emblem_get_size (cell, widget, cell_area, - &pix_rect.x, - &pix_rect.y, - &pix_rect.width, - &pix_rect.height); - - if (stock_pixbuf) - pixbuf = cellpixbuf->pixbuf; - - gtk_cell_renderer_get_padding (cell, &xpad, &ypad); - pix_rect.x += cell_area->x; - pix_rect.y += cell_area->y; - pix_rect.width -= xpad * 2; - pix_rect.height -= ypad * 2; - - cr = gdk_cairo_create (window); - gdk_cairo_rectangle (cr, expose_area); - cairo_clip (cr); - gdk_cairo_rectangle (cr, cell_area); - cairo_clip (cr); - - gdk_cairo_set_source_pixbuf (cr, pixbuf, pix_rect.x, pix_rect.y); - gdk_cairo_rectangle (cr, &pix_rect); - cairo_fill (cr); - - if (cellpixbuf->pixbuf_emblem) - { - pix_emblem_rect.width = gdk_pixbuf_get_width (cellpixbuf->pixbuf_emblem); - pix_emblem_rect.height = gdk_pixbuf_get_height (cellpixbuf->pixbuf_emblem); - pix_emblem_rect.x = pix_rect.x; - pix_emblem_rect.y = pix_rect.y + pix_rect.height - pix_emblem_rect.height; - gdk_cairo_set_source_pixbuf (cr, cellpixbuf->pixbuf_emblem, - pix_emblem_rect.x, pix_emblem_rect.y); - gdk_cairo_rectangle (cr, &pix_emblem_rect); - cairo_fill (cr); - } - - cairo_destory (cr); -} diff --git a/libcaja-private/caja-cell-renderer-pixbuf-emblem.h b/libcaja-private/caja-cell-renderer-pixbuf-emblem.h deleted file mode 100644 index cfdf93d4..00000000 --- a/libcaja-private/caja-cell-renderer-pixbuf-emblem.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- - - caja-cell-renderer-pixbuf-emblem.h: cell renderer which can render - an emblem on top of a pixbuf (for use in FMListView and FMTreeView) - - Copyright (C) 2003 Juerg Billeter - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - General Public License for more details. - - You should have received a copy of the GNU General Public - License along with this program; if not, write to the - Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - This is based on GtkCellRendererPixbuf written by - Jonathan Blandford - - Author: Juerg Billeter -*/ - -#ifndef CAJA_CELL_RENDERER_PIXBUF_EMBLEM_H -#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM_H - -#include - -#define CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM caja_cell_renderer_pixbuf_emblem_get_type() -#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, CajaCellRendererPixbufEmblem)) -#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, CajaCellRendererPixbufEmblemClass)) -#define CAJA_IS_CELL_RENDERER_PIXBUF_EMBLEM(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM)) -#define CAJA_IS_CELL_RENDERER_PIXBUF_EMBLEM_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM)) -#define CAJA_CELL_RENDERER_PIXBUF_EMBLEM_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_CELL_RENDERER_PIXBUF_EMBLEM, CajaCellRendererPixbufEmblemClass)) - -typedef struct _CajaCellRendererPixbufEmblem CajaCellRendererPixbufEmblem; -typedef struct _CajaCellRendererPixbufEmblemClass CajaCellRendererPixbufEmblemClass; - -struct _CajaCellRendererPixbufEmblem -{ - GtkCellRenderer parent; - - /*< private >*/ - GdkPixbuf *pixbuf; - GdkPixbuf *pixbuf_expander_open; - GdkPixbuf *pixbuf_expander_closed; - GdkPixbuf *pixbuf_emblem; -}; - -struct _CajaCellRendererPixbufEmblemClass -{ - GtkCellRendererClass parent_class; -}; - -GType caja_cell_renderer_pixbuf_emblem_get_type (void); -GtkCellRenderer *caja_cell_renderer_pixbuf_emblem_new (void); - -#endif /* CAJA_CELL_RENDERER_PIXBUF_EMBLEM_H */ -- cgit v1.2.1 From 1a056cc77b431b2a013c052c78c0309ee52bc32b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 21:31:20 +0200 Subject: [icon-info] add caja_icon_theme_can_render() http://git.gnome.org/browse/nautilus/commit/?id=110a0e8f2b9ec96b34e4b76390e3f78adc9cda30 --- libcaja-private/caja-icon-info.c | 21 +++++++++++++++++++++ libcaja-private/caja-icon-info.h | 2 ++ 2 files changed, 23 insertions(+) diff --git a/libcaja-private/caja-icon-info.c b/libcaja-private/caja-icon-info.c index e504a557..7873ebfa 100644 --- a/libcaja-private/caja-icon-info.c +++ b/libcaja-private/caja-icon-info.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ /* caja-icon-info.c * Copyright (C) 2007 Red Hat, Inc., Alexander Larsson * @@ -757,3 +758,23 @@ caja_icon_get_emblem_size_for_icon_size (guint size) return 0; /* no emblems for smaller sizes */ } + +gboolean +caja_icon_theme_can_render (GThemedIcon *icon) +{ + GtkIconTheme *icon_theme; + const gchar * const *names; + gint idx; + + names = g_themed_icon_get_names (icon); + + icon_theme = gtk_icon_theme_get_default (); + + for (idx = 0; names[idx] != NULL; idx++) { + if (gtk_icon_theme_has_icon (icon_theme, names[idx])) { + return TRUE; + } + } + + return FALSE; +} diff --git a/libcaja-private/caja-icon-info.h b/libcaja-private/caja-icon-info.h index 7c2a75d2..d2bbc926 100644 --- a/libcaja-private/caja-icon-info.h +++ b/libcaja-private/caja-icon-info.h @@ -90,6 +90,8 @@ extern "C" { gint caja_get_icon_size_for_stock_size (GtkIconSize size); guint caja_icon_get_emblem_size_for_icon_size (guint size); +gboolean caja_icon_theme_can_render (GThemedIcon *icon); + #ifdef __cplusplus } -- cgit v1.2.1 From f170ef87e7968633dd4fb3e166e2e2ff0cfbba70 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 21:48:25 +0200 Subject: [tree-model] ony display the first emblem Only display the first emblem we can render. http://git.gnome.org/browse/nautilus/commit/?id=1d660252b408f3628a2d3d5943abcf6bfdd9091b --- src/file-manager/fm-tree-model.c | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index c7bcab10..3a3e3604 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -298,35 +298,30 @@ get_menu_icon_for_file (TreeNode *node, emblems_to_ignore[i++] = CAJA_FILE_EMBLEM_NAME_CANT_WRITE; } } - + emblems_to_ignore[i++] = NULL; emblem = NULL; emblem_icons = caja_file_get_emblem_icons (node->file, emblems_to_ignore); - if (emblem_icons != NULL) { - emblem_icon = emblem_icons->data; - emblem = g_emblem_new (emblem_icon); - emblemed_icon = g_emblemed_icon_new (gicon, emblem); - - g_object_unref (emblem); - - for (l = emblem_icons->next; l != NULL; l = l->next) { - emblem_icon = l->data; + /* pick only the first emblem we can render for the tree view */ + for (l = emblem_icons; l != NULL; l = l->next) { + emblem_icon = l->data; + if (caja_icon_theme_can_render (G_THEMED_ICON (emblem_icon))) { emblem = g_emblem_new (emblem_icon); - g_emblemed_icon_add_emblem - (G_EMBLEMED_ICON (emblemed_icon), emblem); + emblemed_icon = g_emblemed_icon_new (gicon, emblem); + g_object_unref (gicon); g_object_unref (emblem); - } + gicon = emblemed_icon; - eel_g_object_list_free (emblem_icons); - - g_object_unref (gicon); - gicon = emblemed_icon; + break; + } } + eel_g_object_list_free (emblem_icons); + info = caja_icon_info_lookup (gicon, size); retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); model = node->root->model; -- cgit v1.2.1 From 09766159b53c812ddf55485511cdca457d89d80d Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 21:50:34 +0200 Subject: [lc-p] remove unused caja-iso9660.h http://git.gnome.org/browse/nautilus/commit/?id=52a37d6e46fc34cef6061bc91aa02847652f3c9d --- libcaja-private/Makefile.am | 1 - libcaja-private/caja-iso9660.h | 110 ----------------------------------------- 2 files changed, 111 deletions(-) delete mode 100644 libcaja-private/caja-iso9660.h diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am index 9d53c844..5db9c6e1 100644 --- a/libcaja-private/Makefile.am +++ b/libcaja-private/Makefile.am @@ -119,7 +119,6 @@ libcaja_private_la_SOURCES = \ caja-icon-names.h \ caja-idle-queue.c \ caja-idle-queue.h \ - caja-iso9660.h \ caja-keep-last-vertical-box.c \ caja-keep-last-vertical-box.h \ caja-lib-self-check-functions.c \ diff --git a/libcaja-private/caja-iso9660.h b/libcaja-private/caja-iso9660.h deleted file mode 100644 index d8352cc2..00000000 --- a/libcaja-private/caja-iso9660.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Header file iso9660.h - assorted structure definitions and typecasts. - * specific to iso9660 filesystem. - - Written by Eric Youngdale (1993). - - Copyright 1993 Yggdrasil Computing, Incorporated - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _ISOFS_FS_H -#define _ISOFS_FS_H - -/* - * The isofs filesystem constants/structures - */ - -#define ISODCL(from, to) (to - from + 1) - -struct iso_volume_descriptor -{ - char type[ISODCL(1,1)]; /* 711 */ - char id[ISODCL(2,6)]; - char version[ISODCL(7,7)]; - char data[ISODCL(8,2048)]; -}; - -/* volume descriptor types */ -#define ISO_VD_PRIMARY 1 -#define ISO_VD_END 255 - -#define ISO_STANDARD_ID "CD001" - -struct iso_primary_descriptor -{ - char type [ISODCL ( 1, 1)]; /* 711 */ - char id [ISODCL ( 2, 6)]; - char version [ISODCL ( 7, 7)]; /* 711 */ - char unused1 [ISODCL ( 8, 8)]; - char system_id [ISODCL ( 9, 40)]; /* achars */ - char volume_id [ISODCL ( 41, 72)]; /* dchars */ - char unused2 [ISODCL ( 73, 80)]; - char volume_space_size [ISODCL ( 81, 88)]; /* 733 */ - char unused3 [ISODCL ( 89, 120)]; - char volume_set_size [ISODCL (121, 124)]; /* 723 */ - char volume_sequence_number [ISODCL (125, 128)]; /* 723 */ - char logical_block_size [ISODCL (129, 132)]; /* 723 */ - char path_table_size [ISODCL (133, 140)]; /* 733 */ - char type_l_path_table [ISODCL (141, 144)]; /* 731 */ - char opt_type_l_path_table [ISODCL (145, 148)]; /* 731 */ - char type_m_path_table [ISODCL (149, 152)]; /* 732 */ - char opt_type_m_path_table [ISODCL (153, 156)]; /* 732 */ - char root_directory_record [ISODCL (157, 190)]; /* 9.1 */ - char volume_set_id [ISODCL (191, 318)]; /* dchars */ - char publisher_id [ISODCL (319, 446)]; /* achars */ - char preparer_id [ISODCL (447, 574)]; /* achars */ - char application_id [ISODCL (575, 702)]; /* achars */ - char copyright_file_id [ISODCL (703, 739)]; /* 7.5 dchars */ - char abstract_file_id [ISODCL (740, 776)]; /* 7.5 dchars */ - char bibliographic_file_id [ISODCL (777, 813)]; /* 7.5 dchars */ - char creation_date [ISODCL (814, 830)]; /* 8.4.26.1 */ - char modification_date [ISODCL (831, 847)]; /* 8.4.26.1 */ - char expiration_date [ISODCL (848, 864)]; /* 8.4.26.1 */ - char effective_date [ISODCL (865, 881)]; /* 8.4.26.1 */ - char file_structure_version [ISODCL (882, 882)]; /* 711 */ - char unused4 [ISODCL (883, 883)]; - char application_data [ISODCL (884, 1395)]; - char unused5 [ISODCL (1396, 2048)]; -}; - -/* We use this to help us look up the parent inode numbers. */ - -struct iso_path_table -{ - unsigned char name_len[2]; /* 721 */ - char extent[4]; /* 731 */ - char parent[2]; /* 721 */ - char name[1]; -}; - -struct iso_directory_record -{ - unsigned char length [ISODCL (1, 1)]; /* 711 */ - char ext_attr_length [ISODCL (2, 2)]; /* 711 */ - char extent [ISODCL (3, 10)]; /* 733 */ - char size [ISODCL (11, 18)]; /* 733 */ - char date [ISODCL (19, 25)]; /* 7 by 711 */ - char flags [ISODCL (26, 26)]; - char file_unit_size [ISODCL (27, 27)]; /* 711 */ - char interleave [ISODCL (28, 28)]; /* 711 */ - char volume_sequence_number [ISODCL (29, 32)]; /* 723 */ - unsigned char name_len [ISODCL (33, 33)]; /* 711 */ - char name [34]; /* Not really, but we need something here */ -}; -#endif - - - -- cgit v1.2.1 From 628b15b81b856d42bf00339d317cdcdc3200bbc4 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sun, 28 Oct 2012 14:08:09 +0200 Subject: [eel] simplify build system Note: remove eel-types.h include in eel-wrap-table.c (which was removed upstream prior, along with eel-image-table.[ch], after removal of emblems/background-setting stuff, which we're not doing, yet). So change EEL_TYPE_JUSTIFICATION to GTK_TYPE_JUSTIFICATION, and EEL_JUSTIFICATION_BEGINNING to GTK_JUSTIFY_LEFT. Upstream commit/message: We don't need the enumtypes anymore, and the marshallers can easily be autogenerated. http://git.gnome.org/browse/nautilus/commit/?id=75a03a440ebff23ccbf8674ca4a0e9f6475ebbb8 --- eel/Makefile.am | 90 ++++++--------------- eel/eel-background.c | 4 - eel/eel-types.c | 82 ------------------- eel/eel-types.h | 32 -------- eel/eel-wrap-table.c | 12 +-- eel/eel.h | 1 - eel/eelmarshal.list | 13 --- eel/makeenums.pl | 220 --------------------------------------------------- eel/maketypes.awk | 155 ------------------------------------ 9 files changed, 30 insertions(+), 579 deletions(-) delete mode 100644 eel/eel-types.c delete mode 100644 eel/eel-types.h delete mode 100644 eel/eelmarshal.list delete mode 100755 eel/makeenums.pl delete mode 100755 eel/maketypes.awk diff --git a/eel/Makefile.am b/eel/Makefile.am index d7b04129..19407089 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -15,6 +15,11 @@ INCLUDES = \ -DMATEMENU_I_KNOW_THIS_IS_UNSTABLE \ $(NULL) +BUILT_SOURCES = \ + eel-marshal.c \ + eel-marshal.h \ + $(NULL) + libeel_2_la_LDFLAGS = \ -no-undefined \ $(CORE_CFLAGS) \ @@ -52,7 +57,6 @@ libeel_2_la_SOURCES = \ eel-self-checks.c \ eel-stock-dialogs.c \ eel-string.c \ - eel-types.c \ eel-vfs-extensions.c \ eel-wrap-table.c \ eel-xml-extensions.c \ @@ -85,57 +89,33 @@ eel_headers = \ eel-self-checks.h \ eel-stock-dialogs.h \ eel-string.h \ - eel-types.h \ eel-vfs-extensions.h \ eel-wrap-table.h \ eel-xml-extensions.h \ eel.h \ $(NULL) -marshal_sources = \ - eel-marshal.h \ - eel-marshal.c \ - $(NULL) - -eel-marshal.h: eelmarshal.list $(GLIB_GENMARSHAL) - $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=eel_marshal > $@ -eel-marshal.c: eelmarshal.list $(GLIB_GENMARSHAL) - $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --body --prefix=eel_marshal > $@ - -stamp_sources = \ - eel-enums.defs \ - eel-type-builtins-evals.c \ - $(NULL) - -stamps = \ - eel-makeenums-stamp \ - eel-stamp \ +nodist_libeel_2_la_SOURCES = \ + $(BUILT_SOURCES) \ $(NULL) -eel-makeenums-stamp: makeenums.pl $(eel_headers) - $(AM_V_GEN)$(PERL) $< defs $(filter-out $<,$^) > xgen-eed \ - && (cmp -s xgen-eed eel-enums.defs || mv -f xgen-eed eel-enums.defs) \ - && rm -f xgen-eed \ - && $(PERL) $< arrays $(filter-out $<,$^) > xgen-etbe \ - && (cmp -s xgen-etbe eel-type-builtins-evals.c || mv -f xgen-etbe eel-type-builtins-evals.c) \ - && rm -f xgen-etbe \ - && echo timestamp > $@ - -maketypes_sources = \ - eel-type-builtins.h \ - eel-type-builtins-ids.c \ - eel-type-builtins-vars.c \ - $(NULL) +eel-marshal.list: $(libeel_2_la_SOURCES) Makefile.am + $(AM_V_GEN)( cd $(srcdir) && \ + sed -n -e 's/.*eel_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \ + $(libeel_2_la_SOURCES) ) \ + | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp + @if cmp -s $@.tmp $@; then \ + rm $@.tmp; \ + else \ + mv $@.tmp $@; \ + fi -eel-stamp: eel-makeenums-stamp $(maketypes_sources) - echo timestamp > $@ +%-marshal.c: %-marshal.list Makefile + $(AM_V_GEN)echo "#include \"eel-marshal.h\"" > $@ && \ + $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c -eel-type-builtins.h: eel-enums.defs maketypes.awk eel-makeenums-stamp - LC_ALL=C $(AWK) -f $(srcdir)/maketypes.awk $< macros > $@ -eel-type-builtins-vars.c: eel-enums.defs maketypes.awk eel-makeenums-stamp - LC_ALL=C $(AWK) -f $(srcdir)/maketypes.awk $< variables > $@ -eel-type-builtins-ids.c: eel-enums.defs maketypes.awk eel-makeenums-stamp - LC_ALL=C $(AWK) -f $(srcdir)/maketypes.awk $< entries > $@ +%-marshal.h: %-marshal.list Makefile + $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h noinst_PROGRAMS = check-program @@ -148,28 +128,10 @@ TESTS = check-eel EXTRA_DIST = \ $(eel_headers) \ - eel-type-builtins.h \ - eel-marshal.h \ check-eel \ - eelmarshal.list \ - makeenums.pl \ - maketypes.awk \ + eel-marshal.list \ $(NULL) -$(libeel_2_la_OBJECTS): $(marshal_sources) - -# This trick causes the stamp file to be built first. -Makefile: eel-stamp - -# This trick causes the generated files to be built the first time. -$(stamp_sources): # never add any dependencies - test -f $@ || touch $@ - -built_sources = $(stamps) $(stamp_sources) $(maketypes_sources) $(marshal_sources) -CLEANFILES = $(built_sources) -DONT_DIST_FILES = $(built_sources) - -dist-hook: - for file in $(DONT_DIST_FILES) ; do \ - rm -f $(distdir)/$$file ; \ - done +CLEANFILES = \ + $(BUILT_SOURCES) \ + $(NULL) diff --git a/eel/eel-background.c b/eel/eel-background.c index 98c85163..9cada8c0 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -32,8 +32,6 @@ #include "eel-lib-self-check-functions.h" #include "eel-string.h" #include "eel-marshal.h" -#include "eel-types.h" -#include "eel-type-builtins.h" #include #include #include @@ -112,8 +110,6 @@ eel_background_class_init (gpointer klass) object_class = G_OBJECT_CLASS (klass); - eel_type_init (); - signals[APPEARANCE_CHANGED] = g_signal_new ("appearance_changed", G_TYPE_FROM_CLASS (object_class), diff --git a/eel/eel-types.c b/eel/eel-types.c deleted file mode 100644 index 4b5ae176..00000000 --- a/eel/eel-types.c +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* eel-types.h - - - Copyright (C) 2000 Eazel, Inc. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Maciej Stachowiak -*/ - - -#include -#include - -#define EEL_COMPILATION 1 -#include - -#include "eel-type-builtins-vars.c" -#include "eel-type-builtins-evals.c" - -void -eel_type_init (void) -{ - int i; - GType type_id; - static gboolean initialized = FALSE; - - static struct - { - const gchar *type_name; - GType *type_id; - GType parent; - gconstpointer pointer1; - gpointer pointer2; - } builtin_info[EEL_TYPE_N_BUILTINS] = - { -#include "eel-type-builtins-ids.c" - }; - - if (initialized) - { - return; - } - initialized = TRUE; - - for (i = 0; i < EEL_TYPE_N_BUILTINS; i++) - { - type_id = G_TYPE_INVALID; - - if (builtin_info[i].parent == G_TYPE_ENUM) - { - type_id = g_enum_register_static (builtin_info[i].type_name, - builtin_info[i].pointer1); - } - else if (builtin_info[i].parent == G_TYPE_FLAGS) - { - type_id = g_flags_register_static (builtin_info[i].type_name, - builtin_info[i].pointer1); - } - else - { - g_assert_not_reached (); - } - - g_assert (type_id != G_TYPE_INVALID); - *builtin_info[i].type_id = type_id; - } -} - diff --git a/eel/eel-types.h b/eel/eel-types.h deleted file mode 100644 index ff25087d..00000000 --- a/eel/eel-types.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ -/* eel-types.h - - - Copyright (C) 2000 Eazel, Inc. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Maciej Stachowiak -*/ - -#ifndef EEL_TYPES_H -#define EEL_TYPES_H - -#include - -void eel_type_init (void); - -#endif /* EEL_TYPES_H */ - diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c index 36c6c718..794e1c72 100644 --- a/eel/eel-wrap-table.c +++ b/eel/eel-wrap-table.c @@ -29,7 +29,6 @@ #include "eel-art-gtk-extensions.h" #include "eel-gtk-extensions.h" #include "eel-gtk-macros.h" -#include "eel-types.h" #include /* Arguments */ @@ -135,9 +134,6 @@ eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class) container_class->forall = eel_wrap_table_forall; container_class->child_type = eel_wrap_table_child_type; - /* Register some the enum types we need */ - eel_type_init (); - /* Arguments */ g_object_class_install_property (gobject_class, @@ -155,16 +151,16 @@ eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class) (gobject_class, PROP_X_JUSTIFICATION, g_param_spec_enum ("x_justification", NULL, NULL, - EEL_TYPE_JUSTIFICATION, - EEL_JUSTIFICATION_BEGINNING, + GTK_TYPE_JUSTIFICATION, + GTK_JUSTIFY_LEFT, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, PROP_Y_JUSTIFICATION, g_param_spec_enum ("y_justification", NULL, NULL, - EEL_TYPE_JUSTIFICATION, - EEL_JUSTIFICATION_BEGINNING, + GTK_TYPE_JUSTIFICATION, + GTK_JUSTIFY_LEFT, G_PARAM_READWRITE)); g_object_class_install_property diff --git a/eel/eel.h b/eel/eel.h index 2a965a56..c86bc99a 100644 --- a/eel/eel.h +++ b/eel/eel.h @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include diff --git a/eel/eelmarshal.list b/eel/eelmarshal.list deleted file mode 100644 index 3974c4b7..00000000 --- a/eel/eelmarshal.list +++ /dev/null @@ -1,13 +0,0 @@ -BOOLEAN:BOOLEAN -BOOLEAN:BOXED -BOOLEAN:POINTER,POINTER -BOOLEAN:VOID -ENUM:INT,INT -INT:INT -INT:POINTER,STRING -STRING:POINTER -STRING:VOID -VOID:ENUM,INT -VOID:ENUM,INT,BOOLEAN -VOID:INT,INT,INT,INT -VOID:OBJECT,POINTER diff --git a/eel/makeenums.pl b/eel/makeenums.pl deleted file mode 100755 index 50402ed2..00000000 --- a/eel/makeenums.pl +++ /dev/null @@ -1,220 +0,0 @@ -#!/usr/bin/perl -w - -# This script snarfs the enums from header files and writes them out into -# a .defs file (mate.defs, for example). From there, the sister script -# maketypes.awk converts the defs into a *typebuiltins.h, as well as -# *typebuiltins_vals.c, *typebuiltins_ids.c and *typebuiltins_evals.c. - -# Information about the current enumeration - -my $flags; # Is enumeration a bitmask -my $seenbitshift; # Have we seen bitshift operators? -my $prefix; # Prefix for this enumeration -my $enumname; # Name for this enumeration -my $firstenum = 1; # Is this the first enumeration in file? -my @entries; # [ $name, $val ] for each entry - -sub parse_options { - my $opts = shift; - my @opts; - - for $opt (split /\s*,\s*/, $opts) { - my ($key,$val) = $opt =~ /\s*(\w+)(?:=(\S+))?/; - defined $val or $val = 1; - push @opts, $key, $val; - } - @opts; -} -sub parse_entries { - my $file = shift; - - while (<$file>) { - # Read lines until we have no open comments - while (m@/\* - ([^*]|\*(?!/))*$ - @x) { - my $new; - defined ($new = <$file>) || die "Unmatched comment"; - $_ .= $new; - } - # Now strip comments - s@/\*(?!<) - ([^*]+|\*(?!/))* - \*/@@gx; - - s@\n@ @; - - next if m@^\s*$@; - - # Handle include files - if (/^\#include\s*<([^>]*)>/ ) { - my $file= "../$1"; - open NEWFILE, $file or die "Cannot open include file $file: $!\n"; - - if (parse_entries (\*NEWFILE)) { - return 1; - } else { - next; - } - } - - if (/^\s*\}\s*(\w+)/) { - $enumname = $1; - return 1; - } - - if (m@^\s* - (\w+)\s* # name - (?:=( # value - (?:[^,/]|/(?!\*))* - ))?,?\s* - (?:/\*< # options - (([^*]|\*(?!/))*) - >\*/)? - \s*$ - @x) { - my ($name, $value, $options) = ($1,$2,$3); - - if (!defined $flags && defined $value && $value =~ /<) { - if (eof) { - close (ARGV); # reset line numbering - $firstenum = 1; # Flag to print filename at next enum - } - - if (m@^\s*typedef\s+enum\s* - ({)?\s* - (?:/\*< - (([^*]|\*(?!/))*) - >\*/)? - @x) { - if (defined $2) { - my %options = parse_options($2); - $prefix = $options{prefix}; - $flags = $options{flags}; - } else { - $prefix = undef; - $flags = undef; - } - # Didn't have trailing '{' look on next lines - if (!defined $1) { - while (<>) { - if (s/^\s*\{//) { - last; - } - } - } - - $seenbitshift = 0; - @entries = (); - - # Now parse the entries - parse_entries (\*ARGV); - - # figure out if this was a flags or enums enumeration - - if (!defined $flags) { - $flags = $seenbitshift; - } - - # Autogenerate a prefix - - if (!defined $prefix) { - for (@entries) { - my $name = $_->[0]; - if (defined $prefix) { - my $tmp = ~ ($name ^ $prefix); - ($tmp) = $tmp =~ /(^\xff*)/; - $prefix = $prefix & $tmp; - } else { - $prefix = $name; - } - } - # Trim so that it ends in an underscore - $prefix =~ s/_[^_]*$/_/; - } - - for $entry (@entries) { - my ($name,$nick) = @{$entry}; - if (!defined $nick) { - ($nick = $name) =~ s/^$prefix//; - $nick =~ tr/_/-/; - $nick = lc($nick); - @{$entry} = ($name, $nick); - } - } - - # Spit out the output - - if ($gen_defs) { - if ($firstenum) { - print qq(\n; enumerations from "$ARGV"\n); - $firstenum = 0; - } - - print "\n(define-".($flags ? "flags" : "enum")." $enumname"; - - for (@entries) { - my ($name,$nick) = @{$_}; - print "\n ($nick $name)"; - } - print ")\n"; - - } else { - ($valuename = $enumname) =~ s/([A-Z][a-z])/_$1/g; - $valuename =~ s/([a-z])([A-Z])/$1_$2/g; - $valuename = lc($valuename); - - print "static const GEnumValue $ {valuename}_values[] = {\n"; - for (@entries) { - my ($name,$nick) = @{$_}; - print qq( { $name, "$name", "$nick" },\n); - } - print " { 0, NULL, NULL }\n"; - print "};\n"; - } - } -} diff --git a/eel/maketypes.awk b/eel/maketypes.awk deleted file mode 100755 index 4284eddd..00000000 --- a/eel/maketypes.awk +++ /dev/null @@ -1,155 +0,0 @@ - -BEGIN { - type_name = ""; # GtkEnumType - type_macro = ""; # GTK_TYPE_ENUM_TYPE - type_ident = ""; # _gtk_enum_type - type_counter = 0; - gen_macros = 0; - gen_entries = 0; - gen_vars = 0; - boxed_copy = ""; - boxed_free = ""; - - for (i = 2; i < ARGC; i++) - { - if (ARGV[i] == "macros") - gen_macros = 1; - else if (ARGV[i] == "entries") - gen_entries = 1; - else if (ARGV[i] == "variables") - gen_vars = 1; - ARGV[i] = ""; - } - - if (gen_macros) - { - printf ("/* type macros, generated by maketypes.awk */\n"); - printf ("\n"); - printf ("#ifdef G_OS_WIN32\n"); - printf ("# ifdef EEL_COMPILATION\n"); - printf ("# define EELTYPEBUILTINS_VAR __declspec(dllexport)\n"); - printf ("# else\n"); - printf ("# define EELTYPEBUILTINS_VAR extern __declspec(dllimport)\n"); - printf ("# endif\n"); - printf ("#else\n"); - printf ("# ifdef EEL_COMPILATION\n"); - printf ("# define EELTYPEBUILTINS_VAR\n"); - printf ("# else\n"); - printf ("# define EELTYPEBUILTINS_VAR extern\n"); - printf ("# endif\n"); - printf ("#endif\n"); - printf ("\n"); - } - else if (gen_entries) - printf ("/* type entries, generated by maketypes.awk */\n\n"); - else if (gen_vars) - printf ("/* type variables, generated by maketypes.awk */\n\n"); - else - { - printf ("hm? what do you want me to do?\n") > "/dev/stderr"; - exit 1; - } -} - -function set_type (set_type_1) -{ - type_counter += 1; - type_name = set_type_1; - type_macro = "EEL_TYPE_"; - - tmp = type_name; -# OK, the following is ridiculous, and sed s///g would be far easier - gsub ("[A-Z]", "@&", tmp); - gsub ("[^A-Z]@", "&_", tmp); - gsub ("@", "", tmp); - gsub ("[A-Z][A-Z][A-Z][0-9a-z]", "@&", tmp); - gsub ("@..", "&_", tmp); - gsub ("@", "", tmp); - type_macro = type_macro toupper (tmp); - type_ident = "_" tolower (tmp); - - sub ("^EEL_TYPE_EEL_", "EEL_TYPE_", type_macro); -} - -function generate (generate_what) -{ - if (gen_macros) - { - printf ("EELTYPEBUILTINS_VAR GType %s;\n", type_macro); - } - if (gen_entries) - { - printf (" { \"%s\", &%s,\n", type_name, type_macro); - if (generate_what == "BOXED") - printf (" G_TYPE_%s, %s, %s, },\n", generate_what, boxed_copy, boxed_free); - else - printf (" G_TYPE_%s, %s_values },\n", generate_what, type_ident); - } - if (gen_vars) - { - printf ("EELTYPEBUILTINS_VAR GType %s = 0;\n", type_macro); - } -} - -# skip scheme comments -";" { - sub (";.*", ""); -} - -# parse keywords - -/\(define-enum/ { - if ($2 == "") - printf ("huh? define-enum keyword without arg?\n") > "/dev/stderr"; - else - { - set_type($2); - generate("ENUM"); - } -} - -/\(define-flags/ { - if ($2 == "") - printf ("huh? define-flags keyword without arg?\n") > "/dev/stderr"; - else - { - set_type($2); - generate("FLAGS"); - } -} - -/\(define-boxed/ { - if ($2 == "") - printf ("huh? define-boxed keyword without arg?\n") > "/dev/stderr"; - else - { - boxed_copy = "NULL"; - boxed_free = "NULL"; - set_type($2); - do { - getline; - sub (";.*", "", $0); - } while ($0 ~ /^[ \t]*$/); - tmp_var1 = $1; - if ($0 ~ /\)/) { generate("BOXED"); next; } - do { - getline; - sub (";.*", "", $0); - } while ($0 ~ /^[ \t]*$/); - tmp_var2 = $1; - sub (/\).*/, "", tmp_var2); - if (tmp_var1 ~ /^[_A-Za-z][_A-Za-z0-9]*$/ && - tmp_var2 ~ /^[_A-Za-z][_A-Za-z0-9]*$/) - { - boxed_copy = tmp_var1; - boxed_free = tmp_var2; - # printf ("read boxed funcs: %s %s\n", boxed_copy, boxed_free) > "/dev/stderr"; - } - generate("BOXED"); - } -} - -END { - if (gen_macros) - printf("\n#define\tEEL_TYPE_N_BUILTINS\t(%u)\n", type_counter); -} -- cgit v1.2.1 From ce96467ba24b0dc13262fb5cb7ae8eb674c2099e Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 08:54:18 +0200 Subject: [lc-p] autogenerate marshallers http://git.gnome.org/browse/nautilus/commit/?id=6509c91b48f52c72c868f2ca7a9b47c46b9e0bc6 --- libcaja-private/Makefile.am | 40 +++++++++++++++++++++++------------ libcaja-private/caja-icon-container.c | 14 ++++++------ libcaja-private/caja-marshal.c | 2 -- libcaja-private/caja-marshal.list | 23 -------------------- 4 files changed, 34 insertions(+), 45 deletions(-) delete mode 100644 libcaja-private/caja-marshal.c delete mode 100644 libcaja-private/caja-marshal.list diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am index 5db9c6e1..cbf91983 100644 --- a/libcaja-private/Makefile.am +++ b/libcaja-private/Makefile.am @@ -18,6 +18,11 @@ INCLUDES = \ $(UNIQUE_CFLAGS) \ $(NULL) +BUILT_SOURCES = \ + caja-marshal.c \ + caja-marshal.h \ + $(NULL) + dependency_static_libs = \ $(top_builddir)/cut-n-paste-code/libegg/libegg.la \ $(NULL) @@ -36,11 +41,6 @@ libcaja_private_la_LIBADD = \ $(CORE_LIBS) \ $(NULL) -marshal_sources = \ - caja-marshal.h \ - caja-marshal-guts.c \ - $(NULL) - libcaja_private_la_SOURCES = \ caja-autorun.c \ caja-autorun.h \ @@ -125,8 +125,6 @@ libcaja_private_la_SOURCES = \ caja-lib-self-check-functions.h \ caja-link.c \ caja-link.h \ - caja-marshal.c \ - caja-marshal.h \ caja-merged-directory.c \ caja-merged-directory.h \ caja-metadata.h \ @@ -195,14 +193,29 @@ libcaja_private_la_SOURCES = \ caja-undostack-manager.h \ $(NULL) +nodist_libcaja_private_la_SOURCES =\ + $(BUILT_SOURCES) \ + $(NULL) + $(lib_LTLIBRARIES): $(dependency_static_libs) -caja-marshal.h: caja-marshal.list $(GLIB_GENMARSHAL) - $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --header --prefix=caja_marshal > $@ -caja-marshal-guts.c: caja-marshal.list $(GLIB_GENMARSHAL) - $(AM_V_GEN)$(GLIB_GENMARSHAL) $< --body --prefix=caja_marshal > $@ +caja-marshal.list: $(libcaja_private_la_SOURCES) Makefile.am + $(AM_V_GEN)( cd $(srcdir) && \ + sed -n -e 's/.*caja_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \ + $(libcaja_private_la_SOURCES) ) \ + | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp + @if cmp -s $@.tmp $@; then \ + rm $@.tmp; \ + else \ + mv $@.tmp $@; \ + fi + +%-marshal.h: %-marshal.list Makefile + $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h -$(libcaja_private_la_OBJECTS): $(marshal_sources) +%-marshal.c: %-marshal.list Makefile + $(AM_V_GEN)echo "#include \"caja-marshal.h\"" > $@ && \ + $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c gsettingsschema_in_files = org.mate.caja.gschema.xml.in org.mate.media-handling.gschema.xml.in gsettings_SCHEMAS = $(gsettingsschema_in_files:.xml.in=.xml) @@ -220,9 +233,10 @@ EXTRA_DIST = \ $(NULL) CLEANFILES = \ - $(marshal_sources) \ + $(BUILT_SOURCES) \ $(schema_DATA) \ $(gsettings_SCHEMAS) \ + caja-marshal.list \ $(NULL) dist-hook: diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index b9a7dfc4..eb1eaedb 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -6346,7 +6346,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, get_icon_uri), NULL, NULL, - eel_marshal_STRING__POINTER, + caja_marshal_STRING__POINTER, G_TYPE_STRING, 1, G_TYPE_POINTER); signals[GET_ICON_DROP_TARGET_URI] @@ -6356,7 +6356,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, get_icon_drop_target_uri), NULL, NULL, - eel_marshal_STRING__POINTER, + caja_marshal_STRING__POINTER, G_TYPE_STRING, 1, G_TYPE_POINTER); signals[MOVE_COPY_ITEMS] @@ -6439,7 +6439,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, get_container_uri), NULL, NULL, - eel_marshal_STRING__VOID, + caja_marshal_STRING__VOID, G_TYPE_STRING, 0); signals[CAN_ACCEPT_ITEM] = g_signal_new ("can_accept_item", @@ -6448,7 +6448,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, can_accept_item), NULL, NULL, - eel_marshal_INT__POINTER_STRING, + caja_marshal_INT__POINTER_STRING, G_TYPE_INT, 2, G_TYPE_POINTER, G_TYPE_STRING); @@ -6459,7 +6459,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, get_stored_icon_position), NULL, NULL, - eel_marshal_BOOLEAN__POINTER_POINTER, + caja_marshal_BOOLEAN__POINTER_POINTER, G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_POINTER); @@ -6470,7 +6470,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, get_stored_layout_timestamp), NULL, NULL, - eel_marshal_BOOLEAN__POINTER_POINTER, + caja_marshal_BOOLEAN__POINTER_POINTER, G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_POINTER); @@ -6481,7 +6481,7 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_STRUCT_OFFSET (CajaIconContainerClass, store_layout_timestamp), NULL, NULL, - eel_marshal_BOOLEAN__POINTER_POINTER, + caja_marshal_BOOLEAN__POINTER_POINTER, G_TYPE_BOOLEAN, 2, G_TYPE_POINTER, G_TYPE_POINTER); diff --git a/libcaja-private/caja-marshal.c b/libcaja-private/caja-marshal.c deleted file mode 100644 index 59c9ddcc..00000000 --- a/libcaja-private/caja-marshal.c +++ /dev/null @@ -1,2 +0,0 @@ -#include "caja-marshal.h" -#include "caja-marshal-guts.c" diff --git a/libcaja-private/caja-marshal.list b/libcaja-private/caja-marshal.list deleted file mode 100644 index 787dcc52..00000000 --- a/libcaja-private/caja-marshal.list +++ /dev/null @@ -1,23 +0,0 @@ -BOOLEAN:POINTER -BOOLEAN:VOID -INT:POINTER,BOOLEAN -INT:POINTER,INT -INT:POINTER,POINTER -OBJECT:BOXED -POINTER:VOID -STRING:VOID -VOID:DOUBLE -VOID:INT,BOOLEAN,BOOLEAN,BOOLEAN,BOOLEAN -VOID:INT,STRING -VOID:OBJECT,BOOLEAN -VOID:OBJECT,OBJECT -VOID:POINTER,ENUM -VOID:POINTER,POINTER -VOID:POINTER,POINTER -VOID:POINTER,POINTER,POINTER,ENUM,INT,INT -VOID:POINTER,STRING -VOID:POINTER,STRING,ENUM,INT,INT -VOID:STRING,STRING,ENUM,INT,INT -VOID:STRING,ENUM,INT,INT -VOID:STRING,STRING -VOID:POINTER,INT,STRING,STRING,ENUM,INT,INT -- cgit v1.2.1 From 40167f57fa40d667514b805d6253c372a4a1b9a4 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 25 Oct 2012 13:15:36 +0200 Subject: [src] autogenerate marshallers http://git.gnome.org/browse/nautilus/commit/?id=608918449f548b0d3ea3e7916c944b077ac43e87 --- src/Makefile.am | 32 +++++++++++++++++++++++++++++--- src/caja-query-editor.c | 4 ++-- src/caja-window.c | 6 +++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/src/Makefile.am b/src/Makefile.am index c929e6d3..21de26ee 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,6 +52,11 @@ desktopdir = $(datadir)/mate/network/ schemedir = $(datadir)/applications scheme_DATA = mate-network-scheme.desktop +BUILT_SOURCES = \ + caja-src-marshal.c \ + caja-src-marshal.h \ + $(NULL) + caja_SOURCES = \ caja-actions.h \ caja-application.c \ @@ -141,6 +146,28 @@ caja_SOURCES = \ caja-zoom-control.h \ $(NULL) +nodist_caja_SOURCES = \ + $(BUILT_SOURCES) \ + $(NULL) + +caja-src-marshal.list: $(caja_SOURCES) Makefile.am + $(AM_V_GEN)( cd $(srcdir) && \ + sed -n -e 's/.*caja_src_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \ + $(caja_SOURCES) ) \ + | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp + @if cmp -s $@.tmp $@; then \ + rm $@.tmp; \ + else \ + mv $@.tmp $@; \ + fi + +%-marshal.c: %-marshal.list Makefile + $(AM_V_GEN)echo "#include \"caja-src-marshal.h\"" > $@ && \ + $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c + +%-marshal.h: %-marshal.list Makefile + $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h + caja_file_management_properties_SOURCES = \ caja-file-management-properties.c \ caja-file-management-properties.h \ @@ -179,19 +206,18 @@ ui_DATA = \ $(NULL) CLEANFILES = \ + $(BUILT_SOURCES) \ $(desktop_files) \ $(server_DATA) \ $(NULL) EXTRA_DIST = \ + caja-src-marshal.list \ $(server_in_files) \ $(ui_DATA) \ check-caja \ $(desktop_in_files) \ $(NULL) -BUILT_SOURCES = \ - $(NULL) - dist-hook: cd $(distdir); rm -f $(CLEANFILES) diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c index dab9e329..dcd4416a 100644 --- a/src/caja-query-editor.c +++ b/src/caja-query-editor.c @@ -23,10 +23,10 @@ #include #include "caja-query-editor.h" +#include "caja-src-marshal.h" #include "caja-window-slot.h" #include -#include #include #include #include @@ -197,7 +197,7 @@ caja_query_editor_class_init (CajaQueryEditorClass *class) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CajaQueryEditorClass, changed), NULL, NULL, - caja_marshal_VOID__OBJECT_BOOLEAN, + caja_src_marshal_VOID__OBJECT_BOOLEAN, G_TYPE_NONE, 2, CAJA_TYPE_QUERY, G_TYPE_BOOLEAN); signals[CANCEL] = diff --git a/src/caja-window.c b/src/caja-window.c index 8e9ed5bb..ebe25a57 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -40,6 +40,7 @@ #include "caja-zoom-control.h" #include "caja-search-bar.h" #include "caja-navigation-window-pane.h" +#include "caja-src-marshal.h" #include #include #include @@ -57,7 +58,6 @@ #include #include #include -#include #include #include #include @@ -2117,7 +2117,7 @@ caja_window_class_init (CajaWindowClass *class) G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (CajaWindowClass, go_up), g_signal_accumulator_true_handled, NULL, - eel_marshal_BOOLEAN__BOOLEAN, + caja_src_marshal_BOOLEAN__BOOLEAN, G_TYPE_BOOLEAN, 1, G_TYPE_BOOLEAN); signals[RELOAD] = g_signal_new ("reload", @@ -2141,7 +2141,7 @@ caja_window_class_init (CajaWindowClass *class) G_SIGNAL_RUN_LAST, 0, NULL, NULL, - caja_marshal_VOID__INT_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN, + caja_src_marshal_VOID__INT_BOOLEAN_BOOLEAN_BOOLEAN_BOOLEAN, G_TYPE_NONE, 5, G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN); -- cgit v1.2.1 From acc5445faffbaca14c2b325318e034cd6d8a5d73 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 08:58:31 +0200 Subject: [file-manager] autogenerate marshallers http://git.gnome.org/browse/nautilus/commit/?id=21e75511d2466bd814a31031472323d3cd8ae6c1 --- src/file-manager/Makefile.am | 37 +++++++++++++++++++++++++++++++++++- src/file-manager/fm-directory-view.c | 12 ++++++------ 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/file-manager/Makefile.am b/src/file-manager/Makefile.am index e73afbed..a08d01ad 100644 --- a/src/file-manager/Makefile.am +++ b/src/file-manager/Makefile.am @@ -12,6 +12,11 @@ INCLUDES = \ $(DISABLE_DEPRECATED_CFLAGS) \ $(NULL) +BUILT_SOURCES = \ + fm-marshal.c \ + fm-marshal.h \ + $(NULL) + libcaja_file_manager_la_SOURCES = \ fm-actions.h \ fm-desktop-icon-view.c \ @@ -40,6 +45,28 @@ libcaja_file_manager_la_SOURCES = \ caja-audio-mime-types.h \ $(NULL) +nodist_libcaja_file_manager_la_SOURCES=\ + $(BUILT_SOURCES) \ + $(NULL) + +fm-marshal.list: $(libcaja_file_manager_la_SOURCES) Makefile.am + $(AM_V_GEN)( cd $(srcdir) && \ + sed -n -e 's/.*fm_marshal_\([[:upper:][:digit:]]*__[[:upper:][:digit:]_]*\).*/\1/p' \ + $(libcaja_file_manager_la_SOURCES) ) \ + | sed -e 's/__/:/' -e 'y/_/,/' | sort -u > $@.tmp + @if cmp -s $@.tmp $@; then \ + rm $@.tmp; \ + else \ + mv $@.tmp $@; \ + fi + +%-marshal.c: %-marshal.list Makefile + $(AM_V_GEN)echo "#include \"fm-marshal.h\"" > $@ && \ + $(GLIB_GENMARSHAL) --body --prefix=$(subst -,_,$*)_marshal $< >> $*-marshal.c + +%-marshal.h: %-marshal.list Makefile + $(AM_V_GEN)$(GLIB_GENMARSHAL) --header --prefix=$(subst -,_,$*)_marshal $< > $*-marshal.h + EMPTY_VIEW_SOURCES = \ fm-empty-view.c \ fm-empty-view.h @@ -56,4 +83,12 @@ ui_DATA = \ caja-list-view-ui.xml \ $(NULL) -EXTRA_DIST = $(ui_DATA) +EXTRA_DIST = \ + $(ui_DATA) \ + fm-marshal.list + +CLEANFILES = \ + $(BUILT_SOURCES) \ + fm-marshal.list \ + $(NULL) + diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 55b1e5bb..72a41a31 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -35,6 +35,7 @@ #include "fm-actions.h" #include "fm-error-reporting.h" +#include "fm-marshal.h" #include "fm-properties-window.h" #include "libcaja-private/caja-open-with-dialog.h" @@ -71,7 +72,6 @@ #include /* for caja_file_get_existing_by_uri */ #include #include -#include #include #include #include @@ -10815,7 +10815,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (FMDirectoryViewClass, add_file), NULL, NULL, - caja_marshal_VOID__OBJECT_OBJECT, + fm_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, CAJA_TYPE_FILE, CAJA_TYPE_DIRECTORY); signals[BEGIN_FILE_CHANGES] = g_signal_new ("begin_file_changes", @@ -10871,7 +10871,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (FMDirectoryViewClass, file_changed), NULL, NULL, - caja_marshal_VOID__OBJECT_OBJECT, + fm_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, CAJA_TYPE_FILE, CAJA_TYPE_DIRECTORY); signals[LOAD_ERROR] = g_signal_new ("load_error", @@ -10887,7 +10887,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (FMDirectoryViewClass, remove_file), NULL, NULL, - caja_marshal_VOID__OBJECT_OBJECT, + fm_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, CAJA_TYPE_FILE, CAJA_TYPE_DIRECTORY); klass->accepts_dragged_files = real_accepts_dragged_files; @@ -10944,7 +10944,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (FMDirectoryViewClass, trash), g_signal_accumulator_true_handled, NULL, - eel_marshal_BOOLEAN__VOID, + fm_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); signals[DELETE] = g_signal_new ("delete", @@ -10952,7 +10952,7 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (FMDirectoryViewClass, delete), g_signal_accumulator_true_handled, NULL, - eel_marshal_BOOLEAN__VOID, + fm_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); binding_set = gtk_binding_set_by_class (klass); -- cgit v1.2.1 From 014c77b4c14c17454bfae71d8ba0b68e9911ecf6 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 09:01:45 +0200 Subject: [window] remove dead function caja_window_has_menubar_and_statusbar() http://git.gnome.org/browse/nautilus/commit/?id=eb88f44bd27e11607cb5466c943b9caad0202110 --- src/caja-window.c | 16 ---------------- src/caja-window.h | 1 - 2 files changed, 17 deletions(-) diff --git a/src/caja-window.c b/src/caja-window.c index ebe25a57..55a83e52 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -2179,19 +2179,3 @@ caja_window_class_init (CajaWindowClass *class) g_type_class_add_private (G_OBJECT_CLASS (class), sizeof (CajaWindowDetails)); } - -/** - * caja_window_has_menubar_and_statusbar: - * @window: A #CajaWindow - * - * Queries whether the window should have a menubar and statusbar, based on the - * window_type from its class structure. - * - * Return value: TRUE if the window should have a menubar and statusbar; FALSE - * otherwise. - **/ -gboolean -caja_window_has_menubar_and_statusbar (CajaWindow *window) -{ - return (caja_window_get_window_type (window) != CAJA_WINDOW_DESKTOP); -} diff --git a/src/caja-window.h b/src/caja-window.h index d13129a7..fc4c8999 100644 --- a/src/caja-window.h +++ b/src/caja-window.h @@ -161,6 +161,5 @@ void caja_window_allow_stop (CajaWindow *window, void caja_window_allow_burn_cd (CajaWindow *window, gboolean allow); GtkUIManager * caja_window_get_ui_manager (CajaWindow *window); -gboolean caja_window_has_menubar_and_statusbar (CajaWindow *window); #endif -- cgit v1.2.1 From eebb24f7a768b7dc94705a2d6094ce043d105788 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 09:06:08 +0200 Subject: [desktop-window] cleanups http://git.gnome.org/browse/nautilus/commit/?id=ef13366e667f848adc6b96509612e3321554d188 --- src/caja-desktop-window.c | 64 +++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 36 deletions(-) diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c index 08749cc2..5e477cf5 100644 --- a/src/caja-desktop-window.c +++ b/src/caja-desktop-window.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -39,11 +38,9 @@ struct CajaDesktopWindowDetails { - int dummy; + gulong size_changed_id; }; -static void set_wmspec_desktop_hint (GdkWindow *window); - G_DEFINE_TYPE (CajaDesktopWindow, caja_desktop_window, CAJA_TYPE_SPATIAL_WINDOW); @@ -53,7 +50,8 @@ caja_desktop_window_init (CajaDesktopWindow *window) GtkAction *action; AtkObject *accessible; - window->details = g_new0 (CajaDesktopWindowDetails, 1); + window->details = G_TYPE_INSTANCE_GET_PRIVATE (window, CAJA_TYPE_DESKTOP_WINDOW, + CajaDesktopWindowDetails); gtk_window_move (GTK_WINDOW (window), 0, 0); @@ -76,8 +74,10 @@ caja_desktop_window_init (CajaDesktopWindow *window) /* Set the accessible name so that it doesn't inherit the cryptic desktop URI. */ accessible = gtk_widget_get_accessible (GTK_WIDGET (window)); - if (accessible) + + if (accessible) { atk_object_set_name (accessible, _("Desktop")); + } } static gint @@ -146,18 +146,6 @@ caja_desktop_window_new (CajaApplication *application, return window; } -static void -finalize (GObject *object) -{ - CajaDesktopWindow *window; - - window = CAJA_DESKTOP_WINDOW (object); - - g_free (window->details); - - G_OBJECT_CLASS (caja_desktop_window_parent_class)->finalize (object); -} - static void map (GtkWidget *widget) { @@ -166,14 +154,15 @@ map (GtkWidget *widget) gdk_window_lower (gtk_widget_get_window (widget)); } - static void unrealize (GtkWidget *widget) { CajaDesktopWindow *window; + CajaDesktopWindowDetails *details; GdkWindow *root_window; window = CAJA_DESKTOP_WINDOW (widget); + details = window->details; root_window = gdk_screen_get_root_window ( gtk_window_get_screen (GTK_WINDOW (window))); @@ -181,9 +170,11 @@ unrealize (GtkWidget *widget) gdk_property_delete (root_window, gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", TRUE)); - g_signal_handlers_disconnect_by_func (gtk_window_get_screen (GTK_WINDOW (window)), - G_CALLBACK (caja_desktop_window_screen_size_changed), - window); + if (details->size_changed_id != 0) { + g_signal_handler_disconnect (gtk_window_get_screen (GTK_WINDOW (window)), + details->size_changed_id); + details->size_changed_id = 0; + } GTK_WIDGET_CLASS (caja_desktop_window_parent_class)->unrealize (widget); } @@ -225,8 +216,10 @@ static void realize (GtkWidget *widget) { CajaDesktopWindow *window; + CajaDesktopWindowDetails *details; window = CAJA_DESKTOP_WINDOW (widget); + details = window->details; /* Make sure we get keyboard events */ gtk_widget_set_events (widget, gtk_widget_get_events (widget) @@ -240,8 +233,9 @@ realize (GtkWidget *widget) set_desktop_window_id (window, gtk_widget_get_window (widget)); - g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed", - G_CALLBACK (caja_desktop_window_screen_size_changed), window); + details->size_changed_id = + g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed", + G_CALLBACK (caja_desktop_window_screen_size_changed), window); } static char * @@ -258,20 +252,18 @@ real_get_icon (CajaWindow *window, } static void -caja_desktop_window_class_init (CajaDesktopWindowClass *class) +caja_desktop_window_class_init (CajaDesktopWindowClass *klass) { - G_OBJECT_CLASS (class)->finalize = finalize; - GTK_WIDGET_CLASS (class)->realize = realize; - GTK_WIDGET_CLASS (class)->unrealize = unrealize; - - - GTK_WIDGET_CLASS (class)->map = map; + GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass); + CajaWindowClass *nclass = CAJA_WINDOW_CLASS (klass); - CAJA_WINDOW_CLASS (class)->window_type = CAJA_WINDOW_DESKTOP; + wclass->realize = realize; + wclass->unrealize = unrealize; + wclass->map = map; - CAJA_WINDOW_CLASS (class)->get_title - = real_get_title; - CAJA_WINDOW_CLASS (class)->get_icon - = real_get_icon; + nclass->window_type = CAJA_WINDOW_DESKTOP; + nclass->get_title = real_get_title; + nclass->get_icon = real_get_icon; + g_type_class_add_private (klass, sizeof (CajaDesktopWindowDetails)); } -- cgit v1.2.1 From f45deb706fa21131ae7fc1948be8ca735733e819 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 09:10:32 +0200 Subject: [window] remove dead prototypes http://git.gnome.org/browse/nautilus/commit/?id=5973bc50618d1fe69247e3e2ec6eb8cf3213000b --- src/caja-window-private.h | 3 --- src/caja-window.h | 4 ---- 2 files changed, 7 deletions(-) diff --git a/src/caja-window-private.h b/src/caja-window-private.h index 83a6da0f..ae4a723f 100644 --- a/src/caja-window-private.h +++ b/src/caja-window-private.h @@ -178,9 +178,6 @@ void caja_menus_append_bookmark_to_menu (CajaWindow guint merge_id, GCallback refresh_callback, CajaBookmarkFailedCallback failed_callback); -#ifdef NEW_UI_COMPLETE -void caja_window_go_up (CajaWindow *window); -#endif void caja_window_update_find_menu_item (CajaWindow *window); void caja_window_zoom_in (CajaWindow *window); void caja_window_zoom_out (CajaWindow *window); diff --git a/src/caja-window.h b/src/caja-window.h index fc4c8999..86b85b4f 100644 --- a/src/caja-window.h +++ b/src/caja-window.h @@ -122,7 +122,6 @@ struct CajaWindow CajaWindowDetails *details; - /** CORBA-related elements **/ CajaApplication *application; }; @@ -147,7 +146,6 @@ void caja_window_go_up (CajaWindow *window, gboolean new_tab); void caja_window_prompt_for_location (CajaWindow *window, const char *initial); -void caja_window_launch_cd_burner (CajaWindow *window); void caja_window_display_error (CajaWindow *window, const char *error_msg); void caja_window_reload (CajaWindow *window); @@ -158,8 +156,6 @@ void caja_window_allow_up (CajaWindow *window, gboolean allow); void caja_window_allow_stop (CajaWindow *window, gboolean allow); -void caja_window_allow_burn_cd (CajaWindow *window, - gboolean allow); GtkUIManager * caja_window_get_ui_manager (CajaWindow *window); #endif -- cgit v1.2.1 From 5d8273c1bc7e355e4f032bdc9d40363e01c689b6 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 09:42:40 +0200 Subject: [spatial-window] cleanups - Don't do anything other than checking/scheduling a source in the configure-event callback - Avoid useless roundtrips through GFile - Avoid some casts, so we don't do useless type-checking in a row on the same object http://git.gnome.org/browse/nautilus/commit/?id=93798c75a1ae3cbd3a85a4ce79b5521b562a7074 --- src/caja-spatial-window.c | 290 ++++++++++++++++++---------------------------- 1 file changed, 114 insertions(+), 176 deletions(-) diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index c5a1bac4..24a7b647 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -95,7 +95,8 @@ static const GtkTargetEntry location_button_drag_types[] = G_DEFINE_TYPE(CajaSpatialWindow, caja_spatial_window, CAJA_TYPE_WINDOW) #define parent_class caja_spatial_window_parent_class -static void caja_spatial_window_save_geometry (CajaWindowSlot *slot); +static void caja_spatial_window_save_geometry (CajaSpatialWindow *window, + CajaFile *viewed_file); static gboolean save_window_geometry_timeout (gpointer callback_data) @@ -108,7 +109,7 @@ save_window_geometry_timeout (gpointer callback_data) if (slot != NULL) { - caja_spatial_window_save_geometry (slot); + caja_spatial_window_save_geometry (window, slot->viewed_file); } window->details->save_geometry_timeout_id = 0; @@ -121,7 +122,6 @@ caja_spatial_window_configure_event (GtkWidget *widget, GdkEventConfigure *event) { CajaSpatialWindow *window; - char *geometry_string; window = CAJA_SPATIAL_WINDOW (widget); @@ -134,34 +134,9 @@ caja_spatial_window_configure_event (GtkWidget *widget, { g_source_remove (window->details->save_geometry_timeout_id); } - if (gtk_widget_get_visible (GTK_WIDGET (window)) && !CAJA_IS_DESKTOP_WINDOW (window)) - { - geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); - - /* If the last geometry is NULL the window must have just - * been shown. No need to save geometry to disk since it - * must be the same. - */ - if (window->details->last_geometry == NULL) - { - window->details->last_geometry = geometry_string; - return FALSE; - } - /* Don't save geometry if it's the same as before. */ - if (!strcmp (window->details->last_geometry, - geometry_string)) - { - g_free (geometry_string); - return FALSE; - } - - g_free (window->details->last_geometry); - window->details->last_geometry = geometry_string; - - window->details->save_geometry_timeout_id = - g_timeout_add_seconds (1, save_window_geometry_timeout, window); - } + window->details->save_geometry_timeout_id = + g_timeout_add_seconds (1, save_window_geometry_timeout, window); return FALSE; } @@ -184,7 +159,7 @@ caja_spatial_window_unrealize (GtkWidget *widget) if (slot != NULL) { - caja_spatial_window_save_geometry (slot); + caja_spatial_window_save_geometry (window, slot->viewed_file); } } } @@ -241,18 +216,6 @@ caja_spatial_window_state_event (GtkWidget *widget, return FALSE; } -static void -caja_spatial_window_destroy (GtkObject *object) -{ - CajaSpatialWindow *window; - - window = CAJA_SPATIAL_WINDOW (object); - - window->details->content_box = NULL; - - GTK_OBJECT_CLASS (caja_spatial_window_parent_class)->destroy (object); -} - static void caja_spatial_window_finalize (GObject *object) { @@ -260,25 +223,17 @@ caja_spatial_window_finalize (GObject *object) window = CAJA_SPATIAL_WINDOW (object); - if (window->details->last_geometry != NULL) - { - g_free (window->details->last_geometry); - } + g_free (window->details->last_geometry); G_OBJECT_CLASS (caja_spatial_window_parent_class)->finalize (object); } static void -caja_spatial_window_save_geometry (CajaWindowSlot *slot) +caja_spatial_window_save_geometry (CajaSpatialWindow *window, + CajaFile *viewed_file) { - CajaWindow *window; - CajaFile *viewed_file; char *geometry_string; - window = CAJA_WINDOW (slot->pane->window); - - viewed_file = slot->viewed_file; - if (viewed_file == NULL) { /* We never showed a file */ @@ -286,27 +241,34 @@ caja_spatial_window_save_geometry (CajaWindowSlot *slot) } if (gtk_widget_get_window (GTK_WIDGET (window)) && - !(gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET(window))) & GDK_WINDOW_STATE_MAXIMIZED)) - { + gtk_widget_get_visible (GTK_WIDGET (window)) && + !CAJA_IS_DESKTOP_WINDOW (window) && + !(gdk_window_get_state (gtk_widget_get_window (GTK_WIDGET(window))) & GDK_WINDOW_STATE_MAXIMIZED)) { + geometry_string = eel_gtk_window_get_geometry_string (GTK_WINDOW (window)); + if (!g_strcmp0 (window->details->last_geometry, geometry_string)) { + /* Don't save geometry if it's the same as before. */ + g_free (geometry_string); + return; + } + + g_free (window->details->last_geometry); + window->details->last_geometry = geometry_string; + caja_file_set_metadata (viewed_file, CAJA_METADATA_KEY_WINDOW_GEOMETRY, NULL, geometry_string); - - g_free (geometry_string); } } static void -caja_spatial_window_save_scroll_position (CajaWindowSlot *slot) +caja_spatial_window_save_scroll_position (CajaSpatialWindow *window, + CajaWindowSlot *slot) { - CajaWindow *window; char *scroll_string; - window = CAJA_WINDOW (slot->pane->window); - if (slot->content_view == NULL || slot->viewed_file == NULL) { @@ -322,31 +284,25 @@ caja_spatial_window_save_scroll_position (CajaWindowSlot *slot) } static void -caja_spatial_window_save_show_hidden_files_mode (CajaWindowSlot *slot) +caja_spatial_window_save_show_hidden_files_mode (CajaSpatialWindow *window, + CajaFile *viewed_file) { - CajaWindow *window; char *show_hidden_file_setting; CajaWindowShowHiddenFilesMode mode; - if (slot->viewed_file == NULL) - { + if (viewed_file == NULL) { return; } - window = CAJA_WINDOW (slot->pane->window); - mode = CAJA_WINDOW (window)->details->show_hidden_files_mode; - if (mode != CAJA_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) - { - if (mode == CAJA_WINDOW_SHOW_HIDDEN_FILES_ENABLE) - { + + if (mode != CAJA_WINDOW_SHOW_HIDDEN_FILES_DEFAULT) { + if (mode == CAJA_WINDOW_SHOW_HIDDEN_FILES_ENABLE) { show_hidden_file_setting = "1"; - } - else - { + } else { show_hidden_file_setting = "0"; } - caja_file_set_metadata (slot->viewed_file, + caja_file_set_metadata (viewed_file, CAJA_METADATA_KEY_WINDOW_SHOW_HIDDEN_FILES, NULL, show_hidden_file_setting); @@ -510,48 +466,53 @@ real_open_slot (CajaWindowPane *pane, } static void -save_spatial_data (CajaWindowSlot *slot) +save_spatial_data (CajaSpatialWindow *window, + CajaWindowSlot *slot) { - caja_spatial_window_save_geometry (slot); - caja_spatial_window_save_scroll_position (slot); - caja_spatial_window_save_show_hidden_files_mode (slot); + caja_spatial_window_save_geometry (window, slot->viewed_file); + caja_spatial_window_save_scroll_position (window, slot); + caja_spatial_window_save_show_hidden_files_mode (window, slot->viewed_file); } static void real_close_slot (CajaWindowPane *pane, CajaWindowSlot *slot) { + CajaSpatialWindow *window; + + window = CAJA_SPATIAL_WINDOW (pane->window); + /* Save spatial data for close if we didn't already */ - if (!CAJA_SPATIAL_WINDOW (pane->window)->details->saved_data_on_close) - { - save_spatial_data (slot); + if (!window->details->saved_data_on_close) { + save_spatial_data (window, slot); } - EEL_CALL_PARENT (CAJA_WINDOW_CLASS, - close_slot, (pane, slot)); + CAJA_WINDOW_CLASS (caja_spatial_window_parent_class)->close_slot (pane, slot); } static void real_window_close (CajaWindow *window) { CajaWindowSlot *slot; + CajaSpatialWindow *self; + + self = CAJA_SPATIAL_WINDOW (window); /* We're closing the window, save the geometry. */ /* Note that we do this in window close, not slot close, because slot * close is too late, by then the widgets have been unrealized. * This is for the close by WM case, if you're closing via Ctrl-W that * means we close the slots first and this is not an issue */ - if (window->details->active_pane != NULL && - window->details->active_pane->active_slot != NULL) - { - slot = window->details->active_pane->active_slot; + slot = caja_window_get_active_slot (window); - save_spatial_data (slot); - CAJA_SPATIAL_WINDOW (window)->details->saved_data_on_close = TRUE; + if (slot != NULL) { + save_spatial_data (self, slot); + self->details->saved_data_on_close = TRUE; } - EEL_CALL_PARENT (CAJA_WINDOW_CLASS, - close, (window)); + if (CAJA_WINDOW_CLASS (caja_spatial_window_parent_class)->close != NULL) { + CAJA_WINDOW_CLASS (caja_spatial_window_parent_class)->close (window); + } } static void @@ -559,18 +520,13 @@ location_menu_item_activated_callback (GtkWidget *menu_item, CajaWindow *window) { CajaWindowSlot *slot; - char *location; GFile *current; GFile *dest; GdkEvent *event; - slot = window->details->active_pane->active_slot; - - location = caja_window_slot_get_location_uri (slot); - current = g_file_new_for_uri (location); - g_free (location); - - dest = g_object_get_data (G_OBJECT (menu_item), "uri"); + slot = caja_window_get_active_slot (window); + current = caja_window_slot_get_location (slot); + dest = g_object_get_data (G_OBJECT (menu_item), "location"); event = gtk_get_current_event(); @@ -583,16 +539,14 @@ location_menu_item_activated_callback (GtkWidget *menu_item, close_behind = FALSE; selection = NULL; - child = g_object_get_data (G_OBJECT(menu_item), "child_uri"); - if (child != NULL) - { + child = g_object_get_data (G_OBJECT(menu_item), "child_location"); + if (child != NULL) { selection = g_list_prepend (NULL, g_object_ref (child)); } if (event != NULL && ((GdkEventAny *) event)->type == GDK_BUTTON_RELEASE && (((GdkEventButton *) event)->button == 2 || - (((GdkEventButton *) event)->state & GDK_SHIFT_MASK) != 0)) - { + (((GdkEventButton *) event)->state & GDK_SHIFT_MASK) != 0)) { close_behind = TRUE; } @@ -602,8 +556,7 @@ location_menu_item_activated_callback (GtkWidget *menu_item, eel_g_object_list_free (selection); } - if (event != NULL) - { + if (event != NULL) { gdk_event_free (event); } @@ -697,9 +650,11 @@ location_button_pressed_callback (GtkWidget *widget, GdkEventButton *event, CajaWindow *window) { + CajaWindowSlot *slot; CajaView *view; - view = window->details->active_pane->active_slot->content_view; + slot = caja_window_get_active_slot (window); + view = slot->content_view; if (event->button == 3 && view != NULL) { @@ -715,37 +670,31 @@ location_button_clicked_callback (GtkWidget *widget, { CajaWindowSlot *slot; GtkWidget *popup, *menu_item, *first_item = NULL; - char *location; - GFile *uri; - GFile *child_uri; + GFile *location; + GFile *child_location; GMainLoop *loop; - slot = CAJA_WINDOW (window)->details->active_pane->active_slot; + slot = caja_window_get_active_slot (CAJA_WINDOW (window)); popup = gtk_menu_new (); first_item = NULL; - location = caja_window_slot_get_location_uri (slot); + location = caja_window_slot_get_location (slot); g_return_if_fail (location != NULL); - uri = g_file_new_for_uri (location); - g_free (location); - - child_uri = NULL; - while (uri != NULL) - { + child_location = NULL; + while (location != NULL) { CajaFile *file; char *name; - file = caja_file_get (uri); + file = caja_file_get (location); name = caja_file_get_display_name (file); menu_item = gtk_image_menu_item_new_with_label (name); gtk_image_menu_item_set_always_show_image (GTK_IMAGE_MENU_ITEM (menu_item), TRUE); g_free (name); - if (first_item == NULL) - { + if (first_item == NULL) { first_item = menu_item; } @@ -761,35 +710,31 @@ location_button_clicked_callback (GtkWidget *widget, window); g_object_set_data_full (G_OBJECT (menu_item), - "uri", - g_object_ref (uri), + "location", + g_object_ref (location), (GDestroyNotify)g_object_unref); - if (child_uri) - { + if (child_location) { g_object_set_data_full (G_OBJECT (menu_item), - "child_uri", - g_object_ref (child_uri), + "child_location", + g_object_ref (child_location), (GDestroyNotify)g_object_unref); } gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), menu_item); - if (child_uri) - { - g_object_unref (child_uri); + if (child_location) { + g_object_unref (child_location); } - child_uri = uri; - uri = g_file_get_parent (uri); + child_location = location; + location = g_file_get_parent (location); } - if (child_uri) - { - g_object_unref (child_uri); + if (child_location) { + g_object_unref (child_location); } - if (uri) - { - g_object_unref (uri); + if (location) { + g_object_unref (location); } gtk_menu_set_screen (GTK_MENU (popup), gtk_widget_get_screen (widget)); @@ -813,12 +758,12 @@ location_button_clicked_callback (GtkWidget *widget, static int get_dnd_icon_size (CajaSpatialWindow *window) { - CajaWindow *parent; + CajaWindowSlot *active_slot; CajaView *view; CajaZoomLevel zoom_level; - parent = CAJA_WINDOW(window); - view = parent->details->active_pane->active_slot->content_view; + active_slot = caja_window_get_active_slot (CAJA_WINDOW (window)); + view = active_slot->content_view; if (view == NULL) { @@ -829,7 +774,6 @@ get_dnd_icon_size (CajaSpatialWindow *window) zoom_level = caja_view_get_zoom_level (view); return caja_get_icon_size_for_zoom_level (zoom_level); } - } static void @@ -1164,39 +1108,33 @@ caja_spatial_window_init (CajaSpatialWindow *window) } static void -caja_spatial_window_class_init (CajaSpatialWindowClass *class) +caja_spatial_window_class_init (CajaSpatialWindowClass *klass) { GtkBindingSet *binding_set; - - CAJA_WINDOW_CLASS (class)->window_type = CAJA_WINDOW_SPATIAL; - CAJA_WINDOW_CLASS (class)->bookmarks_placeholder = MENU_PATH_SPATIAL_BOOKMARKS_PLACEHOLDER; - - G_OBJECT_CLASS (class)->finalize = caja_spatial_window_finalize; - GTK_OBJECT_CLASS (class)->destroy = caja_spatial_window_destroy; - GTK_WIDGET_CLASS (class)->show = caja_spatial_window_show; - GTK_WIDGET_CLASS (class)->configure_event = caja_spatial_window_configure_event; - GTK_WIDGET_CLASS (class)->unrealize = caja_spatial_window_unrealize; - GTK_WIDGET_CLASS (class)->window_state_event = caja_spatial_window_state_event; - - CAJA_WINDOW_CLASS (class)->prompt_for_location = - real_prompt_for_location; - CAJA_WINDOW_CLASS (class)->get_icon = - real_get_icon; - CAJA_WINDOW_CLASS (class)->sync_title = - real_sync_title; - CAJA_WINDOW_CLASS(class)->get_min_size = real_get_min_size; - CAJA_WINDOW_CLASS(class)->get_default_size = real_get_default_size; - - CAJA_WINDOW_CLASS(class)->sync_allow_stop = - real_sync_allow_stop; - CAJA_WINDOW_CLASS(class)->set_allow_up = - real_set_allow_up; - - CAJA_WINDOW_CLASS (class)->open_slot = real_open_slot; - CAJA_WINDOW_CLASS (class)->close = real_window_close; - CAJA_WINDOW_CLASS (class)->close_slot = real_close_slot; - - binding_set = gtk_binding_set_by_class (class); + CajaWindowClass *nclass = CAJA_WINDOW_CLASS (klass); + GtkWidgetClass *wclass = GTK_WIDGET_CLASS (klass); + + nclass->window_type = CAJA_WINDOW_SPATIAL; + nclass->bookmarks_placeholder = MENU_PATH_SPATIAL_BOOKMARKS_PLACEHOLDER; + nclass->prompt_for_location = real_prompt_for_location; + nclass->get_icon = real_get_icon; + nclass->sync_title = real_sync_title; + nclass->get_min_size = real_get_min_size; + nclass->get_default_size = real_get_default_size; + nclass->sync_allow_stop = real_sync_allow_stop; + nclass->set_allow_up = real_set_allow_up; + nclass->open_slot = real_open_slot; + nclass->close = real_window_close; + nclass->close_slot = real_close_slot; + + wclass->show = caja_spatial_window_show; + wclass->configure_event = caja_spatial_window_configure_event; + wclass->unrealize = caja_spatial_window_unrealize; + wclass->window_state_event = caja_spatial_window_state_event; + + G_OBJECT_CLASS (klass)->finalize = caja_spatial_window_finalize; + + binding_set = gtk_binding_set_by_class (klass); gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK, "go_up", 1, G_TYPE_BOOLEAN, TRUE); @@ -1204,5 +1142,5 @@ caja_spatial_window_class_init (CajaSpatialWindowClass *class) "go_up", 1, G_TYPE_BOOLEAN, TRUE); - g_type_class_add_private (G_OBJECT_CLASS (class), sizeof(CajaSpatialWindowDetails)); + g_type_class_add_private (klass, sizeof(CajaSpatialWindowDetails)); } -- cgit v1.2.1 From a8ffe6f91bb6d67410fe886ef90deef1d5639aa9 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 09:45:11 +0200 Subject: [bkmrks-win/prop-brwsr] don't use eel_gtk_window_*_close_accelerator() bk-window: don't use _event_is_close_accelerator() http://git.gnome.org/browse/nautilus/commit/?id=cab696f7d760f5ee63f0a623b13d27b76d2f2d00 Also needed to drop eel_gtk_window_set_up_close_accelerator() instance in src/caja-property-browser.c --- src/caja-bookmarks-window.c | 3 +-- src/caja-property-browser.c | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c index 49f66850..aaf0aee1 100644 --- a/src/caja-bookmarks-window.c +++ b/src/caja-bookmarks-window.c @@ -1082,8 +1082,7 @@ handle_close_accelerator (GtkWindow *window, g_assert (event != NULL); g_assert (user_data == NULL); - if (eel_gtk_window_event_is_close_accelerator (window, event)) - { + if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_w) { gtk_widget_hide (GTK_WIDGET (window)); return TRUE; } diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c index 92de4738..8c8cea9d 100644 --- a/src/caja-property-browser.c +++ b/src/caja-property-browser.c @@ -256,7 +256,6 @@ caja_property_browser_init (GtkObject *object) gtk_window_set_title (GTK_WINDOW (widget), _("Backgrounds and Emblems")); gtk_window_set_wmclass (GTK_WINDOW (widget), "property_browser", "Caja"); gtk_window_set_type_hint (GTK_WINDOW (widget), GDK_WINDOW_TYPE_HINT_DIALOG); - eel_gtk_window_set_up_close_accelerator (GTK_WINDOW (widget)); /* create the main vbox. */ vbox = gtk_vbox_new (FALSE, 12); -- cgit v1.2.1 From 5b952b5d19dc17b42845c78cd4b3d5f1b3243756 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 10:10:59 +0200 Subject: [eel] remove functions to handle accelerators These are unused now http://git.gnome.org/browse/nautilus/commit/?id=472f3e1433ecb3d5e1a7fc8707975f45dd8d0469 --- eel/eel-gtk-extensions.c | 97 ------------------------------------------------ eel/eel-gtk-extensions.h | 3 -- 2 files changed, 100 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 7c75ef51..1453d5ef 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -82,103 +82,6 @@ eel_gtk_window_get_geometry_string (GtkWindow *window) return str; } -static void -send_delete_event (GtkWindow *window) -{ - /* Synthesize delete_event to close window. */ - - GdkEvent event; - GtkWidget *widget; - - widget = GTK_WIDGET (window); - - event.any.type = GDK_DELETE; - event.any.window = gtk_widget_get_window (widget); - event.any.send_event = TRUE; - - g_object_ref (event.any.window); - gtk_main_do_event (&event); - g_object_unref (event.any.window); -} - -static int -handle_standard_close_accelerator (GtkWindow *window, - GdkEventKey *event, - gpointer user_data) -{ - g_assert (GTK_IS_WINDOW (window)); - g_assert (event != NULL); - g_assert (user_data == NULL); - - if (eel_gtk_window_event_is_close_accelerator (window, event)) - { - send_delete_event (window); - g_signal_stop_emission_by_name ( - G_OBJECT (window), "key_press_event"); - return TRUE; - } - - return FALSE; -} - -/** - * eel_gtk_window_event_is_close_accelerator: - * - * Tests whether a key event is a standard window close accelerator. - * Not needed for clients that use eel_gtk_window_set_up_close_accelerator; - * use only if you must set up your own key_event handler for your own reasons. - **/ -gboolean -eel_gtk_window_event_is_close_accelerator (GtkWindow *window, GdkEventKey *event) -{ - g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE); - g_return_val_if_fail (event != NULL, FALSE); - - if (event->state & GDK_CONTROL_MASK) - { - /* Note: menu item equivalents are case-sensitive, so we will - * be case-sensitive here too. - */ - if (event->keyval == EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY) - { - return TRUE; - } - } - - - return FALSE; -} - -/** - * eel_gtk_window_set_up_close_accelerator: - * - * Sets up the standard keyboard equivalent to close the window. - * Call this for windows that don't set up a keyboard equivalent to - * close the window some other way, e.g. via a menu item accelerator. - * - * NOTE: do not use for GtkDialog, it already sets up the right - * stuff here. - * - * @window: The GtkWindow that should be hidden when the standard - * keyboard equivalent is typed. - **/ -void -eel_gtk_window_set_up_close_accelerator (GtkWindow *window) -{ - g_return_if_fail (GTK_IS_WINDOW (window)); - - if (GTK_IS_DIALOG (window)) - { - g_warning ("eel_gtk_window_set_up_close_accelerator: Should not mess with close accelerator on GtkDialogs"); - return; - } - - g_signal_connect (window, - "key_press_event", - G_CALLBACK (handle_standard_close_accelerator), - NULL); -} - static void sanity_check_window_position (int *left, int *top) { diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index 1da3e8f4..abc1db90 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -71,9 +71,6 @@ void eel_gtk_window_set_initial_geometry_from_string (GtkWindow guint minimum_width, guint minimum_height, gboolean ignore_position); -void eel_gtk_window_set_up_close_accelerator (GtkWindow *window); -gboolean eel_gtk_window_event_is_close_accelerator (GtkWindow *window, - GdkEventKey *event); char * eel_gtk_window_get_geometry_string (GtkWindow *window); -- cgit v1.2.1 From 654e3c45484f0f082e5ba3ef097219476205caa4 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 03:13:26 +0200 Subject: [eel] remove functions to set widget backgrounds Now that we've removed eel_gtk_widget_set_background_color calls in eel-debug-drawing.c and test-eel-image-table.c, both it and _set_foreground_color are unused. Original commit: http://git.gnome.org/browse/nautilus/commit/?id=57b66862a53298468755e12ca3712569274f0a32 --- eel/eel-debug-drawing.c | 2 -- eel/eel-gtk-extensions.c | 32 -------------------------------- eel/eel-gtk-extensions.h | 4 ---- test/test-eel-image-table.c | 16 +++++++--------- 4 files changed, 7 insertions(+), 47 deletions(-) diff --git a/eel/eel-debug-drawing.c b/eel/eel-debug-drawing.c index 6c98748a..61a3aeb6 100644 --- a/eel/eel-debug-drawing.c +++ b/eel/eel-debug-drawing.c @@ -362,8 +362,6 @@ eel_debug_show_pixbuf (GdkPixbuf *pixbuf) gtk_box_pack_start (GTK_BOX (vbox), debug_image, TRUE, TRUE, 0); - eel_gtk_widget_set_background_color (debug_window, "white"); - eel_debug_call_at_shutdown (destroy_debug_window); gtk_widget_show (debug_image); diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index 1453d5ef..f7ffdc90 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -508,38 +508,6 @@ eel_gtk_label_make_bold (GtkLabel *label) pango_font_description_free (font_desc); } -void -eel_gtk_widget_set_background_color (GtkWidget *widget, - const char *color_spec) -{ - GdkColor color; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - - eel_gdk_color_parse_with_white_default (color_spec, &color); - - gtk_widget_modify_bg (widget, GTK_STATE_NORMAL, &color); - gtk_widget_modify_base (widget, GTK_STATE_NORMAL, &color); - gtk_widget_modify_bg (widget, GTK_STATE_ACTIVE, &color); - gtk_widget_modify_base (widget, GTK_STATE_ACTIVE, &color); -} - -void -eel_gtk_widget_set_foreground_color (GtkWidget *widget, - const char *color_spec) -{ - GdkColor color; - - g_return_if_fail (GTK_IS_WIDGET (widget)); - - eel_gdk_color_parse_with_white_default (color_spec, &color); - - gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color); - gtk_widget_modify_text (widget, GTK_STATE_NORMAL, &color); - gtk_widget_modify_fg (widget, GTK_STATE_ACTIVE, &color); - gtk_widget_modify_text (widget, GTK_STATE_ACTIVE, &color); -} - static gboolean tree_view_button_press_callback (GtkWidget *tree_view, GdkEventButton *event, diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index abc1db90..2ac8ae13 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -54,10 +54,6 @@ void eel_gtk_signal_connect_while_realized (GtkObject /* GtkWidget */ void eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown); -void eel_gtk_widget_set_background_color (GtkWidget *widget, - const char *color_spec); -void eel_gtk_widget_set_foreground_color (GtkWidget *widget, - const char *color_spec); /* GtkWindow */ void eel_gtk_window_set_initial_geometry (GtkWindow *window, diff --git a/test/test-eel-image-table.c b/test/test-eel-image-table.c index d60aa91b..9677537a 100644 --- a/test/test-eel-image-table.c +++ b/test/test-eel-image-table.c @@ -63,7 +63,7 @@ labeled_image_new (const char *text, { GtkWidget *image; GdkPixbuf *pixbuf = NULL; - + if (icon_name) { float sizes[] = { 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, 2.0 }; @@ -194,7 +194,7 @@ image_table_size_allocate (GtkWidget *image_table, gtk_widget_get_allocation (GTK_WIDGET (image_table), &w_allocation); if (0) gtk_widget_size_allocate (GTK_WIDGET (image_table), &w_allocation); - + g_print ("%s(%d)\n", G_STRFUNC, recursion_count); recursion_count--; @@ -264,8 +264,6 @@ image_table_new_scrolled (void) G_CALLBACK (image_table_child_clicked_callback), NULL); - eel_gtk_widget_set_background_color (viewport, BG_COLOR_SPEC); - for (i = 0; i < 100; i++) { char *text; GtkWidget *image; @@ -283,11 +281,11 @@ image_table_new_scrolled (void) gtk_widget_show (viewport); gtk_widget_show (scrolled); gtk_widget_show (image_table); - + return window; } -int +int main (int argc, char* argv[]) { GtkWidget *window = NULL; @@ -295,10 +293,10 @@ main (int argc, char* argv[]) test_init (&argc, &argv); window = image_table_new_scrolled (); - + gtk_widget_show (window); - + gtk_main (); - + return 0; } -- cgit v1.2.1 From e6b8ac93464b85b77b9a3cbcc932ab60a5a2b75c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 03:16:44 +0200 Subject: [eel-gtk-extensions] remove eel_gtk_signal* utilities They're now unused. http://git.gnome.org/browse/nautilus/commit/?id=394cb741c3e59df66f924771d4ef68866e602faa --- eel/eel-gtk-extensions.c | 76 ------------------------------------------------ eel/eel-gtk-extensions.h | 16 ---------- 2 files changed, 92 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index f7ffdc90..c880ec32 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -374,82 +374,6 @@ eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown) } } -/* This stuff is stolen from Gtk. */ - -typedef struct DisconnectInfo -{ - GtkObject *object1; - guint disconnect_handler1; - guint signal_handler; - GtkObject *object2; - guint disconnect_handler2; -} DisconnectInfo; - -static void -alive_disconnecter (GtkObject *object, DisconnectInfo *info) -{ - g_assert (info != NULL); - g_assert (GTK_IS_OBJECT (info->object1)); - g_assert (info->disconnect_handler1 != 0); - g_assert (info->signal_handler != 0); - g_assert (GTK_IS_OBJECT (info->object2)); - g_assert (info->disconnect_handler2 != 0); - g_assert (object == info->object1 || object == info->object2); - - g_signal_handler_disconnect (info->object1, info->disconnect_handler1); - g_signal_handler_disconnect (info->object1, info->signal_handler); - g_signal_handler_disconnect (info->object2, info->disconnect_handler2); - - g_free (info); -} - -/** - * eel_gtk_signal_connect_full_while_alive - * - * Like gtk_signal_connect_while_alive, but works with full parameters. - **/ -void -eel_gtk_signal_connect_full_while_alive (GtkObject *object, - const gchar *name, - GCallback func, - GtkCallbackMarshal marshal, - gpointer data, - GDestroyNotify destroy_func, - gboolean object_signal, - gboolean after, - GtkObject *alive_object) -{ - DisconnectInfo *info; - - g_return_if_fail (GTK_IS_OBJECT (object)); - g_return_if_fail (name != NULL); - g_return_if_fail (func != NULL || marshal != NULL); - g_return_if_fail (object_signal == FALSE || object_signal == TRUE); - g_return_if_fail (after == FALSE || after == TRUE); - g_return_if_fail (GTK_IS_OBJECT (alive_object)); - - info = g_new (DisconnectInfo, 1); - info->object1 = object; - info->object2 = alive_object; - - - info->signal_handler = g_signal_connect_closure ( - object, name, - (object_signal - ? g_cclosure_new_swap - : g_cclosure_new) (func, data, (GClosureNotify) destroy_func), - after); - - info->disconnect_handler1 = g_signal_connect (G_OBJECT (object), - "destroy", - G_CALLBACK (alive_disconnecter), - info); - info->disconnect_handler2 = g_signal_connect (G_OBJECT (alive_object), - "destroy", - G_CALLBACK (alive_disconnecter), - info); -} - /* The standard gtk_adjustment_set_value ignores page size, which * disagrees with the logic used by scroll bars, for example. */ diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index 2ac8ae13..8703d4b5 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -35,22 +35,6 @@ #define EEL_DEFAULT_POPUP_MENU_DISPLACEMENT 2 #define EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY 'w' -/* signals */ -void eel_gtk_signal_connect_full_while_alive (GtkObject *object, - const gchar *name, - GCallback func, - GtkCallbackMarshal marshal, - gpointer data, - GDestroyNotify destroy_func, - gboolean object_signal, - gboolean after, - GtkObject *alive_object); -void eel_gtk_signal_connect_while_realized (GtkObject *object, - const char *name, - GCallback callback, - gpointer callback_data, - GtkWidget *realized_widget); - /* GtkWidget */ void eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown); -- cgit v1.2.1 From cebbe2c78c33b41e164d8e5318d7a51d8cd8839b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 10:35:57 +0200 Subject: [eel] add a utility to pack details into a message dialog So that we can remove EelAlertDialog. http://git.gnome.org/browse/nautilus/commit/?id=a2b4de80a94b4e049f1d2a7ef00a174865b5c9ec --- eel/eel-gtk-extensions.c | 27 +++++++++++++++++++++++++-- eel/eel-gtk-extensions.h | 4 ++++ 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index c880ec32..da8e7d7c 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -32,16 +32,17 @@ #include "eel-gdk-pixbuf-extensions.h" #include "eel-glib-extensions.h" #include "eel-mate-extensions.h" +#include "eel-marshal.h" #include "eel-string.h" + #include #include #include #include #include #include +#include #include -#include "eel-marshal.h" -#include "eel-marshal.c" /* This number is fairly arbitrary. Long enough to show a pretty long * menu title, but not so long to make a menu grotesquely wide. @@ -486,3 +487,25 @@ eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view, GUINT_TO_POINTER (button_press_id)); } } + +void +eel_gtk_message_dialog_set_details_label (GtkMessageDialog *dialog, + const gchar *details_text) +{ + GtkWidget *content_area, *expander, *label; + + content_area = gtk_message_dialog_get_message_area (dialog); + expander = gtk_expander_new_with_mnemonic (_("Show more _details")); + gtk_expander_set_spacing (GTK_EXPANDER (expander), 6); + + label = gtk_label_new (details_text); + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_label_set_selectable (GTK_LABEL (label), TRUE); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + + gtk_container_add (GTK_CONTAINER (expander), label); + gtk_box_pack_start (GTK_BOX (content_area), expander, FALSE, FALSE, 0); + + gtk_widget_show (label); + gtk_widget_show (expander); +} diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index 8703d4b5..e26c2e2f 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -77,4 +77,8 @@ void eel_gtk_adjustment_clamp_value (GtkAdjust void eel_gtk_tree_view_set_activate_on_single_click (GtkTreeView *tree_view, gboolean should_activate); +/* GtkMessageDialog */ +void eel_gtk_message_dialog_set_details_label (GtkMessageDialog *dialog, + const gchar *details_text); + #endif /* EEL_GTK_EXTENSIONS_H */ -- cgit v1.2.1 From a71f882835029bbcbd2f46f54f18407606a558a3 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 10:49:31 +0200 Subject: [all] use GtkMessageDialog instead of EelAlertDialog (going away) This covers 4 commits: file-operations: use GtkMessageDialog http://git.gnome.org/browse/nautilus/commit/?id=51ec5861ca0697e802e8c003053211ac12f2fd54 mime-actions: use GtkMessageDialog http://git.gnome.org/browse/nautilus/commit/?id=7a3dcdd4bf667aac271be74988770e18575a7df2 tree-view: don't include eel-alert-dialog.h http://git.gnome.org/browse/nautilus/commit/?id=930af7f3058eed256a42c0c1558c7307bb93f411 [eel] use GtkMessageDialog for stock dialogs http://git.gnome.org/browse/nautilus/commit/?id=82c5b6c0d82ebd8a705d542fcc9aa58e6e9b0da4 --- eel/eel-stock-dialogs.c | 62 ++++++++++++++++++++-------------- libcaja-private/caja-file-operations.c | 23 +++++++------ libcaja-private/caja-mime-actions.c | 53 ++++++++++++++++------------- src/file-manager/fm-tree-view.c | 1 - 4 files changed, 79 insertions(+), 60 deletions(-) diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c index eb675733..6cf48f02 100644 --- a/eel/eel-stock-dialogs.c +++ b/eel/eel-stock-dialogs.c @@ -25,10 +25,9 @@ #include #include "eel-stock-dialogs.h" -#include "eel-alert-dialog.h" #include "eel-glib-extensions.h" -#include "eel-mate-extensions.h" -#include "eel-string.h" +#include "eel-gtk-extensions.h" + #include #include @@ -203,12 +202,16 @@ timed_wait_callback (gpointer callback_data) /* Put up the timed wait window. */ button = wait->cancel_callback != NULL ? GTK_STOCK_CANCEL : GTK_STOCK_OK; - dialog = GTK_DIALOG (eel_alert_dialog_new (wait->parent_window, - 0, - GTK_MESSAGE_INFO, - GTK_BUTTONS_NONE, - wait->wait_message, - _("You can stop this operation by clicking cancel."))); + dialog = GTK_DIALOG (gtk_message_dialog_new (wait->parent_window, + 0, + GTK_MESSAGE_INFO, + GTK_BUTTONS_NONE, + NULL)); + + g_object_set (dialog, + "text", wait->wait_message, + "secondary-text", _("You can stop this operation by clicking cancel."), + NULL); gtk_dialog_add_button (GTK_DIALOG (dialog), button, GTK_RESPONSE_OK); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); @@ -340,12 +343,16 @@ eel_run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box, } /* Create the dialog. */ - dialog = eel_alert_dialog_new (GTK_WINDOW (chosen_parent), - 0, - message_type, - GTK_BUTTONS_NONE, - primary_text, - secondary_text); + dialog = gtk_message_dialog_new (GTK_WINDOW (chosen_parent), + 0, + message_type, + GTK_BUTTONS_NONE, + NULL); + + g_object_set (dialog, + "text", primary_text, + "secondary-text", secondary_text, + NULL); va_start (button_title_args, secondary_text); response_id = 0; @@ -370,7 +377,7 @@ eel_run_simple_dialog (GtkWidget *parent, gboolean ignore_close_box, gtk_widget_show (GTK_WIDGET (dialog)); result = gtk_dialog_run (GTK_DIALOG (dialog)); } - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (dialog); return result; } @@ -384,12 +391,17 @@ create_message_dialog (const char *primary_text, { GtkWidget *dialog; - dialog = eel_alert_dialog_new (parent, - 0, - type, - buttons_type, - primary_text, - secondary_text); + dialog = gtk_message_dialog_new (parent, + 0, + type, + buttons_type, + NULL); + + g_object_set (dialog, + "text", primary_text, + "secondary-text", secondary_text, + NULL); + return GTK_DIALOG (dialog); } @@ -405,9 +417,9 @@ show_message_dialog (const char *primary_text, dialog = create_message_dialog (primary_text, secondary_text, type, buttons_type, parent); - if (details_text != NULL) - { - eel_alert_dialog_set_details_label (EEL_ALERT_DIALOG (dialog), details_text); + if (details_text != NULL) { + eel_gtk_message_dialog_set_details_label (GTK_MESSAGE_DIALOG (dialog), + details_text); } gtk_widget_show (GTK_WIDGET (dialog)); diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c index 55140e6b..24bb4a19 100644 --- a/libcaja-private/caja-file-operations.c +++ b/libcaja-private/caja-file-operations.c @@ -44,7 +44,6 @@ #include "caja-progress-info.h" -#include #include #include #include @@ -1065,12 +1064,16 @@ do_run_simple_dialog (gpointer _data) int response_id; /* Create the dialog. */ - dialog = eel_alert_dialog_new (*data->parent_window, - 0, - data->message_type, - GTK_BUTTONS_NONE, - data->primary_text, - data->secondary_text); + dialog = gtk_message_dialog_new (*data->parent_window, + 0, + data->message_type, + GTK_BUTTONS_NONE, + NULL); + + g_object_set (dialog, + "text", data->primary_text, + "secondary-text", data->secondary_text, + NULL); for (response_id = 0; data->button_titles[response_id] != NULL; @@ -1085,8 +1088,8 @@ do_run_simple_dialog (gpointer _data) } if (data->details_text) { - eel_alert_dialog_set_details_label (EEL_ALERT_DIALOG (dialog), - data->details_text); + eel_gtk_message_dialog_set_details_label (GTK_MESSAGE_DIALOG (dialog), + data->details_text); } /* Run it. */ @@ -1098,7 +1101,7 @@ do_run_simple_dialog (gpointer _data) result = gtk_dialog_run (GTK_DIALOG (dialog)); } - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (dialog); data->result = result; diff --git a/libcaja-private/caja-mime-actions.c b/libcaja-private/caja-mime-actions.c index 501263f0..a4dc8c97 100644 --- a/libcaja-private/caja-mime-actions.c +++ b/libcaja-private/caja-mime-actions.c @@ -27,7 +27,6 @@ #include #include -#include #include #include #include @@ -1372,26 +1371,29 @@ show_unhandled_type_error (ActivateParametersInstall *parameters) char *mime_type = caja_file_get_mime_type (parameters->file); char *error_message = get_application_no_mime_type_handler_message (parameters->file, parameters->uri); - if (g_content_type_is_unknown (mime_type)) - { - dialog = eel_alert_dialog_new (parameters->parent_window, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - 0, - error_message, - _("The file is of an unknown type")); - } - else - { + if (g_content_type_is_unknown (mime_type)) { + dialog = gtk_message_dialog_new (parameters->parent_window, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + 0, + NULL); + g_object_set (dialog, + "text", error_message, + "secondary-text", _("The file is of an unknown type"), + NULL); + } else { char *text; text = g_strdup_printf (_("There is no application installed for %s files"), g_content_type_get_description (mime_type)); - dialog = eel_alert_dialog_new (parameters->parent_window, - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_MESSAGE_ERROR, - 0, - error_message, - text); + dialog = gtk_message_dialog_new (parameters->parent_window, + GTK_DIALOG_DESTROY_WITH_PARENT, + GTK_MESSAGE_ERROR, + 0, + NULL); + g_object_set (dialog, + "text", error_message, + "secondary-text", text, + NULL); g_free (text); } @@ -1734,12 +1736,15 @@ activate_desktop_file (ActivateParameters *parameters, ), display_name); - dialog = eel_alert_dialog_new (parameters->parent_window, - 0, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_NONE, - primary, - secondary); + dialog = gtk_message_dialog_new (parameters->parent_window, + 0, + GTK_MESSAGE_WARNING, + GTK_BUTTONS_NONE, + NULL); + g_object_set (dialog, + "text", primary, + "secondary-text", secondary, + NULL); gtk_dialog_add_button (GTK_DIALOG (dialog), _("_Launch Anyway"), RESPONSE_RUN); if (caja_file_can_set_permissions (file)) diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c index cb27a07d..d673c70b 100644 --- a/src/file-manager/fm-tree-view.c +++ b/src/file-manager/fm-tree-view.c @@ -35,7 +35,6 @@ #include "fm-tree-model.h" #include "fm-properties-window.h" #include -#include #include #include #include -- cgit v1.2.1 From 8030e5c8d2dc8bd03215584c7e433bafbe6e265a Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 10:55:15 +0200 Subject: [eel] remove EelAlertDialog. It is unused now http://git.gnome.org/browse/nautilus/commit/?id=fe94a33657d55a2463fa066e09a8ecbfc637c4bd --- eel/Makefile.am | 2 - eel/eel-alert-dialog.c | 492 ------------------------------------------------- eel/eel-alert-dialog.h | 60 ------ 3 files changed, 554 deletions(-) delete mode 100644 eel/eel-alert-dialog.c delete mode 100644 eel/eel-alert-dialog.h diff --git a/eel/Makefile.am b/eel/Makefile.am index 19407089..9fb404fc 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -33,7 +33,6 @@ libeel_2_la_LIBADD = \ libeel_2_la_SOURCES = \ eel-accessibility.c \ - eel-alert-dialog.c \ eel-art-extensions.c \ eel-art-gtk-extensions.c \ eel-background.c \ @@ -65,7 +64,6 @@ libeel_2_la_SOURCES = \ eel_headers = \ eel-accessibility.h \ - eel-alert-dialog.h \ eel-art-extensions.h \ eel-art-gtk-extensions.h \ eel-background.h \ diff --git a/eel/eel-alert-dialog.c b/eel/eel-alert-dialog.c deleted file mode 100644 index 0bfdc81e..00000000 --- a/eel/eel-alert-dialog.c +++ /dev/null @@ -1,492 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-alert-dialog.c: An HIG compliant alert dialog. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ -#include - -#include "eel-alert-dialog.h" -#include "eel-gtk-macros.h" - - -#include -#include -#include - -enum -{ - PROP_0, - PROP_ALERT_TYPE, - PROP_BUTTONS -}; - -struct _EelAlertDialogDetails -{ - GtkWidget *image; - GtkWidget *primary_label; - GtkWidget *secondary_label; - GtkWidget *details_expander; - GtkWidget *details_label; - GtkMessageType type; -}; - - -static gpointer parent_class; - -static void eel_alert_dialog_finalize (GObject *object); -static void eel_alert_dialog_class_init (EelAlertDialogClass *klass); -static void eel_alert_dialog_init (EelAlertDialog *dialog); -static void eel_alert_dialog_style_set (GtkWidget *widget, - GtkStyle *prev_style); -static void eel_alert_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void eel_alert_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void eel_alert_dialog_add_buttons (EelAlertDialog *alert_dialog, - GtkButtonsType buttons); - -GType -eel_alert_dialog_get_type (void) -{ - static GType dialog_type = 0; - - if (!dialog_type) - { - - const GTypeInfo dialog_info = - { - sizeof (EelAlertDialogClass), - NULL, - NULL, - (GClassInitFunc) eel_alert_dialog_class_init, - NULL, - NULL, - sizeof (EelAlertDialog), - 0, - (GInstanceInitFunc) eel_alert_dialog_init, - }; - - dialog_type = g_type_register_static (GTK_TYPE_DIALOG, "EelAlertDialog", - &dialog_info, 0); - } - return dialog_type; -} - -static void -eel_alert_dialog_class_init (EelAlertDialogClass *class) -{ - GtkWidgetClass *widget_class; - GObjectClass *gobject_class; - - widget_class = GTK_WIDGET_CLASS (class); - gobject_class = G_OBJECT_CLASS (class); - - parent_class = g_type_class_peek_parent (class); - - G_OBJECT_CLASS (class)->finalize = eel_alert_dialog_finalize; - - widget_class->style_set = eel_alert_dialog_style_set; - - gobject_class->set_property = eel_alert_dialog_set_property; - gobject_class->get_property = eel_alert_dialog_get_property; - - gtk_widget_class_install_style_property (widget_class, - g_param_spec_int ("alert_border", - _("Image/label border"), - _("Width of border around the label and image in the alert dialog"), - 0, - G_MAXINT, - 5, - G_PARAM_READABLE)); - - g_object_class_install_property (gobject_class, - PROP_ALERT_TYPE, - g_param_spec_enum ("alert_type", - _("Alert Type"), - _("The type of alert"), - GTK_TYPE_MESSAGE_TYPE, - GTK_MESSAGE_INFO, - G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT)); - - g_object_class_install_property (gobject_class, - PROP_BUTTONS, - g_param_spec_enum ("buttons", - _("Alert Buttons"), - _("The buttons shown in the alert dialog"), - GTK_TYPE_BUTTONS_TYPE, - GTK_BUTTONS_NONE, - G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY)); -} - -static void -eel_alert_dialog_finalize (GObject *object) -{ - EelAlertDialog *dialog; - - dialog = EEL_ALERT_DIALOG (object); - - g_free (dialog->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - - -static void -eel_alert_dialog_init (EelAlertDialog *dialog) -{ - GtkWidget *hbox; - GtkWidget *vbox; - GtkWidget *expander; - - dialog->details = g_new0 (EelAlertDialogDetails, 1); - - dialog->details->primary_label = gtk_label_new (NULL); - dialog->details->secondary_label = gtk_label_new (NULL); - dialog->details->details_label = gtk_label_new (NULL); - dialog->details->image = gtk_image_new_from_stock (NULL, GTK_ICON_SIZE_DIALOG); - gtk_misc_set_alignment (GTK_MISC (dialog->details->image), 0.5, 0.0); - - gtk_label_set_line_wrap (GTK_LABEL (dialog->details->primary_label), TRUE); - gtk_label_set_selectable (GTK_LABEL (dialog->details->primary_label), TRUE); - gtk_label_set_use_markup (GTK_LABEL (dialog->details->primary_label), TRUE); - gtk_misc_set_alignment (GTK_MISC (dialog->details->primary_label), 0.0, 0.5); - - gtk_label_set_line_wrap (GTK_LABEL (dialog->details->secondary_label), TRUE); - gtk_label_set_selectable (GTK_LABEL (dialog->details->secondary_label), TRUE); - gtk_misc_set_alignment (GTK_MISC (dialog->details->secondary_label), 0.0, 0.5); - - gtk_label_set_line_wrap (GTK_LABEL (dialog->details->details_label), TRUE); - gtk_label_set_selectable (GTK_LABEL (dialog->details->details_label), TRUE); - gtk_misc_set_alignment (GTK_MISC (dialog->details->details_label), 0.0, 0.5); - - hbox = gtk_hbox_new (FALSE, 12); - gtk_container_set_border_width (GTK_CONTAINER (hbox), 5); - - gtk_box_pack_start (GTK_BOX (hbox), dialog->details->image, - FALSE, FALSE, 0); - - vbox = gtk_vbox_new (FALSE, 12); - - gtk_box_pack_start (GTK_BOX (hbox), vbox, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), dialog->details->primary_label, - FALSE, FALSE, 0); - - gtk_box_pack_start (GTK_BOX (vbox), dialog->details->secondary_label, - FALSE, FALSE, 0); - - expander = gtk_expander_new_with_mnemonic (_("Show more _details")); - dialog->details->details_expander = expander; - gtk_expander_set_spacing (GTK_EXPANDER (expander), 6); - gtk_container_add (GTK_CONTAINER (expander), dialog->details->details_label); - - gtk_box_pack_start (GTK_BOX (vbox), expander, - FALSE, FALSE, 0); - - - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, - FALSE, FALSE, 0); - - gtk_widget_show_all (hbox); - gtk_widget_hide (expander); - -} - -static void -setup_type (EelAlertDialog *dialog, - GtkMessageType type) -{ - const gchar *stock_id = NULL; - GtkStockItem item; - - switch (type) - { - case GTK_MESSAGE_INFO: - stock_id = GTK_STOCK_DIALOG_INFO; - break; - case GTK_MESSAGE_QUESTION: - stock_id = GTK_STOCK_DIALOG_QUESTION; - break; - case GTK_MESSAGE_WARNING: - stock_id = GTK_STOCK_DIALOG_WARNING; - break; - case GTK_MESSAGE_ERROR: - stock_id = GTK_STOCK_DIALOG_ERROR; - break; - default: - g_warning ("Unknown GtkMessageType %d", type); - break; - } - - if (stock_id == NULL) - { - stock_id = GTK_STOCK_DIALOG_INFO; - } - - if (gtk_stock_lookup (stock_id, &item)) - { - gtk_image_set_from_stock (GTK_IMAGE (dialog->details->image), stock_id, - GTK_ICON_SIZE_DIALOG); - } - else - { - g_warning ("Stock dialog ID doesn't exist?"); - } -} - -static void -eel_alert_dialog_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - EelAlertDialog *dialog; - - dialog = EEL_ALERT_DIALOG (object); - - switch (prop_id) - { - case PROP_ALERT_TYPE: - dialog->details->type = g_value_get_enum (value); - setup_type (dialog, dialog->details->type); - break; - case PROP_BUTTONS: - eel_alert_dialog_add_buttons (dialog, g_value_get_enum (value)); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -static void -eel_alert_dialog_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - EelAlertDialog *dialog; - - dialog = EEL_ALERT_DIALOG (object); - - switch (prop_id) - { - case PROP_ALERT_TYPE: - g_value_set_enum (value, dialog->details->type); - break; - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - -void -eel_alert_dialog_set_primary_label (EelAlertDialog *dialog, - const gchar *message) -{ - gchar *markup_str; - char *escaped_message; - - if (message != NULL) - { - escaped_message = g_markup_escape_text (message, -1); - markup_str = g_strconcat ("", escaped_message, "", NULL); - gtk_label_set_markup (GTK_LABEL (EEL_ALERT_DIALOG (dialog)->details->primary_label), - markup_str); - g_free (markup_str); - g_free (escaped_message); - } -} - -void -eel_alert_dialog_set_secondary_label (EelAlertDialog *dialog, - const gchar *message) -{ - if (message != NULL) - { - gtk_label_set_text (GTK_LABEL (EEL_ALERT_DIALOG (dialog)->details->secondary_label), - message); - } - else - { - gtk_widget_hide (EEL_ALERT_DIALOG (dialog)->details->secondary_label); - } -} - -void -eel_alert_dialog_set_details_label (EelAlertDialog *dialog, - const gchar *message) -{ - if (message != NULL) - { - gtk_widget_show (dialog->details->details_expander); - gtk_label_set_text (GTK_LABEL (dialog->details->details_label), message); - } - else - { - gtk_widget_hide (dialog->details->details_expander); - } -} - - -GtkWidget* -eel_alert_dialog_new (GtkWindow *parent, - GtkDialogFlags flags, - GtkMessageType type, - GtkButtonsType buttons, - const gchar *primary_message, - const gchar *secondary_message) -{ - GtkWidget *widget; - GtkDialog *dialog; - - g_return_val_if_fail (parent == NULL || GTK_IS_WINDOW (parent), NULL); - - widget = g_object_new (EEL_TYPE_ALERT_DIALOG, - "alert_type", type, - "buttons", buttons, - NULL); - atk_object_set_role (gtk_widget_get_accessible (widget), ATK_ROLE_ALERT); - - dialog = GTK_DIALOG (widget); - - gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); - gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 14); - gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_dialog_set_has_separator (dialog, FALSE); - - /* Make sure we don't get a window title. - * HIG says that alert dialogs should not have window title - */ - gtk_window_set_title (GTK_WINDOW (dialog), ""); - gtk_window_set_skip_taskbar_hint (GTK_WINDOW (dialog), TRUE); - - eel_alert_dialog_set_primary_label (EEL_ALERT_DIALOG (dialog), - primary_message); - - eel_alert_dialog_set_secondary_label (EEL_ALERT_DIALOG (dialog), - secondary_message); - - if (parent != NULL) - { - gtk_window_set_transient_for (GTK_WINDOW (widget), - GTK_WINDOW (parent)); - } - - if (flags & GTK_DIALOG_MODAL) - { - gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); - } - - if (flags & GTK_DIALOG_DESTROY_WITH_PARENT) - { - gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); - } - return widget; -} - -static void -eel_alert_dialog_add_buttons (EelAlertDialog* alert_dialog, - GtkButtonsType buttons) -{ - GtkDialog* dialog; - - dialog = GTK_DIALOG (alert_dialog); - - switch (buttons) - { - case GTK_BUTTONS_NONE: - break; - case GTK_BUTTONS_OK: - gtk_dialog_add_button (dialog, - GTK_STOCK_OK, - GTK_RESPONSE_OK); - gtk_dialog_set_default_response (dialog, - GTK_RESPONSE_OK); - break; - case GTK_BUTTONS_CLOSE: - gtk_dialog_add_button (dialog, - GTK_STOCK_CLOSE, - GTK_RESPONSE_CLOSE); - gtk_dialog_set_default_response (dialog, - GTK_RESPONSE_CLOSE); - break; - case GTK_BUTTONS_CANCEL: - gtk_dialog_add_button (dialog, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - gtk_dialog_set_default_response (dialog, - GTK_RESPONSE_CANCEL); - break; - case GTK_BUTTONS_YES_NO: - gtk_dialog_add_button (dialog, - GTK_STOCK_NO, - GTK_RESPONSE_NO); - gtk_dialog_add_button (dialog, - GTK_STOCK_YES, - GTK_RESPONSE_YES); - gtk_dialog_set_default_response (dialog, - GTK_RESPONSE_YES); - break; - case GTK_BUTTONS_OK_CANCEL: - gtk_dialog_add_button (dialog, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (dialog, - GTK_STOCK_OK, - GTK_RESPONSE_OK); - gtk_dialog_set_default_response (dialog, - GTK_RESPONSE_OK); - break; - default: - g_warning ("Unknown GtkButtonsType"); - break; - } - g_object_notify (G_OBJECT (alert_dialog), "buttons"); -} - -static void -eel_alert_dialog_style_set (GtkWidget *widget, - GtkStyle *prev_style) -{ - GtkWidget *parent; - gint border_width; - - border_width = 0; - - parent = GTK_WIDGET (gtk_widget_get_parent (EEL_ALERT_DIALOG (widget)->details->image)); - - if (parent != NULL) - { - gtk_widget_style_get (widget, "alert_border", - &border_width, NULL); - - gtk_container_set_border_width (GTK_CONTAINER (parent), - border_width); - } - - if (GTK_WIDGET_CLASS (parent_class)->style_set) - { - (GTK_WIDGET_CLASS (parent_class)->style_set) (widget, prev_style); - } -} diff --git a/eel/eel-alert-dialog.h b/eel/eel-alert-dialog.h deleted file mode 100644 index b1bbebe0..00000000 --- a/eel/eel-alert-dialog.h +++ /dev/null @@ -1,60 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* eel-alert-dialog.h: An HIG compliant alert dialog. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - -*/ - -#ifndef EEL_ALERT_DIALOG_H -#define EEL_ALERT_DIALOG_H - -#include - -#define EEL_TYPE_ALERT_DIALOG (eel_alert_dialog_get_type ()) -#define EEL_ALERT_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), EEL_TYPE_ALERT_DIALOG, EelAlertDialog)) - -typedef struct _EelAlertDialog EelAlertDialog; -typedef struct _EelAlertDialogClass EelAlertDialogClass; -typedef struct _EelAlertDialogDetails EelAlertDialogDetails; - -struct _EelAlertDialog -{ - GtkDialog parent_instance; - EelAlertDialogDetails *details; -}; - -struct _EelAlertDialogClass -{ - GtkDialogClass parent_class; -}; - -GType eel_alert_dialog_get_type (void); - -GtkWidget* eel_alert_dialog_new (GtkWindow *parent, - GtkDialogFlags flags, - GtkMessageType type, - GtkButtonsType buttons, - const gchar *primary_message, - const gchar *secondary_message); -void eel_alert_dialog_set_primary_label (EelAlertDialog *dialog, - const gchar *message); -void eel_alert_dialog_set_secondary_label (EelAlertDialog *dialog, - const gchar *message); -void eel_alert_dialog_set_details_label (EelAlertDialog *dialog, - const gchar *message); - -#endif /* EEL_ALERT_DIALOG_H */ -- cgit v1.2.1 From b50a7e051df6589e2d9059ec26329ec7be39a724 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 10:58:49 +0200 Subject: [icon-container] use gdk_window_focus http://git.gnome.org/browse/nautilus/commit/?id=6b06e0e27ca1cf29afd4fac716c58e15928a8ff8 --- libcaja-private/caja-icon-container.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index eb1eaedb..b1d648d3 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4930,7 +4930,7 @@ start_stretching (CajaIconContainer *container) toplevel = gtk_widget_get_toplevel (GTK_WIDGET (container)); if (toplevel != NULL && gtk_widget_get_realized (toplevel)) { - eel_gdk_window_focus (gtk_widget_get_window (toplevel), GDK_CURRENT_TIME); + gdk_window_focus (gtk_widget_get_window (toplevel), GDK_CURRENT_TIME); } return TRUE; -- cgit v1.2.1 From 235ac60d2e47057b7e1943c19e9126927888a301 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:00:28 +0200 Subject: [eel] remove eel_gdk_window_focus http://git.gnome.org/browse/nautilus/commit/?id=7e8d1dfa6a17fe9189bf2489b735cd6462f03571\ --- eel/eel-gdk-extensions.c | 12 ------------ eel/eel-gdk-extensions.h | 5 ----- 2 files changed, 17 deletions(-) diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index f9e28f6d..2a5f8734 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -431,18 +431,6 @@ eel_gdk_color_is_dark (GdkColor *color) return intensity < 128; } -void -eel_gdk_window_focus (GdkWindow *window, guint32 timestamp) -{ - gdk_error_trap_push (); - XSetInputFocus (GDK_DISPLAY (), - GDK_WINDOW_XWINDOW (window), - RevertToParent, - timestamp); - gdk_flush(); - gdk_error_trap_pop (); -} - EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return, guint *width_return, guint *height_return) diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index ca253403..a879bdce 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -112,11 +112,6 @@ char * eel_gdk_rgb_to_color_spec (guint32 gboolean eel_gdk_color_is_dark (GdkColor *color); - -/* Misc GdkWindow helper functions */ -void eel_gdk_window_focus (GdkWindow *window, - guint32 timestamp); - /* Wrapper for XParseGeometry */ EelGdkGeometryFlags eel_gdk_parse_geometry (const char *string, int *x_return, -- cgit v1.2.1 From aaa289476ee990743ef573797736d7e42595a251 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 04:48:40 +0200 Subject: [eel] reorganize Makefile.am http://git.gnome.org/browse/nautilus/commit/?id=ad5e896e1ce04485a115ee684a695b42ea0378a5 --- eel/Makefile.am | 71 +++++++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/eel/Makefile.am b/eel/Makefile.am index 9fb404fc..4883a6f2 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -4,15 +4,13 @@ noinst_LTLIBRARIES=libeel-2.la INCLUDES = \ -DG_LOG_DOMAIN=\"Eel\" \ - -I$(top_srcdir) \ + -I$(top_builddir) \ $(CORE_CFLAGS) \ $(WARNING_CFLAGS) \ + $(DISABLE_DEPRECATED_CFLAGS) \ -DDATADIR=\""$(datadir)"\" \ -DSOURCE_DATADIR=\""$(top_srcdir)/data"\" \ -DMATELOCALEDIR=\""$(prefix)/${DATADIRNAME}/locale"\" \ - -DG_DISABLE_DEPRECATED \ - -DGDK_PIXBUF_DISABLE_DEPRECATED \ - -DMATEMENU_I_KNOW_THIS_IS_UNSTABLE \ $(NULL) BUILT_SOURCES = \ @@ -31,37 +29,6 @@ libeel_2_la_LIBADD = \ $(X_LIBS) \ $(NULL) -libeel_2_la_SOURCES = \ - eel-accessibility.c \ - eel-art-extensions.c \ - eel-art-gtk-extensions.c \ - eel-background.c \ - eel-background-box.c \ - eel-canvas.c \ - eel-canvas-util.c \ - eel-canvas-rect-ellipse.c \ - eel-debug-drawing.c \ - eel-debug.c \ - eel-editable-label.c \ - eel-gdk-extensions.c \ - eel-gdk-pixbuf-extensions.c \ - eel-glib-extensions.c \ - eel-mate-extensions.c \ - eel-graphic-effects.c \ - eel-gtk-container.c \ - eel-gtk-extensions.c \ - eel-image-table.c \ - eel-labeled-image.c \ - eel-lib-self-check-functions.c \ - eel-self-checks.c \ - eel-stock-dialogs.c \ - eel-string.c \ - eel-vfs-extensions.c \ - eel-wrap-table.c \ - eel-xml-extensions.c \ - eel-lib-self-check-functions.h \ - $(NULL) - eel_headers = \ eel-accessibility.h \ eel-art-extensions.h \ @@ -93,6 +60,37 @@ eel_headers = \ eel.h \ $(NULL) +libeel_2_la_SOURCES = \ + eel-accessibility.c \ + eel-art-extensions.c \ + eel-art-gtk-extensions.c \ + eel-background.c \ + eel-background-box.c \ + eel-canvas.c \ + eel-canvas-util.c \ + eel-canvas-rect-ellipse.c \ + eel-debug-drawing.c \ + eel-debug.c \ + eel-editable-label.c \ + eel-gdk-extensions.c \ + eel-gdk-pixbuf-extensions.c \ + eel-glib-extensions.c \ + eel-mate-extensions.c \ + eel-graphic-effects.c \ + eel-gtk-container.c \ + eel-gtk-extensions.c \ + eel-image-table.c \ + eel-labeled-image.c \ + eel-lib-self-check-functions.c \ + eel-self-checks.c \ + eel-stock-dialogs.c \ + eel-string.c \ + eel-vfs-extensions.c \ + eel-wrap-table.c \ + eel-xml-extensions.c \ + eel-lib-self-check-functions.h \ + $(NULL) + nodist_libeel_2_la_SOURCES = \ $(BUILT_SOURCES) \ $(NULL) @@ -125,9 +123,8 @@ check_program_LDFLAGS = $(check_program_DEPENDENCIES) -lm TESTS = check-eel EXTRA_DIST = \ - $(eel_headers) \ check-eel \ - eel-marshal.list \ + eel-marshal.list \ $(NULL) CLEANFILES = \ -- cgit v1.2.1 From 408fb6c29f23b58f5fba2704b378c2d58151490b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:21:31 +0200 Subject: [places-sidebar] Add highlight to eject icon Add highlight to eject icon in places sidebar (#544103) http://git.gnome.org/browse/nautilus/commit/?id=63b2cac301970847f76f7bdbd12835117958d9be --- src/caja-places-sidebar.c | 158 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 136 insertions(+), 22 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 13f06966..770c1e28 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -90,6 +91,8 @@ typedef struct gboolean mounting; CajaWindowSlotInfo *go_to_after_mount_slot; CajaWindowOpenFlags go_to_after_mount_flags; + + GtkTreePath *eject_highlight_path; } CajaPlacesSidebar; typedef struct @@ -122,6 +125,7 @@ enum PLACES_SIDEBAR_COLUMN_BOOKMARK, PLACES_SIDEBAR_COLUMN_NO_BOOKMARK, PLACES_SIDEBAR_COLUMN_TOOLTIP, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, PLACES_SIDEBAR_COLUMN_COUNT }; @@ -211,6 +215,30 @@ G_DEFINE_TYPE_WITH_CODE (CajaPlacesSidebarProvider, caja_places_sidebar_provider G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR_PROVIDER, sidebar_provider_iface_init)); +static GdkPixbuf * +get_eject_icon (gboolean highlighted) +{ + GdkPixbuf *eject; + GIcon *eject_icon; + CajaIconInfo *eject_icon_info; + int icon_size; + + icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); + + eject_icon = g_icon_new_for_string ("media-eject", NULL); + eject_icon_info = caja_icon_info_lookup (eject_icon, icon_size); + g_object_unref (eject_icon_info); + + eject = caja_icon_info_get_pixbuf_at_size (eject_icon_info, icon_size); + if (highlighted) { + GdkPixbuf *high; + high = eel_gdk_pixbuf_render (eject, 1, 255, 255, 0, 0); + g_object_unref (eject); + eject = high; + } + return eject; +} + static GtkTreeIter add_place (CajaPlacesSidebar *sidebar, PlaceType place_type, @@ -225,6 +253,7 @@ add_place (CajaPlacesSidebar *sidebar, { GdkPixbuf *pixbuf; GtkTreeIter iter, child_iter; + GdkPixbuf *eject; CajaIconInfo *icon_info; int icon_size; gboolean show_eject, show_unmount; @@ -252,6 +281,7 @@ add_place (CajaPlacesSidebar *sidebar, show_eject_button = (show_unmount || show_eject); } + eject = get_eject_icon (FALSE); gtk_list_store_append (sidebar->store, &iter); gtk_list_store_set (sidebar->store, &iter, PLACES_SIDEBAR_COLUMN_ICON, pixbuf, @@ -267,6 +297,7 @@ add_place (CajaPlacesSidebar *sidebar, PLACES_SIDEBAR_COLUMN_BOOKMARK, place_type != PLACES_BOOKMARK, PLACES_SIDEBAR_COLUMN_NO_BOOKMARK, place_type == PLACES_BOOKMARK, PLACES_SIDEBAR_COLUMN_TOOLTIP, tooltip, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, eject, -1); if (pixbuf != NULL) @@ -732,11 +763,11 @@ drive_changed_callback (GVolumeMonitor *volume_monitor, } static gboolean -clicked_eject_button (CajaPlacesSidebar *sidebar, - GtkTreePath **path) +over_eject_button (CajaPlacesSidebar *sidebar, + gint x, + gint y, + GtkTreePath **path) { - GdkEvent *event = gtk_get_current_event (); - GdkEventButton *button_event = (GdkEventButton *) event; GtkTreeViewColumn *column; GtkTextDirection direction; int width, total_width; @@ -748,19 +779,16 @@ clicked_eject_button (CajaPlacesSidebar *sidebar, *path = NULL; model = gtk_tree_view_get_model (sidebar->tree_view); - if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) && - gtk_tree_view_get_path_at_pos (sidebar->tree_view, - button_event->x, button_event->y, - path, &column, NULL, NULL)) - { + if (gtk_tree_view_get_path_at_pos (sidebar->tree_view, + x, y, + path, &column, NULL, NULL)) { gtk_tree_model_get_iter (model, &iter, *path); gtk_tree_model_get (model, &iter, PLACES_SIDEBAR_COLUMN_EJECT, &show_eject, -1); - if (!show_eject) - { + if (!show_eject) { goto out; } @@ -772,8 +800,7 @@ clicked_eject_button (CajaPlacesSidebar *sidebar, total_width += width / 2; direction = gtk_widget_get_direction (GTK_WIDGET (sidebar->tree_view)); - if (direction != GTK_TEXT_DIR_RTL) - { + if (direction != GTK_TEXT_DIR_RTL) { gtk_tree_view_column_cell_get_position (column, sidebar->icon_cell_renderer, NULL, &width); @@ -789,19 +816,29 @@ clicked_eject_button (CajaPlacesSidebar *sidebar, eject_button_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); - if (button_event->x - total_width >= 0 && - button_event->x - total_width <= eject_button_size) - { + if (x - total_width >= 0 && + x - total_width <= eject_button_size) { return TRUE; } } out: - if (*path != NULL) - { - gtk_tree_path_free (*path); - } + return FALSE; +} +static gboolean +clicked_eject_button (CajaPlacesSidebar *sidebar, + GtkTreePath **path) +{ + GdkEvent *event = gtk_get_current_event (); + GdkEventButton *button_event = (GdkEventButton *) event; + + *path = NULL; + + if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) && + over_eject_button (sidebar, button_event->x, button_event->y, path)) { + return TRUE; + } return FALSE; } @@ -2606,6 +2643,80 @@ bookmarks_button_release_event_cb (GtkWidget *widget, return FALSE; } +static void +update_eject_buttons (CajaPlacesSidebar *sidebar, + GtkTreePath *path) +{ + GtkTreeIter iter; + + if (!path && !sidebar->eject_highlight_path) { + /* Both are null - highlight up to date */ + return; + } + + if (path && + sidebar->eject_highlight_path && + gtk_tree_path_compare (sidebar->eject_highlight_path, path) == 0) { + /* Same path - highlight up to date */ + return; + } + + /* Reset last path */ + if (sidebar->eject_highlight_path) { + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + sidebar->eject_highlight_path); + + gtk_list_store_set (GTK_LIST_STORE (sidebar->store), + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE), + -1); + + gtk_tree_path_free (sidebar->eject_highlight_path); + } + + /* Update current path */ + if (path) { + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + path); + + gtk_list_store_set (GTK_LIST_STORE (sidebar->store), + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), + -1); + } + + if (path) { + sidebar->eject_highlight_path = gtk_tree_path_copy (path); + } else { + sidebar->eject_highlight_path = NULL; + } +} + +static gboolean +bookmarks_motion_event_cb (GtkWidget *widget, + GdkEventMotion *event, + CajaPlacesSidebar *sidebar) +{ + GtkTreePath *path; + GtkTreeModel *model; + + model = GTK_TREE_MODEL (sidebar->filter_model); + + if (over_eject_button (sidebar, event->x, event->y, &path)) { + update_eject_buttons (sidebar, path); + } else { + update_eject_buttons (sidebar, NULL); + } + + if (path) { + gtk_tree_path_free (path); + } + + return TRUE; +} + /* Callback used when a button is pressed on the shortcuts list. * We trap button 3 to bring up a popup menu, and button 2 to * open in a new tab. @@ -2751,13 +2862,13 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) cell = gtk_cell_renderer_pixbuf_new (); g_object_set (cell, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, - "icon-name", "media-eject", "stock-size", GTK_ICON_SIZE_MENU, "xpad", EJECT_BUTTON_XPAD, NULL); gtk_tree_view_column_pack_start (col, cell, FALSE); gtk_tree_view_column_set_attributes (col, cell, "visible", PLACES_SIDEBAR_COLUMN_EJECT, + "pixbuf", PLACES_SIDEBAR_COLUMN_EJECT_ICON, NULL); cell = gtk_cell_renderer_text_new (); @@ -2800,7 +2911,8 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, - G_TYPE_STRING + G_TYPE_STRING, + GDK_TYPE_PIXBUF ); gtk_tree_view_set_tooltip_column (tree_view, PLACES_SIDEBAR_COLUMN_TOOLTIP); @@ -2847,6 +2959,8 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) G_CALLBACK (bookmarks_popup_menu_cb), sidebar); g_signal_connect (tree_view, "button-press-event", G_CALLBACK (bookmarks_button_press_event_cb), sidebar); + g_signal_connect (tree_view, "motion-notify-event", + G_CALLBACK (bookmarks_motion_event_cb), sidebar); g_signal_connect (tree_view, "button-release-event", G_CALLBACK (bookmarks_button_release_event_cb), sidebar); -- cgit v1.2.1 From e9f10bb18e0b8e0c39c28630b7aab6d739afc80b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:25:12 +0200 Subject: [places-sidebar] use _icon_info_lookup_from_name() http://git.gnome.org/browse/nautilus/commit/?id=f4ae07c8741d2e8cc6b96450c8bb86e532b59137 --- src/caja-places-sidebar.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 770c1e28..71d0bd59 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -219,23 +219,23 @@ static GdkPixbuf * get_eject_icon (gboolean highlighted) { GdkPixbuf *eject; - GIcon *eject_icon; CajaIconInfo *eject_icon_info; int icon_size; icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); - eject_icon = g_icon_new_for_string ("media-eject", NULL); - eject_icon_info = caja_icon_info_lookup (eject_icon, icon_size); - g_object_unref (eject_icon_info); - + eject_icon_info = caja_icon_info_lookup_from_name ("media-eject", icon_size); eject = caja_icon_info_get_pixbuf_at_size (eject_icon_info, icon_size); + if (highlighted) { GdkPixbuf *high; high = eel_gdk_pixbuf_render (eject, 1, 255, 255, 0, 0); g_object_unref (eject); eject = high; } + + g_object_unref (eject_icon_info); + return eject; } -- cgit v1.2.1 From 3434cb86b4a292da136bccd86d5ab9a10707b113 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:30:45 +0200 Subject: [pathbar] make sure |path| is always valid and memory released http://git.gnome.org/browse/nautilus/commit/?id=a43bc7def3976947b9624113d18167211e76f9b8 --- src/caja-places-sidebar.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 71d0bd59..78837dd3 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -823,6 +823,11 @@ over_eject_button (CajaPlacesSidebar *sidebar, } out: + if (*path != NULL) { + gtk_tree_path_free (*path); + *path = NULL; + } + return FALSE; } @@ -833,12 +838,11 @@ clicked_eject_button (CajaPlacesSidebar *sidebar, GdkEvent *event = gtk_get_current_event (); GdkEventButton *button_event = (GdkEventButton *) event; - *path = NULL; - if ((event->type == GDK_BUTTON_PRESS || event->type == GDK_BUTTON_RELEASE) && over_eject_button (sidebar, button_event->x, button_event->y, path)) { return TRUE; } + return FALSE; } @@ -2609,6 +2613,8 @@ bookmarks_button_release_event_cb (GtkWidget *widget, GtkTreeView *tree_view; gboolean ret; + path = NULL; + if (event->type != GDK_BUTTON_RELEASE) { return TRUE; @@ -2703,17 +2709,15 @@ bookmarks_motion_event_cb (GtkWidget *widget, GtkTreeModel *model; model = GTK_TREE_MODEL (sidebar->filter_model); + path = NULL; if (over_eject_button (sidebar, event->x, event->y, &path)) { update_eject_buttons (sidebar, path); + gtk_tree_path_free (path); } else { update_eject_buttons (sidebar, NULL); } - if (path) { - gtk_tree_path_free (path); - } - return TRUE; } -- cgit v1.2.1 From bf89f7f0ec597cfc2458338643f9c6c00e80689b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:33:02 +0200 Subject: [places-sidebar] don't update the icon if it's not visible This greatly reduces the number of times we have to create a pixbuf (only once-per-highlight now). http://git.gnome.org/browse/nautilus/commit/?id=6f5777b81958ce6f3dbc6bac3323d423d3dcc20b --- src/caja-places-sidebar.c | 58 ++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 21 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 78837dd3..714fe6dd 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -2654,6 +2654,9 @@ update_eject_buttons (CajaPlacesSidebar *sidebar, GtkTreePath *path) { GtkTreeIter iter; + gboolean icon_visible; + + icon_visible = TRUE; if (!path && !sidebar->eject_highlight_path) { /* Both are null - highlight up to date */ @@ -2667,37 +2670,50 @@ update_eject_buttons (CajaPlacesSidebar *sidebar, return; } - /* Reset last path */ - if (sidebar->eject_highlight_path) { - gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), - &iter, - sidebar->eject_highlight_path); - - gtk_list_store_set (GTK_LIST_STORE (sidebar->store), - &iter, - PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE), - -1); - - gtk_tree_path_free (sidebar->eject_highlight_path); - } - - /* Update current path */ if (path) { gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), &iter, path); - gtk_list_store_set (GTK_LIST_STORE (sidebar->store), + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, - PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), + PLACES_SIDEBAR_COLUMN_EJECT, &icon_visible, -1); } - if (path) { - sidebar->eject_highlight_path = gtk_tree_path_copy (path); - } else { - sidebar->eject_highlight_path = NULL; + if (!icon_visible || !path) { + /* remove highlighting and reset the saved path, as we are leaving + * an eject button area. + */ + if (sidebar->eject_highlight_path) { + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + sidebar->eject_highlight_path); + + gtk_list_store_set (sidebar->store, + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE), + -1); + + gtk_tree_path_free (sidebar->eject_highlight_path); + sidebar->eject_highlight_path = NULL; + } + + return; } + + /* add highlighting to the selected path, as the icon is visible and + * we're hovering it. + */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + path); + + gtk_list_store_set (sidebar->store, + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), + -1); + sidebar->eject_highlight_path = gtk_tree_path_copy (path); } static gboolean -- cgit v1.2.1 From c7814e5022409a72afe03743b0198d964e0338b5 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 11:35:52 +0200 Subject: [pathbar] release the highlight path on dispose http://git.gnome.org/browse/nautilus/commit/?id=fd75e8f5e8b160eaba22ca4ed7efc852dba612a0 --- src/caja-places-sidebar.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index 714fe6dd..e161a3e6 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -3012,20 +3012,22 @@ caja_places_sidebar_dispose (GObject *object) free_drag_data (sidebar); - if (sidebar->store != NULL) - { + if (sidebar->eject_highlight_path != NULL) { + gtk_tree_path_free (sidebar->eject_highlight_path); + sidebar->eject_highlight_path = NULL; + } + + if (sidebar->store != NULL) { g_object_unref (sidebar->store); sidebar->store = NULL; } - if (sidebar->volume_monitor != NULL) - { + if (sidebar->volume_monitor != NULL) { g_object_unref (sidebar->volume_monitor); sidebar->volume_monitor = NULL; } - if (sidebar->bookmarks != NULL) - { + if (sidebar->bookmarks != NULL) { g_object_unref (sidebar->bookmarks); sidebar->bookmarks = NULL; } -- cgit v1.2.1 From 5680dbcc4995bd860e0e7659481e3d2079b09382 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 13:14:25 +0200 Subject: [icon-info] add a method to fetch GIcons for user special dirs http://git.gnome.org/browse/nautilus/commit/?id=1df83c6586560a8ae5efc96037e673e52b4b119b --- libcaja-private/caja-icon-info.c | 27 +++++++++++++++++++++++++++ libcaja-private/caja-icon-info.h | 2 ++ libcaja-private/caja-icon-names.h | 9 +++++++++ 3 files changed, 38 insertions(+) diff --git a/libcaja-private/caja-icon-info.c b/libcaja-private/caja-icon-info.c index 7873ebfa..5d783877 100644 --- a/libcaja-private/caja-icon-info.c +++ b/libcaja-private/caja-icon-info.c @@ -21,6 +21,7 @@ #include #include #include "caja-icon-info.h" +#include "caja-icon-names.h" #include "caja-default-file-icon.h" #include #include @@ -778,3 +779,29 @@ caja_icon_theme_can_render (GThemedIcon *icon) return FALSE; } + +GIcon * +caja_user_special_directory_get_gicon (GUserDirectory directory) +{ + + #define ICON_CASE(x) \ + case G_USER_DIRECTORY_ ## x:\ + return g_themed_icon_new (CAJA_ICON_FOLDER_ ## x); + + switch (directory) { + + ICON_CASE (DESKTOP); + ICON_CASE (DOCUMENTS); + ICON_CASE (DOWNLOAD); + ICON_CASE (MUSIC); + ICON_CASE (PICTURES); + ICON_CASE (PUBLIC_SHARE); + ICON_CASE (TEMPLATES); + ICON_CASE (VIDEOS); + + default: + return g_themed_icon_new ("folder"); + } + + #undef ICON_CASE +} diff --git a/libcaja-private/caja-icon-info.h b/libcaja-private/caja-icon-info.h index d2bbc926..d4523d1a 100644 --- a/libcaja-private/caja-icon-info.h +++ b/libcaja-private/caja-icon-info.h @@ -91,6 +91,8 @@ extern "C" { guint caja_icon_get_emblem_size_for_icon_size (guint size); gboolean caja_icon_theme_can_render (GThemedIcon *icon); +GIcon * caja_user_special_directory_get_gicon (GUserDirectory directory); + #ifdef __cplusplus diff --git a/libcaja-private/caja-icon-names.h b/libcaja-private/caja-icon-names.h index d0598749..bb50a772 100644 --- a/libcaja-private/caja-icon-names.h +++ b/libcaja-private/caja-icon-names.h @@ -20,6 +20,15 @@ #define CAJA_ICON_EMBLEM_UNREADABLE "emblem-unreadable" #define CAJA_ICON_EMBLEM_SYMLINK "emblem-symbolic-link" +#define CAJA_ICON_FOLDER_DESKTOP "folder-documents" +#define CAJA_ICON_FOLDER_DOCUMENTS "folder-documents" +#define CAJA_ICON_FOLDER_DOWNLOAD "folder-download" +#define CAJA_ICON_FOLDER_MUSIC "folder-music" +#define CAJA_ICON_FOLDER_PICTURES "folder-pictures" +#define CAJA_ICON_FOLDER_PUBLIC_SHARE "folder-publicshare" +#define CAJA_ICON_FOLDER_TEMPLATES "folder-templates" +#define CAJA_ICON_FOLDER_VIDEOS "folder-videos" + /* Other icons */ #define CAJA_ICON_TEMPLATE "text-x-generic-template" -- cgit v1.2.1 From f30de91c1ccc7f3cbaeb3c00c0f89e4443b01238 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 13:16:20 +0200 Subject: [places-sidebar] fix eject button highlighting http://git.gnome.org/browse/nautilus/commit/?id=2d9d47254908533d1eb20e16e091f91310052e93 --- src/caja-places-sidebar.c | 56 ++++++++++++++++++++++++++++------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index e161a3e6..b836de94 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -2654,34 +2654,36 @@ update_eject_buttons (CajaPlacesSidebar *sidebar, GtkTreePath *path) { GtkTreeIter iter; - gboolean icon_visible; + gboolean icon_visible, path_same; icon_visible = TRUE; - if (!path && !sidebar->eject_highlight_path) { + if (path == NULL && sidebar->eject_highlight_path == NULL) { /* Both are null - highlight up to date */ return; } - if (path && - sidebar->eject_highlight_path && - gtk_tree_path_compare (sidebar->eject_highlight_path, path) == 0) { + path_same = (path != NULL) && + (sidebar->eject_highlight_path != NULL) && + (gtk_tree_path_compare (sidebar->eject_highlight_path, path) == 0); + + if (path_same) { /* Same path - highlight up to date */ return; } if (path) { - gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->filter_model), &iter, path); - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_EJECT, &icon_visible, -1); } - if (!icon_visible || !path) { + if (!icon_visible || path == NULL || !path_same) { /* remove highlighting and reset the saved path, as we are leaving * an eject button area. */ @@ -2694,26 +2696,32 @@ update_eject_buttons (CajaPlacesSidebar *sidebar, &iter, PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (FALSE), -1); + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model)); gtk_tree_path_free (sidebar->eject_highlight_path); sidebar->eject_highlight_path = NULL; } - return; + if (!icon_visible) { + return; + } } - /* add highlighting to the selected path, as the icon is visible and - * we're hovering it. - */ - gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), - &iter, - path); + if (path != NULL) { + /* add highlighting to the selected path, as the icon is visible and + * we're hovering it. + */ + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), + &iter, + path); + gtk_list_store_set (sidebar->store, + &iter, + PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), + -1); + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model)); - gtk_list_store_set (sidebar->store, - &iter, - PLACES_SIDEBAR_COLUMN_EJECT_ICON, get_eject_icon (TRUE), - -1); - sidebar->eject_highlight_path = gtk_tree_path_copy (path); + sidebar->eject_highlight_path = gtk_tree_path_copy (path); + } } static gboolean @@ -2730,11 +2738,13 @@ bookmarks_motion_event_cb (GtkWidget *widget, if (over_eject_button (sidebar, event->x, event->y, &path)) { update_eject_buttons (sidebar, path); gtk_tree_path_free (path); - } else { - update_eject_buttons (sidebar, NULL); + + return TRUE; } - return TRUE; + update_eject_buttons (sidebar, NULL); + + return FALSE; } /* Callback used when a button is pressed on the shortcuts list. -- cgit v1.2.1 From 938724fe165f8d1be66121b7d22c42ea3e258dbf Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 13:48:55 +0200 Subject: [places-sidebar] redesign the Places sidebar According to http://live.gnome.org/Nautilus/UIRoadmap/Places http://git.gnome.org/browse/nautilus/commit/?id=a59e586adf32eea64c9c4ae08a5482d2a9c37fb1 Small followup commits also included in this commit: icon-names: fix a typo http://git.gnome.org/browse/nautilus/commit/?id=2f847f37f429062d58df3927d10bc52c67a4524f sidebar: fix bookmark renaming http://git.gnome.org/browse/nautilus/commit/?id=1fdfa522da3e7c672fe4202c591a928c8796bb06 sidebar: add myself to the authors (Cosimo Cecchi ) http://git.gnome.org/browse/nautilus/commit/?id=0f7e56b5e0ae5134ed1d8caeadcb3c684ae7f661 sidebar: don't allow selecting headers http://git.gnome.org/browse/nautilus/commit/?id=8277ddc798fc78793364b54444fa53e9a287b5cc sidebar: don't try to add non-existing special dirs http://git.gnome.org/browse/nautilus/commit/?id=0f70ac4bb782b3c3fb0f5e8a24032cb344fdb2cc --- libcaja-private/caja-icon-names.h | 2 +- src/caja-places-sidebar.c | 820 ++++++++++++++++++++++++++------------ 2 files changed, 557 insertions(+), 265 deletions(-) diff --git a/libcaja-private/caja-icon-names.h b/libcaja-private/caja-icon-names.h index bb50a772..20aee326 100644 --- a/libcaja-private/caja-icon-names.h +++ b/libcaja-private/caja-icon-names.h @@ -20,7 +20,7 @@ #define CAJA_ICON_EMBLEM_UNREADABLE "emblem-unreadable" #define CAJA_ICON_EMBLEM_SYMLINK "emblem-symbolic-link" -#define CAJA_ICON_FOLDER_DESKTOP "folder-documents" +#define CAJA_ICON_FOLDER_DESKTOP "user-desktop" #define CAJA_ICON_FOLDER_DOCUMENTS "folder-documents" #define CAJA_ICON_FOLDER_DOWNLOAD "folder-download" #define CAJA_ICON_FOLDER_MUSIC "folder-music" diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index b836de94..eb05ba37 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -17,7 +17,8 @@ * along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. * - * Author : Mr Jamie McCracken (jamiemcc at blueyonder dot co dot uk) + * Authors : Mr Jamie McCracken (jamiemcc at blueyonder dot co dot uk) + * Cosimo Cecchi * */ @@ -52,14 +53,17 @@ #include "caja-places-sidebar.h" #include "caja-window.h" -#define EJECT_BUTTON_XPAD 5 +#define EJECT_BUTTON_XPAD 6 +#define ICON_CELL_XPAD 6 typedef struct { GtkScrolledWindow parent; GtkTreeView *tree_view; - GtkCellRenderer *icon_cell_renderer; GtkCellRenderer *eject_text_cell_renderer; + GtkCellRenderer *icon_cell_renderer; + GtkCellRenderer *icon_padding_cell_renderer; + GtkCellRenderer *padding_cell_renderer; char *uri; GtkListStore *store; GtkTreeModel *filter_model; @@ -67,6 +71,9 @@ typedef struct CajaBookmarkList *bookmarks; GVolumeMonitor *volume_monitor; + gboolean devices_header_added; + gboolean bookmarks_header_added; + /* DnD */ GList *drag_list; gboolean drag_data_received; @@ -123,9 +130,10 @@ enum PLACES_SIDEBAR_COLUMN_EJECT, PLACES_SIDEBAR_COLUMN_NO_EJECT, PLACES_SIDEBAR_COLUMN_BOOKMARK, - PLACES_SIDEBAR_COLUMN_NO_BOOKMARK, PLACES_SIDEBAR_COLUMN_TOOLTIP, PLACES_SIDEBAR_COLUMN_EJECT_ICON, + PLACES_SIDEBAR_COLUMN_SECTION_TYPE, + PLACES_SIDEBAR_COLUMN_HEADING_TEXT, PLACES_SIDEBAR_COLUMN_COUNT }; @@ -135,9 +143,16 @@ typedef enum PLACES_BUILT_IN, PLACES_MOUNTED_VOLUME, PLACES_BOOKMARK, - PLACES_SEPARATOR + PLACES_HEADING, } PlaceType; +typedef enum { + SECTION_DEVICES, + SECTION_BOOKMARKS, + SECTION_COMPUTER, + SECTION_NETWORK, +} SectionType; + static void caja_places_sidebar_iface_init (CajaSidebarIface *iface); static void sidebar_provider_iface_init (CajaSidebarProviderIface *iface); static GType caja_places_sidebar_provider_get_type (void); @@ -239,9 +254,82 @@ get_eject_icon (gboolean highlighted) return eject; } +static gboolean +is_built_in_bookmark (CajaFile *file) +{ + gboolean built_in; + gint idx; + + built_in = FALSE; + + for (idx = 0; idx < G_USER_N_DIRECTORIES; idx++) { + /* PUBLIC_SHARE and TEMPLATES are not in our built-in list */ + if (caja_file_is_user_special_directory (file, idx)) { + if (idx != G_USER_DIRECTORY_PUBLIC_SHARE && idx != G_USER_DIRECTORY_TEMPLATES) { + built_in = TRUE; + } + + break; + } + } + + return built_in; +} + +static GtkTreeIter +add_heading (CajaPlacesSidebar *sidebar, + SectionType section_type, + const gchar *title) +{ + GtkTreeIter iter, child_iter; + + gtk_list_store_append (sidebar->store, &iter); + gtk_list_store_set (sidebar->store, &iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, PLACES_HEADING, + PLACES_SIDEBAR_COLUMN_SECTION_TYPE, section_type, + PLACES_SIDEBAR_COLUMN_HEADING_TEXT, title, + PLACES_SIDEBAR_COLUMN_EJECT, FALSE, + PLACES_SIDEBAR_COLUMN_NO_EJECT, TRUE, + -1); + + gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (sidebar->filter_model)); + gtk_tree_model_filter_convert_child_iter_to_iter (GTK_TREE_MODEL_FILTER (sidebar->filter_model), + &child_iter, + &iter); + + return child_iter; +} + +static void +check_heading_for_section (CajaPlacesSidebar *sidebar, + SectionType section_type) +{ + switch (section_type) { + case SECTION_DEVICES: + if (!sidebar->devices_header_added) { + add_heading (sidebar, SECTION_DEVICES, + _("Devices")); + sidebar->devices_header_added = TRUE; + } + + break; + case SECTION_BOOKMARKS: + if (!sidebar->bookmarks_header_added) { + add_heading (sidebar, SECTION_BOOKMARKS, + _("Bookmarks")); + sidebar->bookmarks_header_added = TRUE; + } + + break; + default: + break; + } +} + static GtkTreeIter add_place (CajaPlacesSidebar *sidebar, PlaceType place_type, + SectionType section_type, const char *name, GIcon *icon, const char *uri, @@ -259,11 +347,14 @@ add_place (CajaPlacesSidebar *sidebar, gboolean show_eject, show_unmount; gboolean show_eject_button; + check_heading_for_section (sidebar, section_type); + icon_size = caja_get_icon_size_for_stock_size (GTK_ICON_SIZE_MENU); icon_info = caja_icon_info_lookup (icon, icon_size); pixbuf = caja_icon_info_get_pixbuf_at_size (icon_info, icon_size); g_object_unref (icon_info); + check_unmount_and_eject (mount, volume, drive, &show_unmount, &show_eject); @@ -281,7 +372,12 @@ add_place (CajaPlacesSidebar *sidebar, show_eject_button = (show_unmount || show_eject); } - eject = get_eject_icon (FALSE); + if (show_eject_button) { + eject = get_eject_icon (FALSE); + } else { + eject = NULL; + } + gtk_list_store_append (sidebar->store, &iter); gtk_list_store_set (sidebar->store, &iter, PLACES_SIDEBAR_COLUMN_ICON, pixbuf, @@ -295,9 +391,9 @@ add_place (CajaPlacesSidebar *sidebar, PLACES_SIDEBAR_COLUMN_EJECT, show_eject_button, PLACES_SIDEBAR_COLUMN_NO_EJECT, !show_eject_button, PLACES_SIDEBAR_COLUMN_BOOKMARK, place_type != PLACES_BOOKMARK, - PLACES_SIDEBAR_COLUMN_NO_BOOKMARK, place_type == PLACES_BOOKMARK, PLACES_SIDEBAR_COLUMN_TOOLTIP, tooltip, PLACES_SIDEBAR_COLUMN_EJECT_ICON, eject, + PLACES_SIDEBAR_COLUMN_SECTION_TYPE, section_type, -1); if (pixbuf != NULL) @@ -348,7 +444,7 @@ update_places (CajaPlacesSidebar *sidebar) { CajaBookmark *bookmark; GtkTreeSelection *selection; - GtkTreeIter iter, last_iter; + GtkTreeIter last_iter; GtkTreePath *select_path; GtkTreeModel *model; GVolumeMonitor *volume_monitor; @@ -360,10 +456,13 @@ update_places (CajaPlacesSidebar *sidebar) GVolume *volume; int bookmark_count, index; char *location, *mount_uri, *name, *desktop_path, *last_uri; + const gchar *path; GIcon *icon; GFile *root; CajaWindowSlotInfo *slot; char *tooltip; + GList *network_mounts; + CajaFile *file; model = NULL; last_uri = NULL; @@ -378,70 +477,17 @@ update_places (CajaPlacesSidebar *sidebar) } gtk_list_store_clear (sidebar->store); + sidebar->devices_header_added = FALSE; + sidebar->bookmarks_header_added = FALSE; + slot = caja_window_info_get_active_slot (sidebar->window); location = caja_window_slot_info_get_current_location (slot); - /* add built in bookmarks */ - desktop_path = caja_get_desktop_directory (); - - if (strcmp (g_get_home_dir(), desktop_path) != 0) - { - char *display_name; - - mount_uri = caja_get_home_directory_uri (); - display_name = g_filename_display_basename (g_get_home_dir ()); - icon = g_themed_icon_new (CAJA_ICON_HOME); - last_iter = add_place (sidebar, PLACES_BUILT_IN, - display_name, icon, - mount_uri, NULL, NULL, NULL, 0, - _("Open your personal folder")); - g_object_unref (icon); - g_free (display_name); - compare_for_selection (sidebar, - location, mount_uri, last_uri, - &last_iter, &select_path); - g_free (mount_uri); - } - - mount_uri = g_filename_to_uri (desktop_path, NULL, NULL); - icon = g_themed_icon_new (CAJA_ICON_DESKTOP); - last_iter = add_place (sidebar, PLACES_BUILT_IN, - _("Desktop"), icon, - mount_uri, NULL, NULL, NULL, 0, - _("Open the contents of your desktop in a folder")); - g_object_unref (icon); - compare_for_selection (sidebar, - location, mount_uri, last_uri, - &last_iter, &select_path); - g_free (mount_uri); - g_free (desktop_path); - - mount_uri = "file:///"; /* No need to strdup */ - icon = g_themed_icon_new (CAJA_ICON_FILESYSTEM); - last_iter = add_place (sidebar, PLACES_BUILT_IN, - _("File System"), icon, - mount_uri, NULL, NULL, NULL, 0, - _("Open the contents of the File System")); - g_object_unref (icon); - compare_for_selection (sidebar, - location, mount_uri, last_uri, - &last_iter, &select_path); - - mount_uri = "network:///"; /* No need to strdup */ - icon = g_themed_icon_new (CAJA_ICON_NETWORK); - last_iter = add_place (sidebar, PLACES_BUILT_IN, - _("Network"), icon, - mount_uri, NULL, NULL, NULL, 0, - _("Browse the contents of the network")); - g_object_unref (icon); - compare_for_selection (sidebar, - location, mount_uri, last_uri, - &last_iter, &select_path); - volume_monitor = sidebar->volume_monitor; /* first go through all connected drives */ drives = g_volume_monitor_get_connected_drives (volume_monitor); + for (l = drives; l != NULL; l = l->next) { drive = l->data; @@ -461,7 +507,9 @@ update_places (CajaPlacesSidebar *sidebar) mount_uri = g_file_get_uri (root); name = g_mount_get_name (mount); tooltip = g_file_get_parse_name (root); + last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME, + SECTION_DEVICES, name, icon, mount_uri, drive, volume, mount, 0, tooltip); compare_for_selection (sidebar, @@ -487,7 +535,9 @@ update_places (CajaPlacesSidebar *sidebar) icon = g_volume_get_icon (volume); name = g_volume_get_name (volume); tooltip = g_strdup_printf (_("Mount and open %s"), name); + last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME, + SECTION_DEVICES, name, icon, NULL, drive, volume, NULL, 0, tooltip); g_object_unref (icon); @@ -513,7 +563,9 @@ update_places (CajaPlacesSidebar *sidebar) icon = g_drive_get_icon (drive); name = g_drive_get_name (drive); tooltip = g_strdup_printf (_("Mount and open %s"), name); + last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_DEVICES, name, icon, NULL, drive, NULL, NULL, 0, tooltip); g_object_unref (icon); @@ -547,6 +599,7 @@ update_places (CajaPlacesSidebar *sidebar) g_object_unref (root); name = g_mount_get_name (mount); last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME, + SECTION_DEVICES, name, icon, mount_uri, NULL, volume, mount, 0, tooltip); compare_for_selection (sidebar, @@ -564,6 +617,7 @@ update_places (CajaPlacesSidebar *sidebar) icon = g_volume_get_icon (volume); name = g_volume_get_name (volume); last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME, + SECTION_DEVICES, name, icon, NULL, NULL, volume, NULL, 0, name); g_object_unref (icon); @@ -573,8 +627,140 @@ update_places (CajaPlacesSidebar *sidebar) } g_list_free (volumes); + /* add bookmarks */ + bookmark_count = caja_bookmark_list_length (sidebar->bookmarks); + + for (index = 0; index < bookmark_count; ++index) { + bookmark = caja_bookmark_list_item_at (sidebar->bookmarks, index); + + if (caja_bookmark_uri_known_not_to_exist (bookmark)) { + continue; + } + + root = caja_bookmark_get_location (bookmark); + file = caja_file_get (root); + + if (is_built_in_bookmark (file)) { + g_object_unref (root); + caja_file_unref (file); + continue; + } + + name = caja_bookmark_get_name (bookmark); + icon = caja_bookmark_get_icon (bookmark); + mount_uri = caja_bookmark_get_uri (bookmark); + tooltip = g_file_get_parse_name (root); + + last_iter = add_place (sidebar, PLACES_BOOKMARK, + SECTION_BOOKMARKS, + name, icon, mount_uri, + NULL, NULL, NULL, index, + tooltip); + compare_for_selection (sidebar, + location, mount_uri, last_uri, + &last_iter, &select_path); + g_free (name); + g_object_unref (root); + g_object_unref (icon); + g_free (mount_uri); + g_free (tooltip); + } + + last_iter = add_heading (sidebar, SECTION_COMPUTER, + _("Computer")); + + /* add built in bookmarks */ + desktop_path = caja_get_desktop_directory (); + + /* home folder */ + if (strcmp (g_get_home_dir(), desktop_path) != 0) { + char *display_name; + + mount_uri = caja_get_home_directory_uri (); + display_name = g_filename_display_basename (g_get_home_dir ()); + icon = g_themed_icon_new (CAJA_ICON_HOME); + last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_COMPUTER, + display_name, icon, + mount_uri, NULL, NULL, NULL, 0, + _("Open your personal folder")); + g_object_unref (icon); + g_free (display_name); + compare_for_selection (sidebar, + location, mount_uri, last_uri, + &last_iter, &select_path); + g_free (mount_uri); + } + + /* desktop */ + mount_uri = g_filename_to_uri (desktop_path, NULL, NULL); + icon = g_themed_icon_new (CAJA_ICON_DESKTOP); + last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_COMPUTER, + _("Desktop"), icon, + mount_uri, NULL, NULL, NULL, 0, + _("Open the contents of your desktop in a folder")); + g_object_unref (icon); + compare_for_selection (sidebar, + location, mount_uri, last_uri, + &last_iter, &select_path); + g_free (mount_uri); + g_free (desktop_path); + + /* file system root */ + mount_uri = "file:///"; /* No need to strdup */ + icon = g_themed_icon_new (CAJA_ICON_FILESYSTEM); + last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_COMPUTER, + _("File System"), icon, + mount_uri, NULL, NULL, NULL, 0, + _("Open the contents of the File System")); + g_object_unref (icon); + compare_for_selection (sidebar, + location, mount_uri, last_uri, + &last_iter, &select_path); + + + /* XDG directories */ + for (index = 0; index < G_USER_N_DIRECTORIES; index++) { + + if (index == G_USER_DIRECTORY_DESKTOP || + index == G_USER_DIRECTORY_TEMPLATES || + index == G_USER_DIRECTORY_PUBLIC_SHARE) { + continue; + } + + path = g_get_user_special_dir (index); + + if (!path) { + continue; + } + + root = g_file_new_for_path (path); + name = g_file_get_basename (root); + icon = caja_user_special_directory_get_gicon (index); + mount_uri = g_file_get_uri (root); + tooltip = g_file_get_parse_name (root); + + last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_COMPUTER, + name, icon, mount_uri, + NULL, NULL, NULL, 0, + tooltip); + compare_for_selection (sidebar, + location, mount_uri, last_uri, + &last_iter, &select_path); + g_free (name); + g_object_unref (root); + g_object_unref (icon); + g_free (mount_uri); + g_free (tooltip); + } + /* add mounts that has no volume (/etc/mtab mounts, ftp, sftp,...) */ + network_mounts = NULL; mounts = g_volume_monitor_get_mounts (volume_monitor); + for (l = mounts; l != NULL; l = l->next) { mount = l->data; @@ -590,12 +776,19 @@ update_places (CajaPlacesSidebar *sidebar) g_object_unref (mount); continue; } - icon = g_mount_get_icon (mount); root = g_mount_get_default_location (mount); + + if (!g_file_is_native (root)) { + network_mounts = g_list_prepend (network_mounts, g_object_ref (mount)); + continue; + } + + icon = g_mount_get_icon (mount); mount_uri = g_file_get_uri (root); name = g_mount_get_name (mount); tooltip = g_file_get_parse_name (root); last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME, + SECTION_COMPUTER, name, icon, mount_uri, NULL, NULL, mount, 0, tooltip); compare_for_selection (sidebar, @@ -613,6 +806,7 @@ update_places (CajaPlacesSidebar *sidebar) mount_uri = "trash:///"; /* No need to strdup */ icon = caja_trash_monitor_get_icon (); last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_COMPUTER, _("Trash"), icon, mount_uri, NULL, NULL, NULL, 0, _("Open the trash")); @@ -621,75 +815,61 @@ update_places (CajaPlacesSidebar *sidebar) &last_iter, &select_path); g_object_unref (icon); - /* add separator */ + /* network */ + last_iter = add_heading (sidebar, SECTION_NETWORK, + _("Network")); - gtk_list_store_append (sidebar->store, &iter); - gtk_list_store_set (sidebar->store, &iter, - PLACES_SIDEBAR_COLUMN_ROW_TYPE, PLACES_SEPARATOR, - -1); - - /* add bookmarks */ - - bookmark_count = caja_bookmark_list_length (sidebar->bookmarks); - for (index = 0; index < bookmark_count; ++index) - { - bookmark = caja_bookmark_list_item_at (sidebar->bookmarks, index); - - if (caja_bookmark_uri_known_not_to_exist (bookmark)) - { - continue; - } - - name = caja_bookmark_get_name (bookmark); - icon = caja_bookmark_get_icon (bookmark); - mount_uri = caja_bookmark_get_uri (bookmark); - root = caja_bookmark_get_location (bookmark); + network_mounts = g_list_reverse (network_mounts); + for (l = network_mounts; l != NULL; l = l->next) { + mount = l->data; + root = g_mount_get_default_location (mount); + icon = g_mount_get_icon (mount); + mount_uri = g_file_get_uri (root); + name = g_mount_get_name (mount); tooltip = g_file_get_parse_name (root); - last_iter = add_place (sidebar, PLACES_BOOKMARK, + last_iter = add_place (sidebar, PLACES_MOUNTED_VOLUME, + SECTION_NETWORK, name, icon, mount_uri, - NULL, NULL, NULL, index, - tooltip); + NULL, NULL, mount, 0, tooltip); compare_for_selection (sidebar, location, mount_uri, last_uri, &last_iter, &select_path); - g_free (name); g_object_unref (root); + g_object_unref (mount); g_object_unref (icon); + g_free (name); g_free (mount_uri); g_free (tooltip); } + + eel_g_object_list_free (network_mounts); + + /* network:// */ + mount_uri = "network:///"; /* No need to strdup */ + icon = g_themed_icon_new (CAJA_ICON_NETWORK); + last_iter = add_place (sidebar, PLACES_BUILT_IN, + SECTION_NETWORK, + _("Browse Network"), icon, + mount_uri, NULL, NULL, NULL, 0, + _("Browse the contents of the network")); + g_object_unref (icon); + compare_for_selection (sidebar, + location, mount_uri, last_uri, + &last_iter, &select_path); + g_free (location); - if (select_path != NULL) - { + if (select_path != NULL) { gtk_tree_selection_select_path (selection, select_path); } - if (select_path != NULL) - { + if (select_path != NULL) { gtk_tree_path_free (select_path); } g_free (last_uri); } -static gboolean -caja_shortcuts_row_separator_func (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - PlaceType type; - - gtk_tree_model_get (model, iter, PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, -1); - - if (type == PLACES_SEPARATOR) - { - return TRUE; - } - - return FALSE; -} - static void mount_added_callback (GVolumeMonitor *volume_monitor, GMount *mount, @@ -797,11 +977,21 @@ over_eject_button (CajaPlacesSidebar *sidebar, gtk_widget_style_get (GTK_WIDGET (sidebar->tree_view), "horizontal-separator", &width, NULL); - total_width += width / 2; + total_width += width; direction = gtk_widget_get_direction (GTK_WIDGET (sidebar->tree_view)); if (direction != GTK_TEXT_DIR_RTL) { gtk_tree_view_column_cell_get_position (column, + sidebar->padding_cell_renderer, + NULL, &width); + total_width += width; + + gtk_tree_view_column_cell_get_position (column, + sidebar->icon_padding_cell_renderer, + NULL, &width); + total_width += width; + + gtk_tree_view_column_cell_get_position (column, sidebar->icon_cell_renderer, NULL, &width); total_width += width; @@ -896,103 +1086,75 @@ loading_uri_callback (CajaWindowInfo *window, } } - -static unsigned int -get_bookmark_index (GtkTreeView *tree_view) +/* Computes the appropriate row and position for dropping */ +static gboolean +compute_drop_position (GtkTreeView *tree_view, + int x, + int y, + GtkTreePath **path, + GtkTreeViewDropPosition *pos, + CajaPlacesSidebar *sidebar) { GtkTreeModel *model; - GtkTreePath *p; GtkTreeIter iter; PlaceType place_type; - int bookmark_index; + SectionType section_type; + + if (!gtk_tree_view_get_dest_row_at_pos (tree_view, + x, + y, + path, + pos)) { + return FALSE; + } model = gtk_tree_view_get_model (tree_view); - bookmark_index = -1; + gtk_tree_model_get_iter (model, &iter, *path); + gtk_tree_model_get (model, &iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type, + PLACES_SIDEBAR_COLUMN_SECTION_TYPE, §ion_type, + -1); - /* find separator */ - p = gtk_tree_path_new_first (); - while (p != NULL) - { - gtk_tree_model_get_iter (model, &iter, p); - gtk_tree_model_get (model, &iter, - PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type, - -1); + if (place_type == PLACES_HEADING && section_type != SECTION_BOOKMARKS) { + /* never drop on headings, but special case the bookmarks heading, + * so we can drop bookmarks in between it and the first item. + */ - if (place_type == PLACES_SEPARATOR) - { - bookmark_index = *gtk_tree_path_get_indices (p) + 1; - break; - } + gtk_tree_path_free (*path); + *path = NULL; - gtk_tree_path_next (p); + return FALSE; } - gtk_tree_path_free (p); - - g_assert (bookmark_index >= 0); - return bookmark_index; -} + if (section_type != SECTION_BOOKMARKS && + sidebar->drag_data_received && + sidebar->drag_data_info == GTK_TREE_MODEL_ROW) { + /* don't allow dropping bookmarks into non-bookmark areas */ -/* Computes the appropriate row and position for dropping */ -static void -compute_drop_position (GtkTreeView *tree_view, - int x, - int y, - GtkTreePath **path, - GtkTreeViewDropPosition *pos, - CajaPlacesSidebar *sidebar) -{ - int bookmarks_index; - int num_rows; - int row; - - bookmarks_index = get_bookmark_index (tree_view); - - num_rows = gtk_tree_model_iter_n_children (GTK_TREE_MODEL (sidebar->filter_model), NULL); + gtk_tree_path_free (*path); + *path = NULL; - if (!gtk_tree_view_get_dest_row_at_pos (tree_view, - x, - y, - path, - pos)) - { - row = num_rows - 1; - *path = gtk_tree_path_new_from_indices (row, -1); - *pos = GTK_TREE_VIEW_DROP_AFTER; - return; + return FALSE; } - row = *gtk_tree_path_get_indices (*path); - gtk_tree_path_free (*path); - - if (row == bookmarks_index - 1) - { - /* Only allow to drop after separator */ + if (section_type == SECTION_BOOKMARKS) { *pos = GTK_TREE_VIEW_DROP_AFTER; - } - else if (row < bookmarks_index) - { - /* Hardcoded shortcuts can only be dragged into */ + } else { + /* non-bookmark shortcuts can only be dragged into */ *pos = GTK_TREE_VIEW_DROP_INTO_OR_BEFORE; } - else if (row >= num_rows) - { - row = num_rows - 1; - *pos = GTK_TREE_VIEW_DROP_AFTER; - } - else if (*pos != GTK_TREE_VIEW_DROP_BEFORE && - sidebar->drag_data_received && - sidebar->drag_data_info == GTK_TREE_MODEL_ROW) - { + + if (*pos != GTK_TREE_VIEW_DROP_BEFORE && + sidebar->drag_data_received && + sidebar->drag_data_info == GTK_TREE_MODEL_ROW) { /* bookmark rows are never dragged into other bookmark rows */ *pos = GTK_TREE_VIEW_DROP_AFTER; } - *path = gtk_tree_path_new_from_indices (row, -1); + return TRUE; } - static gboolean get_drag_data (GtkTreeView *tree_view, GdkDragContext *context, @@ -1030,7 +1192,8 @@ free_drag_data (CajaPlacesSidebar *sidebar) static gboolean can_accept_file_as_bookmark (CajaFile *file) { - return caja_file_is_directory (file); + return (caja_file_is_directory (file) && + !is_built_in_bookmark (file)); } static gboolean @@ -1069,8 +1232,9 @@ drag_motion_callback (GtkTreeView *tree_view, GtkTreePath *path; GtkTreeViewDropPosition pos; int action; - GtkTreeIter iter, child_iter; + GtkTreeIter iter; char *uri; + gboolean res; if (!sidebar->drag_data_received) { @@ -1080,7 +1244,12 @@ drag_motion_callback (GtkTreeView *tree_view, } } - compute_drop_position (tree_view, x, y, &path, &pos, sidebar); + path = NULL; + res = compute_drop_position (tree_view, x, y, &path, &pos, sidebar); + + if (!res) { + goto out; + } if (pos == GTK_TREE_VIEW_DROP_BEFORE || pos == GTK_TREE_VIEW_DROP_AFTER ) @@ -1109,11 +1278,8 @@ drag_motion_callback (GtkTreeView *tree_view, { gtk_tree_model_get_iter (sidebar->filter_model, &iter, path); - gtk_tree_model_filter_convert_iter_to_child_iter ( - GTK_TREE_MODEL_FILTER (sidebar->filter_model), - &child_iter, &iter); - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), - &child_iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), + &iter, PLACES_SIDEBAR_COLUMN_URI, &uri, -1); caja_drag_default_drop_action_for_icons (context, uri, @@ -1123,8 +1289,15 @@ drag_motion_callback (GtkTreeView *tree_view, } } - gtk_tree_view_set_drag_dest_row (tree_view, path, pos); - gtk_tree_path_free (path); + if (action != 0) { + gtk_tree_view_set_drag_dest_row (tree_view, path, pos); + } + + if (path != NULL) { + gtk_tree_path_free (path); + } + + out: g_signal_stop_emission_by_name (tree_view, "drag-motion"); if (action != 0) @@ -1250,17 +1423,10 @@ get_selected_iter (CajaPlacesSidebar *sidebar, GtkTreeIter *iter) { GtkTreeSelection *selection; - GtkTreeIter parent_iter; selection = gtk_tree_view_get_selection (sidebar->tree_view); - if (!gtk_tree_selection_get_selected (selection, NULL, &parent_iter)) - { - return FALSE; - } - gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (sidebar->filter_model), - iter, - &parent_iter); - return TRUE; + + return gtk_tree_selection_get_selected (selection, NULL, iter); } /* Reorders the selected bookmark to the specified position */ @@ -1277,7 +1443,7 @@ reorder_bookmarks (CajaPlacesSidebar *sidebar, if (!get_selected_iter (sidebar, &iter)) g_assert_not_reached (); - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, PLACES_SIDEBAR_COLUMN_INDEX, &old_position, -1); @@ -1311,7 +1477,8 @@ drag_data_received_callback (GtkWidget *widget, GtkTreeModel *model; char *drop_uri; GList *selection_list, *uris; - PlaceType type; + PlaceType place_type; + SectionType section_type; gboolean success; tree_view = GTK_TREE_VIEW (widget); @@ -1354,18 +1521,17 @@ drag_data_received_callback (GtkWidget *widget, } gtk_tree_model_get (model, &iter, - PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, + PLACES_SIDEBAR_COLUMN_SECTION_TYPE, §ion_type, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type, PLACES_SIDEBAR_COLUMN_INDEX, &position, -1); - if (type != PLACES_SEPARATOR && type != PLACES_BOOKMARK) - { + if (section_type != SECTION_BOOKMARKS) { goto out; } - if (type == PLACES_BOOKMARK && - tree_pos == GTK_TREE_VIEW_DROP_AFTER) - { + if (tree_pos == GTK_TREE_VIEW_DROP_AFTER && place_type != PLACES_HEADING) { + /* heading already has position 0 */ position++; } @@ -1572,7 +1738,7 @@ bookmarks_check_popup_sensitivity (CajaPlacesSidebar *sidebar) if (get_selected_iter (sidebar, &iter)) { - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, PLACES_SIDEBAR_COLUMN_VOLUME, &volume, @@ -1867,10 +2033,10 @@ rename_selected_bookmark (CajaPlacesSidebar *sidebar) if (get_selected_iter (sidebar, &iter)) { - path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->store), &iter); + path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->filter_model), &iter); column = gtk_tree_view_get_column (GTK_TREE_VIEW (sidebar->tree_view), 0); renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (column)); - cell = g_list_nth_data (renderers, 3); + cell = g_list_nth_data (renderers, 6); g_list_free (renderers); g_object_set (cell, "editable", TRUE, NULL); gtk_tree_view_set_cursor_on_cell (GTK_TREE_VIEW (sidebar->tree_view), @@ -1899,7 +2065,7 @@ remove_selected_bookmarks (CajaPlacesSidebar *sidebar) return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, -1); @@ -1908,7 +2074,7 @@ remove_selected_bookmarks (CajaPlacesSidebar *sidebar) return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_INDEX, &index, -1); @@ -1934,7 +2100,7 @@ mount_shortcut_cb (GtkMenuItem *item, return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_VOLUME, &volume, -1); @@ -1979,7 +2145,7 @@ do_unmount_selection (CajaPlacesSidebar *sidebar) return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_MOUNT, &mount, -1); @@ -2134,7 +2300,7 @@ eject_shortcut_cb (GtkMenuItem *item, return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_MOUNT, &mount, PLACES_SIDEBAR_COLUMN_VOLUME, &volume, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, @@ -2204,14 +2370,12 @@ eject_or_unmount_selection (CajaPlacesSidebar *sidebar) GtkTreePath *path; gboolean ret; - if (!get_selected_iter (sidebar, &iter)) - { + if (!get_selected_iter (sidebar, &iter)) { return FALSE; } - path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->store), &iter); - if (path == NULL) - { + path = gtk_tree_model_get_path (GTK_TREE_MODEL (sidebar->filter_model), &iter); + if (path == NULL) { return FALSE; } @@ -2260,7 +2424,7 @@ rescan_shortcut_cb (GtkMenuItem *item, return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, -1); @@ -2316,7 +2480,7 @@ start_shortcut_cb (GtkMenuItem *item, return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, -1); @@ -2376,7 +2540,7 @@ stop_shortcut_cb (GtkMenuItem *item, return; } - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_DRIVE, &drive, -1); @@ -2810,8 +2974,8 @@ bookmarks_edited (GtkCellRenderer *cell, g_object_set (cell, "editable", FALSE, NULL); path = gtk_tree_path_new_from_string (path_string); - gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->store), &iter, path); - gtk_tree_model_get (GTK_TREE_MODEL (sidebar->store), &iter, + gtk_tree_model_get_iter (GTK_TREE_MODEL (sidebar->filter_model), &iter, path); + gtk_tree_model_get (GTK_TREE_MODEL (sidebar->filter_model), &iter, PLACES_SIDEBAR_COLUMN_INDEX, &index, -1); gtk_tree_path_free (path); @@ -2845,6 +3009,107 @@ trash_state_changed_cb (CajaTrashMonitor *trash_monitor, bookmarks_check_popup_sensitivity (sidebar); } +static gboolean +tree_selection_func (GtkTreeSelection *selection, + GtkTreeModel *model, + GtkTreePath *path, + gboolean path_currently_selected, + gpointer user_data) +{ + GtkTreeIter iter; + PlaceType row_type; + + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &row_type, + -1); + + if (row_type == PLACES_HEADING) { + return FALSE; + } + + return TRUE; +} + +static void +icon_cell_renderer_func (GtkTreeViewColumn *column, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer user_data) +{ + CajaPlacesSidebar *sidebar; + PlaceType type; + + sidebar = user_data; + + gtk_tree_model_get (model, iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, + -1); + + if (type == PLACES_HEADING) { + g_object_set (cell, + "visible", FALSE, + NULL); + } else { + g_object_set (cell, + "visible", TRUE, + NULL); + } +} + +static void +padding_cell_renderer_func (GtkTreeViewColumn *column, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer user_data) +{ + PlaceType type; + + gtk_tree_model_get (model, iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, + -1); + + if (type == PLACES_HEADING) { + g_object_set (cell, + "visible", FALSE, + "xpad", 0, + "ypad", 0, + NULL); + } else { + g_object_set (cell, + "visible", TRUE, + "xpad", 3, + "ypad", 3, + NULL); + } +} + +static void +heading_cell_renderer_func (GtkTreeViewColumn *column, + GtkCellRenderer *cell, + GtkTreeModel *model, + GtkTreeIter *iter, + gpointer user_data) +{ + PlaceType type; + + gtk_tree_model_get (model, iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &type, + -1); + + if (type == PLACES_HEADING) { + g_object_set (cell, + "visible", TRUE, + NULL); + } else { + g_object_set (cell, + "visible", FALSE, + NULL); + } +} + static void caja_places_sidebar_init (CajaPlacesSidebar *sidebar) { @@ -2868,14 +3133,50 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) col = GTK_TREE_VIEW_COLUMN (gtk_tree_view_column_new ()); + /* initial padding */ + cell = gtk_cell_renderer_text_new (); + sidebar->padding_cell_renderer = cell; + gtk_tree_view_column_pack_start (col, cell, FALSE); + g_object_set (cell, + "xpad", 6, + NULL); + + /* headings */ + cell = gtk_cell_renderer_text_new (); + gtk_tree_view_column_pack_start (col, cell, FALSE); + gtk_tree_view_column_set_attributes (col, cell, + "text", PLACES_SIDEBAR_COLUMN_HEADING_TEXT, + NULL); + g_object_set (cell, + "weight", PANGO_WEIGHT_BOLD, + "weight-set", TRUE, + "ypad", 6, + "xpad", 0, + NULL); + gtk_tree_view_column_set_cell_data_func (col, cell, + heading_cell_renderer_func, + sidebar, NULL); + + /* icon padding */ + cell = gtk_cell_renderer_text_new (); + sidebar->icon_padding_cell_renderer = cell; + gtk_tree_view_column_pack_start (col, cell, FALSE); + gtk_tree_view_column_set_cell_data_func (col, cell, + padding_cell_renderer_func, + sidebar, NULL); + + /* icon renderer */ cell = gtk_cell_renderer_pixbuf_new (); sidebar->icon_cell_renderer = cell; gtk_tree_view_column_pack_start (col, cell, FALSE); gtk_tree_view_column_set_attributes (col, cell, "pixbuf", PLACES_SIDEBAR_COLUMN_ICON, NULL); + gtk_tree_view_column_set_cell_data_func (col, cell, + icon_cell_renderer_func, + sidebar, NULL); - + /* eject text renderer */ cell = gtk_cell_renderer_text_new (); sidebar->eject_text_cell_renderer = cell; gtk_tree_view_column_pack_start (col, cell, TRUE); @@ -2888,7 +3189,7 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) "ellipsize-set", TRUE, NULL); - + /* eject icon renderer */ cell = gtk_cell_renderer_pixbuf_new (); g_object_set (cell, "mode", GTK_CELL_RENDERER_MODE_ACTIVATABLE, @@ -2901,6 +3202,7 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) "pixbuf", PLACES_SIDEBAR_COLUMN_EJECT_ICON, NULL); + /* normal text renderer */ cell = gtk_cell_renderer_text_new (); gtk_tree_view_column_pack_start (col, cell, TRUE); g_object_set (G_OBJECT (cell), "editable", FALSE, NULL); @@ -2919,11 +3221,6 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) g_signal_connect (cell, "editing-canceled", G_CALLBACK (bookmarks_editing_canceled), sidebar); - gtk_tree_view_set_row_separator_func (tree_view, - caja_shortcuts_row_separator_func, - NULL, - NULL); - /* this is required to align the eject buttons to the right */ gtk_tree_view_column_set_max_width (GTK_TREE_VIEW_COLUMN (col), CAJA_ICON_SIZE_SMALLER); gtk_tree_view_append_column (tree_view, col); @@ -2939,11 +3236,11 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) G_TYPE_INT, G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, - G_TYPE_BOOLEAN, G_TYPE_BOOLEAN, G_TYPE_STRING, - GDK_TYPE_PIXBUF - ); + GDK_TYPE_PIXBUF, + G_TYPE_INT, + G_TYPE_STRING); gtk_tree_view_set_tooltip_column (tree_view, PLACES_SIDEBAR_COLUMN_TOOLTIP); @@ -2962,6 +3259,11 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) selection = gtk_tree_view_get_selection (tree_view); gtk_tree_selection_set_mode (selection, GTK_SELECTION_BROWSE); + gtk_tree_selection_set_select_function (selection, + tree_selection_func, + sidebar, + NULL); + gtk_tree_view_enable_model_drag_source (GTK_TREE_VIEW (tree_view), GDK_BUTTON1_MASK, caja_shortcuts_source_targets, @@ -2983,6 +3285,7 @@ caja_places_sidebar_init (CajaPlacesSidebar *sidebar) G_CALLBACK (drag_data_received_callback), sidebar); g_signal_connect (tree_view, "drag-drop", G_CALLBACK (drag_drop_callback), sidebar); + g_signal_connect (selection, "changed", G_CALLBACK (bookmarks_selection_changed_cb), sidebar); g_signal_connect (tree_view, "popup-menu", @@ -3207,31 +3510,21 @@ static gboolean caja_shortcuts_model_filter_row_draggable (GtkTreeDragSource *drag_source, GtkTreePath *path) { - CajaShortcutsModelFilter *model; - int pos; - int bookmarks_pos; - int num_bookmarks; - - model = CAJA_SHORTCUTS_MODEL_FILTER (drag_source); - - pos = *gtk_tree_path_get_indices (path); - bookmarks_pos = get_bookmark_index (model->sidebar->tree_view); - num_bookmarks = caja_bookmark_list_length (model->sidebar->bookmarks); - - return (pos >= bookmarks_pos && pos < bookmarks_pos + num_bookmarks); -} + GtkTreeModel *model; + GtkTreeIter iter; + PlaceType place_type; + SectionType section_type; -/* GtkTreeDragSource::drag_data_get implementation for the shortcuts filter model */ -static gboolean -caja_shortcuts_model_filter_drag_data_get (GtkTreeDragSource *drag_source, - GtkTreePath *path, - GtkSelectionData *selection_data) -{ - CajaShortcutsModelFilter *model; + model = GTK_TREE_MODEL (drag_source); - model = CAJA_SHORTCUTS_MODEL_FILTER (drag_source); + gtk_tree_model_get_iter (model, &iter, path); + gtk_tree_model_get (model, &iter, + PLACES_SIDEBAR_COLUMN_ROW_TYPE, &place_type, + PLACES_SIDEBAR_COLUMN_SECTION_TYPE, §ion_type, + -1); - /* FIXME */ + if (place_type != PLACES_HEADING && section_type == SECTION_BOOKMARKS) + return TRUE; return FALSE; } @@ -3241,7 +3534,6 @@ static void caja_shortcuts_model_filter_drag_source_iface_init (GtkTreeDragSourceIface *iface) { iface->row_draggable = caja_shortcuts_model_filter_row_draggable; - iface->drag_data_get = caja_shortcuts_model_filter_drag_data_get; } static GtkTreeModel * -- cgit v1.2.1 From 6297e7ac4167b57e0e3076ae2648cdced4c2a5b8 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 04:51:45 +0200 Subject: [connect-dialog] don't use EEL boilerplate http://git.gnome.org/browse/nautilus/commit/?id=f233f2aeb78e5fd14c0b18f7a3c5e80b5e7c84c5 --- src/caja-connect-server-dialog.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index 3737a15b..fc0ebac2 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -25,9 +25,7 @@ #include "caja-connect-server-dialog.h" #include -#include #include -#include #include #include #include @@ -66,12 +64,9 @@ struct _CajaConnectServerDialogDetails GtkWidget *name_entry; }; -static void caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class); -static void caja_connect_server_dialog_init (CajaConnectServerDialog *dialog); +G_DEFINE_TYPE (CajaConnectServerDialog, caja_connect_server_dialog, + GTK_TYPE_DIALOG) -EEL_CLASS_BOILERPLATE (CajaConnectServerDialog, - caja_connect_server_dialog, - GTK_TYPE_DIALOG) enum { RESPONSE_CONNECT @@ -171,19 +166,7 @@ caja_connect_server_dialog_finalize (GObject *object) g_object_unref (dialog->details->bookmark_check); g_object_unref (dialog->details->name_entry); - g_free (dialog->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -static void -caja_connect_server_dialog_destroy (GtkObject *object) -{ - CajaConnectServerDialog *dialog; - - dialog = CAJA_CONNECT_SERVER_DIALOG (object); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object); } static void @@ -404,13 +387,11 @@ static void caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class) { GObjectClass *gobject_class; - GtkObjectClass *object_class; + + g_type_class_add_private (class, sizeof (CajaConnectServerDialogDetails)); gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = caja_connect_server_dialog_finalize; - - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = caja_connect_server_dialog_destroy; } static void @@ -874,7 +855,8 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) GtkCellRenderer *renderer; int i; - dialog->details = g_new0 (CajaConnectServerDialogDetails, 1); + dialog->details = G_TYPE_INSTANCE_GET_PRIVATE (dialog, CAJA_TYPE_CONNECT_SERVER_DIALOG, + CajaConnectServerDialogDetails); gtk_window_set_title (GTK_WINDOW (dialog), _("Connect to Server")); gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); -- cgit v1.2.1 From 9cc5e9489fd7285759d7f4ed0d43028dabc7bd87 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 14:49:53 +0200 Subject: [fm-properties] use right link for the 'Media' help page preferences: use right link for the 'Media' help page (#564866). http://git.gnome.org/browse/nautilus/commit/?id=46544c9885b7064c216f1a9401d42bdb9816bdd2 --- src/caja-file-management-properties.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 438ce08a..824e6798 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -262,6 +262,10 @@ caja_file_management_properties_dialog_response_cb (GtkDialog *parent, break; case 4: section = "goscaja-60"; + break; + case 5: + section = "goscaja-61"; + break; } preferences_show_help (GTK_WINDOW (parent), "user-guide", section); } -- cgit v1.2.1 From 0819a3d1982403935eb70b958ad515494d1b9a0a Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 22:52:00 +0200 Subject: [lc-p/fm] Replace deprecated GDK_DISPLAY with GDK_DISPLAY_XDISPLAY Don't use GDK_DISPLAY () http://git.gnome.org/browse/nautilus/commit/?id=b66ce0fd23500f9727c1aac93366430285575697 --- libcaja-private/caja-autorun.c | 3 ++- src/file-manager/fm-desktop-icon-view.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index cf801b08..d78f402d 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -747,7 +747,8 @@ is_shift_pressed (void) ret = FALSE; gdk_error_trap_push (); - status = XkbGetState (GDK_DISPLAY (), XkbUseCoreKbd, &state); + status = XkbGetState (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), + XkbUseCoreKbd, &state); gdk_error_trap_pop (); if (status == Success) diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index ae9e4c02..37b88378 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -352,7 +352,7 @@ fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container, /* build an X event to represent the middle click. */ x_event.type = ButtonPress; x_event.send_event = True; - x_event.display = GDK_DISPLAY (); + x_event.display = GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()); x_event.window = GDK_ROOT_WINDOW (); x_event.root = GDK_ROOT_WINDOW (); x_event.subwindow = 0; @@ -366,7 +366,7 @@ fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container, x_event.same_screen = True; /* Send it to the root window, the window manager will handle it. */ - XSendEvent (GDK_DISPLAY (), GDK_ROOT_WINDOW (), True, + XSendEvent (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), GDK_ROOT_WINDOW (), True, ButtonPressMask, (XEvent *) &x_event); } -- cgit v1.2.1 From 40cd5a93ced42275631a3d86ad68219aa73cb7a3 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 22:56:14 +0200 Subject: [all] Don't use gtk_dialog_set_has_separator() http://git.gnome.org/browse/nautilus/commit/?id=73e2941f9b837d5d0326e6e88caa7a1e3fdcabeb --- libcaja-private/caja-autorun.c | 1 - libcaja-private/caja-file-conflict-dialog.c | 1 - libcaja-private/caja-open-with-dialog.c | 1 - src/caja-connect-server-dialog.c | 1 - src/caja-location-dialog.c | 1 - src/caja-query-editor.c | 2 +- src/file-manager/fm-directory-view.c | 5 ++--- src/file-manager/fm-properties-window.c | 1 - 8 files changed, 3 insertions(+), 10 deletions(-) diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index d78f402d..bfb26968 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -993,7 +993,6 @@ show_dialog: dialog = gtk_dialog_new (); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); hbox = gtk_hbox_new (FALSE, 12); gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), hbox, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (hbox), 12); diff --git a/libcaja-private/caja-file-conflict-dialog.c b/libcaja-private/caja-file-conflict-dialog.c index c1769960..e3419c7c 100644 --- a/libcaja-private/caja-file-conflict-dialog.c +++ b/libcaja-private/caja-file-conflict-dialog.c @@ -657,7 +657,6 @@ caja_file_conflict_dialog_init (CajaFileConflictDialog *fcd) gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (dialog)), 14); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - gtk_dialog_set_has_separator (dialog, FALSE); gtk_widget_show_all (dialog_area); } diff --git a/libcaja-private/caja-open-with-dialog.c b/libcaja-private/caja-open-with-dialog.c index 8f236d5e..dcd601bc 100644 --- a/libcaja-private/caja-open-with-dialog.c +++ b/libcaja-private/caja-open-with-dialog.c @@ -850,7 +850,6 @@ caja_open_with_dialog_init (CajaOpenWithDialog *dialog) dialog->details = g_new0 (CajaOpenWithDialogDetails, 1); gtk_window_set_title (GTK_WINDOW (dialog), _("Open With")); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index fc0ebac2..2a855eb4 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -859,7 +859,6 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) CajaConnectServerDialogDetails); gtk_window_set_title (GTK_WINDOW (dialog), _("Connect to Server")); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); diff --git a/src/caja-location-dialog.c b/src/caja-location-dialog.c index b80230cd..99596b87 100644 --- a/src/caja-location-dialog.c +++ b/src/caja-location-dialog.c @@ -174,7 +174,6 @@ caja_location_dialog_init (CajaLocationDialog *dialog) gtk_window_set_title (GTK_WINDOW (dialog), _("Open Location")); gtk_window_set_default_size (GTK_WINDOW (dialog), 300, -1); gtk_window_set_destroy_with_parent (GTK_WINDOW (dialog), TRUE); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c index dcd4416a..44425df3 100644 --- a/src/caja-query-editor.c +++ b/src/caja-query-editor.c @@ -587,7 +587,7 @@ type_combo_changed (GtkComboBox *combo_box, CajaQueryEditorRow *row) toplevel = gtk_widget_get_toplevel (GTK_WIDGET (combo_box)); dialog = gtk_dialog_new_with_buttons (_("Select type"), GTK_WINDOW (toplevel), - GTK_DIALOG_NO_SEPARATOR, + 0, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); gtk_window_set_default_size (GTK_WINDOW (dialog), 400, 600); diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 72a41a31..51737db5 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -1204,7 +1204,6 @@ select_pattern (FMDirectoryView *view) NULL); gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); @@ -1334,7 +1333,7 @@ action_save_search_as_callback (GtkAction *action, dialog = gtk_dialog_new_with_buttons (_("Save Search as"), fm_directory_view_get_containing_window (directory_view), - GTK_DIALOG_NO_SEPARATOR, + 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); save_button = gtk_dialog_add_button (GTK_DIALOG (dialog), @@ -6901,7 +6900,7 @@ action_connect_to_server_link_callback (GtkAction *action, title = g_strdup_printf (_("Connect to Server %s"), name); dialog = gtk_dialog_new_with_buttons (title, fm_directory_view_get_containing_window (view), - GTK_DIALOG_NO_SEPARATOR, + 0, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Connect"), GTK_RESPONSE_OK, NULL); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index f44b4a43..98e52b8f 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -5234,7 +5234,6 @@ create_properties_window (StartupData *startup_data) gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_content_area (GTK_DIALOG (window))), 12); gtk_container_set_border_width (GTK_CONTAINER (gtk_dialog_get_action_area (GTK_DIALOG (window))), 0); gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (window))), 12); - gtk_dialog_set_has_separator (GTK_DIALOG (window), FALSE); /* Update from initial state */ properties_window_update (window, NULL); -- cgit v1.2.1 From 42e70735c78d12d88ff9ec2d1c44d3edbadd29b5 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 13:56:30 +0200 Subject: [editable-label|entry] use GtkEditableClass on GTK2, GtkEditableInterface on GTK3 editable-label: rename GtkEditableClass->GtkEditableInterface http://git.gnome.org/browse/nautilus/commit/?id=a58bbde4ca6b11eeb1bca5fa4e62e60c0b26271b entry: rename GtkEditableClass->GtkEditableInterface http://git.gnome.org/browse/nautilus/commit/?id=aeb53075ed55dc2a2ef3228917ded1b8029bfdff --- eel/eel-editable-label.c | 5 +++-- libcaja-private/caja-entry.c | 10 +++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 50329345..08128009 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -41,6 +41,7 @@ #if !GTK_CHECK_VERSION (3, 0, 0) #define cairo_region_t GdkRegion #define cairo_region_destroy gdk_region_destroy +#define GtkEditableInterface GtkEditableClass #endif enum @@ -67,7 +68,7 @@ enum static guint signals[LAST_SIGNAL] = { 0 }; -static void eel_editable_label_editable_init (GtkEditableClass *iface); +static void eel_editable_label_editable_init (GtkEditableInterface *iface); static void eel_editable_label_class_init (EelEditableLabelClass *klass); static void eel_editable_label_init (EelEditableLabel *label); static void eel_editable_label_set_property (GObject *object, @@ -514,7 +515,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) } static void -eel_editable_label_editable_init (GtkEditableClass *iface) +eel_editable_label_editable_init (GtkEditableInterface *iface) { iface->do_insert_text = editable_insert_text_emit; iface->do_delete_text = editable_delete_text_emit; diff --git a/libcaja-private/caja-entry.c b/libcaja-private/caja-entry.c index 31b590c3..fa3669eb 100644 --- a/libcaja-private/caja-entry.c +++ b/libcaja-private/caja-entry.c @@ -35,6 +35,10 @@ #include #include +#if !GTK_CHECK_VERSION(3, 0, 0) +#define GtkEditableInterface GtkEditableClass +#endif + struct CajaEntryDetails { gboolean user_edit; @@ -51,13 +55,13 @@ enum }; static guint signals[LAST_SIGNAL]; -static void caja_entry_editable_init (GtkEditableClass *iface); +static void caja_entry_editable_init (GtkEditableInterface *iface); G_DEFINE_TYPE_WITH_CODE (CajaEntry, caja_entry, GTK_TYPE_ENTRY, G_IMPLEMENT_INTERFACE (GTK_TYPE_EDITABLE, caja_entry_editable_init)); -static GtkEditableClass *parent_editable_interface = NULL; +static GtkEditableInterface *parent_editable_interface = NULL; static void caja_entry_init (CajaEntry *entry) @@ -373,7 +377,7 @@ caja_entry_selection_clear (GtkWidget *widget, } static void -caja_entry_editable_init (GtkEditableClass *iface) +caja_entry_editable_init (GtkEditableInterface *iface) { parent_editable_interface = g_type_interface_peek_parent (iface); -- cgit v1.2.1 From aa81b74fa5297c28f6a83f926c1b6587781c7603 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 14:05:08 +0200 Subject: [eel-editable-label] convert to new GDK_KEY prefix http://git.gnome.org/browse/nautilus/commit/?id=499c54a20b64051e427ff5746fc7c8dd1a1885c2 --- eel/eel-editable-label.c | 86 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 43 deletions(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 08128009..7ed8b521 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -363,154 +363,154 @@ eel_editable_label_class_init (EelEditableLabelClass *class) binding_set = gtk_binding_set_by_class (class); /* Moving the insertion point */ - add_move_binding (binding_set, GDK_Right, 0, + add_move_binding (binding_set, GDK_KEY_Right, 0, GTK_MOVEMENT_VISUAL_POSITIONS, 1); - add_move_binding (binding_set, GDK_Left, 0, + add_move_binding (binding_set, GDK_KEY_Left, 0, GTK_MOVEMENT_VISUAL_POSITIONS, -1); - add_move_binding (binding_set, GDK_KP_Right, 0, + add_move_binding (binding_set, GDK_KEY_KP_Right, 0, GTK_MOVEMENT_VISUAL_POSITIONS, 1); - add_move_binding (binding_set, GDK_KP_Left, 0, + add_move_binding (binding_set, GDK_KEY_KP_Left, 0, GTK_MOVEMENT_VISUAL_POSITIONS, -1); - add_move_binding (binding_set, GDK_f, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, GTK_MOVEMENT_LOGICAL_POSITIONS, 1); - add_move_binding (binding_set, GDK_b, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_b, GDK_CONTROL_MASK, GTK_MOVEMENT_LOGICAL_POSITIONS, -1); - add_move_binding (binding_set, GDK_Right, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_Right, GDK_CONTROL_MASK, GTK_MOVEMENT_WORDS, 1); - add_move_binding (binding_set, GDK_Left, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_Left, GDK_CONTROL_MASK, GTK_MOVEMENT_WORDS, -1); - add_move_binding (binding_set, GDK_KP_Right, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_KP_Right, GDK_CONTROL_MASK, GTK_MOVEMENT_WORDS, 1); - add_move_binding (binding_set, GDK_KP_Left, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_KP_Left, GDK_CONTROL_MASK, GTK_MOVEMENT_WORDS, -1); - add_move_binding (binding_set, GDK_a, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_a, GDK_CONTROL_MASK, GTK_MOVEMENT_PARAGRAPH_ENDS, -1); - add_move_binding (binding_set, GDK_e, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_e, GDK_CONTROL_MASK, GTK_MOVEMENT_PARAGRAPH_ENDS, 1); - add_move_binding (binding_set, GDK_f, GDK_MOD1_MASK, + add_move_binding (binding_set, GDK_KEY_f, GDK_MOD1_MASK, GTK_MOVEMENT_WORDS, 1); - add_move_binding (binding_set, GDK_b, GDK_MOD1_MASK, + add_move_binding (binding_set, GDK_KEY_b, GDK_MOD1_MASK, GTK_MOVEMENT_WORDS, -1); - add_move_binding (binding_set, GDK_Home, 0, + add_move_binding (binding_set, GDK_KEY_Home, 0, GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1); - add_move_binding (binding_set, GDK_End, 0, + add_move_binding (binding_set, GDK_KEY_End, 0, GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1); - add_move_binding (binding_set, GDK_KP_Home, 0, + add_move_binding (binding_set, GDK_KEY_KP_Home, 0, GTK_MOVEMENT_DISPLAY_LINE_ENDS, -1); - add_move_binding (binding_set, GDK_KP_End, 0, + add_move_binding (binding_set, GDK_KEY_KP_End, 0, GTK_MOVEMENT_DISPLAY_LINE_ENDS, 1); - add_move_binding (binding_set, GDK_Home, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_Home, GDK_CONTROL_MASK, GTK_MOVEMENT_BUFFER_ENDS, -1); - add_move_binding (binding_set, GDK_End, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_End, GDK_CONTROL_MASK, GTK_MOVEMENT_BUFFER_ENDS, 1); - add_move_binding (binding_set, GDK_KP_Home, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_KP_Home, GDK_CONTROL_MASK, GTK_MOVEMENT_BUFFER_ENDS, -1); - add_move_binding (binding_set, GDK_KP_End, GDK_CONTROL_MASK, + add_move_binding (binding_set, GDK_KEY_KP_End, GDK_CONTROL_MASK, GTK_MOVEMENT_BUFFER_ENDS, 1); - add_move_binding (binding_set, GDK_Up, 0, + add_move_binding (binding_set, GDK_KEY_Up, 0, GTK_MOVEMENT_DISPLAY_LINES, -1); - add_move_binding (binding_set, GDK_KP_Up, 0, + add_move_binding (binding_set, GDK_KEY_KP_Up, 0, GTK_MOVEMENT_DISPLAY_LINES, -1); - add_move_binding (binding_set, GDK_Down, 0, + add_move_binding (binding_set, GDK_KEY_Down, 0, GTK_MOVEMENT_DISPLAY_LINES, 1); - add_move_binding (binding_set, GDK_KP_Down, 0, + add_move_binding (binding_set, GDK_KEY_KP_Down, 0, GTK_MOVEMENT_DISPLAY_LINES, 1); /* Select all */ - gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK, "move_cursor", 3, GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS, G_TYPE_INT, -1, G_TYPE_BOOLEAN, FALSE); - gtk_binding_entry_add_signal (binding_set, GDK_a, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_a, GDK_CONTROL_MASK, "move_cursor", 3, GTK_TYPE_MOVEMENT_STEP, GTK_MOVEMENT_BUFFER_ENDS, G_TYPE_INT, 1, G_TYPE_BOOLEAN, TRUE); /* Deleting text */ - gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_CHARS, G_TYPE_INT, 1); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_CHARS, G_TYPE_INT, 1); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_CHARS, G_TYPE_INT, -1); /* Make this do the same as Backspace, to help with mis-typing */ - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_CHARS, G_TYPE_INT, -1); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_CONTROL_MASK, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_WORD_ENDS, G_TYPE_INT, 1); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_CONTROL_MASK, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_WORD_ENDS, G_TYPE_INT, 1); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "delete_from_cursor", 2, G_TYPE_ENUM, GTK_DELETE_WORD_ENDS, G_TYPE_INT, -1); /* Cut/copy/paste */ - gtk_binding_entry_add_signal (binding_set, GDK_x, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_x, GDK_CONTROL_MASK, "cut_clipboard", 0); - gtk_binding_entry_add_signal (binding_set, GDK_c, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_c, GDK_CONTROL_MASK, "copy_clipboard", 0); - gtk_binding_entry_add_signal (binding_set, GDK_v, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_v, GDK_CONTROL_MASK, "paste_clipboard", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_SHIFT_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK, "cut_clipboard", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_CONTROL_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_CONTROL_MASK, "copy_clipboard", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Insert, GDK_SHIFT_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, GDK_SHIFT_MASK, "paste_clipboard", 0); /* Overwrite */ - gtk_binding_entry_add_signal (binding_set, GDK_Insert, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Insert, 0, "toggle_overwrite", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, 0, "toggle_overwrite", 0); } -- cgit v1.2.1 From 99699a1670fa6281cea8ce8612bb9866163059e7 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 14:09:22 +0200 Subject: [eel-labeled-image] convert to new GDK_KEY prefix --- eel/eel-labeled-image.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c index c1e51070..3cd7f9ba 100644 --- a/eel/eel-labeled-image.c +++ b/eel/eel-labeled-image.c @@ -191,13 +191,13 @@ eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class) binding_set = gtk_binding_set_by_class (gobject_class); gtk_binding_entry_add_signal (binding_set, - GDK_Return, 0, + GDK_KEY_Return, 0, "activate", 0); gtk_binding_entry_add_signal (binding_set, - GDK_KP_Enter, 0, + GDK_KEY_KP_Enter, 0, "activate", 0); gtk_binding_entry_add_signal (binding_set, - GDK_space, 0, + GDK_KEY_space, 0, "activate", 0); -- cgit v1.2.1 From 0d0641f10e84e0de0b39e63789508c260913cc98 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 14:20:13 +0200 Subject: [lc-p] convert to new GDK_KEY prefix http://git.gnome.org/browse/nautilus/commit/?id=64dcbea2a005e4ed8bb4945d06a943058b8c7ba8 --- libcaja-private/caja-autorun.c | 2 +- libcaja-private/caja-entry.c | 2 +- libcaja-private/caja-icon-container.c | 96 +++++++++++++++++------------------ 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index bfb26968..61adb3e0 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -908,7 +908,7 @@ autorun_always_toggled (GtkToggleButton *togglebutton, AutorunDialogData *data) static gboolean combo_box_enter_ok (GtkWidget *togglebutton, GdkEventKey *event, GtkDialog *dialog) { - if (event->keyval == GDK_KP_Enter || event->keyval == GDK_Return) + if (event->keyval == GDK_KEY_KP_Enter || event->keyval == GDK_KEY_Return) { gtk_dialog_response (dialog, GTK_RESPONSE_OK); return TRUE; diff --git a/libcaja-private/caja-entry.c b/libcaja-private/caja-entry.c index fa3669eb..863b1b4f 100644 --- a/libcaja-private/caja-entry.c +++ b/libcaja-private/caja-entry.c @@ -127,7 +127,7 @@ caja_entry_key_press (GtkWidget *widget, GdkEventKey *event) switch (event->keyval) { - case GDK_Tab: + case GDK_KEY_Tab: /* The location bar entry wants TAB to work kind of * like it does in the shell for command completion, * so if we get a tab and there's a selection, we diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index b1d648d3..8a92d3aa 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -5006,17 +5006,17 @@ keyboard_stretching (CajaIconContainer *container, switch (event->keyval) { - case GDK_equal: - case GDK_plus: - case GDK_KP_Add: + case GDK_KEY_equal: + case GDK_KEY_plus: + case GDK_KEY_KP_Add: icon_set_size (container, icon, size + 5, FALSE, FALSE); break; - case GDK_minus: - case GDK_KP_Subtract: + case GDK_KEY_minus: + case GDK_KEY_KP_Subtract: icon_set_size (container, icon, size - 5, FALSE, FALSE); break; - case GDK_0: - case GDK_KP_0: + case GDK_KEY_0: + case GDK_KEY_KP_0: caja_icon_container_move_icon (container, icon, icon->x, icon->y, 1.0, @@ -5633,14 +5633,14 @@ caja_icon_container_search_key_press_event (GtkWidget *widget, g_assert (CAJA_IS_ICON_CONTAINER (container)); /* close window and cancel the search */ - if (event->keyval == GDK_Escape || event->keyval == GDK_Tab) + if (event->keyval == GDK_KEY_Escape || event->keyval == GDK_KEY_Tab) { caja_icon_container_search_dialog_hide (widget, container); return TRUE; } /* close window and activate alternate */ - if (event->keyval == GDK_Return && event->state & GDK_SHIFT_MASK) + if (event->keyval == GDK_KEY_Return && event->state & GDK_SHIFT_MASK) { caja_icon_container_search_dialog_hide (widget, container); @@ -5650,28 +5650,28 @@ caja_icon_container_search_key_press_event (GtkWidget *widget, } /* select previous matching iter */ - if (event->keyval == GDK_Up || event->keyval == GDK_KP_Up) + if (event->keyval == GDK_KEY_Up || event->keyval == GDK_KEY_KP_Up) { caja_icon_container_search_move (widget, container, TRUE); retval = TRUE; } if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) - && (event->keyval == GDK_g || event->keyval == GDK_G)) + && (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G)) { caja_icon_container_search_move (widget, container, TRUE); retval = TRUE; } /* select next matching iter */ - if (event->keyval == GDK_Down || event->keyval == GDK_KP_Down) + if (event->keyval == GDK_KEY_Down || event->keyval == GDK_KEY_KP_Down) { caja_icon_container_search_move (widget, container, FALSE); retval = TRUE; } if (((event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK)) == GDK_CONTROL_MASK) - && (event->keyval == GDK_g || event->keyval == GDK_G)) + && (event->keyval == GDK_KEY_g || event->keyval == GDK_KEY_G)) { caja_icon_container_search_move (widget, container, FALSE); retval = TRUE; @@ -5880,12 +5880,12 @@ key_press_event (GtkWidget *widget, { switch (event->keyval) { - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: end_renaming_mode (container, TRUE); handled = TRUE; break; - case GDK_Escape: + case GDK_KEY_Escape: end_renaming_mode (container, FALSE); handled = TRUE; break; @@ -5897,18 +5897,18 @@ key_press_event (GtkWidget *widget, { switch (event->keyval) { - case GDK_Home: - case GDK_KP_Home: + case GDK_KEY_Home: + case GDK_KEY_KP_Home: keyboard_home (container, event); handled = TRUE; break; - case GDK_End: - case GDK_KP_End: + case GDK_KEY_End: + case GDK_KEY_KP_End: keyboard_end (container, event); handled = TRUE; break; - case GDK_Left: - case GDK_KP_Left: + case GDK_KEY_Left: + case GDK_KEY_KP_Left: /* Don't eat Alt-Left, as that is used for history browsing */ if ((event->state & GDK_MOD1_MASK) == 0) { @@ -5916,8 +5916,8 @@ key_press_event (GtkWidget *widget, handled = TRUE; } break; - case GDK_Up: - case GDK_KP_Up: + case GDK_KEY_Up: + case GDK_KEY_KP_Up: /* Don't eat Alt-Up, as that is used for alt-shift-Up */ if ((event->state & GDK_MOD1_MASK) == 0) { @@ -5925,8 +5925,8 @@ key_press_event (GtkWidget *widget, handled = TRUE; } break; - case GDK_Right: - case GDK_KP_Right: + case GDK_KEY_Right: + case GDK_KEY_KP_Right: /* Don't eat Alt-Right, as that is used for history browsing */ if ((event->state & GDK_MOD1_MASK) == 0) { @@ -5934,8 +5934,8 @@ key_press_event (GtkWidget *widget, handled = TRUE; } break; - case GDK_Down: - case GDK_KP_Down: + case GDK_KEY_Down: + case GDK_KEY_KP_Down: /* Don't eat Alt-Down, as that is used for Open */ if ((event->state & GDK_MOD1_MASK) == 0) { @@ -5943,20 +5943,20 @@ key_press_event (GtkWidget *widget, handled = TRUE; } break; - case GDK_space: + case GDK_KEY_space: keyboard_space (container, event); handled = TRUE; break; #ifndef TAB_NAVIGATION_DISABLED - case GDK_Tab: - case GDK_ISO_Left_Tab: + case GDK_KEY_Tab: + case GDK_KEY_ISO_Left_Tab: select_previous_or_next_icon (container, (event->state & GDK_SHIFT_MASK) == 0, event); handled = TRUE; break; #endif - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: if ((event->state & GDK_SHIFT_MASK) != 0) { activate_selected_items_alternate (container, NULL); @@ -5968,22 +5968,22 @@ key_press_event (GtkWidget *widget, handled = TRUE; break; - case GDK_Escape: + case GDK_KEY_Escape: handled = undo_stretching (container); break; - case GDK_plus: - case GDK_minus: - case GDK_equal: - case GDK_KP_Add: - case GDK_KP_Subtract: - case GDK_0: - case GDK_KP_0: + case GDK_KEY_plus: + case GDK_KEY_minus: + case GDK_KEY_equal: + case GDK_KEY_KP_Add: + case GDK_KEY_KP_Subtract: + case GDK_KEY_0: + case GDK_KEY_KP_0: if (event->state & GDK_CONTROL_MASK) { handled = keyboard_stretching (container, event); } break; - case GDK_F10: + case GDK_KEY_F10: /* handle Ctrl+F10 because we want to display the * background popup even if something is selected. * The other cases are handled by popup_menu(). @@ -5994,7 +5994,7 @@ key_press_event (GtkWidget *widget, "context_click_background"); } break; - case GDK_v: + case GDK_KEY_v: /* Eat Control + v to not enable type ahead */ if ((event->state & GDK_CONTROL_MASK) != 0) { @@ -6015,9 +6015,9 @@ key_press_event (GtkWidget *widget, * start the typeahead find capabilities. * Copied from CajaIconContainer */ if (!handled && - event->keyval != GDK_slash /* don't steal slash key event, used for "go to" */ && - event->keyval != GDK_BackSpace && - event->keyval != GDK_Delete) + event->keyval != GDK_KEY_slash /* don't steal slash key event, used for "go to" */ && + event->keyval != GDK_KEY_BackSpace && + event->keyval != GDK_KEY_Delete) { GdkEvent *new_event; GdkWindow *window; @@ -6717,8 +6717,8 @@ caja_icon_container_class_init (CajaIconContainerClass *class) binding_set = gtk_binding_set_by_class (class); - gtk_binding_entry_add_signal (binding_set, GDK_f, GDK_CONTROL_MASK, "start_interactive_search", 0); - gtk_binding_entry_add_signal (binding_set, GDK_F, GDK_CONTROL_MASK, "start_interactive_search", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "start_interactive_search", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start_interactive_search", 0); } static void -- cgit v1.2.1 From c97aca046a4f75e73e5d82a814337eef950efce3 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 14:29:50 +0200 Subject: [autorun] use gdk_error_trap_pop_ignored() for GTK3 http://git.gnome.org/browse/nautilus/commit/?id=8dd87483bd187bfac80a606233b769c230343980 --- libcaja-private/caja-autorun.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index 61adb3e0..21f71eb8 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -749,7 +749,11 @@ is_shift_pressed (void) gdk_error_trap_push (); status = XkbGetState (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ()), XkbUseCoreKbd, &state); +#if GTK_CHECK_VERSION(3,0,0) + gdk_error_trap_pop_ignored (); +#else gdk_error_trap_pop (); +#endif if (status == Success) { -- cgit v1.2.1 From 360d966dfa2a9ebe579e77d4f59a1e3b37ead28c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 23:11:40 +0200 Subject: [lc-p] Use gdk_threads_enter/leave in thumbnail_thread_notify_file_changed This was supposed to be a change from the GDK_THREADS_* macros. But, the macros weren't there, so we adapt from: thumbnails: don't use GDK_THREADS_* macros http://git.gnome.org/browse/nautilus/commit/?id=8ee5d37f2b4776730247af75a6ce4cebcba4c550&context=12 --- libcaja-private/caja-thumbnails.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libcaja-private/caja-thumbnails.c b/libcaja-private/caja-thumbnails.c index ef62edba..cbb5f7dc 100644 --- a/libcaja-private/caja-thumbnails.c +++ b/libcaja-private/caja-thumbnails.c @@ -277,6 +277,8 @@ thumbnail_thread_notify_file_changed (gpointer image_uri) { CajaFile *file; + gdk_threads_enter (); + file = caja_file_get_by_uri ((char *) image_uri); #ifdef DEBUG_THUMBNAILS g_message ("(Thumbnail Thread) Notifying file changed file:%p uri: %s\n", file, (char*) image_uri); @@ -292,6 +294,8 @@ thumbnail_thread_notify_file_changed (gpointer image_uri) } g_free (image_uri); + gdk_threads_leave (); + return FALSE; } -- cgit v1.2.1 From b24f066e23fb5b204c940c229c5cdebffd2f7600 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Mon, 5 Nov 2012 23:14:35 +0200 Subject: [src] convert to new GDK_KEY prefix http://git.gnome.org/browse/nautilus/commit/?id=71fa1a50145a6f06da3b805a29e75c1295fd546b Also, make sure we use GDK_KEY prefix in places-sidebar where this patch was previously applied to Caja but with old prefix: places-sidebar: allow keyboard navigation with Enter/Space (#637768) http://git.gnome.org/browse/nautilus/commit/?id=fd03c910a73ba18459e68baaf15e8dd295acd5c1 --- src/caja-bookmarks-window.c | 4 ++-- src/caja-location-entry.c | 28 ++++++++++++++-------------- src/caja-navigation-bar.c | 2 +- src/caja-places-sidebar.c | 16 ++++++++-------- src/caja-query-editor.c | 2 +- src/caja-search-bar.c | 6 +++--- src/caja-side-pane.c | 8 ++++---- src/caja-spatial-window.c | 4 ++-- src/caja-window.c | 8 ++++---- src/caja-zoom-control.c | 12 ++++++------ src/file-manager/fm-directory-view.c | 6 +++--- src/file-manager/fm-list-view.c | 16 ++++++++-------- src/file-manager/fm-properties-window.c | 2 +- 13 files changed, 57 insertions(+), 57 deletions(-) diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c index aaf0aee1..86c80bc5 100644 --- a/src/caja-bookmarks-window.c +++ b/src/caja-bookmarks-window.c @@ -749,7 +749,7 @@ on_key_pressed (GtkTreeView *view, GdkEventKey *event, gpointer user_data) { - if (event->keyval == GDK_Delete || event->keyval == GDK_KP_Delete) + if (event->keyval == GDK_KEY_Delete || event->keyval == GDK_KEY_KP_Delete) { bookmarks_delete_bookmark (); return TRUE; @@ -1082,7 +1082,7 @@ handle_close_accelerator (GtkWindow *window, g_assert (event != NULL); g_assert (user_data == NULL); - if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_w) { + if (event->state & GDK_CONTROL_MASK && event->keyval == GDK_KEY_w) { gtk_widget_hide (GTK_WIDGET (window)); return TRUE; } diff --git a/src/caja-location-entry.c b/src/caja-location-entry.c index fac59e44..f23f1a9f 100644 --- a/src/caja-location-entry.c +++ b/src/caja-location-entry.c @@ -133,19 +133,19 @@ entry_would_have_inserted_characters (const GdkEventKey *event) { switch (event->keyval) { - case GDK_BackSpace: - case GDK_Clear: - case GDK_Insert: - case GDK_Delete: - case GDK_Home: - case GDK_End: - case GDK_KP_Home: - case GDK_KP_End: - case GDK_Left: - case GDK_Right: - case GDK_KP_Left: - case GDK_KP_Right: - case GDK_Return: + case GDK_KEY_BackSpace: + case GDK_KEY_Clear: + case GDK_KEY_Insert: + case GDK_KEY_Delete: + case GDK_KEY_Home: + case GDK_KEY_End: + case GDK_KEY_KP_Home: + case GDK_KEY_KP_End: + case GDK_KEY_Left: + case GDK_KEY_Right: + case GDK_KEY_KP_Left: + case GDK_KEY_KP_Right: + case GDK_KEY_Return: return FALSE; default: if (event->keyval >= 0x20 && event->keyval <= 0xFF) @@ -235,7 +235,7 @@ editable_event_after_callback (GtkEntry *entry, * likely an auto-completion. We ignore shift / control since * they can validly be used to extend the selection. */ - if ((keyevent->keyval == GDK_Right || keyevent->keyval == GDK_End) && + if ((keyevent->keyval == GDK_KEY_Right || keyevent->keyval == GDK_KEY_End) && !(keyevent->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && gtk_editable_get_selection_bounds (editable, NULL, NULL)) { diff --git a/src/caja-navigation-bar.c b/src/caja-navigation-bar.c index 45434e89..c71d6503 100644 --- a/src/caja-navigation-bar.c +++ b/src/caja-navigation-bar.c @@ -93,7 +93,7 @@ caja_navigation_bar_class_init (CajaNavigationBarClass *klass) klass->cancel = NULL; binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0); EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, caja_navigation_bar, get_location); EEL_ASSIGN_MUST_OVERRIDE_SIGNAL (klass, caja_navigation_bar, set_location); diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index eb05ba37..c12c6200 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -2577,10 +2577,10 @@ bookmarks_key_press_event_cb (GtkWidget *widget, modifiers = gtk_accelerator_get_default_mod_mask (); - if (event->keyval == GDK_Return || - event->keyval == GDK_KP_Enter || - event->keyval == GDK_ISO_Enter || - event->keyval == GDK_space) + if (event->keyval == GDK_KEY_Return || + event->keyval == GDK_KEY_KP_Enter || + event->keyval == GDK_KEY_ISO_Enter || + event->keyval == GDK_KEY_space) { if ((event->state & modifiers) == GDK_SHIFT_MASK) flags = CAJA_WINDOW_OPEN_FLAG_NEW_TAB; @@ -2596,21 +2596,21 @@ bookmarks_key_press_event_cb (GtkWidget *widget, return TRUE; } - if (event->keyval == GDK_Down && + if (event->keyval == GDK_KEY_Down && (event->state & modifiers) == GDK_MOD1_MASK) { return eject_or_unmount_selection (sidebar); } - if ((event->keyval == GDK_Delete - || event->keyval == GDK_KP_Delete) + if ((event->keyval == GDK_KEY_Delete + || event->keyval == GDK_KEY_KP_Delete) && (event->state & modifiers) == 0) { remove_selected_bookmarks (sidebar); return TRUE; } - if ((event->keyval == GDK_F2) + if ((event->keyval == GDK_KEY_F2) && (event->state & modifiers) == 0) { rename_selected_bookmark (sidebar); diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c index 44425df3..7beb13d0 100644 --- a/src/caja-query-editor.c +++ b/src/caja-query-editor.c @@ -210,7 +210,7 @@ caja_query_editor_class_init (CajaQueryEditorClass *class) G_TYPE_NONE, 0); binding_set = gtk_binding_set_by_class (class); - gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0); } static void diff --git a/src/caja-search-bar.c b/src/caja-search-bar.c index 86bd1f0a..4ff4ef4b 100644 --- a/src/caja-search-bar.c +++ b/src/caja-search-bar.c @@ -102,7 +102,7 @@ caja_search_bar_class_init (CajaSearchBarClass *class) G_TYPE_NONE, 0); binding_set = gtk_binding_set_by_class (class); - gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0); } static gboolean @@ -198,7 +198,7 @@ caja_search_bar_borrow_entry (CajaSearchBar *bar) bar->details->entry_borrowed = TRUE; binding_set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (bar)); - gtk_binding_entry_remove (binding_set, GDK_Escape, 0); + gtk_binding_entry_remove (binding_set, GDK_KEY_Escape, 0); return bar->details->entry; } @@ -210,7 +210,7 @@ caja_search_bar_return_entry (CajaSearchBar *bar) bar->details->entry_borrowed = FALSE; binding_set = gtk_binding_set_by_class (G_OBJECT_GET_CLASS (bar)); - gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "cancel", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "cancel", 0); } GtkWidget * diff --git a/src/caja-side-pane.c b/src/caja-side-pane.c index 0566e81d..a5d6544e 100644 --- a/src/caja-side-pane.c +++ b/src/caja-side-pane.c @@ -274,10 +274,10 @@ select_button_key_press_callback (GtkWidget *widget, side_pane = CAJA_SIDE_PANE (user_data); - if (event->keyval == GDK_space || - event->keyval == GDK_KP_Space || - event->keyval == GDK_Return || - event->keyval == GDK_KP_Enter) + if (event->keyval == GDK_KEY_space || + event->keyval == GDK_KEY_KP_Space || + event->keyval == GDK_KEY_Return || + event->keyval == GDK_KEY_KP_Enter) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), TRUE); gtk_menu_popup (GTK_MENU (side_pane->details->menu), diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 24a7b647..612de13e 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -1135,10 +1135,10 @@ caja_spatial_window_class_init (CajaSpatialWindowClass *klass) G_OBJECT_CLASS (klass)->finalize = caja_spatial_window_finalize; binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_SHIFT_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_SHIFT_MASK, "go_up", 1, G_TYPE_BOOLEAN, TRUE); - gtk_binding_entry_add_signal (binding_set, GDK_Up, GDK_SHIFT_MASK | GDK_MOD1_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Up, GDK_SHIFT_MASK | GDK_MOD1_MASK, "go_up", 1, G_TYPE_BOOLEAN, TRUE); diff --git a/src/caja-window.c b/src/caja-window.c index 55a83e52..9dcf3863 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -1134,7 +1134,7 @@ add_view_as_menu_item (CajaWindow *window, g_snprintf (accel_path, sizeof (accel_path), "/%s", action_name); accel_keyval = gdk_keyval_from_name (accel); - g_assert (accel_keyval != GDK_VoidSymbol); + g_assert (accel_keyval != GDK_KEY_VoidSymbol); gtk_accel_map_add_entry (accel_path, accel_keyval, GDK_CONTROL_MASK); gtk_action_set_accel_path (GTK_ACTION (action), accel_path); @@ -2155,12 +2155,12 @@ caja_window_class_init (CajaWindowClass *class) G_TYPE_NONE, 0); binding_set = gtk_binding_set_by_class (class); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, "go_up", 1, G_TYPE_BOOLEAN, FALSE); - gtk_binding_entry_add_signal (binding_set, GDK_F5, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F5, 0, "reload", 0); - gtk_binding_entry_add_signal (binding_set, GDK_slash, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_slash, 0, "prompt-for-location", 1, G_TYPE_STRING, "/"); diff --git a/src/caja-zoom-control.c b/src/caja-zoom-control.c index 8ba974c4..5dc79518 100644 --- a/src/caja-zoom-control.c +++ b/src/caja-zoom-control.c @@ -723,32 +723,32 @@ caja_zoom_control_class_init (CajaZoomControlClass *class) binding_set = gtk_binding_set_by_class (class); gtk_binding_entry_add_signal (binding_set, - GDK_KP_Subtract, 0, + GDK_KEY_KP_Subtract, 0, "change_value", 1, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN); gtk_binding_entry_add_signal (binding_set, - GDK_minus, 0, + GDK_KEY_minus, 0, "change_value", 1, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_DOWN); gtk_binding_entry_add_signal (binding_set, - GDK_KP_Equal, 0, + GDK_KEY_KP_Equal, 0, "zoom_to_default", 0); gtk_binding_entry_add_signal (binding_set, - GDK_KP_Equal, 0, + GDK_KEY_KP_Equal, 0, "zoom_to_default", 0); gtk_binding_entry_add_signal (binding_set, - GDK_KP_Add, 0, + GDK_KEY_KP_Add, 0, "change_value", 1, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP); gtk_binding_entry_add_signal (binding_set, - GDK_plus, 0, + GDK_KEY_plus, 0, "change_value", 1, GTK_TYPE_SCROLL_TYPE, GTK_SCROLL_STEP_UP); diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 51737db5..6ed863bb 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -10955,11 +10955,11 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) G_TYPE_BOOLEAN, 0); binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0, "trash", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0, "trash", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_SHIFT_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK, "delete", 0); klass->trash = real_trash; diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index 10586bd3..e9fdd88b 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -1108,14 +1108,14 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat switch (event->keyval) { - case GDK_F10: + case GDK_KEY_F10: if (event->state & GDK_CONTROL_MASK) { fm_directory_view_pop_up_background_context_menu (view, &button_event); handled = TRUE; } break; - case GDK_Right: + case GDK_KEY_Right: gtk_tree_view_get_cursor (tree_view, &path, NULL); if (path) { @@ -1124,7 +1124,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat } handled = TRUE; break; - case GDK_Left: + case GDK_KEY_Left: gtk_tree_view_get_cursor (tree_view, &path, NULL); if (path) { @@ -1133,7 +1133,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat } handled = TRUE; break; - case GDK_space: + case GDK_KEY_space: if (event->state & GDK_CONTROL_MASK) { handled = FALSE; @@ -1154,8 +1154,8 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat } handled = TRUE; break; - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: if ((event->state & GDK_SHIFT_MASK) != 0) { activate_selected_items_alternate (FM_LIST_VIEW (view), NULL, TRUE); @@ -1166,7 +1166,7 @@ key_press_callback (GtkWidget *widget, GdkEventKey *event, gpointer callback_dat } handled = TRUE; break; - case GDK_v: + case GDK_KEY_v: /* Eat Control + v to not enable type ahead */ if ((event->state & GDK_CONTROL_MASK) != 0) { @@ -1641,7 +1641,7 @@ create_and_set_up_tree_view (FMListView *view) /* Don't handle backspace key. It's used to open the parent folder. */ binding_set = gtk_binding_set_by_class (GTK_WIDGET_GET_CLASS (view->details->tree_view)); - gtk_binding_entry_remove (binding_set, GDK_BackSpace, 0); + gtk_binding_entry_remove (binding_set, GDK_KEY_BackSpace, 0); view->details->drag_dest = caja_tree_view_drag_dest_new (view->details->tree_view); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 98e52b8f..bb9f06cd 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -5799,7 +5799,7 @@ fm_properties_window_class_init (FMPropertiesWindowClass *class) GTK_DIALOG_CLASS (class)->response = real_response; binding_set = gtk_binding_set_by_class (class); - gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "close", 0); } -- cgit v1.2.1 From 1915c80f583c8d09322bc0ed91159743b7ccaf56 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 23:17:14 +0200 Subject: [ui] remove 'has_separator' properties from Glade files http://git.gnome.org/browse/nautilus/commit/?id=78e37ae9a18925d75cf90424d92c8d3ba502848a --- src/caja-bookmarks-window.ui | 1 - src/caja-file-management-properties.ui | 1 - 2 files changed, 2 deletions(-) diff --git a/src/caja-bookmarks-window.ui b/src/caja-bookmarks-window.ui index 3c5e47e6..b57adcb1 100644 --- a/src/caja-bookmarks-window.ui +++ b/src/caja-bookmarks-window.ui @@ -9,7 +9,6 @@ False True False - False True diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui index c810d57e..8f4003d8 100644 --- a/src/caja-file-management-properties.ui +++ b/src/caja-file-management-properties.ui @@ -274,7 +274,6 @@ GDK_GRAVITY_NORTH_WEST True False - False True -- cgit v1.2.1 From df6ac41622e955bfc2e3d3d38624dceaf4436df5 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 15:29:36 +0200 Subject: [build] don't include marshals we don't own http://git.gnome.org/browse/nautilus/commit/?id=8d07a73b28767b7c866fe403e9ac706b8affb8a2 --- libcaja-private/caja-directory.c | 1 - libcaja-private/caja-icon-container.c | 1 - src/caja-pathbar.c | 1 - src/caja-window.c | 1 - src/caja-zoom-control.c | 1 - src/file-manager/fm-directory-view.c | 1 - 6 files changed, 6 deletions(-) diff --git a/libcaja-private/caja-directory.c b/libcaja-private/caja-directory.c index 6479b38a..efcfc5ed 100644 --- a/libcaja-private/caja-directory.c +++ b/libcaja-private/caja-directory.c @@ -32,7 +32,6 @@ #include "caja-search-directory.h" #include "caja-global-preferences.h" #include "caja-lib-self-check-functions.h" -#include "caja-marshal.h" #include "caja-metadata.h" #include "caja-desktop-directory.h" #include "caja-vfs-directory.h" diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 8a92d3aa..f9b01311 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index 279f4cd5..dffd63ee 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include "caja-pathbar.h" diff --git a/src/caja-window.c b/src/caja-window.c index 9dcf3863..d7c4c2cc 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -42,7 +42,6 @@ #include "caja-navigation-window-pane.h" #include "caja-src-marshal.h" #include -#include #include #include #include diff --git a/src/caja-zoom-control.c b/src/caja-zoom-control.c index 5dc79518..685242dc 100644 --- a/src/caja-zoom-control.c +++ b/src/caja-zoom-control.c @@ -40,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index 6ed863bb..bd75951e 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.1 From 2a1ef1efb5434f189e0463c834d5926bd931184e Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 15:32:31 +0200 Subject: [window-info] move include to caja-window-private http://git.gnome.org/browse/nautilus/commit/?id=42cc7bd181d2f57dbc008bea54a40f02be40ce39 --- libcaja-private/caja-window-info.h | 1 - src/caja-window-private.h | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/libcaja-private/caja-window-info.h b/libcaja-private/caja-window-info.h index fb39c73f..4bb271b6 100644 --- a/libcaja-private/caja-window-info.h +++ b/libcaja-private/caja-window-info.h @@ -28,7 +28,6 @@ #include #include #include -#include "../src/caja-bookmark-list.h" #ifdef __cplusplus extern "C" { diff --git a/src/caja-window-private.h b/src/caja-window-private.h index ae4a723f..73a9c29c 100644 --- a/src/caja-window-private.h +++ b/src/caja-window-private.h @@ -33,6 +33,7 @@ #include "caja-window-pane.h" #include "caja-spatial-window.h" #include "caja-navigation-window.h" +#include "caja-bookmark-list.h" #include -- cgit v1.2.1 From 662d2326c5ce63c867b3d94fb2bb44d9a244399b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 00:01:23 +0200 Subject: [window] add _full() versions of _go_to and _open() methods These also have a callback to get the result of the operation. http://git.gnome.org/browse/nautilus/commit/?id=24515b87a91afd32885e07e32e2b4080584673a4 --- libcaja-private/caja-window-info.h | 4 ++++ libcaja-private/caja-window-slot-info.c | 14 +++++++++----- libcaja-private/caja-window-slot-info.h | 19 ++++++++++++++----- src/caja-window-manage-views.c | 8 ++++---- src/caja-window-slot.h | 11 +++++++++-- src/caja-window.c | 14 +++++++++++++- src/caja-window.h | 4 ++++ 7 files changed, 57 insertions(+), 17 deletions(-) diff --git a/libcaja-private/caja-window-info.h b/libcaja-private/caja-window-info.h index 4bb271b6..7cced147 100644 --- a/libcaja-private/caja-window-info.h +++ b/libcaja-private/caja-window-info.h @@ -88,6 +88,10 @@ extern "C" { typedef struct _CajaWindowInfoIface CajaWindowInfoIface; + typedef void (* CajaWindowGoToCallback) (CajaWindow *window, + GError *error, + gpointer user_data); + struct _CajaWindowInfoIface { GTypeInterface g_iface; diff --git a/libcaja-private/caja-window-slot-info.c b/libcaja-private/caja-window-slot-info.c index f0193980..01a38a80 100644 --- a/libcaja-private/caja-window-slot-info.c +++ b/libcaja-private/caja-window-slot-info.c @@ -108,11 +108,13 @@ caja_window_slot_info_make_hosting_pane_active (CajaWindowSlotInfo *slot) } void -caja_window_slot_info_open_location (CajaWindowSlotInfo *slot, +caja_window_slot_info_open_location_full (CajaWindowSlotInfo *slot, GFile *location, - CajaWindowOpenMode mode, - CajaWindowOpenFlags flags, - GList *selection) + CajaWindowOpenMode mode, + CajaWindowOpenFlags flags, + GList *selection, + CajaWindowGoToCallback callback, + gpointer user_data) { g_assert (CAJA_IS_WINDOW_SLOT_INFO (slot)); @@ -120,7 +122,9 @@ caja_window_slot_info_open_location (CajaWindowSlotInfo *slot, location, mode, flags, - selection); + selection, + callback, + user_data); } char * diff --git a/libcaja-private/caja-window-slot-info.h b/libcaja-private/caja-window-slot-info.h index 2d8b21d2..49804820 100644 --- a/libcaja-private/caja-window-slot-info.h +++ b/libcaja-private/caja-window-slot-info.h @@ -72,18 +72,27 @@ struct _CajaWindowSlotInfoIface GFile *location, CajaWindowOpenMode mode, CajaWindowOpenFlags flags, - GList *selection); + GList *selection, + CajaWindowGoToCallback callback, + gpointer user_data); void (* make_hosting_pane_active) (CajaWindowSlotInfo *slot); }; GType caja_window_slot_info_get_type (void); CajaWindowInfo * caja_window_slot_info_get_window (CajaWindowSlotInfo *slot); -void caja_window_slot_info_open_location (CajaWindowSlotInfo *slot, +#define caja_window_slot_info_open_location(slot, location, mode, flags, selection) \ + caja_window_slot_info_open_location_full(slot, location, mode, \ + flags, selection, NULL, NULL) + +void caja_window_slot_info_open_location_full + (CajaWindowSlotInfo *slot, GFile *location, - CajaWindowOpenMode mode, - CajaWindowOpenFlags flags, - GList *selection); + CajaWindowOpenMode mode, + CajaWindowOpenFlags flags, + GList *selection, + CajaWindowGoToCallback callback, + gpointer user_data); void caja_window_slot_info_set_status (CajaWindowSlotInfo *slot, const char *status); void caja_window_slot_info_make_hosting_pane_active (CajaWindowSlotInfo *slot); diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c index 35091bed..e34fc232 100644 --- a/src/caja-window-manage-views.c +++ b/src/caja-window-manage-views.c @@ -724,7 +724,7 @@ caja_window_slot_open_location (CajaWindowSlot *slot, caja_window_slot_open_location_full (slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, - flags, NULL); + flags, NULL, NULL, NULL); } void @@ -742,7 +742,7 @@ caja_window_slot_open_location_with_selection (CajaWindowSlot *slot, } caja_window_slot_open_location_full (slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, - flags, selection); + flags, selection, NULL, NULL); } @@ -766,7 +766,7 @@ caja_window_slot_go_home (CajaWindowSlot *slot, gboolean new_tab) home = g_file_new_for_path (g_get_home_dir ()); caja_window_slot_open_location_full (slot, home, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, - flags, NULL); + flags, NULL, NULL, NULL); g_object_unref (home); } @@ -2273,7 +2273,7 @@ caja_navigation_window_back_or_forward (CajaNavigationWindow *window, caja_window_slot_open_location_full (slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, CAJA_WINDOW_OPEN_FLAG_NEW_TAB, - NULL); + NULL, NULL, NULL); } else { diff --git a/src/caja-window-slot.h b/src/caja-window-slot.h index f25bdf41..e0e93db9 100644 --- a/src/caja-window-slot.h +++ b/src/caja-window-slot.h @@ -139,7 +139,9 @@ void caja_window_slot_open_location_full (CajaWindowSlot *slot, GFile *location, CajaWindowOpenMode mode, CajaWindowOpenFlags flags, - GList *new_selection); + GList *new_selection, + CajaWindowGoToCallback callback, + gpointer user_data); void caja_window_slot_stop_loading (CajaWindowSlot *slot); void caja_window_slot_set_content_view (CajaWindowSlot *slot, @@ -156,7 +158,12 @@ void caja_window_slot_disconnect_content_view (CajaWindowSlo #define caja_window_slot_go_to(slot,location, new_tab) \ caja_window_slot_open_location_full(slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, \ (new_tab ? CAJA_WINDOW_OPEN_FLAG_NEW_TAB : 0), \ - NULL) + NULL, NULL, NULL) + +#define caja_window_slot_go_to_full(slot, location, new_tab, callback, user_data) \ + caja_window_slot_open_location_full(slot, location, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, \ + (new_tab ? CAJA_WINDOW_OPEN_FLAG_NEW_TAB : 0), \ + NULL, callback, user_data) #define caja_window_slot_go_to_with_selection(slot,location,new_selection) \ caja_window_slot_open_location_with_selection(slot, location, new_selection, FALSE) diff --git a/src/caja-window.c b/src/caja-window.c index d7c4c2cc..13f45508 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -235,6 +235,17 @@ caja_window_go_to (CajaWindow *window, GFile *location) caja_window_slot_go_to (window->details->active_pane->active_slot, location, FALSE); } +void +caja_window_go_to_full (CajaWindow *window, + GFile *location, + CajaWindowGoToCallback callback, + gpointer user_data) +{ + g_return_if_fail (CAJA_IS_WINDOW (window)); + + caja_window_slot_go_to_full (window->details->active_pane->active_slot, location, FALSE, callback, user_data); +} + void caja_window_go_to_with_selection (CajaWindow *window, GFile *location, GList *new_selection) { @@ -324,7 +335,8 @@ caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab) caja_window_slot_open_location_full (slot, parent, CAJA_WINDOW_OPEN_ACCORDING_TO_MODE, flags, - selection); + selection, + NULL, NULL); g_object_unref (parent); diff --git a/src/caja-window.h b/src/caja-window.h index 86b85b4f..b5ea219c 100644 --- a/src/caja-window.h +++ b/src/caja-window.h @@ -136,6 +136,10 @@ void caja_window_disconnect_content_view (CajaWindow *window, void caja_window_go_to (CajaWindow *window, GFile *location); +void caja_window_go_to_full (CajaWindow *window, + GFile *location, + CajaWindowGoToCallback callback, + gpointer user_data); void caja_window_go_to_with_selection (CajaWindow *window, GFile *location, GList *new_selection); -- cgit v1.2.1 From 11c358d779c6c0913cf9d784a8adbb663c6b8bd9 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 00:19:18 +0200 Subject: [window] rewrite window-opening policies The code there was very hackish and convoluted. Rewrite it to make it at least cleaner. This will allow further cleanup later. http://git.gnome.org/browse/nautilus/commit/?id=54e0a1f21513babc89f980b5b02af2bf7a6ebe85 --- src/caja-window-manage-views.c | 144 +++++++++++++++++++++-------------------- 1 file changed, 74 insertions(+), 70 deletions(-) diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c index e34fc232..89722d04 100644 --- a/src/caja-window-manage-views.c +++ b/src/caja-window-manage-views.c @@ -511,23 +511,28 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot, GFile *location, CajaWindowOpenMode mode, CajaWindowOpenFlags flags, - GList *new_selection) + GList *new_selection, + CajaWindowGoToCallback callback, + gpointer user_data) { CajaWindow *window; CajaWindow *target_window; CajaWindowPane *pane; CajaWindowSlot *target_slot; CajaWindowOpenFlags slot_flags; - gboolean do_load_location = TRUE; + gboolean existing = FALSE; GFile *old_location; char *old_uri, *new_uri; int new_slot_position; GList *l; + gboolean target_spatial, target_navigation, target_same; + gboolean is_desktop; window = slot->pane->window; target_window = NULL; target_slot = NULL; + target_spatial = target_navigation = target_same = FALSE; old_uri = caja_window_slot_get_location_uri (slot); if (old_uri == NULL) @@ -546,87 +551,86 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot, g_assert (!((flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0 && (flags & CAJA_WINDOW_OPEN_FLAG_NEW_TAB) != 0)); + is_desktop = CAJA_IS_DESKTOP_WINDOW (window); + target_same = is_desktop && + !caja_desktop_window_loaded (CAJA_DESKTOP_WINDOW (window)); old_location = caja_window_slot_get_location (slot); + switch (mode) { case CAJA_WINDOW_OPEN_ACCORDING_TO_MODE : - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) - { - target_window = window; - if (CAJA_IS_SPATIAL_WINDOW (window)) - { - if (!CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change) - { - target_window = caja_application_create_navigation_window - (window->application, - NULL, - gtk_window_get_screen (GTK_WINDOW (window))); - } - else - { - CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = FALSE; - } - } - else if ((flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) != 0) - { - target_window = caja_application_create_navigation_window - (window->application, - NULL, - gtk_window_get_screen (GTK_WINDOW (window))); + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) { + /* always use browser: if we're on the desktop the target is a new navigation window, + * otherwise it's the same window. + */ + if (is_desktop) { + target_navigation = TRUE; + } else { + target_same = TRUE; } } else if (CAJA_IS_SPATIAL_WINDOW (window)) { - if (!CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change) - { - target_window = caja_application_present_spatial_window_with_selection ( - window->application, - window, - NULL, - location, - new_selection, - gtk_window_get_screen (GTK_WINDOW (window))); - do_load_location = FALSE; - } - else - { - CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = FALSE; - target_window = window; - } - } - else if (flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) - { - target_window = caja_application_create_navigation_window - (window->application, - NULL, - gtk_window_get_screen (GTK_WINDOW (window))); - } - else - { - target_window = window; + /* don't always use browser: if source is spatial, target is spatial */ + target_spatial = TRUE; + } else if (flags & CAJA_WINDOW_OPEN_FLAG_NEW_WINDOW) { + /* if it's specified to open a new window, and we're not using spatial, + * the target is a navigation. + */ + target_navigation = TRUE; } break; case CAJA_WINDOW_OPEN_IN_SPATIAL : - target_window = caja_application_present_spatial_window ( - window->application, - window, - NULL, - location, - gtk_window_get_screen (GTK_WINDOW (window))); + target_spatial = TRUE; break; case CAJA_WINDOW_OPEN_IN_NAVIGATION : - target_window = caja_application_create_navigation_window - (window->application, - NULL, - gtk_window_get_screen (GTK_WINDOW (window))); + target_navigation = TRUE; break; default : - g_warning ("Unknown open location mode"); + g_critical ("Unknown open location mode"); g_object_unref (old_location); return; } + /* now get/create the window according to the mode */ + if (target_same) { + target_window = window; + } else if (target_navigation) { + target_window = caja_application_create_navigation_window + (window->application, + NULL, + gtk_window_get_screen (GTK_WINDOW (window))); + } else { + target_window = caja_application_get_spatial_window + (window->application, + window, + NULL, + location, + gtk_window_get_screen (GTK_WINDOW (window)), + &existing); + } + + /* if the spatial window is already showing, present it and set the + * new selection, if present. + */ + if (existing) { + target_slot = target_window->details->active_pane->active_slot; + + gtk_window_present (GTK_WINDOW (target_window)); + + if (new_selection != NULL && slot->content_view != NULL) { + caja_view_set_selection (target_slot->content_view, new_selection); + } + + /* call the callback successfully */ + if (callback != NULL) { + callback (window, NULL, user_data); + } + + return; + } + g_assert (target_window != NULL); if ((flags & CAJA_WINDOW_OPEN_FLAG_NEW_TAB) != 0 && @@ -676,14 +680,14 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot, } } - if ((!do_load_location) || - (target_window == window && target_slot == slot && - old_location && g_file_equal (old_location, location))) - { - if (old_location) - { - g_object_unref (old_location); + if ((target_window == window && target_slot == slot && + old_location && g_file_equal (old_location, location))) { + + if (callback != NULL) { + callback (window, NULL, user_data); } + + g_object_unref (old_location); return; } -- cgit v1.2.1 From e4ff799b046b0f7740619c7ddd0ef4f770f7102e Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 00:44:38 +0200 Subject: [desktop-window] add a 'loaded' flag http://git.gnome.org/browse/nautilus/commit/?id=f95927360079b1c05efb9cea0de62457eea307ab&context=6 --- src/caja-desktop-window.c | 12 +++++++++++- src/caja-desktop-window.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c index 5e477cf5..aabc0468 100644 --- a/src/caja-desktop-window.c +++ b/src/caja-desktop-window.c @@ -39,6 +39,8 @@ struct CajaDesktopWindowDetails { gulong size_changed_id; + + gboolean loaded; }; G_DEFINE_TYPE (CajaDesktopWindow, caja_desktop_window, @@ -94,9 +96,10 @@ caja_desktop_window_update_directory (CajaDesktopWindow *window) g_assert (CAJA_IS_DESKTOP_WINDOW (window)); - CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE; location = g_file_new_for_uri (EEL_DESKTOP_URI); caja_window_go_to (CAJA_WINDOW (window), location); + window->details->loaded = TRUE; + g_object_unref (location); } @@ -267,3 +270,10 @@ caja_desktop_window_class_init (CajaDesktopWindowClass *klass) g_type_class_add_private (klass, sizeof (CajaDesktopWindowDetails)); } + +gboolean +caja_desktop_window_loaded (CajaDesktopWindow *window) +{ + return window->details->loaded; +} + diff --git a/src/caja-desktop-window.h b/src/caja-desktop-window.h index cd9582b4..2bd3579c 100644 --- a/src/caja-desktop-window.h +++ b/src/caja-desktop-window.h @@ -62,5 +62,6 @@ GType caja_desktop_window_get_type (void); CajaDesktopWindow *caja_desktop_window_new (CajaApplication *application, GdkScreen *screen); void caja_desktop_window_update_directory (CajaDesktopWindow *window); +gboolean caja_desktop_window_loaded (CajaDesktopWindow *window); #endif /* CAJA_DESKTOP_WINDOW_H */ -- cgit v1.2.1 From f1f85813b51e79b0be816a28dba61bbdef5a6df5 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 00:47:14 +0200 Subject: [spatial-window] remove affect_location_on_next_change hack http://git.gnome.org/browse/nautilus/commit/?id=1936e668c73b932f8cb018e278f8b7f46442fda2 --- src/caja-spatial-window.c | 2 -- src/caja-spatial-window.h | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 612de13e..161a3038 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -1012,8 +1012,6 @@ caja_spatial_window_init (CajaSpatialWindow *window) pane = caja_window_pane_new (win); win->details->panes = g_list_prepend (win->details->panes, pane); - window->affect_spatial_window_on_next_location_change = TRUE; - vbox = gtk_vbox_new (FALSE, 0); gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table), vbox, diff --git a/src/caja-spatial-window.h b/src/caja-spatial-window.h index f877aaf1..a012e88e 100644 --- a/src/caja-spatial-window.h +++ b/src/caja-spatial-window.h @@ -53,8 +53,6 @@ struct _CajaSpatialWindow { CajaWindow parent_object; - gboolean affect_spatial_window_on_next_location_change; - CajaSpatialWindowDetails *details; }; -- cgit v1.2.1 From 867bdfb4c9f899358e82d9511300fde541172967 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 01:22:08 +0200 Subject: [application] change the way spatial windows are created Use a _get() function + the standard caja_window_go_to() instead of using _present(). The new functions in caja-window-manage-views are smart enough to take care of re-using an existent window. http://git.gnome.org/browse/nautilus/commit/?id=d070d631545aac9114bc271481da603587c07c7c --- src/caja-application.c | 174 ++++++++++++++++++++----------------------------- src/caja-application.h | 15 ++--- 2 files changed, 74 insertions(+), 115 deletions(-) diff --git a/src/caja-application.c b/src/caja-application.c index 5881facd..a462524f 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -777,43 +777,34 @@ open_window (CajaApplication *application, { GFile *location; CajaWindow *window; + gboolean existing; + + if (uri == NULL) { + location = g_file_new_for_path (g_get_home_dir ()); + } else { + location = g_file_new_for_uri (uri); + } + + existing = FALSE; if (browser_window || - g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) - { + g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) { window = caja_application_create_navigation_window (application, startup_id, screen); - if (uri == NULL) - { - caja_window_go_home (window); - } - else - { - location = g_file_new_for_uri (uri); - caja_window_go_to (window, location); - g_object_unref (location); - } - } - else - { - if (uri == NULL) - { - location = g_file_new_for_path (g_get_home_dir ()); - } - else - { - location = g_file_new_for_uri (uri); - } - - window = caja_application_present_spatial_window (application, + } else { + window = caja_application_get_spatial_window (application, NULL, startup_id, location, - screen); - g_object_unref (location); + screen, + NULL); } + caja_window_go_to (window, location); + + g_object_unref (location); + if (geometry != NULL && !gtk_widget_get_visible (GTK_WIDGET (window))) { /* never maximize windows opened from shell if a @@ -1225,22 +1216,25 @@ caja_application_get_existing_spatial_window (GFile *location) { GList *l; CajaWindowSlot *slot; + GFile *window_location; for (l = caja_application_get_spatial_window_list (); - l != NULL; l = l->next) - { - GFile *window_location; - + l != NULL; l = l->next) { slot = CAJA_WINDOW (l->data)->details->active_pane->active_slot; - window_location = slot->location; - if (window_location != NULL) - { - if (g_file_equal (location, window_location)) - { - return CAJA_SPATIAL_WINDOW (l->data); + + window_location = slot->pending_location; + + if (window_location == NULL) { + window_location = slot->location; + } + + if (window_location != NULL) { + if (g_file_equal (location, window_location)) { + return CAJA_SPATIAL_WINDOW (l->data); } } } + return NULL; } @@ -1416,68 +1410,32 @@ spatial_window_destroyed_callback (void *user_data, GObject *window) } CajaWindow * -caja_application_present_spatial_window (CajaApplication *application, - CajaWindow *requesting_window, - const char *startup_id, - GFile *location, - GdkScreen *screen) -{ - return caja_application_present_spatial_window_with_selection (application, - requesting_window, - startup_id, - location, - NULL, - screen); -} - -CajaWindow * -caja_application_present_spatial_window_with_selection (CajaApplication *application, - CajaWindow *requesting_window, - const char *startup_id, - GFile *location, - GList *new_selection, - GdkScreen *screen) +caja_application_get_spatial_window (CajaApplication *application, + CajaWindow *requesting_window, + const char *startup_id, + GFile *location, + GdkScreen *screen, + gboolean *existing) { CajaWindow *window; - GList *l; - char *uri; + gchar *uri; g_return_val_if_fail (CAJA_IS_APPLICATION (application), NULL); + window = CAJA_WINDOW + (caja_application_get_existing_spatial_window (location)); - for (l = caja_application_get_spatial_window_list (); - l != NULL; l = l->next) - { - CajaWindow *existing_window; - CajaWindowSlot *slot; - GFile *existing_location; - - existing_window = CAJA_WINDOW (l->data); - slot = existing_window->details->active_pane->active_slot; - existing_location = slot->pending_location; - - if (existing_location == NULL) - { - existing_location = slot->location; + if (window != NULL) { + if (existing != NULL) { + *existing = TRUE; } - if (g_file_equal (existing_location, location)) - { - gtk_window_present (GTK_WINDOW (existing_window)); - if (new_selection && - slot->content_view != NULL) - { - caja_view_set_selection (slot->content_view, new_selection); - } - - uri = g_file_get_uri (location); - caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER, - "present EXISTING spatial window=%p: %s", - existing_window, uri); - g_free (uri); - return existing_window; - } + return window; } + if (existing != NULL) { + *existing = FALSE; + } + window = create_window (application, CAJA_TYPE_SPATIAL_WINDOW, startup_id, screen); if (requesting_window) { @@ -1508,8 +1466,6 @@ caja_application_present_spatial_window_with_selection (CajaApplication *applica g_object_weak_ref (G_OBJECT (window), spatial_window_destroyed_callback, NULL); - caja_window_go_to_with_selection (window, location, new_selection); - uri = g_file_get_uri (location); caja_debug_log (FALSE, CAJA_DEBUG_LOG_DOMAIN_USER, "present NEW spatial window=%p: %s", @@ -1704,27 +1660,30 @@ autorun_show_window (GMount *mount, gpointer user_data) { GFile *location; CajaApplication *application = user_data; + CajaWindow *window; + gboolean existing; location = g_mount_get_root (mount); + existing = FALSE; /* There should probably be an easier way to do this */ - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) - { - CajaWindow *window; + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) { window = caja_application_create_navigation_window (application, - NULL, - gdk_screen_get_default ()); - caja_window_go_to (window, location); - + NULL, + gdk_screen_get_default ()); } else { - caja_application_present_spatial_window (application, - NULL, - NULL, - location, - gdk_screen_get_default ()); + window = caja_application_get_spatial_window (application, + NULL, + NULL, + location, + gdk_screen_get_default (), + NULL); } + + caja_window_go_to (window, location); + g_object_unref (location); } @@ -2285,7 +2244,12 @@ caja_application_load_session (CajaApplication *application) else if (!strcmp (type, "spatial")) { location = g_file_new_for_uri (location_uri); - window = caja_application_present_spatial_window (application, NULL, NULL, location, gdk_screen_get_default ()); + window = caja_application_get_spatial_window (application, NULL, NULL, + location, gdk_screen_get_default (), + NULL); + + caja_window_go_to (window, location); + g_object_unref (location); } else diff --git a/src/caja-application.h b/src/caja-application.h index 5c5b94d0..426f2c09 100644 --- a/src/caja-application.h +++ b/src/caja-application.h @@ -88,17 +88,12 @@ GList * caja_application_get_window_list (void); GList * caja_application_get_spatial_window_list (void); unsigned int caja_application_get_n_windows (void); -CajaWindow * caja_application_present_spatial_window (CajaApplication *application, +CajaWindow * caja_application_get_spatial_window (CajaApplication *application, CajaWindow *requesting_window, - const char *startup_id, - GFile *location, - GdkScreen *screen); -CajaWindow * caja_application_present_spatial_window_with_selection (CajaApplication *application, - CajaWindow *requesting_window, - const char *startup_id, - GFile *location, - GList *new_selection, - GdkScreen *screen); + const char *startup_id, + GFile *location, + GdkScreen *screen, + gboolean *existing); CajaWindow * caja_application_create_navigation_window (CajaApplication *application, const char *startup_id, -- cgit v1.2.1 From dd924575b8e1fd4c99acf3c8f3860fc38798f0e8 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 01:41:16 +0200 Subject: [window] call the callback during the location change http://git.gnome.org/browse/nautilus/commit/?id=adedf859ec47296106f0f0d938e70b32f0120f7c --- src/caja-window-manage-views.c | 57 +++++++++++++++++++++++++++++------------- src/caja-window-slot.h | 2 ++ 2 files changed, 42 insertions(+), 17 deletions(-) diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c index 89722d04..f3e30f6a 100644 --- a/src/caja-window-manage-views.c +++ b/src/caja-window-manage-views.c @@ -84,9 +84,11 @@ static void begin_location_change (CajaWindowSlot *slot, GFile *location, GList *new_selection, - CajaLocationChangeType type, + CajaLocationChangeType type, guint distance, - const char *scroll_pos); + const char *scroll_pos, + CajaWindowGoToCallback callback, + gpointer user_data); static void free_location_change (CajaWindowSlot *slot); static void end_location_change (CajaWindowSlot *slot); static void cancel_location_change (CajaWindowSlot *slot); @@ -697,7 +699,7 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot, } begin_location_change (target_slot, location, new_selection, - CAJA_LOCATION_CHANGE_STANDARD, 0, NULL); + CAJA_LOCATION_CHANGE_STANDARD, 0, NULL, callback, user_data); /* Additionally, load this in all slots that have no location, this means we load both panes in e.g. a newly opened dual pane window. */ @@ -705,10 +707,9 @@ caja_window_slot_open_location_full (CajaWindowSlot *slot, { pane = l->data; slot = pane->active_slot; - if (slot->location == NULL && slot->pending_location == NULL) - { + if (slot->location == NULL && slot->pending_location == NULL) { begin_location_change (slot, location, new_selection, - CAJA_LOCATION_CHANGE_STANDARD, 0, NULL); + CAJA_LOCATION_CHANGE_STANDARD, 0, NULL, NULL, NULL); } } } @@ -862,6 +863,20 @@ caja_window_slot_content_view_matches_iid (CajaWindowSlot *slot, return eel_strcmp (caja_view_get_view_id (slot->content_view), iid) == 0; } +static gboolean +report_callback (CajaWindowSlot *slot, + GError *error) +{ + if (slot->open_callback != NULL) { + slot->open_callback (slot->pane->window, error, slot->open_callback_user_data); + slot->open_callback = NULL; + slot->open_callback_user_data = NULL; + + return TRUE; + } + + return FALSE; +} /* * begin_location_change @@ -874,6 +889,8 @@ caja_window_slot_content_view_matches_iid (CajaWindowSlot *slot, * @distance: If type is back or forward, the index into the back or forward chain. If * type is standard or reload, this is ignored, and must be 0. * @scroll_pos: The file to scroll to when the location is loaded. + * @callback: function to be called when the location is changed. + * @user_data: data for @callback. * * This is the core function for changing the location of a window. Every change to the * location begins here. @@ -884,7 +901,9 @@ begin_location_change (CajaWindowSlot *slot, GList *new_selection, CajaLocationChangeType type, guint distance, - const char *scroll_pos) + const char *scroll_pos, + CajaWindowGoToCallback callback, + gpointer user_data) { CajaWindow *window; CajaDirectory *directory; @@ -918,6 +937,9 @@ begin_location_change (CajaWindowSlot *slot, slot->pending_scroll_to = g_strdup (scroll_pos); + slot->open_callback = callback; + slot->open_callback_user_data = user_data; + directory = caja_directory_get (location); /* The code to force a reload is here because if we do it @@ -1249,11 +1271,15 @@ got_file_info_for_view_selection_callback (CajaFile *file, } create_content_view (slot, view_id); g_free (view_id); + + report_callback (slot, NULL); } else { - display_view_selection_failure (window, file, - location, error); + if (!report_callback (slot, error)) { + display_view_selection_failure (window, file, + location, error); + } if (!gtk_widget_get_visible (GTK_WIDGET (window))) { @@ -1265,11 +1291,6 @@ got_file_info_for_view_selection_callback (CajaFile *file, { g_assert (caja_application_get_n_windows () == 1); - /* Make sure we re-use this window */ - if (CAJA_IS_SPATIAL_WINDOW (window)) - { - CAJA_SPATIAL_WINDOW (window)->affect_spatial_window_on_next_location_change = TRUE; - } /* the user could have typed in a home directory that doesn't exist, in which case going home would cause an infinite loop, so we better test for that */ @@ -2038,7 +2059,7 @@ caja_window_report_view_failed (CajaWindow *window, { /* We loose the pending selection change here, but who cares... */ begin_location_change (slot, fallback_load_location, NULL, - CAJA_LOCATION_CHANGE_FALLBACK, 0, NULL); + CAJA_LOCATION_CHANGE_FALLBACK, 0, NULL, NULL, NULL); g_object_unref (fallback_load_location); } @@ -2289,7 +2310,8 @@ caja_navigation_window_back_or_forward (CajaNavigationWindow *window, location, NULL, back ? CAJA_LOCATION_CHANGE_BACK : CAJA_LOCATION_CHANGE_FORWARD, distance, - scroll_pos); + scroll_pos, + NULL, NULL); g_free (scroll_pos); } @@ -2325,7 +2347,8 @@ caja_window_slot_reload (CajaWindowSlot *slot) } begin_location_change (slot, location, selection, - CAJA_LOCATION_CHANGE_RELOAD, 0, current_pos); + CAJA_LOCATION_CHANGE_RELOAD, 0, current_pos, + NULL, NULL); g_free (current_pos); g_object_unref (location); eel_g_object_list_free (selection); diff --git a/src/caja-window-slot.h b/src/caja-window-slot.h index e0e93db9..ea858166 100644 --- a/src/caja-window-slot.h +++ b/src/caja-window-slot.h @@ -109,6 +109,8 @@ struct CajaWindowSlot GCancellable *mount_cancellable; GError *mount_error; gboolean tried_mount; + CajaWindowGoToCallback open_callback; + gpointer open_callback_user_data; GCancellable *find_mount_cancellable; -- cgit v1.2.1 From d92e8f674131476d7382496cbc37a5827cef0c84 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Fri, 19 Oct 2012 01:45:59 +0200 Subject: [bookmarks-window] use new CajaApplication API http://git.gnome.org/browse/nautilus/commit/?id=a3ce22ec6e8fcb39dafb35e04e445f4a94b8c394 --- src/caja-bookmarks-window.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c index 86c80bc5..2ce15aae 100644 --- a/src/caja-bookmarks-window.c +++ b/src/caja-bookmarks-window.c @@ -582,35 +582,35 @@ open_selected_bookmark (gpointer user_data, GdkScreen *screen) if (CAJA_IS_NAVIGATION_WINDOW (user_data)) { - caja_window_go_to (CAJA_WINDOW (user_data), location); + window = user_data; } else if (CAJA_IS_SPATIAL_WINDOW (user_data)) { - window = caja_application_present_spatial_window (application, - NULL, - NULL, - location, - screen); - } - else /* window that opened bookmarks window has been closed */ - { - if (parent_is_browser_window || g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) - { + window = caja_application_get_spatial_window (application, + NULL, + NULL, + location, + screen, + NULL); + } else { /* window that opened bookmarks window has been closed */ + if (parent_is_browser_window || g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) { window = caja_application_create_navigation_window (application, NULL, screen); - caja_window_go_to (window, location); } else { - window = caja_application_present_spatial_window (application, - NULL, - NULL, - location, - screen); + window = caja_application_get_spatial_window (application, + NULL, + NULL, + location, + screen, + NULL); } } + caja_window_go_to (window, location); + g_object_unref (location); } -- cgit v1.2.1 From 32ebe8fbfd23e8cae92c487f5c91eff60ec8ec99 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 05:00:52 +0200 Subject: [nav-win-menus] use new CajaApplication API http://git.gnome.org/browse/nautilus/commit/?id=d5350003ac927bd683d4e18f7c0513b94f9220d7 --- src/caja-navigation-window-menus.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c index 825bc8a5..22c89c28 100644 --- a/src/caja-navigation-window-menus.c +++ b/src/caja-navigation-window-menus.c @@ -629,19 +629,23 @@ static void action_folder_window_callback (GtkAction *action, gpointer user_data) { - CajaWindow *current_window; + CajaWindow *current_window, *window; CajaWindowSlot *slot; GFile *current_location; current_window = CAJA_WINDOW (user_data); slot = current_window->details->active_pane->active_slot; current_location = caja_window_slot_get_location (slot); - caja_application_present_spatial_window ( - current_window->application, - current_window, - NULL, - current_location, - gtk_window_get_screen (GTK_WINDOW (current_window))); + window = caja_application_get_spatial_window + (current_window->application, + current_window, + NULL, + current_location, + gtk_window_get_screen (GTK_WINDOW (current_window)), + NULL); + + caja_window_go_to (window, current_location); + if (current_location != NULL) { g_object_unref (current_location); -- cgit v1.2.1 From 1638bc87bac1eb0bcf842872767d4cc953153a4e Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 05:40:18 +0200 Subject: [connect-dialog] redesign the dialog According to Allan Day's mockups. http://git.gnome.org/browse/nautilus/commit/?id=7848e74d812c22299962a8ae22b01dbd403929c0 --- src/caja-connect-server-dialog-main.c | 23 +- src/caja-connect-server-dialog.c | 1000 +++++++++++---------------------- src/caja-connect-server-dialog.h | 3 +- 3 files changed, 317 insertions(+), 709 deletions(-) diff --git a/src/caja-connect-server-dialog-main.c b/src/caja-connect-server-dialog-main.c index 44c57980..c73b0df4 100644 --- a/src/caja-connect-server-dialog-main.c +++ b/src/caja-connect-server-dialog-main.c @@ -171,20 +171,12 @@ main (int argc, char *argv[]) { GtkWidget *dialog; GOptionContext *context; - const char **args; - GFile *location; GError *error; - const GOptionEntry options[] = - { - { G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &args, NULL, N_("[URI]") }, - { NULL } - }; bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); - args = NULL; error = NULL; /* Translators: This is the --help description for the connect to server app, the initial newlines are between the command line arg and the description */ @@ -208,20 +200,7 @@ main (int argc, char *argv[]) gtk_window_set_default_icon_name (CAJA_ICON_FOLDER); - - /* command line arguments, null terminated array */ - location = NULL; - if (args) - { - location = g_file_new_for_commandline_arg (*args); - } - - dialog = caja_connect_server_dialog_new (NULL, location); - - if (location) - { - g_object_unref (location); - } + dialog = caja_connect_server_dialog_new (NULL); open_dialogs = 0; g_signal_connect (dialog, "destroy", diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index 2a855eb4..38531856 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -49,13 +49,14 @@ struct _CajaConnectServerDialogDetails { CajaApplication *application; + GtkWidget *user_details; + GtkWidget *port_spinbutton; + GtkWidget *table; GtkWidget *type_combo; - GtkWidget *uri_entry; GtkWidget *server_entry; GtkWidget *share_entry; - GtkWidget *port_entry; GtkWidget *folder_entry; GtkWidget *domain_entry; GtkWidget *user_entry; @@ -76,107 +77,71 @@ struct MethodInfo { const char *scheme; guint flags; + guint default_port; }; /* A collection of flags for MethodInfo.flags */ enum { - DEFAULT_METHOD = 0x00000001, + DEFAULT_METHOD = (1 << 0), /* Widgets to display in setup_for_type */ - SHOW_SHARE = 0x00000010, - SHOW_PORT = 0x00000020, - SHOW_USER = 0x00000040, - SHOW_DOMAIN = 0x00000080, + SHOW_SHARE = (1 << 1), + SHOW_PORT = (1 << 2), + SHOW_USER = (1 << 3), + SHOW_DOMAIN = (1 << 4), - IS_ANONYMOUS = 0x00001000 + IS_ANONYMOUS = (1 << 5) }; /* Remember to fill in descriptions below */ static struct MethodInfo methods[] = { /* FIXME: we need to alias ssh to sftp */ - { "sftp", SHOW_PORT | SHOW_USER }, - { "ftp", SHOW_PORT | SHOW_USER }, - { "ftp", DEFAULT_METHOD | IS_ANONYMOUS | SHOW_PORT}, - { "smb", SHOW_SHARE | SHOW_USER | SHOW_DOMAIN }, - { "dav", SHOW_PORT | SHOW_USER }, + { "sftp", SHOW_PORT | SHOW_USER, 22 }, + { "ftp", SHOW_PORT | SHOW_USER, 21 }, + { "ftp", DEFAULT_METHOD | IS_ANONYMOUS | SHOW_PORT, 21 }, + { "smb", SHOW_SHARE | SHOW_USER | SHOW_DOMAIN, 0 }, + { "dav", SHOW_PORT | SHOW_USER, 80 }, /* FIXME: hrm, shouldn't it work? */ - { "davs", SHOW_PORT | SHOW_USER }, - { NULL, 0 }, /* Custom URI method */ + { "davs", SHOW_PORT | SHOW_USER, 443 }, }; /* To get around non constant gettext strings */ static const char* get_method_description (struct MethodInfo *meth) { - if (!meth->scheme) - { - return _("Custom Location"); - } - else if (strcmp (meth->scheme, "sftp") == 0) - { + if (strcmp (meth->scheme, "sftp") == 0) { return _("SSH"); - } - else if (strcmp (meth->scheme, "ftp") == 0) - { - if (meth->flags & IS_ANONYMOUS) - { + } else if (strcmp (meth->scheme, "ftp") == 0) { + if (meth->flags & IS_ANONYMOUS) { return _("Public FTP"); - } - else - { + } else { return _("FTP (with login)"); } - } - else if (strcmp (meth->scheme, "smb") == 0) - { + } else if (strcmp (meth->scheme, "smb") == 0) { return _("Windows share"); - } - else if (strcmp (meth->scheme, "dav") == 0) - { + } else if (strcmp (meth->scheme, "dav") == 0) { return _("WebDAV (HTTP)"); - } - else if (strcmp (meth->scheme, "davs") == 0) - { + } else if (strcmp (meth->scheme, "davs") == 0) { return _("Secure WebDAV (HTTPS)"); /* No descriptive text */ - } - else - { + } else { return meth->scheme; } } -static void -caja_connect_server_dialog_finalize (GObject *object) -{ - CajaConnectServerDialog *dialog; - - dialog = CAJA_CONNECT_SERVER_DIALOG (object); - - g_object_unref (dialog->details->uri_entry); - g_object_unref (dialog->details->server_entry); - g_object_unref (dialog->details->share_entry); - g_object_unref (dialog->details->port_entry); - g_object_unref (dialog->details->folder_entry); - g_object_unref (dialog->details->domain_entry); - g_object_unref (dialog->details->user_entry); - g_object_unref (dialog->details->bookmark_check); - g_object_unref (dialog->details->name_entry); - - G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object); -} - static void connect_to_server (CajaConnectServerDialog *dialog) { struct MethodInfo *meth; - char *uri; GFile *location; int index; GtkTreeIter iter; + char *user, *initial_path, *server, *folder, *domain, *port_str; + char *t, *join, *uri; + double port; /* Get our method info */ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter); @@ -185,142 +150,94 @@ connect_to_server (CajaConnectServerDialog *dialog) g_assert (index < G_N_ELEMENTS (methods) && index >= 0); meth = &(methods[index]); - uri = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1); - if (strlen (uri) == 0) - { - eel_show_error_dialog (_("Cannot Connect to Server. You must enter a name for the server."), - _("Please enter a name and try again."), - GTK_WINDOW (dialog)); - g_free (uri); - return; - } + server = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1); - if (meth->scheme == NULL) - { - uri = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->uri_entry), 0, -1); - /* FIXME: we should validate it in some way? */ - } - else - { - char *user, *port, *initial_path, *server, *folder, *domain; - char *t, *join; - gboolean free_initial_path, free_user, free_domain, free_port; - - server = uri; - uri = NULL; - - user = ""; - port = ""; - initial_path = ""; - domain = ""; - free_initial_path = FALSE; - free_user = FALSE; - free_domain = FALSE; - free_port = FALSE; - - /* FTP special case */ - if (meth->flags & IS_ANONYMOUS) - { - user = "anonymous"; + user = NULL; + initial_path = NULL; + domain = NULL; + folder = NULL; - /* SMB special case */ - } - else if (strcmp (meth->scheme, "smb") == 0) - { - t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->share_entry), 0, -1); - initial_path = g_strconcat ("/", t, NULL); - free_initial_path = TRUE; - g_free (t); - } + /* FTP special case */ + if (meth->flags & IS_ANONYMOUS) { + user = g_strdup ("anonymous"); - if (gtk_widget_get_parent (dialog->details->port_entry) != NULL) - { - free_port = TRUE; - port = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->port_entry), 0, -1); - } - folder = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->folder_entry), 0, -1); - if (gtk_widget_get_parent (dialog->details->user_entry) != NULL) - { - free_user = TRUE; + /* SMB special case */ + } else if (strcmp (meth->scheme, "smb") == 0) { + t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->share_entry), 0, -1); + initial_path = g_strconcat ("/", t, NULL); - t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1); - - user = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, FALSE); + g_free (t); + } - g_free (t); - } - if (gtk_widget_get_parent (dialog->details->domain_entry) != NULL) - { - free_domain = TRUE; + /* port */ + port = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->details->port_spinbutton)); - domain = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->domain_entry), 0, -1); + /* username */ + if (!user) { + t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1); + user = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_USERINFO, FALSE); + g_free (t); + } - if (strlen (domain) != 0) - { - t = user; + /* domain */ + domain = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->domain_entry), 0, -1); - user = g_strconcat (domain , ";" , t, NULL); + if (strlen (domain) != 0) { + t = user; - if (free_user) - { - g_free (t); - } + user = g_strconcat (domain , ";" , t, NULL); + g_free (t); + } - free_user = TRUE; - } - } + /* folder */ + folder = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->folder_entry), 0, -1); - if (folder[0] != 0 && - folder[0] != '/') - { - join = "/"; - } - else - { - join = ""; - } + if (folder[0] != 0 && + folder[0] != '/') { + join = "/"; + } else { + join = ""; + } + if (initial_path != NULL) { t = folder; folder = g_strconcat (initial_path, join, t, NULL); g_free (t); + } - t = folder; - folder = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE); - g_free (t); - - uri = g_strdup_printf ("%s://%s%s%s%s%s%s", - meth->scheme, - user, (user[0] != 0) ? "@" : "", - server, - (port[0] != 0) ? ":" : "", port, - folder); + t = folder; + folder = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE); + g_free (t); - if (free_initial_path) - { - g_free (initial_path); - } - g_free (server); - if (free_port) - { - g_free (port); - } - g_free (folder); - if (free_user) - { - g_free (user); - } - if (free_domain) - { - g_free (domain); - } + /* port */ + if (port != 0 && port != meth->default_port) { + port_str = g_strdup_printf ("%d", (int) port); + } else { + port_str = NULL; } + /* final uri */ + uri = g_strdup_printf ("%s://%s%s%s%s%s%s", + meth->scheme, + (user != NULL) ? user : "", + (user[0] != 0) ? "@" : "", + server, + (port_str != NULL) ? ":" : "", + (port_str != NULL) ? port_str : "", + (folder != NULL) ? folder : ""); + + g_free (initial_path); + g_free (server); + g_free (folder); + g_free (user); + g_free (domain); + g_free (port_str); + gtk_widget_hide (GTK_WIDGET (dialog)); location = g_file_new_for_uri (uri); g_free (uri); - /* FIXME: sensitivity */ if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->bookmark_check))) { char *name; @@ -386,20 +303,14 @@ response_callback (CajaConnectServerDialog *dialog, static void caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class) { - GObjectClass *gobject_class; - g_type_class_add_private (class, sizeof (CajaConnectServerDialogDetails)); - - gobject_class = G_OBJECT_CLASS (class); - gobject_class->finalize = caja_connect_server_dialog_finalize; } static void setup_for_type (CajaConnectServerDialog *dialog) { struct MethodInfo *meth; - int index, i; - GtkWidget *label, *table; + int index; GtkTreeIter iter; /* Get our method info */ @@ -409,483 +320,155 @@ setup_for_type (CajaConnectServerDialog *dialog) g_assert (index < G_N_ELEMENTS (methods) && index >= 0); meth = &(methods[index]); - if (gtk_widget_get_parent (dialog->details->uri_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->uri_entry); - } - if (gtk_widget_get_parent (dialog->details->server_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->server_entry); - } - if (gtk_widget_get_parent (dialog->details->share_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->share_entry); - } - if (gtk_widget_get_parent (dialog->details->port_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->port_entry); - } - if (gtk_widget_get_parent (dialog->details->folder_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->folder_entry); - } - if (gtk_widget_get_parent (dialog->details->user_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->user_entry); - } - if (gtk_widget_get_parent (dialog->details->domain_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->domain_entry); - } - if (gtk_widget_get_parent (dialog->details->bookmark_check) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->bookmark_check); - } - if (gtk_widget_get_parent (dialog->details->name_entry) != NULL) - { - gtk_container_remove (GTK_CONTAINER (dialog->details->table), - dialog->details->name_entry); - } - /* Destroy all labels */ - gtk_container_foreach (GTK_CONTAINER (dialog->details->table), - (GtkCallback) gtk_widget_destroy, NULL); - - - i = 1; - table = dialog->details->table; - - if (meth->scheme == NULL) - { - label = gtk_label_new_with_mnemonic (_("_Location (URI):")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->uri_entry); - gtk_widget_show (dialog->details->uri_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->uri_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - - goto connection_name; - } - - label = gtk_label_new_with_mnemonic (_("_Server:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->server_entry); - gtk_widget_show (dialog->details->server_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->server_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - - label = gtk_label_new (_("Optional information:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 2, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - i++; - - if (meth->flags & SHOW_SHARE) - { - label = gtk_label_new_with_mnemonic (_("_Share:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->share_entry); - gtk_widget_show (dialog->details->share_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->share_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - } - - if (meth->flags & SHOW_PORT) - { - label = gtk_label_new_with_mnemonic (_("_Port:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->port_entry); - gtk_widget_show (dialog->details->port_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->port_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - } - - label = gtk_label_new_with_mnemonic (_("_Folder:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->folder_entry); - gtk_widget_show (dialog->details->folder_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->folder_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - - if (meth->flags & SHOW_USER) - { - label = gtk_label_new_with_mnemonic (_("_User Name:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->user_entry); - gtk_widget_show (dialog->details->user_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->user_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - } - - if (meth->flags & SHOW_DOMAIN) - { - label = gtk_label_new_with_mnemonic (_("_Domain Name:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->domain_entry); - gtk_widget_show (dialog->details->domain_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->domain_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - } - - - -connection_name: - - gtk_widget_show (dialog->details->bookmark_check); - gtk_table_attach (GTK_TABLE (table), dialog->details->bookmark_check, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - i++; - - label = gtk_label_new_with_mnemonic (_("Bookmark _name:")); - gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_widget_show (label); - gtk_table_attach (GTK_TABLE (table), label, - 0, 1, - i, i+1, - GTK_FILL, GTK_FILL, - 0, 0); - - gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->name_entry); - gtk_widget_show (dialog->details->name_entry); - gtk_table_attach (GTK_TABLE (table), dialog->details->name_entry, - 1, 2, - i, i+1, - GTK_FILL | GTK_EXPAND, GTK_FILL, - 0, 0); - - i++; - + g_object_set (dialog->details->share_entry, + "visible", + (meth->flags & SHOW_SHARE) != 0, + NULL); + + g_object_set (dialog->details->port_spinbutton, + "sensitive", + (meth->flags & SHOW_PORT) != 0, + "value", (gdouble) meth->default_port, + NULL); + + g_object_set (dialog->details->user_details, + "visible", + (meth->flags & SHOW_USER) != 0 || + (meth->flags & SHOW_DOMAIN) != 0, + NULL); + + g_object_set (dialog->details->user_entry, + "visible", + (meth->flags & SHOW_USER) != 0, + NULL); + + g_object_set (dialog->details->domain_entry, + "visible", + (meth->flags & SHOW_DOMAIN) != 0, + NULL); } static void -display_server_location (CajaConnectServerDialog *dialog, GFile *location) +entry_changed_callback (GtkEditable *editable, + GtkWidget *connect_button) { -#if 0 /*FIXME */ - struct MethodInfo *meth = NULL; - char *scheme; - int i, index = 0; - char *folder; - const char *t; + guint length; - /* Find an appropriate method */ - scheme = g_file_get_uri_scheme (location); - g_return_if_fail (scheme != NULL); + length = gtk_entry_get_text_length (GTK_ENTRY (editable)); - for (i = 0; i < G_N_ELEMENTS (methods); i++) - { - - /* The default is 'Custom URI' */ - if (methods[i].scheme == NULL) - { - meth = &(methods[i]); - index = i; - - } - else if (strcmp (methods[i].scheme, scheme) == 0) - { - - /* FTP Special case: If no user keep searching for public ftp */ - if (strcmp (scheme, "ftp") == 0) - { - t = mate_vfs_uri_get_user_name (uri); - if ((!t || !t[0] || strcmp (t, "anonymous") == 0) && - (!(methods[i].flags & IS_ANONYMOUS))) - { - continue; - } - } - - meth = &(methods[i]); - index = i; - break; - } - } - - g_free (scheme); - g_assert (meth); - - gtk_combo_box_set_active (GTK_COMBO_BOX (dialog->details->type_combo), index); - setup_for_type (dialog); - - /* Custom URI */ - if (meth->scheme == NULL) - { - gchar *uri; - - /* FIXME: with mate-vfs, we had MATE_VFS_URI_HIDE_PASSWORD | - * MATE_VFS_URI_HIDE_FRAGMENT_IDENTIFIER */ - uri = g_file_get_uri (location) - gtk_entry_set_text (GTK_ENTRY (dialog->details->uri_entry), uri); - g_free (uri); - - } - else - { - - folder = g_file_get_path (location); - if (!folder) - { - folder = ""; - } - else if (folder[0] == '/') - { - folder++; - } - - /* Server */ - t = mate_vfs_uri_get_host_name (uri); - gtk_entry_set_text (GTK_ENTRY (dialog->details->server_entry), - t ? t : ""); - - /* Share */ - if (meth->flags & SHOW_SHARE) - { - t = strchr (folder, '/'); - if (t) - { - char *share = g_strndup (folder, t - folder); - gtk_entry_set_text (GTK_ENTRY (dialog->details->share_entry), share); - g_free (share); - folder = t + 1; - } - - } - - /* Port */ - if (meth->flags & SHOW_PORT) - { - guint port = mate_vfs_uri_get_host_port (uri); - if (port != 0) - { - char sport[32]; - g_snprintf (sport, sizeof (sport), "%d", port); - gtk_entry_set_text (GTK_ENTRY (dialog->details->port_entry), sport); - } - } - - /* Folder */ - gtk_entry_set_text (GTK_ENTRY (dialog->details->folder_entry), folder); - g_free (folder); - - /* User */ - if (meth->flags & SHOW_USER) - { - const char *user = mate_vfs_uri_get_user_name (uri); - if (user) - { - t = strchr (user, ';'); - if (t) - { - user = t + 1; - } - gtk_entry_set_text (GTK_ENTRY (dialog->details->user_entry), user); - } - } - - /* Domain */ - if (meth->flags & SHOW_DOMAIN) - { - const char *user = mate_vfs_uri_get_user_name (uri); - if (user) - { - t = strchr (user, ';'); - if (t) - { - char *domain = g_strndup (user, t - user); - gtk_entry_set_text (GTK_ENTRY (dialog->details->domain_entry), domain); - g_free (domain); - } - } - } - } -#endif + gtk_widget_set_sensitive (connect_button, + length > 0); } static void -combo_changed_callback (GtkComboBox *combo_box, - CajaConnectServerDialog *dialog) +bind_visibility (CajaConnectServerDialog *dialog, + GtkWidget *source, + GtkWidget *dest) { - setup_for_type (dialog); -} - -static void -port_insert_text (GtkEditable *editable, - const gchar *new_text, - gint new_text_length, - gint *position) -{ - int pos; - - if (new_text_length < 0) - { - new_text_length = strlen (new_text); - } - - /* Only allow digits to be inserted as port number */ - for (pos = 0; pos < new_text_length; pos++) - { - if (!g_ascii_isdigit (new_text[pos])) - { - GtkWidget *toplevel = gtk_widget_get_toplevel (GTK_WIDGET (editable)); - if (toplevel != NULL) - { - gdk_window_beep (gtk_widget_get_window (toplevel)); - } - g_signal_stop_emission_by_name (editable, "insert_text"); - return; - } - } -} - -static void -bookmark_checkmark_toggled (GtkToggleButton *toggle, CajaConnectServerDialog *dialog) -{ - gtk_widget_set_sensitive (GTK_WIDGET(dialog->details->name_entry), - gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON (toggle))); + g_object_bind_property (source, + "visible", + dest, + "visible", + G_BINDING_DEFAULT); } static void caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) { GtkWidget *label; - GtkWidget *table; - GtkWidget *combo; - GtkWidget *hbox; - GtkWidget *vbox; + GtkWidget *alignment; + GtkWidget *content_area; + GtkWidget *combo ,* table; + GtkWidget *hbox, *connect_button; GtkListStore *store; GtkCellRenderer *renderer; + gchar *str; int i; dialog->details = G_TYPE_INSTANCE_GET_PRIVATE (dialog, CAJA_TYPE_CONNECT_SERVER_DIALOG, CajaConnectServerDialogDetails); + content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog)); + + /* set dialog properties */ gtk_window_set_title (GTK_WINDOW (dialog), _("Connect to Server")); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); - gtk_box_set_spacing (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), 2); + gtk_container_set_border_width (GTK_CONTAINER (dialog), 6); + gtk_box_set_spacing (GTK_BOX (content_area), 2); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); - vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (vbox), 5); - gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))), - vbox, FALSE, TRUE, 0); - gtk_widget_show (vbox); + /* server settings label */ + label = gtk_label_new (NULL); + str = g_strdup_printf ("%s", _("Server Details")); + gtk_label_set_markup (GTK_LABEL (label), str); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 6); + gtk_widget_show (label); + + /* server settings alignment */ + alignment = gtk_alignment_new (0, 0, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), + 0, 0, 12, 0); + gtk_box_pack_start (GTK_BOX (content_area), alignment, TRUE, TRUE, 0); + gtk_widget_show (alignment); + + table = gtk_table_new (4, 2, FALSE); + gtk_container_add (GTK_CONTAINER (alignment), table); + gtk_widget_show (table); + + /* first row: server entry + port spinbutton */ + label = gtk_label_new_with_mnemonic (_("_Server:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + gtk_widget_show (label); hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), - hbox, FALSE, TRUE, 0); gtk_widget_show (hbox); + gtk_table_attach (GTK_TABLE (table), hbox, + 1, 2, + 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + + dialog->details->server_entry = gtk_entry_new (); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->server_entry), TRUE); + gtk_box_pack_start (GTK_BOX (hbox), dialog->details->server_entry, FALSE, FALSE, 0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->server_entry); + gtk_widget_show (dialog->details->server_entry); - label = gtk_label_new_with_mnemonic (_("Service _type:")); + /* port */ + label = gtk_label_new_with_mnemonic (_("_Port:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + + dialog->details->port_spinbutton = + gtk_spin_button_new_with_range (0.0, 65535.0, 1.0); + g_object_set (dialog->details->port_spinbutton, + "digits", 0, + "numeric", TRUE, + "update-policy", GTK_UPDATE_IF_VALID, + NULL); + gtk_box_pack_start (GTK_BOX (hbox), dialog->details->port_spinbutton, + FALSE, FALSE, 0); + gtk_label_set_mnemonic_widget (GTK_LABEL (label), dialog->details->port_spinbutton); + gtk_widget_show (dialog->details->port_spinbutton); + + /* second row: type combobox */ + label = gtk_label_new (_("Type:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), - label, FALSE, FALSE, 0); dialog->details->type_combo = combo = gtk_combo_box_new (); /* each row contains: method index, textual description */ store = gtk_list_store_new (2, G_TYPE_INT, G_TYPE_STRING); gtk_combo_box_set_model (GTK_COMBO_BOX (combo), GTK_TREE_MODEL (store)); - g_object_unref (G_OBJECT (store)); + g_object_unref (store); renderer = gtk_cell_renderer_text_new (); gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE); @@ -941,71 +524,123 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) gtk_widget_show (combo); gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo); - gtk_box_pack_start (GTK_BOX (hbox), - combo, TRUE, TRUE, 0); - g_signal_connect (combo, "changed", - G_CALLBACK (combo_changed_callback), - dialog); + gtk_table_attach (GTK_TABLE (table), combo, + 1, 2, + 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND, 6, 3); + g_signal_connect_swapped (combo, "changed", + G_CALLBACK (setup_for_type), + dialog); + + /* third row: share entry */ + label = gtk_label_new (_("Share:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 2, 3, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + dialog->details->share_entry = gtk_entry_new (); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->share_entry), TRUE); + gtk_table_attach (GTK_TABLE (table), dialog->details->share_entry, + 1, 2, + 2, 3, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); - hbox = gtk_hbox_new (FALSE, 6); - gtk_box_pack_start (GTK_BOX (vbox), - hbox, FALSE, TRUE, 0); - gtk_widget_show (hbox); + bind_visibility (dialog, dialog->details->share_entry, label); - label = gtk_label_new_with_mnemonic (" "); + /* fourth row: folder entry */ + label = gtk_label_new (_("Folder:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 3, 4, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); gtk_widget_show (label); - gtk_box_pack_start (GTK_BOX (hbox), - label, FALSE, FALSE, 0); + dialog->details->folder_entry = gtk_entry_new (); + gtk_entry_set_text (GTK_ENTRY (dialog->details->folder_entry), "/"); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->folder_entry), TRUE); + gtk_table_attach (GTK_TABLE (table), dialog->details->folder_entry, + 1, 2, + 3, 4, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + gtk_widget_show (dialog->details->folder_entry); + + /* user details label */ + label = gtk_label_new (NULL); + str = g_strdup_printf ("%s", _("User Details")); + gtk_label_set_markup (GTK_LABEL (label), str); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (content_area), label, FALSE, FALSE, 6); + /* user details alignment */ + alignment = gtk_alignment_new (0, 0, 0, 0); + gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), + 0, 0, 12, 0); + gtk_box_pack_start (GTK_BOX (content_area), alignment, TRUE, TRUE, 0); - dialog->details->table = table = gtk_table_new (5, 2, FALSE); - gtk_table_set_row_spacings (GTK_TABLE (table), 6); - gtk_table_set_col_spacings (GTK_TABLE (table), 12); + bind_visibility (dialog, alignment, label); + dialog->details->user_details = alignment; + + table = gtk_table_new (2, 2, FALSE); + gtk_container_add (GTK_CONTAINER (alignment), table); gtk_widget_show (table); - gtk_box_pack_start (GTK_BOX (hbox), - table, TRUE, TRUE, 0); - dialog->details->uri_entry = caja_location_entry_new (); - /* hide the clean icon, as it doesn't make sense here */ - g_object_set (dialog->details->uri_entry, "secondary-icon-name", NULL, NULL); - dialog->details->server_entry = gtk_entry_new (); - dialog->details->share_entry = gtk_entry_new (); - dialog->details->port_entry = gtk_entry_new (); - g_signal_connect (dialog->details->port_entry, "insert_text", G_CALLBACK (port_insert_text), - NULL); - dialog->details->folder_entry = gtk_entry_new (); + /* first row: domain entry */ + label = gtk_label_new (_("Domain Name:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + dialog->details->domain_entry = gtk_entry_new (); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->domain_entry), TRUE); + gtk_table_attach (GTK_TABLE (table), dialog->details->domain_entry, + 1, 2, + 0, 1, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + + bind_visibility (dialog, dialog->details->domain_entry, label); + + /* second row: username entry */ + label = gtk_label_new (_("User Name:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + dialog->details->user_entry = gtk_entry_new (); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->user_entry), TRUE); + gtk_table_attach (GTK_TABLE (table), dialog->details->user_entry, + 1, 2, + 1, 2, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + + bind_visibility (dialog, dialog->details->user_entry, label); + + /* add as bookmark */ dialog->details->bookmark_check = gtk_check_button_new_with_mnemonic (_("Add _bookmark")); - dialog->details->name_entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (content_area), dialog->details->bookmark_check, TRUE, TRUE, 0); + gtk_widget_show (dialog->details->bookmark_check); - g_signal_connect (dialog->details->bookmark_check, "toggled", - G_CALLBACK (bookmark_checkmark_toggled), dialog); + hbox = gtk_hbox_new (FALSE, 12); + gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); - gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (dialog->details->bookmark_check), FALSE); - gtk_widget_set_sensitive (GTK_WIDGET(dialog->details->name_entry), FALSE); + label = gtk_label_new (_("Bookmark Name:")); + gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); + gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->uri_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->server_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->share_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->port_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->folder_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->domain_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->user_entry), TRUE); - gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->name_entry), TRUE); - - /* We need an extra ref so we can remove them from the table */ - g_object_ref (dialog->details->uri_entry); - g_object_ref (dialog->details->server_entry); - g_object_ref (dialog->details->share_entry); - g_object_ref (dialog->details->port_entry); - g_object_ref (dialog->details->folder_entry); - g_object_ref (dialog->details->domain_entry); - g_object_ref (dialog->details->user_entry); - g_object_ref (dialog->details->bookmark_check); - g_object_ref (dialog->details->name_entry); + dialog->details->name_entry = gtk_entry_new (); + gtk_box_pack_start (GTK_BOX (hbox), dialog->details->name_entry, TRUE, TRUE, 0); + gtk_widget_show_all (hbox); + + g_object_bind_property (dialog->details->bookmark_check, "active", + dialog->details->name_entry, "sensitive", + G_BINDING_DEFAULT | + G_BINDING_SYNC_CREATE); setup_for_type (dialog); gtk_dialog_add_button (GTK_DIALOG (dialog), @@ -1014,21 +649,25 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL); - gtk_dialog_add_button (GTK_DIALOG (dialog), - _("C_onnect"), - RESPONSE_CONNECT); + connect_button = gtk_dialog_add_button (GTK_DIALOG (dialog), + _("C_onnect"), + RESPONSE_CONNECT); gtk_dialog_set_default_response (GTK_DIALOG (dialog), RESPONSE_CONNECT); + g_signal_connect (dialog->details->server_entry, "changed", + G_CALLBACK (entry_changed_callback), + connect_button); + entry_changed_callback (GTK_EDITABLE (dialog->details->server_entry), + connect_button); + g_signal_connect (dialog, "response", G_CALLBACK (response_callback), dialog); - - } GtkWidget * -caja_connect_server_dialog_new (CajaWindow *window, GFile *location) +caja_connect_server_dialog_new (CajaWindow *window) { CajaConnectServerDialog *conndlg; GtkWidget *dialog; @@ -1043,14 +682,5 @@ caja_connect_server_dialog_new (CajaWindow *window, GFile *location) conndlg->details->application = window->application; } - if (location) - { - /* If it's a remote URI, then load as the default */ - if (!g_file_is_native (location)) - { - display_server_location (conndlg, location); - } - } - return dialog; } diff --git a/src/caja-connect-server-dialog.h b/src/caja-connect-server-dialog.h index 135df55f..65c8c58e 100644 --- a/src/caja-connect-server-dialog.h +++ b/src/caja-connect-server-dialog.h @@ -49,8 +49,7 @@ struct _CajaConnectServerDialogClass }; GType caja_connect_server_dialog_get_type (void); -GtkWidget* caja_connect_server_dialog_new (CajaWindow *window, - GFile *location); +GtkWidget* caja_connect_server_dialog_new (CajaWindow *window); /* Private internal calls */ -- cgit v1.2.1 From 71c4af286ce5fab422537202081103aded078692 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 05:41:59 +0200 Subject: [window-menus] use new connect dialog API http://git.gnome.org/browse/nautilus/commit/?id=156615f8d9f8b99dea3459cdd76392d01b9d80df --- src/caja-window-menus.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/caja-window-menus.c b/src/caja-window-menus.c index 7608ad3b..01408c07 100644 --- a/src/caja-window-menus.c +++ b/src/caja-window-menus.c @@ -243,17 +243,9 @@ action_connect_to_server_callback (GtkAction *action, gpointer user_data) { CajaWindow *window = CAJA_WINDOW (user_data); - CajaWindowSlot *slot; GtkWidget *dialog; - GFile *location; - slot = caja_window_get_active_slot (window); - location = caja_window_slot_get_location (slot); - dialog = caja_connect_server_dialog_new (window, location); - if (location) - { - g_object_unref (location); - } + dialog = caja_connect_server_dialog_new (window); gtk_widget_show (dialog); } -- cgit v1.2.1 From eade711fe26dc22391a60bc33f423817c39d9f43 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 05:46:00 +0200 Subject: [connect-operation] add CajaConnectServerOperation This is a GtkMountOperation subclass to handle password/username/domain requests directly from inside of the 'Connect to Server' dialog. http://git.gnome.org/browse/nautilus/commit/?id=c1bebe3a29bc2dc3b01ad2277a9802d9d0bc25cd --- src/Makefile.am | 6 +- src/caja-connect-server-operation.c | 140 ++++++++++++++++++++++++++++++++++++ src/caja-connect-server-operation.h | 63 ++++++++++++++++ 3 files changed, 207 insertions(+), 2 deletions(-) create mode 100644 src/caja-connect-server-operation.c create mode 100644 src/caja-connect-server-operation.h diff --git a/src/Makefile.am b/src/Makefile.am index 21de26ee..b9ec8b87 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -68,6 +68,8 @@ caja_SOURCES = \ caja-connect-server-dialog.c \ caja-connect-server-dialog.h \ caja-connect-server-dialog-nonmain.c \ + caja-connect-server-operation.c \ + caja-connect-server-operation.h \ caja-desktop-window.c \ caja-desktop-window.h \ caja-emblem-sidebar.c \ @@ -184,8 +186,8 @@ caja_connect_server_SOURCES = \ caja-connect-server-dialog.c \ caja-connect-server-dialog.h \ caja-connect-server-dialog-main.c \ - caja-location-entry.c \ - caja-location-entry.h \ + caja-connect-server-operation.c \ + caja-connect-server-operation.h \ $(NULL) caja_convert_metadata_SOURCES = \ diff --git a/src/caja-connect-server-operation.c b/src/caja-connect-server-operation.c new file mode 100644 index 00000000..51b69b84 --- /dev/null +++ b/src/caja-connect-server-operation.c @@ -0,0 +1,140 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Caja + * + * Copyright (C) 2010 Cosimo Cecchi + * + * Caja is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * Caja is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; see the file COPYING. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Cosimo Cecchi + */ + +#include + +#include "caja-connect-server-operation.h" + +#include "caja-connect-server-dialog.h" + +G_DEFINE_TYPE (CajaConnectServerOperation, + caja_connect_server_operation, GTK_TYPE_MOUNT_OPERATION); + +enum { + PROP_DIALOG = 1, + NUM_PROPERTIES +}; + +struct _CajaConnectServerOperationDetails { + CajaConnectServerDialog *dialog; +}; + +static void +fill_details_async_cb (GObject *source, + GAsyncResult *result, + gpointer user_data) +{ + CajaConnectServerDialog *dialog; + CajaConnectServerOperation *self; + gboolean res; + + self = user_data; + dialog = CAJA_CONNECT_SERVER_DIALOG (source); + + res = caja_connect_server_dialog_fill_details_finish (dialog, result); + + if (!res) { + g_mount_operation_reply (G_MOUNT_OPERATION (self), G_MOUNT_OPERATION_ABORTED); + } else { + g_mount_operation_reply (G_MOUNT_OPERATION (self), G_MOUNT_OPERATION_HANDLED); + } +} + +static void +caja_connect_server_operation_ask_password (GMountOperation *op, + const gchar *message, + const gchar *default_user, + const gchar *default_domain, + GAskPasswordFlags flags) +{ + CajaConnectServerOperation *self; + + self = CAJA_CONNECT_SERVER_OPERATION (op); + + caja_connect_server_dialog_fill_details_async (self->details->dialog, + G_MOUNT_OPERATION (self), + default_user, + default_domain, + flags, + fill_details_async_cb, + self); +} + +static void +caja_connect_server_operation_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec) +{ + CajaConnectServerOperation *self; + + self = CAJA_CONNECT_SERVER_OPERATION (object); + + switch (property_id) { + case PROP_DIALOG: + self->details->dialog = g_value_get_object (value); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + break; + } +} + +static void +caja_connect_server_operation_class_init (CajaConnectServerOperationClass *klass) +{ + GMountOperationClass *mount_op_class; + GObjectClass *object_class; + GParamSpec *pspec; + + object_class = G_OBJECT_CLASS (klass); + object_class->set_property = caja_connect_server_operation_set_property; + + mount_op_class = G_MOUNT_OPERATION_CLASS (klass); + mount_op_class->ask_password = caja_connect_server_operation_ask_password; + + pspec = g_param_spec_object ("dialog", "The connect dialog", + "The connect to server dialog", + CAJA_TYPE_CONNECT_SERVER_DIALOG, + G_PARAM_CONSTRUCT_ONLY | G_PARAM_WRITABLE | G_PARAM_STATIC_STRINGS); + g_object_class_install_property (object_class, PROP_DIALOG, pspec); + + g_type_class_add_private (klass, sizeof (CajaConnectServerOperationDetails)); +} + +static void +caja_connect_server_operation_init (CajaConnectServerOperation *self) +{ + self->details = G_TYPE_INSTANCE_GET_PRIVATE (self, + CAJA_TYPE_CONNECT_SERVER_OPERATION, + CajaConnectServerOperationDetails); +} + +GMountOperation * +caja_connect_server_operation_new (CajaConnectServerDialog *dialog) +{ + return g_object_new (CAJA_TYPE_CONNECT_SERVER_OPERATION, + "dialog", dialog, + NULL); +} diff --git a/src/caja-connect-server-operation.h b/src/caja-connect-server-operation.h new file mode 100644 index 00000000..eba0283a --- /dev/null +++ b/src/caja-connect-server-operation.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ +/* + * Caja + * + * Copyright (C) 2010 Cosimo Cecchi + * + * Caja is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * Caja is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program; see the file COPYING. If not, + * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + * + * Author: Cosimo Cecchi + */ + +#ifndef __CAJA_CONNECT_SERVER_OPERATION_H__ +#define __CAJA_CONNECT_SERVER_OPERATION_H__ + +#include +#include + +#include "caja-connect-server-dialog.h" + +#define CAJA_TYPE_CONNECT_SERVER_OPERATION\ + (caja_connect_server_operation_get_type ()) +#define CAJA_CONNECT_SERVER_OPERATION(obj)\ + (G_TYPE_CHECK_INSTANCE_CAST ((obj),\ + CAJA_TYPE_CONNECT_SERVER_OPERATION,\ + CajaConnectServerOperation)) +#define CAJA_CONNECT_SERVER_OPERATION_CLASS(klass)\ + (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CONNECT_SERVER_OPERATION,\ + CajaConnectServerOperationClass)) +#define CAJA_IS_CONNECT_SERVER_OPERATION(obj)\ + (G_TYPE_INSTANCE_CHECK_TYPE ((obj), CAJA_TYPE_CONNECT_SERVER_OPERATION) + +typedef struct _CajaConnectServerOperationDetails + CajaConnectServerOperationDetails; + +typedef struct { + GtkMountOperation parent; + CajaConnectServerOperationDetails *details; +} CajaConnectServerOperation; + +typedef struct { + GtkMountOperationClass parent_class; +} CajaConnectServerOperationClass; + +GType caja_connect_server_operation_get_type (void); + +GMountOperation * +caja_connect_server_operation_new (CajaConnectServerDialog *dialog); + + +#endif /* __CAJA_CONNECT_SERVER_OPERATION_H__ */ -- cgit v1.2.1 From 2218501731180797c5e29ce677f31fd2b2d3ecea Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 06:11:08 +0200 Subject: [connect-dialog] handle psswds, display warns/errs in info bar, tweak UI details connect-dialog: integrate password handling Also, use the info bar to display warnings/errors, and tweak the UI details. http://git.gnome.org/browse/nautilus/commit/?id=7d004452f333b7b8b804d87de49c858e8743a115 --- src/caja-connect-server-dialog-main.c | 127 ++---- src/caja-connect-server-dialog-nonmain.c | 76 +++- src/caja-connect-server-dialog.c | 680 +++++++++++++++++++++++++++---- src/caja-connect-server-dialog.h | 47 ++- 4 files changed, 723 insertions(+), 207 deletions(-) diff --git a/src/caja-connect-server-dialog-main.c b/src/caja-connect-server-dialog-main.c index c73b0df4..4c80fc16 100644 --- a/src/caja-connect-server-dialog-main.c +++ b/src/caja-connect-server-dialog-main.c @@ -22,6 +22,7 @@ * * Authors: * Vincent Untz + * Cosimo Cecchi */ #include @@ -38,10 +39,9 @@ #include #include -#include "caja-window.h" #include "caja-connect-server-dialog.h" -static int open_dialogs; +static GSimpleAsyncResult *display_location_res = NULL; static void main_dialog_destroyed (GtkWidget *widget, @@ -53,117 +53,53 @@ main_dialog_destroyed (GtkWidget *widget, gtk_main_quit (); } -static void -error_dialog_destroyed (GtkWidget *widget, - GtkWidget *main_dialog) -{ - if (--open_dialogs <= 0) - gtk_widget_destroy (main_dialog); -} - -static void -display_error_dialog (GError *error, - const char *uri, - GtkWidget *parent) +gboolean +caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self, + GAsyncResult *res, + GError **error) { - GtkDialog *error_dialog; - char *error_message; - - error_message = g_strdup_printf (_("Cannot display location \"%s\""), - uri); - error_dialog = eel_show_error_dialog (error_message, - error->message, - NULL); - - open_dialogs++; - - g_signal_connect (error_dialog, "destroy", - G_CALLBACK (error_dialog_destroyed), parent); - - gtk_window_set_screen (GTK_WINDOW (error_dialog), - gtk_widget_get_screen (parent)); + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) { + return FALSE; + } - g_free (error_message); + return TRUE; } -static void -show_uri (const char *uri, - GtkWidget *widget) +void +caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self, + CajaApplication *application, + GFile *location, + GAsyncReadyCallback callback, + gpointer user_data) { - GError *error; + GError *error; GdkAppLaunchContext *launch_context; + gchar *uri; + display_location_res = g_simple_async_result_new (G_OBJECT (self), + callback, user_data, + caja_connect_server_dialog_display_location_async); + + error = NULL; + uri = g_file_get_uri (location); launch_context = gdk_app_launch_context_new (); gdk_app_launch_context_set_screen (launch_context, - gtk_widget_get_screen (widget)); + gtk_widget_get_screen (GTK_WIDGET (self))); - error = NULL; g_app_info_launch_default_for_uri (uri, G_APP_LAUNCH_CONTEXT (launch_context), &error); g_object_unref (launch_context); - if (error) - { - display_error_dialog (error, uri, widget); - g_error_free (error); - } - else - { - /* everything is OK, destroy the main dialog and quit */ - gtk_widget_destroy (widget); - } -} - -static void -mount_enclosing_ready_cb (GFile *location, - GAsyncResult *res, - GtkWidget *widget) -{ - char *uri; - gboolean success; - GError *error = NULL; - - uri = g_file_get_uri (location); - success = g_file_mount_enclosing_volume_finish (location, - res, &error); - - if (success || - g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED)) - { - /* volume is mounted, show it */ - show_uri (uri, widget); - } - else - { - display_error_dialog (error, uri, widget); - } - - if (error) - { + if (error != NULL) { + g_simple_async_result_set_from_error (display_location_res, error); g_error_free (error); } + g_simple_async_result_complete_in_idle (display_location_res); - g_object_unref (location); - g_free (uri); -} - -void -caja_connect_server_dialog_present_uri (CajaApplication *application, - GFile *location, - GtkWidget *widget) -{ - GMountOperation *op; - - op = gtk_mount_operation_new (GTK_WINDOW (widget)); - g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_FOR_SESSION); - g_file_mount_enclosing_volume (location, - 0, op, - NULL, - (GAsyncReadyCallback) mount_enclosing_ready_cb, - widget); - g_object_unref (op); + g_object_unref (display_location_res); + display_location_res = NULL; } int @@ -181,8 +117,6 @@ main (int argc, char *argv[]) /* Translators: This is the --help description for the connect to server app, the initial newlines are between the command line arg and the description */ context = g_option_context_new (N_("\n\nAdd connect to server mount")); - g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE); - g_option_context_set_translation_domain (context, GETTEXT_PACKAGE); g_option_context_add_group (context, gtk_get_option_group (TRUE)); @@ -202,7 +136,6 @@ main (int argc, char *argv[]) dialog = caja_connect_server_dialog_new (NULL); - open_dialogs = 0; g_signal_connect (dialog, "destroy", G_CALLBACK (main_dialog_destroyed), NULL); diff --git a/src/caja-connect-server-dialog-nonmain.c b/src/caja-connect-server-dialog-nonmain.c index 0f196ca0..78015f3e 100644 --- a/src/caja-connect-server-dialog-nonmain.c +++ b/src/caja-connect-server-dialog-nonmain.c @@ -31,29 +31,69 @@ * caja-connect-server-dialog-main.c for the standalone version. */ +static GSimpleAsyncResult *display_location_res = NULL; + +static void +window_go_to_cb (CajaWindow *window, + GError *error, + gpointer user_data) +{ + CajaConnectServerDialog *self; + + self = user_data; + + if (error != NULL) { + g_simple_async_result_set_from_error (display_location_res, error); + } + + g_simple_async_result_complete (display_location_res); + + g_object_unref (display_location_res); + display_location_res = NULL; +} + +gboolean +caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self, + GAsyncResult *res, + GError **error) +{ + if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) { + return FALSE; + } + + return TRUE; +} + void -caja_connect_server_dialog_present_uri (CajaApplication *application, - GFile *location, - GtkWidget *widget) +caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self, + CajaApplication *application, + GFile *location, + GAsyncReadyCallback callback, + gpointer user_data) { CajaWindow *window; + GtkWidget *widget; + + widget = GTK_WIDGET (self); - if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) - { + display_location_res = + g_simple_async_result_new (G_OBJECT (self), + callback, user_data, + caja_connect_server_dialog_display_location_async); + + if (g_settings_get_boolean (caja_preferences, CAJA_PREFERENCES_ALWAYS_USE_BROWSER)) { window = caja_application_create_navigation_window (application, - NULL, - gtk_widget_get_screen (widget)); - caja_window_go_to (window, location); - } - else - { - caja_application_present_spatial_window (application, - NULL, - NULL, - location, - gtk_widget_get_screen (widget)); + NULL, + gtk_widget_get_screen (widget)); + } else { + window = caja_application_get_spatial_window (application, + NULL, + NULL, + location, + gtk_widget_get_screen (widget), + NULL); } - gtk_widget_destroy (widget); - g_object_unref (location); + caja_window_go_to_full (window, location, + window_go_to_cb, self); } diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index 38531856..ee5416bf 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -4,6 +4,7 @@ * Caja * * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2010 Cosimo Cecchi * * Caja is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -22,6 +23,7 @@ */ #include + #include "caja-connect-server-dialog.h" #include @@ -29,20 +31,17 @@ #include #include #include -#include "caja-location-entry.h" + +#include "caja-application.h" +#include "caja-bookmark-list.h" +#include "caja-connect-server-operation.h" +#include "caja-window.h" + #include #include /* TODO: - * - dns-sd fill out servers - * - pre-fill user? * - name entry + pre-fill - * - folder browse function - */ - -/* TODO gio port: - * - see FIXME here - * - see FIXME in caja-connect-server-dialog-main.c */ struct _CajaConnectServerDialogDetails @@ -52,7 +51,8 @@ struct _CajaConnectServerDialogDetails GtkWidget *user_details; GtkWidget *port_spinbutton; - GtkWidget *table; + GtkWidget *info_bar; + GtkWidget *info_bar_content; GtkWidget *type_combo; GtkWidget *server_entry; @@ -60,14 +60,29 @@ struct _CajaConnectServerDialogDetails GtkWidget *folder_entry; GtkWidget *domain_entry; GtkWidget *user_entry; + GtkWidget *password_entry; + GtkWidget *remember_checkbox; + GtkWidget *connect_button; - GtkWidget *bookmark_check; - GtkWidget *name_entry; + GList *iconized_entries; + + GSimpleAsyncResult *fill_details_res; + GAskPasswordFlags fill_details_flags; + GMountOperation *fill_operation; + + gboolean last_password_set; + gulong password_sensitive_id; + gboolean should_destroy; }; G_DEFINE_TYPE (CajaConnectServerDialog, caja_connect_server_dialog, GTK_TYPE_DIALOG) +static void sensitive_entry_changed_callback (GtkEditable *editable, + GtkWidget *widget); +static void iconized_entry_changed_cb (GtkEditable *entry, + CajaConnectServerDialog *dialog); + enum { RESPONSE_CONNECT @@ -132,6 +147,341 @@ get_method_description (struct MethodInfo *meth) } } +static void +dialog_restore_info_bar (CajaConnectServerDialog *dialog, + GtkMessageType message_type) +{ + if (dialog->details->info_bar_content != NULL) { + gtk_widget_destroy (dialog->details->info_bar_content); + dialog->details->info_bar_content = NULL; + } + + gtk_info_bar_set_message_type (GTK_INFO_BAR (dialog->details->info_bar), + message_type); +} + +static void +dialog_set_connecting (CajaConnectServerDialog *dialog) +{ + GtkWidget *hbox; + GtkWidget *widget; + GtkWidget *content_area; + gint width, height; + + dialog_restore_info_bar (dialog, GTK_MESSAGE_INFO); + gtk_widget_show (dialog->details->info_bar); + + content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar)); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (content_area), hbox); + gtk_widget_show (hbox); + + dialog->details->info_bar_content = hbox; + + widget = gtk_spinner_new (); + gtk_icon_size_lookup (GTK_ICON_SIZE_SMALL_TOOLBAR, &width, &height); + gtk_widget_set_size_request (widget, width, height); + gtk_spinner_start (GTK_SPINNER (widget)); + gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6); + gtk_widget_show (widget); + + widget = gtk_label_new (_("Connecting...")); + gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 6); + gtk_widget_show (widget); + + gtk_widget_set_sensitive (dialog->details->connect_button, FALSE); +} + + +static void +iconized_entry_restore (gpointer data, + gpointer user_data) +{ + GtkEntry *entry; + CajaConnectServerDialog *dialog; + + entry = data; + dialog = user_data; + + gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), + GTK_ENTRY_ICON_SECONDARY, + NULL); + + g_signal_handlers_disconnect_by_func (entry, + iconized_entry_changed_cb, + dialog); +} + +static void +iconized_entry_changed_cb (GtkEditable *entry, + CajaConnectServerDialog *dialog) +{ + dialog->details->iconized_entries = + g_list_remove (dialog->details->iconized_entries, entry); + + iconized_entry_restore (entry, dialog); +} + +static void +iconize_entry (CajaConnectServerDialog *dialog, + GtkWidget *entry) +{ + dialog->details->iconized_entries = + g_list_prepend (dialog->details->iconized_entries, entry); + + gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), + GTK_ENTRY_ICON_SECONDARY, + GTK_STOCK_DIALOG_WARNING); + + gtk_widget_grab_focus (entry); + + g_signal_connect (entry, "changed", + G_CALLBACK (iconized_entry_changed_cb), dialog); +} + +static void +set_info_bar_error (CajaConnectServerDialog *dialog, + GError *error) +{ + GtkWidget *content_area, *label, *entry, *hbox, *icon; + gchar *str; + const gchar *folder, *server; + + dialog_restore_info_bar (dialog, GTK_MESSAGE_WARNING); + + content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar)); + entry = NULL; + + switch (error->code) { + case G_IO_ERROR_FAILED_HANDLED: + return; + case G_IO_ERROR_NOT_FOUND: + folder = gtk_entry_get_text (GTK_ENTRY (dialog->details->folder_entry)); + server = gtk_entry_get_text (GTK_ENTRY (dialog->details->server_entry)); + str = g_strdup_printf (_("The folder \"%s\" cannot be opened on \"%s\"."), + folder, server); + label = gtk_label_new (str); + entry = dialog->details->folder_entry; + + g_free (str); + + break; + case G_IO_ERROR_HOST_NOT_FOUND: + server = gtk_entry_get_text (GTK_ENTRY (dialog->details->server_entry)); + str = g_strdup_printf (_("The server at \"%s\" cannot be found."), server); + label = gtk_label_new (str); + entry = dialog->details->server_entry; + + g_free (str); + + break; + case G_IO_ERROR_FAILED: + default: + label = gtk_label_new (error->message); + break; + } + + gtk_label_set_line_wrap (GTK_LABEL (label), TRUE); + gtk_widget_show (dialog->details->info_bar); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 6); + gtk_widget_show (hbox); + + icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 6); + gtk_widget_show (icon); + + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); + gtk_widget_show (label); + + if (entry != NULL) { + iconize_entry (dialog, entry); + } + + dialog->details->info_bar_content = hbox; + + gtk_button_set_label (GTK_BUTTON (dialog->details->connect_button), + _("Try Again")); + gtk_widget_set_sensitive (dialog->details->connect_button, TRUE); +} + +static void +dialog_finish_fill (CajaConnectServerDialog *dialog) +{ + GAskPasswordFlags flags; + GMountOperation *op; + + flags = dialog->details->fill_details_flags; + op = G_MOUNT_OPERATION (dialog->details->fill_operation); + + if (flags & G_ASK_PASSWORD_NEED_PASSWORD) { + g_mount_operation_set_password (op, gtk_entry_get_text (GTK_ENTRY (dialog->details->password_entry))); + } + + if (flags & G_ASK_PASSWORD_NEED_USERNAME) { + g_mount_operation_set_username (op, gtk_entry_get_text (GTK_ENTRY (dialog->details->user_entry))); + } + + if (flags & G_ASK_PASSWORD_NEED_DOMAIN) { + g_mount_operation_set_domain (op, gtk_entry_get_text (GTK_ENTRY (dialog->details->domain_entry))); + } + + if (flags & G_ASK_PASSWORD_SAVING_SUPPORTED && + gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->remember_checkbox))) { + g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_PERMANENTLY); + } + + dialog_set_connecting (dialog); + + g_simple_async_result_set_op_res_gboolean (dialog->details->fill_details_res, TRUE); + g_simple_async_result_complete (dialog->details->fill_details_res); + + g_object_unref (dialog->details->fill_details_res); + dialog->details->fill_details_res = NULL; + + g_object_unref (dialog->details->fill_operation); + dialog->details->fill_operation = NULL; +} + +static void +dialog_request_additional_details (CajaConnectServerDialog *self, + GAskPasswordFlags flags, + const gchar *default_user, + const gchar *default_domain) +{ + GtkWidget *content_area, *label, *entry, *hbox, *icon; + + self->details->fill_details_flags = flags; + + dialog_restore_info_bar (self, GTK_MESSAGE_WARNING); + + content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (self->details->info_bar)); + entry = NULL; + + hbox = gtk_hbox_new (FALSE, 6); + gtk_box_pack_start (GTK_BOX (content_area), hbox, FALSE, FALSE, 6); + gtk_widget_show (hbox); + + icon = gtk_image_new_from_stock (GTK_STOCK_DIALOG_WARNING, + GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_box_pack_start (GTK_BOX (hbox), icon, FALSE, FALSE, 6); + gtk_widget_show (icon); + + label = gtk_label_new (_("Please verify your user details.")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); + gtk_widget_show (label); + + if (flags & G_ASK_PASSWORD_NEED_PASSWORD) { + iconize_entry (self, self->details->password_entry); + } + + if (flags & G_ASK_PASSWORD_NEED_USERNAME) { + if (default_user != NULL && g_strcmp0 (default_user, "") != 0) { + gtk_entry_set_text (GTK_ENTRY (self->details->user_entry), + default_user); + } else { + iconize_entry (self, self->details->user_entry); + } + } + + if (flags & G_ASK_PASSWORD_NEED_DOMAIN) { + if (default_domain != NULL && g_strcmp0 (default_domain, "") != 0) { + gtk_entry_set_text (GTK_ENTRY (self->details->domain_entry), + default_domain); + } else { + iconize_entry (self, self->details->domain_entry); + } + } + + self->details->info_bar_content = hbox; + + gtk_widget_set_sensitive (self->details->connect_button, TRUE); + gtk_button_set_label (GTK_BUTTON (self->details->connect_button), + _("Continue")); + + if (!(flags & G_ASK_PASSWORD_SAVING_SUPPORTED)) { + g_signal_handler_disconnect (self->details->password_entry, + self->details->password_sensitive_id); + self->details->password_sensitive_id = 0; + + gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (self->details->remember_checkbox), + FALSE); + gtk_widget_set_sensitive (self->details->remember_checkbox, FALSE); + } +} + +static void +display_location_async_cb (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + CajaConnectServerDialog *dialog; + GError *error; + + dialog = CAJA_CONNECT_SERVER_DIALOG (source); + error = NULL; + + caja_connect_server_dialog_display_location_finish (dialog, + res, &error); + + if (error != NULL) { + set_info_bar_error (dialog, error); + g_error_free (error); + } else { + gtk_widget_destroy (GTK_WIDGET (dialog)); + } +} + +static void +mount_enclosing_ready_cb (GObject *source, + GAsyncResult *res, + gpointer user_data) +{ + GFile *location; + CajaConnectServerDialog *dialog; + GError *error; + + error = NULL; + location = G_FILE (source); + dialog = user_data; + + g_file_mount_enclosing_volume_finish (location, res, &error); + + if (!error || g_error_matches (error, G_IO_ERROR, G_IO_ERROR_ALREADY_MOUNTED)) { + /* volume is mounted, show it */ + caja_connect_server_dialog_display_location_async (dialog, + dialog->details->application, location, + display_location_async_cb, NULL); + } else { + if (dialog->details->should_destroy) { + gtk_widget_destroy (GTK_WIDGET (dialog)); + } else { + set_info_bar_error (dialog, error); + } + } + + if (error != NULL) { + g_error_free (error); + } +} + +static void +dialog_present_uri_async (CajaConnectServerDialog *self, + CajaApplication *application, + GFile *location) +{ + GMountOperation *op; + + op = caja_connect_server_operation_new (self); + g_file_mount_enclosing_volume (location, + 0, op, NULL, + mount_enclosing_ready_cb, self); + g_object_unref (op); +} + static void connect_to_server (CajaConnectServerDialog *dialog) { @@ -153,7 +503,7 @@ connect_to_server (CajaConnectServerDialog *dialog) server = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->server_entry), 0, -1); user = NULL; - initial_path = NULL; + initial_path = g_strdup (""); domain = NULL; folder = NULL; @@ -163,15 +513,14 @@ connect_to_server (CajaConnectServerDialog *dialog) /* SMB special case */ } else if (strcmp (meth->scheme, "smb") == 0) { + g_free (initial_path); + t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->share_entry), 0, -1); initial_path = g_strconcat ("/", t, NULL); g_free (t); } - /* port */ - port = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->details->port_spinbutton)); - /* username */ if (!user) { t = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->user_entry), 0, -1); @@ -199,17 +548,17 @@ connect_to_server (CajaConnectServerDialog *dialog) join = ""; } - if (initial_path != NULL) { - t = folder; - folder = g_strconcat (initial_path, join, t, NULL); - g_free (t); - } + t = folder; + folder = g_strconcat (initial_path, join, t, NULL); + g_free (t); t = folder; folder = g_uri_escape_string (t, G_URI_RESERVED_CHARS_ALLOWED_IN_PATH, FALSE); g_free (t); /* port */ + port = gtk_spin_button_get_value (GTK_SPIN_BUTTON (dialog->details->port_spinbutton)); + if (port != 0 && port != meth->default_port) { port_str = g_strdup_printf ("%d", (int) port); } else { @@ -233,37 +582,56 @@ connect_to_server (CajaConnectServerDialog *dialog) g_free (domain); g_free (port_str); - gtk_widget_hide (GTK_WIDGET (dialog)); - location = g_file_new_for_uri (uri); g_free (uri); - if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (dialog->details->bookmark_check))) - { - char *name; - CajaBookmark *bookmark; - CajaBookmarkList *list; - GIcon *icon; - - name = gtk_editable_get_chars (GTK_EDITABLE (dialog->details->name_entry), 0, -1); - icon = g_themed_icon_new (CAJA_ICON_FOLDER_REMOTE); - bookmark = caja_bookmark_new (location, strlen (name) ? name : NULL, - TRUE, icon); - list = caja_bookmark_list_new (); - if (!caja_bookmark_list_contains (list, bookmark)) - { - caja_bookmark_list_append (list, bookmark); + dialog_set_connecting (dialog); + dialog_present_uri_async (dialog, + dialog->details->application, + location); + + g_object_unref (location); +} + +static void +connect_to_server_or_finish_fill (CajaConnectServerDialog *dialog) +{ + if (dialog->details->fill_details_res != NULL) { + dialog_finish_fill (dialog); + } else { + connect_to_server (dialog); + } +} + +static gboolean +abort_mount_operation (CajaConnectServerDialog *dialog) +{ + if (dialog->details->fill_details_res != NULL) { + g_simple_async_result_set_op_res_gboolean (dialog->details->fill_details_res, FALSE); + g_simple_async_result_complete (dialog->details->fill_details_res); + + g_object_unref (dialog->details->fill_details_res); + dialog->details->fill_details_res = NULL; + + if (dialog->details->fill_operation) { + g_object_unref (dialog->details->fill_operation); + dialog->details->fill_operation = NULL; } - g_object_unref (bookmark); - g_object_unref (list); - g_object_unref (icon); - g_free (name); + return TRUE; } - caja_connect_server_dialog_present_uri (dialog->details->application, - location, - GTK_WIDGET (dialog)); + return FALSE; +} + +static void +destroy_dialog (CajaConnectServerDialog *dialog) +{ + if (abort_mount_operation (dialog)) { + dialog->details->should_destroy = TRUE; + } else { + gtk_widget_destroy (GTK_WIDGET (dialog)); + } } static void @@ -276,12 +644,12 @@ response_callback (CajaConnectServerDialog *dialog, switch (response_id) { case RESPONSE_CONNECT: - connect_to_server (dialog); + connect_to_server_or_finish_fill (dialog); break; case GTK_RESPONSE_NONE: case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CANCEL: - gtk_widget_destroy (GTK_WIDGET (dialog)); + destroy_dialog (dialog); break; case GTK_RESPONSE_HELP : error = NULL; @@ -300,9 +668,63 @@ response_callback (CajaConnectServerDialog *dialog, } } +static void +dialog_cleanup (CajaConnectServerDialog *dialog) +{ + /* hide the infobar */ + gtk_widget_hide (dialog->details->info_bar); + + /* set the connect button label back to 'Connect' */ + gtk_button_set_label (GTK_BUTTON (dialog->details->connect_button), + _("C_onnect")); + + /* if there was a pending mount operation, cancel it. */ + abort_mount_operation (dialog); + + /* restore password checkbox sensitivity */ + if (dialog->details->password_sensitive_id == 0) { + dialog->details->password_sensitive_id = + g_signal_connect (dialog->details->password_entry, "changed", + G_CALLBACK (sensitive_entry_changed_callback), + dialog->details->remember_checkbox); + sensitive_entry_changed_callback (GTK_EDITABLE (dialog->details->password_entry), + dialog->details->remember_checkbox); + } + + /* remove icons on the entries */ + g_list_foreach (dialog->details->iconized_entries, + (GFunc) iconized_entry_restore, dialog); + g_list_free (dialog->details->iconized_entries); + dialog->details->iconized_entries = NULL; + + dialog->details->last_password_set = FALSE; +} + +static void +caja_connect_server_dialog_finalize (GObject *object) +{ + CajaConnectServerDialog *dialog; + + dialog = CAJA_CONNECT_SERVER_DIALOG (object); + + abort_mount_operation (dialog); + + g_list_foreach (dialog->details->iconized_entries, + (GFunc) iconized_entry_restore, dialog); + g_list_free (dialog->details->iconized_entries); + dialog->details->iconized_entries = NULL; + + G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object); +} + static void caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class) { + GObjectClass *oclass; + + oclass = G_OBJECT_CLASS (class); + oclass->finalize = caja_connect_server_dialog_finalize; + g_type_class_add_private (class, sizeof (CajaConnectServerDialogDetails)); } @@ -313,7 +735,9 @@ setup_for_type (CajaConnectServerDialog *dialog) int index; GtkTreeIter iter; - /* Get our method info */ + dialog_cleanup (dialog); + + /* get our method info */ gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter); gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)), &iter, 0, &index, -1); @@ -342,6 +766,11 @@ setup_for_type (CajaConnectServerDialog *dialog) (meth->flags & SHOW_USER) != 0, NULL); + g_object_set (dialog->details->password_entry, + "visible", + (meth->flags & SHOW_USER) != 0, + NULL); + g_object_set (dialog->details->domain_entry, "visible", (meth->flags & SHOW_DOMAIN) != 0, @@ -349,15 +778,14 @@ setup_for_type (CajaConnectServerDialog *dialog) } static void -entry_changed_callback (GtkEditable *editable, - GtkWidget *connect_button) +sensitive_entry_changed_callback (GtkEditable *editable, + GtkWidget *widget) { guint length; length = gtk_entry_get_text_length (GTK_ENTRY (editable)); - gtk_widget_set_sensitive (connect_button, - length > 0); + gtk_widget_set_sensitive (widget, length > 0); } static void @@ -379,7 +807,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) GtkWidget *alignment; GtkWidget *content_area; GtkWidget *combo ,* table; - GtkWidget *hbox, *connect_button; + GtkWidget *hbox, *connect_button, *checkbox; GtkListStore *store; GtkCellRenderer *renderer; gchar *str; @@ -396,6 +824,13 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) gtk_box_set_spacing (GTK_BOX (content_area), 2); gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE); + /* infobar */ + dialog->details->info_bar = gtk_info_bar_new (); + gtk_info_bar_set_message_type (GTK_INFO_BAR (dialog->details->info_bar), + GTK_MESSAGE_INFO); + gtk_box_pack_start (GTK_BOX (content_area), dialog->details->info_bar, + FALSE, FALSE, 6); + /* server settings label */ label = gtk_label_new (NULL); str = g_strdup_printf ("%s", _("Server Details")); @@ -480,7 +915,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) const gchar * const *supported; int j; - /* skip methods that don't have corresponding MateVFSMethods */ + /* skip methods that don't have corresponding gvfs uri schemes */ supported = g_vfs_get_supported_uri_schemes (g_vfs_get_default ()); if (methods[i].scheme != NULL) @@ -582,7 +1017,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) bind_visibility (dialog, alignment, label); dialog->details->user_details = alignment; - table = gtk_table_new (2, 2, FALSE); + table = gtk_table_new (4, 2, FALSE); gtk_container_add (GTK_CONTAINER (alignment), table); gtk_widget_show (table); @@ -620,28 +1055,33 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) bind_visibility (dialog, dialog->details->user_entry, label); - /* add as bookmark */ - dialog->details->bookmark_check = gtk_check_button_new_with_mnemonic (_("Add _bookmark")); - gtk_box_pack_start (GTK_BOX (content_area), dialog->details->bookmark_check, TRUE, TRUE, 0); - gtk_widget_show (dialog->details->bookmark_check); - - hbox = gtk_hbox_new (FALSE, 12); - gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0); - - label = gtk_label_new (_("Bookmark Name:")); + /* third row: password entry */ + label = gtk_label_new (_("Password:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); - gtk_box_pack_start (GTK_BOX (hbox), label, TRUE, TRUE, 0); - - dialog->details->name_entry = gtk_entry_new (); - gtk_box_pack_start (GTK_BOX (hbox), dialog->details->name_entry, TRUE, TRUE, 0); - - gtk_widget_show_all (hbox); - - g_object_bind_property (dialog->details->bookmark_check, "active", - dialog->details->name_entry, "sensitive", - G_BINDING_DEFAULT | - G_BINDING_SYNC_CREATE); - setup_for_type (dialog); + gtk_table_attach (GTK_TABLE (table), label, + 0, 1, + 2, 3, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + + dialog->details->password_entry = gtk_entry_new (); + gtk_entry_set_activates_default (GTK_ENTRY (dialog->details->password_entry), TRUE); + gtk_entry_set_visibility (GTK_ENTRY (dialog->details->password_entry), FALSE); + gtk_table_attach (GTK_TABLE (table), dialog->details->password_entry, + 1, 2, + 2, 3, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 3); + + bind_visibility (dialog, dialog->details->password_entry, label); + + /* fourth row: remember checkbox */ + checkbox = gtk_check_button_new_with_label (_("Remember this password")); + gtk_table_attach (GTK_TABLE (table), checkbox, + 1, 2, + 3, 4, + GTK_EXPAND | GTK_FILL, GTK_EXPAND | GTK_FILL, 6, 0); + dialog->details->remember_checkbox = checkbox; + + bind_visibility (dialog, dialog->details->password_entry, checkbox); gtk_dialog_add_button (GTK_DIALOG (dialog), GTK_STOCK_HELP, @@ -654,16 +1094,19 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) RESPONSE_CONNECT); gtk_dialog_set_default_response (GTK_DIALOG (dialog), RESPONSE_CONNECT); + dialog->details->connect_button = connect_button; g_signal_connect (dialog->details->server_entry, "changed", - G_CALLBACK (entry_changed_callback), + G_CALLBACK (sensitive_entry_changed_callback), connect_button); - entry_changed_callback (GTK_EDITABLE (dialog->details->server_entry), - connect_button); + sensitive_entry_changed_callback (GTK_EDITABLE (dialog->details->server_entry), + connect_button); g_signal_connect (dialog, "response", G_CALLBACK (response_callback), dialog); + + setup_for_type (dialog); } GtkWidget * @@ -684,3 +1127,82 @@ caja_connect_server_dialog_new (CajaWindow *window) return dialog; } + +gboolean +caja_connect_server_dialog_fill_details_finish (CajaConnectServerDialog *self, + GAsyncResult *result) +{ + return g_simple_async_result_get_op_res_gboolean (G_SIMPLE_ASYNC_RESULT (result)); +} + +void +caja_connect_server_dialog_fill_details_async (CajaConnectServerDialog *self, + GMountOperation *operation, + const gchar *default_user, + const gchar *default_domain, + GAskPasswordFlags flags, + GAsyncReadyCallback callback, + gpointer user_data) +{ + GSimpleAsyncResult *fill_details_res; + const gchar *str; + GAskPasswordFlags set_flags; + + fill_details_res = g_simple_async_result_new (G_OBJECT (self), callback, user_data, + caja_connect_server_dialog_fill_details_async); + + self->details->fill_details_res = fill_details_res; + set_flags = (flags & G_ASK_PASSWORD_NEED_PASSWORD) | + (flags & G_ASK_PASSWORD_NEED_USERNAME) | + (flags & G_ASK_PASSWORD_NEED_DOMAIN); + + if (set_flags & G_ASK_PASSWORD_NEED_PASSWORD) { + /* provide the password */ + str = gtk_entry_get_text (GTK_ENTRY (self->details->password_entry)); + + if (str != NULL && g_strcmp0 (str, "") != 0 && + !self->details->last_password_set) { + g_mount_operation_set_password (G_MOUNT_OPERATION (operation), + str); + set_flags ^= G_ASK_PASSWORD_NEED_PASSWORD; + + self->details->last_password_set = TRUE; + } + } + + if (set_flags & G_ASK_PASSWORD_NEED_USERNAME) { + /* see if the default username is different from ours */ + str = gtk_entry_get_text (GTK_ENTRY (self->details->user_entry)); + + if (str != NULL && g_strcmp0 (str, "") != 0 && + g_strcmp0 (str, default_user) != 0) { + g_mount_operation_set_username (G_MOUNT_OPERATION (operation), + str); + set_flags ^= G_ASK_PASSWORD_NEED_USERNAME; + } + } + + if (set_flags & G_ASK_PASSWORD_NEED_DOMAIN) { + /* see if the default domain is different from ours */ + str = gtk_entry_get_text (GTK_ENTRY (self->details->domain_entry)); + + if (str != NULL && g_strcmp0 (str, "") && + g_strcmp0 (str, default_domain) != 0) { + g_mount_operation_set_domain (G_MOUNT_OPERATION (operation), + str); + set_flags ^= G_ASK_PASSWORD_NEED_DOMAIN; + } + } + + if (set_flags != 0) { + set_flags |= (flags & G_ASK_PASSWORD_SAVING_SUPPORTED); + self->details->fill_operation = g_object_ref (operation); + dialog_request_additional_details (self, set_flags, default_user, default_domain); + } else { + g_simple_async_result_set_op_res_gboolean (fill_details_res, TRUE); + g_simple_async_result_complete (fill_details_res); + g_object_unref (self->details->fill_details_res); + + self->details->fill_details_res = NULL; + } +} diff --git a/src/caja-connect-server-dialog.h b/src/caja-connect-server-dialog.h index 65c8c58e..1876e8a9 100644 --- a/src/caja-connect-server-dialog.h +++ b/src/caja-connect-server-dialog.h @@ -1,9 +1,9 @@ /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - /* * Caja * * Copyright (C) 2003 Red Hat, Inc. + * Copyright (C) 2010 Cosimo Cecchi * * Caja is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -26,15 +26,22 @@ #include #include + #include "caja-window.h" -#define CAJA_TYPE_CONNECT_SERVER_DIALOG (caja_connect_server_dialog_get_type ()) -#define CAJA_CONNECT_SERVER_DIALOG(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG, CajaConnectServerDialog)) -#define CAJA_CONNECT_SERVER_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CONNECT_SERVER_DIALOG, CajaConnectServerDialogClass)) -#define CAJA_IS_CONNECT_SERVER_DIALOG(obj) (G_TYPE_INSTANCE_CHECK_TYPE ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG) +#define CAJA_TYPE_CONNECT_SERVER_DIALOG\ + (caja_connect_server_dialog_get_type ()) +#define CAJA_CONNECT_SERVER_DIALOG(obj)\ + (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG,\ + CajaConnectServerDialog)) +#define CAJA_CONNECT_SERVER_DIALOG_CLASS(klass)\ + (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_CONNECT_SERVER_DIALOG,\ + CajaConnectServerDialogClass)) +#define CAJA_IS_CONNECT_SERVER_DIALOG(obj)\ + (G_TYPE_INSTANCE_CHECK_TYPE ((obj), CAJA_TYPE_CONNECT_SERVER_DIALOG) -typedef struct _CajaConnectServerDialog CajaConnectServerDialog; -typedef struct _CajaConnectServerDialogClass CajaConnectServerDialogClass; +typedef struct _CajaConnectServerDialog CajaConnectServerDialog; +typedef struct _CajaConnectServerDialogClass CajaConnectServerDialogClass; typedef struct _CajaConnectServerDialogDetails CajaConnectServerDialogDetails; struct _CajaConnectServerDialog @@ -48,13 +55,27 @@ struct _CajaConnectServerDialogClass GtkDialogClass parent_class; }; -GType caja_connect_server_dialog_get_type (void); -GtkWidget* caja_connect_server_dialog_new (CajaWindow *window); +GType caja_connect_server_dialog_get_type (void); + +GtkWidget* caja_connect_server_dialog_new (CajaWindow *window); -/* Private internal calls */ +void caja_connect_server_dialog_display_location_async (CajaConnectServerDialog *self, + CajaApplication *application, + GFile *location, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean caja_connect_server_dialog_display_location_finish (CajaConnectServerDialog *self, + GAsyncResult *result, + GError **error); -void caja_connect_server_dialog_present_uri (CajaApplication *application, - GFile *location, - GtkWidget *widget); +void caja_connect_server_dialog_fill_details_async (CajaConnectServerDialog *self, + GMountOperation *operation, + const gchar *default_user, + const gchar *default_domain, + GAskPasswordFlags flags, + GAsyncReadyCallback callback, + gpointer user_data); +gboolean caja_connect_server_dialog_fill_details_finish (CajaConnectServerDialog *self, + GAsyncResult *result); #endif /* CAJA_CONNECT_SERVER_DIALOG_H */ -- cgit v1.2.1 From 337155137426e1a07049f59f8a7ec63ec4b94c80 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 06:14:17 +0200 Subject: [connect-dialog] fixes for the handling of iconized entries http://git.gnome.org/browse/nautilus/commit/?id=1c826ed78bde5f34fd4a0f72d788b8d0824d6099 --- src/caja-connect-server-dialog.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index ee5416bf..1c759820 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -227,17 +227,19 @@ static void iconize_entry (CajaConnectServerDialog *dialog, GtkWidget *entry) { - dialog->details->iconized_entries = - g_list_prepend (dialog->details->iconized_entries, entry); + if (!g_list_find (dialog->details->iconized_entries, entry)) { + dialog->details->iconized_entries = + g_list_prepend (dialog->details->iconized_entries, entry); - gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), - GTK_ENTRY_ICON_SECONDARY, - GTK_STOCK_DIALOG_WARNING); + gtk_entry_set_icon_from_stock (GTK_ENTRY (entry), + GTK_ENTRY_ICON_SECONDARY, + GTK_STOCK_DIALOG_WARNING); - gtk_widget_grab_focus (entry); + gtk_widget_grab_focus (entry); - g_signal_connect (entry, "changed", - G_CALLBACK (iconized_entry_changed_cb), dialog); + g_signal_connect (entry, "changed", + G_CALLBACK (iconized_entry_changed_cb), dialog); + } } static void @@ -709,10 +711,10 @@ caja_connect_server_dialog_finalize (GObject *object) abort_mount_operation (dialog); - g_list_foreach (dialog->details->iconized_entries, - (GFunc) iconized_entry_restore, dialog); - g_list_free (dialog->details->iconized_entries); - dialog->details->iconized_entries = NULL; + if (dialog->details->iconized_entries != NULL) { + g_list_free (dialog->details->iconized_entries); + dialog->details->iconized_entries = NULL; + } G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object); } -- cgit v1.2.1 From cd93992b95b9b16f0c41ad200da7cdfc05ded71b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 06:17:00 +0200 Subject: [connect-dialog] display a fatal error if GVfs doesn't have methods I.e. when GVfs is not installed. http://git.gnome.org/browse/nautilus/commit/?id=1b79a8666fee56cdb704e8757f28acf486f7dc54 --- src/caja-connect-server-dialog.c | 41 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index 1c759820..c9938e6e 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -48,6 +48,7 @@ struct _CajaConnectServerDialogDetails { CajaApplication *application; + GtkWidget *primary_table; GtkWidget *user_details; GtkWidget *port_spinbutton; @@ -193,6 +194,33 @@ dialog_set_connecting (CajaConnectServerDialog *dialog) gtk_widget_set_sensitive (dialog->details->connect_button, FALSE); } +static void +connect_dialog_gvfs_error (CajaConnectServerDialog *dialog) +{ + GtkWidget *hbox, *image, *content_area, *label; + + connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_ERROR); + + content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar)); + + hbox = gtk_hbox_new (FALSE, 6); + gtk_container_add (GTK_CONTAINER (content_area), hbox); + gtk_widget_show (hbox); + + image = gtk_image_new_from_stock (GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_SMALL_TOOLBAR); + gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 6); + gtk_widget_show (image); + + label = gtk_label_new (_("Can't load the supported server method list.\n" + "Please check your GVfs installation.")); + gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 6); + gtk_widget_show (label); + + gtk_widget_set_sensitive (dialog->details->connect_button, FALSE); + gtk_widget_set_sensitive (dialog->details->primary_table, FALSE); + + gtk_widget_show (dialog->details->info_bar); +} static void iconized_entry_restore (gpointer data, @@ -740,7 +768,16 @@ setup_for_type (CajaConnectServerDialog *dialog) dialog_cleanup (dialog); /* get our method info */ - gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), &iter); + if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), + &iter)) { + /* there are no entries in the combo, something is wrong + * with our GVfs installation. + */ + connect_dialog_gvfs_error (dialog); + + return; + } + gtk_tree_model_get (gtk_combo_box_get_model (GTK_COMBO_BOX (dialog->details->type_combo)), &iter, 0, &index, -1); g_assert (index < G_N_ELEMENTS (methods) && index >= 0); @@ -852,6 +889,8 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) gtk_container_add (GTK_CONTAINER (alignment), table); gtk_widget_show (table); + dialog->details->primary_table = table; + /* first row: server entry + port spinbutton */ label = gtk_label_new_with_mnemonic (_("_Server:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); -- cgit v1.2.1 From c9507784924598f54275cd88ff408f53944b9549 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 06:21:33 +0200 Subject: [connect-dialog] make the code more readable Move bits around and rename methods; no actual code change. http://git.gnome.org/browse/nautilus/commit/?id=24100d075f747e8fc9ca3cc43a32489177f35459 --- src/caja-connect-server-dialog.c | 141 ++++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 70 deletions(-) diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index c9938e6e..c150e5fd 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -42,6 +42,7 @@ /* TODO: * - name entry + pre-fill + * - NetworkManager integration */ struct _CajaConnectServerDialogDetails @@ -101,7 +102,7 @@ enum { DEFAULT_METHOD = (1 << 0), - /* Widgets to display in setup_for_type */ + /* Widgets to display in connect_dialog_setup_for_type */ SHOW_SHARE = (1 << 1), SHOW_PORT = (1 << 2), SHOW_USER = (1 << 3), @@ -149,8 +150,8 @@ get_method_description (struct MethodInfo *meth) } static void -dialog_restore_info_bar (CajaConnectServerDialog *dialog, - GtkMessageType message_type) +connect_dialog_restore_info_bar (CajaConnectServerDialog *dialog, + GtkMessageType message_type) { if (dialog->details->info_bar_content != NULL) { gtk_widget_destroy (dialog->details->info_bar_content); @@ -162,14 +163,14 @@ dialog_restore_info_bar (CajaConnectServerDialog *dialog, } static void -dialog_set_connecting (CajaConnectServerDialog *dialog) +connect_dialog_set_connecting (CajaConnectServerDialog *dialog) { GtkWidget *hbox; GtkWidget *widget; GtkWidget *content_area; gint width, height; - dialog_restore_info_bar (dialog, GTK_MESSAGE_INFO); + connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_INFO); gtk_widget_show (dialog->details->info_bar); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar)); @@ -271,14 +272,14 @@ iconize_entry (CajaConnectServerDialog *dialog, } static void -set_info_bar_error (CajaConnectServerDialog *dialog, - GError *error) +connect_dialog_set_info_bar_error (CajaConnectServerDialog *dialog, + GError *error) { GtkWidget *content_area, *label, *entry, *hbox, *icon; gchar *str; const gchar *folder, *server; - dialog_restore_info_bar (dialog, GTK_MESSAGE_WARNING); + connect_dialog_restore_info_bar (dialog, GTK_MESSAGE_WARNING); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (dialog->details->info_bar)); entry = NULL; @@ -339,7 +340,7 @@ set_info_bar_error (CajaConnectServerDialog *dialog, } static void -dialog_finish_fill (CajaConnectServerDialog *dialog) +connect_dialog_finish_fill (CajaConnectServerDialog *dialog) { GAskPasswordFlags flags; GMountOperation *op; @@ -364,7 +365,7 @@ dialog_finish_fill (CajaConnectServerDialog *dialog) g_mount_operation_set_password_save (op, G_PASSWORD_SAVE_PERMANENTLY); } - dialog_set_connecting (dialog); + connect_dialog_set_connecting (dialog); g_simple_async_result_set_op_res_gboolean (dialog->details->fill_details_res, TRUE); g_simple_async_result_complete (dialog->details->fill_details_res); @@ -377,16 +378,16 @@ dialog_finish_fill (CajaConnectServerDialog *dialog) } static void -dialog_request_additional_details (CajaConnectServerDialog *self, - GAskPasswordFlags flags, - const gchar *default_user, - const gchar *default_domain) +connect_dialog_request_additional_details (CajaConnectServerDialog *self, + GAskPasswordFlags flags, + const gchar *default_user, + const gchar *default_domain) { GtkWidget *content_area, *label, *entry, *hbox, *icon; self->details->fill_details_flags = flags; - dialog_restore_info_bar (self, GTK_MESSAGE_WARNING); + connect_dialog_restore_info_bar (self, GTK_MESSAGE_WARNING); content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (self->details->info_bar)); entry = NULL; @@ -458,7 +459,7 @@ display_location_async_cb (GObject *source, res, &error); if (error != NULL) { - set_info_bar_error (dialog, error); + connect_dialog_set_info_bar_error (dialog, error); g_error_free (error); } else { gtk_widget_destroy (GTK_WIDGET (dialog)); @@ -489,7 +490,7 @@ mount_enclosing_ready_cb (GObject *source, if (dialog->details->should_destroy) { gtk_widget_destroy (GTK_WIDGET (dialog)); } else { - set_info_bar_error (dialog, error); + connect_dialog_set_info_bar_error (dialog, error); } } @@ -499,9 +500,9 @@ mount_enclosing_ready_cb (GObject *source, } static void -dialog_present_uri_async (CajaConnectServerDialog *self, - CajaApplication *application, - GFile *location) +connect_dialog_present_uri_async (CajaConnectServerDialog *self, + CajaApplication *application, + GFile *location) { GMountOperation *op; @@ -513,7 +514,7 @@ dialog_present_uri_async (CajaConnectServerDialog *self, } static void -connect_to_server (CajaConnectServerDialog *dialog) +connect_dialog_connect_to_server (CajaConnectServerDialog *dialog) { struct MethodInfo *meth; GFile *location; @@ -615,10 +616,10 @@ connect_to_server (CajaConnectServerDialog *dialog) location = g_file_new_for_uri (uri); g_free (uri); - dialog_set_connecting (dialog); - dialog_present_uri_async (dialog, - dialog->details->application, - location); + connect_dialog_set_connecting (dialog); + connect_dialog_present_uri_async (dialog, + dialog->details->application, + location); g_object_unref (location); } @@ -627,14 +628,14 @@ static void connect_to_server_or_finish_fill (CajaConnectServerDialog *dialog) { if (dialog->details->fill_details_res != NULL) { - dialog_finish_fill (dialog); + connect_dialog_finish_fill (dialog); } else { - connect_to_server (dialog); + connect_dialog_connect_to_server (dialog); } } static gboolean -abort_mount_operation (CajaConnectServerDialog *dialog) +connect_dialog_abort_mount_operation (CajaConnectServerDialog *dialog) { if (dialog->details->fill_details_res != NULL) { g_simple_async_result_set_op_res_gboolean (dialog->details->fill_details_res, FALSE); @@ -655,9 +656,9 @@ abort_mount_operation (CajaConnectServerDialog *dialog) } static void -destroy_dialog (CajaConnectServerDialog *dialog) +connect_dialog_destroy (CajaConnectServerDialog *dialog) { - if (abort_mount_operation (dialog)) { + if (connect_dialog_abort_mount_operation (dialog)) { dialog->details->should_destroy = TRUE; } else { gtk_widget_destroy (GTK_WIDGET (dialog)); @@ -665,9 +666,9 @@ destroy_dialog (CajaConnectServerDialog *dialog) } static void -response_callback (CajaConnectServerDialog *dialog, - int response_id, - gpointer data) +connect_dialog_response_cb (CajaConnectServerDialog *dialog, + int response_id, + gpointer data) { GError *error; @@ -679,7 +680,7 @@ response_callback (CajaConnectServerDialog *dialog, case GTK_RESPONSE_NONE: case GTK_RESPONSE_DELETE_EVENT: case GTK_RESPONSE_CANCEL: - destroy_dialog (dialog); + connect_dialog_destroy (dialog); break; case GTK_RESPONSE_HELP : error = NULL; @@ -699,7 +700,7 @@ response_callback (CajaConnectServerDialog *dialog, } static void -dialog_cleanup (CajaConnectServerDialog *dialog) +connect_dialog_cleanup (CajaConnectServerDialog *dialog) { /* hide the infobar */ gtk_widget_hide (dialog->details->info_bar); @@ -709,7 +710,7 @@ dialog_cleanup (CajaConnectServerDialog *dialog) _("C_onnect")); /* if there was a pending mount operation, cancel it. */ - abort_mount_operation (dialog); + connect_dialog_abort_mount_operation (dialog); /* restore password checkbox sensitivity */ if (dialog->details->password_sensitive_id == 0) { @@ -731,41 +732,13 @@ dialog_cleanup (CajaConnectServerDialog *dialog) } static void -caja_connect_server_dialog_finalize (GObject *object) -{ - CajaConnectServerDialog *dialog; - - dialog = CAJA_CONNECT_SERVER_DIALOG (object); - - abort_mount_operation (dialog); - - if (dialog->details->iconized_entries != NULL) { - g_list_free (dialog->details->iconized_entries); - dialog->details->iconized_entries = NULL; - } - - G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object); -} - -static void -caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class) -{ - GObjectClass *oclass; - - oclass = G_OBJECT_CLASS (class); - oclass->finalize = caja_connect_server_dialog_finalize; - - g_type_class_add_private (class, sizeof (CajaConnectServerDialogDetails)); -} - -static void -setup_for_type (CajaConnectServerDialog *dialog) +connect_dialog_setup_for_type (CajaConnectServerDialog *dialog) { struct MethodInfo *meth; int index; GtkTreeIter iter; - dialog_cleanup (dialog); + connect_dialog_cleanup (dialog); /* get our method info */ if (!gtk_combo_box_get_active_iter (GTK_COMBO_BOX (dialog->details->type_combo), @@ -1005,7 +978,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) 1, 2, GTK_EXPAND | GTK_FILL, GTK_EXPAND, 6, 3); g_signal_connect_swapped (combo, "changed", - G_CALLBACK (setup_for_type), + G_CALLBACK (connect_dialog_setup_for_type), dialog); /* third row: share entry */ @@ -1144,10 +1117,38 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) connect_button); g_signal_connect (dialog, "response", - G_CALLBACK (response_callback), + G_CALLBACK (connect_dialog_response_cb), dialog); - setup_for_type (dialog); + connect_dialog_setup_for_type (dialog); +} + +static void +caja_connect_server_dialog_finalize (GObject *object) +{ + CajaConnectServerDialog *dialog; + + dialog = CAJA_CONNECT_SERVER_DIALOG (object); + + connect_dialog_abort_mount_operation (dialog); + + if (dialog->details->iconized_entries != NULL) { + g_list_free (dialog->details->iconized_entries); + dialog->details->iconized_entries = NULL; + } + + G_OBJECT_CLASS (caja_connect_server_dialog_parent_class)->finalize (object); +} + +static void +caja_connect_server_dialog_class_init (CajaConnectServerDialogClass *class) +{ + GObjectClass *oclass; + + oclass = G_OBJECT_CLASS (class); + oclass->finalize = caja_connect_server_dialog_finalize; + + g_type_class_add_private (class, sizeof (CajaConnectServerDialogDetails)); } GtkWidget * @@ -1238,7 +1239,7 @@ caja_connect_server_dialog_fill_details_async (CajaConnectServerDialog *self, if (set_flags != 0) { set_flags |= (flags & G_ASK_PASSWORD_SAVING_SUPPORTED); self->details->fill_operation = g_object_ref (operation); - dialog_request_additional_details (self, set_flags, default_user, default_domain); + connect_dialog_request_additional_details (self, set_flags, default_user, default_domain); } else { g_simple_async_result_set_op_res_gboolean (fill_details_res, TRUE); g_simple_async_result_complete (fill_details_res); -- cgit v1.2.1 From 6268feb7e18013e204c2ddfd5c17f9d8a1c127ef Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 06:23:37 +0200 Subject: [connect-dialog] add a missing gtk_widget_show() http://git.gnome.org/browse/nautilus/commit/?id=f3bbee79b915276068e0a0d6ed9590c212e11a0a --- src/caja-connect-server-dialog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/caja-connect-server-dialog.c b/src/caja-connect-server-dialog.c index c150e5fd..6c6036fe 100644 --- a/src/caja-connect-server-dialog.c +++ b/src/caja-connect-server-dialog.c @@ -890,6 +890,7 @@ caja_connect_server_dialog_init (CajaConnectServerDialog *dialog) label = gtk_label_new_with_mnemonic (_("_Port:")); gtk_misc_set_alignment (GTK_MISC (label), 0.0, 0.5); gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0); + gtk_widget_show (label); dialog->details->port_spinbutton = gtk_spin_button_new_with_range (0.0, 65535.0, 1.0); -- cgit v1.2.1 From 1cd48341ea01f8c8e0c2adb240c6703b6f6e9848 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 30 Oct 2012 20:14:01 +0200 Subject: [icon-view] Don't use GtkObject nor eel-gtk-macros Similar to the commit linked below, but without moving background-setting code to FMDesktopIconView http://git.gnome.org/browse/nautilus/commit/?id=ab0616de55f6f817a745caac26fd2b38ae41b71b --- src/file-manager/fm-desktop-icon-view.c | 44 +++++++++------------------------ 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 37b88378..ef9a84de 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -31,13 +31,8 @@ #include #include -#include #include -#include #include -#include -#include -#include #include #include #include @@ -80,8 +75,6 @@ struct FMDesktopIconViewDetails gboolean pending_rescan; }; -static void fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view); -static void fm_desktop_icon_view_class_init (FMDesktopIconViewClass *klass); static void default_zoom_level_changed (gpointer user_data); static gboolean real_supports_auto_layout (FMIconView *view); static gboolean real_supports_scaling (FMIconView *view); @@ -93,9 +86,7 @@ static gboolean real_supports_zooming (FMDirectoryVi static void fm_desktop_icon_view_update_icon_container_fonts (FMDesktopIconView *view); static void font_changed_callback (gpointer callback_data); -EEL_CLASS_BOILERPLATE (FMDesktopIconView, - fm_desktop_icon_view, - FM_TYPE_ICON_VIEW) +G_DEFINE_TYPE (FMDesktopIconView, fm_desktop_icon_view, FM_TYPE_ICON_VIEW) static char *desktop_directory; static time_t desktop_dir_modify_time; @@ -263,7 +254,7 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent, } static void -fm_desktop_icon_view_destroy (GtkObject *object) +fm_desktop_icon_view_dispose (GObject *object) { FMDesktopIconView *icon_view; GtkUIManager *ui_manager; @@ -285,16 +276,6 @@ fm_desktop_icon_view_destroy (GtkObject *object) &icon_view->details->desktop_action_group); } - GTK_OBJECT_CLASS (parent_class)->destroy (object); -} - -static void -fm_desktop_icon_view_finalize (GObject *object) -{ - FMDesktopIconView *icon_view; - - icon_view = FM_DESKTOP_ICON_VIEW (object); - g_signal_handlers_disconnect_by_func (caja_icon_view_preferences, default_zoom_level_changed, icon_view); @@ -309,17 +290,13 @@ fm_desktop_icon_view_finalize (GObject *object) desktop_directory_changed_callback, NULL); - g_free (icon_view->details); - - G_OBJECT_CLASS (parent_class)->finalize (object); + G_OBJECT_CLASS (fm_desktop_icon_view_parent_class)->dispose (object); } static void fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class) { - G_OBJECT_CLASS (class)->finalize = fm_desktop_icon_view_finalize; - - GTK_OBJECT_CLASS (class)->destroy = fm_desktop_icon_view_destroy; + G_OBJECT_CLASS (class)->dispose = fm_desktop_icon_view_dispose; FM_DIRECTORY_VIEW_CLASS (class)->merge_menus = real_merge_menus; FM_DIRECTORY_VIEW_CLASS (class)->update_menus = real_update_menus; @@ -329,6 +306,8 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class) FM_ICON_VIEW_CLASS (class)->supports_scaling = real_supports_scaling; FM_ICON_VIEW_CLASS (class)->supports_keep_aligned = real_supports_keep_aligned; FM_ICON_VIEW_CLASS (class)->supports_labels_beside_icons = real_supports_labels_beside_icons; + + g_type_class_add_private (class, sizeof (FMDesktopIconViewDetails)); } static void @@ -547,6 +526,10 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view) GtkAllocation allocation; GtkAdjustment *hadj, *vadj; + desktop_icon_view->details = G_TYPE_INSTANCE_GET_PRIVATE (desktop_icon_view, + FM_TYPE_DESKTOP_ICON_VIEW, + FMDesktopIconViewDetails); + if (desktop_directory == NULL) { g_signal_connect_swapped (caja_preferences, "changed::" CAJA_PREFERENCES_DESKTOP_IS_HOME_DIR, @@ -560,9 +543,6 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view) caja_icon_container_set_use_drop_shadows (icon_container, TRUE); fm_icon_container_set_sort_desktop (FM_ICON_CONTAINER (icon_container), TRUE); - /* Set up details */ - desktop_icon_view->details = g_new0 (FMDesktopIconViewDetails, 1); - /* Do a reload on the desktop if we don't have FAM, a smarter * way to keep track of the items on the desktop. */ @@ -716,7 +696,7 @@ real_update_menus (FMDirectoryView *view) g_assert (FM_IS_DESKTOP_ICON_VIEW (view)); - EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, update_menus, (view)); + FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->update_menus (view); desktop_view = FM_DESKTOP_ICON_VIEW (view); @@ -782,7 +762,7 @@ real_merge_menus (FMDirectoryView *view) GtkActionGroup *action_group; const char *ui; - EEL_CALL_PARENT (FM_DIRECTORY_VIEW_CLASS, merge_menus, (view)); + FM_DIRECTORY_VIEW_CLASS (fm_desktop_icon_view_parent_class)->merge_menus (view); desktop_view = FM_DESKTOP_ICON_VIEW (view); -- cgit v1.2.1 From b6dc7b5cfbcc1f619084293d462f3f359c2e7121 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 30 Oct 2012 20:45:27 +0200 Subject: [eel-background] Don't use GtkObject nor eel-gtk-macros http://git.gnome.org/browse/nautilus/commit/?id=60044f8ef457036560fb94ad6b20cdf7bedb4f77 http://git.gnome.org/browse/nautilus/commit/?id=2e59a60800a9bc837af9132b0ac234d9d14668c6 --- eel/eel-background.c | 149 ++++++++++++++++++++++++--------------------------- eel/eel-background.h | 4 +- 2 files changed, 72 insertions(+), 81 deletions(-) diff --git a/eel/eel-background.c b/eel/eel-background.c index 9cada8c0..bc2be2f1 100644 --- a/eel/eel-background.c +++ b/eel/eel-background.c @@ -25,13 +25,8 @@ #include #include "eel-background.h" #include "eel-gdk-extensions.h" -#include "eel-gdk-pixbuf-extensions.h" #include "eel-glib-extensions.h" -#include "eel-mate-extensions.h" -#include "eel-gtk-macros.h" #include "eel-lib-self-check-functions.h" -#include "eel-string.h" -#include "eel-marshal.h" #include #include #include @@ -42,10 +37,6 @@ #define MATE_DESKTOP_USE_UNSTABLE_API #include -static void eel_background_class_init (gpointer klass); -static void eel_background_init (gpointer object, - gpointer klass); -static void eel_background_finalize (GObject *object); static GdkPixmap *eel_background_get_pixmap_and_color (EelBackground *background, GdkWindow *window, GdkColor *color); @@ -55,7 +46,7 @@ static void set_image_properties (EelBackground *background); static void init_fade (EelBackground *background, GtkWidget *widget); static void free_fade (EelBackground *background); -EEL_CLASS_BOILERPLATE (EelBackground, eel_background, GTK_TYPE_OBJECT) +G_DEFINE_TYPE (EelBackground, eel_background, G_TYPE_OBJECT); enum { @@ -103,47 +94,6 @@ struct EelBackgroundDetails gboolean is_active; }; -static void -eel_background_class_init (gpointer klass) -{ - GObjectClass *object_class; - - object_class = G_OBJECT_CLASS (klass); - - signals[APPEARANCE_CHANGED] = - g_signal_new ("appearance_changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (EelBackgroundClass, - appearance_changed), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - signals[SETTINGS_CHANGED] = - g_signal_new ("settings_changed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (EelBackgroundClass, - settings_changed), - NULL, NULL, - g_cclosure_marshal_VOID__INT, - G_TYPE_NONE, - 1, G_TYPE_INT); - signals[RESET] = - g_signal_new ("reset", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, - G_STRUCT_OFFSET (EelBackgroundClass, - reset), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, - 0); - - object_class->finalize = eel_background_finalize; -} - static void on_bg_changed (MateBG *bg, EelBackground *background) { @@ -161,13 +111,13 @@ on_bg_transitioned (MateBG *bg, EelBackground *background) } static void -eel_background_init (gpointer object, gpointer klass) +eel_background_init (EelBackground *background) { - EelBackground *background; + background->details = + G_TYPE_INSTANCE_GET_PRIVATE (background, + EEL_TYPE_BACKGROUND, + EelBackgroundDetails); - background = EEL_BACKGROUND (object); - - background->details = g_new0 (EelBackgroundDetails, 1); background->details->default_color.red = 0xffff; background->details->default_color.green = 0xffff; background->details->default_color.blue = 0xffff; @@ -231,25 +181,6 @@ free_background_pixmap (EelBackground *background) } -static void -eel_background_finalize (GObject *object) -{ - EelBackground *background; - - background = EEL_BACKGROUND (object); - - g_free (background->details->color); - eel_background_remove_current_image (background); - - free_background_pixmap (background); - - free_fade (background); - - g_free (background->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - static EelBackgroundImagePlacement placement_mate_to_eel (MateBGPlacement p) { @@ -312,6 +243,67 @@ eel_background_set_image_placement (EelBackground *background, placement_eel_to_mate (new_placement)); } + +static void +eel_background_finalize (GObject *object) +{ + EelBackground *background; + + background = EEL_BACKGROUND (object); + + g_free (background->details->color); + eel_background_remove_current_image (background); + + free_background_pixmap (background); + + free_fade (background); + + G_OBJECT_CLASS (eel_background_parent_class)->finalize (object); +} + +static void +eel_background_class_init (EelBackgroundClass *klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + + signals[APPEARANCE_CHANGED] = + g_signal_new ("appearance_changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (EelBackgroundClass, + appearance_changed), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + signals[SETTINGS_CHANGED] = + g_signal_new ("settings_changed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (EelBackgroundClass, + settings_changed), + NULL, NULL, + g_cclosure_marshal_VOID__INT, + G_TYPE_NONE, + 1, G_TYPE_INT); + signals[RESET] = + g_signal_new ("reset", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE, + G_STRUCT_OFFSET (EelBackgroundClass, + reset), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, + 0); + + object_class->finalize = eel_background_finalize; + + g_type_class_add_private (klass, sizeof (EelBackgroundDetails)); +} + EelBackground * eel_background_new (void) { @@ -603,7 +595,7 @@ void eel_background_set_color (EelBackground *background, const char *color) { - if (eel_strcmp (background->details->color, color) != 0) + if (g_strcmp0 (background->details->color, color) != 0) { g_free (background->details->color); background->details->color = g_strdup (color); @@ -632,7 +624,7 @@ eel_background_set_image_uri_helper (EelBackground *background, if (emit_signal) { - g_signal_emit (GTK_OBJECT (background), signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY); + g_signal_emit (background, signals[SETTINGS_CHANGED], 0, GDK_ACTION_COPY); } set_image_properties (background); @@ -707,7 +699,7 @@ eel_background_reset (EelBackground *background) { g_return_if_fail (EEL_IS_BACKGROUND (background)); - g_signal_emit (GTK_OBJECT (background), signals[RESET], 0); + g_signal_emit (background, signals[RESET], 0); } static void @@ -1101,7 +1093,6 @@ eel_get_widget_background (GtkWidget *widget) /* Store the background in the widget's data. */ background = eel_background_new (); - g_object_ref_sink (background); g_object_set_data_full (G_OBJECT (widget), "eel_background", background, g_object_unref); background->details->widget = widget; diff --git a/eel/eel-background.h b/eel/eel-background.h index 1604b537..cfccf2a1 100644 --- a/eel/eel-background.h +++ b/eel/eel-background.h @@ -128,13 +128,13 @@ typedef struct EelBackgroundDetails EelBackgroundDetails; struct EelBackground { - GtkObject object; + GObject object; EelBackgroundDetails *details; }; struct EelBackgroundClass { - GtkObjectClass parent_class; + GObjectClass parent_class; /* This signal is emitted whenever the background settings are * changed. -- cgit v1.2.1 From 20ceebe17ffc956f59ce28834d528d436e66f796 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 15 Nov 2012 10:56:33 +0200 Subject: [directory-background] Use weak refs instead of EelBackground destroy signal i.e. don't connect to the destroy signal of EelBackground, in favor of g_object_weak_ref() and g_object_weak_unref() Though Nautilus removed code for setting non-desktop window backgrounds: http://git.gnome.org/browse/nautilus/commit/?id=c9be35b3ee6c468a9a102b317b82b8b639637d0f ..this is a tad similar: directory-background: don't user the 'destroy' signal of EelBackground http://git.gnome.org/browse/nautilus/commit/?id=fbb6b024128e3c35aeb1d74f8e287e8870c9999f&context=12 --- libcaja-private/caja-directory-background.c | 52 +++++++++++++++++------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/libcaja-private/caja-directory-background.c b/libcaja-private/caja-directory-background.c index 21aea675..a445aab7 100644 --- a/libcaja-private/caja-directory-background.c +++ b/libcaja-private/caja-directory-background.c @@ -296,11 +296,12 @@ desktop_background_settings_notify_cb (GSettings *settings, gchar *key, gpointer } static void -desktop_background_destroyed_callback (EelBackground *background, void *georgeWBush) +desktop_background_weak_notify (gpointer data, + GObject *object) { g_signal_handlers_disconnect_by_func(mate_background_preferences, G_CALLBACK (desktop_background_settings_notify_cb), - background); + object); } static void @@ -309,10 +310,10 @@ caja_file_background_receive_settings_changes (EelBackground *background) g_signal_connect (mate_background_preferences, "changed", G_CALLBACK (desktop_background_settings_notify_cb), - background); + G_OBJECT (background)); - g_signal_connect (background, "destroy", - G_CALLBACK (desktop_background_destroyed_callback), NULL); + g_object_weak_ref (G_OBJECT (background), + desktop_background_weak_notify, NULL); } /* return true if the background is not in the default state */ @@ -563,9 +564,11 @@ background_reset_callback (EelBackground *background, /* handle the background destroyed signal */ static void -background_destroyed_callback (EelBackground *background, - CajaFile *file) +background_weak_notify (gpointer data, + GObject *background) { + CajaFile *file = CAJA_FILE (data); + g_signal_handlers_disconnect_by_func (file, G_CALLBACK (saved_settings_changed_callback), background); @@ -598,23 +601,26 @@ caja_connect_background_to_file_metadata (GtkWidget *widget, if (old_file != NULL) { g_assert (CAJA_IS_FILE (old_file)); - g_signal_handlers_disconnect_by_func - (background, - G_CALLBACK (background_changed_callback), old_file); - g_signal_handlers_disconnect_by_func - (background, - G_CALLBACK (background_destroyed_callback), old_file); - g_signal_handlers_disconnect_by_func - (background, - G_CALLBACK (background_reset_callback), old_file); - g_signal_handlers_disconnect_by_func - (old_file, - G_CALLBACK (saved_settings_changed_callback), background); + + g_signal_handlers_disconnect_by_func (background, + G_CALLBACK (background_changed_callback), + old_file); + + g_signal_handlers_disconnect_by_func (background, + G_CALLBACK (background_reset_callback), + old_file); + + g_object_weak_unref (G_OBJECT (background), background_weak_notify, old_file); + + g_signal_handlers_disconnect_by_func (old_file, + G_CALLBACK (saved_settings_changed_callback), + background); + caja_file_monitor_remove (old_file, background); + g_signal_handlers_disconnect_by_func (caja_preferences, caja_file_background_theme_changed, background); - } /* Attach the new directory. */ @@ -629,13 +635,15 @@ caja_connect_background_to_file_metadata (GtkWidget *widget, { g_signal_connect_object (background, "settings_changed", G_CALLBACK (background_changed_callback), file, 0); - g_signal_connect_object (background, "destroy", - G_CALLBACK (background_destroyed_callback), file, 0); + g_signal_connect_object (background, "reset", G_CALLBACK (background_reset_callback), file, 0); + g_signal_connect_object (file, "changed", G_CALLBACK (saved_settings_changed_callback), background, 0); + g_object_weak_ref (G_OBJECT (background), background_weak_notify, file); + /* arrange to receive file metadata */ caja_file_monitor_add (file, background, -- cgit v1.2.1 From 4fe815f4dc825928008a1fc09e53ebcbbc22569d Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 30 Oct 2012 23:31:43 +0200 Subject: [eel-stock-dialogs] don't use GtkObject http://git.gnome.org/browse/nautilus/commit/?id=5edcd42e503623c11bf55c6afba437b3013c7f45 --- eel/eel-stock-dialogs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/eel/eel-stock-dialogs.c b/eel/eel-stock-dialogs.c index 6cf48f02..7f83476e 100644 --- a/eel/eel-stock-dialogs.c +++ b/eel/eel-stock-dialogs.c @@ -60,7 +60,7 @@ typedef struct static GHashTable *timed_wait_hash_table; -static void timed_wait_dialog_destroy_callback (GtkObject *object, gpointer callback_data); +static void timed_wait_dialog_destroy_callback (GtkWidget *object, gpointer callback_data); static guint timed_wait_hash (gconstpointer value) @@ -86,7 +86,7 @@ timed_wait_hash_equal (gconstpointer value1, gconstpointer value2) } static void -timed_wait_delayed_close_destroy_dialog_callback (GtkObject *object, gpointer callback_data) +timed_wait_delayed_close_destroy_dialog_callback (GtkWidget *object, gpointer callback_data) { g_source_remove (GPOINTER_TO_UINT (callback_data)); } @@ -103,7 +103,7 @@ timed_wait_delayed_close_timeout_callback (gpointer callback_data) G_CALLBACK (timed_wait_delayed_close_destroy_dialog_callback), GUINT_TO_POINTER (handler_id)); - gtk_object_destroy (GTK_OBJECT (callback_data)); + gtk_widget_destroy (GTK_WIDGET (callback_data)); return FALSE; } @@ -153,7 +153,7 @@ timed_wait_free (TimedWait *wait) } else { - gtk_object_destroy (GTK_OBJECT (wait->dialog)); + gtk_widget_destroy (GTK_WIDGET (wait->dialog)); } } @@ -162,7 +162,7 @@ timed_wait_free (TimedWait *wait) } static void -timed_wait_dialog_destroy_callback (GtkObject *object, gpointer callback_data) +timed_wait_dialog_destroy_callback (GtkWidget *object, gpointer callback_data) { TimedWait *wait; @@ -424,7 +424,7 @@ show_message_dialog (const char *primary_text, gtk_widget_show (GTK_WIDGET (dialog)); g_signal_connect (dialog, "response", - G_CALLBACK (gtk_object_destroy), NULL); + G_CALLBACK (gtk_widget_destroy), NULL); return dialog; } -- cgit v1.2.1 From 5f7d0e33a04e69778509edb93beabbe0e62ab69b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 30 Oct 2012 23:42:48 +0200 Subject: [eel-canvas] don't use GtkObject (GTK3) the ::destroy signal of GtkObject has only been moved to GtkWidget in GTK3 (after GtkObject removal): http://developer.gnome.org/gtk3/3.0/ch25s02.html So, we conditionals in this case, to keep working with GTK2 Nautilus commit message: This implies adding a 'destroy' signal to EelCanvasItem, with similar semantics to gtk_object_destroy() http://git.gnome.org/browse/nautilus/commit/?id=1f615321613751a5dbc84d5ef7f20edd104b8dc4 --- eel/eel-canvas-rect-ellipse.c | 21 ---------- eel/eel-canvas.c | 91 +++++++++++++++++++++++++++---------------- eel/eel-canvas.h | 8 +++- 3 files changed, 63 insertions(+), 57 deletions(-) diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index 9d738243..18263ce9 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -68,7 +68,6 @@ enum static void eel_canvas_re_class_init (EelCanvasREClass *klass); static void eel_canvas_re_init (EelCanvasRE *re); -static void eel_canvas_re_destroy (GtkObject *object); static void eel_canvas_re_set_property (GObject *object, guint param_id, const GValue *value, @@ -133,11 +132,9 @@ static void eel_canvas_re_class_init (EelCanvasREClass *klass) { GObjectClass *gobject_class; - GtkObjectClass *object_class; EelCanvasItemClass *item_class; gobject_class = (GObjectClass *) klass; - object_class = (GtkObjectClass *) klass; item_class = (EelCanvasItemClass *) klass; re_parent_class = g_type_class_peek_parent (klass); @@ -223,8 +220,6 @@ eel_canvas_re_class_init (EelCanvasREClass *klass) 0.0, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE)); - object_class->destroy = eel_canvas_re_destroy; - item_class->realize = eel_canvas_re_realize; item_class->unrealize = eel_canvas_re_unrealize; item_class->translate = eel_canvas_re_translate; @@ -241,22 +236,6 @@ eel_canvas_re_init (EelCanvasRE *re) re->width = 0.0; } -static void -eel_canvas_re_destroy (GtkObject *object) -{ - EelCanvasRE *re; - - g_return_if_fail (object != NULL); - g_return_if_fail (EEL_IS_CANVAS_RE (object)); - - re = EEL_CANVAS_RE (object); - - /* remember, destroy can be run multiple times! */ - - if (GTK_OBJECT_CLASS (re_parent_class)->destroy) - (* GTK_OBJECT_CLASS (re_parent_class)->destroy) (object); -} - static void get_bounds (EelCanvasRE *re, double *px1, double *py1, double *px2, double *py2) { EelCanvasItem *item; diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index ff38d197..647de723 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -101,6 +101,7 @@ enum enum { + ITEM_DESTROY, ITEM_EVENT, ITEM_LAST_SIGNAL }; @@ -111,7 +112,7 @@ static int emit_event (EelCanvas *canvas, GdkEvent *event static guint item_signals[ITEM_LAST_SIGNAL]; -static GtkObjectClass *item_parent_class; +static GObjectClass *item_parent_class; static gpointer accessible_item_parent_class; static gpointer accessible_parent_class; @@ -145,10 +146,10 @@ eel_canvas_item_get_type (void) (GInstanceInitFunc) eel_canvas_item_init }; - canvas_item_type = g_type_register_static (gtk_object_get_type (), - "EelCanvasItem", - &canvas_item_info, - 0); + canvas_item_type = g_type_register_static (G_TYPE_INITIALLY_UNOWNED, + "EelCanvasItem", + &canvas_item_info, + 0); } return canvas_item_type; @@ -359,9 +360,21 @@ eel_canvas_item_dispose (GObject *object) item->canvas = NULL; } + g_object_set_data (object, "in-destruction", GINT_TO_POINTER (1)); + g_signal_emit (object, item_signals[ITEM_DESTROY], 0); + + g_object_set_data (object, "in-destruction", NULL); + G_OBJECT_CLASS (item_parent_class)->dispose (object); } +void +eel_canvas_item_destroy (EelCanvasItem *item) +{ + if (g_object_get_data (G_OBJECT (item), "in-destruction") == NULL) { + g_object_run_dispose (G_OBJECT (item)); + } +} /* Realize handler for canvas items */ static void @@ -1200,7 +1213,7 @@ static void eel_canvas_group_get_property(GObject *object, GValue *value, GParamSpec *pspec); -static void eel_canvas_group_destroy (GtkObject *object); +static void eel_canvas_group_destroy (EelCanvasItem *object); static void eel_canvas_group_update (EelCanvasItem *item, double i2w_dx, @@ -1266,11 +1279,9 @@ static void eel_canvas_group_class_init (EelCanvasGroupClass *klass) { GObjectClass *gobject_class; - GtkObjectClass *object_class; EelCanvasItemClass *item_class; gobject_class = (GObjectClass *) klass; - object_class = (GtkObjectClass *) klass; item_class = (EelCanvasItemClass *) klass; group_parent_class = g_type_class_peek_parent (klass); @@ -1293,8 +1304,7 @@ eel_canvas_group_class_init (EelCanvasGroupClass *klass) -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_READWRITE)); - object_class->destroy = eel_canvas_group_destroy; - + item_class->destroy = eel_canvas_group_destroy; item_class->update = eel_canvas_group_update; item_class->unrealize = eel_canvas_group_unrealize; item_class->map = eel_canvas_group_map; @@ -1391,7 +1401,7 @@ eel_canvas_group_get_property (GObject *gobject, guint param_id, /* Destroy handler for canvas groups */ static void -eel_canvas_group_destroy (GtkObject *object) +eel_canvas_group_destroy (EelCanvasItem *object) { EelCanvasGroup *group; EelCanvasItem *child; @@ -1407,11 +1417,11 @@ eel_canvas_group_destroy (GtkObject *object) child = list->data; list = list->next; - gtk_object_destroy (GTK_OBJECT (child)); + eel_canvas_item_destroy (child); } - if (GTK_OBJECT_CLASS (group_parent_class)->destroy) - (* GTK_OBJECT_CLASS (group_parent_class)->destroy) (object); + if (EEL_CANVAS_ITEM_CLASS (group_parent_class)->destroy) + (* EEL_CANVAS_ITEM_CLASS (group_parent_class)->destroy) (object); } /* Update handler for canvas groups */ @@ -1720,12 +1730,7 @@ eel_canvas_group_bounds (EelCanvasItem *item, double *x1, double *y1, double *x2 static void group_add (EelCanvasGroup *group, EelCanvasItem *item) { -#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14) g_object_ref_sink (item); -#else - g_object_ref (item); - gtk_object_sink (GTK_OBJECT (item)); -#endif if (!group->item_list) { @@ -1793,7 +1798,11 @@ enum static void eel_canvas_class_init (EelCanvasClass *klass); static void eel_canvas_init (EelCanvas *canvas); +#if GTK_CHECK_VERSION (3, 0, 0) +static void eel_canvas_destroy (GtkWidget *object); +#else static void eel_canvas_destroy (GtkObject *object); +#endif static void eel_canvas_map (GtkWidget *widget); static void eel_canvas_unmap (GtkWidget *widget); static void eel_canvas_realize (GtkWidget *widget); @@ -2108,11 +2117,9 @@ static void eel_canvas_class_init (EelCanvasClass *klass) { GObjectClass *gobject_class; - GtkObjectClass *object_class; GtkWidgetClass *widget_class; gobject_class = (GObjectClass *)klass; - object_class = (GtkObjectClass *) klass; widget_class = (GtkWidgetClass *) klass; canvas_parent_class = g_type_class_peek_parent (klass); @@ -2120,8 +2127,11 @@ eel_canvas_class_init (EelCanvasClass *klass) gobject_class->set_property = eel_canvas_set_property; gobject_class->get_property = eel_canvas_get_property; - object_class->destroy = eel_canvas_destroy; - +#if !GTK_CHECK_VERSION (3, 0, 0) + GTK_OBJECT_CLASS (klass)->destroy = eel_canvas_destroy; +#else + widget_class->destroy = eel_canvas_destroy; +#endif widget_class->map = eel_canvas_map; widget_class->unmap = eel_canvas_unmap; widget_class->realize = eel_canvas_realize; @@ -2143,7 +2153,7 @@ eel_canvas_class_init (EelCanvasClass *klass) canvas_signals[DRAW_BACKGROUND] = g_signal_new ("draw_background", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EelCanvasClass, draw_background), NULL, NULL, @@ -2160,7 +2170,7 @@ eel_canvas_class_init (EelCanvasClass *klass) * never ever do this, so we panic if this happens. */ static void -panic_root_destroyed (GtkObject *object, gpointer data) +panic_root_destroyed (GtkWidget *object, gpointer data) { g_error ("Eeeek, root item %p of canvas %p was destroyed!", object, data); } @@ -2195,12 +2205,7 @@ eel_canvas_init (EelCanvas *canvas) canvas->root = EEL_CANVAS_ITEM (g_object_new (eel_canvas_group_get_type (), NULL)); canvas->root->canvas = canvas; -#if GLIB_CHECK_VERSION(2,10,0) && GTK_CHECK_VERSION(2,8,14) g_object_ref_sink (canvas->root); -#else - g_object_ref (canvas->root); - gtk_object_sink (GTK_OBJECT (canvas->root)); -#endif canvas->root_destroy_id = g_signal_connect (G_OBJECT (canvas->root), "destroy", G_CALLBACK (panic_root_destroyed), canvas); @@ -2246,7 +2251,11 @@ shutdown_transients (EelCanvas *canvas) /* Destroy handler for EelCanvas */ static void +#if GTK_CHECK_VERSION (3, 0, 0) +eel_canvas_destroy (GtkWidget *object) +#else eel_canvas_destroy (GtkObject *object) +#endif { EelCanvas *canvas; @@ -2265,14 +2274,19 @@ eel_canvas_destroy (GtkObject *object) { EelCanvasItem *root = canvas->root; canvas->root = NULL; - gtk_object_destroy (GTK_OBJECT (root)); + eel_canvas_item_destroy (root); g_object_unref (root); } shutdown_transients (canvas); +#if GTK_CHECK_VERSION (3, 0, 0) + if (GTK_WIDGET_CLASS (canvas_parent_class)->destroy) + (* GTK_WIDGET_CLASS (canvas_parent_class)->destroy) (object); +#else if (GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (* GTK_OBJECT_CLASS (canvas_parent_class)->destroy) (object); +#endif } /** @@ -2673,14 +2687,14 @@ emit_event (EelCanvas *canvas, GdkEvent *event) while (item && !finished) { - g_object_ref (GTK_OBJECT (item)); + g_object_ref (item); g_signal_emit ( G_OBJECT (item), item_signals[ITEM_EVENT], 0, &ev, &finished); parent = item->parent; - g_object_unref (GTK_OBJECT (item)); + g_object_unref (item); item = parent; } @@ -4015,7 +4029,7 @@ eel_canvas_item_accessible_get_type (void) GTypeInfo tinfo = { 0 }; factory = atk_registry_get_factory (atk_get_default_registry(), - GTK_TYPE_OBJECT); + G_TYPE_INITIALLY_UNOWNED); if (!factory) { return G_TYPE_INVALID; @@ -4148,6 +4162,15 @@ eel_canvas_item_class_init (EelCanvasItemClass *klass) G_TYPE_BOOLEAN, 1, GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE); + item_signals[ITEM_DESTROY] = + g_signal_new ("destroy", + G_TYPE_FROM_CLASS (klass), + G_SIGNAL_RUN_CLEANUP | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS, + G_STRUCT_OFFSET (EelCanvasItemClass, destroy), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + klass->realize = eel_canvas_item_realize; klass->unrealize = eel_canvas_item_unrealize; klass->map = eel_canvas_item_map; diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index 453cdaee..b288dedf 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -115,7 +115,7 @@ extern "C" { struct _EelCanvasItem { - GtkObject object; + GInitiallyUnowned object; /* Parent canvas for this item */ EelCanvas *canvas; @@ -132,7 +132,9 @@ extern "C" { struct _EelCanvasItemClass { - GtkObjectClass parent_class; + GInitiallyUnownedClass parent_class; + + void (* destroy) (EelCanvasItem *item); /* Tell the item to update itself. The flags are from the update flags * defined above. The item should update its internal state from its @@ -195,6 +197,8 @@ extern "C" { EelCanvasItem *eel_canvas_item_new (EelCanvasGroup *parent, GType type, const gchar *first_arg_name, ...); + void eel_canvas_item_destroy (EelCanvasItem *item); + /* Constructors for use in derived classes and language wrappers */ void eel_canvas_item_construct (EelCanvasItem *item, EelCanvasGroup *parent, const gchar *first_arg_name, va_list args); -- cgit v1.2.1 From ca47debc4ffe4f3ec5b8d6094261dbef02b73dcd Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 30 Oct 2012 23:45:15 +0200 Subject: [eel-editable-label] don't use GtkObject http://git.gnome.org/browse/nautilus/commit/?id=b5f9acb9029c015558ab678e01fc2c8dcc8c6c82 --- eel/eel-editable-label.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 7ed8b521..57386f88 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -213,7 +213,6 @@ static void eel_editable_label_class_init (EelEditableLabelClass *class) { GObjectClass *gobject_class = G_OBJECT_CLASS (class); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (class); GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (class); GtkBindingSet *binding_set; @@ -250,7 +249,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[MOVE_CURSOR] = g_signal_new ("move_cursor", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EelEditableLabelClass, move_cursor), NULL, NULL, @@ -259,7 +258,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[COPY_CLIPBOARD] = g_signal_new ("copy_clipboard", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EelEditableLabelClass, copy_clipboard), NULL, NULL, @@ -268,7 +267,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[POPULATE_POPUP] = g_signal_new ("populate_popup", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EelEditableLabelClass, populate_popup), NULL, NULL, @@ -277,7 +276,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[DELETE_FROM_CURSOR] = g_signal_new ("delete_from_cursor", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EelEditableLabelClass, delete_from_cursor), NULL, NULL, @@ -286,7 +285,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[CUT_CLIPBOARD] = g_signal_new ("cut_clipboard", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EelEditableLabelClass, cut_clipboard), NULL, NULL, @@ -295,7 +294,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[PASTE_CLIPBOARD] = g_signal_new ("paste_clipboard", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EelEditableLabelClass, paste_clipboard), NULL, NULL, @@ -304,7 +303,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) signals[TOGGLE_OVERWRITE] = g_signal_new ("toggle_overwrite", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (EelEditableLabelClass, toggle_overwrite), NULL, NULL, @@ -312,7 +311,7 @@ eel_editable_label_class_init (EelEditableLabelClass *class) G_TYPE_NONE, 0); - g_object_class_install_property (G_OBJECT_CLASS(object_class), + g_object_class_install_property (gobject_class, PROP_TEXT, g_param_spec_string ("text", _("Text"), @@ -2969,7 +2968,7 @@ activate_cb (GtkWidget *menuitem, EelEditableLabel *label) { const gchar *signal = g_object_get_data (G_OBJECT (menuitem), "gtk-signal"); - g_signal_emit_by_name (GTK_OBJECT (label), signal); + g_signal_emit_by_name (label, signal); } static void @@ -3103,7 +3102,7 @@ popup_targets_received (GtkClipboard *clipboard, gtk_im_multicontext_append_menuitems (GTK_IM_MULTICONTEXT (label->im_context), GTK_MENU_SHELL (submenu)); - g_signal_emit (GTK_OBJECT (label), + g_signal_emit (label, signals[POPULATE_POPUP], 0, label->popup_menu); -- cgit v1.2.1 From 4895118afc287dc511792a5f91f109a2e1f868d0 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 31 Oct 2012 04:23:12 +0200 Subject: [lc-p] don't use GtkObject (GTK3) the ::destroy signal of GtkObject has only been moved to GtkWidget in GTK3 (after GtkObject removal): http://developer.gnome.org/gtk3/3.0/ch25s02.html So, we use conditionals in this case, to keep working with GTK2 Original commit: http://git.gnome.org/browse/nautilus/commit/?id=aef4cfcf93ef34a0b2d4c87b40fcec2b7a66dd06 --- libcaja-private/caja-autorun.c | 2 +- libcaja-private/caja-clipboard.c | 4 ++-- libcaja-private/caja-entry.c | 12 ++++-------- libcaja-private/caja-icon-container.c | 16 +++++++++++++--- libcaja-private/caja-mime-actions.c | 6 +++--- libcaja-private/caja-mime-application-chooser.c | 10 ---------- libcaja-private/caja-open-with-dialog.c | 12 +----------- libcaja-private/caja-program-choosing.c | 2 +- 8 files changed, 25 insertions(+), 39 deletions(-) diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index 21f71eb8..89b8e63d 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -274,7 +274,7 @@ dialog_response_cb (GtkDialog *dialog, } static void -dialog_destroy_cb (GtkObject *object, +dialog_destroy_cb (GtkWidget *object, CajaAutorunComboBoxData *data) { handle_dialog_closure (data); diff --git a/libcaja-private/caja-clipboard.c b/libcaja-private/caja-clipboard.c index b1614509..bc06675a 100644 --- a/libcaja-private/caja-clipboard.c +++ b/libcaja-private/caja-clipboard.c @@ -432,7 +432,7 @@ owner_change_callback (GtkClipboard *clipboard, } static void -target_destroy_callback (GtkObject *object, +target_destroy_callback (GtkWidget *object, gpointer callback_data) { TargetCallbackData *target_data; @@ -440,7 +440,7 @@ target_destroy_callback (GtkObject *object, g_assert (callback_data != NULL); target_data = callback_data; - if (clipboard_items_are_merged_in (GTK_WIDGET(object))) + if (clipboard_items_are_merged_in (object)) { merge_out_clipboard_menu_items (G_OBJECT (object), callback_data); } diff --git a/libcaja-private/caja-entry.c b/libcaja-private/caja-entry.c index 863b1b4f..fb9ac38c 100644 --- a/libcaja-private/caja-entry.c +++ b/libcaja-private/caja-entry.c @@ -395,12 +395,10 @@ static void caja_entry_class_init (CajaEntryClass *class) { GtkWidgetClass *widget_class; - GtkObjectClass *object_class; GObjectClass *gobject_class; widget_class = GTK_WIDGET_CLASS (class); gobject_class = G_OBJECT_CLASS (class); - object_class = GTK_OBJECT_CLASS (class); widget_class->button_press_event = caja_entry_button_press; widget_class->button_release_event = caja_entry_button_release; @@ -413,19 +411,17 @@ caja_entry_class_init (CajaEntryClass *class) /* Set up signals */ signals[USER_CHANGED] = g_signal_new ("user_changed", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CajaEntryClass, - user_changed), + G_STRUCT_OFFSET (CajaEntryClass, user_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); signals[SELECTION_CHANGED] = g_signal_new ("selection_changed", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (CajaEntryClass, - selection_changed), + G_STRUCT_OFFSET (CajaEntryClass, selection_changed), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index f9b01311..0f6898c9 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4379,10 +4379,12 @@ select_previous_or_next_icon (CajaIconContainer *container, } #endif -/* GtkObject methods. */ - static void +#if GTK_CHECK_VERSION(3, 0, 0) +destroy (GtkWidget *object) +#else destroy (GtkObject *object) +#endif { CajaIconContainer *container; @@ -4439,8 +4441,11 @@ destroy (GtkObject *object) } } - +#if GTK_CHECK_VERSION(3, 0, 0) + GTK_WIDGET_CLASS (caja_icon_container_parent_class)->destroy (object); +#else GTK_OBJECT_CLASS (caja_icon_container_parent_class)->destroy (object); +#endif } static void @@ -6213,7 +6218,12 @@ caja_icon_container_class_init (CajaIconContainerClass *class) G_OBJECT_CLASS (class)->constructor = caja_icon_container_constructor; G_OBJECT_CLASS (class)->finalize = finalize; + +#if GTK_CHECK_VERSION(3, 0, 0) + GTK_WIDGET_CLASS (class)->destroy = destroy; +#else GTK_OBJECT_CLASS (class)->destroy = destroy; +#endif /* Signals. */ diff --git a/libcaja-private/caja-mime-actions.c b/libcaja-private/caja-mime-actions.c index a4dc8c97..794c84b0 100644 --- a/libcaja-private/caja-mime-actions.c +++ b/libcaja-private/caja-mime-actions.c @@ -793,7 +793,7 @@ report_broken_symbolic_link (GtkWindow *parent_window, CajaFile *file) */ response = gtk_dialog_run (dialog); - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); if (response == GTK_RESPONSE_YES) { @@ -860,7 +860,7 @@ get_executable_text_file_action (GtkWindow *parent_window, CajaFile *file) g_free (detail); response = gtk_dialog_run (dialog); - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); switch (response) { @@ -1223,7 +1223,7 @@ confirm_multiple_windows (GtkWindow *parent_window, g_free (detail); response = gtk_dialog_run (dialog); - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); return response == GTK_RESPONSE_YES; } diff --git a/libcaja-private/caja-mime-application-chooser.c b/libcaja-private/caja-mime-application-chooser.c index 3f458dba..32767f38 100644 --- a/libcaja-private/caja-mime-application-chooser.c +++ b/libcaja-private/caja-mime-application-chooser.c @@ -107,23 +107,13 @@ caja_mime_application_chooser_finalize (GObject *object) G_OBJECT_CLASS (caja_mime_application_chooser_parent_class)->finalize (object); } -static void -caja_mime_application_chooser_destroy (GtkObject *object) -{ - GTK_OBJECT_CLASS (caja_mime_application_chooser_parent_class)->destroy (object); -} - static void caja_mime_application_chooser_class_init (CajaMimeApplicationChooserClass *class) { GObjectClass *gobject_class; - GtkObjectClass *object_class; gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = caja_mime_application_chooser_finalize; - - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = caja_mime_application_chooser_destroy; } static void diff --git a/libcaja-private/caja-open-with-dialog.c b/libcaja-private/caja-open-with-dialog.c index dcd601bc..93e376c9 100644 --- a/libcaja-private/caja-open-with-dialog.c +++ b/libcaja-private/caja-open-with-dialog.c @@ -120,12 +120,6 @@ caja_open_with_dialog_finalize (GObject *object) G_OBJECT_CLASS (caja_open_with_dialog_parent_class)->finalize (object); } -static void -caja_open_with_dialog_destroy (GtkObject *object) -{ - GTK_OBJECT_CLASS (caja_open_with_dialog_parent_class)->destroy (object); -} - /* An application is valid if: * * 1) The file exists @@ -397,17 +391,13 @@ static void caja_open_with_dialog_class_init (CajaOpenWithDialogClass *class) { GObjectClass *gobject_class; - GtkObjectClass *object_class; gobject_class = G_OBJECT_CLASS (class); gobject_class->finalize = caja_open_with_dialog_finalize; - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = caja_open_with_dialog_destroy; - signals[APPLICATION_SELECTED] = g_signal_new ("application_selected", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (class), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CajaOpenWithDialogClass, application_selected), diff --git a/libcaja-private/caja-program-choosing.c b/libcaja-private/caja-program-choosing.c index a31746ec..56d6e8eb 100644 --- a/libcaja-private/caja-program-choosing.c +++ b/libcaja-private/caja-program-choosing.c @@ -98,7 +98,7 @@ application_cannot_open_location (GAppInfo *application, GTK_STOCK_CANCEL, parent_window); response = gtk_dialog_run (message_dialog); - gtk_object_destroy (GTK_OBJECT (message_dialog)); + gtk_widget_destroy (GTK_WIDGET (message_dialog)); if (response == GTK_RESPONSE_YES) { -- cgit v1.2.1 From ae33b1c624c008ca0818ab08735968c8d01fae1c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 3 Nov 2012 19:03:17 +0200 Subject: [lc-p] use eel_canvas_item_destroy instead of gtk_object_destroy() http://git.gnome.org/browse/nautilus/commit/?id=f5192b6990cd9240d126974dd587b7b7525ae714 --- libcaja-private/caja-icon-container.c | 4 ++-- libcaja-private/caja-icon-dnd.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 0f6898c9..1ae2cb2a 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -300,7 +300,7 @@ static void icon_free (CajaIcon *icon) { /* Destroy this canvas item; the parent will unref it. */ - gtk_object_destroy (GTK_OBJECT (icon->item)); + eel_canvas_item_destroy (EEL_CANVAS_ITEM (icon->item)); g_free (icon); } @@ -2990,7 +2990,7 @@ stop_rubberbanding (CajaIconContainer *container, /* Destroy this canvas item; the parent will unref it. */ eel_canvas_item_ungrab (band_info->selection_rectangle, time); - gtk_object_destroy (GTK_OBJECT (band_info->selection_rectangle)); + eel_canvas_item_destroy (band_info->selection_rectangle); band_info->selection_rectangle = NULL; /* if only one item has been selected, use it as range diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 2e7dc32a..449ceab8 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -375,7 +375,7 @@ caja_icon_container_dropped_icon_feedback (GtkWidget *widget, { /* FIXME bugzilla.gnome.org 42484: * Is a destroy really sufficient here? Who does the unref? */ - gtk_object_destroy (GTK_OBJECT (dnd_info->shadow)); + eel_canvas_item_destroy (dnd_info->shadow); } /* Build the selection list and the shadow. */ @@ -1514,7 +1514,7 @@ caja_icon_container_free_drag_data (CajaIconContainer *container) if (dnd_info->shadow != NULL) { - gtk_object_destroy (GTK_OBJECT (dnd_info->shadow)); + eel_canvas_item_destroy (dnd_info->shadow); dnd_info->shadow = NULL; } -- cgit v1.2.1 From 2472d52a0f28dd84d362dcc5570e747a82aa8ba6 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 31 Oct 2012 04:42:15 +0200 Subject: [src] don't use GtkObject (GTK3) the ::destroy signal of GtkObject has only been moved to GtkWidget in GTK3 (after GtkObject removal): http://developer.gnome.org/gtk3/3.0/ch25s02.html So we use conditionals in this case, to keep it working with GTK2. A tad similar: http://git.gnome.org/browse/nautilus/commit/?id=cc6cb51e827c0b15d4ef09f12d37b9f331ddcef8 --- src/caja-application.c | 6 +++++- src/caja-bookmarks-window.c | 8 ++++---- src/caja-location-bar.c | 20 ++++++++++++++------ src/caja-location-dialog.c | 19 +------------------ src/caja-location-entry.c | 29 ++++++++++++++++------------- src/caja-main.c | 12 ++++++++---- src/caja-main.h | 6 +++++- src/caja-navigation-bar.c | 9 +++------ src/caja-navigation-window-menus.c | 2 +- src/caja-navigation-window.c | 12 ++++++++++++ src/caja-pathbar.c | 6 ++---- src/caja-window-bookmarks.c | 2 +- src/caja-window-manage-views.c | 4 ++-- src/caja-window.c | 23 ++++++++++++++++++++--- src/file-manager/fm-desktop-icon-view.c | 3 ++- src/file-manager/fm-directory-view.c | 32 +++++++++++++++++++++----------- src/file-manager/fm-icon-view.c | 18 +++++++++++++----- src/file-manager/fm-properties-window.c | 12 ++++++++++++ 18 files changed, 142 insertions(+), 81 deletions(-) diff --git a/src/caja-application.c b/src/caja-application.c index a462524f..978af2d6 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -432,7 +432,7 @@ check_required_directories (CajaApplication *application) dialog = eel_show_error_dialog (error_string, detail_string, NULL); /* We need the main event loop so the user has a chance to see the dialog. */ - caja_main_event_loop_register (GTK_OBJECT (dialog)); + caja_main_event_loop_register (GTK_WIDGET (dialog)); g_string_free (directories_as_string, TRUE); g_free (error_string); @@ -1346,7 +1346,11 @@ caja_application_close_all_spatial_windows (void) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +caja_application_destroyed_window (GtkWidget *object, CajaApplication *application) +#else caja_application_destroyed_window (GtkObject *object, CajaApplication *application) +#endif { caja_application_window_list = g_list_remove (caja_application_window_list, object); } diff --git a/src/caja-bookmarks-window.c b/src/caja-bookmarks-window.c index 2ce15aae..4b13a1ee 100644 --- a/src/caja-bookmarks-window.c +++ b/src/caja-bookmarks-window.c @@ -229,9 +229,9 @@ static void edit_bookmarks_dialog_reset_signals (gpointer data, GObject *obj) { - g_signal_handler_disconnect (GTK_OBJECT (jump_button), + g_signal_handler_disconnect (jump_button, jump_button_signal_id); - g_signal_handler_disconnect (GTK_OBJECT (bookmark_list_widget), + g_signal_handler_disconnect (bookmark_list_widget, row_activated_signal_id); jump_button_signal_id = g_signal_connect (jump_button, "clicked", @@ -415,9 +415,9 @@ void edit_bookmarks_dialog_set_signals (CajaWindow *window) { - g_signal_handler_disconnect (GTK_OBJECT (jump_button), + g_signal_handler_disconnect (jump_button, jump_button_signal_id); - g_signal_handler_disconnect (GTK_OBJECT (bookmark_list_widget), + g_signal_handler_disconnect (bookmark_list_widget, row_activated_signal_id); jump_button_signal_id = diff --git a/src/caja-location-bar.c b/src/caja-location-bar.c index 6fdc34e5..428f26a1 100644 --- a/src/caja-location-bar.c +++ b/src/caja-location-bar.c @@ -356,7 +356,11 @@ finalize (GObject *object) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +destroy (GtkWidget *object) +#else destroy (GtkObject *object) +#endif { CajaLocationBar *bar; @@ -372,21 +376,25 @@ destroy (GtkObject *object) g_free (bar->details->last_location); bar->details->last_location = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + EEL_CALL_PARENT (GTK_WIDGET_CLASS, destroy, (object)); +#else EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); +#endif } static void caja_location_bar_class_init (CajaLocationBarClass *class) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; CajaNavigationBarClass *navigation_bar_class; - gobject_class = G_OBJECT_CLASS (class); - gobject_class->finalize = finalize; + G_OBJECT_CLASS (class)->finalize = finalize; - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = destroy; +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (class)->destroy = destroy; +#else + GTK_OBJECT_CLASS (class)->destroy = destroy; +#endif navigation_bar_class = CAJA_NAVIGATION_BAR_CLASS (class); diff --git a/src/caja-location-dialog.c b/src/caja-location-dialog.c index 99596b87..ec102300 100644 --- a/src/caja-location-dialog.c +++ b/src/caja-location-dialog.c @@ -61,16 +61,6 @@ caja_location_dialog_finalize (GObject *object) EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); } -static void -caja_location_dialog_destroy (GtkObject *object) -{ - CajaLocationDialog *dialog; - - dialog = CAJA_LOCATION_DIALOG (object); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - static void open_current_location (CajaLocationDialog *dialog) { @@ -136,14 +126,7 @@ entry_activate_callback (GtkEntry *entry, static void caja_location_dialog_class_init (CajaLocationDialogClass *class) { - GObjectClass *gobject_class; - GtkObjectClass *object_class; - - gobject_class = G_OBJECT_CLASS (class); - gobject_class->finalize = caja_location_dialog_finalize; - - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = caja_location_dialog_destroy; + G_OBJECT_CLASS (class)->finalize = caja_location_dialog_finalize; } static void diff --git a/src/caja-location-entry.c b/src/caja-location-entry.c index f23f1a9f..0a59a347 100644 --- a/src/caja-location-entry.c +++ b/src/caja-location-entry.c @@ -285,7 +285,11 @@ finalize (GObject *object) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +destroy (GtkWidget *object) +#else destroy (GtkObject *object) +#endif { CajaLocationEntry *entry; @@ -301,7 +305,11 @@ destroy (GtkObject *object) g_free (entry->details->current_directory); entry->details->current_directory = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + EEL_CALL_PARENT (GTK_WIDGET_CLASS, destroy, (object)); +#else EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); +#endif } static void @@ -382,22 +390,17 @@ caja_location_entry_activate (GtkEntry *entry) static void caja_location_entry_class_init (CajaLocationEntryClass *class) { - GtkWidgetClass *widget_class; - GObjectClass *gobject_class; - GtkObjectClass *object_class; - GtkEntryClass *entry_class; + GTK_WIDGET_CLASS (class)->focus_in_event = caja_location_entry_focus_in; - widget_class = GTK_WIDGET_CLASS (class); - widget_class->focus_in_event = caja_location_entry_focus_in; +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (class)->destroy = destroy; +#else + GTK_OBJECT_CLASS (class)->destroy = destroy; +#endif - gobject_class = G_OBJECT_CLASS (class); - gobject_class->finalize = finalize; + G_OBJECT_CLASS (class)->finalize = finalize; - object_class = GTK_OBJECT_CLASS (class); - object_class->destroy = destroy; - - entry_class = GTK_ENTRY_CLASS (class); - entry_class->activate = caja_location_entry_activate; + GTK_ENTRY_CLASS (class)->activate = caja_location_entry_activate; } void diff --git a/src/caja-main.c b/src/caja-main.c index ef5714b2..3a99163f 100644 --- a/src/caja-main.c +++ b/src/caja-main.c @@ -101,7 +101,7 @@ static void eel_gtk_main_quit_all (void) g_idle_add (quit_if_in_main_loop, NULL); } -static void event_loop_unregister (GtkObject *object) +static void event_loop_unregister (GtkWidget *object) { event_loop_registrants = g_slist_remove (event_loop_registrants, object); @@ -111,13 +111,17 @@ static void event_loop_unregister (GtkObject *object) } } +#if GTK_CHECK_VERSION(3, 0, 0) +void caja_main_event_loop_register (GtkWidget *object) +#else void caja_main_event_loop_register (GtkObject *object) +#endif { g_signal_connect (object, "destroy", G_CALLBACK (event_loop_unregister), NULL); - event_loop_registrants = g_slist_prepend (event_loop_registrants, object); + event_loop_registrants = g_slist_prepend (event_loop_registrants, GTK_WIDGET (object)); } -gboolean caja_main_is_event_loop_mainstay (GtkObject *object) +gboolean caja_main_is_event_loop_mainstay (GtkWidget *object) { return g_slist_length (event_loop_registrants) == 1 && event_loop_registrants->data == object; @@ -148,7 +152,7 @@ void caja_main_event_loop_quit (gboolean explicit) } while (event_loop_registrants != NULL) { - gtk_object_destroy (event_loop_registrants->data); + gtk_widget_destroy (event_loop_registrants->data); } } diff --git a/src/caja-main.h b/src/caja-main.h index c3ddf82a..abb9e6a7 100644 --- a/src/caja-main.h +++ b/src/caja-main.h @@ -29,8 +29,12 @@ #include +#if GTK_CHECK_VERSION(3, 0, 0) +void caja_main_event_loop_register (GtkWidget *object); +#else void caja_main_event_loop_register (GtkObject *object); -gboolean caja_main_is_event_loop_mainstay (GtkObject *object); +#endif +gboolean caja_main_is_event_loop_mainstay (GtkWidget *object); void caja_main_event_loop_quit (gboolean explicit); #endif /* CAJA_MAIN_H */ diff --git a/src/caja-navigation-bar.c b/src/caja-navigation-bar.c index c71d6503..89cd0e20 100644 --- a/src/caja-navigation-bar.c +++ b/src/caja-navigation-bar.c @@ -54,14 +54,11 @@ EEL_IMPLEMENT_MUST_OVERRIDE_SIGNAL (caja_navigation_bar, set_location) static void caja_navigation_bar_class_init (CajaNavigationBarClass *klass) { - GtkObjectClass *object_class; GtkBindingSet *binding_set; - object_class = GTK_OBJECT_CLASS (klass); - signals[ACTIVATE] = g_signal_new ("activate", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CajaNavigationBarClass, activate), @@ -71,7 +68,7 @@ caja_navigation_bar_class_init (CajaNavigationBarClass *klass) signals[CANCEL] = g_signal_new ("cancel", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, G_STRUCT_OFFSET (CajaNavigationBarClass, cancel), @@ -81,7 +78,7 @@ caja_navigation_bar_class_init (CajaNavigationBarClass *klass) signals[LOCATION_CHANGED] = g_signal_new ("location_changed", - G_TYPE_FROM_CLASS (object_class), + G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (CajaNavigationBarClass, location_changed), diff --git a/src/caja-navigation-window-menus.c b/src/caja-navigation-window-menus.c index 22c89c28..a9214476 100644 --- a/src/caja-navigation-window-menus.c +++ b/src/caja-navigation-window-menus.c @@ -116,7 +116,7 @@ forget_history_if_yes (GtkDialog *dialog, int response, gpointer callback_data) { caja_forget_history (); } - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); } static void diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c index db9cf523..3cddcb26 100644 --- a/src/caja-navigation-window.c +++ b/src/caja-navigation-window.c @@ -593,7 +593,11 @@ caja_navigation_window_button_press_event (GtkWidget *widget, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +caja_navigation_window_destroy (GtkWidget *object) +#else caja_navigation_window_destroy (GtkObject *object) +#endif { CajaNavigationWindow *window; @@ -609,7 +613,11 @@ caja_navigation_window_destroy (GtkObject *object) window->details->content_paned = NULL; window->details->split_view_hpane = NULL; +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (parent_class)->destroy (object); +#else GTK_OBJECT_CLASS (parent_class)->destroy (object); +#endif } static void @@ -1243,7 +1251,11 @@ caja_navigation_window_class_init (CajaNavigationWindowClass *class) CAJA_WINDOW_CLASS (class)->bookmarks_placeholder = MENU_PATH_BOOKMARKS_PLACEHOLDER; G_OBJECT_CLASS (class)->finalize = caja_navigation_window_finalize; +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (class)->destroy = caja_navigation_window_destroy; +#else GTK_OBJECT_CLASS (class)->destroy = caja_navigation_window_destroy; +#endif GTK_WIDGET_CLASS (class)->show = caja_navigation_window_show; GTK_WIDGET_CLASS (class)->unrealize = caja_navigation_window_unrealize; GTK_WIDGET_CLASS (class)->window_state_event = caja_navigation_window_state_event; diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index dffd63ee..b5504fc9 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -361,12 +361,10 @@ static void caja_path_bar_class_init (CajaPathBarClass *path_bar_class) { GObjectClass *gobject_class; - GtkObjectClass *object_class; GtkWidgetClass *widget_class; GtkContainerClass *container_class; gobject_class = (GObjectClass *) path_bar_class; - object_class = (GtkObjectClass *) path_bar_class; widget_class = (GtkWidgetClass *) path_bar_class; container_class = (GtkContainerClass *) path_bar_class; @@ -388,7 +386,7 @@ caja_path_bar_class_init (CajaPathBarClass *path_bar_class) path_bar_signals [PATH_CLICKED] = g_signal_new ("path-clicked", - G_OBJECT_CLASS_TYPE (object_class), + G_OBJECT_CLASS_TYPE (path_bar_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (CajaPathBarClass, path_clicked), NULL, NULL, @@ -397,7 +395,7 @@ caja_path_bar_class_init (CajaPathBarClass *path_bar_class) G_TYPE_FILE); path_bar_signals [PATH_SET] = g_signal_new ("path-set", - G_OBJECT_CLASS_TYPE (object_class), + G_OBJECT_CLASS_TYPE (path_bar_class), G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (CajaPathBarClass, path_set), NULL, NULL, diff --git a/src/caja-window-bookmarks.c b/src/caja-window-bookmarks.c index e2b6ec73..f96b823f 100644 --- a/src/caja-window-bookmarks.c +++ b/src/caja-window-bookmarks.c @@ -62,7 +62,7 @@ remove_bookmarks_for_uri_if_yes (GtkDialog *dialog, int response, gpointer callb caja_bookmark_list_delete_items_with_uri (window->details->bookmark_list, uri); } - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); } static void diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c index f3e30f6a..aba56377 100644 --- a/src/caja-window-manage-views.c +++ b/src/caja-window-manage-views.c @@ -1313,13 +1313,13 @@ got_file_info_for_view_selection_callback (CajaFile *file, } else { - gtk_object_destroy (GTK_OBJECT (window)); + gtk_widget_destroy (GTK_WIDGET (window)); } } else { /* Since this is a window, destroying it will also unref it. */ - gtk_object_destroy (GTK_OBJECT (window)); + gtk_widget_destroy (GTK_WIDGET (window)); } } else diff --git a/src/caja-window.c b/src/caja-window.c index 13f45508..27e2852f 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -188,10 +188,14 @@ caja_window_init (CajaWindow *window) g_signal_connect_object (caja_signaller_get_current (), "popup_menu_changed", G_CALLBACK (caja_window_load_extension_menus), window, G_CONNECT_SWAPPED); +#if GTK_CHECK_VERSION(3, 0, 0) + gtk_quit_add_destroy (1, GTK_WIDGET (window)); +#else gtk_quit_add_destroy (1, GTK_OBJECT (window)); +#endif /* Keep the main event loop alive as long as the window exists */ - caja_main_event_loop_register (GTK_OBJECT (window)); + caja_main_event_loop_register (GTK_WIDGET (window)); } /* Unconditionally synchronize the GtkUIManager of WINDOW. */ @@ -621,8 +625,11 @@ free_stored_viewers (CajaWindow *window) window->details->extra_viewer = NULL; } -static void +#if GTK_CHECK_VERSION (3, 0, 0) +caja_window_destroy (GtkWidget *object) +#else caja_window_destroy (GtkObject *object) +#endif { CajaWindow *window; GList *panes_copy; @@ -638,7 +645,11 @@ caja_window_destroy (GtkObject *object) g_assert (window->details->panes == NULL); g_assert (window->details->active_pane == NULL); +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (caja_window_parent_class)->destroy (object); +#else GTK_OBJECT_CLASS (caja_window_parent_class)->destroy (object); +#endif } static void @@ -2099,12 +2110,18 @@ caja_window_class_init (CajaWindowClass *class) { GtkBindingSet *binding_set; - G_OBJECT_CLASS (class)->finalize = caja_window_finalize; G_OBJECT_CLASS (class)->constructor = caja_window_constructor; G_OBJECT_CLASS (class)->constructed = caja_window_constructed; G_OBJECT_CLASS (class)->get_property = caja_window_get_property; G_OBJECT_CLASS (class)->set_property = caja_window_set_property; + G_OBJECT_CLASS (class)->finalize = caja_window_finalize; + +#if !GTK_CHECK_VERSION (3, 0, 0) GTK_OBJECT_CLASS (class)->destroy = caja_window_destroy; +#else + GTK_WIDGET_CLASS (class)->destroy = caja_window_destroy; +#endif + GTK_WIDGET_CLASS (class)->show = caja_window_show; GTK_WIDGET_CLASS (class)->size_request = caja_window_size_request; GTK_WIDGET_CLASS (class)->realize = caja_window_realize; diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index ef9a84de..005bc198 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -460,7 +460,8 @@ do_desktop_rescan (gpointer data) } static void -done_loading (GtkObject *DirectoryView, FMDesktopIconView *desktop_icon_view) +done_loading (CajaDirectory *model, + FMDesktopIconView *desktop_icon_view) { struct stat buf; diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index bd75951e..a4119ec4 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -659,7 +659,7 @@ fm_directory_view_confirm_multiple (GtkWindow *parent_window, g_free (detail); response = gtk_dialog_run (dialog); - gtk_object_destroy (GTK_OBJECT (dialog)); + gtk_widget_destroy (GTK_WIDGET (dialog)); return response == GTK_RESPONSE_YES; } @@ -2096,7 +2096,11 @@ real_unmerge_menus (FMDirectoryView *view) } static void +#if GTK_CHECK_VERSION (3, 0, 0) +fm_directory_view_destroy (GtkWidget *object) +#else fm_directory_view_destroy (GtkObject *object) +#endif { FMDirectoryView *view; GList *node, *next; @@ -2157,7 +2161,11 @@ fm_directory_view_destroy (GtkObject *object) view->details->directory_as_file = NULL; } +#if GTK_CHECK_VERSION (3, 0, 0) + EEL_CALL_PARENT (GTK_WIDGET_CLASS, destroy, (object)); +#else EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); +#endif } static void @@ -2168,17 +2176,17 @@ fm_directory_view_finalize (GObject *object) view = FM_DIRECTORY_VIEW (object); g_signal_handlers_disconnect_by_func (caja_preferences, - schedule_update_menus_callback, view); + schedule_update_menus_callback, view); g_signal_handlers_disconnect_by_func (caja_icon_view_preferences, - text_attribute_names_changed_callback, view); + text_attribute_names_changed_callback, view); g_signal_handlers_disconnect_by_func (caja_preferences, - image_display_policy_changed_callback, view); + image_display_policy_changed_callback, view); g_signal_handlers_disconnect_by_func (caja_preferences, - click_policy_changed_callback, view); + click_policy_changed_callback, view); g_signal_handlers_disconnect_by_func (caja_preferences, - sort_directories_first_changed_callback, view); + sort_directories_first_changed_callback, view); g_signal_handlers_disconnect_by_func (mate_lockdown_preferences, - schedule_update_menus, view); + schedule_update_menus, view); unschedule_pop_up_location_context_menu (view); if (view->details->location_popup_event != NULL) { @@ -2738,7 +2746,7 @@ copy_move_done_callback (GHashTable *debuting_files, gpointer data) * operate on. The ADD_FILE signal is registered as G_SIGNAL_RUN_LAST, so we * must use connect_after. */ - g_signal_connect_data (GTK_OBJECT (directory_view), + g_signal_connect_data (directory_view, "add_file", G_CALLBACK (debuting_files_add_file_callback), debuting_files_data, @@ -10794,11 +10802,13 @@ fm_directory_view_class_init (FMDirectoryViewClass *klass) widget_class = GTK_WIDGET_CLASS (klass); scrolled_window_class = GTK_SCROLLED_WINDOW_CLASS (klass); - G_OBJECT_CLASS (klass)->finalize = fm_directory_view_finalize; G_OBJECT_CLASS (klass)->set_property = fm_directory_view_set_property; - + G_OBJECT_CLASS (klass)->finalize = fm_directory_view_finalize; +#if !GTK_CHECK_VERSION (3, 0, 0) GTK_OBJECT_CLASS (klass)->destroy = fm_directory_view_destroy; - +#else + widget_class->destroy = fm_directory_view_destroy; +#endif widget_class->scroll_event = fm_directory_view_scroll_event; widget_class->parent_set = fm_directory_view_parent_set; diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index eee45185..a9fb8b11 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -209,7 +209,11 @@ G_DEFINE_TYPE_WITH_CODE (FMIconView, fm_icon_view, FM_TYPE_DIRECTORY_VIEW, fm_icon_view_iface_init)); static void +#if GTK_CHECK_VERSION (3, 0, 0) +fm_icon_view_destroy (GtkWidget *object) +#else fm_icon_view_destroy (GtkObject *object) +#endif { FMIconView *icon_view; @@ -237,10 +241,13 @@ fm_icon_view_destroy (GtkObject *object) icon_view->details->icons_not_positioned = NULL; } +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (fm_icon_view_parent_class)->destroy (object); +#else GTK_OBJECT_CLASS (fm_icon_view_parent_class)->destroy (object); +#endif } - static void fm_icon_view_finalize (GObject *object) { @@ -271,6 +278,7 @@ fm_icon_view_finalize (GObject *object) g_signal_handlers_disconnect_by_func (caja_compact_view_preferences, all_columns_same_width_changed_callback, icon_view); + G_OBJECT_CLASS (fm_icon_view_parent_class)->finalize (object); } @@ -2829,8 +2837,6 @@ fm_icon_view_sort_directories_first_changed (FMDirectoryView *directory_view) } } -/* GtkObject methods. */ - static gboolean icon_view_can_accept_item (CajaIconContainer *container, CajaFile *target_item, @@ -3145,9 +3151,11 @@ fm_icon_view_class_init (FMIconViewClass *klass) G_OBJECT_CLASS (klass)->set_property = fm_icon_view_set_property; G_OBJECT_CLASS (klass)->finalize = fm_icon_view_finalize; - +#if !GTK_CHECK_VERSION (3, 0, 0) GTK_OBJECT_CLASS (klass)->destroy = fm_icon_view_destroy; - +#else + GTK_WIDGET_CLASS (klass)->destroy = fm_icon_view_destroy; +#endif GTK_WIDGET_CLASS (klass)->screen_changed = fm_icon_view_screen_changed; GTK_WIDGET_CLASS (klass)->scroll_event = fm_icon_view_scroll_event; diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index bb9f06cd..19eea640 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -5482,7 +5482,11 @@ real_response (GtkDialog *dialog, } static void +#if GTK_CHECK_VERSION (3, 0, 0) +real_destroy (GtkWidget *object) +#else real_destroy (GtkObject *object) +#endif { FMPropertiesWindow *window; GList *l; @@ -5540,7 +5544,11 @@ real_destroy (GtkObject *object) window->details->update_files_timeout_id = 0; } +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (parent_class)->destroy (object); +#else GTK_OBJECT_CLASS (parent_class)->destroy (object); +#endif } static void @@ -5795,7 +5803,11 @@ fm_properties_window_class_init (FMPropertiesWindowClass *class) GtkBindingSet *binding_set; G_OBJECT_CLASS (class)->finalize = real_finalize; +#if !GTK_CHECK_VERSION (3, 0, 0) GTK_OBJECT_CLASS (class)->destroy = real_destroy; +#else + GTK_WIDGET_CLASS (class)->destroy = real_destroy; +#endif GTK_DIALOG_CLASS (class)->response = real_response; binding_set = gtk_binding_set_by_class (class); -- cgit v1.2.1 From ca03cc6c6b01a8a9b42a6e5b0f3096e5b792a531 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 31 Oct 2012 03:43:42 +0200 Subject: [eel-labeled-image] Don't use GtkObject nor eel-gtk-macros --- eel/eel-labeled-image.c | 360 +++++++++++++++++++++--------------------------- 1 file changed, 160 insertions(+), 200 deletions(-) diff --git a/eel/eel-labeled-image.c b/eel/eel-labeled-image.c index 3cd7f9ba..12dad9c1 100644 --- a/eel/eel-labeled-image.c +++ b/eel/eel-labeled-image.c @@ -30,7 +30,6 @@ #include "eel-debug-drawing.h" #include "eel-gtk-container.h" #include "eel-gtk-extensions.h" -#include "eel-gtk-macros.h" #include "eel-accessibility.h" #include #include @@ -89,47 +88,9 @@ static GType eel_labeled_image_check_button_get_type (void); static GType eel_labeled_image_radio_button_get_type (void); static GType eel_labeled_image_toggle_button_get_type (void); - -static void eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class); -static void eel_labeled_image_init (EelLabeledImage *image); -static void eel_labeled_image_finalize (GObject *object); - - - -/* GObjectClass methods */ -static void eel_labeled_image_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void eel_labeled_image_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); - -/* GtkObjectClass methods */ -static void eel_labeled_image_destroy (GtkObject *object); - /* GtkWidgetClass methods */ -static void eel_labeled_image_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static int eel_labeled_image_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static void eel_labeled_image_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void eel_labeled_image_map (GtkWidget *widget); -static void eel_labeled_image_unmap (GtkWidget *widget); static AtkObject *eel_labeled_image_get_accessible (GtkWidget *widget); -/* GtkContainerClass methods */ -static void eel_labeled_image_add (GtkContainer *container, - GtkWidget *widget); -static void eel_labeled_image_remove (GtkContainer *container, - GtkWidget *widget); -static void eel_labeled_image_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); - /* Private EelLabeledImage methods */ static EelDimensions labeled_image_get_image_dimensions (const EelLabeledImage *labeled_image); static EelDimensions labeled_image_get_label_dimensions (const EelLabeledImage *labeled_image); @@ -143,158 +104,16 @@ static gboolean labeled_image_show_image (const EelLabeledImage static guint labeled_image_signals[LAST_SIGNAL] = { 0 }; -EEL_CLASS_BOILERPLATE (EelLabeledImage, eel_labeled_image, GTK_TYPE_CONTAINER) - -/* Class init methods */ -static void -eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (labeled_image_class); - GtkObjectClass *object_class = GTK_OBJECT_CLASS (labeled_image_class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (labeled_image_class); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (labeled_image_class); - GtkBindingSet *binding_set; - - gobject_class->finalize = eel_labeled_image_finalize; - - /* GObjectClass */ - gobject_class->set_property = eel_labeled_image_set_property; - gobject_class->get_property = eel_labeled_image_get_property; - - /* GtkObjectClass */ - object_class->destroy = eel_labeled_image_destroy; - - /* GtkWidgetClass */ - widget_class->size_request = eel_labeled_image_size_request; - widget_class->size_allocate = eel_labeled_image_size_allocate; - widget_class->expose_event = eel_labeled_image_expose_event; - widget_class->map = eel_labeled_image_map; - widget_class->unmap = eel_labeled_image_unmap; - widget_class->get_accessible = eel_labeled_image_get_accessible; - - /* GtkContainerClass */ - container_class->add = eel_labeled_image_add; - container_class->remove = eel_labeled_image_remove; - container_class->forall = eel_labeled_image_forall; - - labeled_image_signals[ACTIVATE] = - g_signal_new ("activate", - G_TYPE_FROM_CLASS (labeled_image_class), - G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, - G_STRUCT_OFFSET (EelLabeledImageClass, - activate), - NULL, NULL, - g_cclosure_marshal_VOID__VOID, - G_TYPE_NONE, 0); - widget_class->activate_signal = labeled_image_signals[ACTIVATE]; - - binding_set = gtk_binding_set_by_class (gobject_class); - - gtk_binding_entry_add_signal (binding_set, - GDK_KEY_Return, 0, - "activate", 0); - gtk_binding_entry_add_signal (binding_set, - GDK_KEY_KP_Enter, 0, - "activate", 0); - gtk_binding_entry_add_signal (binding_set, - GDK_KEY_space, 0, - "activate", 0); - - - /* Properties */ - g_object_class_install_property ( - gobject_class, - PROP_PIXBUF, - g_param_spec_object ("pixbuf", NULL, NULL, - GDK_TYPE_PIXBUF, G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_LABEL, - g_param_spec_string ("label", NULL, NULL, - "", G_PARAM_READWRITE)); - - - g_object_class_install_property ( - gobject_class, - PROP_LABEL_POSITION, - g_param_spec_enum ("label_position", NULL, NULL, - GTK_TYPE_POSITION_TYPE, - GTK_POS_BOTTOM, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_SHOW_LABEL, - g_param_spec_boolean ("show_label", NULL, NULL, - TRUE, G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_SHOW_IMAGE, - g_param_spec_boolean ("show_image", NULL, NULL, - TRUE, G_PARAM_READWRITE)); - - - g_object_class_install_property ( - gobject_class, - PROP_SPACING, - g_param_spec_uint ("spacing", NULL, NULL, - 0, - G_MAXINT, - DEFAULT_SPACING, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_X_PADDING, - g_param_spec_int ("x_padding", NULL, NULL, - 0, - G_MAXINT, - DEFAULT_X_PADDING, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_Y_PADDING, - g_param_spec_int ("y_padding", NULL, NULL, - 0, - G_MAXINT, - DEFAULT_Y_PADDING, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_X_ALIGNMENT, - g_param_spec_float ("x_alignment", NULL, NULL, - 0.0, - 1.0, - DEFAULT_X_ALIGNMENT, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_Y_ALIGNMENT, - g_param_spec_float ("y_alignment", NULL, NULL, - 0.0, - 1.0, - DEFAULT_Y_ALIGNMENT, - G_PARAM_READWRITE)); - - g_object_class_install_property ( - gobject_class, - PROP_FILL, - g_param_spec_boolean ("fill", NULL, NULL, - FALSE, - G_PARAM_READWRITE)); -} +G_DEFINE_TYPE (EelLabeledImage, eel_labeled_image, GTK_TYPE_CONTAINER) static void eel_labeled_image_init (EelLabeledImage *labeled_image) { gtk_widget_set_has_window (GTK_WIDGET (labeled_image), FALSE); - labeled_image->details = g_new0 (EelLabeledImageDetails, 1); + labeled_image->details = G_TYPE_INSTANCE_GET_PRIVATE (labeled_image, + EEL_TYPE_LABELED_IMAGE, + EelLabeledImageDetails); labeled_image->details->show_label = TRUE; labeled_image->details->show_image = TRUE; labeled_image->details->label_position = GTK_POS_BOTTOM; @@ -309,20 +128,11 @@ eel_labeled_image_init (EelLabeledImage *labeled_image) } static void -eel_labeled_image_finalize (GObject *object) -{ - EelLabeledImage *labeled_image; - - labeled_image = EEL_LABELED_IMAGE (object); - - g_free (labeled_image->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - - -static void +#if GTK_CHECK_VERSION (3, 0, 0) +eel_labeled_image_destroy (GtkWidget *object) +#else eel_labeled_image_destroy (GtkObject *object) +#endif { EelLabeledImage *labeled_image; @@ -338,7 +148,11 @@ eel_labeled_image_destroy (GtkObject *object) gtk_widget_destroy (labeled_image->details->label); } - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); +#if GTK_CHECK_VERSION (3, 0, 0) + GTK_WIDGET_CLASS (eel_labeled_image_parent_class)->destroy (object); +#else + GTK_OBJECT_CLASS (eel_labeled_image_parent_class)->destroy (object); +#endif } /* GObjectClass methods */ @@ -694,6 +508,152 @@ eel_labeled_image_forall (GtkContainer *container, } } +/* Class init methods */ +static void +eel_labeled_image_class_init (EelLabeledImageClass *labeled_image_class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (labeled_image_class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (labeled_image_class); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS (labeled_image_class); + GtkBindingSet *binding_set; + + /* GObjectClass */ + gobject_class->set_property = eel_labeled_image_set_property; + gobject_class->get_property = eel_labeled_image_get_property; + +#if !GTK_CHECK_VERSION (3, 0, 0) + GTK_OBJECT_CLASS (labeled_image_class)->destroy = eel_labeled_image_destroy; +#else + widget_class->destroy = eel_labeled_image_destroy; +#endif + + /* GtkWidgetClass */ + widget_class->size_request = eel_labeled_image_size_request; + widget_class->size_allocate = eel_labeled_image_size_allocate; + widget_class->expose_event = eel_labeled_image_expose_event; + widget_class->map = eel_labeled_image_map; + widget_class->unmap = eel_labeled_image_unmap; + widget_class->get_accessible = eel_labeled_image_get_accessible; + + /* GtkContainerClass */ + container_class->add = eel_labeled_image_add; + container_class->remove = eel_labeled_image_remove; + container_class->forall = eel_labeled_image_forall; + + labeled_image_signals[ACTIVATE] = + g_signal_new ("activate", + G_TYPE_FROM_CLASS (labeled_image_class), + G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, + G_STRUCT_OFFSET (EelLabeledImageClass, + activate), + NULL, NULL, + g_cclosure_marshal_VOID__VOID, + G_TYPE_NONE, 0); + widget_class->activate_signal = labeled_image_signals[ACTIVATE]; + + binding_set = gtk_binding_set_by_class (gobject_class); + + gtk_binding_entry_add_signal (binding_set, + GDK_KEY_Return, 0, + "activate", 0); + gtk_binding_entry_add_signal (binding_set, + GDK_KEY_KP_Enter, 0, + "activate", 0); + gtk_binding_entry_add_signal (binding_set, + GDK_KEY_space, 0, + "activate", 0); + + + /* Properties */ + g_object_class_install_property ( + gobject_class, + PROP_PIXBUF, + g_param_spec_object ("pixbuf", NULL, NULL, + GDK_TYPE_PIXBUF, G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_LABEL, + g_param_spec_string ("label", NULL, NULL, + "", G_PARAM_READWRITE)); + + + g_object_class_install_property ( + gobject_class, + PROP_LABEL_POSITION, + g_param_spec_enum ("label_position", NULL, NULL, + GTK_TYPE_POSITION_TYPE, + GTK_POS_BOTTOM, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_SHOW_LABEL, + g_param_spec_boolean ("show_label", NULL, NULL, + TRUE, G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_SHOW_IMAGE, + g_param_spec_boolean ("show_image", NULL, NULL, + TRUE, G_PARAM_READWRITE)); + + + g_object_class_install_property ( + gobject_class, + PROP_SPACING, + g_param_spec_uint ("spacing", NULL, NULL, + 0, + G_MAXINT, + DEFAULT_SPACING, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_X_PADDING, + g_param_spec_int ("x_padding", NULL, NULL, + 0, + G_MAXINT, + DEFAULT_X_PADDING, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_Y_PADDING, + g_param_spec_int ("y_padding", NULL, NULL, + 0, + G_MAXINT, + DEFAULT_Y_PADDING, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_X_ALIGNMENT, + g_param_spec_float ("x_alignment", NULL, NULL, + 0.0, + 1.0, + DEFAULT_X_ALIGNMENT, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_Y_ALIGNMENT, + g_param_spec_float ("y_alignment", NULL, NULL, + 0.0, + 1.0, + DEFAULT_Y_ALIGNMENT, + G_PARAM_READWRITE)); + + g_object_class_install_property ( + gobject_class, + PROP_FILL, + g_param_spec_boolean ("fill", NULL, NULL, + FALSE, + G_PARAM_READWRITE)); + + g_type_class_add_private (labeled_image_class, sizeof (EelLabeledImageDetails)); +} + /* Private EelLabeledImage methods */ static gboolean is_fixed_height (const EelLabeledImage *labeled_image) @@ -1308,7 +1268,7 @@ labeled_image_show_label (const EelLabeledImage *labeled_image) * be created as neeeded. * * Thus, using this widget in place of EelImage or EelLabel is "free" with - * only the GtkObject and function call overhead. + * only the GtkWidget and function call overhead. * */ GtkWidget* -- cgit v1.2.1 From 9bb422fbed4667c1540889091960f7ee9ebd89ed Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 6 Nov 2012 17:14:03 +0200 Subject: [eel-(image|wrap)-table] Don't use GtkObject nor eel-gtk-macros the ::destroy signal of GtkObject has only been moved to GtkWidget in GTK3 (after GtkObject removal): http://developer.gnome.org/gtk3/3.0/ch25s02.html So, we use conditionals in eel-image-table's case, to keep working with GTK2 --- eel/eel-image-table.c | 215 ++++++++++++++++++++++++-------------------------- eel/eel-wrap-table.c | 175 +++++++++++++++++----------------------- 2 files changed, 175 insertions(+), 215 deletions(-) diff --git a/eel/eel-image-table.c b/eel/eel-image-table.c index 84dff9aa..205fc70a 100644 --- a/eel/eel-image-table.c +++ b/eel/eel-image-table.c @@ -29,7 +29,6 @@ #include "eel-art-gtk-extensions.h" #include "eel-debug-drawing.h" #include "eel-gtk-extensions.h" -#include "eel-gtk-macros.h" #include "eel-labeled-image.h" #include "eel-marshal.h" #include @@ -62,33 +61,13 @@ typedef enum /* Signals */ static guint image_table_signals[LAST_SIGNAL] = { 0 }; -static void eel_image_table_class_init (EelImageTableClass *image_table_class); -static void eel_image_table_init (EelImageTable *image); - -/* GObjectClass methods */ -static void eel_image_table_finalize (GObject *object); - -/* GtkWidgetClass methods */ -static void eel_image_table_realize (GtkWidget *widget); - -/* GtkContainerClass methods */ -static void eel_image_table_remove (GtkContainer *container, - GtkWidget *widget); -static GType eel_image_table_child_type (GtkContainer *container); - -/* Private EelImageTable methods */ -static void image_table_emit_signal (EelImageTable *image_table, - GtkWidget *child, - guint signal_index, - int x, - int y, - int button, - guint state, - GdkEvent *event); - /* Ancestor methods */ GtkWidget * find_windowed_ancestor (GtkWidget *widget); +#if GTK_CHECK_VERSION (3, 0, 0) +static void signal_connect_while_realized (GtkWidget *object, +#else static void signal_connect_while_realized (GtkObject *object, +#endif const char *name, GCallback callback, gpointer callback_data, @@ -110,84 +89,16 @@ static int ancestor_button_release_event (GtkWidget *widget, GdkEventButton *event, gpointer event_data); -EEL_CLASS_BOILERPLATE (EelImageTable, eel_image_table, EEL_TYPE_WRAP_TABLE) - -static void -eel_image_table_class_init (EelImageTableClass *image_table_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (image_table_class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (image_table_class); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (image_table_class); - - /* GObjectClass */ - object_class->finalize = eel_image_table_finalize; - - /* GtkWidgetClass */ - widget_class->realize = eel_image_table_realize; - - /* GtkContainerClass */ - container_class->remove = eel_image_table_remove; - container_class->child_type = eel_image_table_child_type; - - /* Signals */ - image_table_signals[CHILD_ENTER] = g_signal_new ("child_enter", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_enter), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_LEAVE] = g_signal_new ("child_leave", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_leave), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_PRESSED] = g_signal_new ("child_pressed", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_pressed), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_RELEASED] = g_signal_new ("child_released", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_released), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); - image_table_signals[CHILD_CLICKED] = g_signal_new ("child_clicked", - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (EelImageTableClass, child_clicked), - NULL, NULL, - eel_marshal_VOID__OBJECT_POINTER, - G_TYPE_NONE, - 2, - GTK_TYPE_WIDGET, - G_TYPE_POINTER); -} +G_DEFINE_TYPE (EelImageTable, eel_image_table, EEL_TYPE_WRAP_TABLE) static void eel_image_table_init (EelImageTable *image_table) { gtk_widget_set_has_window (GTK_WIDGET (image_table), FALSE); - image_table->details = g_new0 (EelImageTableDetails, 1); + image_table->details = G_TYPE_INSTANCE_GET_PRIVATE (image_table, + EEL_TYPE_IMAGE_TABLE, + EelImageTableDetails); } /* GObjectClass methods */ @@ -198,9 +109,7 @@ eel_image_table_finalize (GObject *object) image_table = EEL_IMAGE_TABLE (object); - g_free (image_table->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (eel_image_table_parent_class)->finalize (object); } static void @@ -211,7 +120,7 @@ eel_image_table_realize (GtkWidget *widget) g_assert (EEL_IS_IMAGE_TABLE (widget)); /* Chain realize */ - EEL_CALL_PARENT (GTK_WIDGET_CLASS, realize, (widget)); + GTK_WIDGET_CLASS (eel_image_table_parent_class)->realize (widget); windowed_ancestor = find_windowed_ancestor (widget); g_assert (GTK_IS_WIDGET (windowed_ancestor)); @@ -224,31 +133,35 @@ eel_image_table_realize (GtkWidget *widget) | GDK_LEAVE_NOTIFY_MASK | GDK_POINTER_MOTION_MASK); - signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), +#if !GTK_CHECK_VERSION (3, 0, 0) +#define windowed_ancestor GTK_OBJECT(windowed_ancestor) +#endif + + signal_connect_while_realized (windowed_ancestor, "enter_notify_event", G_CALLBACK (ancestor_enter_notify_event), widget, widget); - signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + signal_connect_while_realized (windowed_ancestor, "leave_notify_event", G_CALLBACK (ancestor_leave_notify_event), widget, widget); - signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + signal_connect_while_realized (windowed_ancestor, "motion_notify_event", G_CALLBACK (ancestor_motion_notify_event), widget, widget); - signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + signal_connect_while_realized (windowed_ancestor, "button_press_event", G_CALLBACK (ancestor_button_press_event), widget, widget); - signal_connect_while_realized (GTK_OBJECT (windowed_ancestor), + signal_connect_while_realized (windowed_ancestor, "button_release_event", G_CALLBACK (ancestor_button_release_event), widget, @@ -277,7 +190,7 @@ eel_image_table_remove (GtkContainer *container, image_table->details->child_being_pressed = NULL; } - EEL_CALL_PARENT (GTK_CONTAINER_CLASS, remove, (container, child)); + GTK_CONTAINER_CLASS (eel_image_table_parent_class)->remove (container, child); } static GType @@ -317,6 +230,78 @@ image_table_emit_signal (EelImageTable *image_table, &event); } +static void +eel_image_table_class_init (EelImageTableClass *image_table_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (image_table_class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (image_table_class); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS (image_table_class); + + /* GObjectClass */ + object_class->finalize = eel_image_table_finalize; + + /* GtkWidgetClass */ + widget_class->realize = eel_image_table_realize; + + /* GtkContainerClass */ + container_class->remove = eel_image_table_remove; + container_class->child_type = eel_image_table_child_type; + + /* Signals */ + image_table_signals[CHILD_ENTER] = g_signal_new ("child_enter", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EelImageTableClass, child_enter), + NULL, NULL, + eel_marshal_VOID__OBJECT_POINTER, + G_TYPE_NONE, + 2, + GTK_TYPE_WIDGET, + G_TYPE_POINTER); + image_table_signals[CHILD_LEAVE] = g_signal_new ("child_leave", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EelImageTableClass, child_leave), + NULL, NULL, + eel_marshal_VOID__OBJECT_POINTER, + G_TYPE_NONE, + 2, + GTK_TYPE_WIDGET, + G_TYPE_POINTER); + image_table_signals[CHILD_PRESSED] = g_signal_new ("child_pressed", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EelImageTableClass, child_pressed), + NULL, NULL, + eel_marshal_VOID__OBJECT_POINTER, + G_TYPE_NONE, + 2, + GTK_TYPE_WIDGET, + G_TYPE_POINTER); + image_table_signals[CHILD_RELEASED] = g_signal_new ("child_released", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EelImageTableClass, child_released), + NULL, NULL, + eel_marshal_VOID__OBJECT_POINTER, + G_TYPE_NONE, + 2, + GTK_TYPE_WIDGET, + G_TYPE_POINTER); + image_table_signals[CHILD_CLICKED] = g_signal_new ("child_clicked", + G_TYPE_FROM_CLASS (object_class), + G_SIGNAL_RUN_LAST, + G_STRUCT_OFFSET (EelImageTableClass, child_clicked), + NULL, NULL, + eel_marshal_VOID__OBJECT_POINTER, + G_TYPE_NONE, + 2, + GTK_TYPE_WIDGET, + G_TYPE_POINTER); + + g_type_class_add_private (image_table_class, sizeof (EelImageTableDetails)); +} + static void image_table_handle_motion (EelImageTable *image_table, int x, @@ -401,7 +386,7 @@ find_windowed_ancestor (GtkWidget *widget) typedef struct { - GtkObject *object; + GObject *object; guint object_destroy_handler; GtkWidget *realized_widget; @@ -412,12 +397,12 @@ typedef struct } RealizeDisconnectInfo; static void -while_realized_disconnecter (GtkObject *object, +while_realized_disconnecter (GObject *object, RealizeDisconnectInfo *info) { - g_assert (GTK_IS_OBJECT (object)); + g_assert (G_IS_OBJECT (object)); g_assert (info != NULL); - g_assert (GTK_IS_OBJECT (info->object)); + g_assert (G_IS_OBJECT (info->object)); g_assert (info->object_destroy_handler != 0); g_assert (info->object_destroy_handler != 0); g_assert (info->realized_widget_destroy_handler != 0); @@ -447,7 +432,11 @@ while_realized_disconnecter (GtkObject *object, * or &widget are destroyed. **/ static void +#if GTK_CHECK_VERSION (3, 0, 0) +signal_connect_while_realized (GtkWidget *object, +#else signal_connect_while_realized (GtkObject *object, +#endif const char *name, GCallback callback, gpointer callback_data, @@ -455,7 +444,11 @@ signal_connect_while_realized (GtkObject *object, { RealizeDisconnectInfo *info; +#if GTK_CHECK_VERSION (3, 0, 0) + g_return_if_fail (GTK_IS_WIDGET (object)); +#else g_return_if_fail (GTK_IS_OBJECT (object)); +#endif g_return_if_fail (name != NULL); g_return_if_fail (name[0] != '\0'); g_return_if_fail (callback != NULL); diff --git a/eel/eel-wrap-table.c b/eel/eel-wrap-table.c index 794e1c72..42253acd 100644 --- a/eel/eel-wrap-table.c +++ b/eel/eel-wrap-table.c @@ -28,7 +28,6 @@ #include "eel-art-extensions.h" #include "eel-art-gtk-extensions.h" #include "eel-gtk-extensions.h" -#include "eel-gtk-macros.h" #include /* Arguments */ @@ -56,41 +55,6 @@ struct EelWrapTableDetails guint cols; }; -static void eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class); -static void eel_wrap_table_init (EelWrapTable *wrap); -/* GObjectClass methods */ -static void eel_wrap_table_finalize (GObject *object); -static void eel_wrap_table_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void eel_wrap_table_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); -/* GtkWidgetClass methods */ -static void eel_wrap_table_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static int eel_wrap_table_expose_event (GtkWidget *widget, - GdkEventExpose *event); -static void eel_wrap_table_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void eel_wrap_table_map (GtkWidget *widget); -static void eel_wrap_table_unmap (GtkWidget *widget); -static void eel_wrap_table_realize (GtkWidget *widget); - -/* GtkContainerClass methods */ -static void eel_wrap_table_add (GtkContainer *container, - GtkWidget *widget); -static void eel_wrap_table_remove (GtkContainer *container, - GtkWidget *widget); -static void eel_wrap_table_forall (GtkContainer *container, - gboolean include_internals, - GtkCallback callback, - gpointer callback_data); -static GType eel_wrap_table_child_type (GtkContainer *container); - - /* Private EelWrapTable methods */ static EelDimensions wrap_table_irect_max_dimensions (const EelDimensions *one, const EelDimensions *two); @@ -105,77 +69,16 @@ static gboolean wrap_table_child_focus_in (GtkWidget *w static void wrap_table_layout (EelWrapTable *wrap_table); -EEL_CLASS_BOILERPLATE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER) - -/* Class init methods */ -static void -eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (wrap_table_class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (wrap_table_class); - GtkContainerClass *container_class = GTK_CONTAINER_CLASS (wrap_table_class); - - /* GObjectClass */ - gobject_class->finalize = eel_wrap_table_finalize; - gobject_class->set_property = eel_wrap_table_set_property; - gobject_class->get_property = eel_wrap_table_get_property; - - /* GtkWidgetClass */ - widget_class->size_request = eel_wrap_table_size_request; - widget_class->size_allocate = eel_wrap_table_size_allocate; - widget_class->expose_event = eel_wrap_table_expose_event; - widget_class->map = eel_wrap_table_map; - widget_class->unmap = eel_wrap_table_unmap; - widget_class->realize = eel_wrap_table_realize; - - /* GtkContainerClass */ - container_class->add = eel_wrap_table_add; - container_class->remove = eel_wrap_table_remove; - container_class->forall = eel_wrap_table_forall; - container_class->child_type = eel_wrap_table_child_type; - - /* Arguments */ - g_object_class_install_property - (gobject_class, - PROP_X_SPACING, - g_param_spec_uint ("x_spacing", NULL, NULL, - 0, G_MAXINT, 0, G_PARAM_READWRITE)); - - g_object_class_install_property - (gobject_class, - PROP_Y_SPACING, - g_param_spec_uint ("y_spacing", NULL, NULL, - 0, G_MAXINT, 0, G_PARAM_READWRITE)); - - g_object_class_install_property - (gobject_class, - PROP_X_JUSTIFICATION, - g_param_spec_enum ("x_justification", NULL, NULL, - GTK_TYPE_JUSTIFICATION, - GTK_JUSTIFY_LEFT, - G_PARAM_READWRITE)); - - g_object_class_install_property - (gobject_class, - PROP_Y_JUSTIFICATION, - g_param_spec_enum ("y_justification", NULL, NULL, - GTK_TYPE_JUSTIFICATION, - GTK_JUSTIFY_LEFT, - G_PARAM_READWRITE)); - - g_object_class_install_property - (gobject_class, - PROP_HOMOGENEOUS, - g_param_spec_boolean ("homogenous", NULL, NULL, - FALSE, G_PARAM_READWRITE)); -} +G_DEFINE_TYPE (EelWrapTable, eel_wrap_table, GTK_TYPE_CONTAINER) static void eel_wrap_table_init (EelWrapTable *wrap_table) { gtk_widget_set_has_window (GTK_WIDGET (wrap_table), FALSE); - wrap_table->details = g_new0 (EelWrapTableDetails, 1); + wrap_table->details = G_TYPE_INSTANCE_GET_PRIVATE (wrap_table, + EEL_TYPE_WRAP_TABLE, + EelWrapTableDetails); wrap_table->details->x_justification = EEL_JUSTIFICATION_BEGINNING; wrap_table->details->y_justification = EEL_JUSTIFICATION_END; wrap_table->details->cols = 1; @@ -189,9 +92,8 @@ eel_wrap_table_finalize (GObject *object) wrap_table = EEL_WRAP_TABLE (object); g_list_free (wrap_table->details->children); - g_free (wrap_table->details); - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (eel_wrap_table_parent_class)->finalize (object); } /* GObjectClass methods */ @@ -389,7 +291,7 @@ eel_wrap_table_realize (GtkWidget *widget) { g_assert (EEL_IS_WRAP_TABLE (widget)); - GTK_WIDGET_CLASS (parent_class)->realize (widget); + GTK_WIDGET_CLASS (eel_wrap_table_parent_class)->realize (widget); gtk_widget_queue_resize (widget); } @@ -495,6 +397,71 @@ eel_wrap_table_child_type (GtkContainer *container) return GTK_TYPE_WIDGET; } +/* Class init methods */ +static void +eel_wrap_table_class_init (EelWrapTableClass *wrap_table_class) +{ + GObjectClass *gobject_class = G_OBJECT_CLASS (wrap_table_class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (wrap_table_class); + GtkContainerClass *container_class = GTK_CONTAINER_CLASS (wrap_table_class); + + /* GObjectClass */ + gobject_class->finalize = eel_wrap_table_finalize; + gobject_class->set_property = eel_wrap_table_set_property; + gobject_class->get_property = eel_wrap_table_get_property; + + /* GtkWidgetClass */ + widget_class->size_request = eel_wrap_table_size_request; + widget_class->size_allocate = eel_wrap_table_size_allocate; + widget_class->expose_event = eel_wrap_table_expose_event; + widget_class->map = eel_wrap_table_map; + widget_class->unmap = eel_wrap_table_unmap; + widget_class->realize = eel_wrap_table_realize; + + /* GtkContainerClass */ + container_class->add = eel_wrap_table_add; + container_class->remove = eel_wrap_table_remove; + container_class->forall = eel_wrap_table_forall; + container_class->child_type = eel_wrap_table_child_type; + + /* Arguments */ + g_object_class_install_property + (gobject_class, + PROP_X_SPACING, + g_param_spec_uint ("x_spacing", NULL, NULL, + 0, G_MAXINT, 0, G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_Y_SPACING, + g_param_spec_uint ("y_spacing", NULL, NULL, + 0, G_MAXINT, 0, G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_X_JUSTIFICATION, + g_param_spec_enum ("x_justification", NULL, NULL, + GTK_TYPE_JUSTIFICATION, + GTK_JUSTIFY_LEFT, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_Y_JUSTIFICATION, + g_param_spec_enum ("y_justification", NULL, NULL, + GTK_TYPE_JUSTIFICATION, + GTK_JUSTIFY_LEFT, + G_PARAM_READWRITE)); + + g_object_class_install_property + (gobject_class, + PROP_HOMOGENEOUS, + g_param_spec_boolean ("homogenous", NULL, NULL, + FALSE, G_PARAM_READWRITE)); + + g_type_class_add_private (wrap_table_class, sizeof (EelWrapTableDetails)); +} + /* Private EelWrapTable methods */ static int wrap_table_get_num_fitting (int available, -- cgit v1.2.1 From 5347614b1dae2a8edad9f8cebc073c4a282de7b7 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 6 Nov 2012 17:28:49 +0200 Subject: [eel-debug-drawing] Don't use eel-gtk-macros --- eel/eel-debug-drawing.c | 38 +++++++++++++------------------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/eel/eel-debug-drawing.c b/eel/eel-debug-drawing.c index 61a3aeb6..63706829 100644 --- a/eel/eel-debug-drawing.c +++ b/eel/eel-debug-drawing.c @@ -32,7 +32,6 @@ #include "eel-gdk-pixbuf-extensions.h" #include "eel-gtk-extensions.h" #include "eel-gtk-extensions.h" -#include "eel-gtk-macros.h" #include @@ -73,29 +72,7 @@ struct DebugPixbufViewerClass GtkWidgetClass parent_class; }; -/* GtkObjectClass methods */ -static void debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class); -static void debug_pixbuf_viewer_init (DebugPixbufViewer *pixbuf_viewer); -static void debug_pixbuf_viewer_finalize (GObject *object); - -/* GtkWidgetClass methods */ -static void debug_pixbuf_viewer_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static int debug_pixbuf_viewer_expose_event (GtkWidget *widget, - GdkEventExpose *event); - -EEL_CLASS_BOILERPLATE (DebugPixbufViewer, debug_pixbuf_viewer, GTK_TYPE_WIDGET) - -static void -debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class) -{ - GObjectClass *object_class = G_OBJECT_CLASS (pixbuf_viewer_class); - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (pixbuf_viewer_class); - - object_class->finalize = debug_pixbuf_viewer_finalize; - widget_class->size_request = debug_pixbuf_viewer_size_request; - widget_class->expose_event = debug_pixbuf_viewer_expose_event; -} +G_DEFINE_TYPE (DebugPixbufViewer, debug_pixbuf_viewer, GTK_TYPE_WIDGET) static void debug_pixbuf_viewer_init (DebugPixbufViewer *viewer) @@ -113,7 +90,7 @@ debug_pixbuf_viewer_finalize (GObject *object) eel_gdk_pixbuf_unref_if_not_null (viewer->pixbuf); viewer->pixbuf = NULL; - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (debug_pixbuf_viewer_parent_class)->finalize (object); } static void @@ -198,6 +175,17 @@ debug_pixbuf_viewer_expose_event (GtkWidget *widget, GdkEventExpose *event) return TRUE; } +static void +debug_pixbuf_viewer_class_init (DebugPixbufViewerClass *pixbuf_viewer_class) +{ + GObjectClass *object_class = G_OBJECT_CLASS (pixbuf_viewer_class); + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (pixbuf_viewer_class); + + object_class->finalize = debug_pixbuf_viewer_finalize; + widget_class->size_request = debug_pixbuf_viewer_size_request; + widget_class->expose_event = debug_pixbuf_viewer_expose_event; +} + static void debug_pixbuf_viewer_set_pixbuf (DebugPixbufViewer *viewer, GdkPixbuf *pixbuf) { -- cgit v1.2.1 From ad104e7b749949455f88cb47a082a16ae00fee77 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 13 Nov 2012 06:13:50 +0200 Subject: [eel-background-box] Don't use eel-gtk-macros --- eel/eel-background-box.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/eel/eel-background-box.c b/eel/eel-background-box.c index a3e98ed1..6e25cc62 100644 --- a/eel/eel-background-box.c +++ b/eel/eel-background-box.c @@ -25,13 +25,12 @@ #include #include "eel-background-box.h" -#include "eel-gtk-macros.h" #include "eel-background.h" static void eel_background_box_class_init (EelBackgroundBoxClass *background_box_class); static void eel_background_box_init (EelBackgroundBox *background); -EEL_CLASS_BOILERPLATE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX) +G_DEFINE_TYPE (EelBackgroundBox, eel_background_box, GTK_TYPE_EVENT_BOX) static gboolean eel_background_box_expose_event (GtkWidget *widget, -- cgit v1.2.1 From dc5517f0b74d260129753417f7f36b06ef9f4121 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 13 Nov 2012 07:25:36 +0200 Subject: [sidebar-title] Don't use GtkObject nor eel-gtk-macros --- src/caja-sidebar-title.c | 65 +++++++++++++++++++++--------------------------- 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/src/caja-sidebar-title.c b/src/caja-sidebar-title.c index 86dd4e41..c7bda988 100644 --- a/src/caja-sidebar-title.c +++ b/src/caja-sidebar-title.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -58,20 +57,17 @@ #define DEFAULT_LIGHT_INFO_COLOR 0xFFFFFF #define DEFAULT_DARK_INFO_COLOR 0x2A2A2A -static void caja_sidebar_title_class_init (CajaSidebarTitleClass *klass); -static void caja_sidebar_title_destroy (GtkObject *object); -static void caja_sidebar_title_init (CajaSidebarTitle *pixmap); -static void caja_sidebar_title_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); -static void update_icon (CajaSidebarTitle *sidebar_title); -static GtkWidget * sidebar_title_create_title_label (void); -static GtkWidget * sidebar_title_create_more_info_label (void); -static void update_all (CajaSidebarTitle *sidebar_title); -static void update_more_info (CajaSidebarTitle *sidebar_title); -static void update_title_font (CajaSidebarTitle *sidebar_title); -static void style_set (GtkWidget *widget, - GtkStyle *previous_style); -static guint get_best_icon_size (CajaSidebarTitle *sidebar_title); +static void caja_sidebar_title_size_allocate (GtkWidget *widget, + GtkAllocation *allocation); +static void update_icon (CajaSidebarTitle *sidebar_title); +static GtkWidget * sidebar_title_create_title_label (void); +static GtkWidget * sidebar_title_create_more_info_label (void); +static void update_all (CajaSidebarTitle *sidebar_title); +static void update_more_info (CajaSidebarTitle *sidebar_title); +static void update_title_font (CajaSidebarTitle *sidebar_title); +static void style_set (GtkWidget *widget, + GtkStyle *previous_style); +static guint get_best_icon_size (CajaSidebarTitle *sidebar_title); enum { @@ -102,22 +98,8 @@ struct CajaSidebarTitleDetails gboolean determined_icon; }; -EEL_CLASS_BOILERPLATE (CajaSidebarTitle, caja_sidebar_title, gtk_vbox_get_type ()) +G_DEFINE_TYPE (CajaSidebarTitle, caja_sidebar_title, GTK_TYPE_VBOX) -static void -caja_sidebar_title_class_init (CajaSidebarTitleClass *class) -{ - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass*) class; - widget_class = (GtkWidgetClass*) class; - - object_class->destroy = caja_sidebar_title_destroy; - widget_class->size_allocate = caja_sidebar_title_size_allocate; - widget_class->style_set = style_set; - -} static void style_set (GtkWidget *widget, @@ -150,7 +132,9 @@ style_set (GtkWidget *widget, static void caja_sidebar_title_init (CajaSidebarTitle *sidebar_title) { - sidebar_title->details = g_new0 (CajaSidebarTitleDetails, 1); + sidebar_title->details = G_TYPE_INSTANCE_GET_PRIVATE (sidebar_title, + CAJA_TYPE_SIDEBAR_TITLE, + CajaSidebarTitleDetails); /* Create the icon */ sidebar_title->details->icon = gtk_image_new (); @@ -204,7 +188,7 @@ release_file (CajaSidebarTitle *sidebar_title) } static void -caja_sidebar_title_destroy (GtkObject *object) +caja_sidebar_title_finalize (GObject *object) { CajaSidebarTitle *sidebar_title; @@ -215,14 +199,23 @@ caja_sidebar_title_destroy (GtkObject *object) release_file (sidebar_title); g_free (sidebar_title->details->title_text); - g_free (sidebar_title->details); - sidebar_title->details = NULL; } g_signal_handlers_disconnect_by_func (caja_preferences, update_more_info, sidebar_title); - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); + G_OBJECT_CLASS (caja_sidebar_title_parent_class)->finalize (object); +} + +static void +caja_sidebar_title_class_init (CajaSidebarTitleClass *klass) +{ + g_type_class_add_private (klass, sizeof (CajaSidebarTitleDetails)); + + G_OBJECT_CLASS (klass)->finalize = caja_sidebar_title_finalize; + + GTK_WIDGET_CLASS (klass)->size_allocate = caja_sidebar_title_size_allocate; + GTK_WIDGET_CLASS (klass)->style_set = style_set; } /* return a new index title object */ @@ -726,7 +719,7 @@ caja_sidebar_title_size_allocate (GtkWidget *widget, gtk_widget_get_allocation (widget, &old_allocation); old_width = old_allocation.width; - EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation)); + GTK_WIDGET_CLASS (caja_sidebar_title_parent_class)->size_allocate (widget, allocation); gtk_widget_get_allocation (widget, &new_allocation); -- cgit v1.2.1 From 079f01d120988b1b6549a0b815cd0fad65bdc424 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 13 Nov 2012 12:11:05 +0200 Subject: [KeepLastVerticalBox] Don't use eel-gtk-macros --- libcaja-private/caja-keep-last-vertical-box.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libcaja-private/caja-keep-last-vertical-box.c b/libcaja-private/caja-keep-last-vertical-box.c index 51c709ce..212fcc93 100644 --- a/libcaja-private/caja-keep-last-vertical-box.c +++ b/libcaja-private/caja-keep-last-vertical-box.c @@ -26,14 +26,13 @@ #include #include "caja-keep-last-vertical-box.h" -#include - static void caja_keep_last_vertical_box_class_init (CajaKeepLastVerticalBoxClass *class); static void caja_keep_last_vertical_box_init (CajaKeepLastVerticalBox *box); static void caja_keep_last_vertical_box_size_allocate (GtkWidget *widget, GtkAllocation *allocation); -EEL_CLASS_BOILERPLATE (CajaKeepLastVerticalBox, caja_keep_last_vertical_box, GTK_TYPE_VBOX) +G_DEFINE_TYPE (CajaKeepLastVerticalBox, caja_keep_last_vertical_box, GTK_TYPE_VBOX) +#define parent_class caja_keep_last_vertical_box_parent_class /* Standard class initialization function */ static void @@ -96,10 +95,10 @@ caja_keep_last_vertical_box_size_allocate (GtkWidget *widget, g_return_if_fail (CAJA_IS_KEEP_LAST_VERTICAL_BOX (widget)); g_return_if_fail (allocation != NULL); - EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, (widget, allocation)); + GTK_WIDGET_CLASS (caja_keep_last_vertical_box_parent_class)->size_allocate (widget, allocation); box = GTK_BOX (widget); - children = gtk_container_get_children (GTK_CONTAINER(widget)); + children = gtk_container_get_children (GTK_CONTAINER (widget)); l = g_list_last (children); if (l != NULL) -- cgit v1.2.1 From 700c0c288247d4cecaeb0ea340437779faf64edb Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 13 Nov 2012 07:53:03 +0200 Subject: [information-panel] Don't use eel-gtk-macros --- src/caja-information-panel.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c index 086faaee..5585457e 100644 --- a/src/caja-information-panel.c +++ b/src/caja-information-panel.c @@ -31,7 +31,6 @@ #include #include #include -#include #include #include #include @@ -146,8 +145,6 @@ typedef struct G_DEFINE_TYPE_WITH_CODE (CajaInformationPanel, caja_information_panel, EEL_TYPE_BACKGROUND_BOX, G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR, caja_information_panel_iface_init)); -/* for EEL_CALL_PARENT */ -#define parent_class caja_information_panel_parent_class G_DEFINE_TYPE_WITH_CODE (CajaInformationPanelProvider, caja_information_panel_provider, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR_PROVIDER, @@ -221,6 +218,8 @@ caja_information_panel_class_init (CajaInformationPanelClass *klass) NULL, NULL, g_cclosure_marshal_VOID__STRING, G_TYPE_NONE, 1, G_TYPE_STRING); + + g_type_class_add_private (klass, sizeof (CajaInformationPanelDetails)); } /* utility routine to allocate the box the holds the command buttons */ @@ -245,11 +244,9 @@ make_button_box (CajaInformationPanel *information_panel) static void caja_information_panel_init (CajaInformationPanel *information_panel) { - GtkWidget *widget; - - widget = GTK_WIDGET (information_panel); - - information_panel->details = g_new0 (CajaInformationPanelDetails, 1); + information_panel->details = G_TYPE_INSTANCE_GET_PRIVATE (information_panel, + CAJA_TYPE_INFORMATION_PANEL, + CajaInformationPanelDetails); /* load the default background */ caja_information_panel_read_defaults (information_panel); @@ -312,13 +309,12 @@ caja_information_panel_finalize (GObject *object) g_free (information_panel->details->default_background_image); g_free (information_panel->details->current_background_color); g_free (information_panel->details->current_background_image); - g_free (information_panel->details); g_signal_handlers_disconnect_by_func (caja_preferences, caja_information_panel_theme_changed, information_panel); - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); + G_OBJECT_CLASS (caja_information_panel_parent_class)->finalize (object); } /* callback to handle resetting the background */ -- cgit v1.2.1 From 5d46e2a7bed077a365f4df32e8ef2ef20323871c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 3 Nov 2012 18:26:46 +0200 Subject: [property-browser] Don't use GtkObject nor eel-gtk-macros --- src/caja-property-browser.c | 149 ++++++++++++++++++++------------------------ 1 file changed, 69 insertions(+), 80 deletions(-) diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c index 8c8cea9d..5fb5c249 100644 --- a/src/caja-property-browser.c +++ b/src/caja-property-browser.c @@ -35,13 +35,10 @@ #include #include #include -#include #include -#include #include #include #include -#include #include #include #include @@ -122,9 +119,6 @@ struct CajaPropertyBrowserDetails gboolean has_local; }; -static void caja_property_browser_class_init (GtkObjectClass *object_klass); -static void caja_property_browser_init (GtkObject *object); -static void caja_property_browser_destroy (GtkObject *object); static void caja_property_browser_update_contents (CajaPropertyBrowser *property_browser); static void caja_property_browser_set_category (CajaPropertyBrowser *property_browser, const char *new_category); @@ -200,41 +194,85 @@ static GtkTargetEntry drag_types[] = }; -EEL_CLASS_BOILERPLATE (CajaPropertyBrowser, - caja_property_browser, - GTK_TYPE_WINDOW) +G_DEFINE_TYPE (CajaPropertyBrowser, caja_property_browser, GTK_TYPE_WINDOW) + + +/* Destroy the three dialogs for adding patterns/colors/emblems if any of them + exist. */ +static void +caja_property_browser_destroy_dialogs (CajaPropertyBrowser *property_browser) +{ + if (property_browser->details->patterns_dialog) + { + gtk_widget_destroy (property_browser->details->patterns_dialog); + property_browser->details->patterns_dialog = NULL; + } + if (property_browser->details->colors_dialog) + { + gtk_widget_destroy (property_browser->details->colors_dialog); + property_browser->details->colors_dialog = NULL; + } + if (property_browser->details->emblems_dialog) + { + gtk_widget_destroy (property_browser->details->emblems_dialog); + property_browser->details->emblems_dialog = NULL; + } +} -/* initializing the class object by installing the operations we override */ static void -caja_property_browser_class_init (GtkObjectClass *object_klass) +caja_property_browser_dispose (GObject *object) { - CajaPropertyBrowserClass *klass; - GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (object_klass); + CajaPropertyBrowser *property_browser; + + property_browser = CAJA_PROPERTY_BROWSER (object); + + caja_property_browser_destroy_dialogs (property_browser); + + g_free (property_browser->details->path); + g_free (property_browser->details->category); + g_free (property_browser->details->dragged_file); + g_free (property_browser->details->drag_type); + + eel_g_list_free_deep (property_browser->details->keywords); - klass = CAJA_PROPERTY_BROWSER_CLASS (object_klass); + if (property_browser->details->property_chit) + { + g_object_unref (property_browser->details->property_chit); + } + + G_OBJECT_CLASS (caja_property_browser_parent_class)->dispose (object); +} - object_klass->destroy = caja_property_browser_destroy; +/* initializing the class object by installing the operations we override */ +static void +caja_property_browser_class_init (CajaPropertyBrowserClass *klass) +{ + GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); + + G_OBJECT_CLASS (klass)->dispose = caja_property_browser_dispose; widget_class->drag_begin = caja_property_browser_drag_begin; widget_class->drag_data_get = caja_property_browser_drag_data_get; widget_class->drag_end = caja_property_browser_drag_end; + + g_type_class_add_private (klass, sizeof (CajaPropertyBrowserDetails)); } /* initialize the instance's fields, create the necessary subviews, etc. */ static void -caja_property_browser_init (GtkObject *object) +caja_property_browser_init (CajaPropertyBrowser *property_browser) { - CajaPropertyBrowser *property_browser; GtkWidget *widget, *temp_box, *temp_hbox, *temp_frame, *vbox; GtkWidget *temp_button; GtkWidget *viewport; PangoAttrList *attrs; char *temp_str; - property_browser = CAJA_PROPERTY_BROWSER (object); - widget = GTK_WIDGET (object); + widget = GTK_WIDGET (property_browser); - property_browser->details = g_new0 (CajaPropertyBrowserDetails, 1); + property_browser->details = G_TYPE_INSTANCE_GET_PRIVATE (property_browser, + CAJA_TYPE_PROPERTY_BROWSER, + CajaPropertyBrowserDetails); property_browser->details->category = g_strdup ("patterns"); property_browser->details->category_type = CAJA_PROPERTY_PATTERN; @@ -405,55 +443,6 @@ caja_property_browser_init (GtkObject *object) caja_property_browser_set_path(property_browser, BROWSER_CATEGORIES_FILE_NAME); } -/* Destroy the three dialogs for adding patterns/colors/emblems if any of them - exist. */ -static void -caja_property_browser_destroy_dialogs (CajaPropertyBrowser *property_browser) -{ - if (property_browser->details->patterns_dialog) - { - gtk_widget_destroy (property_browser->details->patterns_dialog); - property_browser->details->patterns_dialog = NULL; - } - if (property_browser->details->colors_dialog) - { - gtk_widget_destroy (property_browser->details->colors_dialog); - property_browser->details->colors_dialog = NULL; - } - if (property_browser->details->emblems_dialog) - { - gtk_widget_destroy (property_browser->details->emblems_dialog); - property_browser->details->emblems_dialog = NULL; - } -} - -static void -caja_property_browser_destroy (GtkObject *object) -{ - CajaPropertyBrowser *property_browser; - - - property_browser = CAJA_PROPERTY_BROWSER (object); - - caja_property_browser_destroy_dialogs (property_browser); - - g_free (property_browser->details->path); - g_free (property_browser->details->category); - g_free (property_browser->details->dragged_file); - g_free (property_browser->details->drag_type); - - eel_g_list_free_deep (property_browser->details->keywords); - - if (property_browser->details->property_chit) - { - g_object_unref (property_browser->details->property_chit); - } - - g_free (property_browser->details); - - EEL_CALL_PARENT (GTK_OBJECT_CLASS, destroy, (object)); -} - /* create a new instance */ CajaPropertyBrowser * caja_property_browser_new (GdkScreen *screen) @@ -555,7 +544,7 @@ caja_property_browser_drag_begin (GtkWidget *widget, /* it's not a color, so, for now, it must be an image */ /* fiddle with the category to handle the "reset" case properly */ char * save_category = property_browser->details->category; - if (eel_strcmp (property_browser->details->category, "colors") == 0) + if (g_strcmp0 (property_browser->details->category, "colors") == 0) { property_browser->details->category = "patterns"; } @@ -625,7 +614,7 @@ caja_property_browser_drag_data_get (GtkWidget *widget, guint16 colorArray[4]; /* handle the "reset" case as an image */ - if (eel_strcmp (property_browser->details->dragged_file, RESET_IMAGE_NAME) != 0) + if (g_strcmp0 (property_browser->details->dragged_file, RESET_IMAGE_NAME) != 0) { gdk_color_parse (property_browser->details->dragged_file, &color); @@ -783,7 +772,7 @@ make_drag_image (CajaPropertyBrowser *property_browser, const char* file_name) return NULL; } - is_reset = eel_strcmp (file_name, RESET_IMAGE_NAME) == 0; + is_reset = g_strcmp0 (file_name, RESET_IMAGE_NAME) == 0; if (strcmp (property_browser->details->category, "patterns") == 0 && property_browser->details->property_chit != NULL) @@ -1240,7 +1229,7 @@ add_pattern_to_browser (GtkDialog *dialog, gint response_id, gpointer *data) /* don't allow the user to change the reset image */ basename = g_file_get_basename (selected); - if (basename && eel_strcmp (basename, RESET_IMAGE_NAME) == 0) + if (basename && g_strcmp0 (basename, RESET_IMAGE_NAME) == 0) { eel_show_error_dialog (_("Sorry, but you cannot replace the reset image."), _("Reset is a special image that cannot be deleted."), @@ -1725,7 +1714,7 @@ element_clicked_callback (GtkWidget *image_table, drag_types[0].target = property_browser->details->drag_type; /* treat the reset property in the colors section specially */ - if (eel_strcmp (element_name, RESET_IMAGE_NAME) == 0) + if (g_strcmp0 (element_name, RESET_IMAGE_NAME) == 0) { drag_types[0].target = "x-special/mate-reset-background"; } @@ -1888,7 +1877,7 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser) /* Keep track of ERASE objects to place them prominently later */ if (property_browser->details->category_type == CAJA_PROPERTY_PATTERN - && !eel_strcmp (object_name, RESET_IMAGE_NAME)) + && !g_strcmp0 (object_name, RESET_IMAGE_NAME)) { g_assert (reset_object == NULL); reset_object = property_image; @@ -2408,7 +2397,7 @@ caja_property_browser_set_category (CajaPropertyBrowser *property_browser, const char *new_category) { /* there's nothing to do if the category is the same as the current one */ - if (eel_strcmp (property_browser->details->category, new_category) == 0) + if (g_strcmp0 (property_browser->details->category, new_category) == 0) { return; } @@ -2417,15 +2406,15 @@ caja_property_browser_set_category (CajaPropertyBrowser *property_browser, property_browser->details->category = g_strdup (new_category); /* set up the property type enum */ - if (eel_strcmp (new_category, "patterns") == 0) + if (g_strcmp0 (new_category, "patterns") == 0) { property_browser->details->category_type = CAJA_PROPERTY_PATTERN; } - else if (eel_strcmp (new_category, "colors") == 0) + else if (g_strcmp0 (new_category, "colors") == 0) { property_browser->details->category_type = CAJA_PROPERTY_COLOR; } - else if (eel_strcmp (new_category, "emblems") == 0) + else if (g_strcmp0 (new_category, "emblems") == 0) { property_browser->details->category_type = CAJA_PROPERTY_EMBLEM; } @@ -2447,7 +2436,7 @@ caja_property_browser_set_path (CajaPropertyBrowser *property_browser, const char *new_path) { /* there's nothing to do if the uri is the same as the current one */ - if (eel_strcmp (property_browser->details->path, new_path) == 0) + if (g_strcmp0 (property_browser->details->path, new_path) == 0) { return; } -- cgit v1.2.1 From 765d89de748d29e99e0babf08091985133f9c377 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Tue, 6 Nov 2012 18:07:07 +0200 Subject: [emblem-sidebar] Don't include eel-gtk-macros, minor cleanup --- src/caja-emblem-sidebar.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c index 7c188a7d..ea21bec9 100644 --- a/src/caja-emblem-sidebar.c +++ b/src/caja-emblem-sidebar.c @@ -32,7 +32,6 @@ #include "caja-emblem-sidebar.h" #include -#include #include #include #include @@ -67,12 +66,10 @@ struct CajaEmblemSidebarDetails #define STANDARD_EMBLEM_HEIGHT 52 #define EMBLEM_LABEL_SPACING 2 -static void caja_emblem_sidebar_iface_init (CajaSidebarIface *iface); -static void caja_emblem_sidebar_finalize (GObject *object); static void caja_emblem_sidebar_populate (CajaEmblemSidebar *emblem_sidebar); static void caja_emblem_sidebar_refresh (CajaEmblemSidebar *emblem_sidebar); static void caja_emblem_sidebar_iface_init (CajaSidebarIface *iface); -static void sidebar_provider_iface_init (CajaSidebarProviderIface *iface); +static void sidebar_provider_iface_init (CajaSidebarProviderIface *iface); static GType caja_emblem_sidebar_provider_get_type (void); static const GtkTargetEntry drag_types[] = @@ -113,8 +110,6 @@ typedef struct } CajaEmblemSidebarProviderClass; - - G_DEFINE_TYPE_WITH_CODE (CajaEmblemSidebar, caja_emblem_sidebar, GTK_TYPE_VBOX, G_IMPLEMENT_INTERFACE (CAJA_TYPE_SIDEBAR, caja_emblem_sidebar_iface_init)); -- cgit v1.2.1 From 2e0b6b0a2e689d5af0ca719ee0ef29f90c4f2e0c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 16:33:39 +0200 Subject: [icon-dnd] remove commented out obsolete code http://git.gnome.org/browse/nautilus/commit/?id=c5eba3314c99059aa1fff13aedcb1004966fdd55 --- libcaja-private/caja-icon-dnd.c | 63 +---------------------------------------- 1 file changed, 1 insertion(+), 62 deletions(-) diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 449ceab8..470a767e 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -940,63 +940,6 @@ stop_auto_scroll (CajaIconContainer *container) caja_drag_autoscroll_stop (&container->details->dnd_info->drag_info); } -static gboolean -confirm_switch_to_manual_layout (CajaIconContainer *container) -{ -#if 0 - const char *message; - const char *detail; - GtkDialog *dialog; - int response; - - /* FIXME bugzilla.gnome.org 40915: Use of the word "directory" - * makes this FMIconView specific. Move these messages into - * FMIconView so CajaIconContainer can be used for things - * that are not directories? - */ - if (caja_icon_container_has_stored_icon_positions (container)) - { - if (eel_g_list_exactly_one_item (container->details->dnd_info->drag_info.selection_list)) - { - message = no_translate("Do you want to switch to manual layout and leave this item where you dropped it? " - "This will clobber the stored manual layout."); - detail = no_translate("This folder uses automatic layout."); - } - else - { - message = no_translate("Do you want to switch to manual layout and leave these items where you dropped them? " - "This will clobber the stored manual layout."); - detail = no_translate("This folder uses automatic layout."); - } - } - else - { - if (eel_g_list_exactly_one_item (container->details->dnd_info->drag_info.selection_list)) - { - message = no_translate("Do you want to switch to manual layout and leave this item where you dropped it?"); - detail = no_translate("This folder uses automatic layout."); - } - else - { - message = no_translate("Do you want to switch to manual layout and leave these items where you dropped them?"); - detail = no_translate("This folder uses automatic layout."); - - } - } - - dialog = eel_show_yes_no_dialog (message, detail, _("Switch to Manual Layout?"), - GTK_STOCK_CANCEL, - GTK_WINDOW (gtk_widget_get_toplevel(GTK_WIDGET(container)))); - - response = gtk_dialog_run (dialog); - gtk_object_destroy (GTK_OBJECT (dialog)); - - return response == GTK_RESPONSE_YES; -#else - return FALSE; -#endif -} - static void handle_local_move (CajaIconContainer *container, double world_x, double world_y) @@ -1011,11 +954,7 @@ handle_local_move (CajaIconContainer *container, if (container->details->auto_layout) { - if (!confirm_switch_to_manual_layout (container)) - { - return; - } - caja_icon_container_freeze_icon_positions (container); + return; } time (&now); -- cgit v1.2.1 From 8af0b94b1f4df47364abc9f7f02cc467ecd1cdee Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 17:27:04 +0200 Subject: [eel-gdk-extensions] Add eel_cairo_draw_layout_with_drop_shadow for GTK3 keeping eel_gdk_draw_layout_with_drop_shadow for GTK2 http://git.gnome.org/browse/nautilus/commit/?id=d2f141f4a5435b10b43abea0822e3d0569b67886 --- eel/eel-gdk-extensions.c | 13 ++++++++++++- eel/eel-gdk-extensions.h | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/eel/eel-gdk-extensions.c b/eel/eel-gdk-extensions.c index 2a5f8734..ed694277 100644 --- a/eel/eel-gdk-extensions.c +++ b/eel/eel-gdk-extensions.c @@ -477,16 +477,23 @@ eel_gdk_parse_geometry (const char *string, int *x_return, int *y_return, } void +#if GTK_CHECK_VERSION(3,0,0) +eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr, +#else eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, +#endif GdkColor *text_color, GdkColor *shadow_color, int x, int y, PangoLayout *layout) { +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else cairo_t *cr; - cr = gdk_cairo_create (drawable); +#endif gdk_cairo_set_source_color (cr, shadow_color); cairo_move_to (cr, x+1, y+1); @@ -496,7 +503,11 @@ eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, layout); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore +#else cairo_destroy (cr); +#endif } #if ! defined (EEL_OMIT_SELF_CHECK) diff --git a/eel/eel-gdk-extensions.h b/eel/eel-gdk-extensions.h index a879bdce..2036eec4 100644 --- a/eel/eel-gdk-extensions.h +++ b/eel/eel-gdk-extensions.h @@ -28,6 +28,10 @@ #include +#ifndef GTK_CHECK_VERSION +#include +#endif + #define EEL_RGB_COLOR_RED 0xFF0000 #define EEL_RGB_COLOR_GREEN 0x00FF00 #define EEL_RGB_COLOR_BLUE 0x0000FF @@ -118,10 +122,14 @@ EelGdkGeometryFlags eel_gdk_parse_geometry (const char int *y_return, guint *width_return, guint *height_return); +#if GTK_CHECK_VERSION(3,0,0) +void eel_cairo_draw_layout_with_drop_shadow (cairo_t *cr, +#else void eel_gdk_draw_layout_with_drop_shadow (GdkDrawable *drawable, - GdkColor *text_color, - GdkColor *shadow_color, - int x, - int y, - PangoLayout *layout); +#endif + GdkColor *text_color, + GdkColor *shadow_color, + int x, + int y, + PangoLayout *layout); #endif /* EEL_GDK_EXTENSIONS_H */ -- cgit v1.2.1 From aebf60348dd7675678c28a5c850d1900b7b95e8c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 19:19:10 +0200 Subject: [eel-canvas] Port the eel canvas to rendering-cleanup-next http://git.gnome.org/browse/nautilus/commit/?id=58832e54b6a4e596693527d577e4f8fa2f3e4ccf --- eel/eel-canvas-rect-ellipse.c | 38 +++++++++- eel/eel-canvas.c | 173 ++++++++++++++++++++++++++++++++++++------ eel/eel-canvas.h | 8 ++ 3 files changed, 193 insertions(+), 26 deletions(-) diff --git a/eel/eel-canvas-rect-ellipse.c b/eel/eel-canvas-rect-ellipse.c index 18263ce9..d0e4a592 100644 --- a/eel/eel-canvas-rect-ellipse.c +++ b/eel/eel-canvas-rect-ellipse.c @@ -621,7 +621,11 @@ static void eel_canvas_rect_init (EelCanvasRect *rect); static void eel_canvas_rect_finalize (GObject *object); static void eel_canvas_rect_realize (EelCanvasItem *item); +#if GTK_CHECK_VERSION(3,0,0) +static void eel_canvas_rect_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); +#else static void eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); +#endif static double eel_canvas_rect_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item); @@ -749,10 +753,13 @@ eel_canvas_set_source_color (cairo_t *cr, #define DASH_ON 0.8 #define DASH_OFF 1.7 static void +#if GTK_CHECK_VERSION(3,0,0) +eel_canvas_rect_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region) +#else eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) +#endif { EelCanvasRE *re; - cairo_t *cr; double x1, y1, x2, y2; int cx1, cy1, cx2, cy2; double i2w_dx, i2w_dy; @@ -776,9 +783,13 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose return; } - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); gdk_cairo_region (cr, expose->region); cairo_clip (cr); +#endif if (re->fill_set) { @@ -812,7 +823,11 @@ eel_canvas_rect_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose cairo_stroke (cr); } +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } static double @@ -1008,7 +1023,11 @@ eel_canvas_rect_update (EelCanvasItem *item, double i2w_dx, double i2w_dy, gint static void eel_canvas_ellipse_class_init (EelCanvasEllipseClass *klass); +#if GTK_CHECK_VERSION(3,0,0) +static void eel_canvas_ellipse_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); +#else static void eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); +#endif static double eel_canvas_ellipse_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item); @@ -1056,12 +1075,15 @@ eel_canvas_ellipse_class_init (EelCanvasEllipseClass *klass) } static void +#if GTK_CHECK_VERSION(3,0,0) +eel_canvas_ellipse_draw (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region) +#else eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) +#endif { EelCanvasRE *re; int x1, y1, x2, y2; double i2w_dx, i2w_dy; - cairo_t *cr; re = EEL_CANVAS_RE (item); @@ -1080,9 +1102,13 @@ eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExp re->y2 + i2w_dy, &x2, &y2); - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); gdk_cairo_region (cr, expose->region); cairo_clip (cr); +#endif cairo_save (cr); cairo_translate (cr, (x1 + x2) / 2., (y1 + y2) / 2.); @@ -1108,7 +1134,11 @@ eel_canvas_ellipse_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExp cairo_stroke_preserve (cr); } +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } static double diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 647de723..08793333 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -69,16 +69,13 @@ #include #include #include +#if GTK_CHECK_VERSION(3,0,0) +# include +#endif #include "eel-canvas.h" #include "eel-marshal.h" -/* Some compatibility defines to let us build on both Gtk2 and Gtk3 */ -#if !GTK_CHECK_VERSION (3, 0, 0) -#define cairo_region_contains_rectangle gdk_region_rect_in -#define CAIRO_REGION_OVERLAP_OUT GDK_OVERLAP_RECTANGLE_OUT -#endif - static void eel_canvas_request_update (EelCanvas *canvas); static void group_add (EelCanvasGroup *group, EelCanvasItem *item); @@ -1222,8 +1219,14 @@ static void eel_canvas_group_update (EelCanvasItem *item, static void eel_canvas_group_unrealize (EelCanvasItem *item); static void eel_canvas_group_map (EelCanvasItem *item); static void eel_canvas_group_unmap (EelCanvasItem *item); +#if GTK_CHECK_VERSION(3,0,0) +static void eel_canvas_group_draw (EelCanvasItem *item, + cairo_t *cr, + cairo_region_t *region); +#else static void eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); +#endif static double eel_canvas_group_point (EelCanvasItem *item, double x, double y, int cx, int cy, EelCanvasItem **actual_item); @@ -1546,8 +1549,14 @@ eel_canvas_group_unmap (EelCanvasItem *item) /* Draw handler for canvas groups */ static void +#if GTK_CHECK_VERSION(3,0,0) +eel_canvas_group_draw (EelCanvasItem *item, + cairo_t *cr, + cairo_region_t *region) +#else eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) +#endif { EelCanvasGroup *group; GList *list; @@ -1569,8 +1578,13 @@ eel_canvas_group_draw (EelCanvasItem *item, GdkDrawable *drawable, child_rect.width = child->x2 - child->x1 + 1; child_rect.height = child->y2 - child->y1 + 1; - if (cairo_region_contains_rectangle (expose->region, &child_rect) != CAIRO_REGION_OVERLAP_OUT) +#if GTK_CHECK_VERSION (3, 0, 0) + if (cairo_region_contains_rectangle (region, &child_rect) != CAIRO_REGION_OVERLAP_OUT) + EEL_CANVAS_ITEM_GET_CLASS (child)->draw (child, cr, region); +#else + if (gdk_region_rect_in (expose->region, &child_rect) != GDK_OVERLAP_RECTANGLE_OUT) (* EEL_CANVAS_ITEM_GET_CLASS (child)->draw) (child, drawable, expose); +#endif } } } @@ -1813,8 +1827,13 @@ static gint eel_canvas_button (GtkWidget *widget, GdkEventButton *event); static gint eel_canvas_motion (GtkWidget *widget, GdkEventMotion *event); +#if GTK_CHECK_VERSION (3, 0, 0) +static gint eel_canvas_draw (GtkWidget *widget, + cairo_t *cr); +#else static gint eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event); +#endif static gint eel_canvas_key (GtkWidget *widget, GdkEventKey *event); static gint eel_canvas_crossing (GtkWidget *widget, @@ -1825,11 +1844,14 @@ static gint eel_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event); static void eel_canvas_request_update_real (EelCanvas *canvas); static void eel_canvas_draw_background (EelCanvas *canvas, +#if GTK_CHECK_VERSION (3, 0, 0) + cairo_t *cr); +#else int x, int y, int width, int height); - +#endif static GtkLayoutClass *canvas_parent_class; @@ -2140,7 +2162,11 @@ eel_canvas_class_init (EelCanvasClass *klass) widget_class->button_press_event = eel_canvas_button; widget_class->button_release_event = eel_canvas_button; widget_class->motion_notify_event = eel_canvas_motion; +#if GTK_CHECK_VERSION (3, 0, 0) + widget_class->draw = eel_canvas_draw; +#else widget_class->expose_event = eel_canvas_expose; +#endif widget_class->key_press_event = eel_canvas_key; widget_class->key_release_event = eel_canvas_key; widget_class->enter_notify_event = eel_canvas_crossing; @@ -2157,9 +2183,15 @@ eel_canvas_class_init (EelCanvasClass *klass) G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (EelCanvasClass, draw_background), NULL, NULL, +#if GTK_CHECK_VERSION (3, 0, 0) + g_cclosure_marshal_VOID__BOXED, + G_TYPE_NONE, 1, + CAIRO_GOBJECT_TYPE_CONTEXT); +#else eel_marshal_VOID__INT_INT_INT_INT, G_TYPE_NONE, 4, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT, G_TYPE_INT); +#endif atk_registry_set_factory_type (atk_get_default_registry (), EEL_TYPE_CANVAS, @@ -3018,18 +3050,80 @@ eel_canvas_focus_out (GtkWidget *widget, GdkEventFocus *event) return FALSE; } + +#if GTK_CHECK_VERSION(3,0,0) +static cairo_region_t * +eel_cairo_get_clip_region (cairo_t *cr) +{ + cairo_rectangle_list_t *list; + cairo_region_t *region; + int i; + + list = cairo_copy_clip_rectangle_list (cr); + if (list->status == CAIRO_STATUS_CLIP_NOT_REPRESENTABLE) { + cairo_rectangle_int_t clip_rect; + + cairo_rectangle_list_destroy (list); + + if (!gdk_cairo_get_clip_rectangle (cr, &clip_rect)) + return NULL; + return cairo_region_create_rectangle (&clip_rect); + } + + + region = cairo_region_create (); + for (i = list->num_rectangles - 1; i >= 0; --i) { + cairo_rectangle_t *rect = &list->rectangles[i]; + cairo_rectangle_int_t clip_rect; + + clip_rect.x = floor (rect->x); + clip_rect.y = floor (rect->y); + clip_rect.width = ceil (rect->x + rect->width) - clip_rect.x; + clip_rect.height = ceil (rect->y + rect->height) - clip_rect.y; + + if (cairo_region_union_rectangle (region, &clip_rect) != CAIRO_STATUS_SUCCESS) { + cairo_region_destroy (region); + region = NULL; + break; + } + } + + cairo_rectangle_list_destroy (list); + return region; +} +#endif + /* Expose handler for the canvas */ +#if GTK_CHECK_VERSION(3,0,0) +static gboolean +eel_canvas_draw (GtkWidget *widget, cairo_t *cr) +#else static gint eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event) +#endif { - EelCanvas *canvas; + EelCanvas *canvas = EEL_CANVAS (widget); +#if GTK_CHECK_VERSION(3,0,0) + GdkWindow *bin_window; + cairo_region_t *region; - canvas = EEL_CANVAS (widget); + if (!gdk_cairo_get_clip_rectangle (cr, NULL)) + return FALSE; + bin_window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); + gtk_cairo_transform_to_window (cr, widget, bin_window); + + region = eel_cairo_get_clip_region (cr); + if (region == NULL) + return FALSE; +#else if (!gtk_widget_is_drawable (widget) || (event->window != gtk_layout_get_bin_window (&canvas->layout))) return FALSE; +#endif -#ifdef VERBOSE - g_print ("Expose\n"); +#if defined VERBOSE && GTK_CHECK_VERSION(3,0,0) + g_print ("Draw\n"); +#elif defined VERBOSE + g_print ("Expose\n"); #endif /* If there are any outstanding items that need updating, do them now */ if (canvas->idle_id) @@ -3054,31 +3148,59 @@ eel_canvas_expose (GtkWidget *widget, GdkEventExpose *event) /* Hmmm. Would like to queue antiexposes if the update marked anything that is gonna get redrawn as invalid */ - g_signal_emit (G_OBJECT (canvas), canvas_signals[DRAW_BACKGROUND], 0, +#if GTK_CHECK_VERSION(3,0,0) + cr); +#else event->area.x, event->area.y, event->area.width, event->area.height); +#endif if (canvas->root->flags & EEL_CANVAS_ITEM_MAPPED) - (* EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->draw) (canvas->root, - gtk_layout_get_bin_window (&canvas->layout), - event); - - + EEL_CANVAS_ITEM_GET_CLASS (canvas->root)->draw (canvas->root, +#if GTK_CHECK_VERSION(3,0,0) + cr, region); +#else + gtk_layout_get_bin_window (&canvas->layout), + event); +#endif /* Chain up to get exposes on child widgets */ +#if !GTK_CHECK_VERSION(3,0,0) GTK_WIDGET_CLASS (canvas_parent_class)->expose_event (widget, event); +#else + if (GTK_WIDGET_CLASS (canvas_parent_class)->draw) + GTK_WIDGET_CLASS (canvas_parent_class)->draw (widget, cr); + cairo_region_destroy (region); +#endif return FALSE; } + +#if GTK_CHECK_VERSION(3,0,0) static void eel_canvas_draw_background (EelCanvas *canvas, - int x, int y, int width, int height) + cairo_t *cr) { - cairo_t *cr; + cairo_rectangle_int_t rect; - cr = gdk_cairo_create (gtk_layout_get_bin_window (&canvas->layout)); + if (!gdk_cairo_get_clip_rectangle (cr, &rect)) + return; + + cairo_save (cr); + /* By default, we use the style background. */ + gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]); + gdk_cairo_rectangle (cr, &rect); + cairo_fill (cr); + cairo_restore (cr); +} +#else /* GTK_CHECK_VERSION(3,0,0) */ +static void +eel_canvas_draw_background (EelCanvas *canvas, + int x, int y, int width, int height) +{ + cairo_t *cr = gdk_cairo_create (gtk_layout_get_bin_window (&canvas->layout)); /* By default, we use the style background. */ gdk_cairo_set_source_color (cr, >k_widget_get_style (GTK_WIDGET (canvas))->bg[GTK_STATE_NORMAL]); @@ -3087,6 +3209,7 @@ eel_canvas_draw_background (EelCanvas *canvas, cairo_destroy (cr); } +#endif /* GTK_CHECK_VERSION(3,0,0) */ static void do_update (EelCanvas *canvas) @@ -3349,14 +3472,20 @@ eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n) attributes.height = allocation.height; attributes.wclass = GDK_INPUT_OUTPUT; attributes.visual = gtk_widget_get_visual (widget); - attributes.colormap = gtk_widget_get_colormap (widget); attributes.event_mask = GDK_VISIBILITY_NOTIFY_MASK; +#if GTK_CHECK_VERSION(3,0,0) + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL; +#else + attributes.colormap = gtk_widget_get_colormap (widget); attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP; +#endif window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); +#if !GTK_CHECK_VERSION(3,0,0) gdk_window_set_back_pixmap (window, NULL, FALSE); +#endif gdk_window_set_user_data (window, widget); gdk_window_show (window); diff --git a/eel/eel-canvas.h b/eel/eel-canvas.h index b288dedf..8f49141a 100644 --- a/eel/eel-canvas.h +++ b/eel/eel-canvas.h @@ -159,7 +159,11 @@ extern "C" { * coordinates of the drawable, a temporary pixmap, where things get * drawn. (width, height) are the dimensions of the drawable. */ +#if GTK_CHECK_VERSION(3,0,0) + void (* draw) (EelCanvasItem *item, cairo_t *cr, cairo_region_t *region); +#else void (* draw) (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose); +#endif /* Calculate the distance from an item to the specified point. It also * returns a canvas item which is the item itself in the case of the @@ -434,7 +438,11 @@ extern "C" { /* Draw the background for the area given. */ void (* draw_background) (EelCanvas *canvas, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr); +#else int x, int y, int width, int height); +#endif /* Private Virtual methods for groping the canvas inside matecomponent */ void (* request_update) (EelCanvas *canvas); -- cgit v1.2.1 From 7e395411a8ef934accc205f34b4c67e03282a2dc Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 19:27:12 +0200 Subject: [editable-label] use gtk_widget_get_preferred_size() for GTK3 and gtk_widget_size_request() for GTK2 http://git.gnome.org/browse/nautilus/commit/?id=4963a3c9e5526ffd139b1b0b5bff18b6ea91a717 --- eel/eel-editable-label.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 57386f88..5a916aed 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -1216,7 +1216,11 @@ get_layout_location (EelEditableLabel *label, if (gtk_widget_get_direction (widget) != GTK_TEXT_DIR_LTR) xalign = 1.0 - xalign; - gtk_widget_get_child_requisition (widget, &req); +#if GTK_CHECK_VERSION(3,0,0) + gtk_widget_get_preferred_size (widget, &req, NULL); +#else + gtk_widget_size_request (widget, &req); +#endif gtk_misc_get_padding (misc, &xpad, &ypad); gtk_widget_get_allocation (widget, &allocation); -- cgit v1.2.1 From 40d77d2c4a371a546a35cbc8aa24bf9261e30fc0 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 19:52:40 +0200 Subject: [eel] Port EelEditableLabel to rendering-cleanup-next http://git.gnome.org/browse/nautilus/commit/?id=2b7659ac4fcaa8b93ad8f409e1560aaa60dcdc12 --- eel/eel-editable-label.c | 82 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 69 insertions(+), 13 deletions(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 5a916aed..014caabd 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -90,8 +90,13 @@ static void eel_editable_label_style_set (GtkWidget GtkStyle *previous_style); static void eel_editable_label_direction_changed (GtkWidget *widget, GtkTextDirection previous_dir); +#if GTK_CHECK_VERSION(3,0,0) +static gint eel_editable_label_draw (GtkWidget *widget, + cairo_t *cr); +#else static gint eel_editable_label_expose (GtkWidget *widget, - GdkEventExpose *event); + GdkEventExpose *event); +#endif static void eel_editable_label_realize (GtkWidget *widget); static void eel_editable_label_unrealize (GtkWidget *widget); static void eel_editable_label_map (GtkWidget *widget); @@ -225,7 +230,11 @@ eel_editable_label_class_init (EelEditableLabelClass *class) widget_class->state_changed = eel_editable_label_state_changed; widget_class->style_set = eel_editable_label_style_set; widget_class->direction_changed = eel_editable_label_direction_changed; +#if GTK_CHECK_VERSION(3,0,0) + widget_class->draw = eel_editable_label_draw; +#else widget_class->expose_event = eel_editable_label_expose; +#endif widget_class->realize = eel_editable_label_realize; widget_class->unrealize = eel_editable_label_unrealize; widget_class->map = eel_editable_label_map; @@ -1389,7 +1398,11 @@ eel_editable_label_get_block_cursor_location (EelEditableLabel *label, /* These functions are copies from gtk+, as they are not exported from gtk+ */ static void +#if GTK_CHECK_VERSION(3,0,0) +eel_editable_label_draw_cursor (EelEditableLabel *label, cairo_t *cr, gint xoffset, gint yoffset) +#else eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yoffset) +#endif { if (gtk_widget_is_drawable (GTK_WIDGET (label))) { @@ -1456,8 +1469,14 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof cursor_location.width = 0; cursor_location.height = PANGO_PIXELS (cursor1->height); - gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget), + gtk_draw_insertion_cursor (widget, +#if GTK_CHECK_VERSION(3,0,0) + cr, + &cursor_location, +#else + gtk_widget_get_window (widget), NULL, &cursor_location, +#endif TRUE, dir1, dir2 != GTK_TEXT_DIR_NONE); if (dir2 != GTK_TEXT_DIR_NONE) @@ -1467,17 +1486,23 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof cursor_location.width = 0; cursor_location.height = PANGO_PIXELS (cursor2->height); - gtk_draw_insertion_cursor (widget, gtk_widget_get_window (widget), - NULL, &cursor_location, - FALSE, dir1, TRUE); + gtk_draw_insertion_cursor (widget, +#if GTK_CHECK_VERSION(3,0,0) + cr, + &cursor_location, +#else + gtk_widget_get_window (widget), + NULL, &cursor_location, +#endif + FALSE, dir1, TRUE); } } else /* Block cursor */ { cairo_region_t *clip; - cairo_t *cr; - - cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#if !GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif cairo_set_source_rgb (cr, 0, 0, 0); cairo_rectangle (cr, @@ -1507,22 +1532,31 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof cairo_region_destroy (clip); } +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif } } } static gint +#if GTK_CHECK_VERSION(3,0,0) +eel_editable_label_draw (GtkWidget *widget, + cairo_t *cr) +#else eel_editable_label_expose (GtkWidget *widget, GdkEventExpose *event) +#endif { EelEditableLabel *label; GtkStyle *style; gint x, y; g_assert (EEL_IS_EDITABLE_LABEL (widget)); +#if !GTK_CHECK_VERSION(3,0,0) g_assert (event != NULL); +#endif label = EEL_EDITABLE_LABEL (widget); style = gtk_widget_get_style (widget); @@ -1535,10 +1569,16 @@ eel_editable_label_expose (GtkWidget *widget, get_layout_location (label, &x, &y); gtk_paint_layout (style, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else gtk_widget_get_window (widget), +#endif gtk_widget_get_state (widget), TRUE, +#if !GTK_CHECK_VERSION(3,0,0) &event->area, +#endif widget, "label", x, y, @@ -1550,14 +1590,13 @@ eel_editable_label_expose (GtkWidget *widget, const char *text; cairo_region_t *clip; GtkStateType state; - cairo_t *cr; range[0] = label->selection_anchor; range[1] = label->selection_end; /* Handle possible preedit string */ if (label->preedit_length > 0 && - range[1] > label->selection_anchor) + range[1] > label->selection_anchor) { text = pango_layout_get_text (label->layout) + label->selection_anchor; range[1] += g_utf8_offset_to_pointer (text, label->preedit_length) - text; @@ -1570,7 +1609,9 @@ eel_editable_label_expose (GtkWidget *widget, range[1] = tmp; } - cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#if !GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif clip = gdk_pango_layout_get_clip_region (label->layout, x, y, range, @@ -1589,19 +1630,26 @@ eel_editable_label_expose (GtkWidget *widget, cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, label->layout); +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif cairo_region_destroy (clip); } else if (gtk_widget_has_focus (widget)) +#if GTK_CHECK_VERSION(3,0,0) + eel_editable_label_draw_cursor (label, cr, x, y); +#else eel_editable_label_draw_cursor (label, x, y); +#endif if (label->draw_outline) { GtkAllocation allocation; - cairo_t *cr; gtk_widget_get_allocation (widget, &allocation); - cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#if !GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif gdk_cairo_set_source_color (cr, &style->text [gtk_widget_get_state (widget)]); cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, 0.5, 0.5, @@ -1609,7 +1657,9 @@ eel_editable_label_expose (GtkWidget *widget, allocation.height - 1); cairo_stroke (cr); +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif } } @@ -1637,7 +1687,9 @@ eel_editable_label_realize (GtkWidget *widget) attributes.width = allocation.width; attributes.height = allocation.height; attributes.visual = gtk_widget_get_visual (widget); +#if !GTK_CHECK_VERSION(3,0,0) attributes.colormap = gtk_widget_get_colormap (widget); +#endif attributes.cursor = gdk_cursor_new (GDK_XTERM); attributes.event_mask = gtk_widget_get_events (widget) | (GDK_EXPOSURE_MASK | @@ -1650,7 +1702,11 @@ eel_editable_label_realize (GtkWidget *widget) GDK_ENTER_NOTIFY_MASK | GDK_LEAVE_NOTIFY_MASK); +#if GTK_CHECK_VERSION(3,0,0) + attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_CURSOR; +#else attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP | GDK_WA_CURSOR; +#endif window = gdk_window_new (gtk_widget_get_parent_window (widget), &attributes, attributes_mask); -- cgit v1.2.1 From 2a4433a562b4a9fde5f81961c67fbee8810d63f0 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 00:05:37 +0200 Subject: [libcaja-private] Port to rendering-cleanup-next http://git.gnome.org/browse/nautilus/commit/?id=910191ea13e5647e1b8c793e7585530c6ae4c9b1 --- libcaja-private/caja-icon-canvas-item.c | 282 ++++++++++++++++++++++++----- libcaja-private/caja-icon-canvas-item.h | 8 +- libcaja-private/caja-icon-container.c | 16 +- libcaja-private/caja-icon-dnd.c | 56 +++++- libcaja-private/caja-tree-view-drag-dest.c | 44 +++-- 5 files changed, 325 insertions(+), 81 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index d6bba70b..e8b1762c 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -215,41 +215,57 @@ G_DEFINE_TYPE_WITH_CODE (CajaIconCanvasItem, caja_icon_canvas_item, EEL_TYPE_CAN /* private */ static void draw_label_text (CajaIconCanvasItem *item, - GdkDrawable *drawable, - gboolean create_mask, - EelIRect icon_rect); +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkDrawable *drawable, +#endif + gboolean create_mask, + EelIRect icon_rect); static void measure_label_text (CajaIconCanvasItem *item); static void get_icon_canvas_rectangle (CajaIconCanvasItem *item, - EelIRect *rect); -static void emblem_layout_reset (EmblemLayout *layout, - CajaIconCanvasItem *icon_item, - EelIRect icon_rect, - gboolean is_rtl); -static gboolean emblem_layout_next (EmblemLayout *layout, - GdkPixbuf **emblem_pixbuf, - EelIRect *emblem_rect, - gboolean is_rtl); -static void draw_pixbuf (GdkPixbuf *pixbuf, - GdkDrawable *drawable, - int x, - int y); -static PangoLayout *get_label_layout (PangoLayout **layout, - CajaIconCanvasItem *item, - const char *text); + EelIRect *rect); +static void emblem_layout_reset (EmblemLayout *layout, + CajaIconCanvasItem *icon_item, + EelIRect icon_rect, + gboolean is_rtl); +static gboolean emblem_layout_next (EmblemLayout *layout, + GdkPixbuf **emblem_pixbuf, + EelIRect *emblem_rect, + gboolean is_rtl); +static void draw_pixbuf (GdkPixbuf *pixbuf, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkDrawable *drawable, +#endif + int x, + int y); +static PangoLayout *get_label_layout (PangoLayout **layout, + CajaIconCanvasItem *item, + const char *text); static void draw_label_layout (CajaIconCanvasItem *item, - GdkDrawable *drawable, - PangoLayout *layout, - gboolean highlight, - GdkColor *label_color, - int x, - int y); +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkDrawable *drawable, +#endif + PangoLayout *layout, + gboolean highlight, + GdkColor *label_color, + int x, + int y); static gboolean hit_test_stretch_handle (CajaIconCanvasItem *item, - EelIRect canvas_rect, - GtkCornerType *corner); + EelIRect canvas_rect, + GtkCornerType *corner); static void draw_embedded_text (CajaIconCanvasItem *icon_item, - GdkDrawable *drawable, - int x, - int y); +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkDrawable *drawable, +#endif + int x, + int y); static void caja_icon_canvas_item_ensure_bounds_up_to_date (CajaIconCanvasItem *icon_item); @@ -538,12 +554,21 @@ caja_icon_canvas_item_get_property (GObject *object, } } +#if GTK_CHECK_VERSION(3,0,0) +cairo_surface_t * +caja_icon_canvas_item_get_drag_surface (CajaIconCanvasItem *item) +#else GdkPixmap * caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, GdkBitmap **mask, GdkColormap *colormap) +#endif { +#if GTK_CHECK_VERSION(3,0,0) + cairo_surface_t *surface; +#else GdkPixmap *pixmap; +#endif EelCanvas *canvas; GdkScreen *screen; int width, height; @@ -560,7 +585,11 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, g_return_val_if_fail (CAJA_IS_ICON_CANVAS_ITEM (item), NULL); canvas = EEL_CANVAS_ITEM (item)->canvas; +#if GTK_CHECK_VERSION(3,0,0) + screen = gtk_widget_get_screen (GTK_WIDGET (canvas)); +#else screen = gdk_colormap_get_screen (colormap); +#endif /* Assume we're updated so canvas item data is right */ @@ -577,10 +606,16 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, width = EEL_CANVAS_ITEM (item)->x2 - EEL_CANVAS_ITEM (item)->x1; height = EEL_CANVAS_ITEM (item)->y2 - EEL_CANVAS_ITEM (item)->y1; +#if GTK_CHECK_VERSION(3,0,0) + surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen), + CAIRO_CONTENT_COLOR_ALPHA, + width, height); +#else pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen), width, height, gdk_visual_get_depth (gdk_colormap_get_visual (colormap))); gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), colormap); +#endif pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, @@ -616,12 +651,23 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, } /* draw pixbuf to mask and pixmap */ +#if GTK_CHECK_VERSION(3,0,0) + cr = cairo_create (surface); +#else cr = gdk_cairo_create (pixmap); +#endif cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_paint (cr); + +#if GTK_CHECK_VERSION(3,0,0) + draw_embedded_text (item, cr, + item_offset_x, item_offset_y); + draw_label_text (item, cr, FALSE, icon_rect); +#endif cairo_destroy (cr); +#if !GTK_CHECK_VERSION(3,0,0) *mask = gdk_pixmap_new (gdk_screen_get_root_window (screen), width, height, 1); @@ -636,10 +682,15 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, draw_label_text (item, GDK_DRAWABLE (pixmap), FALSE, icon_rect); draw_label_text (item, GDK_DRAWABLE (*mask), TRUE, icon_rect); +#endif g_object_unref (pixbuf); +#if GTK_CHECK_VERSION(3,0,0) + return surface; +#else return pixmap; +#endif } void @@ -1016,7 +1067,11 @@ make_round_rect (cairo_t *cr, static void draw_frame (CajaIconCanvasItem *item, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else GdkDrawable *drawable, +#endif guint color, gboolean create_mask, int x, @@ -1025,12 +1080,14 @@ draw_frame (CajaIconCanvasItem *item, int height) { CajaIconContainer *container; - cairo_t *cr; container = CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas); - /* Get a cairo context */ - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); +#endif /* Set the rounded rect clip region. Magic rounding value taken * from old code. @@ -1054,8 +1111,11 @@ draw_frame (CajaIconCanvasItem *item, /* Paint into drawable now that we have set up the color and opacity */ cairo_fill (cr); - /* Clean up now that drawing is complete */ +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } /* Keep these for a bit while we work on performance of draw_or_measure_label_text. */ @@ -1363,7 +1423,11 @@ measure_label_text (CajaIconCanvasItem *item) static void draw_label_text (CajaIconCanvasItem *item, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else GdkDrawable *drawable, +#endif gboolean create_mask, EelIRect icon_rect) { @@ -1414,7 +1478,11 @@ draw_label_text (CajaIconCanvasItem *item, if (needs_highlight && !details->is_renaming) { draw_frame (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif gtk_widget_has_focus (GTK_WIDGET (container)) ? container->details->highlight_color_rgba : container->details->active_color_rgba, create_mask, is_rtl_label_beside ? text_rect.x0 + item->details->text_dx : text_rect.x0, @@ -1427,11 +1495,24 @@ draw_label_text (CajaIconCanvasItem *item, details->is_highlighted_as_keyboard_focus)) { /* clear the underlying icons, where the text or overlaps them. */ +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); + /* FIMXEchpe draw the background here? */ + cairo_set_source_rgb (cr, 1., 1., 1.); + cairo_rectangle (cr, + text_rect.x0, + text_rect.y0, + text_rect.x1 - text_rect.x0, + text_rect.y1 - text_rect.y0); + cairo_fill (cr); + cairo_restore (cr); +#else gdk_window_clear_area (gtk_layout_get_bin_window (&EEL_CANVAS (container)->layout), text_rect.x0, text_rect.y0, text_rect.x1 - text_rect.x0, text_rect.y1 - text_rect.y0); +#endif } if (container->details->label_position == CAJA_ICON_LABEL_POSITION_BESIDE) @@ -1457,7 +1538,11 @@ draw_label_text (CajaIconCanvasItem *item, if (!(prelight_label && item->details->is_prelit)) { draw_frame (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif container->details->normal_color_rgba, create_mask, text_rect.x0, @@ -1468,7 +1553,11 @@ draw_label_text (CajaIconCanvasItem *item, else { draw_frame (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif container->details->prelight_color_rgba, create_mask, text_rect.x0, @@ -1483,7 +1572,12 @@ draw_label_text (CajaIconCanvasItem *item, &label_color, TRUE, needs_highlight, prelight_label & item->details->is_prelit); - draw_label_layout (item, drawable, + draw_label_layout (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else + drawable, +#endif editable_layout, needs_highlight, label_color, x, @@ -1500,7 +1594,12 @@ draw_label_text (CajaIconCanvasItem *item, &label_color, FALSE, needs_highlight, FALSE); - draw_label_layout (item, drawable, + draw_label_layout (item, +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else + drawable, +#endif additional_layout, needs_highlight, label_color, x, @@ -1510,7 +1609,11 @@ draw_label_text (CajaIconCanvasItem *item, if (!create_mask && item->details->is_highlighted_as_keyboard_focus) { gtk_paint_focus (gtk_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas)), +#if GTK_CHECK_VERSION(3,0,0) + cr, +#else drawable, +#endif needs_highlight ? GTK_STATE_SELECTED : GTK_STATE_NORMAL, NULL, GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas), @@ -1592,14 +1695,18 @@ get_knob_pixbuf (void) } static void +#if GTK_CHECK_VERSION(3,0,0) +draw_stretch_handles (CajaIconCanvasItem *item, + cairo_t *cr, +#else draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, +#endif const EelIRect *rect) { GtkWidget *widget; GdkPixbuf *knob_pixbuf; int knob_width, knob_height; double dash = { 2.0 }; - cairo_t *cr; if (!item->details->show_stretch_handles) { @@ -1608,7 +1715,11 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, widget = GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas); - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); +#endif knob_pixbuf = get_knob_pixbuf (); knob_width = gdk_pixbuf_get_width (knob_pixbuf); knob_height = gdk_pixbuf_get_height (knob_pixbuf); @@ -1624,13 +1735,22 @@ draw_stretch_handles (CajaIconCanvasItem *item, GdkDrawable *drawable, rect->y1 - rect->y0 - 1); cairo_stroke (cr); - cairo_destroy (cr); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); /* draw the stretch handles themselves */ + draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y0); + draw_pixbuf (knob_pixbuf, cr, rect->x0, rect->y1 - knob_height); + draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y0); + draw_pixbuf (knob_pixbuf, cr, rect->x1 - knob_width, rect->y1 - knob_height); +#else + cairo_destroy (cr); + draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y0); draw_pixbuf (knob_pixbuf, drawable, rect->x0, rect->y1 - knob_height); draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y0); draw_pixbuf (knob_pixbuf, drawable, rect->x1 - knob_width, rect->y1 - knob_height); +#endif g_object_unref (knob_pixbuf); } @@ -1793,15 +1913,25 @@ emblem_layout_next (EmblemLayout *layout, } static void +#if GTK_CHECK_VERSION(3,0,0) +draw_pixbuf (GdkPixbuf *pixbuf, + cairo_t *cr, + int x, int y) +{ + cairo_save (cr); + gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); + cairo_paint (cr); + cairo_restore (cr); +} +#else draw_pixbuf (GdkPixbuf *pixbuf, GdkDrawable *drawable, int x, int y) { cairo_t *cr = gdk_cairo_create (drawable); - gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y); cairo_paint (cr); - cairo_destroy (cr); } +#endif /* shared code to highlight or dim the passed-in pixbuf */ static GdkPixbuf * @@ -1967,13 +2097,16 @@ map_pixbuf (CajaIconCanvasItem *icon_item) static void draw_embedded_text (CajaIconCanvasItem *item, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else GdkDrawable *drawable, +#endif int x, int y) { PangoLayout *layout; PangoContext *context; PangoFontDescription *desc; - cairo_t *cr; if (item->details->embedded_text == NULL || item->details->embedded_text_rect.width == 0 || @@ -2002,7 +2135,11 @@ draw_embedded_text (CajaIconCanvasItem *item, } } - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); +#endif cairo_rectangle (cr, x + item->details->embedded_text_rect.x, @@ -2017,13 +2154,23 @@ draw_embedded_text (CajaIconCanvasItem *item, y + item->details->embedded_text_rect.y); pango_cairo_show_layout (cr, layout); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } /* Draw the icon item for non-anti-aliased mode. */ static void +#if GTK_CHECK_VERSION(3,0,0) +caja_icon_canvas_item_draw (EelCanvasItem *item, + cairo_t *cr, + cairo_region_t *region) +#else caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkEventExpose *expose) +#endif { CajaIconCanvasItem *icon_item; CajaIconCanvasItemDetails *details; @@ -2032,7 +2179,6 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, GdkPixbuf *emblem_pixbuf, *temp_pixbuf; GdkRectangle pixbuf_rect; gboolean is_rtl; - cairo_t *cr; icon_item = CAJA_ICON_CANVAS_ITEM (item); details = icon_item->details; @@ -2053,16 +2199,28 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, pixbuf_rect.width = gdk_pixbuf_get_width (temp_pixbuf); pixbuf_rect.height = gdk_pixbuf_get_height (temp_pixbuf); - cr = gdk_cairo_create (drawable); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else + cairo_t *cr = gdk_cairo_create (drawable); gdk_cairo_rectangle (cr, &expose->area); cairo_clip (cr); +#endif gdk_cairo_set_source_pixbuf (cr, temp_pixbuf, pixbuf_rect.x, pixbuf_rect.y); gdk_cairo_rectangle (cr, &pixbuf_rect); cairo_fill (cr); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif g_object_unref (temp_pixbuf); +#if GTK_CHECK_VERSION(3,0,0) + draw_embedded_text (icon_item, cr, icon_rect.x0, icon_rect.y0); +#else draw_embedded_text (icon_item, drawable, icon_rect.x0, icon_rect.y0); +#endif is_rtl = caja_icon_container_is_layout_rtl (CAJA_ICON_CONTAINER (item->canvas)); @@ -2070,14 +2228,23 @@ caja_icon_canvas_item_draw (EelCanvasItem *item, GdkDrawable *drawable, emblem_layout_reset (&emblem_layout, icon_item, icon_rect, is_rtl); while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl)) { +#if GTK_CHECK_VERSION(3,0,0) + draw_pixbuf (emblem_pixbuf, cr, emblem_rect.x0, emblem_rect.y0); +#else draw_pixbuf (emblem_pixbuf, drawable, emblem_rect.x0, emblem_rect.y0); +#endif } +#if GTK_CHECK_VERSION(3,0,0) /* Draw stretching handles (if necessary). */ - draw_stretch_handles (icon_item, drawable, &icon_rect); + draw_stretch_handles (icon_item, cr, &icon_rect); /* Draw the label text. */ + draw_label_text (icon_item, cr, FALSE, icon_rect); +#else + draw_stretch_handles (icon_item, drawable, &icon_rect); draw_label_text (icon_item, drawable, FALSE, icon_rect); +#endif } #define ZERO_WIDTH_SPACE "\xE2\x80\x8B" @@ -2195,17 +2362,20 @@ get_label_layout (PangoLayout **layout_cache, static void draw_label_layout (CajaIconCanvasItem *item, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else GdkDrawable *drawable, +#endif PangoLayout *layout, gboolean highlight, GdkColor *label_color, int x, int y) { - if (drawable == NULL) - { - return; - } +#if !GTK_CHECK_VERSION(3,0,0) + g_return_if_fail (drawable != NULL); +#endif if (item->details->is_renaming) { @@ -2215,7 +2385,11 @@ draw_label_layout (CajaIconCanvasItem *item, if (!highlight && (CAJA_ICON_CONTAINER (EEL_CANVAS_ITEM (item)->canvas)->details->use_drop_shadows)) { /* draw a drop shadow */ +#if GTK_CHECK_VERSION(3,0,0) + eel_cairo_draw_layout_with_drop_shadow (cr, +#else eel_gdk_draw_layout_with_drop_shadow (drawable, +#endif label_color, >k_widget_get_style (GTK_WIDGET (EEL_CANVAS_ITEM (item)->canvas))->black, x, y, @@ -2223,12 +2397,20 @@ draw_label_layout (CajaIconCanvasItem *item, } else { +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else cairo_t *cr = gdk_cairo_create (drawable); +#endif gdk_cairo_set_source_color (cr, label_color); cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, layout); +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); +#endif } } diff --git a/libcaja-private/caja-icon-canvas-item.h b/libcaja-private/caja-icon-canvas-item.h index 27d01867..14b93b63 100644 --- a/libcaja-private/caja-icon-canvas-item.h +++ b/libcaja-private/caja-icon-canvas-item.h @@ -74,9 +74,13 @@ extern "C" { /* attributes */ void caja_icon_canvas_item_set_image (CajaIconCanvasItem *item, GdkPixbuf *image); +#if GTK_CHECK_VERSION(3,0,0) + cairo_surface_t* caja_icon_canvas_item_get_drag_surface (CajaIconCanvasItem *item); +#else GdkPixmap * caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, - GdkBitmap **mask, - GdkColormap *colormap); + GdkBitmap **mask, + GdkColormap *colormap); +#endif void caja_icon_canvas_item_set_emblems (CajaIconCanvasItem *item, GList *emblem_pixbufs); void caja_icon_canvas_item_set_show_stretch_handles (CajaIconCanvasItem *item, diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 1ae2cb2a..f3e1ccf8 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -5246,7 +5246,7 @@ caja_icon_container_search_position_func (CajaIconContainer *container, cont_window = gtk_widget_get_window (GTK_WIDGET (container)); - screen = gdk_drawable_get_screen (cont_window); + screen = gdk_window_get_screen (cont_window); monitor_num = gdk_screen_get_monitor_at_window (screen, cont_window); gdk_screen_get_monitor_geometry (screen, monitor_num, &monitor); @@ -5256,10 +5256,10 @@ caja_icon_container_search_position_func (CajaIconContainer *container, gdk_window_get_origin (cont_window, &cont_x, &cont_y); #if GTK_CHECK_VERSION(3, 0, 0) - cont_width = gdk_window_get_width(GDK_WINDOW(cont_window)); - cont_height = gdk_window_get_height(GDK_WINDOW(cont_window)); + cont_width = gdk_window_get_width (cont_window); + cont_height = gdk_window_get_height (cont_window); #else - gdk_drawable_get_size(cont_window, &cont_width, &cont_height); + gdk_drawable_get_size (cont_window, &cont_width, &cont_height); #endif gtk_widget_size_request (search_dialog, &requisition); @@ -6110,12 +6110,17 @@ popup_menu (GtkWidget *widget) static void draw_canvas_background (EelCanvas *canvas, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr) +#else int x, int y, int width, int height) +#endif { /* Don't chain up to the parent to avoid clearing and redrawing */ } +#if !GTK_CHECK_VERSION(3,0,0) static gboolean expose_event (GtkWidget *widget, GdkEventExpose *event) @@ -6127,6 +6132,7 @@ expose_event (GtkWidget *widget, return GTK_WIDGET_CLASS (caja_icon_container_parent_class)->expose_event (widget, event); } +#endif static AtkObject * get_accessible (GtkWidget *widget) @@ -6585,7 +6591,9 @@ caja_icon_container_class_init (CajaIconContainerClass *class) widget_class->popup_menu = popup_menu; widget_class->get_accessible = get_accessible; widget_class->style_set = style_set; +#if !GTK_CHECK_VERSION(3,0,0) widget_class->expose_event = expose_event; +#endif widget_class->grab_notify = grab_notify_cb; canvas_class = EEL_CANVAS_CLASS (class); diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 470a767e..67e0dd32 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -1495,18 +1495,23 @@ drag_begin_callback (GtkWidget *widget, GdkDragContext *context, gpointer data) { +#if GTK_CHECK_VERSION(3,0,0) + cairo_surface_t *surface; +#else CajaIconContainer *container; GdkScreen *screen; GdkColormap *colormap; GdkPixmap *pixmap; GdkBitmap *mask; + gboolean use_mask; +#endif double x1, y1, x2, y2, winx, winy; int x_offset, y_offset; int start_x, start_y; - gboolean use_mask; container = CAJA_ICON_CONTAINER (widget); +#if !GTK_CHECK_VERSION(3,0,0) screen = gtk_widget_get_screen (widget); colormap = NULL; if (gdk_screen_is_composited (screen)) @@ -1524,12 +1529,17 @@ drag_begin_callback (GtkWidget *widget, colormap = gtk_widget_get_colormap (widget); use_mask = TRUE; } +#endif start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); /* create a pixmap and mask to drag with */ +#if GTK_CHECK_VERSION(3,0,0) + surface = caja_icon_canvas_item_get_drag_surface (container->details->drag_icon->item); +#else pixmap = caja_icon_canvas_item_get_image (container->details->drag_icon->item, &mask, colormap); +#endif /* we want to drag semi-transparent pixbufs, but X is too slow dealing with stippled masks, so we had to remove the code; this comment is left as a memorial @@ -1543,6 +1553,11 @@ drag_begin_callback (GtkWidget *widget, x_offset = start_x - winx; y_offset = start_y - winy; +#if GTK_CHECK_VERSION(3,0,0) + cairo_surface_set_device_offset (surface, x_offset, y_offset); + gtk_drag_set_icon_surface (context, surface); + cairo_surface_destroy (surface); +#else if (!use_mask && pixmap != NULL) { cairo_t *cr; @@ -1559,6 +1574,7 @@ drag_begin_callback (GtkWidget *widget, colormap, pixmap, (use_mask ? mask : NULL), x_offset, y_offset); +#endif } void @@ -1593,37 +1609,50 @@ caja_icon_dnd_begin_drag (CajaIconContainer *container, } static gboolean +#if GTK_CHECK_VERSION(3,0,0) +drag_highlight_draw (GtkWidget *widget, + cairo_t *cr, + gpointer user_data) +#else drag_highlight_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) +#endif { gint x, y, width, height; GdkWindow *window; - cairo_t *cr; x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget))); y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget))); + window = gtk_widget_get_window (widget); #if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(GDK_WINDOW(gtk_widget_get_window(widget))); - height = gdk_window_get_height(GDK_WINDOW(gtk_widget_get_window(widget))); -#else - gdk_drawable_get_size(gtk_widget_get_window(widget), &width, &height); -#endif + width = gdk_window_get_width (window); + height = gdk_window_get_height (window); - window = gtk_layout_get_bin_window (GTK_LAYOUT (widget)); + gtk_paint_shadow (gtk_widget_get_style (widget), + cr, + GTK_STATE_NORMAL, GTK_SHADOW_OUT, + widget, "dnd", + x, y, width, height); +#else + gdk_drawable_get_size(window, &width, &height); gtk_paint_shadow (gtk_widget_get_style (widget), window, GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, widget, "dnd", x, y, width, height); - cr = gdk_cairo_create (window); + cairo_t *cr = gdk_cairo_create (window); +#endif + cairo_set_line_width (cr, 1.0); cairo_set_source_rgb (cr, 0, 0, 0); cairo_rectangle (cr, x + 0.5, y + 0.5, width - 1, height - 1); cairo_stroke (cr); +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif return FALSE; } @@ -1682,8 +1711,13 @@ start_dnd_highlight (GtkWidget *widget) if (!dnd_info->highlighted) { dnd_info->highlighted = TRUE; +#if GTK_CHECK_VERSION(3,0,0) + g_signal_connect_after (widget, "draw", + G_CALLBACK (drag_highlight_draw), +#else g_signal_connect_after (widget, "expose_event", G_CALLBACK (drag_highlight_expose), +#endif NULL); dnd_highlight_queue_redraw (widget); } @@ -1699,7 +1733,11 @@ stop_dnd_highlight (GtkWidget *widget) if (dnd_info->highlighted) { g_signal_handlers_disconnect_by_func (widget, +#if GTK_CHECK_VERSION(3,0,0) + drag_highlight_draw, +#else drag_highlight_expose, +#endif NULL); dnd_highlight_queue_redraw (widget); dnd_info->highlighted = FALSE; diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c index 1c25c452..d7a8d2b6 100644 --- a/libcaja-private/caja-tree-view-drag-dest.c +++ b/libcaja-private/caja-tree-view-drag-dest.c @@ -186,35 +186,42 @@ remove_expand_timeout (CajaTreeViewDragDest *dest) } static gboolean +#if GTK_CHECK_VERSION(3,0,0) +highlight_draw (GtkWidget *widget, + cairo_t *cr, + gpointer data) +#else highlight_expose (GtkWidget *widget, GdkEventExpose *event, gpointer data) +#endif { GdkWindow *bin_window; int width; int height; - if (gtk_widget_is_drawable (widget)) - { - bin_window = - gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); + /* FIXMEchpe: is bin window right here??? */ + bin_window = gtk_tree_view_get_bin_window (GTK_TREE_VIEW (widget)); #if GTK_CHECK_VERSION(3, 0, 0) - width = gdk_window_get_width(GDK_WINDOW(bin_window)); - height = gdk_window_get_height(GDK_WINDOW(bin_window)); + width = gdk_window_get_width(bin_window); + height = gdk_window_get_height(bin_window); #else - gdk_drawable_get_size(bin_window, &width, &height); + gdk_drawable_get_size(bin_window, &width, &height); #endif - - gtk_paint_focus (gtk_widget_get_style (widget), - bin_window, - gtk_widget_get_state (widget), - NULL, - widget, - "treeview-drop-indicator", - 0, 0, width, height); - } + gtk_paint_focus (gtk_widget_get_style (widget), +#if GTK_CHECK_VERSION(3,0,0) + cr, + gtk_widget_get_state (widget), +#else + bin_window, + gtk_widget_get_state (widget), + NULL, +#endif + widget, + "treeview-drop-indicator", + 0, 0, width, height); return FALSE; } @@ -234,8 +241,13 @@ set_widget_highlight (CajaTreeViewDragDest *dest, gboolean highlight) { dest->details->highlight_id = g_signal_connect_object (dest->details->tree_view, +#if GTK_CHECK_VERSION(3,0,0) + "draw", + G_CALLBACK (highlight_draw), +#else "expose_event", G_CALLBACK (highlight_expose), +#endif dest, 0); gtk_widget_queue_draw (GTK_WIDGET (dest->details->tree_view)); } -- cgit v1.2.1 From e5b2fbf43e1c1ad5552abb004e5ebc4beb17ce2c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 00:14:30 +0200 Subject: [icon-container] use gtk_widget_get_preferred_size() http://git.gnome.org/browse/nautilus/commit/?id=e56241830bfd2ca470ec2b1da53313c2230bc2b9 --- libcaja-private/caja-icon-container.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index f3e1ccf8..583b6c85 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -5258,11 +5258,13 @@ caja_icon_container_search_position_func (CajaIconContainer *container, #if GTK_CHECK_VERSION(3, 0, 0) cont_width = gdk_window_get_width (cont_window); cont_height = gdk_window_get_height (cont_window); + + gtk_widget_get_preferred_size (search_dialog, &requisition, NULL); #else gdk_drawable_get_size (cont_window, &cont_width, &cont_height); -#endif gtk_widget_size_request (search_dialog, &requisition); +#endif if (cont_x + cont_width - requisition.width > gdk_screen_get_width (screen)) { -- cgit v1.2.1 From 48d2f19ea2b821d1f3b3017afc912154ab2ee7da Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 01:03:47 +0200 Subject: [src] use gtk_widget_get_preferred_size() http://git.gnome.org/browse/nautilus/commit/?id=c47d18f566fa9518ca7750922da7da66d3211f3e --- src/caja-pathbar.c | 27 ++++++++++++++++++--------- src/caja-side-pane.c | 8 ++++++-- src/caja-spatial-window.c | 8 ++++++-- src/caja-zoom-control.c | 8 ++++++-- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index b5504fc9..6a582014 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -39,6 +39,10 @@ #include "caja-window-private.h" #include "caja-window-slot.h" +#if !GTK_CHECK_VERSION(3,0,0) +#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) +#endif + enum { PATH_CLICKED, @@ -493,7 +497,8 @@ caja_path_bar_size_request (GtkWidget *widget, for (list = path_bar->button_list; list; list = list->next) { button_data = BUTTON_DATA (list->data); - gtk_widget_size_request (button_data->button, &child_requisition); + gtk_widget_get_preferred_size (button_data->button, + &child_requisition, NULL); requisition->width = MAX (child_requisition.width, requisition->width); requisition->height = MAX (child_requisition.height, requisition->height); } @@ -508,8 +513,10 @@ caja_path_bar_size_request (GtkWidget *widget, requisition->width += (path_bar->spacing + path_bar->slider_width) * 2; } - gtk_widget_size_request (path_bar->up_slider_button, &child_requisition); - gtk_widget_size_request (path_bar->down_slider_button, &child_requisition); + gtk_widget_get_preferred_size (path_bar->up_slider_button, + &child_requisition, NULL); + gtk_widget_get_preferred_size (path_bar->down_slider_button, + &child_requisition, NULL); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); requisition->width += border_width * 2; @@ -601,13 +608,14 @@ caja_path_bar_size_allocate (GtkWidget *widget, width = 0; } - gtk_widget_get_child_requisition (BUTTON_DATA (path_bar->button_list->data)->button, &child_requisition); + gtk_widget_get_preferred_size (BUTTON_DATA (path_bar->button_list->data)->button, + &child_requisition, NULL); width += child_requisition.width; for (list = path_bar->button_list->next; list; list = list->next) { child = BUTTON_DATA (list->data)->button; - gtk_widget_get_child_requisition (child, &child_requisition); + gtk_widget_get_preferred_size (child, &child_requisition, NULL); width += child_requisition.width + path_bar->spacing; if (list == path_bar->fake_root) @@ -649,13 +657,14 @@ caja_path_bar_size_allocate (GtkWidget *widget, * button, then count backwards. */ /* Count down the path chain towards the end. */ - gtk_widget_get_child_requisition (BUTTON_DATA (first_button->data)->button, &child_requisition); + gtk_widget_get_preferred_size (BUTTON_DATA (first_button->data)->button, + &child_requisition, NULL); width = child_requisition.width; list = first_button->prev; while (list && !reached_end) { child = BUTTON_DATA (list->data)->button; - gtk_widget_get_child_requisition (child, &child_requisition); + gtk_widget_get_preferred_size (child, &child_requisition, NULL); if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width) { @@ -681,7 +690,7 @@ caja_path_bar_size_allocate (GtkWidget *widget, while (first_button->next && ! reached_end) { child = BUTTON_DATA (first_button->next->data)->button; - gtk_widget_get_child_requisition (child, &child_requisition); + gtk_widget_get_preferred_size (child, &child_requisition, NULL); if (width + child_requisition.width + path_bar->spacing + slider_space > allocation_width) { @@ -725,7 +734,7 @@ caja_path_bar_size_allocate (GtkWidget *widget, for (list = first_button; list; list = list->prev) { child = BUTTON_DATA (list->data)->button; - gtk_widget_get_child_requisition (child, &child_requisition); + gtk_widget_get_preferred_size (child, &child_requisition, NULL); gtk_widget_get_allocation (widget, &widget_allocation); diff --git a/src/caja-side-pane.c b/src/caja-side-pane.c index a5d6544e..d3922b9f 100644 --- a/src/caja-side-pane.c +++ b/src/caja-side-pane.c @@ -30,6 +30,10 @@ #include #include +#if !GTK_CHECK_VERSION(3,0,0) +#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) +#endif + typedef struct { char *title; @@ -146,7 +150,7 @@ caja_side_pane_size_allocate (GtkWidget *widget, frame = pane->details->title_frame; hbox = pane->details->title_hbox; - gtk_widget_get_child_requisition (hbox, &child_requisition); + gtk_widget_get_preferred_size (hbox, &child_requisition, NULL); width = child_requisition.width; gtk_widget_get_allocation (frame, &frame_allocation); @@ -249,7 +253,7 @@ select_button_press_callback (GtkWidget *widget, gtk_widget_get_allocation (widget, &allocation); width = allocation.width; gtk_widget_set_size_request (side_pane->details->menu, -1, -1); - gtk_widget_size_request (side_pane->details->menu, &requisition); + gtk_widget_get_preferred_size (side_pane->details->menu, &requisition, NULL); gtk_widget_set_size_request (side_pane->details->menu, MAX (width, requisition.width), -1); diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 161a3038..524fbb9b 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -64,6 +64,10 @@ #include #include +#if !GTK_CHECK_VERSION(3,0,0) +#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) +#endif + #define MAX_TITLE_LENGTH 180 #define MAX_SHORTNAME_PATH 16 @@ -632,8 +636,8 @@ menu_popup_pos (GtkMenu *menu, widget = user_data; - gtk_widget_size_request (GTK_WIDGET (menu), &menu_requisition); - gtk_widget_size_request (widget, &button_requisition); + gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_requisition, NULL); + gtk_widget_get_preferred_size (widget, &button_requisition, NULL); gtk_widget_get_allocation (widget, &allocation); gdk_window_get_origin (gtk_widget_get_window (widget), x, y); diff --git a/src/caja-zoom-control.c b/src/caja-zoom-control.c index 685242dc..1b251da2 100644 --- a/src/caja-zoom-control.c +++ b/src/caja-zoom-control.c @@ -44,6 +44,10 @@ #include #include +#if !GTK_CHECK_VERSION(3,0,0) +#define gtk_widget_get_preferred_size(x,y,z) gtk_widget_size_request(x,y) +#endif + enum { ZOOM_IN, @@ -153,8 +157,8 @@ menu_position_under_widget (GtkMenu *menu, container = gtk_widget_get_ancestor (widget, GTK_TYPE_CONTAINER); g_assert (container != NULL); - gtk_widget_size_request (widget, &req); - gtk_widget_size_request (GTK_WIDGET (menu), &menu_req); + gtk_widget_get_preferred_size (GTK_WIDGET (menu), &menu_req, NULL); + gtk_widget_get_preferred_size (widget, &req, NULL); gtk_widget_get_allocation (widget, &allocation); screen = gtk_widget_get_screen (GTK_WIDGET (menu)); -- cgit v1.2.1 From eb4866501e0ab9114c3ea459d3d4aa437194d961 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 31 Oct 2012 08:58:28 +0200 Subject: [desktop-icon-view] don't use gdk_drawable_get_screen() http://git.gnome.org/browse/nautilus/commit/?id=b1aac113ef867846fb39ee4187378c6f1a13f33e --- src/file-manager/fm-desktop-icon-view.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 005bc198..232b198a 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -217,7 +217,7 @@ net_workarea_changed (FMDesktopIconView *icon_view, } else { - screen = gdk_drawable_get_screen (GDK_DRAWABLE (window)); + screen = gdk_window_get_screen (window); icon_container_set_workarea ( icon_container, screen, workareas, length_returned / sizeof (long)); -- cgit v1.2.1 From f4babe394d101d2053b3358fcb6bfb489b1e2d58 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 02:15:15 +0200 Subject: [icon-canvas-item] set transparent background for highlight http://git.gnome.org/browse/nautilus/commit/?id=c6860491c432e311d585a6d92443ef821afd46d2 --- libcaja-private/caja-icon-canvas-item.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index e8b1762c..eb6f4ffd 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -1497,8 +1497,7 @@ draw_label_text (CajaIconCanvasItem *item, /* clear the underlying icons, where the text or overlaps them. */ #if GTK_CHECK_VERSION(3,0,0) cairo_save (cr); - /* FIMXEchpe draw the background here? */ - cairo_set_source_rgb (cr, 1., 1., 1.); + cairo_set_source_rgba (cr, 0, 0, 0, 0); cairo_rectangle (cr, text_rect.x0, text_rect.y0, -- cgit v1.2.1 From b6b774806a7198d46edd701054cc73989dc3e200 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 02:51:02 +0200 Subject: [icon-canvas-item] use cairo directly instead of gdk_pixbuf_composite() http://git.gnome.org/browse/nautilus/commit/?id=a136af0a01c160cdfb513c531b910b49a4a62973 --- libcaja-private/caja-icon-canvas-item.c | 45 ++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index eb6f4ffd..9f6992cf 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -568,6 +568,7 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, cairo_surface_t *surface; #else GdkPixmap *pixmap; + GdkPixbuf *pixbuf; #endif EelCanvas *canvas; GdkScreen *screen; @@ -575,7 +576,6 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, int item_offset_x, item_offset_y; EelIRect icon_rect; EelIRect emblem_rect; - GdkPixbuf *pixbuf; GdkPixbuf *emblem_pixbuf; EmblemLayout emblem_layout; double item_x, item_y; @@ -610,12 +610,19 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, surface = gdk_window_create_similar_surface (gdk_screen_get_root_window (screen), CAIRO_CONTENT_COLOR_ALPHA, width, height); + + cr = cairo_create (surface); + gdk_cairo_set_source_pixbuf (cr, item->details->pixbuf, + item_offset_x, item_offset_y); + cairo_rectangle (cr, item_offset_x, item_offset_y, + gdk_pixbuf_get_width (item->details->pixbuf), + gdk_pixbuf_get_height (item->details->pixbuf)); + cairo_fill (cr); #else pixmap = gdk_pixmap_new (gdk_screen_get_root_window (screen), width, height, gdk_visual_get_depth (gdk_colormap_get_visual (colormap))); gdk_drawable_set_colormap (GDK_DRAWABLE (pixmap), colormap); -#endif pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, @@ -629,16 +636,33 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, gdk_pixbuf_get_height (item->details->pixbuf), item_offset_x, item_offset_y, 1.0, 1.0, GDK_INTERP_BILINEAR, 255); +#endif icon_rect.x0 = item_offset_x; icon_rect.y0 = item_offset_y; icon_rect.x1 = item_offset_x + gdk_pixbuf_get_width (item->details->pixbuf); icon_rect.y1 = item_offset_y + gdk_pixbuf_get_height (item->details->pixbuf); - is_rtl = caja_icon_container_is_layout_rtl (CAJA_ICON_CONTAINER (canvas)); emblem_layout_reset (&emblem_layout, item, icon_rect, is_rtl); +#if GTK_CHECK_VERSION(3,0,0) + while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl)) + { + gdk_cairo_set_source_pixbuf (cr, emblem_pixbuf, emblem_rect.x0, emblem_rect.y0); + cairo_rectangle (cr, emblem_rect.x0, emblem_rect.y0, + gdk_pixbuf_get_width (emblem_pixbuf), + gdk_pixbuf_get_height (emblem_pixbuf)); + cairo_fill (cr); + } + + draw_embedded_text (item, cr, + item_offset_x, item_offset_y); + draw_label_text (item, cr, FALSE, icon_rect); + cairo_destroy (cr); + + return surface; +#else while (emblem_layout_next (&emblem_layout, &emblem_pixbuf, &emblem_rect, is_rtl)) { gdk_pixbuf_composite (emblem_pixbuf, pixbuf, @@ -651,23 +675,12 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, } /* draw pixbuf to mask and pixmap */ -#if GTK_CHECK_VERSION(3,0,0) - cr = cairo_create (surface); -#else cr = gdk_cairo_create (pixmap); -#endif cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE); gdk_cairo_set_source_pixbuf (cr, pixbuf, 0, 0); cairo_paint (cr); - -#if GTK_CHECK_VERSION(3,0,0) - draw_embedded_text (item, cr, - item_offset_x, item_offset_y); - draw_label_text (item, cr, FALSE, icon_rect); -#endif cairo_destroy (cr); -#if !GTK_CHECK_VERSION(3,0,0) *mask = gdk_pixmap_new (gdk_screen_get_root_window (screen), width, height, 1); @@ -682,13 +695,9 @@ caja_icon_canvas_item_get_image (CajaIconCanvasItem *item, draw_label_text (item, GDK_DRAWABLE (pixmap), FALSE, icon_rect); draw_label_text (item, GDK_DRAWABLE (*mask), TRUE, icon_rect); -#endif g_object_unref (pixbuf); -#if GTK_CHECK_VERSION(3,0,0) - return surface; -#else return pixmap; #endif } -- cgit v1.2.1 From 07bbb722c57b1f985a8750db9776099f1fadf7f6 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 02:53:55 +0200 Subject: [icon-dnd] use negative device offsets to set the drag surface http://git.gnome.org/browse/nautilus/commit/?id=f38bad2536faf497fe56c9a491ab852cb00514c0 --- libcaja-private/caja-icon-dnd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 67e0dd32..308715fa 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -1554,7 +1554,7 @@ drag_begin_callback (GtkWidget *widget, y_offset = start_y - winy; #if GTK_CHECK_VERSION(3,0,0) - cairo_surface_set_device_offset (surface, x_offset, y_offset); + cairo_surface_set_device_offset (surface, -x_offset, -y_offset); gtk_drag_set_icon_surface (context, surface); cairo_surface_destroy (surface); #else -- cgit v1.2.1 From b1cb355a3a65d11101d55846803cbf0296e22da5 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 02:57:24 +0200 Subject: [icon-dnd] cleanup useless comment removing old comment, keeping old pixmap/mask code around for GTK2 was: icon-dnd: cleanup useless code http://git.gnome.org/browse/nautilus/commit/?id=098057414b38aeeddd3fcd81942324336628d341 --- libcaja-private/caja-icon-dnd.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 308715fa..5aa48669 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -1541,10 +1541,6 @@ drag_begin_callback (GtkWidget *widget, pixmap = caja_icon_canvas_item_get_image (container->details->drag_icon->item, &mask, colormap); #endif - /* we want to drag semi-transparent pixbufs, but X is too slow dealing with - stippled masks, so we had to remove the code; this comment is left as a memorial - to it, with the hope that we get it back someday as X Windows improves */ - /* compute the image's offset */ eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (container->details->drag_icon->item), &x1, &y1, &x2, &y2); -- cgit v1.2.1 From 9dc0c0cf31bbd72f0545ae79e724f2c98e38f43f Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 17:02:32 +0200 Subject: [window-toolbars] show/hide the spinner when changing its state http://git.gnome.org/browse/nautilus/commit/?id=d72087b74c871ef82b1f6a13bb5bb72b38670a52 Including followup commit: window-toolbars: show/hide the spinner in the right order Apparently calling them in the wrong order makes new GTK+ crash. http://git.gnome.org/browse/nautilus/commit/?id=61906b05ec90d5d4759ae7ff7fc7aca40fb18f15 --- src/caja-window-toolbars.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/caja-window-toolbars.c b/src/caja-window-toolbars.c index d777ab41..1d6a22fb 100644 --- a/src/caja-window-toolbars.c +++ b/src/caja-window-toolbars.c @@ -59,19 +59,16 @@ caja_navigation_window_set_spinner_active (CajaNavigationWindow *window, gboolean allow) { if (( window->details->spinner_active && allow) || - (!window->details->spinner_active && !allow)) - { + (!window->details->spinner_active && !allow)) { return; } window->details->spinner_active = allow; - if (allow) - { + if (allow) { + gtk_widget_show (window->details->spinner); gtk_spinner_start (GTK_SPINNER (window->details->spinner)); - } - else - { - gtk_spinner_stop (GTK_SPINNER (window->details->spinner)); + } else { + gtk_widget_hide (window->details->spinner); } } -- cgit v1.2.1 From 452e4c3b65141bc819d3f7de2d6522d166de65b0 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 03:17:41 +0200 Subject: [properties-window] don't use expose-event to draw the pie chart Use GtkWidget::draw instead http://git.gnome.org/browse/nautilus/commit/?id=5ece5d67163e30a91e600d2f2bcf0d657d365dc4 --- src/file-manager/fm-properties-window.c | 62 ++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 12 deletions(-) diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 19eea640..711fcdb8 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -2743,10 +2743,15 @@ should_show_volume_usage (FMPropertiesWindow *window) } static void -paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data) +paint_used_legend (GtkWidget *widget, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkEventExpose *eev, +#endif + gpointer data) { FMPropertiesWindow *window; - cairo_t *cr; gint width, height; GtkAllocation allocation; @@ -2757,7 +2762,9 @@ paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data) window = FM_PROPERTIES_WINDOW (data); - cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#if !GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif cairo_rectangle (cr, 2, @@ -2771,14 +2778,20 @@ paint_used_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data) cairo_set_source_rgb (cr, (double) window->details->used_stroke_color.red / 65535, (double) window->details->used_stroke_color.green / 65535, (double) window->details->used_stroke_color.blue / 65535); cairo_stroke (cr); +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif } static void -paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data) +paint_free_legend (GtkWidget *widget, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, gpointer data) +#else + GdkEventExpose *eev, gpointer data) +#endif { FMPropertiesWindow *window; - cairo_t *cr; gint width, height; GtkAllocation allocation; @@ -2787,7 +2800,9 @@ paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data) width = allocation.width; height = allocation.height; - cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#if !GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif cairo_rectangle (cr, 2, @@ -2801,15 +2816,22 @@ paint_free_legend (GtkWidget *widget, GdkEventExpose *eev, gpointer data) cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535); cairo_stroke (cr); +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif } static void -paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data) +paint_pie_chart (GtkWidget *widget, +#if GTK_CHECK_VERSION(3,0,0) + cairo_t *cr, +#else + GdkEventExpose *eev, +#endif + gpointer data) { FMPropertiesWindow *window; - cairo_t *cr; gint width, height; double free, used; double angle1, angle2, split, xc, yc, radius; @@ -2831,7 +2853,9 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data) xc = width / 2; yc = height / 2; - cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#if !GTK_CHECK_VERSION(3,0,0) + cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); +#endif if (width < height) { radius = width / 2 - 8; @@ -2883,7 +2907,9 @@ paint_pie_chart (GtkWidget *widget, GdkEventExpose *eev, gpointer data) cairo_stroke (cr); } +#if !GTK_CHECK_VERSION(3,0,0) cairo_destroy (cr); +#endif } @@ -3172,9 +3198,21 @@ create_pie_widget (FMPropertiesWindow *window) gtk_table_attach (table, capacity_label , 1, 3, 2, 3, GTK_FILL, 0, 5, 5); gtk_table_attach (table, fstype_label , 1, 3, 3, 4, GTK_FILL, 0, 5, 5); - g_signal_connect (G_OBJECT (pie_canvas), "expose-event", G_CALLBACK (paint_pie_chart), window); - g_signal_connect (G_OBJECT (used_canvas), "expose-event", G_CALLBACK (paint_used_legend), window); - g_signal_connect (G_OBJECT (free_canvas), "expose-event", G_CALLBACK (paint_free_legend), window); +#if GTK_CHECK_VERSION(3,0,0) + g_signal_connect (pie_canvas, "draw", + G_CALLBACK (paint_pie_chart), window); + g_signal_connect (used_canvas, "draw", + G_CALLBACK (paint_used_legend), window); + g_signal_connect (free_canvas, "draw", + G_CALLBACK (paint_free_legend), window); +#else + g_signal_connect (G_OBJECT (pie_canvas), "expose-event", + G_CALLBACK (paint_pie_chart), window); + g_signal_connect (G_OBJECT (used_canvas), "expose-event", + G_CALLBACK (paint_used_legend), window); + g_signal_connect (G_OBJECT (free_canvas), "expose-event", + G_CALLBACK (paint_free_legend), window); +#endif return GTK_WIDGET (table); } -- cgit v1.2.1 From 61cb94240f5844596fa0e061af83646355d3484b Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 03:23:01 +0200 Subject: [properties-window] split some long lines http://git.gnome.org/browse/nautilus/commit/?id=64819695a13eb636df535e08e0eed6e896a8821c --- src/file-manager/fm-properties-window.c | 40 ++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index 711fcdb8..b79436af 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -2772,10 +2772,16 @@ paint_used_legend (GtkWidget *widget, width - 4, height - 4); - cairo_set_source_rgb (cr, (double) window->details->used_color.red / 65535, (double) window->details->used_color.green / 65535, (double) window->details->used_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->used_color.red / 65535, + (double) window->details->used_color.green / 65535, + (double) window->details->used_color.blue / 65535); cairo_fill_preserve (cr); - cairo_set_source_rgb (cr, (double) window->details->used_stroke_color.red / 65535, (double) window->details->used_stroke_color.green / 65535, (double) window->details->used_stroke_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->used_stroke_color.red / 65535, + (double) window->details->used_stroke_color.green / 65535, + (double) window->details->used_stroke_color.blue / 65535); cairo_stroke (cr); #if !GTK_CHECK_VERSION(3,0,0) @@ -2810,10 +2816,16 @@ paint_free_legend (GtkWidget *widget, width - 4, height - 4); - cairo_set_source_rgb (cr, (double) window->details->free_color.red / 65535, (double) window->details->free_color.green / 65535, (double) window->details->free_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->free_color.red / 65535, + (double) window->details->free_color.green / 65535, + (double) window->details->free_color.blue / 65535); cairo_fill_preserve(cr); - cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->free_stroke_color.red / 65535, + (double) window->details->free_stroke_color.green / 65535, + (double) window->details->free_stroke_color.blue / 65535); cairo_stroke (cr); #if !GTK_CHECK_VERSION(3,0,0) @@ -2882,10 +2894,16 @@ paint_pie_chart (GtkWidget *widget, cairo_line_to (cr,xc,yc); } - cairo_set_source_rgb (cr, (double) window->details->used_color.red / 65535, (double) window->details->used_color.green / 65535, (double) window->details->used_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->used_color.red / 65535, + (double) window->details->used_color.green / 65535, + (double) window->details->used_color.blue / 65535); cairo_fill_preserve (cr); - cairo_set_source_rgb (cr, (double) window->details->used_stroke_color.red / 65535, (double) window->details->used_stroke_color.green / 65535, (double) window->details->used_stroke_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->used_stroke_color.red / 65535, + (double) window->details->used_stroke_color.green / 65535, + (double) window->details->used_stroke_color.blue / 65535); cairo_stroke (cr); } @@ -2900,10 +2918,16 @@ paint_pie_chart (GtkWidget *widget, cairo_line_to (cr,xc,yc); } - cairo_set_source_rgb (cr, (double) window->details->free_color.red / 65535, (double) window->details->free_color.green / 65535,(double) window->details->free_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->free_color.red / 65535, + (double) window->details->free_color.green / 65535, + (double) window->details->free_color.blue / 65535); cairo_fill_preserve(cr); - cairo_set_source_rgb (cr, (double) window->details->free_stroke_color.red / 65535, (double) window->details->free_stroke_color.green / 65535, (double) window->details->free_stroke_color.blue / 65535); + cairo_set_source_rgb (cr, + (double) window->details->free_stroke_color.red / 65535, + (double) window->details->free_stroke_color.green / 65535, + (double) window->details->free_stroke_color.blue / 65535); cairo_stroke (cr); } -- cgit v1.2.1 From 4d27e091b87bc08fee257fda6cb3f928c3aee39f Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 17:30:19 +0200 Subject: [build] fix distcheck http://git.gnome.org/browse/nautilus/commit/?id=74a0311e65f2c9fc2d03967b0607633dcb652f88 --- eel/Makefile.am | 1 + src/Makefile.am | 1 + 2 files changed, 2 insertions(+) diff --git a/eel/Makefile.am b/eel/Makefile.am index 4883a6f2..831ab7d5 100644 --- a/eel/Makefile.am +++ b/eel/Makefile.am @@ -128,5 +128,6 @@ EXTRA_DIST = \ $(NULL) CLEANFILES = \ + eel-marshal.list \ $(BUILT_SOURCES) \ $(NULL) diff --git a/src/Makefile.am b/src/Makefile.am index b9ec8b87..c5b60ede 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -208,6 +208,7 @@ ui_DATA = \ $(NULL) CLEANFILES = \ + caja-src-marshal.list \ $(BUILT_SOURCES) \ $(desktop_files) \ $(server_DATA) \ -- cgit v1.2.1 From 767734608e245a3a6684e1087fa9e11280296004 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 03:51:08 +0200 Subject: [cell-renderer-text-ellipsized] use new GtkSizeRequest vfunctions This fixes the 'Name' column being too thin in list view. http://git.gnome.org/browse/nautilus/commit/?id=33c9b6d24a60079fe6c4c1be281c76f43def6fee --- .../caja-cell-renderer-text-ellipsized.c | 88 ++++++++++++++-------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/libcaja-private/caja-cell-renderer-text-ellipsized.c b/libcaja-private/caja-cell-renderer-text-ellipsized.c index 4c3cd443..ad535a5d 100644 --- a/libcaja-private/caja-cell-renderer-text-ellipsized.c +++ b/libcaja-private/caja-cell-renderer-text-ellipsized.c @@ -26,55 +26,81 @@ #include "caja-cell-renderer-text-ellipsized.h" -#define ELLIPSIZE_PROP "ellipsize" - -static void caja_cell_renderer_text_ellipsized_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *rectangle, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); - G_DEFINE_TYPE (CajaCellRendererTextEllipsized, caja_cell_renderer_text_ellipsized, GTK_TYPE_CELL_RENDERER_TEXT); +#if GTK_CHECK_VERSION(3,0,0) static void caja_cell_renderer_text_ellipsized_init (CajaCellRendererTextEllipsized *cell) { - g_object_set (cell, ELLIPSIZE_PROP, PANGO_ELLIPSIZE_END, NULL); + g_object_set (cell, + "ellipsize", PANGO_ELLIPSIZE_END, + "ellipsize-set", TRUE, + NULL); } static void -caja_cell_renderer_text_ellipsized_class_init (CajaCellRendererTextEllipsizedClass *klass) +nautilus_cell_renderer_text_ellipsized_get_preferred_width (GtkCellRenderer *cell, + GtkWidget *widget, + gint *minimum_size, + gint *natural_size) { - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); - - cell_class->get_size = caja_cell_renderer_text_ellipsized_get_size; + g_object_set (cell, + "ellipsize", PANGO_ELLIPSIZE_NONE, + "ellipsize-set", FALSE, + NULL); + + GTK_CELL_RENDERER_CLASS + (nautilus_cell_renderer_text_ellipsized_parent_class)->get_preferred_width (cell, widget, + minimum_size, natural_size); + + g_object_set (cell, + "ellipsize", PANGO_ELLIPSIZE_END, + "ellipsize-set", TRUE, + NULL); } - -GtkCellRenderer * -caja_cell_renderer_text_ellipsized_new (void) +#else /* GTK_CHECK_VERSION(3,0,0) */ +static void +caja_cell_renderer_text_ellipsized_init (CajaCellRendererTextEllipsized *cell) { - return g_object_new (CAJA_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NULL); + g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); } static void caja_cell_renderer_text_ellipsized_get_size (GtkCellRenderer *cell, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) + GtkWidget *widget, + GdkRectangle *cell_area, + gint *x_offset, + gint *y_offset, + gint *width, + gint *height) { - g_object_set (cell, ELLIPSIZE_PROP, PANGO_ELLIPSIZE_NONE, NULL); + g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_NONE, NULL); - (* GTK_CELL_RENDERER_CLASS (caja_cell_renderer_text_ellipsized_parent_class)->get_size) - (cell, widget, cell_area, - x_offset, y_offset, - width, height); + GTK_CELL_RENDERER_CLASS + (caja_cell_renderer_text_ellipsized_parent_class)->get_size (cell, widget, + cell_area, + x_offset, y_offset, + width, height); - g_object_set (cell, ELLIPSIZE_PROP, PANGO_ELLIPSIZE_END, NULL); + g_object_set (cell, "ellipsize", PANGO_ELLIPSIZE_END, NULL); } +#endif /* GTK_CHECK_VERSION(3,0,0) */ +static void +caja_cell_renderer_text_ellipsized_class_init (CajaCellRendererTextEllipsizedClass *klass) +{ + GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); + +#if GTK_CHECK_VERSION(3,0,0) + cell_class->get_preferred_width = caja_cell_renderer_text_ellipsized_get_preferred_width; +#else + cell_class->get_size = caja_cell_renderer_text_ellipsized_get_size; +#endif +} + +GtkCellRenderer * +caja_cell_renderer_text_ellipsized_new (void) +{ + return g_object_new (CAJA_TYPE_CELL_RENDERER_TEXT_ELLIPSIZED, NULL); +} -- cgit v1.2.1 From add2dd8b06d33c6c9cb73b1fdcccf66e81ae2749 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 04:07:00 +0200 Subject: [editable-label] fix cairo drawing regressions http://git.gnome.org/browse/nautilus/commit/?id=407666719856127547f5c2f3f03f6a050858239a --- eel/eel-editable-label.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index 014caabd..a934f881 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -1494,13 +1494,16 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof gtk_widget_get_window (widget), NULL, &cursor_location, #endif - FALSE, dir1, TRUE); + FALSE, dir2, TRUE); } } else /* Block cursor */ { cairo_region_t *clip; -#if !GTK_CHECK_VERSION(3,0,0) + +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); #endif @@ -1510,6 +1513,9 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof yoffset + PANGO_PIXELS (strong_pos.y), PANGO_PIXELS (strong_pos.width), PANGO_PIXELS (strong_pos.height)); +#if GTK_CHECK_VERSION(3,0,0) + cairo_fill (cr); +#endif if (!block_at_line_end) { @@ -1519,11 +1525,6 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof gdk_cairo_region (cr, clip); cairo_clip (cr); - - /* FIXME should use gtk_paint, but it can't use a clip - * region - */ - gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[GTK_STATE_NORMAL]); cairo_move_to (cr, xoffset, yoffset); @@ -1532,7 +1533,9 @@ eel_editable_label_draw_cursor (EelEditableLabel *label, gint xoffset, gint yof cairo_region_destroy (clip); } -#if !GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); #endif } @@ -1609,13 +1612,15 @@ eel_editable_label_expose (GtkWidget *widget, range[1] = tmp; } -#if !GTK_CHECK_VERSION(3,0,0) + clip = gdk_pango_layout_get_clip_region (label->layout, + x, y, + range, + 1); +#if GTK_CHECK_VERSION(3,0,0) + cairo_save (cr); +#else cairo_t *cr = gdk_cairo_create (gtk_widget_get_window (widget)); #endif - clip = gdk_pango_layout_get_clip_region (label->layout, - x, y, - range, - 1); gdk_cairo_region (cr, clip); cairo_clip (cr); @@ -1630,7 +1635,9 @@ eel_editable_label_expose (GtkWidget *widget, cairo_move_to (cr, x, y); pango_cairo_show_layout (cr, label->layout); -#if !GTK_CHECK_VERSION(3,0,0) +#if GTK_CHECK_VERSION(3,0,0) + cairo_restore (cr); +#else cairo_destroy (cr); #endif cairo_region_destroy (clip); -- cgit v1.2.1 From aa6696e05a7c2614eccde660bf06554735ace3e2 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 01:43:35 +0200 Subject: [horizontal-splitter] remove, and use a regular GtkPaned instead The feature it was bringing in (shrink when the paned handle is double-clicked) is even confusing. http://git.gnome.org/browse/nautilus/commit/?id=1620bd8a4e4ab1760c5c518dd954a4471645ce87 --- libcaja-private/Makefile.am | 2 - libcaja-private/caja-horizontal-splitter.c | 307 ----------------------------- libcaja-private/caja-horizontal-splitter.h | 76 ------- src/caja-navigation-window.c | 8 +- src/caja-spatial-window.c | 1 - src/caja-window.c | 1 - 6 files changed, 4 insertions(+), 391 deletions(-) delete mode 100644 libcaja-private/caja-horizontal-splitter.c delete mode 100644 libcaja-private/caja-horizontal-splitter.h diff --git a/libcaja-private/Makefile.am b/libcaja-private/Makefile.am index cbf91983..55cadeee 100644 --- a/libcaja-private/Makefile.am +++ b/libcaja-private/Makefile.am @@ -105,8 +105,6 @@ libcaja_private_la_SOURCES = \ caja-file.h \ caja-global-preferences.c \ caja-global-preferences.h \ - caja-horizontal-splitter.c \ - caja-horizontal-splitter.h \ caja-icon-canvas-item.c \ caja-icon-canvas-item.h \ caja-icon-container.c \ diff --git a/libcaja-private/caja-horizontal-splitter.c b/libcaja-private/caja-horizontal-splitter.c deleted file mode 100644 index 0fbaa3c4..00000000 --- a/libcaja-private/caja-horizontal-splitter.c +++ /dev/null @@ -1,307 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* caja-horizontal-splitter.c - A horizontal splitter with a semi gradient look - - Copyright (C) 1999, 2000 Eazel, Inc. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Ramiro Estrugo -*/ - -#include -#include "caja-horizontal-splitter.h" - -#include -#include - -struct CajaHorizontalSplitterDetails -{ - guint32 press_time; - int press_position; - int saved_size; -}; - -#define CLOSED_THRESHOLD 4 -#define NOMINAL_SIZE 148 -#define SPLITTER_CLICK_SLOP 4 -#define SPLITTER_CLICK_TIMEOUT 400 - -static void caja_horizontal_splitter_class_init (CajaHorizontalSplitterClass *horizontal_splitter_class); -static void caja_horizontal_splitter_init (CajaHorizontalSplitter *horizontal_splitter); - -EEL_CLASS_BOILERPLATE (CajaHorizontalSplitter, - caja_horizontal_splitter, - GTK_TYPE_HPANED) - -static void -caja_horizontal_splitter_init (CajaHorizontalSplitter *horizontal_splitter) -{ - horizontal_splitter->details = g_new0 (CajaHorizontalSplitterDetails, 1); -} - -static void -caja_horizontal_splitter_finalize (GObject *object) -{ - CajaHorizontalSplitter *horizontal_splitter; - - horizontal_splitter = CAJA_HORIZONTAL_SPLITTER (object); - - g_free (horizontal_splitter->details); - - EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); -} - -static void -splitter_expand (CajaHorizontalSplitter *splitter, int position) -{ - g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - if (position >= CLOSED_THRESHOLD) - { - return; - } - - position = splitter->details->saved_size; - if (position < CLOSED_THRESHOLD) - { - position = NOMINAL_SIZE; - } - - gtk_paned_set_position (GTK_PANED (splitter), position); -} - -static void -splitter_collapse (CajaHorizontalSplitter *splitter, int position) -{ - g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - splitter->details->saved_size = position; - gtk_paned_set_position (GTK_PANED (splitter), 0); -} - -static void -splitter_toggle (CajaHorizontalSplitter *splitter, int position) -{ - g_assert (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - if (gtk_paned_get_position (GTK_PANED (splitter)) >= CLOSED_THRESHOLD) - { - caja_horizontal_splitter_collapse (splitter); - } - else - { - caja_horizontal_splitter_expand (splitter); - } -} - -static void -splitter_hide (CajaHorizontalSplitter *splitter) -{ - GtkPaned *parent; - - parent = GTK_PANED (splitter); - - gtk_widget_hide (gtk_paned_get_child1 (parent)); -} - -static void -splitter_show (CajaHorizontalSplitter *splitter) -{ - GtkPaned *parent; - - parent = GTK_PANED (splitter); - - gtk_widget_show (gtk_paned_get_child1 (parent)); -} - -static gboolean -splitter_is_hidden (CajaHorizontalSplitter *splitter) -{ - GtkPaned *parent; - - parent = GTK_PANED (splitter); - - return gtk_widget_get_visible (gtk_paned_get_child1 (parent)); -} - -void -caja_horizontal_splitter_expand (CajaHorizontalSplitter *splitter) -{ - splitter_expand (splitter, gtk_paned_get_position (GTK_PANED (splitter))); -} - -void -caja_horizontal_splitter_hide (CajaHorizontalSplitter *splitter) -{ - splitter_hide (splitter); -} - -void -caja_horizontal_splitter_show (CajaHorizontalSplitter *splitter) -{ - splitter_show (splitter); -} - -gboolean -caja_horizontal_splitter_is_hidden (CajaHorizontalSplitter *splitter) -{ - return splitter_is_hidden (splitter); -} - -void -caja_horizontal_splitter_collapse (CajaHorizontalSplitter *splitter) -{ - splitter_collapse (splitter, gtk_paned_get_position (GTK_PANED (splitter))); -} - -/* routine to toggle the open/closed state of the splitter */ -void -caja_horizontal_splitter_toggle_position (CajaHorizontalSplitter *splitter) -{ - splitter_toggle (splitter, gtk_paned_get_position (GTK_PANED (splitter))); -} - -/* CajaHorizontalSplitter public methods */ -GtkWidget * -caja_horizontal_splitter_new (void) -{ - return gtk_widget_new (caja_horizontal_splitter_get_type (), NULL); -} - -/* handle mouse downs by remembering the position and the time */ -static gboolean -caja_horizontal_splitter_button_press (GtkWidget *widget, GdkEventButton *event) -{ - gboolean result; - CajaHorizontalSplitter *splitter; - int position; - - splitter = CAJA_HORIZONTAL_SPLITTER (widget); - - position = gtk_paned_get_position (GTK_PANED (widget)); - - result = EEL_CALL_PARENT_WITH_RETURN_VALUE - (GTK_WIDGET_CLASS, button_press_event, (widget, event)); - - if (result) - { - splitter->details->press_time = event->time; - splitter->details->press_position = position; - } - - return result; -} - -/* handle mouse ups by seeing if it was a tap and toggling the open state accordingly */ -static gboolean -caja_horizontal_splitter_button_release (GtkWidget *widget, GdkEventButton *event) -{ - gboolean result; - CajaHorizontalSplitter *splitter; - int position, delta, delta_time; - splitter = CAJA_HORIZONTAL_SPLITTER (widget); - - position = gtk_paned_get_position (GTK_PANED (widget)); - - result = EEL_CALL_PARENT_WITH_RETURN_VALUE - (GTK_WIDGET_CLASS, button_release_event, (widget, event)); - - if (result) - { - delta = abs (position - splitter->details->press_position); - delta_time = event->time - splitter->details->press_time; - if (delta < SPLITTER_CLICK_SLOP && delta_time < SPLITTER_CLICK_TIMEOUT) - { - caja_horizontal_splitter_toggle_position (splitter); - } - } - - return result; -} - -static void -caja_horizontal_splitter_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - gint border_width; - GtkPaned *paned; - GtkAllocation child_allocation; - GtkRequisition child_requisition; - - paned = GTK_PANED (widget); - border_width = gtk_container_get_border_width (GTK_CONTAINER (paned)); - - gtk_widget_set_allocation (widget, allocation); - - if (gtk_paned_get_child2 (paned) != NULL && gtk_widget_get_visible (gtk_paned_get_child2 (paned))) - { - EEL_CALL_PARENT (GTK_WIDGET_CLASS, size_allocate, - (widget, allocation)); - } - else if (gtk_paned_get_child1 (paned) && gtk_widget_get_visible (gtk_paned_get_child1 (paned))) - { - - if (gtk_widget_get_realized (widget)) - { - gdk_window_hide (gtk_paned_get_handle_window (paned)); - } - - gtk_widget_get_child_requisition (gtk_paned_get_child1 (paned), - &child_requisition); - - child_allocation.x = allocation->x + border_width; - child_allocation.y = allocation->y + border_width; - child_allocation.width = MIN (child_requisition.width, - allocation->width - 2 * border_width); - child_allocation.height = MIN (child_requisition.height, - allocation->height - 2 * border_width); - - gtk_widget_size_allocate (gtk_paned_get_child1 (paned), &child_allocation); - } - else if (gtk_widget_get_realized (widget)) - { - gdk_window_hide (gtk_paned_get_handle_window (paned)); - } - -} - -static void -caja_horizontal_splitter_class_init (CajaHorizontalSplitterClass *class) -{ - GtkWidgetClass *widget_class; - - widget_class = GTK_WIDGET_CLASS (class); - - G_OBJECT_CLASS (class)->finalize = caja_horizontal_splitter_finalize; - - widget_class->size_allocate = caja_horizontal_splitter_size_allocate; - widget_class->button_press_event = caja_horizontal_splitter_button_press; - widget_class->button_release_event = caja_horizontal_splitter_button_release; -} - -void -caja_horizontal_splitter_pack2 (CajaHorizontalSplitter *splitter, - GtkWidget *child2) -{ - GtkPaned *paned; - - g_return_if_fail (GTK_IS_WIDGET (child2)); - g_return_if_fail (CAJA_IS_HORIZONTAL_SPLITTER (splitter)); - - paned = GTK_PANED (splitter); - gtk_paned_pack2 (paned, child2, TRUE, FALSE); -} diff --git a/libcaja-private/caja-horizontal-splitter.h b/libcaja-private/caja-horizontal-splitter.h deleted file mode 100644 index b0fdcf4a..00000000 --- a/libcaja-private/caja-horizontal-splitter.h +++ /dev/null @@ -1,76 +0,0 @@ -/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */ - -/* caja-horizontal-splitter.h - A horizontal splitter with a semi gradient look - - Copyright (C) 1999, 2000 Eazel, Inc. - - The Mate Library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public License as - published by the Free Software Foundation; either version 2 of the - License, or (at your option) any later version. - - The Mate Library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with the Mate Library; see the file COPYING.LIB. If not, - write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, - Boston, MA 02110-1301, USA. - - Authors: Ramiro Estrugo -*/ - -#ifndef CAJA_HORIZONTAL_SPLITTER_H -#define CAJA_HORIZONTAL_SPLITTER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -#define CAJA_TYPE_HORIZONTAL_SPLITTER caja_horizontal_splitter_get_type() -#define CAJA_HORIZONTAL_SPLITTER(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitter)) -#define CAJA_HORIZONTAL_SPLITTER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST ((klass), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitterClass)) -#define CAJA_IS_HORIZONTAL_SPLITTER(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER)) -#define CAJA_IS_HORIZONTAL_SPLITTER_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE ((klass), CAJA_TYPE_HORIZONTAL_SPLITTER)) -#define CAJA_HORIZONTAL_SPLITTER_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS ((obj), CAJA_TYPE_HORIZONTAL_SPLITTER, CajaHorizontalSplitterClass)) - - typedef struct CajaHorizontalSplitterDetails CajaHorizontalSplitterDetails; - - typedef struct - { - GtkHPaned parent_slot; - CajaHorizontalSplitterDetails *details; - } CajaHorizontalSplitter; - - typedef struct - { - GtkHPanedClass parent_slot; - } CajaHorizontalSplitterClass; - - /* CajaHorizontalSplitter public methods */ - GType caja_horizontal_splitter_get_type (void); - GtkWidget *caja_horizontal_splitter_new (void); - - gboolean caja_horizontal_splitter_is_hidden (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_collapse (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_hide (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_show (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_expand (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_toggle_position (CajaHorizontalSplitter *splitter); - void caja_horizontal_splitter_pack2 (CajaHorizontalSplitter *splitter, - GtkWidget *child2); - -#ifdef __cplusplus -} -#endif - -#endif /* CAJA_HORIZONTAL_SPLITTER_H */ diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c index 3cddcb26..eba87c47 100644 --- a/src/caja-navigation-window.c +++ b/src/caja-navigation-window.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include @@ -141,7 +140,7 @@ caja_navigation_window_init (CajaNavigationWindow *window) window->details->header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); gtk_size_group_set_ignore_hidden (window->details->header_size_group, FALSE); - window->details->content_paned = caja_horizontal_splitter_new (); + window->details->content_paned = gtk_hpaned_new (); gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table), window->details->content_paned, /* X direction */ /* Y direction */ @@ -151,7 +150,8 @@ caja_navigation_window_init (CajaNavigationWindow *window) gtk_widget_show (window->details->content_paned); vbox = gtk_vbox_new (FALSE, 0); - caja_horizontal_splitter_pack2 (CAJA_HORIZONTAL_SPLITTER (window->details->content_paned), vbox); + gtk_paned_pack2 (GTK_PANED (window->details->content_paned), vbox, + TRUE, FALSE); gtk_widget_show (vbox); hpaned = gtk_hpaned_new (); @@ -1036,7 +1036,7 @@ caja_navigation_window_sidebar_showing (CajaNavigationWindow *window) g_return_val_if_fail (CAJA_IS_NAVIGATION_WINDOW (window), FALSE); return (window->sidebar != NULL) - && caja_horizontal_splitter_is_hidden (CAJA_HORIZONTAL_SPLITTER (window->details->content_paned)); + && gtk_widget_get_visible (gtk_paned_get_child1 (GTK_PANED (window->details->content_paned))); } /** diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 524fbb9b..5dd3bbce 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -56,7 +56,6 @@ #include #include #include -#include #include #include #include diff --git a/src/caja-window.c b/src/caja-window.c index 27e2852f..14c5d5c4 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -55,7 +55,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.1 From 43dad9d04402b97de8440366d03d43dbe954528a Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 01:50:57 +0200 Subject: [icon-view] if possible, use the local path for the preview This solves issues where the audio previewer is not capable of understanding some GVfs URIs. (#624841) http://git.gnome.org/browse/nautilus/commit/?id=ebcbb167876f8b4491af0bc86bc29015c211b3af --- src/file-manager/fm-icon-view.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/file-manager/fm-icon-view.c b/src/file-manager/fm-icon-view.c index a9fb8b11..931df9f8 100644 --- a/src/file-manager/fm-icon-view.c +++ b/src/file-manager/fm-icon-view.c @@ -2192,6 +2192,8 @@ play_file (gpointer callback_data) char **argv; GError *error; char *uri; + GFile *gfile; + char *path; icon_view = FM_ICON_VIEW (callback_data); @@ -2199,7 +2201,21 @@ play_file (gpointer callback_data) icon_view->details->audio_preview_timeout = 0; file = icon_view->details->audio_preview_file; - uri = caja_file_get_uri (file); + gfile = caja_file_get_location (file); + path = g_file_get_path (gfile); + + /* if we have a local path, use that instead of the native URI. + * this can be useful for special GVfs mounts, such as cdda:// + */ + if (path) { + uri = g_filename_to_uri (path, NULL, NULL); + } else { + uri = caja_file_get_uri (file); + } + + g_object_unref (gfile); + g_free (path); + argv = get_preview_argv (uri); g_free (uri); if (argv == NULL) -- cgit v1.2.1 From 29bf2205fbea100f3b799560a4d5b4ffece1ac53 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 01:53:16 +0200 Subject: [column-utilities] disable SELinux column if !HAVE_SELINUX http://git.gnome.org/browse/nautilus/commit/?id=b0550951f461c2033f4d1aaa4404078c7a70f220 --- libcaja-private/caja-column-utilities.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libcaja-private/caja-column-utilities.c b/libcaja-private/caja-column-utilities.c index 3b789221..d649f518 100644 --- a/libcaja-private/caja-column-utilities.c +++ b/libcaja-private/caja-column-utilities.c @@ -113,6 +113,7 @@ get_builtin_columns (void) "label", _("MIME Type"), "description", _("The mime type of the file."), NULL)); +#ifdef HAVE_SELINUX columns = g_list_append (columns, g_object_new (CAJA_TYPE_COLUMN, "name", "selinux_context", @@ -120,6 +121,7 @@ get_builtin_columns (void) "label", _("SELinux Context"), "description", _("The SELinux security context of the file."), NULL)); +#endif columns = g_list_append (columns, g_object_new (CAJA_TYPE_COLUMN, "name", "where", -- cgit v1.2.1 From 01a922551d410ecb11e4eb1477cfe3f33bff3491 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Wed, 7 Nov 2012 01:54:48 +0200 Subject: [column-utilities] fix a TODO about a missing description string http://git.gnome.org/browse/nautilus/commit/?id=0f8dcf2ac394121c488afdf0fecc2b7afeb673b6 --- libcaja-private/caja-column-utilities.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libcaja-private/caja-column-utilities.c b/libcaja-private/caja-column-utilities.c index d649f518..1ba570df 100644 --- a/libcaja-private/caja-column-utilities.c +++ b/libcaja-private/caja-column-utilities.c @@ -127,8 +127,7 @@ get_builtin_columns (void) "name", "where", "attribute", "where", "label", _("Location"), - /* TODO: Change after string freeze over */ - "description", _("Location"), + "description", _("The location of the file."), NULL)); return columns; -- cgit v1.2.1 From bd5fe64bb5ec8a9cdca866d7bc78baf8f725a9f9 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 17:39:45 +0200 Subject: [image-properties-page] call gdk_pixbuf_loader_close() earlier This helps smaller images (>8192 bytes) to signal size_prepared before reading image geometry. (#558267) http://git.gnome.org/browse/nautilus/commit/?id=d3ab8e137ae957e5afef54bf0ec1e275b96caab5 --- src/caja-image-properties-page.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/caja-image-properties-page.c b/src/caja-image-properties-page.c index 67428fde..1e5b53e2 100644 --- a/src/caja-image-properties-page.c +++ b/src/caja-image-properties-page.c @@ -391,6 +391,10 @@ load_finished (CajaImagePropertiesPage *page) gtk_widget_destroy (page->details->loading_label); + if (page->details->loader != NULL) { + gdk_pixbuf_loader_close (page->details->loader, NULL); + } + if (page->details->got_size) { #ifdef HAVE_EXIF @@ -437,7 +441,6 @@ load_finished (CajaImagePropertiesPage *page) if (page->details->loader != NULL) { - gdk_pixbuf_loader_close (page->details->loader, NULL); g_object_unref (page->details->loader); page->details->loader = NULL; } -- cgit v1.2.1 From 345bf975a496493161baf455af07977d57cbf709 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 25 Oct 2012 14:13:07 +0200 Subject: [src] replace deprecated GtkComboBox text APIs with GtkComboBoxText [src] don't use GtkComboBox text APIs (#632651) They got replaced by GtkComboBoxText. Thanks to Mathias Clasen and Flo Gravo. http://git.gnome.org/browse/nautilus/commit/?id=f123f99bee1005cd279783f9d441f538fcf85542 --- src/caja-file-management-properties.c | 21 +++++++++++---------- src/caja-query-editor.c | 4 ++-- src/caja-view-as-action.c | 8 ++++---- src/file-manager/fm-properties-window.c | 10 +++++----- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/src/caja-file-management-properties.c b/src/caja-file-management-properties.c index 824e6798..ef532d72 100644 --- a/src/caja-file-management-properties.c +++ b/src/caja-file-management-properties.c @@ -307,7 +307,7 @@ free_column_names_array (GPtrArray *column_names) } static void -create_icon_caption_combo_box_items (GtkComboBox *combo_box, +create_icon_caption_combo_box_items (GtkComboBoxText *combo_box, GList *columns) { GList *l; @@ -316,7 +316,7 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box, column_names = g_ptr_array_new (); /* Translators: this is referred to captions under icons. */ - gtk_combo_box_append_text (combo_box, _("None")); + gtk_combo_box_text_append_text (combo_box, _("None")); g_ptr_array_add (column_names, g_strdup ("none")); for (l = columns; l != NULL; l = l->next) @@ -339,7 +339,7 @@ create_icon_caption_combo_box_items (GtkComboBox *combo_box, continue; } - gtk_combo_box_append_text (combo_box, label); + gtk_combo_box_text_append_text (combo_box, label); g_ptr_array_add (column_names, name); g_free (label); @@ -472,7 +472,7 @@ caja_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *buil combo_box = GTK_WIDGET (gtk_builder_get_object (builder, icon_captions_components[i])); - create_icon_caption_combo_box_items (GTK_COMBO_BOX (combo_box), columns); + create_icon_caption_combo_box_items (GTK_COMBO_BOX_TEXT (combo_box), columns); gtk_widget_set_sensitive (combo_box, writable); g_signal_connect (combo_box, "changed", @@ -488,27 +488,28 @@ caja_file_management_properties_dialog_setup_icon_caption_page (GtkBuilder *buil static void create_date_format_menu (GtkBuilder *builder) { - GtkWidget *combo_box; + GtkComboBoxText *combo_box; gchar *date_string; time_t now_raw; struct tm* now; - combo_box = GTK_WIDGET (gtk_builder_get_object (builder, - CAJA_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET)); + combo_box = GTK_COMBO_BOX_TEXT + (gtk_builder_get_object (builder, + CAJA_FILE_MANAGEMENT_PROPERTIES_DATE_FORMAT_WIDGET)); now_raw = time (NULL); now = localtime (&now_raw); date_string = eel_strdup_strftime ("%c", now); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), date_string); g_free (date_string); date_string = eel_strdup_strftime ("%Y-%m-%d %H:%M:%S", now); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), date_string); g_free (date_string); date_string = eel_strdup_strftime (_("today at %-I:%M:%S %p"), now); - gtk_combo_box_append_text (GTK_COMBO_BOX (combo_box), date_string); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), date_string); g_free (date_string); } diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c index 7beb13d0..1b7ea10f 100644 --- a/src/caja-query-editor.c +++ b/src/caja-query-editor.c @@ -967,11 +967,11 @@ caja_query_editor_add_row (CajaQueryEditor *editor, gtk_widget_show (hbox); gtk_box_pack_start (GTK_BOX (editor->details->visible_vbox), hbox, FALSE, FALSE, 0); - combo = gtk_combo_box_new_text (); + combo = gtk_combo_box_text_new (); row->combo = combo; for (i = 0; i < CAJA_QUERY_EDITOR_ROW_LAST; i++) { - gtk_combo_box_append_text (GTK_COMBO_BOX (combo), gettext (row_type[i].name)); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo), gettext (row_type[i].name)); } gtk_widget_show (combo); gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0); diff --git a/src/caja-view-as-action.c b/src/caja-view-as-action.c index 645d8057..87785855 100644 --- a/src/caja-view-as-action.c +++ b/src/caja-view-as-action.c @@ -134,7 +134,7 @@ view_as_changed_callback (CajaWindow *window, node = node->next, ++index) { info = caja_view_factory_lookup (node->data); - gtk_combo_box_append_text (combo_box, _(info->view_combo_label)); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), _(info->view_combo_label)); if (caja_window_slot_content_view_matches_iid (slot, (char *)node->data)) { @@ -149,8 +149,8 @@ view_as_changed_callback (CajaWindow *window, id = caja_window_slot_get_content_view_id (slot); info = caja_view_factory_lookup (id); - gtk_combo_box_append_text (combo_box, - _(info->view_combo_label)); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), + _(info->view_combo_label)); selected_index = index; } @@ -179,7 +179,7 @@ connect_proxy (GtkAction *action, gtk_container_set_border_width (GTK_CONTAINER (item), 4); gtk_container_add (GTK_CONTAINER (item), view_as_menu_vbox); - view_as_combo_box = gtk_combo_box_new_text (); + view_as_combo_box = gtk_combo_box_text_new (); gtk_combo_box_set_focus_on_click (GTK_COMBO_BOX (view_as_combo_box), FALSE); gtk_box_pack_end (GTK_BOX (view_as_menu_vbox), view_as_combo_box, TRUE, FALSE, 0); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index b79436af..ea07b1c4 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -1635,7 +1635,7 @@ changed_group_callback (GtkComboBox *combo_box, CajaFile *file) g_assert (GTK_IS_COMBO_BOX (combo_box)); g_assert (CAJA_IS_FILE (file)); - group = gtk_combo_box_get_active_text (combo_box); + group = gtk_combo_box_text_get_active_text (GTK_COMBO_BOX_TEXT (combo_box)); cur_group = caja_file_get_group_name (file); if (group != NULL && strcmp (group, cur_group) != 0) { @@ -1790,7 +1790,7 @@ synch_groups_combo_box (GtkComboBox *combo_box, CajaFile *file) for (node = groups, group_index = 0; node != NULL; node = node->next, ++group_index) { group_name = (const char *)node->data; - gtk_combo_box_append_text (combo_box, group_name); + gtk_combo_box_text_append_text (GTK_COMBO_BOX_TEXT (combo_box), group_name); } } @@ -1804,10 +1804,10 @@ synch_groups_combo_box (GtkComboBox *combo_box, CajaFile *file) if (current_group_index < 0 && current_group_name != NULL) { if (groups != NULL) { /* add separator */ - gtk_combo_box_prepend_text (combo_box, "-"); + gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (combo_box), "-"); } - gtk_combo_box_prepend_text (combo_box, current_group_name); + gtk_combo_box_text_prepend_text (GTK_COMBO_BOX_TEXT (combo_box), current_group_name); current_group_index = 0; } gtk_combo_box_set_active (combo_box, current_group_index); @@ -1849,7 +1849,7 @@ attach_combo_box (GtkTable *table, GtkWidget *aligner; if (!two_columns) { - combo_box = gtk_combo_box_new_text (); + combo_box = gtk_combo_box_text_new (); } else { GtkTreeModel *model; GtkCellRenderer *renderer; -- cgit v1.2.1 From b7f2233c06be6506e6913fcd02ae9c9e2183c9d3 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 27 Oct 2012 19:42:49 +0200 Subject: [fm-properties] use GtkComboBoxText in the GtkBuilder file http://git.gnome.org/browse/nautilus/commit/?id=18fc6dd2516f9091570902640032e68b263cfddf Also include subsequent commit: preferences: cleanup expand/fill flags Probably a change in GTK+ requires fixing this flags, so that the dialog doesn't look odd. http://git.gnome.org/browse/nautilus/commit/?id=6669f155734c320617bcf79f3b5d8f315f4886f9 --- src/caja-file-management-properties.ui | 247 +++++++++------------------------ 1 file changed, 69 insertions(+), 178 deletions(-) diff --git a/src/caja-file-management-properties.ui b/src/caja-file-management-properties.ui index 8f4003d8..5c4c3036 100644 --- a/src/caja-file-management-properties.ui +++ b/src/caja-file-management-properties.ui @@ -233,32 +233,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - 5 File Management Preferences @@ -419,15 +393,13 @@ 0 - True - True + False 0 - True - True + False @@ -475,15 +447,13 @@ 0 - True - True + False 0 - True - True + False @@ -527,15 +497,13 @@ 0 - True - True + False 0 False - True @@ -628,15 +596,13 @@ 0 - True - True + False 0 - True - True + False @@ -680,8 +646,7 @@ 0 - True - True + False @@ -781,15 +746,13 @@ 0 - True - True + False 0 - True - True + False @@ -815,8 +778,7 @@ 0 - True - True + False @@ -916,15 +878,13 @@ 0 - True - True + False 0 - True - True + False @@ -932,8 +892,7 @@ 0 - True - True + False @@ -1011,8 +970,7 @@ 0 - True - True + False @@ -1135,31 +1093,6 @@ False - - - 6 - True - - False - False - GTK_JUSTIFY_LEFT - False - False - 0.5 - 0.5 - 0 - 0 - PANGO_ELLIPSIZE_NONE - -1 - False - 0 - - - 0 - True - True - - True @@ -1183,8 +1116,8 @@ 0 - True - True + False + False @@ -1300,8 +1233,8 @@ 0 - True - True + False + False @@ -1397,8 +1330,8 @@ 0 - True - True + False + False @@ -1538,29 +1471,23 @@ - + True False True - model11 - - - - 0 - - + 0 0 False - True + False 0 - True - True + False + False @@ -1593,22 +1520,16 @@ - + True False True - model12 - - - - 0 - - + 0 0 False - True + False @@ -1648,29 +1569,23 @@ - + True False True - model13 - - - - 0 - - + 0 0 False - True + False 0 - True - True + False + False @@ -1678,8 +1593,8 @@ 0 - True - True + False + False @@ -1760,17 +1675,11 @@ - + True False True - model14 - - - - 0 - - + 0 0 @@ -1783,15 +1692,15 @@ 0 - True - True + False + False 0 False - True + False @@ -1902,15 +1811,13 @@ 0 - True - True + False 0 - True - True + False @@ -2034,15 +1941,15 @@ 0 - True - True + False + False 0 - True - True + False + False @@ -2050,8 +1957,8 @@ 0 - True - True + False + False @@ -2151,15 +2058,15 @@ 0 - True - True + False + False 0 - True - True + False + False @@ -2207,15 +2114,13 @@ 0 - True - True + False 0 - True - True + False @@ -2223,8 +2128,7 @@ 0 - True - True + False @@ -2324,15 +2228,13 @@ 0 - True - True + False 0 - True - True + False @@ -2340,8 +2242,7 @@ 0 - True - True + False @@ -2441,15 +2342,13 @@ 0 - True - True + False 0 - True - True + False @@ -2457,8 +2356,7 @@ 0 - True - True + False @@ -2798,8 +2696,7 @@ 0 - True - True + False @@ -2807,15 +2704,13 @@ 0 - True - True + False 0 - True - True + False @@ -2983,8 +2878,7 @@ 0 - True - True + False @@ -2992,15 +2886,13 @@ 0 - True - True + False 0 - True - True + False @@ -3100,8 +2992,7 @@ 0 - True - True + False -- cgit v1.2.1 From 5ee6f114f83b68d02e7d5b723090f1dfe8c443ca Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 06:40:35 +0200 Subject: [general] use new GtkScrollable interface http://git.gnome.org/browse/nautilus/commit/?id=d811553a4e74106efdf8bf6c91c6d29944ed6df7 canvas: use GTK_LAYOUT casts instead of going through the parent struct http://git.gnome.org/browse/nautilus/commit/?id=2260005986d8c620669e56c4b9f2fba12e8e0625 --- eel/eel-canvas.c | 54 +++++++++++++++++------------- libcaja-private/caja-icon-container.c | 52 +++++++++++++++------------- libcaja-private/caja-icon-dnd.c | 42 +++++++++++++++-------- libcaja-private/caja-tree-view-drag-dest.c | 4 +-- src/file-manager/fm-desktop-icon-view.c | 10 ++++-- 5 files changed, 98 insertions(+), 64 deletions(-) diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c index 08793333..b3b4c482 100644 --- a/eel/eel-canvas.c +++ b/eel/eel-canvas.c @@ -76,6 +76,14 @@ #include "eel-marshal.h" +#if !GTK_CHECK_VERSION(3, 0, 0) +#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment +#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment +#define gtk_scrollable_set_hadjustment gtk_layout_set_hadjustment +#define gtk_scrollable_set_vadjustment gtk_layout_set_vadjustment +#define GTK_SCROLLABLE GTK_LAYOUT +#endif + static void eel_canvas_request_update (EelCanvas *canvas); static void group_add (EelCanvasGroup *group, EelCanvasItem *item); @@ -1944,11 +1952,11 @@ eel_canvas_accessible_initialize (AtkObject *obj, ATK_OBJECT_CLASS (accessible_parent_class)->initialize (obj, data); canvas = EEL_CANVAS (data); - g_signal_connect (gtk_layout_get_hadjustment (&canvas->layout), + g_signal_connect (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)), "value_changed", G_CALLBACK (eel_canvas_accessible_adjustment_changed), obj); - g_signal_connect (gtk_layout_get_vadjustment (&canvas->layout), + g_signal_connect (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)), "value_changed", G_CALLBACK (eel_canvas_accessible_adjustment_changed), obj); @@ -2218,7 +2226,7 @@ eel_canvas_init (EelCanvas *canvas) canvas->scroll_x1 = 0.0; canvas->scroll_y1 = 0.0; - gtk_layout_get_size (&canvas->layout, + gtk_layout_get_size (GTK_LAYOUT (canvas), &width, &height); canvas->scroll_x2 = width; canvas->scroll_y2 = height; @@ -2229,8 +2237,8 @@ eel_canvas_init (EelCanvas *canvas) canvas->pick_event.crossing.x = 0; canvas->pick_event.crossing.y = 0; - gtk_layout_set_hadjustment (GTK_LAYOUT (canvas), NULL); - gtk_layout_set_vadjustment (GTK_LAYOUT (canvas), NULL); + gtk_scrollable_set_hadjustment (GTK_SCROLLABLE (canvas), NULL); + gtk_scrollable_set_vadjustment (GTK_SCROLLABLE (canvas), NULL); /* Create the root item as a special case */ @@ -2399,8 +2407,8 @@ eel_canvas_realize (GtkWidget *widget) canvas = EEL_CANVAS (widget); - gdk_window_set_events (gtk_layout_get_bin_window (&canvas->layout), - (gdk_window_get_events (gtk_layout_get_bin_window (&canvas->layout)) + gdk_window_set_events (gtk_layout_get_bin_window (GTK_LAYOUT (canvas)), + (gdk_window_get_events (gtk_layout_get_bin_window (GTK_LAYOUT (canvas))) | GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK @@ -2529,8 +2537,8 @@ scroll_to (EelCanvas *canvas, int cx, int cy) gtk_widget_queue_draw (GTK_WIDGET (canvas)); } - hadjustment = gtk_layout_get_hadjustment (&canvas->layout); - vadjustment = gtk_layout_get_vadjustment (&canvas->layout); + hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); if (((int) gtk_adjustment_get_value (hadjustment)) != cx) { @@ -2574,8 +2582,8 @@ eel_canvas_size_allocate (GtkWidget *widget, GtkAllocation *allocation) /* Recenter the view, if appropriate */ - hadjustment = gtk_layout_get_hadjustment (&canvas->layout); - vadjustment = gtk_layout_get_vadjustment (&canvas->layout); + hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); gtk_adjustment_set_page_size (hadjustment, allocation->width); gtk_adjustment_set_page_increment (hadjustment, allocation->width / 2); @@ -2908,7 +2916,7 @@ eel_canvas_button (GtkWidget *widget, GdkEventButton *event) * dispatch normally regardless of the event's window if an item has * has a pointer grab in effect */ - if (!canvas->grabbed_item && event->window != gtk_layout_get_bin_window (&canvas->layout)) + if (!canvas->grabbed_item && event->window != gtk_layout_get_bin_window (GTK_LAYOUT (canvas))) return retval; switch (event->button) @@ -2976,7 +2984,7 @@ eel_canvas_motion (GtkWidget *widget, GdkEventMotion *event) canvas = EEL_CANVAS (widget); - if (event->window != gtk_layout_get_bin_window (&canvas->layout)) + if (event->window != gtk_layout_get_bin_window (GTK_LAYOUT (canvas))) return FALSE; canvas->state = event->state; @@ -3015,7 +3023,7 @@ eel_canvas_crossing (GtkWidget *widget, GdkEventCrossing *event) canvas = EEL_CANVAS (widget); - if (event->window != gtk_layout_get_bin_window (&canvas->layout)) + if (event->window != gtk_layout_get_bin_window (GTK_LAYOUT (canvas))) return FALSE; canvas->state = event->state; @@ -3333,8 +3341,8 @@ eel_canvas_set_scroll_region (EelCanvas *canvas, double x1, double y1, double x2 * Set the new scrolling region. If possible, do not move the visible contents of the * canvas. */ - hadjustment = gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)); - vadjustment = gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)); + hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); eel_canvas_c2w (canvas, gtk_adjustment_get_value (hadjustment) + canvas->zoom_xofs, @@ -3400,8 +3408,8 @@ eel_canvas_set_center_scroll_region (EelCanvas *canvas, canvas->center_scroll_region = center_scroll_region != 0; - hadjustment = gtk_layout_get_hadjustment (&canvas->layout); - vadjustment = gtk_layout_get_vadjustment (&canvas->layout); + hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (&canvas->layout)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (&canvas->layout)); scroll_to (canvas, gtk_adjustment_get_value (hadjustment), @@ -3440,8 +3448,8 @@ eel_canvas_set_pixels_per_unit (EelCanvas *canvas, double n) center_y = allocation.height / 2; /* Find the coordinates of the screen center in units. */ - hadjustment = gtk_layout_get_hadjustment (&canvas->layout); - vadjustment = gtk_layout_get_vadjustment (&canvas->layout); + hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); cx = (gtk_adjustment_get_value (hadjustment) + center_x) / canvas->pixels_per_unit + canvas->scroll_x1 + canvas->zoom_xofs; cy = (gtk_adjustment_get_value (vadjustment) + center_y) / canvas->pixels_per_unit + canvas->scroll_y1 + canvas->zoom_yofs; @@ -3545,8 +3553,8 @@ eel_canvas_get_scroll_offsets (EelCanvas *canvas, int *cx, int *cy) g_return_if_fail (EEL_IS_CANVAS (canvas)); - hadjustment = gtk_layout_get_hadjustment (&canvas->layout); - vadjustment = gtk_layout_get_vadjustment (&canvas->layout); + hadjustment = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); if (cx) *cx = gtk_adjustment_get_value (hadjustment); @@ -3646,7 +3654,7 @@ eel_canvas_request_redraw (EelCanvas *canvas, int x1, int y1, int x2, int y2) bbox.width = x2 - x1; bbox.height = y2 - y1; - gdk_window_invalidate_rect (gtk_layout_get_bin_window (&canvas->layout), + gdk_window_invalidate_rect (gtk_layout_get_bin_window (GTK_LAYOUT (canvas)), &bbox, FALSE); } diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index 583b6c85..e88cac74 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -52,6 +52,12 @@ #include #include +#if !GTK_CHECK_VERSION(3, 0, 0) +#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment +#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment +#define GTK_SCROLLABLE GTK_LAYOUT +#endif + #define TAB_NAVIGATION_DISABLED /* Interval for updating the rubberband selection, in milliseconds. */ @@ -591,8 +597,8 @@ caja_icon_container_scroll (CajaIconContainer *container, GtkAdjustment *hadj, *vadj; int old_h_value, old_v_value; - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container)); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)); /* Store the old ajustment values so we can tell if we * ended up actually scrolling. We may not have in a case @@ -754,8 +760,8 @@ reveal_icon (CajaIconContainer *container, details = container->details; gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container)); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)); if (caja_icon_container_is_auto_layout (container)) { @@ -1087,8 +1093,8 @@ canvas_set_scroll_region_include_visible_area (EelCanvas *canvas, width = (allocation.width) / canvas->pixels_per_unit; height = (allocation.height) / canvas->pixels_per_unit; - old_scroll_x = gtk_adjustment_get_value (GTK_ADJUSTMENT (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas)))); - old_scroll_y = gtk_adjustment_get_value (GTK_ADJUSTMENT (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas)))); + old_scroll_x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas))); + old_scroll_y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas))); x1 = MIN (x1, old_x1 + old_scroll_x); y1 = MIN (y1, old_y1 + old_scroll_y); @@ -1212,8 +1218,8 @@ caja_icon_container_update_scroll_region (CajaIconContainer *container) x1, y1, x2, y2); } - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container)); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)); /* Scroll by 1/4 icon each time you click. */ step_increment = caja_get_icon_size_for_zoom_level @@ -2775,14 +2781,14 @@ rubberband_timeout_callback (gpointer data) adj_changed = FALSE; gtk_widget_get_allocation (widget, &allocation); - adj_x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); + adj_x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); if (adj_x != band_info->last_adj_x) { band_info->last_adj_x = adj_x; adj_changed = TRUE; } - adj_y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); + adj_y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); if (adj_y != band_info->last_adj_y) { band_info->last_adj_y = adj_y; @@ -2831,8 +2837,8 @@ rubberband_timeout_callback (gpointer data) /* Remember to convert from widget to scrolled window coords */ eel_canvas_window_to_world (EEL_CANVAS (container), - x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))), - y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))), + x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))), + y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))), &world_x, &world_y); if (world_x < band_info->start_x) @@ -2953,8 +2959,8 @@ start_rubberbanding (CajaIconContainer *container, atk_object_set_name (accessible, "selection"); atk_object_set_description (accessible, _("The selection rectangle")); - band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); - band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); + band_info->prev_x = event->x - gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); + band_info->prev_y = event->y - gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); band_info->active = TRUE; @@ -4588,11 +4594,11 @@ realize (GtkWidget *widget) setup_label_gcs (container); - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (widget)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget)); g_signal_connect (hadj, "value_changed", G_CALLBACK (handle_hadjustment_changed), widget); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (widget)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget)); g_signal_connect (vadj, "value_changed", G_CALLBACK (handle_vadjustment_changed), widget); @@ -7192,9 +7198,9 @@ caja_icon_container_get_first_visible_icon (CajaIconContainer *container) gboolean better_icon; gboolean compare_lt; - hadj_v = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); - vadj_v = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); - h_page_size = gtk_adjustment_get_page_size (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); + hadj_v = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); + vadj_v = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); + h_page_size = gtk_adjustment_get_page_size (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); if (caja_icon_container_is_layout_rtl (container)) { @@ -7283,8 +7289,8 @@ caja_icon_container_scroll_to_icon (CajaIconContainer *container, EelIRect bounds; GtkAllocation allocation; - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container)); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)); gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); /* We need to force a relayout now if there are updates queued @@ -7616,8 +7622,8 @@ caja_icon_container_update_visible_icons (CajaIconContainer *container) gboolean visible; GtkAllocation allocation; - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (container)); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container)); gtk_widget_get_allocation (GTK_WIDGET (container), &allocation); min_x = gtk_adjustment_get_value (hadj); diff --git a/libcaja-private/caja-icon-dnd.c b/libcaja-private/caja-icon-dnd.c index 5aa48669..cae6e4ee 100644 --- a/libcaja-private/caja-icon-dnd.c +++ b/libcaja-private/caja-icon-dnd.c @@ -60,6 +60,12 @@ #include #include +#if !GTK_CHECK_VERSION(3, 0, 0) +#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment +#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment +#define GTK_SCROLLABLE GTK_LAYOUT +#endif + static const GtkTargetEntry drag_types [] = { { CAJA_ICON_DND_MATE_ICON_LIST_TYPE, 0, CAJA_ICON_DND_MATE_ICON_LIST }, @@ -197,6 +203,10 @@ canvas_rect_world_to_widget (EelCanvas *canvas, EelIRect *widget_rect) { EelDRect window_rect; + GtkAdjustment *hadj, *vadj; + + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas)); eel_canvas_world_to_window (canvas, world_rect->x0, world_rect->y0, @@ -204,10 +214,10 @@ canvas_rect_world_to_widget (EelCanvas *canvas, eel_canvas_world_to_window (canvas, world_rect->x1, world_rect->y1, &window_rect.x1, &window_rect.y1); - widget_rect->x0 = (int) window_rect.x0 - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))); - widget_rect->y0 = (int) window_rect.y0 - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))); - widget_rect->x1 = (int) window_rect.x1 - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))); - widget_rect->y1 = (int) window_rect.y1 - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))); + widget_rect->x0 = (int) window_rect.x0 - gtk_adjustment_get_value (hadj); + widget_rect->y0 = (int) window_rect.y0 - gtk_adjustment_get_value (vadj); + widget_rect->x1 = (int) window_rect.x1 - gtk_adjustment_get_value (hadj); + widget_rect->y1 = (int) window_rect.y1 - gtk_adjustment_get_value (vadj); } static void @@ -216,8 +226,8 @@ canvas_widget_to_world (EelCanvas *canvas, double *world_x, double *world_y) { eel_canvas_window_to_world (canvas, - widget_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (canvas))), - widget_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (canvas))), + widget_x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (canvas))), + widget_y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (canvas))), world_x, world_y); } @@ -1267,8 +1277,8 @@ caja_icon_container_receive_dropped_icons (CajaIconContainer *container, if (real_action > 0) { eel_canvas_window_to_world (EEL_CANVAS (container), - x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))), - y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))), + x + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))), + y + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))), &world_x, &world_y); drop_target = caja_icon_container_find_drop_target (container, @@ -1531,8 +1541,10 @@ drag_begin_callback (GtkWidget *widget, } #endif - start_x = container->details->dnd_info->drag_info.start_x + gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); - start_y = container->details->dnd_info->drag_info.start_y + gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); + start_x = container->details->dnd_info->drag_info.start_x + + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); + start_y = container->details->dnd_info->drag_info.start_y + + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); /* create a pixmap and mask to drag with */ #if GTK_CHECK_VERSION(3,0,0) @@ -1593,8 +1605,10 @@ caja_icon_dnd_begin_drag (CajaIconContainer *container, /* Notice that the event is in bin_window coordinates, because of the way the canvas handles events. */ - dnd_info->drag_info.start_x = start_x - gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (container))); - dnd_info->drag_info.start_y = start_y - gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (container))); + dnd_info->drag_info.start_x = start_x - + gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (container))); + dnd_info->drag_info.start_y = start_y - + gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (container))); /* start the drag */ context = gtk_drag_begin (GTK_WIDGET (container), @@ -1618,8 +1632,8 @@ drag_highlight_expose (GtkWidget *widget, gint x, y, width, height; GdkWindow *window; - x = gtk_adjustment_get_value (gtk_layout_get_hadjustment (GTK_LAYOUT (widget))); - y = gtk_adjustment_get_value (gtk_layout_get_vadjustment (GTK_LAYOUT (widget))); + x = gtk_adjustment_get_value (gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget))); + y = gtk_adjustment_get_value (gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (widget))); window = gtk_widget_get_window (widget); #if GTK_CHECK_VERSION(3, 0, 0) diff --git a/libcaja-private/caja-tree-view-drag-dest.c b/libcaja-private/caja-tree-view-drag-dest.c index d7a8d2b6..56e9a1cd 100644 --- a/libcaja-private/caja-tree-view-drag-dest.c +++ b/libcaja-private/caja-tree-view-drag-dest.c @@ -110,9 +110,9 @@ gtk_tree_view_vertical_autoscroll (GtkTreeView *tree_view) window = gtk_tree_view_get_bin_window (tree_view); #if GTK_CHECK_VERSION(3, 0, 0) - vadjustment = gtk_scrollable_get_vadjustment(GTK_SCROLLABLE(tree_view)); + vadjustment = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE(tree_view)); #else - vadjustment = gtk_tree_view_get_vadjustment(tree_view); + vadjustment = gtk_tree_view_get_vadjustment (tree_view); #endif gdk_window_get_pointer (window, NULL, &y, NULL); diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c index 232b198a..3885ca13 100644 --- a/src/file-manager/fm-desktop-icon-view.c +++ b/src/file-manager/fm-desktop-icon-view.c @@ -59,6 +59,12 @@ #include #include +#if !GTK_CHECK_VERSION(3, 0, 0) +#define gtk_scrollable_get_hadjustment gtk_layout_get_hadjustment +#define gtk_scrollable_get_vadjustment gtk_layout_get_vadjustment +#define GTK_SCROLLABLE GTK_LAYOUT +#endif + /* Timeout to check the desktop directory for updates */ #define RESCAN_TIMEOUT 4 @@ -566,8 +572,8 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view) gtk_widget_queue_resize (GTK_WIDGET (icon_container)); - hadj = gtk_layout_get_hadjustment (GTK_LAYOUT (icon_container)); - vadj = gtk_layout_get_vadjustment (GTK_LAYOUT (icon_container)); + hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (icon_container)); + vadj = gtk_scrollable_get_vadjustment (GTK_SCROLLABLE (icon_container)); eel_gtk_adjustment_set_value (hadj, 0); eel_gtk_adjustment_set_value (vadj, 0); -- cgit v1.2.1 From 7ec82bee955b65550ce806186c7f01070170e2de Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 08:22:02 +0200 Subject: [pathbar] don't use deprecated size_request vfunc http://git.gnome.org/browse/nautilus/commit/?id=22cb1accd98c1ae10938eac10cc6beda8fb6b145 --- src/caja-pathbar.c | 199 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 186 insertions(+), 13 deletions(-) diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index 6a582014..cc79e497 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -103,8 +103,17 @@ G_DEFINE_TYPE (CajaPathBar, static void caja_path_bar_finalize (GObject *object); static void caja_path_bar_dispose (GObject *object); +#if GTK_CHECK_VERSION(3,0,0) +static void caja_path_bar_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural); +static void caja_path_bar_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural); +#else static void caja_path_bar_size_request (GtkWidget *widget, - GtkRequisition *requisition); + GtkRequisition *requisition); +#endif static void caja_path_bar_unmap (GtkWidget *widget); static void caja_path_bar_size_allocate (GtkWidget *widget, GtkAllocation *allocation); @@ -375,7 +384,12 @@ caja_path_bar_class_init (CajaPathBarClass *path_bar_class) gobject_class->finalize = caja_path_bar_finalize; gobject_class->dispose = caja_path_bar_dispose; +#if GTK_CHECK_VERSION(3,0,0) + widget_class->get_preferred_height = caja_path_bar_get_preferred_height; + widget_class->get_preferred_width = caja_path_bar_get_preferred_width; +#else widget_class->size_request = caja_path_bar_size_request; +#endif widget_class->unmap = caja_path_bar_unmap; widget_class->size_allocate = caja_path_bar_size_allocate; widget_class->style_set = caja_path_bar_style_set; @@ -406,6 +420,10 @@ caja_path_bar_class_init (CajaPathBarClass *path_bar_class) g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, G_TYPE_FILE); + +#if GTK_CHECK_VERSION(3,0,0) + gtk_container_class_handle_border_width (container_class); +#endif } @@ -479,6 +497,77 @@ caja_path_bar_dispose (GObject *object) * Ideally, our size is determined by another widget, and we are just filling * available space. */ +#if GTK_CHECK_VERSION(3,0,0) +static void +caja_path_bar_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + ButtonData *button_data; + CajaPathBar *path_bar; + GList *list; + gint child_height; + gint height; + gint child_min, child_nat; + + path_bar = CAJA_PATH_BAR (widget); + + *minimum = *natural = 0; + height = 0; + + for (list = path_bar->button_list; list; list = list->next) { + button_data = BUTTON_DATA (list->data); + gtk_widget_get_preferred_width (button_data->button, &child_min, &child_nat); + gtk_widget_get_preferred_height (button_data->button, &child_height, NULL); + height = MAX (height, child_height); + + if (button_data->type == NORMAL_BUTTON) { + /* Use 2*Height as button width because of ellipsized label. */ + child_min = MAX (child_min, child_height * 2); + child_nat = MAX (child_min, child_height * 2); + } + + *minimum = MAX (*minimum, child_min); + *natural = MAX (*natural, child_nat); + } + + /* Add space for slider, if we have more than one path */ + /* Theoretically, the slider could be bigger than the other button. But we're + * not going to worry about that now. + */ + path_bar->slider_width = MIN (height * 2 / 3 + 5, height); + + if (path_bar->button_list && path_bar->button_list->next != NULL) { + *minimum += (path_bar->spacing + path_bar->slider_width) * 2; + *natural += (path_bar->spacing + path_bar->slider_width) * 2; + } +} + +static void +caja_path_bar_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + ButtonData *button_data; + CajaPathBar *path_bar; + GList *list; + gint child_min, child_nat; + + path_bar = CAJA_PATH_BAR (widget); + + *minimum = *natural = 0; + + for (list = path_bar->button_list; list; list = list->next) { + button_data = BUTTON_DATA (list->data); + gtk_widget_get_preferred_height (button_data->button, &child_min, &child_nat); + + *minimum = MAX (*minimum, child_min); + *natural = MAX (*natural, child_nat); + } +} + +#else /* GTK_CHECK_VERSION(3,0,0) */ + static void caja_path_bar_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -497,8 +586,7 @@ caja_path_bar_size_request (GtkWidget *widget, for (list = path_bar->button_list; list; list = list->next) { button_data = BUTTON_DATA (list->data); - gtk_widget_get_preferred_size (button_data->button, - &child_requisition, NULL); + gtk_widget_size_request (button_data->button, &child_requisition); requisition->width = MAX (child_requisition.width, requisition->width); requisition->height = MAX (child_requisition.height, requisition->height); } @@ -513,10 +601,8 @@ caja_path_bar_size_request (GtkWidget *widget, requisition->width += (path_bar->spacing + path_bar->slider_width) * 2; } - gtk_widget_get_preferred_size (path_bar->up_slider_button, - &child_requisition, NULL); - gtk_widget_get_preferred_size (path_bar->down_slider_button, - &child_requisition, NULL); + gtk_widget_size_request (path_bar->up_slider_button, &child_requisition); + gtk_widget_size_request (path_bar->down_slider_button, &child_requisition); border_width = gtk_container_get_border_width (GTK_CONTAINER (widget)); requisition->width += border_width * 2; @@ -525,6 +611,7 @@ caja_path_bar_size_request (GtkWidget *widget, gtk_widget_set_size_request (widget, requisition->width, requisition->height); } +#endif /* GTK_CHECK_VERSION(3,0,0) */ static void caja_path_bar_update_slider_buttons (CajaPathBar *path_bar) @@ -575,7 +662,6 @@ caja_path_bar_size_allocate (GtkWidget *widget, GList *list, *first_button; gint width; gint allocation_width; - gint border_width; gboolean need_sliders; gint up_slider_offset; gint down_slider_offset; @@ -595,8 +681,12 @@ caja_path_bar_size_allocate (GtkWidget *widget, return; } direction = gtk_widget_get_direction (widget); - border_width = (gint) gtk_container_get_border_width (GTK_CONTAINER (path_bar)); +#if GTK_CHECK_VERSION(3,0,0) + allocation_width = allocation->width; +#else + gint border_width = (gint) gtk_container_get_border_width (GTK_CONTAINER (path_bar)); allocation_width = allocation->width - 2 * border_width; +#endif /* First, we check to see if we need the scrollbars. */ if (path_bar->fake_root) @@ -709,24 +799,45 @@ caja_path_bar_size_allocate (GtkWidget *widget, } /* Now, we allocate space to the buttons */ +#if GTK_CHECK_VERSION(3,0,0) + child_allocation.y = allocation->y; + child_allocation.height = allocation->height; +#else child_allocation.y = allocation->y + border_width; child_allocation.height = MAX (1, (gint) allocation->height - border_width * 2); +#endif if (direction == GTK_TEXT_DIR_RTL) { +#if GTK_CHECK_VERSION(3,0,0) + child_allocation.x = allocation->x + allocation->width; +#else child_allocation.x = allocation->x + allocation->width - border_width; +#endif if (need_sliders || path_bar->fake_root) { child_allocation.x -= (path_bar->spacing + path_bar->slider_width); +#if GTK_CHECK_VERSION(3,0,0) + up_slider_offset = allocation->width - path_bar->slider_width; +#else up_slider_offset = allocation->width - border_width - path_bar->slider_width; +#endif } } else { +#if GTK_CHECK_VERSION(3,0,0) + child_allocation.x = allocation->x; +#else child_allocation.x = allocation->x + border_width; +#endif if (need_sliders || path_bar->fake_root) { +#if GTK_CHECK_VERSION(3,0,0) + up_slider_offset = 0; +#else up_slider_offset = border_width; +#endif child_allocation.x += (path_bar->spacing + path_bar->slider_width); } } @@ -746,7 +857,11 @@ caja_path_bar_size_allocate (GtkWidget *widget, /* Check to see if we've don't have any more space to allocate buttons */ if (need_sliders && direction == GTK_TEXT_DIR_RTL) { +#if GTK_CHECK_VERSION(3,0,0) + if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget_allocation.x) { +#else if (child_allocation.x - path_bar->spacing - path_bar->slider_width < widget_allocation.x + border_width) +#endif { break; } @@ -755,7 +870,11 @@ caja_path_bar_size_allocate (GtkWidget *widget, { if (need_sliders && direction == GTK_TEXT_DIR_LTR) { +#if GTK_CHECK_VERSION(3,0,0) + if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width > widget_allocation.x + allocation_width) { +#else if (child_allocation.x + child_allocation.width + path_bar->spacing + path_bar->slider_width > widget_allocation.x + border_width + allocation_width) +#endif { break; } @@ -769,12 +888,20 @@ caja_path_bar_size_allocate (GtkWidget *widget, { child_allocation.x -= path_bar->spacing; down_slider_offset = child_allocation.x - widget_allocation.x - path_bar->slider_width; +#if GTK_CHECK_VERSION(3,0,0) + down_slider_offset = 0; +#else down_slider_offset = border_width; +#endif } else { down_slider_offset = child_allocation.x - widget_allocation.x; +#if GTK_CHECK_VERSION(3,0,0) + down_slider_offset = allocation->width - path_bar->slider_width; +#else down_slider_offset = allocation->width - border_width - path_bar->slider_width; +#endif child_allocation.x += child_allocation.width + path_bar->spacing; } } @@ -968,7 +1095,6 @@ caja_path_bar_scroll_down (CajaPathBar *path_bar) GList *up_button; gint space_available; gint space_needed; - gint border_width; GtkTextDirection direction; GtkAllocation allocation, button_allocation, slider_allocation; @@ -983,7 +1109,9 @@ caja_path_bar_scroll_down (CajaPathBar *path_bar) gtk_widget_queue_resize (GTK_WIDGET (path_bar)); - border_width = gtk_container_get_border_width (GTK_CONTAINER (path_bar)); +#if !GTK_CHECK_VERSION(3,0,0) + gint border_width = gtk_container_get_border_width (GTK_CONTAINER (path_bar)); +#endif direction = gtk_widget_get_direction (GTK_WIDGET (path_bar)); /* We find the button at the 'down' end that we have to make */ @@ -1023,7 +1151,10 @@ caja_path_bar_scroll_down (CajaPathBar *path_bar) } else { - space_available = (allocation.x + allocation.width - border_width) - + space_available = (allocation.x + allocation.width) - +#if !GTK_CHECK_VERSION(3,0,0) + border_width - +#endif (slider_allocation.x + slider_allocation.width); } @@ -1415,6 +1546,34 @@ get_dir_name (ButtonData *button_data) /* We always want to request the same size for the label, whether * or not the contents are bold */ +#if GTK_CHECK_VERSION(3,0,0) +static void +set_label_size_request (GtkWidget *alignment, + ButtonData *button_data) +{ + const gchar *dir_name = get_dir_name (button_data); + PangoLayout *layout; + gint width, height, bold_width, bold_height; + gchar *markup; + + layout = gtk_widget_create_pango_layout (button_data->label, dir_name); + pango_layout_get_pixel_size (layout, &width, &height); + + markup = g_markup_printf_escaped ("%s", dir_name); + pango_layout_set_markup (layout, markup, -1); + g_free (markup); + + pango_layout_get_pixel_size (layout, &bold_width, &bold_height); + + gtk_widget_set_size_request (alignment, + MAX (width, bold_width), + MAX (height, bold_height)); + + g_object_unref (layout); +} + +#else /* GTK_CHECK_VERSION(3,0,0) */ + static void label_size_request_cb (GtkWidget *widget, GtkRequisition *requisition, @@ -1438,6 +1597,7 @@ label_size_request_cb (GtkWidget *widget, g_object_unref (layout); } +#endif /* GTK_CHECK_VERSION(3,0,0) */ static void caja_path_bar_update_button_appearance (ButtonData *button_data) @@ -1872,16 +2032,17 @@ make_directory_button (CajaPathBar *path_bar, button_data->is_base_dir = base_dir; } +#if !GTK_CHECK_VERSION(3,0,0) /* label_alignment is created because we can't override size-request * on label itself and still have the contents of the label centered * properly in the label's requisition */ - if (label_alignment) { g_signal_connect (label_alignment, "size-request", G_CALLBACK (label_size_request_cb), button_data); } +#endif if (button_data->path == NULL) { @@ -1904,6 +2065,18 @@ make_directory_button (CajaPathBar *path_bar, button_data->file_is_hidden = file_is_hidden; +#if GTK_CHECK_VERSION(3,0,0) + /* FIXME: Maybe we dont need this alignment at all and we can + * use GtkMisc aligments or even GtkWidget:halign/valign center. + * + * The following function ensures that the alignment will always + * request the same size whether the button's text is bold or not. + */ + if (label_alignment) { + set_label_size_request (label_alignment, button_data); + } +#endif + gtk_container_add (GTK_CONTAINER (button_data->button), child); gtk_widget_show_all (button_data->button); -- cgit v1.2.1 From 743a7522519fb3c3ac69dae3789d4f0873252779 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 08:25:46 +0200 Subject: [icon-container] remove size_request vfunc impl It doesn't seem to do anything useful. http://git.gnome.org/browse/nautilus/commit/?id=1cdd0b41bf9de69a93cb166636d7eccff9f5355f --- libcaja-private/caja-icon-container.c | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index e88cac74..efda5cab 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -4493,15 +4493,6 @@ finalize (GObject *object) /* GtkWidget methods. */ -static void -size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GTK_WIDGET_CLASS (caja_icon_container_parent_class)->size_request (widget, requisition); - requisition->width = 1; - requisition->height = 1; -} - static gboolean clear_size_allocation_count (gpointer data) { @@ -6588,7 +6579,6 @@ caja_icon_container_class_init (CajaIconContainerClass *class) /* GtkWidget class. */ widget_class = GTK_WIDGET_CLASS (class); - widget_class->size_request = size_request; widget_class->size_allocate = size_allocate; widget_class->realize = realize; widget_class->unrealize = unrealize; -- cgit v1.2.1 From cb95554ed52fc0c5d996de6ae821999d92e15b65 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 08:36:39 +0200 Subject: [window] don't use deprecated size_request vfunc http://git.gnome.org/browse/nautilus/commit/?id=b532d0d9290d1731203d971e7c679979265f0a43 --- src/caja-window.c | 74 ++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 57 insertions(+), 17 deletions(-) diff --git a/src/caja-window.c b/src/caja-window.c index 14c5d5c4..142ae4a1 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -527,30 +527,18 @@ static void caja_window_set_initial_window_geometry (CajaWindow *window) { GdkScreen *screen; - guint max_width_for_screen, max_height_for_screen, min_width, min_height; + guint max_width_for_screen, max_height_for_screen; +#if !GTK_CHECK_VERSION(3,0,0) + guint min_width, min_height; +#endif guint default_width, default_height; screen = gtk_window_get_screen (GTK_WINDOW (window)); - /* Don't let GTK determine the minimum size - * automatically. It will insist that the window be - * really wide based on some misguided notion about - * the content view area. Also, it might start the - * window wider (or taller) than the screen, which - * is evil. So we choose semi-arbitrary initial and - * minimum widths instead of letting GTK decide. - */ - /* FIXME - the above comment suggests that the size request - * of the content view area is wrong, probably because of - * another stupid set_usize someplace. If someone gets the - * content view area's size request right then we can - * probably remove this broken set_size_request() here. - * - hp@redhat.com - */ - max_width_for_screen = get_max_forced_width (screen); max_height_for_screen = get_max_forced_height (screen); +#if !GTK_CHECK_VERSION(3,0,0) EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window, get_min_size, (window, &min_width, &min_height)); @@ -559,6 +547,7 @@ caja_window_set_initial_window_geometry (CajaWindow *window) max_width_for_screen), MIN (min_height, max_height_for_screen)); +#endif EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window, get_default_size, (window, &default_width, &default_height)); @@ -1003,6 +992,51 @@ caja_window_slot_close (CajaWindowSlot *slot) caja_window_pane_slot_close (slot->pane, slot); } +#if GTK_CHECK_VERSION(3,0,0) +static void +caja_window_get_preferred_width (GtkWidget *widget, + gint *minimal_width, + gint *natural_width) +{ + GdkScreen *screen; + gint max_w, min_w, min_h, default_w, default_h; + CajaWindow *window = CAJA_WINDOW (widget); + + screen = gtk_window_get_screen (GTK_WINDOW (widget)); + + max_w = get_max_forced_width (screen); + EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window, + get_min_size, (window, &min_w, &min_h)); + EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window, + get_default_size, (window, &default_w, &default_h)); + + *minimal_width = MIN (min_w, max_w); + *natural_width = MIN (default_w, max_w); +} + +static void +caja_window_get_preferred_height (GtkWidget *widget, + gint *minimal_height, + gint *natural_height) +{ + GdkScreen *screen; + gint max_h, min_w, min_h, default_w, default_h; + CajaWindow *window = CAJA_WINDOW (widget); + + screen = gtk_window_get_screen (GTK_WINDOW (widget)); + + max_h = get_max_forced_height (screen); + EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window, + get_min_size, (window, &min_w, &min_h)); + EEL_CALL_METHOD (CAJA_WINDOW_CLASS, window, + get_default_size, (window, &default_w, &default_h)); + + *minimal_height = MIN (min_h, max_h); + *natural_height = MIN (default_h, max_h); +} + +#else /* GTK_CHECK_VERSION(3,0,0) */ + static void caja_window_size_request (GtkWidget *widget, GtkRequisition *requisition) @@ -1044,6 +1078,7 @@ caja_window_size_request (GtkWidget *widget, requisition->height = max_height; } } +#endif /* GTK_CHECK_VERSION(3,0,0) */ static void caja_window_realize (GtkWidget *widget) @@ -2122,7 +2157,12 @@ caja_window_class_init (CajaWindowClass *class) #endif GTK_WIDGET_CLASS (class)->show = caja_window_show; +#if GTK_CHECK_VERSION(3,0,0) + GTK_WIDGET_CLASS (class)->get_preferred_width = caja_window_get_preferred_width; + GTK_WIDGET_CLASS (class)->get_preferred_height = caja_window_get_preferred_height; +#else GTK_WIDGET_CLASS (class)->size_request = caja_window_size_request; +#endif GTK_WIDGET_CLASS (class)->realize = caja_window_realize; GTK_WIDGET_CLASS (class)->key_press_event = caja_window_key_press_event; class->get_title = real_get_title; -- cgit v1.2.1 From decb73c787a2709f977305a4a6da052227d7b37d Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 8 Nov 2012 08:42:47 +0200 Subject: [editable-label] don't use deprecated size_request vfunc http://git.gnome.org/browse/nautilus/commit/?id=12c7a03bfe3c49078cb5b44ff2651eb9ce1edce4 --- eel/eel-editable-label.c | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c index a934f881..f7ec2d41 100644 --- a/eel/eel-editable-label.c +++ b/eel/eel-editable-label.c @@ -80,8 +80,17 @@ static void eel_editable_label_get_property (GObject GValue *value, GParamSpec *pspec); static void eel_editable_label_finalize (GObject *object); +#if GTK_CHECK_VERSION(3,0,0) +static void eel_editable_label_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural); +static void eel_editable_label_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural); +#else static void eel_editable_label_size_request (GtkWidget *widget, - GtkRequisition *requisition); + GtkRequisition *requisition); +#endif static void eel_editable_label_size_allocate (GtkWidget *widget, GtkAllocation *allocation); static void eel_editable_label_state_changed (GtkWidget *widget, @@ -225,7 +234,12 @@ eel_editable_label_class_init (EelEditableLabelClass *class) gobject_class->get_property = eel_editable_label_get_property; gobject_class->finalize = eel_editable_label_finalize; +#if GTK_CHECK_VERSION(3,0,0) + widget_class->get_preferred_width = eel_editable_label_get_preferred_width; + widget_class->get_preferred_height = eel_editable_label_get_preferred_height; +#else widget_class->size_request = eel_editable_label_size_request; +#endif widget_class->size_allocate = eel_editable_label_size_allocate; widget_class->state_changed = eel_editable_label_state_changed; widget_class->style_set = eel_editable_label_style_set; @@ -1148,6 +1162,32 @@ eel_editable_label_size_request (GtkWidget *widget, requisition->height = height; } +#if GTK_CHECK_VERSION(3,0,0) +static void +eel_editable_label_get_preferred_width (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + GtkRequisition requisition; + + eel_editable_label_size_request (widget, &requisition); + + *minimum = *natural = requisition.width; +} + +static void +eel_editable_label_get_preferred_height (GtkWidget *widget, + gint *minimum, + gint *natural) +{ + GtkRequisition requisition; + + eel_editable_label_size_request (widget, &requisition); + + *minimum = *natural = requisition.height; +} +#endif + static void eel_editable_label_size_allocate (GtkWidget *widget, GtkAllocation *allocation) -- cgit v1.2.1 From 7a42b9b076d6b831c89bd0b9e996368c1c95aef3 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 10:30:31 +0200 Subject: [all] use g_list_free() and g_strcmp0 instead of eel functions Was: general: use g_list_free_full() instead of eel functions http://git.gnome.org/browse/nautilus/commit/?id=5e669515fd7f760382e6b7aa1449734a35a2d7f4 . Instead of g_list_free_full(), we use g_list_foreach and g_list_free() to avoid unnecessary glib dependency bump to 2.28 --- eel/eel-gdk-pixbuf-extensions.c | 12 --- eel/eel-gdk-pixbuf-extensions.h | 2 - eel/eel-glib-extensions.c | 97 +++---------------------- eel/eel-glib-extensions.h | 14 ---- libcaja-private/caja-autorun.c | 4 +- libcaja-private/caja-bookmark.c | 4 +- libcaja-private/caja-clipboard.c | 19 ++--- libcaja-private/caja-customization-data.c | 12 +-- libcaja-private/caja-debug-log.c | 4 +- libcaja-private/caja-directory-async.c | 22 ++++-- libcaja-private/caja-directory.c | 19 +++-- libcaja-private/caja-dnd.c | 7 +- libcaja-private/caja-emblem-utils.c | 4 +- libcaja-private/caja-file-changes-queue.c | 16 ++-- libcaja-private/caja-file-dnd.c | 4 +- libcaja-private/caja-file-operations.c | 24 ++++-- libcaja-private/caja-file-utilities.c | 3 +- libcaja-private/caja-file.c | 28 ++++--- libcaja-private/caja-icon-canvas-item.c | 10 ++- libcaja-private/caja-icon-container.c | 7 +- libcaja-private/caja-merged-directory.c | 3 +- libcaja-private/caja-mime-actions.c | 9 ++- libcaja-private/caja-mime-application-chooser.c | 8 +- libcaja-private/caja-open-with-dialog.c | 4 +- libcaja-private/caja-program-choosing.c | 14 ++-- libcaja-private/caja-progress-info.c | 10 +-- libcaja-private/caja-query.c | 5 +- libcaja-private/caja-search-engine-beagle.c | 4 +- libcaja-private/caja-search-engine-simple.c | 10 ++- libcaja-private/caja-search-engine-tracker.c | 4 +- libcaja-private/caja-undostack-manager.c | 25 ++++--- src/caja-application.c | 3 +- src/caja-bookmark-list.c | 9 ++- src/caja-emblem-sidebar.c | 5 +- src/caja-history-sidebar.c | 5 +- src/caja-information-panel.c | 3 +- src/caja-navigation-window-slot.c | 6 +- src/caja-notes-viewer.c | 5 +- src/caja-pathbar.c | 9 +-- src/caja-places-sidebar.c | 7 +- src/caja-property-browser.c | 10 ++- src/caja-query-editor.c | 4 +- src/caja-spatial-window.c | 4 +- src/caja-trash-bar.c | 3 +- src/caja-window-manage-views.c | 22 ++++-- src/caja-window-slot.c | 3 +- src/caja-window.c | 11 +-- src/file-manager/fm-directory-view.c | 38 +++++++--- src/file-manager/fm-list-model.c | 11 +-- src/file-manager/fm-list-view.c | 6 +- src/file-manager/fm-properties-window.c | 35 +++++---- src/file-manager/fm-tree-model.c | 4 +- src/file-manager/fm-tree-view.c | 11 +-- 53 files changed, 302 insertions(+), 320 deletions(-) diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index fed0eb45..040855b8 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -66,18 +66,6 @@ eel_gdk_pixbuf_list_ref (GList *pixbuf_list) g_list_foreach (pixbuf_list, (GFunc) g_object_ref, NULL); } -/** - * eel_gdk_pixbuf_list_free - * @pixbuf_list: A list of GdkPixbuf objects. - * - * Unrefs all the pixbufs, then frees the list. - **/ -void -eel_gdk_pixbuf_list_free (GList *pixbuf_list) -{ - eel_g_list_free_deep_custom (pixbuf_list, (GFunc) g_object_unref, NULL); -} - GdkPixbuf * eel_gdk_pixbuf_load (const char *uri) { diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h index ae649e55..07a7a0ac 100644 --- a/eel/eel-gdk-pixbuf-extensions.h +++ b/eel/eel-gdk-pixbuf-extensions.h @@ -43,8 +43,6 @@ typedef void (* EelPixbufLoadCallback) (GError *error, /* Convenience functions for lists of GdkPixbuf objects. */ void eel_gdk_pixbuf_list_ref (GList *pixbuf_list); -void eel_gdk_pixbuf_list_unref (GList *pixbuf_list); -void eel_gdk_pixbuf_list_free (GList *pixbuf_list); /* Loading a GdkPixbuf with a URI. */ diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index ea7ecbca..63ac74a7 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -375,63 +375,6 @@ eel_g_str_list_index (GList *str_list, return -1; } -/** - * eel_g_list_free_deep_custom - * - * Frees the elements of a list and then the list, using a custom free function. - * - * @list: List of elements that can be freed with the provided free function. - * @element_free_func: function to call with the data pointer and user_data to free it. - * @user_data: User data to pass to element_free_func - **/ -void -eel_g_list_free_deep_custom (GList *list, GFunc element_free_func, gpointer user_data) -{ - g_list_foreach (list, element_free_func, user_data); - g_list_free (list); -} - -/** - * eel_g_list_free_deep - * - * Frees the elements of a list and then the list. - * @list: List of elements that can be freed with g_free. - **/ -void -eel_g_list_free_deep (GList *list) -{ - eel_g_list_free_deep_custom (list, (GFunc) g_free, NULL); -} - -/** - * eel_g_list_free_deep_custom - * - * Frees the elements of a list and then the list, using a custom free function. - * - * @list: List of elements that can be freed with the provided free function. - * @element_free_func: function to call with the data pointer and user_data to free it. - * @user_data: User data to pass to element_free_func - **/ -void -eel_g_slist_free_deep_custom (GSList *list, GFunc element_free_func, gpointer user_data) -{ - g_slist_foreach (list, element_free_func, user_data); - g_slist_free (list); -} - -/** - * eel_g_slist_free_deep - * - * Frees the elements of a list and then the list. - * @list: List of elements that can be freed with g_free. - **/ -void -eel_g_slist_free_deep (GSList *list) -{ - eel_g_slist_free_deep_custom (list, (GFunc) g_free, NULL); -} - - /** * eel_g_strv_find * @@ -761,31 +704,6 @@ eel_g_object_list_ref (GList *list) return list; } -/** - * eel_g_object_list_unref - * - * Unref all the objects in a list. - * @list: GList of objects. - **/ -void -eel_g_object_list_unref (GList *list) -{ - g_list_foreach (list, (GFunc) g_object_unref, NULL); -} - -/** - * eel_g_object_list_free - * - * Free a list of objects after unrefing them. - * @list: GList of objects. - **/ -void -eel_g_object_list_free (GList *list) -{ - eel_g_object_list_unref (list); - g_list_free (list); -} - /** * eel_g_object_list_copy * @@ -1214,11 +1132,16 @@ eel_self_check_glib_extensions (void) EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_4), FALSE); EEL_CHECK_BOOLEAN_RESULT (eel_g_str_list_equal (compare_list_1, compare_list_5), FALSE); - eel_g_list_free_deep (compare_list_1); - eel_g_list_free_deep (compare_list_2); - eel_g_list_free_deep (compare_list_3); - eel_g_list_free_deep (compare_list_4); - eel_g_list_free_deep (compare_list_5); + g_list_foreach (compare_list_1, (GFunc) g_free, NULL); + g_list_free(compare_list_1); + g_list_foreach (compare_list_2, (GFunc) g_free, NULL); + g_list_free(compare_list_2); + g_list_foreach (compare_list_3, (GFunc) g_free, NULL); + g_list_free(compare_list_3); + g_list_foreach (compare_list_4, (GFunc) g_free, NULL); + g_list_free(compare_list_4); + g_list_foreach (compare_list_5, (GFunc) g_free, NULL); + g_list_free(compare_list_5); /* eel_g_list_partition */ diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index 1a8bd3e8..416ebe2f 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -54,18 +54,6 @@ GList * eel_g_list_partition (GList * gpointer user_data, GList **removed); -/* List functions for lists of g_free'able objects. */ -void eel_g_list_free_deep (GList *list); -void eel_g_list_free_deep_custom (GList *list, - GFunc element_free_func, - gpointer user_data); - -/* List functions for slists of g_free'able objects. */ -void eel_g_slist_free_deep (GSList *list); -void eel_g_slist_free_deep_custom (GSList *list, - GFunc element_free_func, - gpointer user_data); - /* List functions for lists of C strings. */ gboolean eel_g_str_list_equal (GList *str_list_a, GList *str_list_b); @@ -76,8 +64,6 @@ int eel_g_str_list_index (GList * /* List functions for lists of objects */ GList * eel_g_object_list_ref (GList *list); -void eel_g_object_list_unref (GList *list); -void eel_g_object_list_free (GList *list); GList * eel_g_object_list_copy (GList *list); /* GHashTable functions */ diff --git a/libcaja-private/caja-autorun.c b/libcaja-private/caja-autorun.c index 89b8e63d..66534642 100644 --- a/libcaja-private/caja-autorun.c +++ b/libcaja-private/caja-autorun.c @@ -33,7 +33,6 @@ #include #include -#include #include "caja-icon-info.h" #include "caja-global-preferences.h" @@ -652,7 +651,8 @@ caja_autorun_prepare_combo_box (GtkWidget *combo_box, { g_object_unref (default_app_info); } - eel_g_object_list_free (app_info_list); + g_list_foreach (app_info_list, (GFunc) g_object_unref, NULL); + g_list_free(app_info_list); gtk_combo_box_set_model (GTK_COMBO_BOX (combo_box), GTK_TREE_MODEL (list_store)); g_object_unref (G_OBJECT (list_store)); diff --git a/libcaja-private/caja-bookmark.c b/libcaja-private/caja-bookmark.c index e20efd96..48952fbb 100644 --- a/libcaja-private/caja-bookmark.c +++ b/libcaja-private/caja-bookmark.c @@ -29,10 +29,10 @@ #include #include #include -#include #include #include #include +#include #include #include @@ -143,7 +143,7 @@ caja_bookmark_compare_with (gconstpointer a, gconstpointer b) bookmark_a = CAJA_BOOKMARK (a); bookmark_b = CAJA_BOOKMARK (b); - if (eel_strcmp (bookmark_a->details->name, + if (g_strcmp0 (bookmark_a->details->name, bookmark_b->details->name) != 0) { return 1; diff --git a/libcaja-private/caja-clipboard.c b/libcaja-private/caja-clipboard.c index bc06675a..bce5d552 100644 --- a/libcaja-private/caja-clipboard.c +++ b/libcaja-private/caja-clipboard.c @@ -33,7 +33,6 @@ #include #include -#include #include typedef struct _TargetCallbackData TargetCallbackData; @@ -662,31 +661,27 @@ caja_clipboard_clear_if_colliding_uris (GtkWidget *widget, collision = FALSE; data = gtk_clipboard_wait_for_contents (caja_clipboard_get (widget), copied_files_atom); - if (data == NULL) - { + if (data == NULL) { return; } clipboard_item_uris = caja_clipboard_get_uri_list_from_selection_data (data, NULL, copied_files_atom); - for (l = (GList *) item_uris; l; l = l->next) - { + for (l = (GList *) item_uris; l; l = l->next) { if (g_list_find_custom ((GList *) item_uris, l->data, - (GCompareFunc) g_strcmp0)) - { + (GCompareFunc) g_strcmp0)) { collision = TRUE; break; } } - if (collision) - { + if (collision) { gtk_clipboard_clear (caja_clipboard_get (widget)); } - if (clipboard_item_uris) - { - eel_g_list_free_deep (clipboard_item_uris); + if (clipboard_item_uris) { + g_list_foreach (clipboard_item_uris, (GFunc) g_free, NULL); + g_list_free(clipboard_item_uris); } } diff --git a/libcaja-private/caja-customization-data.c b/libcaja-private/caja-customization-data.c index aeeab942..01521d0a 100644 --- a/libcaja-private/caja-customization-data.c +++ b/libcaja-private/caja-customization-data.c @@ -32,10 +32,8 @@ #include #include #include -#include #include #include -#include #include #include #include @@ -260,7 +258,7 @@ caja_customization_data_get_next_element_for_display (CajaCustomizationData *dat label_out); } - is_reset_image = eel_strcmp(g_file_info_get_name (current_file_info), RESET_IMAGE_NAME) == 0; + is_reset_image = g_strcmp0(g_file_info_get_name (current_file_info), RESET_IMAGE_NAME) == 0; *emblem_name = g_strdup (g_file_info_get_name (current_file_info)); @@ -306,8 +304,10 @@ caja_customization_data_destroy (CajaCustomizationData *data) g_object_unref (data->pattern_frame); } - eel_g_object_list_free (data->public_file_list); - eel_g_object_list_free (data->private_file_list); + g_list_foreach(data->public_file_list, (GFunc) g_object_unref, NULL); + g_list_free(data->public_file_list); + g_list_foreach(data->private_file_list, (GFunc) g_object_unref, NULL); + g_list_free(data->private_file_list); if (data->name_map_hash != NULL) { @@ -427,7 +427,7 @@ format_name_for_display (CajaCustomizationData *data, const char* name) { char *formatted_str, *mapped_name; - if (!eel_strcmp(name, RESET_IMAGE_NAME)) + if (!g_strcmp0(name, RESET_IMAGE_NAME)) { return g_strdup (_("Reset")); } diff --git a/libcaja-private/caja-debug-log.c b/libcaja-private/caja-debug-log.c index 89ff6933..1ccfed0b 100644 --- a/libcaja-private/caja-debug-log.c +++ b/libcaja-private/caja-debug-log.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "caja-debug-log.h" #include "caja-file.h" @@ -309,7 +308,8 @@ caja_debug_log_with_file_list (gboolean is_milestone, const char *domain, GList caja_debug_logv (is_milestone, domain, uris, format, args); va_end (args); - eel_g_list_free_deep (uris); + g_list_foreach (uris, (GFunc) g_free, NULL); + g_list_free(uris); } gboolean diff --git a/libcaja-private/caja-directory-async.c b/libcaja-private/caja-directory-async.c index a20d90d7..9694b1b0 100644 --- a/libcaja-private/caja-directory-async.c +++ b/libcaja-private/caja-directory-async.c @@ -34,7 +34,6 @@ #include "caja-link.h" #include "caja-marshal.h" #include -#include #include #include #include @@ -1080,7 +1079,8 @@ dequeue_pending_idle_callback (gpointer callback_data) file->details->got_mime_list = TRUE; file->details->mime_list_is_up_to_date = TRUE; - eel_g_list_free_deep (file->details->mime_list); + g_list_foreach (file->details->mime_list, (GFunc) g_free, NULL); + g_list_free(file->details->mime_list); file->details->mime_list = istr_set_get_as_list (dir_load_state->load_mime_list_hash); @@ -1093,7 +1093,8 @@ dequeue_pending_idle_callback (gpointer callback_data) } drain: - eel_g_object_list_free (pending_file_info); + g_list_foreach (pending_file_info, (GFunc) g_object_unref, NULL); + g_list_free(pending_file_info); /* Get the state machine running again. */ caja_directory_async_state_changed (directory); @@ -1181,7 +1182,8 @@ file_list_cancel (CajaDirectory *directory) if (directory->details->pending_file_info != NULL) { - eel_g_object_list_free (directory->details->pending_file_info); + g_list_foreach (directory->details->pending_file_info, (GFunc) g_object_unref, NULL); + g_list_free(directory->details->pending_file_info); directory->details->pending_file_info = NULL; } @@ -2786,7 +2788,8 @@ count_more_files_callback (GObject *source_object, state); } - eel_g_object_list_free (files); + g_list_foreach (files, (GFunc) g_object_unref, NULL); + g_list_free(files); if (error) { @@ -3011,7 +3014,8 @@ deep_count_state_free (DeepCountState *state) { g_object_unref (state->deep_count_location); } - eel_g_object_list_free (state->deep_count_subdirectories); + g_list_foreach (state->deep_count_subdirectories, (GFunc) g_object_unref, NULL); + g_list_free(state->deep_count_subdirectories); g_array_free (state->seen_deep_count_inodes, TRUE); g_free (state); } @@ -3319,7 +3323,8 @@ mime_list_done (MimeListState *state, gboolean success) file = state->mime_list_file; file->details->mime_list_is_up_to_date = TRUE; - eel_g_list_free_deep (file->details->mime_list); + g_list_foreach(file->details->mime_list, (GFunc) g_free, NULL); + g_list_free(file->details->mime_list); if (success) { file->details->mime_list_failed = TRUE; @@ -4574,7 +4579,8 @@ get_mount_at (GFile *target) g_object_unref (root); } - eel_g_object_list_free (mounts); + g_list_foreach (mounts, (GFunc) g_object_unref, NULL); + g_list_free(mounts); g_object_unref (monitor); diff --git a/libcaja-private/caja-directory.c b/libcaja-private/caja-directory.c index efcfc5ed..38d73794 100644 --- a/libcaja-private/caja-directory.c +++ b/libcaja-private/caja-directory.c @@ -37,8 +37,8 @@ #include "caja-vfs-directory.h" #include #include -#include #include +#include enum { @@ -175,7 +175,8 @@ caja_directory_finalize (GObject *object) if (directory->details->monitor_list != NULL) { g_warning ("destroying a CajaDirectory while it's being monitored"); - eel_g_list_free_deep (directory->details->monitor_list); + g_list_foreach(directory->details->monitor_list, (GFunc) g_free, NULL); + g_list_free(directory->details->monitor_list); } if (directory->details->monitor != NULL) @@ -212,7 +213,8 @@ caja_directory_finalize (GObject *object) g_assert (directory->details->directory_load_in_progress == NULL); g_assert (directory->details->count_in_progress == NULL); g_assert (directory->details->dequeue_pending_idle_id == 0); - eel_g_object_list_free (directory->details->pending_file_info); + g_list_foreach(directory->details->pending_file_info, (GFunc) g_object_unref, NULL); + g_list_free(directory->details->pending_file_info); EEL_CALL_PARENT (G_OBJECT_CLASS, finalize, (object)); } @@ -758,7 +760,7 @@ caja_directory_find_file_by_internal_filename (CajaDirectory *directory, { CajaFile *result; - if (eel_strcmp (internal_filename, ".") == 0) + if (g_strcmp0 (internal_filename, ".") == 0) { result = caja_directory_get_existing_corresponding_file (directory); if (result != NULL) @@ -1092,7 +1094,8 @@ caja_directory_notify_files_added_by_uri (GList *uris) files = caja_file_list_from_uris (uris); caja_directory_notify_files_added (files); - eel_g_object_list_free (files); + g_list_foreach(files, (GFunc) g_object_unref, NULL); + g_list_free(files); } void @@ -1141,7 +1144,8 @@ caja_directory_notify_files_changed_by_uri (GList *uris) files = caja_file_list_from_uris (uris); caja_directory_notify_files_changed (files); - eel_g_object_list_free (files); + g_list_foreach(files, (GFunc) g_object_unref, NULL); + g_list_free(files); } void @@ -1202,7 +1206,8 @@ caja_directory_notify_files_removed_by_uri (GList *uris) files = caja_file_list_from_uris (uris); caja_directory_notify_files_changed (files); - eel_g_object_list_free (files); + g_list_foreach(files, (GFunc) g_object_unref, NULL); + g_list_free(files); } static void diff --git a/libcaja-private/caja-dnd.c b/libcaja-private/caja-dnd.c index 87617a77..feea5ca8 100644 --- a/libcaja-private/caja-dnd.c +++ b/libcaja-private/caja-dnd.c @@ -129,7 +129,8 @@ caja_drag_uri_array_from_selection_list (const GList *selection_list) uri_list = caja_drag_uri_list_from_selection_list (selection_list); uris = caja_drag_uri_array_from_list (uri_list); - eel_g_list_free_deep (uri_list); + g_list_foreach(uri_list, (GFunc) g_free, NULL); + g_list_free(uri_list); return uris; } @@ -1315,7 +1316,9 @@ slot_proxy_handle_drop (GtkWidget *widget, uri_list, target_uri, gdk_drag_context_get_selected_action (context)); - eel_g_list_free_deep (uri_list); + g_list_foreach(uri_list, (GFunc) g_free, NULL); + g_list_free(uri_list); + } else if (drag_info->info == CAJA_ICON_DND_URI_LIST) { diff --git a/libcaja-private/caja-emblem-utils.c b/libcaja-private/caja-emblem-utils.c index 3c41a016..dd70dbc3 100644 --- a/libcaja-private/caja-emblem-utils.c +++ b/libcaja-private/caja-emblem-utils.c @@ -37,7 +37,6 @@ #include #include -#include #include #include @@ -120,7 +119,8 @@ is_reserved_keyword (const char *keyword) result = g_list_find_custom (available, (char *) icon_name, (GCompareFunc) g_ascii_strcasecmp) != NULL; - eel_g_list_free_deep (available); + g_list_foreach(available, (GFunc) g_free, NULL); + g_list_free(available); g_free (icon_name); return result; } diff --git a/libcaja-private/caja-file-changes-queue.c b/libcaja-private/caja-file-changes-queue.c index b3cd1db0..39cf123e 100644 --- a/libcaja-private/caja-file-changes-queue.c +++ b/libcaja-private/caja-file-changes-queue.c @@ -24,7 +24,6 @@ #include "caja-file-changes-queue.h" #include "caja-directory-notify.h" -#include #ifdef G_THREADS_ENABLED #define MUTEX_LOCK(a) if ((a) != NULL) g_mutex_lock (a) @@ -289,7 +288,8 @@ pairs_list_free (GList *pairs) } /* delete the list and the now empty pair structs */ - eel_g_list_free_deep (pairs); + g_list_foreach(pairs, (GFunc) g_free, NULL); + g_list_free(pairs); } static void @@ -304,7 +304,8 @@ position_set_list_free (GList *list) g_object_unref (item->location); } /* delete the list and the now empty structs */ - eel_g_list_free_deep (list); + g_list_foreach(list, (GFunc) g_free, NULL); + g_list_free(list); } /* go through changes in the change queue, send ones with the same kind @@ -386,7 +387,8 @@ caja_file_changes_consume_changes (gboolean consume_all) { deletions = g_list_reverse (deletions); caja_directory_notify_files_removed (deletions); - eel_g_object_list_free (deletions); + g_list_foreach(deletions, (GFunc) g_object_unref, NULL); + g_list_free(deletions); deletions = NULL; } if (moves != NULL) @@ -400,14 +402,16 @@ caja_file_changes_consume_changes (gboolean consume_all) { additions = g_list_reverse (additions); caja_directory_notify_files_added (additions); - eel_g_object_list_free (additions); + g_list_foreach(additions, (GFunc) g_object_unref, NULL); + g_list_free(additions); additions = NULL; } if (changes != NULL) { changes = g_list_reverse (changes); caja_directory_notify_files_changed (changes); - eel_g_object_list_free (changes); + g_list_foreach(changes, (GFunc) g_object_unref, NULL); + g_list_free(changes); changes = NULL; } if (position_set_requests != NULL) diff --git a/libcaja-private/caja-file-dnd.c b/libcaja-private/caja-file-dnd.c index a44d42f3..2c239643 100644 --- a/libcaja-private/caja-file-dnd.c +++ b/libcaja-private/caja-file-dnd.c @@ -30,7 +30,6 @@ #include "caja-dnd.h" #include "caja-directory.h" #include "caja-file-utilities.h" -#include #include static gboolean @@ -182,5 +181,6 @@ caja_drag_file_receive_dropped_keyword (CajaFile *file, } caja_file_set_keywords (file, keywords); - eel_g_list_free_deep (keywords); + g_list_foreach(keywords, (GFunc) g_free, NULL); + g_list_free(keywords); } diff --git a/libcaja-private/caja-file-operations.c b/libcaja-private/caja-file-operations.c index 24bb4a19..067f52d5 100644 --- a/libcaja-private/caja-file-operations.c +++ b/libcaja-private/caja-file-operations.c @@ -1858,7 +1858,8 @@ delete_job_done (gpointer user_data) job = user_data; - eel_g_object_list_free (job->files); + g_list_foreach(job->files, (GFunc) g_object_unref, NULL); + g_list_free(job->files); if (job->done_callback) { debuting_uris = g_hash_table_new_full (g_file_hash, (GEqualFunc)g_file_equal, g_object_unref, NULL); @@ -2187,7 +2188,8 @@ has_trash_files (GMount *mount) } } - eel_g_object_list_free (dirs); + g_list_foreach(dirs, (GFunc) g_object_unref, NULL); + g_list_free(dirs); return res; } @@ -4460,7 +4462,8 @@ copy_job_done (gpointer user_data) job->done_callback (job->debuting_files, job->done_callback_data); } - eel_g_object_list_free (job->files); + g_list_foreach(job->files, (GFunc) g_object_unref, NULL); + g_list_free(job->files); if (job->destination) { g_object_unref (job->destination); } @@ -4987,7 +4990,8 @@ move_job_done (gpointer user_data) job->done_callback (job->debuting_files, job->done_callback_data); } - eel_g_object_list_free (job->files); + g_list_foreach(job->files, (GFunc) g_object_unref, NULL); + g_list_free(job->files); g_object_unref (job->destination); g_hash_table_unref (job->debuting_files); g_free (job->icon_positions); @@ -5067,7 +5071,8 @@ move_job (GIOSchedulerJob *io_job, &source_info, &transfer_info); aborted: - eel_g_list_free_deep (fallbacks); + g_list_foreach(fallbacks, (GFunc) g_free, NULL); + g_list_free(fallbacks); g_free (dest_fs_id); g_free (dest_fs_type); @@ -5321,7 +5326,8 @@ link_job_done (gpointer user_data) job->done_callback (job->debuting_files, job->done_callback_data); } - eel_g_object_list_free (job->files); + g_list_foreach(job->files, (GFunc) g_object_unref, NULL); + g_list_free(job->files); g_object_unref (job->destination); g_hash_table_unref (job->debuting_files); g_free (job->icon_positions); @@ -5773,7 +5779,8 @@ caja_file_operations_copy_move (const GList *item_uris, done_callback, done_callback_data); } - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); if (dest) { g_object_unref (dest); } @@ -6251,7 +6258,8 @@ empty_trash_job_done (gpointer user_data) job = user_data; - eel_g_object_list_free (job->trash_dirs); + g_list_foreach(job->trash_dirs, (GFunc) g_object_unref, NULL); + g_list_free(job->trash_dirs); if (job->done_callback) { job->done_callback (job->done_callback_data); diff --git a/libcaja-private/caja-file-utilities.c b/libcaja-private/caja-file-utilities.c index 61ad5c47..bfe8321e 100644 --- a/libcaja-private/caja-file-utilities.c +++ b/libcaja-private/caja-file-utilities.c @@ -1428,7 +1428,8 @@ caja_restore_files_from_trash (GList *files, parent_window, NULL, NULL); - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); g_object_unref (original_dir_location); } diff --git a/libcaja-private/caja-file.c b/libcaja-private/caja-file.c index 31863c9c..788eec68 100644 --- a/libcaja-private/caja-file.c +++ b/libcaja-private/caja-file.c @@ -816,11 +816,14 @@ finalize (GObject *object) eel_ref_str_unref (file->details->filesystem_id); - eel_g_list_free_deep (file->details->mime_list); - - eel_g_list_free_deep (file->details->pending_extension_emblems); - eel_g_list_free_deep (file->details->extension_emblems); - eel_g_object_list_free (file->details->pending_info_providers); + g_list_foreach(file->details->mime_list, (GFunc) g_free, NULL); + g_list_free(file->details->mime_list); + g_list_foreach(file->details->pending_extension_emblems, (GFunc) g_free, NULL); + g_list_free(file->details->pending_extension_emblems); + g_list_foreach(file->details->extension_emblems, (GFunc) g_free, NULL); + g_list_free(file->details->extension_emblems); + g_list_foreach(file->details->pending_info_providers, (GFunc) g_object_unref, NULL); + g_list_free(file->details->pending_info_providers); if (file->details->pending_extension_attributes) { g_hash_table_destroy (file->details->pending_extension_attributes); @@ -2994,7 +2997,8 @@ fill_emblem_cache_if_needed (CajaFile *file) /* Zero-terminate so we can tell where the list ends. */ *scanner = 0; - eel_g_list_free_deep (keywords); + g_list_foreach(keywords, (GFunc) g_free, NULL); + g_list_free(keywords); } static int @@ -6601,7 +6605,8 @@ caja_file_get_emblem_icons (CajaFile *file, icons = g_list_prepend (icons, icon); } - eel_g_list_free_deep (keywords); + g_list_foreach(keywords, (GFunc) g_free, NULL); + g_list_free(keywords); return icons; } @@ -6660,7 +6665,8 @@ sort_keyword_list_and_remove_duplicates (GList *keywords) if (strcmp ((const char *) p->data, (const char *) p->next->data) == 0) { duplicate_link = p->next; keywords = g_list_remove_link (keywords, duplicate_link); - eel_g_list_free_deep (duplicate_link); + g_list_foreach(duplicate_link, (GFunc) g_free, NULL); + g_list_free(duplicate_link); } else { p = p->next; } @@ -7554,7 +7560,8 @@ void caja_file_invalidate_extension_info_internal (CajaFile *file) { if (file->details->pending_info_providers) - eel_g_object_list_free (file->details->pending_info_providers); + g_list_foreach(file->details->pending_info_providers, (GFunc) g_object_unref, NULL); + g_list_free(file->details->pending_info_providers); file->details->pending_info_providers = caja_module_get_extensions_for_type (CAJA_TYPE_INFO_PROVIDER); @@ -8376,7 +8383,8 @@ caja_file_invalidate_extension_info (CajaFile *file) void caja_file_info_providers_done (CajaFile *file) { - eel_g_list_free_deep (file->details->extension_emblems); + g_list_foreach(file->details->extension_emblems, (GFunc) g_free, NULL); + g_list_free(file->details->extension_emblems); file->details->extension_emblems = file->details->pending_extension_emblems; file->details->pending_extension_emblems = NULL; diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index 9f6992cf..bcec72a5 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -327,7 +327,8 @@ caja_icon_canvas_item_finalize (GObject *object) g_object_unref (details->text_util); } - eel_gdk_pixbuf_list_free (details->emblem_pixbufs); + g_list_foreach(details->emblem_pixbufs, (GFunc) g_object_unref, NULL); + g_list_free(details->emblem_pixbufs); g_free (details->editable_text); g_free (details->additional_text); g_free (details->attach_points); @@ -419,7 +420,7 @@ caja_icon_canvas_item_set_property (GObject *object, { case PROP_EDITABLE_TEXT: - if (eel_strcmp (details->editable_text, + if (g_strcmp0 (details->editable_text, g_value_get_string (value)) == 0) { return; @@ -446,7 +447,7 @@ caja_icon_canvas_item_set_property (GObject *object, break; case PROP_ADDITIONAL_TEXT: - if (eel_strcmp (details->additional_text, + if (g_strcmp0 (details->additional_text, g_value_get_string (value)) == 0) { return; @@ -763,7 +764,8 @@ caja_icon_canvas_item_set_emblems (CajaIconCanvasItem *item, /* Take in the new list of emblems. */ eel_gdk_pixbuf_list_ref (emblem_pixbufs); - eel_gdk_pixbuf_list_free (item->details->emblem_pixbufs); + g_list_foreach(item->details->emblem_pixbufs, (GFunc) g_object_unref, NULL); + g_list_free(item->details->emblem_pixbufs); item->details->emblem_pixbufs = g_list_copy (emblem_pixbufs); caja_icon_canvas_item_invalidate_bounds_cache (item); diff --git a/libcaja-private/caja-icon-container.c b/libcaja-private/caja-icon-container.c index efda5cab..6b2f18e8 100644 --- a/libcaja-private/caja-icon-container.c +++ b/libcaja-private/caja-icon-container.c @@ -7775,7 +7775,7 @@ caja_icon_container_update_icon (CajaIconContainer *container, * happened to be typing at that moment. */ if (icon == get_icon_being_renamed (container) && - eel_strcmp (editable_text, + g_strcmp0 (editable_text, caja_icon_canvas_item_get_editable_text (icon->item)) != 0) { end_renaming_mode (container, FALSE); @@ -7795,7 +7795,8 @@ caja_icon_container_update_icon (CajaIconContainer *container, /* Let the pixbufs go. */ g_object_unref (pixbuf); - eel_gdk_pixbuf_list_free (emblem_pixbufs); + g_list_foreach(emblem_pixbufs, (GFunc) g_object_unref, NULL); + g_list_free(emblem_pixbufs); g_free (editable_text); g_free (additional_text); @@ -9678,7 +9679,7 @@ caja_icon_container_set_font (CajaIconContainer *container, { g_return_if_fail (CAJA_IS_ICON_CONTAINER (container)); - if (eel_strcmp (container->details->font, font) == 0) + if (g_strcmp0 (container->details->font, font) == 0) { return; } diff --git a/libcaja-private/caja-merged-directory.c b/libcaja-private/caja-merged-directory.c index 0dc1b10c..a3e2a9b2 100644 --- a/libcaja-private/caja-merged-directory.c +++ b/libcaja-private/caja-merged-directory.c @@ -589,7 +589,8 @@ real_directory_notify_files_removed (CajaDirectory *real_directory) caja_directory_notify_files_removed_by_uri (files); } - eel_g_list_free_deep (files); + g_list_foreach(files, (GFunc) g_free, NULL); + g_list_free(files); } static void diff --git a/libcaja-private/caja-mime-actions.c b/libcaja-private/caja-mime-actions.c index 794c84b0..4668e0ac 100644 --- a/libcaja-private/caja-mime-actions.c +++ b/libcaja-private/caja-mime-actions.c @@ -230,7 +230,8 @@ static void application_launch_parameters_free (ApplicationLaunchParameters *parameters) { g_object_unref (parameters->application); - eel_g_list_free_deep (parameters->uris); + g_list_foreach(parameters->uris, (GFunc) g_free, NULL); + g_list_free(parameters->uris); g_free (parameters); } @@ -512,7 +513,8 @@ caja_mime_has_any_applications_for_file (CajaFile *file) if (apps) { result = TRUE; - eel_g_object_list_free (apps); + g_list_foreach(apps, (GFunc) g_object_unref, NULL); + g_list_free(apps); } else { @@ -733,7 +735,8 @@ trash_or_delete_files (GtkWindow *parent_window, caja_file_operations_trash_or_delete (locations, parent_window, NULL, NULL); - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); } static void diff --git a/libcaja-private/caja-mime-application-chooser.c b/libcaja-private/caja-mime-application-chooser.c index 32767f38..dd8af544 100644 --- a/libcaja-private/caja-mime-application-chooser.c +++ b/libcaja-private/caja-mime-application-chooser.c @@ -32,8 +32,6 @@ #include "caja-signaller.h" #include "caja-file.h" #include -#include -#include #include #include @@ -565,7 +563,8 @@ refresh_model (CajaMimeApplicationChooser *chooser) g_object_unref (default_app); } - eel_g_object_list_free (applications); + g_list_foreach(applications, (GFunc) g_object_unref, NULL); + g_list_free(applications); } static void @@ -673,8 +672,7 @@ set_uri_and_type_for_multiple_files (CajaMimeApplicationChooser *chooser, char *extension_current; extension_current = get_extension_from_file (CAJA_FILE (iter->data)); - if (eel_strcmp (first_extension, extension_current)) - { + if (g_strcmp0 (first_extension, extension_current)) { same_extension = FALSE; g_free (extension_current); break; diff --git a/libcaja-private/caja-open-with-dialog.c b/libcaja-private/caja-open-with-dialog.c index 93e376c9..50ca03ef 100644 --- a/libcaja-private/caja-open-with-dialog.c +++ b/libcaja-private/caja-open-with-dialog.c @@ -29,7 +29,6 @@ #include "caja-open-with-dialog.h" #include "caja-signaller.h" -#include #include #include @@ -291,7 +290,8 @@ add_or_find_application (CajaOpenWithDialog *dialog) if (applications != NULL) { - eel_g_object_list_free (applications); + g_list_foreach(applications, (GFunc) g_object_unref, NULL); + g_list_free(applications); } } diff --git a/libcaja-private/caja-program-choosing.c b/libcaja-private/caja-program-choosing.c index 56d6e8eb..f7b3fa42 100644 --- a/libcaja-private/caja-program-choosing.c +++ b/libcaja-private/caja-program-choosing.c @@ -31,10 +31,8 @@ #include "caja-icon-info.h" #include "caja-recent.h" #include "caja-desktop-icon-file.h" -#include #include #include -#include #include #include #include @@ -165,7 +163,8 @@ caja_launch_application (GAppInfo *application, uris = g_list_reverse (uris); caja_launch_application_by_uri (application, uris, parent_window); - eel_g_list_free_deep (uris); + g_list_foreach(uris, (GFunc) g_free, NULL); + g_list_free(uris); } void @@ -274,7 +273,8 @@ caja_launch_application_by_uri (GAppInfo *application, } } - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); } /** @@ -450,7 +450,8 @@ caja_launch_desktop_file (GdkScreen *screen, " drop them again."), parent_window); - eel_g_object_list_free (files); + g_list_foreach(files, (GFunc) g_object_unref, NULL); + g_list_free(files); g_object_unref (app_info); return; } @@ -502,7 +503,8 @@ caja_launch_desktop_file (GdkScreen *screen, g_free (message); } - eel_g_object_list_free (files); + g_list_foreach(files, (GFunc) g_object_unref, NULL); + g_list_free(files); g_object_unref (context); g_object_unref (app_info); } diff --git a/libcaja-private/caja-progress-info.c b/libcaja-private/caja-progress-info.c index b547ead8..789b5de0 100644 --- a/libcaja-private/caja-progress-info.c +++ b/libcaja-private/caja-progress-info.c @@ -26,9 +26,9 @@ #include #include #include -#include #include #include "caja-progress-info.h" +#include enum { @@ -800,7 +800,7 @@ caja_progress_info_take_status (CajaProgressInfo *info, { G_LOCK (progress_info); - if (eel_strcmp (info->status, status) != 0) + if (g_strcmp0 (info->status, status) != 0) { g_free (info->status); info->status = status; @@ -822,7 +822,7 @@ caja_progress_info_set_status (CajaProgressInfo *info, { G_LOCK (progress_info); - if (eel_strcmp (info->status, status) != 0) + if (g_strcmp0 (info->status, status) != 0) { g_free (info->status); info->status = g_strdup (status); @@ -841,7 +841,7 @@ caja_progress_info_take_details (CajaProgressInfo *info, { G_LOCK (progress_info); - if (eel_strcmp (info->details, details) != 0) + if (g_strcmp0 (info->details, details) != 0) { g_free (info->details); info->details = details; @@ -863,7 +863,7 @@ caja_progress_info_set_details (CajaProgressInfo *info, { G_LOCK (progress_info); - if (eel_strcmp (info->details, details) != 0) + if (g_strcmp0 (info->details, details) != 0) { g_free (info->details); info->details = g_strdup (details); diff --git a/libcaja-private/caja-query.c b/libcaja-private/caja-query.c index 42804eda..9c6044af 100644 --- a/libcaja-private/caja-query.c +++ b/libcaja-private/caja-query.c @@ -118,7 +118,10 @@ caja_query_get_mime_types (CajaQuery *query) void caja_query_set_mime_types (CajaQuery *query, GList *mime_types) { - eel_g_list_free_deep (query->details->mime_types); + g_list_foreach(query->details->mime_types, (GFunc) g_free, NULL); + g_list_free(query->details->mime_types); + g_list_foreach(query->details->mime_types, (GFunc) g_free, NULL); + g_list_free(query->details->mime_types); query->details->mime_types = eel_g_str_list_copy (mime_types); } diff --git a/libcaja-private/caja-search-engine-beagle.c b/libcaja-private/caja-search-engine-beagle.c index 0a2c34ff..6e59b060 100644 --- a/libcaja-private/caja-search-engine-beagle.c +++ b/libcaja-private/caja-search-engine-beagle.c @@ -25,7 +25,6 @@ #include "caja-search-engine-beagle.h" #include -#include #include typedef struct _BeagleHit BeagleHit; @@ -342,7 +341,8 @@ caja_search_engine_beagle_start (CajaSearchEngine *engine) /* These must live during the lifetime of the query */ g_free (text); - eel_g_list_free_deep (mimetypes); + g_list_foreach(mimetypes, (GFunc) g_free, NULL); + g_list_free(mimetypes); } static void diff --git a/libcaja-private/caja-search-engine-simple.c b/libcaja-private/caja-search-engine-simple.c index 5e906334..cf50497f 100644 --- a/libcaja-private/caja-search-engine-simple.c +++ b/libcaja-private/caja-search-engine-simple.c @@ -28,7 +28,6 @@ #include #include -#include #include #define BATCH_SIZE 500 @@ -138,8 +137,10 @@ search_thread_data_free (SearchThreadData *data) g_hash_table_destroy (data->visited); g_object_unref (data->cancellable); g_strfreev (data->words); - eel_g_list_free_deep (data->mime_types); - eel_g_list_free_deep (data->uri_hits); + g_list_foreach(data->mime_types, (GFunc) g_free, NULL); + g_list_free(data->mime_types); + g_list_foreach(data->uri_hits, (GFunc) g_free, NULL); + g_list_free(data->uri_hits); g_free (data); } @@ -181,7 +182,8 @@ search_thread_add_hits_idle (gpointer user_data) hits->uris); } - eel_g_list_free_deep (hits->uris); + g_list_foreach(hits->uris, (GFunc) g_free, NULL); + g_list_free(hits->uris); g_free (hits); return FALSE; diff --git a/libcaja-private/caja-search-engine-tracker.c b/libcaja-private/caja-search-engine-tracker.c index ea56a924..e47af045 100644 --- a/libcaja-private/caja-search-engine-tracker.c +++ b/libcaja-private/caja-search-engine-tracker.c @@ -24,7 +24,6 @@ #include #include "caja-search-engine-tracker.h" #include -#include #include #include @@ -462,7 +461,8 @@ caja_search_engine_tracker_start (CajaSearchEngine *engine) tracker->details->query_pending = TRUE; g_free (search_text); - eel_g_list_free_deep (mimetypes); + g_list_foreach(mimetypes, (GFunc) g_free, NULL); + g_list_free(mimetypes); } static void diff --git a/libcaja-private/caja-undostack-manager.c b/libcaja-private/caja-undostack-manager.c index 465e35e1..0a19934e 100644 --- a/libcaja-private/caja-undostack-manager.c +++ b/libcaja-private/caja-undostack-manager.c @@ -33,7 +33,6 @@ #include #include #include -#include /* ***************************************************************** Private fields @@ -432,7 +431,8 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager, uris = construct_gfile_list (action->sources, action->src_dir); caja_file_operations_copy (uris, NULL, action->dest_dir, NULL, undo_redo_done_transfer_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); break; case CAJA_UNDOSTACK_CREATEFILEFROMTEMPLATE: puri = get_uri_parent (action->target_uri); @@ -448,14 +448,16 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager, uris = construct_gfile_list (action->sources, action->src_dir); caja_file_operations_duplicate (uris, NULL, NULL, undo_redo_done_transfer_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); break; case CAJA_UNDOSTACK_RESTOREFROMTRASH: case CAJA_UNDOSTACK_MOVE: uris = construct_gfile_list (action->sources, action->src_dir); caja_file_operations_move (uris, NULL, action->dest_dir, NULL, undo_redo_done_transfer_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); break; case CAJA_UNDOSTACK_RENAME: new_name = get_uri_basename (action->new_uri); @@ -489,14 +491,16 @@ caja_undostack_manager_redo (CajaUndoStackManager * manager, caja_file_operations_trash_or_delete (uris, NULL, undo_redo_done_delete_callback, action); g_list_free (uri_to_trash); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); } break; case CAJA_UNDOSTACK_CREATELINK: uris = construct_gfile_list (action->sources, action->src_dir); caja_file_operations_link (uris, NULL, action->dest_dir, NULL, undo_redo_done_transfer_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); break; case CAJA_UNDOSTACK_SETPERMISSIONS: file = caja_file_get_by_uri (action->target_uri); @@ -579,7 +583,8 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager, if (priv->confirm_delete) { caja_file_operations_delete (uris, NULL, undo_redo_done_delete_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); } else { /* We skip the confirmation message */ @@ -600,7 +605,8 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager, uris = construct_gfile_list (action->destinations, action->dest_dir); caja_file_operations_trash_or_delete (uris, NULL, undo_redo_done_delete_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); break; case CAJA_UNDOSTACK_MOVETOTRASH: files_to_restore = retrieve_files_to_restore (action->trashed); @@ -630,7 +636,8 @@ caja_undostack_manager_undo (CajaUndoStackManager * manager, uris = construct_gfile_list (action->destinations, action->dest_dir); caja_file_operations_move (uris, NULL, action->src_dir, NULL, undo_redo_done_transfer_callback, action); - eel_g_object_list_free (uris); + g_list_foreach(uris, (GFunc) g_object_unref, NULL); + g_list_free(uris); break; case CAJA_UNDOSTACK_RENAME: new_name = get_uri_basename (action->old_uri); diff --git a/src/caja-application.c b/src/caja-application.c index 978af2d6..edba1d5c 100644 --- a/src/caja-application.c +++ b/src/caja-application.c @@ -257,7 +257,8 @@ automount_all_volumes (CajaApplication *application) /* pass NULL as GMountOperation to avoid user interaction */ g_volume_mount (volume, 0, NULL, NULL, startup_volume_mount_cb, NULL); } - eel_g_object_list_free (volumes); + g_list_foreach(volumes, (GFunc) g_object_unref, NULL); + g_list_free(volumes); } } diff --git a/src/caja-bookmark-list.c b/src/caja-bookmark-list.c index cde07a1c..db594cf7 100644 --- a/src/caja-bookmark-list.c +++ b/src/caja-bookmark-list.c @@ -31,9 +31,9 @@ #include #include #include -#include -#include + #include +#include #define MAX_BOOKMARK_LENGTH 80 #define LOAD_JOB 1 @@ -167,7 +167,8 @@ static void clear (CajaBookmarkList *bookmarks) { g_list_foreach (bookmarks->list, stop_monitoring_one, bookmarks); - eel_g_object_list_free (bookmarks->list); + g_list_foreach(bookmarks->list, (GFunc) g_object_unref, NULL); + g_list_free(bookmarks->list); bookmarks->list = NULL; } @@ -407,7 +408,7 @@ caja_bookmark_list_delete_items_with_uri (CajaBookmarkList *bookmarks, next = node->next; bookmark_uri = caja_bookmark_get_uri (CAJA_BOOKMARK (node->data)); - if (eel_strcmp (bookmark_uri, uri) == 0) + if (g_strcmp0 (bookmark_uri, uri) == 0) { bookmarks->list = g_list_remove_link (bookmarks->list, node); stop_monitoring_bookmark (bookmarks, CAJA_BOOKMARK (node->data)); diff --git a/src/caja-emblem-sidebar.c b/src/caja-emblem-sidebar.c index ea21bec9..1de86f9b 100644 --- a/src/caja-emblem-sidebar.c +++ b/src/caja-emblem-sidebar.c @@ -32,8 +32,6 @@ #include "caja-emblem-sidebar.h" #include -#include -#include #include #include #include @@ -1008,7 +1006,8 @@ caja_emblem_sidebar_populate (CajaEmblemSidebar *emblem_sidebar) widgets = g_list_prepend (widgets, emblem_widget); } - eel_g_list_free_deep (icons); + g_list_foreach(icons, (GFunc) g_free, NULL); + g_list_free(icons); /* sort the emblems by display name */ widgets = g_list_sort (widgets, emblem_widget_sort_func); diff --git a/src/caja-history-sidebar.c b/src/caja-history-sidebar.c index 2375a046..b69dce51 100644 --- a/src/caja-history-sidebar.c +++ b/src/caja-history-sidebar.c @@ -27,9 +27,7 @@ #include -#include #include -#include #include #include #include @@ -123,7 +121,8 @@ update_history (CajaHistorySidebar *sidebar) } g_free (name); } - eel_g_object_list_free (history); + g_list_foreach(history, (GFunc) g_object_unref, NULL); + g_list_free(history); selection = GTK_TREE_SELECTION (gtk_tree_view_get_selection (sidebar->tree_view)); diff --git a/src/caja-information-panel.c b/src/caja-information-panel.c index 5585457e..7aa17908 100644 --- a/src/caja-information-panel.c +++ b/src/caja-information-panel.c @@ -1228,7 +1228,8 @@ selection_changed_callback (CajaWindowInfo *window, caja_information_panel_set_uri (panel, uri, name); - eel_g_object_list_unref (selection); + g_list_foreach (selection, (GFunc) g_object_unref, NULL); + g_list_free (selection); g_free (uri); g_free (name); } diff --git a/src/caja-navigation-window-slot.c b/src/caja-navigation-window-slot.c index 703cca90..14963733 100644 --- a/src/caja-navigation-window-slot.c +++ b/src/caja-navigation-window-slot.c @@ -88,7 +88,8 @@ caja_navigation_window_slot_clear_forward_list (CajaNavigationWindowSlot *slot) { g_assert (CAJA_IS_NAVIGATION_WINDOW_SLOT (slot)); - eel_g_object_list_free (slot->forward_list); + g_list_foreach(slot->forward_list, (GFunc) g_object_unref, NULL); + g_list_free(slot->forward_list); slot->forward_list = NULL; } @@ -97,7 +98,8 @@ caja_navigation_window_slot_clear_back_list (CajaNavigationWindowSlot *slot) { g_assert (CAJA_IS_NAVIGATION_WINDOW_SLOT (slot)); - eel_g_object_list_free (slot->back_list); + g_list_foreach(slot->back_list, (GFunc) g_object_unref, NULL); + g_list_free(slot->back_list); slot->back_list = NULL; } diff --git a/src/caja-notes-viewer.c b/src/caja-notes-viewer.c index dc2df7fd..e62a0f14 100644 --- a/src/caja-notes-viewer.c +++ b/src/caja-notes-viewer.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include @@ -141,7 +140,7 @@ set_saved_text (CajaNotesViewer *notes, char *new_notes) old_text = notes->details->previous_saved_text; notes->details->previous_saved_text = new_notes; - if (eel_strcmp (old_text, new_notes) != 0) + if (g_strcmp0 (old_text, new_notes) != 0) { g_signal_emit_by_name (CAJA_SIDEBAR (notes), "tab_icon_changed"); @@ -207,7 +206,7 @@ load_note_text_from_metadata (CajaFile *file, /* This fn is called for any change signal on the file, so make sure that the * metadata has actually changed. */ - if (eel_strcmp (saved_text, notes->details->previous_saved_text) != 0) + if (g_strcmp0 (saved_text, notes->details->previous_saved_text) != 0) { set_saved_text (notes, saved_text); cancel_pending_save (notes); diff --git a/src/caja-pathbar.c b/src/caja-pathbar.c index cc79e497..57821d60 100644 --- a/src/caja-pathbar.c +++ b/src/caja-pathbar.c @@ -20,10 +20,6 @@ #include #include -#include -#include -#include -#include #include #include #include @@ -1754,7 +1750,8 @@ setup_file_path_mounted_mount (GFile *location, ButtonData *button_data) g_object_unref (default_location); g_object_unref (root); } - eel_g_object_list_free (mounts); + g_list_foreach(mounts, (GFunc) g_object_unref, NULL); + g_list_free(mounts); return result; } @@ -1963,7 +1960,7 @@ button_data_file_changed (CajaFile *file, if (button_data->type != MOUNT_BUTTON) { display_name = caja_file_get_display_name (file); - if (eel_strcmp (display_name, button_data->dir_name) != 0) + if (g_strcmp0 (display_name, button_data->dir_name) != 0) { g_free (button_data->dir_name); button_data->dir_name = g_strdup (display_name); diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index c12c6200..a6b3f022 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -417,7 +417,7 @@ compare_for_selection (CajaPlacesSidebar *sidebar, { int res; - res = eel_strcmp (added_uri, last_uri); + res = g_strcmp0 (added_uri, last_uri); if (res == 0) { @@ -429,7 +429,7 @@ compare_for_selection (CajaPlacesSidebar *sidebar, *path = gtk_tree_model_get_path (sidebar->filter_model, iter); } - else if (eel_strcmp (location, added_uri) == 0) + else if (g_strcmp0 (location, added_uri) == 0) { if (*path == NULL) { @@ -842,7 +842,8 @@ update_places (CajaPlacesSidebar *sidebar) g_free (tooltip); } - eel_g_object_list_free (network_mounts); + g_list_foreach (network_mounts, (GFunc) g_object_unref, NULL); + g_list_free(network_mounts); /* network:// */ mount_uri = "network:///"; /* No need to strdup */ diff --git a/src/caja-property-browser.c b/src/caja-property-browser.c index 5fb5c249..e3ee8dd7 100644 --- a/src/caja-property-browser.c +++ b/src/caja-property-browser.c @@ -34,7 +34,6 @@ #include #include -#include #include #include #include @@ -233,7 +232,8 @@ caja_property_browser_dispose (GObject *object) g_free (property_browser->details->dragged_file); g_free (property_browser->details->drag_type); - eel_g_list_free_deep (property_browser->details->keywords); + g_list_foreach (property_browser->details->keywords, (GFunc) g_free, NULL); + g_list_free(property_browser->details->keywords); if (property_browser->details->property_chit) { @@ -1796,7 +1796,8 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser) if (property_browser->details->category_type == CAJA_PROPERTY_EMBLEM) { - eel_g_list_free_deep (property_browser->details->keywords); + g_list_foreach(property_browser->details->keywords, (GFunc) g_free, NULL); + g_list_free(property_browser->details->keywords); property_browser->details->keywords = NULL; icons = caja_emblem_list_available (); @@ -1850,7 +1851,8 @@ make_properties_from_directories (CajaPropertyBrowser *property_browser) g_object_unref (object_pixbuf); } } - eel_g_list_free_deep (icons); + g_list_foreach(icons, (GFunc) g_free, NULL); + g_list_free(icons); } else { diff --git a/src/caja-query-editor.c b/src/caja-query-editor.c index 1b7ea10f..b0d04008 100644 --- a/src/caja-query-editor.c +++ b/src/caja-query-editor.c @@ -864,8 +864,8 @@ type_add_rows_from_query (CajaQueryEditor *editor, &iter); } - eel_g_list_free_deep (mime_types); - + g_list_foreach(mime_types, (GFunc) g_free, NULL); + g_list_free(mime_types); } /* End of row types */ diff --git a/src/caja-spatial-window.c b/src/caja-spatial-window.c index 5dd3bbce..94e43956 100644 --- a/src/caja-spatial-window.c +++ b/src/caja-spatial-window.c @@ -42,7 +42,6 @@ #include "caja-search-bar.h" #include "caja-window-manage-views.h" #include "caja-zoom-control.h" -#include #include #include #include @@ -556,7 +555,8 @@ location_menu_item_activated_callback (GtkWidget *menu_item, caja_window_slot_open_location_with_selection (slot, dest, selection, close_behind); - eel_g_object_list_free (selection); + g_list_foreach(selection, (GFunc) g_object_unref, NULL); + g_list_free(selection); } if (event != NULL) { diff --git a/src/caja-trash-bar.c b/src/caja-trash-bar.c index 77e60f88..beb993bd 100644 --- a/src/caja-trash-bar.c +++ b/src/caja-trash-bar.c @@ -70,7 +70,8 @@ restore_button_clicked_cb (GtkWidget *button, caja_restore_files_from_trash (files, GTK_WINDOW (gtk_widget_get_toplevel (button))); caja_file_list_free (files); - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); } static void diff --git a/src/caja-window-manage-views.c b/src/caja-window-manage-views.c index aba56377..5156cb18 100644 --- a/src/caja-window-manage-views.c +++ b/src/caja-window-manage-views.c @@ -860,7 +860,7 @@ caja_window_slot_content_view_matches_iid (CajaWindowSlot *slot, { return FALSE; } - return eel_strcmp (caja_view_get_view_id (slot->content_view), iid) == 0; + return g_strcmp0 (caja_view_get_view_id (slot->content_view), iid) == 0; } static gboolean @@ -1390,7 +1390,7 @@ create_content_view (CajaWindowSlot *slot, } if (slot->content_view != NULL && - eel_strcmp (caja_view_get_view_id (slot->content_view), + g_strcmp0 (caja_view_get_view_id (slot->content_view), view_id) == 0) { /* reuse existing content view */ @@ -1421,7 +1421,8 @@ create_content_view (CajaWindowSlot *slot, FALSE, TRUE); - eel_g_object_list_free (slot->pending_selection); + g_list_foreach(slot->pending_selection, (GFunc) g_object_unref, NULL); + g_list_free(slot->pending_selection); slot->pending_selection = NULL; } else if (slot->location != NULL) @@ -1432,7 +1433,8 @@ create_content_view (CajaWindowSlot *slot, selection, FALSE, TRUE); - eel_g_object_list_free (selection); + g_list_foreach(selection, (GFunc) g_object_unref, NULL); + g_list_free(selection); } else { @@ -1490,7 +1492,8 @@ load_new_location (CajaWindowSlot *slot, caja_view_set_selection (view, selection_copy); } - eel_g_object_list_free (selection_copy); + g_list_foreach(selection_copy, (GFunc) g_object_unref, NULL); + g_list_free(selection_copy); } /* A view started to load the location its viewing, either due to @@ -1947,7 +1950,8 @@ free_location_change (CajaWindowSlot *slot) } slot->pending_location = NULL; - eel_g_object_list_free (slot->pending_selection); + g_list_foreach(slot->pending_selection, (GFunc) g_object_unref, NULL); + g_list_free(slot->pending_selection); slot->pending_selection = NULL; /* Don't free pending_scroll_to, since thats needed until @@ -2001,7 +2005,8 @@ cancel_location_change (CajaWindowSlot *slot) selection, TRUE, FALSE); - eel_g_object_list_free (selection); + g_list_foreach(selection, (GFunc) g_object_unref, NULL); + g_list_free(selection); } end_location_change (slot); @@ -2351,7 +2356,8 @@ caja_window_slot_reload (CajaWindowSlot *slot) NULL, NULL); g_free (current_pos); g_object_unref (location); - eel_g_object_list_free (selection); + g_list_foreach(selection, (GFunc) g_object_unref, NULL); + g_list_free(selection); } void diff --git a/src/caja-window-slot.c b/src/caja-window-slot.c index e82bcb00..5d87a60f 100644 --- a/src/caja-window-slot.c +++ b/src/caja-window-slot.c @@ -662,7 +662,8 @@ caja_window_slot_dispose (GObject *object) g_object_ref (slot->location); } - eel_g_list_free_deep (slot->pending_selection); + g_list_foreach(slot->pending_selection, (GFunc) g_free, NULL); + g_list_free(slot->pending_selection); slot->pending_selection = NULL; if (slot->current_location_bookmark != NULL) diff --git a/src/caja-window.c b/src/caja-window.c index 142ae4a1..35b78432 100644 --- a/src/caja-window.c +++ b/src/caja-window.c @@ -343,7 +343,8 @@ caja_window_go_up (CajaWindow *window, gboolean close_behind, gboolean new_tab) g_object_unref (parent); - eel_g_object_list_free (selection); + g_list_foreach(selection, (GFunc) g_object_unref, NULL); + g_list_free(selection); } static void @@ -605,9 +606,8 @@ caja_window_get_property (GObject *object, static void free_stored_viewers (CajaWindow *window) { - eel_g_list_free_deep_custom (window->details->short_list_viewers, - (GFunc) g_free, - NULL); + g_list_foreach(window->details->short_list_viewers, (GFunc) g_free, NULL); + g_list_free(window->details->short_list_viewers); window->details->short_list_viewers = NULL; g_free (window->details->extra_viewer); window->details->extra_viewer = NULL; @@ -1760,7 +1760,8 @@ caja_send_history_list_changed (void) static void free_history_list (void) { - eel_g_object_list_free (history_list); + g_list_foreach(history_list, (GFunc) g_object_unref, NULL); + g_list_free(history_list); history_list = NULL; } diff --git a/src/file-manager/fm-directory-view.c b/src/file-manager/fm-directory-view.c index a4119ec4..c40a40ba 100644 --- a/src/file-manager/fm-directory-view.c +++ b/src/file-manager/fm-directory-view.c @@ -1025,7 +1025,8 @@ delete_selected_files (FMDirectoryView *view) caja_file_operations_delete (locations, fm_directory_view_get_containing_window (view), NULL, NULL); - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); caja_file_list_free (selection); } @@ -1934,7 +1935,8 @@ fm_directory_view_set_selection_locations (CajaView *caja_view, /* If we are still loading, set the list of pending URIs instead. * done_loading() will eventually select the pending URIs and reveal them. */ - eel_g_object_list_free (view->details->pending_locations_selected); + g_list_foreach(view->details->pending_locations_selected, (GFunc) g_object_unref, NULL); + g_list_free(view->details->pending_locations_selected); view->details->pending_locations_selected = eel_g_object_list_copy (selection_locations); } @@ -2548,7 +2550,8 @@ done_loading (FMDirectoryView *view, fm_directory_view_reveal_selection (view); } } - eel_g_object_list_free (locations_selected); + g_list_foreach(locations_selected, (GFunc) g_object_unref, NULL); + g_list_free(locations_selected); fm_directory_view_display_selection_info (view); } @@ -3790,7 +3793,8 @@ fm_directory_view_create_links_for_files (FMDirectoryView *view, GList *files, caja_file_operations_copy_move (uris, relative_item_points, dir_uri, GDK_ACTION_LINK, GTK_WIDGET (view), copy_move_done_callback, copy_move_done_data); g_free (dir_uri); - eel_g_list_free_deep (uris); + g_list_foreach(uris, (GFunc) g_free, NULL); + g_list_free(uris); } static void @@ -3822,7 +3826,8 @@ fm_directory_view_duplicate_selection (FMDirectoryView *view, GList *files, copy_move_done_data = pre_copy_move (view); caja_file_operations_copy_move (uris, relative_item_points, NULL, GDK_ACTION_COPY, GTK_WIDGET (view), copy_move_done_callback, copy_move_done_data); - eel_g_list_free_deep (uris); + g_list_foreach(uris, (GFunc) g_free, NULL); + g_list_free(uris); } /* special_link_in_selection @@ -3926,7 +3931,8 @@ trash_or_delete_files (GtkWindow *parent_window, parent_window, (CajaDeleteCallback) trash_or_delete_done_cb, view); - eel_g_object_list_free (locations); + g_list_foreach(locations, (GFunc) g_object_unref, NULL); + g_list_free(locations); } static gboolean @@ -4675,7 +4681,8 @@ reset_open_with_menu (FMDirectoryView *view, GList *selection) index, menu_path, popup_path, submenu_visible); } - eel_g_object_list_free (applications); + g_list_foreach(applications, (GFunc) g_object_unref, NULL); + g_list_free(applications); if (default_app != NULL) { g_object_unref (default_app); } @@ -5970,7 +5977,8 @@ move_copy_selection_to_location (FMDirectoryView *view, 0, 0, view); - eel_g_list_free_deep (uris); + g_list_foreach(uris, (GFunc) g_free, NULL); + g_list_free(uris); caja_file_list_free (selection); } @@ -6110,7 +6118,10 @@ paste_clipboard_data (FMDirectoryView *view, gtk_clipboard_clear (caja_clipboard_get (GTK_WIDGET (view))); } - eel_g_list_free_deep (item_uris); + g_list_foreach(item_uris, (GFunc) g_free, NULL); + g_list_free(item_uris); + g_list_foreach(item_uris, (GFunc) g_free, NULL); + g_list_free(item_uris); } } @@ -7104,7 +7115,8 @@ action_location_delete_callback (GtkAction *action, caja_file_operations_delete (files, fm_directory_view_get_containing_window (view), NULL, NULL); - eel_g_object_list_free (files); + g_list_foreach(files, (GFunc) g_object_unref, NULL); + g_list_free(files); } static void @@ -9787,7 +9799,8 @@ fm_directory_view_stop (FMDirectoryView *view) view->details->old_added_files = NULL; file_and_directory_list_free (view->details->old_changed_files); view->details->old_changed_files = NULL; - eel_g_object_list_free (view->details->pending_locations_selected); + g_list_foreach(view->details->pending_locations_selected, (GFunc) g_object_unref, NULL); + g_list_free(view->details->pending_locations_selected); view->details->pending_locations_selected = NULL; if (view->details->model != NULL) { @@ -10565,7 +10578,8 @@ fm_directory_view_handle_uri_list_drop (FMDirectoryView *view, target_uri != NULL ? target_uri : container_uri, action, x, y, view); - eel_g_list_free_deep (real_uri_list); + g_list_foreach(real_uri_list, (GFunc) g_free, NULL); + g_list_free(real_uri_list); if (points != NULL) g_array_free (points, TRUE); diff --git a/src/file-manager/fm-list-model.c b/src/file-manager/fm-list-model.c index b814a313..f6ba0168 100644 --- a/src/file-manager/fm-list-model.c +++ b/src/file-manager/fm-list-model.c @@ -29,8 +29,6 @@ #include #include -#include -#include #include #include #include @@ -373,7 +371,8 @@ fm_list_model_get_value (GtkTreeModel *tree_model, GtkTreeIter *iter, int column g_object_unref (emblem); } - eel_g_object_list_free (emblem_icons); + g_list_foreach (emblem_icons, (GFunc) g_object_unref, NULL); + g_list_free(emblem_icons); g_object_unref (gicon); gicon = emblemed_icon; @@ -679,7 +678,8 @@ fm_list_model_get_first_iter_for_file (FMListModel *model, res = TRUE; *iter = *(GtkTreeIter *)list->data; } - eel_g_list_free_deep (list); + g_list_foreach(list, (GFunc) g_free, NULL); + g_list_free(list); return res; } @@ -1806,7 +1806,8 @@ refresh_row (gpointer data, gtk_tree_path_free (path); } - eel_g_list_free_deep (iters); + g_list_foreach(iters, (GFunc) g_free, NULL); + g_list_free(iters); } void diff --git a/src/file-manager/fm-list-view.c b/src/file-manager/fm-list-view.c index e9fdd88b..f487c333 100644 --- a/src/file-manager/fm-list-view.c +++ b/src/file-manager/fm-list-view.c @@ -2325,7 +2325,8 @@ fm_list_view_set_selection (FMDirectoryView *view, GList *selection) gtk_tree_selection_select_iter (tree_selection, (GtkTreeIter *)l->data); } - eel_g_list_free_deep (iters); + g_list_foreach(iters, (GFunc) g_free, NULL); + g_list_free(iters); } g_signal_handlers_unblock_by_func (tree_selection, list_selection_changed_callback, view); @@ -2362,7 +2363,8 @@ fm_list_view_invert_selection (FMDirectoryView *view) gtk_tree_selection_unselect_iter (tree_selection, (GtkTreeIter *)l->data); } - eel_g_list_free_deep (iters); + g_list_foreach(iters, (GFunc) g_free, NULL); + g_list_free(iters); } g_list_free (selection); diff --git a/src/file-manager/fm-properties-window.c b/src/file-manager/fm-properties-window.c index ea07b1c4..4a7b7c54 100644 --- a/src/file-manager/fm-properties-window.c +++ b/src/file-manager/fm-properties-window.c @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -700,7 +699,7 @@ update_name_field (FMPropertiesWindow *window) set_name_field (window, original_name, current_name); if (original_name == NULL || - eel_strcmp (original_name, current_name) != 0) { + g_strcmp0 (original_name, current_name) != 0) { g_object_set_data_full (G_OBJECT (window->details->name_field), "original_name", current_name, @@ -842,7 +841,8 @@ file_has_keyword (CajaFile *file, const char *keyword) keywords = caja_file_get_keywords (file); word = g_list_find_custom (keywords, keyword, (GCompareFunc) strcmp); - eel_g_list_free_deep (keywords); + g_list_foreach(keywords, (GFunc) g_free, NULL); + g_list_free(keywords); return (word != NULL); } @@ -932,7 +932,8 @@ emblem_button_toggled (GtkToggleButton *button, keywords = g_list_prepend (keywords, g_strdup (name)); } caja_file_set_keywords (file, keywords); - eel_g_list_free_deep (keywords); + g_list_foreach(keywords, (GFunc) g_free, NULL); + g_list_free(keywords); } for (l = files_off; l != NULL; l = l->next) { @@ -945,10 +946,12 @@ emblem_button_toggled (GtkToggleButton *button, word = g_list_find_custom (keywords, name, (GCompareFunc)strcmp); if (word) { keywords = g_list_remove_link (keywords, word); - eel_g_list_free_deep (word); + g_list_foreach(word, (GFunc) g_free, NULL); + g_list_free(word); } caja_file_set_keywords (file, keywords); - eel_g_list_free_deep (keywords); + g_list_foreach(keywords, (GFunc) g_free, NULL); + g_list_free(keywords); } g_list_free (files_on); @@ -1204,7 +1207,8 @@ properties_window_update (FMPropertiesWindow *window, refresh_extension_pages (window); } - eel_g_list_free_deep (window->details->mime_list); + g_list_foreach(window->details->mime_list, (GFunc) g_free, NULL); + g_list_free(window->details->mime_list); window->details->mime_list = mime_list; } } @@ -1813,7 +1817,8 @@ synch_groups_combo_box (GtkComboBox *combo_box, CajaFile *file) gtk_combo_box_set_active (combo_box, current_group_index); g_free (current_group_name); - eel_g_list_free_deep (groups); + g_list_foreach(groups, (GFunc) g_free, NULL); + g_list_free(groups); } static gboolean @@ -2168,7 +2173,8 @@ synch_user_menu (GtkComboBox *combo_box, CajaFile *file) gtk_combo_box_set_active (combo_box, owner_index); g_free (owner_name); - eel_g_list_free_deep (users); + g_list_foreach(users, (GFunc) g_free, NULL); + g_list_free(users); } static GtkComboBox* @@ -3424,7 +3430,7 @@ get_initial_emblems (GList *files) ret = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, - (GDestroyNotify)eel_g_list_free_deep); + (GFunc) g_free); for (l = files; l != NULL; l = l->next) { CajaFile *file; @@ -3563,7 +3569,8 @@ create_emblems_page (FMPropertiesWindow *window) gtk_container_add (GTK_CONTAINER (emblems_table), button); } - eel_g_list_free_deep (icons); + g_list_foreach(icons, (GFunc) g_free, NULL); + g_list_free(icons); gtk_widget_show_all (emblems_table); } @@ -5047,7 +5054,8 @@ get_pending_key (GList *file_list) g_string_append (key, ";"); } - eel_g_list_free_deep (uris); + g_list_foreach(uris, (GFunc) g_free, NULL); + g_list_free(uris); ret = key->str; g_string_free (key, FALSE); @@ -5620,7 +5628,8 @@ real_finalize (GObject *object) window = FM_PROPERTIES_WINDOW (object); - eel_g_list_free_deep (window->details->mime_list); + g_list_foreach(window->details->mime_list, (GFunc) g_free, NULL); + g_list_free(window->details->mime_list); g_free (window->details->pending_name); g_free (window->details); diff --git a/src/file-manager/fm-tree-model.c b/src/file-manager/fm-tree-model.c index 3a3e3604..3423e2d1 100644 --- a/src/file-manager/fm-tree-model.c +++ b/src/file-manager/fm-tree-model.c @@ -29,7 +29,6 @@ #include #include "fm-tree-model.h" -#include #include #include #include @@ -320,7 +319,8 @@ get_menu_icon_for_file (TreeNode *node, } } - eel_g_object_list_free (emblem_icons); + g_list_foreach (emblem_icons, (GFunc) g_object_unref, NULL); + g_list_free(emblem_icons); info = caja_icon_info_lookup (gicon, size); retval = caja_icon_info_get_pixbuf_nodefault_at_size (info, size); diff --git a/src/file-manager/fm-tree-view.c b/src/file-manager/fm-tree-view.c index d673c70b..37559f53 100644 --- a/src/file-manager/fm-tree-view.c +++ b/src/file-manager/fm-tree-view.c @@ -35,9 +35,7 @@ #include "fm-tree-model.h" #include "fm-properties-window.h" #include -#include #include -#include #include #include #include @@ -1061,7 +1059,8 @@ paste_clipboard_data (FMTreeView *view, gtk_clipboard_clear (caja_clipboard_get (GTK_WIDGET (view))); } - eel_g_list_free_deep (item_uris); + g_list_foreach(item_uris, (GFunc) g_free, NULL); + g_list_free(item_uris); } } @@ -1124,7 +1123,8 @@ fm_tree_view_trash_cb (GtkWidget *menu_item, caja_file_operations_trash_or_delete (list, fm_tree_view_get_containing_window (view), NULL, NULL); - eel_g_object_list_free (list); + g_list_foreach(list, (GFunc) g_object_unref, NULL); + g_list_free(list); } static void @@ -1142,7 +1142,8 @@ fm_tree_view_delete_cb (GtkWidget *menu_item, caja_file_get_location (view->details->popup_file)); caja_file_operations_delete (location_list, fm_tree_view_get_containing_window (view), NULL, NULL); - eel_g_object_list_free (location_list); + g_list_foreach(location_list, (GFunc) g_object_unref, NULL); + g_list_free(location_list); } static void -- cgit v1.2.1 From f5b61ba409db5976bcc5be71accaac57ea88fcd0 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 11:21:40 +0200 Subject: [places-sidebar] use gtk_widget_set_visible() instead of the eel helper http://git.gnome.org/browse/nautilus/commit/?id=bb145a018a9d66b748971e40be4e09a7f843b2be --- src/caja-places-sidebar.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/caja-places-sidebar.c b/src/caja-places-sidebar.c index a6b3f022..7b188152 100644 --- a/src/caja-places-sidebar.c +++ b/src/caja-places-sidebar.c @@ -1764,16 +1764,16 @@ bookmarks_check_popup_sensitivity (CajaPlacesSidebar *sidebar) show_empty_trash = (uri != NULL) && (!strcmp (uri, "trash:///")); - eel_gtk_widget_set_shown (sidebar->popup_menu_separator_item, + gtk_widget_set_visible (sidebar->popup_menu_separator_item, show_mount || show_unmount || show_eject || show_format || show_empty_trash); - eel_gtk_widget_set_shown (sidebar->popup_menu_mount_item, show_mount); - eel_gtk_widget_set_shown (sidebar->popup_menu_unmount_item, show_unmount); - eel_gtk_widget_set_shown (sidebar->popup_menu_eject_item, show_eject); - eel_gtk_widget_set_shown (sidebar->popup_menu_rescan_item, show_rescan); - eel_gtk_widget_set_shown (sidebar->popup_menu_format_item, show_format); - eel_gtk_widget_set_shown (sidebar->popup_menu_start_item, show_start); - eel_gtk_widget_set_shown (sidebar->popup_menu_stop_item, show_stop); - eel_gtk_widget_set_shown (sidebar->popup_menu_empty_trash_item, show_empty_trash); + gtk_widget_set_visible (sidebar->popup_menu_mount_item, show_mount); + gtk_widget_set_visible (sidebar->popup_menu_unmount_item, show_unmount); + gtk_widget_set_visible (sidebar->popup_menu_eject_item, show_eject); + gtk_widget_set_visible (sidebar->popup_menu_rescan_item, show_rescan); + gtk_widget_set_visible (sidebar->popup_menu_format_item, show_format); + gtk_widget_set_visible (sidebar->popup_menu_start_item, show_start); + gtk_widget_set_visible (sidebar->popup_menu_stop_item, show_stop); + gtk_widget_set_visible (sidebar->popup_menu_empty_trash_item, show_empty_trash); /* Adjust start/stop items to reflect the type of the drive */ gtk_menu_item_set_label (GTK_MENU_ITEM (sidebar->popup_menu_start_item), _("_Start")); -- cgit v1.2.1 From eb0fb3845bd7a6f3b566c454d16b6f7cd287ef9c Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 11:25:15 +0200 Subject: [eel] remove eel_gtk_widget_set_shown() http://git.gnome.org/browse/nautilus/commit/?id=31dfbdc19075ddf92b4f04a2f84e3111c3fb429b --- eel/eel-gtk-extensions.c | 22 ---------------------- eel/eel-gtk-extensions.h | 3 --- 2 files changed, 25 deletions(-) diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c index da8e7d7c..5b8121b6 100644 --- a/eel/eel-gtk-extensions.c +++ b/eel/eel-gtk-extensions.c @@ -353,28 +353,6 @@ eel_gtk_menu_tool_button_get_button (GtkMenuToolButton *tool_button) return button; } -/** - * eel_gtk_widget_set_shown - * - * Show or hide a widget. - * @widget: The widget. - * @shown: Boolean value indicating whether the widget should be shown or hidden. - **/ -void -eel_gtk_widget_set_shown (GtkWidget *widget, gboolean shown) -{ - g_return_if_fail (GTK_IS_WIDGET (widget)); - - if (shown) - { - gtk_widget_show (widget); - } - else - { - gtk_widget_hide (widget); - } -} - /* The standard gtk_adjustment_set_value ignores page size, which * disagrees with the logic used by scroll bars, for example. */ diff --git a/eel/eel-gtk-extensions.h b/eel/eel-gtk-extensions.h index e26c2e2f..a5d8e60a 100644 --- a/eel/eel-gtk-extensions.h +++ b/eel/eel-gtk-extensions.h @@ -35,9 +35,6 @@ #define EEL_DEFAULT_POPUP_MENU_DISPLACEMENT 2 #define EEL_STANDARD_CLOSE_WINDOW_CONTROL_KEY 'w' -/* GtkWidget */ -void eel_gtk_widget_set_shown (GtkWidget *widget, - gboolean shown); /* GtkWindow */ void eel_gtk_window_set_initial_geometry (GtkWindow *window, -- cgit v1.2.1 From 639c9137b77557f38946d6dc174772554343da47 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Thu, 18 Oct 2012 11:29:02 +0200 Subject: [eel] remove unused eel_get_filename_charset() http://git.gnome.org/browse/nautilus/commit/?id=00c0b9daa2053a110e17c64fb79ce4884290dc76 --- eel/eel-glib-extensions.c | 98 ----------------------------------------------- eel/eel-glib-extensions.h | 3 -- 2 files changed, 101 deletions(-) diff --git a/eel/eel-glib-extensions.c b/eel/eel-glib-extensions.c index 63ac74a7..5b016aad 100644 --- a/eel/eel-glib-extensions.c +++ b/eel/eel-glib-extensions.c @@ -775,104 +775,6 @@ eel_remove_weak_pointer (gpointer pointer_location) *object_location = NULL; } -/* Get the filename encoding, returns TRUE if utf8 */ - -typedef struct _EelFilenameCharsetCache EelFilenameCharsetCache; - -struct _EelFilenameCharsetCache -{ - gboolean is_utf8; - gchar *charset; - gchar *filename_charset; -}; - -static void -filename_charset_cache_free (gpointer data) -{ - EelFilenameCharsetCache *cache = data; - g_free (cache->charset); - g_free (cache->filename_charset); - g_free (cache); -} - -/* - * eel_get_filename_charset: - * @charset: return location for the name of the filename encoding - * - * Determines the character set used for filenames by consulting the - * environment variables G_FILENAME_ENCODING and G_BROKEN_FILENAMES. - * - * G_FILENAME_ENCODING may be set to a comma-separated list of character - * set names. The special token "@locale" is taken to mean the character set - * for the current locale. The first character set from the list is taken - * as the filename encoding. - * If G_FILENAME_ENCODING is not set, but G_BROKEN_FILENAMES is, the - * character set of the current locale is taken as the filename encoding. - * - * The returned @charset belongs to Eel and must not be freed. - * - * Return value: %TRUE if the charset used for filename is UTF-8. - */ -gboolean -eel_get_filename_charset (const gchar **filename_charset) -{ - static GStaticPrivate cache_private = G_STATIC_PRIVATE_INIT; - EelFilenameCharsetCache *cache = g_static_private_get (&cache_private); - const gchar *charset; - - if (!cache) - { - cache = g_new0 (EelFilenameCharsetCache, 1); - g_static_private_set (&cache_private, cache, filename_charset_cache_free); - } - - g_get_charset (&charset); - - if (!(cache->charset && strcmp (cache->charset, charset) == 0)) - { - const gchar *new_charset; - gchar *p, *q; - - g_free (cache->charset); - g_free (cache->filename_charset); - cache->charset = g_strdup (charset); - - p = getenv ("G_FILENAME_ENCODING"); - if (p != NULL) - { - q = strchr (p, ','); - if (!q) - q = p + strlen (p); - - if (strncmp ("@locale", p, q - p) == 0) - { - cache->is_utf8 = g_get_charset (&new_charset); - cache->filename_charset = g_strdup (new_charset); - } - else - { - cache->filename_charset = g_strndup (p, q - p); - cache->is_utf8 = (strcmp (cache->filename_charset, "UTF-8") == 0); - } - } - else if (getenv ("G_BROKEN_FILENAMES") != NULL) - { - cache->is_utf8 = g_get_charset (&new_charset); - cache->filename_charset = g_strdup (new_charset); - } - else - { - cache->filename_charset = g_strdup ("UTF-8"); - cache->is_utf8 = TRUE; - } - } - - if (filename_charset) - *filename_charset = cache->filename_charset; - - return cache->is_utf8; -} - static void update_auto_boolean (GSettings *settings, const gchar *key, diff --git a/eel/eel-glib-extensions.h b/eel/eel-glib-extensions.h index 416ebe2f..907a1ec9 100644 --- a/eel/eel-glib-extensions.h +++ b/eel/eel-glib-extensions.h @@ -90,9 +90,6 @@ int eel_round (double void eel_add_weak_pointer (gpointer pointer_location); void eel_remove_weak_pointer (gpointer pointer_location); -/* Get the filename encoding, returns TRUE if utf8 */ -gboolean eel_get_filename_charset (const gchar **filename_charset); - void eel_g_settings_add_auto_enum (GSettings *settings, const char *key, int *storage); -- cgit v1.2.1 From 48cc04df5933644ade234ce16ac8a6ee817bb867 Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 10 Nov 2012 11:22:51 +0200 Subject: [eel] remove eel_gdk_pixbuf_list_ref() But unlike upstream commit below, not removing include eel-art-extensions.h from eel-gdk-pixbuf-extensions.h, as we still have functions in the latter using eel_irect_* (from eel-art-extensions), which are still used by the eel-debug-drawing we kept around. http://git.gnome.org/browse/nautilus/commit/?id=7dee3226ad6b3aa1c782cc3d2969e32c5eeae3f3 --- eel/eel-gdk-pixbuf-extensions.c | 12 ------------ eel/eel-gdk-pixbuf-extensions.h | 4 ---- libcaja-private/caja-icon-canvas-item.c | 3 +-- 3 files changed, 1 insertion(+), 18 deletions(-) diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c index 040855b8..c913cb10 100644 --- a/eel/eel-gdk-pixbuf-extensions.c +++ b/eel/eel-gdk-pixbuf-extensions.c @@ -54,18 +54,6 @@ struct EelPixbufLoadHandle char buffer[LOAD_BUFFER_SIZE]; }; -/** - * eel_gdk_pixbuf_list_ref - * @pixbuf_list: A list of GdkPixbuf objects. - * - * Refs all the pixbufs. - **/ -void -eel_gdk_pixbuf_list_ref (GList *pixbuf_list) -{ - g_list_foreach (pixbuf_list, (GFunc) g_object_ref, NULL); -} - GdkPixbuf * eel_gdk_pixbuf_load (const char *uri) { diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h index 07a7a0ac..382cd6cd 100644 --- a/eel/eel-gdk-pixbuf-extensions.h +++ b/eel/eel-gdk-pixbuf-extensions.h @@ -41,10 +41,6 @@ typedef void (* EelPixbufLoadCallback) (GError *error, GdkPixbuf *pixbuf, gpointer callback_data); -/* Convenience functions for lists of GdkPixbuf objects. */ -void eel_gdk_pixbuf_list_ref (GList *pixbuf_list); - - /* Loading a GdkPixbuf with a URI. */ GdkPixbuf * eel_gdk_pixbuf_load (const char *uri); GdkPixbuf * eel_gdk_pixbuf_load_from_stream (GInputStream *stream); diff --git a/libcaja-private/caja-icon-canvas-item.c b/libcaja-private/caja-icon-canvas-item.c index bcec72a5..f36f2ccf 100644 --- a/libcaja-private/caja-icon-canvas-item.c +++ b/libcaja-private/caja-icon-canvas-item.c @@ -35,7 +35,6 @@ #include #include #include -#include #include #include #include @@ -763,7 +762,7 @@ caja_icon_canvas_item_set_emblems (CajaIconCanvasItem *item, } /* Take in the new list of emblems. */ - eel_gdk_pixbuf_list_ref (emblem_pixbufs); + eel_g_object_list_ref (emblem_pixbufs); g_list_foreach(item->details->emblem_pixbufs, (GFunc) g_object_unref, NULL); g_list_free(item->details->emblem_pixbufs); item->details->emblem_pixbufs = g_list_copy (emblem_pixbufs); -- cgit v1.2.1 From 1466df20591105550738a1d0784a623af9909abf Mon Sep 17 00:00:00 2001 From: Jasmine Hassan Date: Sat, 10 Nov 2012 11:28:29 +0200 Subject: [navigation-window] Use gtk_paned_new for GTK3 instead of gtk_[h|v]paned_new http://git.gnome.org/browse/nautilus/commit/?id=0609431a5cb3803d0b98bd333f90e3c7796f86b7 --- src/caja-navigation-window.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/caja-navigation-window.c b/src/caja-navigation-window.c index eba87c47..e5622af7 100644 --- a/src/caja-navigation-window.c +++ b/src/caja-navigation-window.c @@ -140,7 +140,11 @@ caja_navigation_window_init (CajaNavigationWindow *window) window->details->header_size_group = gtk_size_group_new (GTK_SIZE_GROUP_VERTICAL); gtk_size_group_set_ignore_hidden (window->details->header_size_group, FALSE); +#if GTK_CHECK_VERSION(3, 0, 0) + window->details->content_paned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); +#else window->details->content_paned = gtk_hpaned_new (); +#endif gtk_table_attach (GTK_TABLE (CAJA_WINDOW (window)->details->table), window->details->content_paned, /* X direction */ /* Y direction */ @@ -154,7 +158,11 @@ caja_navigation_window_init (CajaNavigationWindow *window) TRUE, FALSE); gtk_widget_show (vbox); +#if GTK_CHECK_VERSION(3, 0, 0) + hpaned = gtk_paned_new (GTK_ORIENTATION_HORIZONTAL); +#else hpaned = gtk_hpaned_new (); +#endif gtk_box_pack_start (GTK_BOX (vbox), hpaned, TRUE, TRUE, 0); gtk_widget_show (hpaned); window->details->split_view_hpane = hpaned; -- cgit v1.2.1