[nautilus/wip/gbsneto/code-cleanup] project: drop gtk deprecations usage



commit 6b7a1010a493ff4e6b5d9f9728de2a3f5201b462
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Wed Jun 17 02:21:05 2015 -0300

    project: drop gtk deprecations usage

 eel/eel-canvas.c                                |    9 +---
 libnautilus-private/nautilus-canvas-container.c |   12 +++--
 libnautilus-private/nautilus-canvas-item.c      |    4 +-
 src/nautilus-desktop-window.c                   |   13 ++++-
 src/nautilus-list-view.c                        |    9 ++--
 src/nautilus-main.c                             |    3 -
 src/nautilus-pathbar.c                          |   58 ++++------------------
 src/nautilus-progress-ui-handler.c              |   11 ++++-
 src/nautilus-properties-window.c                |    2 +
 src/nautilus-window.c                           |    3 +-
 10 files changed, 53 insertions(+), 71 deletions(-)
---
diff --git a/eel/eel-canvas.c b/eel/eel-canvas.c
index 0040a43..0a3e6be 100644
--- a/eel/eel-canvas.c
+++ b/eel/eel-canvas.c
@@ -2893,19 +2893,14 @@ eel_canvas_draw_background (EelCanvas *canvas,
 {
         cairo_rectangle_int_t rect;
        GtkStyleContext *style_context;
-       GdkRGBA color;
 
         if (!gdk_cairo_get_clip_rectangle (cr, &rect))
               return;
 
-        cairo_save (cr);
        /* By default, we use the style background. */
        style_context = gtk_widget_get_style_context (GTK_WIDGET (canvas));
-       gtk_style_context_get_background_color (style_context, GTK_STATE_FLAG_NORMAL, &color);
-       gdk_cairo_set_source_rgba (cr, &color);
-       gdk_cairo_rectangle (cr, &rect);
-       cairo_fill (cr);
-        cairo_restore (cr);
+
+       gtk_render_background (style_context, cr, rect.x, rect.y, rect.width, rect.height);
 }
 
 static void
diff --git a/libnautilus-private/nautilus-canvas-container.c b/libnautilus-private/nautilus-canvas-container.c
index 67a8cb8..1483032 100644
--- a/libnautilus-private/nautilus-canvas-container.c
+++ b/libnautilus-private/nautilus-canvas-container.c
@@ -2399,8 +2399,10 @@ get_rubber_color (NautilusCanvasContainer *container,
                gtk_style_context_save (context);
                gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
                gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, bgcolor);
                gtk_style_context_get_border_color (context, GTK_STATE_FLAG_NORMAL, bordercolor);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
                gtk_style_context_restore (context);
        }
@@ -4156,11 +4158,13 @@ start_stretching (NautilusCanvasContainer *container)
        NautilusCanvasContainerDetails *details;
        NautilusCanvasIcon *icon;
        GtkWidget *toplevel;
+       GdkDisplay *display;
        GtkCornerType corner;
        GdkCursor *cursor;
 
        details = container->details;
        icon = details->stretch_icon;
+       display = gdk_display_get_default ();
        
        /* Check if we hit the stretch handles. */
        if (!nautilus_canvas_item_hit_test_stretch_handles (icon->item,
@@ -4171,16 +4175,16 @@ start_stretching (NautilusCanvasContainer *container)
 
        switch (corner) {
        case GTK_CORNER_TOP_LEFT:
-               cursor = gdk_cursor_new (GDK_TOP_LEFT_CORNER);
+               cursor = gdk_cursor_new_for_display (display, GDK_TOP_LEFT_CORNER);
                break;
        case GTK_CORNER_BOTTOM_LEFT:
-               cursor = gdk_cursor_new (GDK_BOTTOM_LEFT_CORNER);
+               cursor = gdk_cursor_new_for_display (display, GDK_BOTTOM_LEFT_CORNER);
                break;
        case GTK_CORNER_TOP_RIGHT:
-               cursor = gdk_cursor_new (GDK_TOP_RIGHT_CORNER);
+               cursor = gdk_cursor_new_for_display (display, GDK_TOP_RIGHT_CORNER);
                break;
        case GTK_CORNER_BOTTOM_RIGHT:
-               cursor = gdk_cursor_new (GDK_BOTTOM_RIGHT_CORNER);
+               cursor = gdk_cursor_new_for_display (display, GDK_BOTTOM_RIGHT_CORNER);
                break;
        default: 
                cursor = NULL;
diff --git a/libnautilus-private/nautilus-canvas-item.c b/libnautilus-private/nautilus-canvas-item.c
index 318eb53..fc4b167 100644
--- a/libnautilus-private/nautilus-canvas-item.c
+++ b/libnautilus-private/nautilus-canvas-item.c
@@ -1138,11 +1138,13 @@ real_map_surface (NautilusCanvasItem *canvas_item)
            || canvas_item->details->is_highlighted_for_drop) {
                style = gtk_widget_get_style_context (GTK_WIDGET (canvas));
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
                if (gtk_widget_has_focus (GTK_WIDGET (canvas))) {
                        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
                } else {
-                       gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);  
+                       gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);
                }
+G_GNUC_END_IGNORE_DEPRECATIONS
 
                old_pixbuf = temp_pixbuf;
                temp_pixbuf = eel_create_colorized_pixbuf (temp_pixbuf, &color);
diff --git a/src/nautilus-desktop-window.c b/src/nautilus-desktop-window.c
index 30197aa..de1de6a 100644
--- a/src/nautilus-desktop-window.c
+++ b/src/nautilus-desktop-window.c
@@ -163,7 +163,7 @@ nautilus_desktop_window_constructed (GObject *obj)
 {
        AtkObject *accessible;
        NautilusDesktopWindow *window = NAUTILUS_DESKTOP_WINDOW (obj);
-        GdkRGBA transparent = {0, 0, 0, 0};
+       GtkCssProvider *provider;
 
        G_OBJECT_CLASS (nautilus_desktop_window_parent_class)->constructed (obj);
 
@@ -200,7 +200,16 @@ nautilus_desktop_window_constructed (GObject *obj)
         * Note that nautilus_desktop_window_init is too early to do this.
         */
        nautilus_desktop_window_update_directory (window);
-        gtk_widget_override_background_color (GTK_WIDGET (window), 0, &transparent);
+
+       /* Make the window transparent */
+       provider = gtk_css_provider_new ();
+       gtk_css_provider_load_from_data (provider,
+                                         "NautilusDesktopWindow {background-color: transparent;}",
+                                         -1,
+                                         NULL);
+       gtk_style_context_add_provider (gtk_widget_get_style_context (GTK_WIDGET (window)),
+                                        GTK_STYLE_PROVIDER (provider),
+                                        GTK_STYLE_PROVIDER_PRIORITY_USER);
 
        /* We realize it immediately so that the NAUTILUS_DESKTOP_WINDOW_ID
         * property is set so gnome-settings-daemon doesn't try to set
diff --git a/src/nautilus-list-view.c b/src/nautilus-list-view.c
index 82163f9..ec5b052 100644
--- a/src/nautilus-list-view.c
+++ b/src/nautilus-list-view.c
@@ -542,12 +542,14 @@ motion_notify_callback (GtkWidget *widget,
                                              view->details->drag_y,
                                              event->x, 
                                              event->y)) {
-                       gtk_drag_begin
+                       gtk_drag_begin_with_coordinates
                                (widget,
                                 source_target_list,
                                 GDK_ACTION_MOVE | GDK_ACTION_COPY | GDK_ACTION_LINK | GDK_ACTION_ASK,
                                 view->details->drag_button,
-                                (GdkEvent*)event);
+                                (GdkEvent*) event,
+                                event->x,
+                                event->y);
                }                     
                return TRUE;
        }
@@ -1869,7 +1871,6 @@ create_and_set_up_tree_view (NautilusListView *view)
                                 G_CALLBACK (get_icon_scale_callback), view, 0);
 
        gtk_tree_selection_set_mode (gtk_tree_view_get_selection (view->details->tree_view), 
GTK_SELECTION_MULTIPLE);
-       gtk_tree_view_set_rules_hint (view->details->tree_view, TRUE);
 
        g_settings_bind (nautilus_list_view_preferences, NAUTILUS_PREFERENCES_LIST_VIEW_USE_TREE,
                         view->details->tree_view, "show-expanders",
@@ -2983,7 +2984,7 @@ nautilus_list_view_click_policy_changed (NautilusView *directory_view)
                g_clear_object (&hand_cursor);
        } else if (get_click_policy () == NAUTILUS_CLICK_POLICY_SINGLE) {
                if (hand_cursor == NULL) {
-                       hand_cursor = gdk_cursor_new(GDK_HAND2);
+                       hand_cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_HAND2);
                }
        }
 }
diff --git a/src/nautilus-main.c b/src/nautilus-main.c
index fdbc0be..b719007 100644
--- a/src/nautilus-main.c
+++ b/src/nautilus-main.c
@@ -74,9 +74,6 @@ main (int argc, char *argv[])
        mallopt (M_MMAP_THRESHOLD, 128 *1024);
 #endif
 
-       /* This will be done by gtk+ later, but for now, force it to GNOME */
-       g_desktop_app_info_set_desktop_env ("GNOME");
-
        if (g_getenv ("NAUTILUS_DEBUG") != NULL) {
                eel_make_warnings_and_criticals_stop_in_debugger ();
        }
diff --git a/src/nautilus-pathbar.c b/src/nautilus-pathbar.c
index a0eed27..2a44c47 100644
--- a/src/nautilus-pathbar.c
+++ b/src/nautilus-pathbar.c
@@ -97,6 +97,9 @@ struct _NautilusPathBarDetails {
 G_DEFINE_TYPE (NautilusPathBar, nautilus_path_bar,
               GTK_TYPE_CONTAINER);
 
+#define ARROW_LEFT  "pan-start-symbolic"
+#define ARROW_RIGHT "pan-end-symbolic"
+
 static void     nautilus_path_bar_scroll_up                (NautilusPathBar *path_bar);
 static void     nautilus_path_bar_scroll_down              (NautilusPathBar *path_bar);
 static void     nautilus_path_bar_stop_scrolling           (NautilusPathBar *path_bar);
@@ -115,21 +118,18 @@ static void     nautilus_path_bar_update_path              (NautilusPathBar *pat
 
 static GtkWidget *
 get_slider_button (NautilusPathBar  *path_bar,
-                  GtkArrowType arrow_type)
+                  const gchar *arrow_type)
 {
-        GtkWidget *button;
-
-        gtk_widget_push_composite_child ();
+        GtkWidget *button, *arrow;
 
+        arrow = gtk_image_new_from_icon_name (arrow_type, GTK_ICON_SIZE_MENU);
         button = gtk_button_new ();
        gtk_button_set_focus_on_click (GTK_BUTTON (button), FALSE);
        gtk_widget_add_events (button, GDK_SCROLL_MASK);
-        gtk_container_add (GTK_CONTAINER (button), gtk_arrow_new (arrow_type, GTK_SHADOW_OUT));
+        gtk_container_add (GTK_CONTAINER (button), arrow);
         gtk_container_add (GTK_CONTAINER (path_bar), button);
         gtk_widget_show_all (button);
 
-        gtk_widget_pop_composite_child ();
-
         return button;
 }
 
@@ -205,8 +205,8 @@ nautilus_path_bar_init (NautilusPathBar *path_bar)
        gtk_widget_set_has_window (GTK_WIDGET (path_bar), FALSE);
         gtk_widget_set_redraw_on_allocate (GTK_WIDGET (path_bar), FALSE);
 
-        path_bar->priv->up_slider_button = get_slider_button (path_bar, GTK_ARROW_LEFT);
-        path_bar->priv->down_slider_button = get_slider_button (path_bar, GTK_ARROW_RIGHT);
+        path_bar->priv->up_slider_button = get_slider_button (path_bar, ARROW_LEFT);
+        path_bar->priv->down_slider_button = get_slider_button (path_bar, ARROW_RIGHT);
 
         g_signal_connect_swapped (path_bar->priv->up_slider_button, "clicked", G_CALLBACK 
(nautilus_path_bar_scroll_up), path_bar);
         g_signal_connect_swapped (path_bar->priv->down_slider_button, "clicked", G_CALLBACK 
(nautilus_path_bar_scroll_down), path_bar);
@@ -467,24 +467,6 @@ _set_simple_bottom_clip (GtkWidget *widget,
        gtk_widget_set_clip (widget, &clip);
 }
 
-static void
-child_ordering_changed (NautilusPathBar *path_bar)
-{
-       GList *l;
-
-       if (path_bar->priv->up_slider_button) {
-               gtk_style_context_invalidate (gtk_widget_get_style_context 
(path_bar->priv->up_slider_button));
-       }
-       if (path_bar->priv->down_slider_button) {
-               gtk_style_context_invalidate (gtk_widget_get_style_context 
(path_bar->priv->down_slider_button));
-       }
-
-       for (l = path_bar->priv->button_list; l; l = l->next) {
-               ButtonData *data = l->data;
-               gtk_style_context_invalidate (gtk_widget_get_style_context (data->button));             
-       }
-}
-
 /* This is a tad complicated */
 static void
 nautilus_path_bar_size_allocate (GtkWidget     *widget,
@@ -501,7 +483,6 @@ nautilus_path_bar_size_allocate (GtkWidget     *widget,
         gint up_slider_offset;
         gint down_slider_offset;
        GtkRequisition child_requisition;
-       gboolean needs_reorder = FALSE;
 
        need_sliders = FALSE;
        up_slider_offset = 0;
@@ -633,7 +614,6 @@ nautilus_path_bar_size_allocate (GtkWidget     *widget,
                        }
                }
 
-               needs_reorder |= gtk_widget_get_child_visible (child) == FALSE;
                 gtk_widget_set_child_visible (child, TRUE);
                 gtk_widget_size_allocate (child, &child_allocation);
 
@@ -647,13 +627,11 @@ nautilus_path_bar_size_allocate (GtkWidget     *widget,
         /* Now we go hide all the widgets that don't fit */
         while (list) {
                 child = BUTTON_DATA (list->data)->button;
-               needs_reorder |= gtk_widget_get_child_visible (child) == TRUE;
                gtk_widget_set_child_visible (child, FALSE);
                 list = list->prev;
         }
         for (list = first_button->next; list; list = list->next) {
                 child = BUTTON_DATA (list->data)->button;
-               needs_reorder |= gtk_widget_get_child_visible (child) == TRUE;
                gtk_widget_set_child_visible (child, FALSE);
         }
 
@@ -662,7 +640,6 @@ nautilus_path_bar_size_allocate (GtkWidget     *widget,
                 child_allocation.x = up_slider_offset + allocation->x;
                 gtk_widget_size_allocate (path_bar->priv->up_slider_button, &child_allocation);
 
-               needs_reorder |= gtk_widget_get_child_visible (path_bar->priv->up_slider_button) == FALSE;
                 gtk_widget_set_child_visible (path_bar->priv->up_slider_button, TRUE);
                 gtk_widget_show_all (path_bar->priv->up_slider_button);
 
@@ -670,7 +647,6 @@ nautilus_path_bar_size_allocate (GtkWidget     *widget,
                        down_slider_offset += path_bar->priv->slider_width;
                }
         } else {
-               needs_reorder |= gtk_widget_get_child_visible (path_bar->priv->up_slider_button) == TRUE;
                gtk_widget_set_child_visible (path_bar->priv->up_slider_button, FALSE);
         }
        
@@ -679,19 +655,13 @@ nautilus_path_bar_size_allocate (GtkWidget     *widget,
                child_allocation.x = down_slider_offset + allocation->x;
                gtk_widget_size_allocate (path_bar->priv->down_slider_button, &child_allocation);
 
-               needs_reorder |= gtk_widget_get_child_visible (path_bar->priv->down_slider_button) == FALSE;
                gtk_widget_set_child_visible (path_bar->priv->down_slider_button, TRUE);
                gtk_widget_show_all (path_bar->priv->down_slider_button);
                nautilus_path_bar_update_slider_buttons (path_bar);
        } else {
-               needs_reorder |= gtk_widget_get_child_visible (path_bar->priv->down_slider_button) == TRUE;
                gtk_widget_set_child_visible (path_bar->priv->down_slider_button, FALSE);
        }
 
-       if (needs_reorder) {
-               child_ordering_changed (path_bar);
-       }
-
        _set_simple_bottom_clip (widget, BUTTON_BOTTOM_SHADOW);
 }
 
@@ -1748,8 +1718,6 @@ nautilus_path_bar_update_path (NautilusPathBar *path_bar,
 
        file = nautilus_file_get (file_path);
 
-        gtk_widget_push_composite_child ();
-
         while (file != NULL) {
                NautilusFile *parent_file;
 
@@ -1779,15 +1747,11 @@ nautilus_path_bar_update_path (NautilusPathBar *path_bar,
                GtkWidget *button;
                button = BUTTON_DATA (l->data)->button;
                gtk_container_add (GTK_CONTAINER (path_bar), button);
-       }       
-
-        gtk_widget_pop_composite_child ();
-
-       child_ordering_changed (path_bar);
+       }
 }
 
 void
-nautilus_path_bar_set_path (NautilusPathBar *path_bar, 
+nautilus_path_bar_set_path (NautilusPathBar *path_bar,
                            GFile *file_path)
 {
        ButtonData *button_data;
diff --git a/src/nautilus-progress-ui-handler.c b/src/nautilus-progress-ui-handler.c
index 21722df..e19d68b 100644
--- a/src/nautilus-progress-ui-handler.c
+++ b/src/nautilus-progress-ui-handler.c
@@ -68,8 +68,11 @@ static gboolean server_has_persistence (void);
 static void
 status_icon_activate_cb (GtkStatusIcon *icon,
                         NautilusProgressUIHandler *self)
-{      
+{
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
        gtk_status_icon_set_visible (icon, FALSE);
+G_GNUC_END_IGNORE_DEPRECATIONS
+
        gtk_window_present (GTK_WINDOW (self->priv->progress_dialog));
 }
 
@@ -79,6 +82,7 @@ progress_ui_handler_ensure_status_icon (NautilusProgressUIHandler *self)
        GIcon *icon;
        GtkStatusIcon *status_icon;
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
        if (self->priv->status_icon != NULL) {
                return;
        }
@@ -93,6 +97,7 @@ progress_ui_handler_ensure_status_icon (NautilusProgressUIHandler *self)
        g_object_unref (icon);
 
        self->priv->status_icon = status_icon;
+G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static void
@@ -126,6 +131,7 @@ progress_ui_handler_update_status_icon (NautilusProgressUIHandler *self)
 
        progress_ui_handler_ensure_status_icon (self);
 
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS
        tooltip = g_strdup_printf (ngettext ("%'d file operation active",
                                             "%'d file operations active",
                                             self->priv->active_infos),
@@ -134,6 +140,7 @@ progress_ui_handler_update_status_icon (NautilusProgressUIHandler *self)
        g_free (tooltip);
 
        gtk_status_icon_set_visible (self->priv->status_icon, TRUE);
+G_GNUC_END_IGNORE_DEPRECATIONS
 }
 
 static gboolean
@@ -233,7 +240,9 @@ static void
 progress_ui_handler_hide_notification_or_status (NautilusProgressUIHandler *self)
 {
        if (self->priv->status_icon != NULL) {
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
                gtk_status_icon_set_visible (self->priv->status_icon, FALSE);
+G_GNUC_END_IGNORE_DEPRECATIONS
        }
 
         g_application_withdraw_notification (g_application_get_default (),
diff --git a/src/nautilus-properties-window.c b/src/nautilus-properties-window.c
index 9142c48..381c10e 100644
--- a/src/nautilus-properties-window.c
+++ b/src/nautilus-properties-window.c
@@ -2638,11 +2638,13 @@ paint_slice (GtkWidget          *widget,
        state = gtk_style_context_get_state (context);
        gtk_style_context_get_border (context, state, &border);
 
+G_GNUC_BEGIN_IGNORE_DEPRECATIONS
        gtk_style_context_save (context);
        gtk_style_context_add_class (context, style_class);
        gtk_style_context_get_background_color (context, state, &fill);
        gtk_style_context_get_border_color (context, state, &stroke);
        gtk_style_context_restore (context);
+G_GNUC_END_IGNORE_DEPRECATIONS
 
        width = gtk_widget_get_allocated_width (widget);
        height = gtk_widget_get_allocated_height (widget);
diff --git a/src/nautilus-window.c b/src/nautilus-window.c
index ce4c93f..2a70f86 100644
--- a/src/nautilus-window.c
+++ b/src/nautilus-window.c
@@ -823,7 +823,7 @@ update_cursor (NautilusWindow *window)
        slot = nautilus_window_get_active_slot (window);
 
        if (nautilus_window_slot_get_allow_stop (slot)) {
-               cursor = gdk_cursor_new (GDK_WATCH);
+               cursor = gdk_cursor_new_for_display (gdk_display_get_default (), GDK_WATCH);
                gdk_window_set_cursor (gtk_widget_get_window (GTK_WIDGET (window)), cursor);
                g_object_unref (cursor);
        } else {
@@ -1328,7 +1328,6 @@ nautilus_window_set_up_sidebar (NautilusWindow *window)
                                           (GTK_PLACES_OPEN_NORMAL
                                            | GTK_PLACES_OPEN_NEW_TAB
                                            | GTK_PLACES_OPEN_NEW_WINDOW));
-       gtk_places_sidebar_set_show_connect_to_server (GTK_PLACES_SIDEBAR (window->priv->places_sidebar), 
TRUE);
 
        g_signal_connect (window->priv->places_sidebar, "open-location",
                          G_CALLBACK (places_sidebar_open_location_cb), window);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]