~ubuntu-branches/debian/wheezy/nautilus/wheezy

« back to all changes in this revision

Viewing changes to libnautilus-private/nautilus-icon-container.c

  • Committer: Package Import Robot
  • Author(s): Michael Biebl
  • Date: 2011-11-21 20:52:38 UTC
  • mfrom: (3.1.14 experimental)
  • Revision ID: package-import@ubuntu.com-20111121205238-lo8b89pqpzv9p1jk
Tags: 3.2.1-2
* Upload to unstable.
* debian/control.in:
  - Drop Build-Depends on libdbus-glib-1-dev, no longer required.
  - Drop Recommends on desktop-base. It was originally added when nautilus
    was patched to show the .desktop icons from the desktop-base package. We
    don't do that anymore, so the Recommends has become obsolete.
  - Drop Recommends on consolekit. The ConsoleKit specific functionality has
    been moved into gnome-settings-daemon.
  - Drop Recommends on synaptic and app-install-data. We no longer call
    synaptic for mimetypes without a handler as this functionality is
    provided by alternatives like PackageKit or sessioninstaller now.
  - Update Vcs-* URLs.
* debian/nautilus-data.gconf-defaults:
  - Removed, obsolete.
* Refresh patches.

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
#include "nautilus-icon-private.h"
34
34
#include "nautilus-lib-self-check-functions.h"
35
35
#include "nautilus-selection-canvas-item.h"
36
 
#include "nautilus-marshal.h"
37
36
#include <atk/atkaction.h>
38
37
#include <eel/eel-accessibility.h>
39
38
#include <eel/eel-vfs-extensions.h>
144
143
 
145
144
static GType         nautilus_icon_container_accessible_get_type (void);
146
145
 
 
146
static void          preview_selected_items                         (NautilusIconContainer *container);
147
147
static void          activate_selected_items                        (NautilusIconContainer *container);
148
148
static void          activate_selected_items_alternate              (NautilusIconContainer *container,
149
149
                                                                     NautilusIcon          *icon);
150
 
static void          nautilus_icon_container_theme_changed          (gpointer               user_data);
151
150
static void          compute_stretch                                (StretchState          *start,
152
151
                                                                     StretchState          *current);
153
152
static NautilusIcon *get_first_selected_icon                        (NautilusIconContainer *container);
171
170
static gboolean      is_renaming                                    (NautilusIconContainer *container);
172
171
static gboolean      is_renaming_pending                            (NautilusIconContainer *container);
173
172
static void          process_pending_icon_to_rename                 (NautilusIconContainer *container);
174
 
static void          setup_label_gcs                                (NautilusIconContainer *container);
175
173
static void          nautilus_icon_container_stop_monitor_top_left  (NautilusIconContainer *container,
176
174
                                                                     NautilusIconData      *data,
177
175
                                                                     gconstpointer          client);
203
201
                                   NautilusIcon *icon_b);
204
202
 
205
203
static void store_layout_timestamps_now (NautilusIconContainer *container);
 
204
static void remove_search_entry_timeout (NautilusIconContainer *container);
206
205
 
207
206
static gpointer accessible_parent_class;
208
207
 
226
225
enum {
227
226
        ACTIVATE,
228
227
        ACTIVATE_ALTERNATE,
 
228
        ACTIVATE_PREVIEWER,
229
229
        BAND_SELECT_STARTED,
230
230
        BAND_SELECT_ENDED,
231
231
        BUTTON_PRESS,
240
240
        ICON_POSITION_CHANGED,
241
241
        GET_STORED_LAYOUT_TIMESTAMP,
242
242
        STORE_LAYOUT_TIMESTAMP,
243
 
        ICON_TEXT_CHANGED,
 
243
        ICON_RENAME_STARTED,
 
244
        ICON_RENAME_ENDED,
244
245
        ICON_STRETCH_STARTED,
245
246
        ICON_STRETCH_ENDED,
246
 
        RENAMING_ICON,
247
247
        LAYOUT_CHANGED,
248
248
        MOVE_COPY_ITEMS,
249
249
        HANDLE_NETSCAPE_URL,
250
250
        HANDLE_URI_LIST,
251
251
        HANDLE_TEXT,
252
252
        HANDLE_RAW,
253
 
        PREVIEW,
254
253
        SELECTION_CHANGED,
255
254
        ICON_ADDED,
256
255
        ICON_REMOVED,
257
256
        CLEARED,
258
 
        START_INTERACTIVE_SEARCH,
259
257
        LAST_SIGNAL
260
258
};
261
259
 
2612
2610
        AtkObject *accessible;
2613
2611
        NautilusIconContainerDetails *details;
2614
2612
        NautilusIconRubberbandInfo *band_info;
2615
 
        GdkRGBA *fill_color_gdk, outline, color;
 
2613
        GdkRGBA bg_color, border_color;
2616
2614
        GList *p;
2617
2615
        NautilusIcon *icon;
2618
 
        GtkStyleContext *style;
 
2616
        GtkStyleContext *context;
2619
2617
 
2620
2618
        details = container->details;
2621
2619
        band_info = &details->rubberband_info;
2632
2630
                (EEL_CANVAS (container), event->x, event->y,
2633
2631
                 &band_info->start_x, &band_info->start_y);
2634
2632
 
2635
 
        style = gtk_widget_get_style_context (GTK_WIDGET (container));
2636
 
        gtk_style_context_get_style (style,
2637
 
                                     "selection_box_rgba", &fill_color_gdk,
2638
 
                                     NULL);
2639
 
 
2640
 
        if (!fill_color_gdk) {
2641
 
                gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED,
2642
 
                                                        &color);
2643
 
                fill_color_gdk = gdk_rgba_copy (&color);
2644
 
        }
2645
 
 
2646
 
        if (fill_color_gdk->alpha == 1) {
2647
 
                fill_color_gdk->alpha = 0.25;
2648
 
        }
2649
 
 
2650
 
        outline = *fill_color_gdk;
2651
 
        eel_make_color_inactive (&outline);
 
2633
        context = gtk_widget_get_style_context (GTK_WIDGET (container));
 
2634
        gtk_style_context_save (context);
 
2635
        gtk_style_context_add_class (context, GTK_STYLE_CLASS_RUBBERBAND);
 
2636
 
 
2637
        gtk_style_context_get_background_color (context, GTK_STATE_FLAG_NORMAL, &bg_color);
 
2638
        gtk_style_context_get_border_color (context, GTK_STATE_FLAG_NORMAL, &border_color);
 
2639
 
 
2640
        gtk_style_context_restore (context);
2652
2641
 
2653
2642
        band_info->selection_rectangle = eel_canvas_item_new
2654
2643
                (eel_canvas_root
2658
2647
                 "y1", band_info->start_y,
2659
2648
                 "x2", band_info->start_x,
2660
2649
                 "y2", band_info->start_y,
2661
 
                 "fill_color_rgba", fill_color_gdk,
2662
 
                 "outline_color_rgba", &outline,
 
2650
                 "fill_color_rgba", &bg_color,
 
2651
                 "outline_color_rgba", &border_color,
2663
2652
                 "width_pixels", 1,
2664
2653
                 NULL);
2665
2654
 
2666
 
        gdk_rgba_free (fill_color_gdk);
2667
 
 
2668
2655
        accessible = atk_gobject_accessible_for_object
2669
2656
                (G_OBJECT (band_info->selection_rectangle));
2670
2657
        atk_object_set_name (accessible, "selection");
3891
3878
        } else if ((event->state & GDK_SHIFT_MASK) != 0) {
3892
3879
                activate_selected_items_alternate (container, NULL);
3893
3880
        } else {
3894
 
                activate_selected_items (container);
 
3881
                preview_selected_items (container);
3895
3882
        }
3896
3883
}
3897
3884
 
3990
3977
                gtk_widget_destroy (container->details->search_window);
3991
3978
                container->details->search_window = NULL;
3992
3979
                container->details->search_entry = NULL;
3993
 
                if (container->details->typeselect_flush_timeout) {
3994
 
                        g_source_remove (container->details->typeselect_flush_timeout);
3995
 
                        container->details->typeselect_flush_timeout = 0;
3996
 
                }
3997
3980
        }
3998
3981
 
 
3982
        remove_search_entry_timeout (container);
3999
3983
 
4000
3984
        GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->destroy (object);
4001
3985
}
4101
4085
        }
4102
4086
}
4103
4087
 
 
4088
static GtkSizeRequestMode
 
4089
get_request_mode (GtkWidget *widget)
 
4090
{
 
4091
  /* Don't trade size at all, since we get whatever we get anyway. */
 
4092
  return GTK_SIZE_REQUEST_CONSTANT_SIZE;
 
4093
}
 
4094
 
 
4095
/* We need to implement these since the GtkScrolledWindow uses them
 
4096
   to guess whether to show scrollbars or not, and if we don't report
 
4097
   anything it'll tend to get it wrong causing double calls
 
4098
   to size_allocate (at different sizes) during its size allocation. */
 
4099
static void
 
4100
get_prefered_width (GtkWidget *widget,
 
4101
                    gint      *minimum_size,
 
4102
                    gint      *natural_size)
 
4103
{
 
4104
        EelCanvasGroup *root;
 
4105
        double x1, x2;
 
4106
        int cx1, cx2;
 
4107
        int width;
 
4108
 
 
4109
        root = eel_canvas_root (EEL_CANVAS (widget));
 
4110
        eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (root),
 
4111
                                    &x1, NULL, &x2, NULL);
 
4112
        eel_canvas_w2c (EEL_CANVAS (widget), x1, 0, &cx1, NULL);
 
4113
        eel_canvas_w2c (EEL_CANVAS (widget), x2, 0, &cx2, NULL);
 
4114
 
 
4115
        width = cx2 - cx1;
 
4116
        if (natural_size) {
 
4117
                *natural_size = width;
 
4118
        }
 
4119
        if (minimum_size) {
 
4120
                *minimum_size = width;
 
4121
        }
 
4122
}
 
4123
 
 
4124
static void
 
4125
get_prefered_height (GtkWidget *widget,
 
4126
                     gint      *minimum_size,
 
4127
                     gint      *natural_size)
 
4128
{
 
4129
        EelCanvasGroup *root;
 
4130
        double y1, y2;
 
4131
        int cy1, cy2;
 
4132
        int height;
 
4133
 
 
4134
        root = eel_canvas_root (EEL_CANVAS (widget));
 
4135
        eel_canvas_item_get_bounds (EEL_CANVAS_ITEM (root),
 
4136
                                    NULL, &y1, NULL, &y2);
 
4137
        eel_canvas_w2c (EEL_CANVAS (widget), 0, y1, NULL, &cy1);
 
4138
        eel_canvas_w2c (EEL_CANVAS (widget), 0, y2, NULL, &cy2);
 
4139
 
 
4140
        height = cy2 - cy1;
 
4141
        if (natural_size) {
 
4142
                *natural_size = height;
 
4143
        }
 
4144
        if (minimum_size) {
 
4145
                *minimum_size = height;
 
4146
        }
 
4147
}
 
4148
 
4104
4149
static void
4105
4150
setup_background (NautilusIconContainer *container)
4106
4151
{
4156
4201
        nautilus_icon_dnd_init (container);
4157
4202
 
4158
4203
        setup_background (container);
4159
 
        setup_label_gcs (container);
4160
4204
 
4161
4205
        hadj = gtk_scrollable_get_hadjustment (GTK_SCROLLABLE (widget));
4162
4206
        g_signal_connect (hadj, "value_changed",
4176
4220
        container = NAUTILUS_ICON_CONTAINER (widget);
4177
4221
 
4178
4222
        nautilus_icon_dnd_fini (container);
4179
 
 
4180
 
        if (container->details->typeselect_flush_timeout) {
4181
 
                g_source_remove (container->details->typeselect_flush_timeout);
4182
 
                container->details->typeselect_flush_timeout = 0;
4183
 
        }
 
4223
        remove_search_entry_timeout (container);
4184
4224
 
4185
4225
        GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->unrealize (widget);
4186
4226
}
4200
4240
                GTK_WIDGET_CLASS (nautilus_icon_container_parent_class)->style_updated (widget);
4201
4241
        }
4202
4242
 
4203
 
        nautilus_icon_container_theme_changed (NAUTILUS_ICON_CONTAINER (widget));
4204
 
 
4205
4243
        if (gtk_widget_get_realized (widget)) {
4206
 
                invalidate_label_sizes (container);
 
4244
                invalidate_labels (container);
4207
4245
                nautilus_icon_container_request_update_all (container);
4208
4246
        }
4209
4247
}
4792
4830
                y = cont_y + cont_height;
4793
4831
        }
4794
4832
 
4795
 
        gtk_window_move (GTK_WINDOW (search_dialog), x, y);
4796
 
}
4797
 
 
4798
 
static gboolean
4799
 
nautilus_icon_container_real_search_enable_popdown (gpointer data)
4800
 
{
4801
 
        NautilusIconContainer *container = (NautilusIconContainer *)data;
4802
 
 
4803
 
        container->details->disable_popdown = FALSE;
4804
 
        
4805
 
        g_object_unref (container);
4806
 
 
4807
 
        return FALSE;
4808
 
}
4809
 
 
4810
 
static void
4811
 
nautilus_icon_container_search_enable_popdown (GtkWidget *widget,
4812
 
                                               gpointer   data)
4813
 
{
4814
 
        NautilusIconContainer *container = (NautilusIconContainer *) data;
4815
 
        
4816
 
        g_object_ref (container);
4817
 
        g_timeout_add (200, nautilus_icon_container_real_search_enable_popdown, data);
4818
 
}
4819
 
 
4820
 
static void
4821
 
nautilus_icon_container_search_disable_popdown (GtkEntry *entry,
4822
 
                                                GtkMenu  *menu,
4823
 
                                                gpointer  data)
4824
 
{
4825
 
        NautilusIconContainer *container = (NautilusIconContainer *) data;
4826
 
 
4827
 
        container->details->disable_popdown = TRUE;
4828
 
        g_signal_connect (menu, "hide",
4829
 
                          G_CALLBACK (nautilus_icon_container_search_enable_popdown),
4830
 
                          data);
 
4833
        gdk_window_move (gtk_widget_get_window (search_dialog), x, y);
4831
4834
}
4832
4835
 
4833
4836
/* Cut and paste from gtkwindow.c */
4859
4862
nautilus_icon_container_search_dialog_hide (GtkWidget *search_dialog,
4860
4863
                                            NautilusIconContainer *container)
4861
4864
{
4862
 
        if (container->details->disable_popdown) {
4863
 
                return;
4864
 
        }
4865
 
 
4866
4865
        if (container->details->search_entry_changed_id) {
4867
4866
                g_signal_handler_disconnect (container->details->search_entry,
4868
4867
                                             container->details->search_entry_changed_id);
4869
4868
                container->details->search_entry_changed_id = 0;
4870
4869
        }
4871
 
        if (container->details->typeselect_flush_timeout) {
4872
 
                g_source_remove (container->details->typeselect_flush_timeout);
4873
 
                container->details->typeselect_flush_timeout = 0;
4874
 
        }
 
4870
 
 
4871
        remove_search_entry_timeout (container);
4875
4872
 
4876
4873
        /* send focus-in event */
4877
4874
        send_focus_change (GTK_WIDGET (container->details->search_entry), FALSE);
4880
4877
}
4881
4878
 
4882
4879
static gboolean
4883
 
nautilus_icon_container_search_entry_flush_timeout (NautilusIconContainer *container)
 
4880
nautilus_icon_container_search_entry_flush_timeout (gpointer data)
4884
4881
{
 
4882
        NautilusIconContainer *container = data;
 
4883
 
 
4884
        container->details->typeselect_flush_timeout = 0;
4885
4885
        nautilus_icon_container_search_dialog_hide (container->details->search_window, container);
4886
4886
 
4887
 
        return TRUE;
 
4887
        return FALSE;
 
4888
}
 
4889
 
 
4890
static void
 
4891
add_search_entry_timeout (NautilusIconContainer *container)
 
4892
{
 
4893
        container->details->typeselect_flush_timeout =
 
4894
                g_timeout_add_seconds (NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT,
 
4895
                                       nautilus_icon_container_search_entry_flush_timeout,
 
4896
                                       container);
 
4897
}
 
4898
 
 
4899
static void
 
4900
remove_search_entry_timeout (NautilusIconContainer *container)
 
4901
{
 
4902
        if (container->details->typeselect_flush_timeout) {
 
4903
                g_source_remove (container->details->typeselect_flush_timeout);
 
4904
                container->details->typeselect_flush_timeout = 0;
 
4905
        }
 
4906
}
 
4907
 
 
4908
static void
 
4909
reset_search_entry_timeout (NautilusIconContainer *container)
 
4910
{
 
4911
        remove_search_entry_timeout (container);
 
4912
        add_search_entry_timeout (container);
4888
4913
}
4889
4914
 
4890
4915
/* Because we're visible but offscreen, we just set a flag in the preedit
4896
4921
                                                NautilusIconContainer *container)
4897
4922
{
4898
4923
        container->details->imcontext_changed = 1;
4899
 
        if (container->details->typeselect_flush_timeout) {
4900
 
                g_source_remove (container->details->typeselect_flush_timeout);
4901
 
                container->details->typeselect_flush_timeout =
4902
 
                        g_timeout_add_seconds (NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT,
4903
 
                                (GSourceFunc) nautilus_icon_container_search_entry_flush_timeout,
4904
 
                                container);
4905
 
        }
 
4924
        reset_search_entry_timeout (container);
4906
4925
}
4907
4926
 
4908
4927
static void
4920
4939
                                             GdkEventAny *event,
4921
4940
                                             NautilusIconContainer *container)
4922
4941
{
4923
 
        g_assert (GTK_IS_WIDGET (widget));
4924
 
 
4925
4942
        nautilus_icon_container_search_dialog_hide (widget, container);
4926
4943
 
4927
4944
        return TRUE;
4932
4949
                                                   GdkEventButton *event,
4933
4950
                                                   NautilusIconContainer *container)
4934
4951
{
4935
 
        g_assert (GTK_IS_WIDGET (widget));
4936
 
 
4937
4952
        nautilus_icon_container_search_dialog_hide (widget, container);
4938
4953
 
4939
4954
        if (event->window == gtk_layout_get_bin_window (GTK_LAYOUT (container))) {
4943
4958
        return TRUE;
4944
4959
}
4945
4960
 
 
4961
static gboolean
 
4962
nautilus_icon_container_search_entry_button_press_event (GtkWidget *widget,
 
4963
                                                         GdkEventButton *event,
 
4964
                                                         NautilusIconContainer *container)
 
4965
{
 
4966
        reset_search_entry_timeout (container);
 
4967
 
 
4968
        return FALSE;
 
4969
}
 
4970
 
 
4971
static void
 
4972
nautilus_icon_container_search_populate_popup (GtkEntry *entry,
 
4973
                                               GtkMenu *menu,
 
4974
                                               NautilusIconContainer *container)
 
4975
{
 
4976
        remove_search_entry_timeout (container);
 
4977
        g_signal_connect_swapped (menu, "hide",
 
4978
                                  G_CALLBACK (add_search_entry_timeout), container);
 
4979
}
 
4980
 
4946
4981
static void
4947
4982
nautilus_icon_container_get_icon_text (NautilusIconContainer *container,
4948
4983
                                       NautilusIconData      *data,
5090
5125
                retval = TRUE;
5091
5126
        }
5092
5127
 
5093
 
        /* renew the flush timeout */
5094
 
        if (retval && container->details->typeselect_flush_timeout) {
5095
 
                g_source_remove (container->details->typeselect_flush_timeout);
5096
 
                container->details->typeselect_flush_timeout =
5097
 
                        g_timeout_add_seconds (NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT,
5098
 
                                (GSourceFunc) nautilus_icon_container_search_entry_flush_timeout,
5099
 
                                container);
5100
 
        }
 
5128
        reset_search_entry_timeout (container);
5101
5129
 
5102
5130
        return retval;
5103
5131
}
5151
5179
                retval = TRUE;
5152
5180
        }
5153
5181
 
5154
 
        /* renew the flush timeout */
5155
 
        if (retval && container->details->typeselect_flush_timeout) {
5156
 
                g_source_remove (container->details->typeselect_flush_timeout);
5157
 
                container->details->typeselect_flush_timeout =
5158
 
                        g_timeout_add_seconds (NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT,
5159
 
                                (GSourceFunc) nautilus_icon_container_search_entry_flush_timeout,
5160
 
                                container);
5161
 
        }
 
5182
        reset_search_entry_timeout (container);
5162
5183
 
5163
5184
        return retval;
5164
5185
}
5179
5200
 
5180
5201
        /* search */
5181
5202
        unselect_all (container);
5182
 
        if (container->details->typeselect_flush_timeout)
5183
 
        {
5184
 
                g_source_remove (container->details->typeselect_flush_timeout);
5185
 
                container->details->typeselect_flush_timeout =
5186
 
                        g_timeout_add_seconds (NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT,
5187
 
                                (GSourceFunc) nautilus_icon_container_search_entry_flush_timeout,
5188
 
                                container);
5189
 
        }
 
5203
        reset_search_entry_timeout (container);
5190
5204
 
5191
5205
        if (len < 1) {
5192
5206
                return;
5232
5246
        gtk_widget_show (frame);
5233
5247
        gtk_container_add (GTK_CONTAINER (container->details->search_window), frame);
5234
5248
 
5235
 
        vbox = gtk_vbox_new (FALSE, 0);
 
5249
        vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
5236
5250
        gtk_widget_show (vbox);
5237
5251
        gtk_container_add (GTK_CONTAINER (frame), vbox);
5238
5252
        gtk_container_set_border_width (GTK_CONTAINER (vbox), 3);
5240
5254
        /* add entry */
5241
5255
        container->details->search_entry = gtk_entry_new ();
5242
5256
        gtk_widget_show (container->details->search_entry);
5243
 
        g_signal_connect (container->details->search_entry, "populate_popup",
5244
 
                          G_CALLBACK (nautilus_icon_container_search_disable_popdown),
 
5257
        g_signal_connect (container->details->search_entry, "populate-popup",
 
5258
                          G_CALLBACK (nautilus_icon_container_search_populate_popup),
5245
5259
                          container);
5246
5260
        g_signal_connect (container->details->search_entry, "activate",
5247
5261
                          G_CALLBACK (nautilus_icon_container_search_activate),
5248
5262
                          container);
5249
 
        g_signal_connect (container->details->search_entry,
5250
 
                          "preedit-changed",
 
5263
        g_signal_connect (container->details->search_entry, "preedit-changed",
5251
5264
                          G_CALLBACK (nautilus_icon_container_search_preedit_changed),
5252
5265
                          container);
 
5266
        g_signal_connect (container->details->search_entry, "button-press-event",
 
5267
                          G_CALLBACK (nautilus_icon_container_search_entry_button_press_event),
 
5268
                          container);
5253
5269
        gtk_container_add (GTK_CONTAINER (vbox), container->details->search_entry);
5254
5270
 
5255
5271
        gtk_widget_realize (container->details->search_entry);
5259
5275
 * started this by typing the start_interactive_search keybinding.  Otherwise, it came from 
5260
5276
 */
5261
5277
static gboolean
5262
 
nautilus_icon_container_real_start_interactive_search (NautilusIconContainer *container,
5263
 
                                                       gboolean keybinding)
 
5278
nautilus_icon_container_start_interactive_search (NautilusIconContainer *container)
5264
5279
{
5265
5280
        /* We only start interactive search if we have focus.  If one of our
5266
5281
         * children have focus, we don't want to start the search.
5278
5293
 
5279
5294
        nautilus_icon_container_ensure_interactive_directory (container);
5280
5295
 
5281
 
        if (keybinding) {
5282
 
                gtk_entry_set_text (GTK_ENTRY (container->details->search_entry), "");
5283
 
        }
5284
 
 
5285
5296
        /* done, show it */
5286
5297
        nautilus_icon_container_search_position_func (container, container->details->search_window);
5287
5298
        gtk_widget_show (container->details->search_window);
5292
5303
                                container);
5293
5304
        }
5294
5305
 
5295
 
        container->details->typeselect_flush_timeout =
5296
 
                g_timeout_add_seconds (NAUTILUS_ICON_CONTAINER_SEARCH_DIALOG_TIMEOUT,
5297
 
                        (GSourceFunc) nautilus_icon_container_search_entry_flush_timeout,
5298
 
                        container);
5299
 
 
5300
5306
        /* Grab focus will select all the text.  We don't want that to happen, so we
5301
5307
        * call the parent instance and bypass the selection change.  This is probably
5302
5308
        * really non-kosher. */
5313
5319
}
5314
5320
 
5315
5321
static gboolean
5316
 
nautilus_icon_container_start_interactive_search (NautilusIconContainer *container)
5317
 
{
5318
 
        return nautilus_icon_container_real_start_interactive_search (container, TRUE);
5319
 
}
5320
 
 
5321
 
static gboolean
5322
5322
handle_popups (NautilusIconContainer *container,
5323
5323
               GdkEventKey           *event,
5324
5324
               const char            *signal)
5447
5447
                                                         "context_click_background");
5448
5448
                        }
5449
5449
                        break;
 
5450
                case GDK_KEY_v:
 
5451
                        /* Eat Control + v to not enable type ahead */
 
5452
                        if ((event->state & GDK_CONTROL_MASK) != 0) {
 
5453
                                handled = TRUE;
 
5454
                        }
 
5455
                        break;
5450
5456
                default:
5451
5457
                        break;
5452
5458
                }
5462
5468
        if (!handled &&
5463
5469
            event->keyval != GDK_KEY_slash /* don't steal slash key event, used for "go to" */ &&
5464
5470
            event->keyval != GDK_KEY_BackSpace &&
5465
 
            event->keyval != GDK_KEY_Delete &&
5466
 
            !(event->keyval == GDK_KEY_v && event->state == GDK_CONTROL_MASK)) {
 
5471
            event->keyval != GDK_KEY_Delete) {
5467
5472
                GdkEvent *new_event;
5468
5473
                GdkWindow *window;
5469
5474
                char *old_text;
5508
5513
                g_free (old_text);
5509
5514
                if (container->details->imcontext_changed ||    /* we're in a preedit */
5510
5515
                    (retval && text_modified)) {                /* ...or the text was modified */
5511
 
                        if (nautilus_icon_container_real_start_interactive_search (container, FALSE)) {
 
5516
                        if (nautilus_icon_container_start_interactive_search (container)) {
5512
5517
                                gtk_widget_grab_focus (GTK_WIDGET (container));
5513
5518
                                return TRUE;
5514
5519
                        } else {
5631
5636
{
5632
5637
        GtkWidgetClass *widget_class;
5633
5638
        EelCanvasClass *canvas_class;
5634
 
        GtkBindingSet *binding_set;
5635
5639
 
5636
5640
        G_OBJECT_CLASS (class)->constructor = nautilus_icon_container_constructor;
5637
5641
        G_OBJECT_CLASS (class)->finalize = finalize;
5654
5658
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5655
5659
                                                 button_press),
5656
5660
                                NULL, NULL,
5657
 
                                nautilus_marshal_BOOLEAN__POINTER,
 
5661
                                g_cclosure_marshal_generic,
5658
5662
                                G_TYPE_BOOLEAN, 1,
5659
5663
                                GDK_TYPE_EVENT);
5660
5664
        signals[ACTIVATE]
5677
5681
                                g_cclosure_marshal_VOID__POINTER,
5678
5682
                                G_TYPE_NONE, 1,
5679
5683
                                G_TYPE_POINTER);
 
5684
        signals[ACTIVATE_PREVIEWER]
 
5685
                = g_signal_new ("activate_previewer",
 
5686
                                G_TYPE_FROM_CLASS (class),
 
5687
                                G_SIGNAL_RUN_LAST,
 
5688
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
 
5689
                                                 activate_previewer),
 
5690
                                NULL, NULL,
 
5691
                                g_cclosure_marshal_generic,
 
5692
                                G_TYPE_NONE, 2,
 
5693
                                G_TYPE_POINTER, G_TYPE_POINTER);
5680
5694
        signals[CONTEXT_CLICK_SELECTION]
5681
5695
                = g_signal_new ("context_click_selection",
5682
5696
                                G_TYPE_FROM_CLASS (class),
5714
5728
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5715
5729
                                                 icon_position_changed),
5716
5730
                                NULL, NULL,
5717
 
                                nautilus_marshal_VOID__POINTER_POINTER,
 
5731
                                g_cclosure_marshal_generic,
5718
5732
                                G_TYPE_NONE, 2,
5719
5733
                                G_TYPE_POINTER,
5720
5734
                                G_TYPE_POINTER);
5721
 
        signals[ICON_TEXT_CHANGED]
5722
 
                = g_signal_new ("icon_text_changed",
5723
 
                                G_TYPE_FROM_CLASS (class),
5724
 
                                G_SIGNAL_RUN_LAST,
5725
 
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5726
 
                                                 icon_text_changed),
5727
 
                                NULL, NULL,
5728
 
                                nautilus_marshal_VOID__POINTER_STRING,
5729
 
                                G_TYPE_NONE, 2,
5730
 
                                G_TYPE_POINTER,
5731
 
                                G_TYPE_STRING);
5732
5735
        signals[ICON_STRETCH_STARTED]
5733
5736
                = g_signal_new ("icon_stretch_started",
5734
5737
                                G_TYPE_FROM_CLASS (class),
5749
5752
                                g_cclosure_marshal_VOID__POINTER,
5750
5753
                                G_TYPE_NONE, 1,
5751
5754
                                G_TYPE_POINTER);
5752
 
        signals[RENAMING_ICON]
5753
 
                = g_signal_new ("renaming_icon",
 
5755
        signals[ICON_RENAME_STARTED]
 
5756
                = g_signal_new ("icon_rename_started",
5754
5757
                                G_TYPE_FROM_CLASS (class),
5755
5758
                                G_SIGNAL_RUN_LAST,
5756
5759
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5757
 
                                                 renaming_icon),
 
5760
                                                 icon_rename_started),
5758
5761
                                NULL, NULL,
5759
5762
                                g_cclosure_marshal_VOID__POINTER,
5760
5763
                                G_TYPE_NONE, 1,
5761
5764
                                G_TYPE_POINTER);
 
5765
        signals[ICON_RENAME_ENDED]
 
5766
                = g_signal_new ("icon_rename_ended",
 
5767
                                G_TYPE_FROM_CLASS (class),
 
5768
                                G_SIGNAL_RUN_LAST,
 
5769
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
 
5770
                                                 icon_rename_ended),
 
5771
                                NULL, NULL,
 
5772
                                g_cclosure_marshal_generic,
 
5773
                                G_TYPE_NONE, 2,
 
5774
                                G_TYPE_POINTER,
 
5775
                                G_TYPE_STRING);
5762
5776
        signals[GET_ICON_URI]
5763
5777
                = g_signal_new ("get_icon_uri",
5764
5778
                                G_TYPE_FROM_CLASS (class),
5766
5780
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5767
5781
                                                 get_icon_uri),
5768
5782
                                NULL, NULL,
5769
 
                                nautilus_marshal_STRING__POINTER,
 
5783
                                g_cclosure_marshal_generic,
5770
5784
                                G_TYPE_STRING, 1,
5771
5785
                                G_TYPE_POINTER);
5772
5786
        signals[GET_ICON_DROP_TARGET_URI]
5776
5790
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5777
5791
                                                 get_icon_drop_target_uri),
5778
5792
                                NULL, NULL,
5779
 
                                nautilus_marshal_STRING__POINTER,
 
5793
                                g_cclosure_marshal_generic,
5780
5794
                                G_TYPE_STRING, 1,
5781
5795
                                G_TYPE_POINTER);
5782
5796
        signals[MOVE_COPY_ITEMS] 
5786
5800
                                G_STRUCT_OFFSET (NautilusIconContainerClass, 
5787
5801
                                                 move_copy_items),
5788
5802
                                NULL, NULL,
5789
 
                                nautilus_marshal_VOID__POINTER_POINTER_POINTER_ENUM_INT_INT,
 
5803
                                g_cclosure_marshal_generic,
5790
5804
                                G_TYPE_NONE, 6,
5791
5805
                                G_TYPE_POINTER,
5792
5806
                                G_TYPE_POINTER,
5801
5815
                                G_STRUCT_OFFSET (NautilusIconContainerClass, 
5802
5816
                                                 handle_netscape_url),
5803
5817
                                NULL, NULL,
5804
 
                                nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
 
5818
                                g_cclosure_marshal_generic,
5805
5819
                                G_TYPE_NONE, 5,
5806
5820
                                G_TYPE_STRING,
5807
5821
                                G_TYPE_STRING,
5815
5829
                                G_STRUCT_OFFSET (NautilusIconContainerClass, 
5816
5830
                                                     handle_uri_list),
5817
5831
                                NULL, NULL,
5818
 
                                nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
 
5832
                                g_cclosure_marshal_generic,
5819
5833
                                G_TYPE_NONE, 5,
5820
5834
                                G_TYPE_STRING,
5821
5835
                                G_TYPE_STRING,
5829
5843
                                G_STRUCT_OFFSET (NautilusIconContainerClass, 
5830
5844
                                                 handle_text),
5831
5845
                                NULL, NULL,
5832
 
                                nautilus_marshal_VOID__STRING_STRING_ENUM_INT_INT,
 
5846
                                g_cclosure_marshal_generic,
5833
5847
                                G_TYPE_NONE, 5,
5834
5848
                                G_TYPE_STRING,
5835
5849
                                G_TYPE_STRING,
5843
5857
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5844
5858
                                                 handle_raw),
5845
5859
                                NULL, NULL,
5846
 
                                nautilus_marshal_VOID__POINTER_INT_STRING_STRING_ENUM_INT_INT,
 
5860
                                g_cclosure_marshal_generic,
5847
5861
                                G_TYPE_NONE, 7,
5848
5862
                                G_TYPE_POINTER,
5849
5863
                                G_TYPE_INT,
5859
5873
                                G_STRUCT_OFFSET (NautilusIconContainerClass, 
5860
5874
                                                 get_container_uri),
5861
5875
                                NULL, NULL,
5862
 
                                nautilus_marshal_STRING__VOID,
 
5876
                                g_cclosure_marshal_generic,
5863
5877
                                G_TYPE_STRING, 0);
5864
5878
        signals[CAN_ACCEPT_ITEM] 
5865
5879
                = g_signal_new ("can_accept_item",
5868
5882
                                G_STRUCT_OFFSET (NautilusIconContainerClass, 
5869
5883
                                                 can_accept_item),
5870
5884
                                NULL, NULL,
5871
 
                                nautilus_marshal_INT__POINTER_STRING,
 
5885
                                g_cclosure_marshal_generic,
5872
5886
                                G_TYPE_INT, 2,
5873
5887
                                G_TYPE_POINTER,
5874
5888
                                G_TYPE_STRING);
5879
5893
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5880
5894
                                                 get_stored_icon_position),
5881
5895
                                NULL, NULL,
5882
 
                                nautilus_marshal_BOOLEAN__POINTER_POINTER,
 
5896
                                g_cclosure_marshal_generic,
5883
5897
                                G_TYPE_BOOLEAN, 2,
5884
5898
                                G_TYPE_POINTER,
5885
5899
                                G_TYPE_POINTER);
5890
5904
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5891
5905
                                                 get_stored_layout_timestamp),
5892
5906
                                NULL, NULL,
5893
 
                                nautilus_marshal_BOOLEAN__POINTER_POINTER,
 
5907
                                g_cclosure_marshal_generic,
5894
5908
                                G_TYPE_BOOLEAN, 2,
5895
5909
                                G_TYPE_POINTER,
5896
5910
                                G_TYPE_POINTER);
5901
5915
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5902
5916
                                                 store_layout_timestamp),
5903
5917
                                NULL, NULL,
5904
 
                                nautilus_marshal_BOOLEAN__POINTER_POINTER,
 
5918
                                g_cclosure_marshal_generic,
5905
5919
                                G_TYPE_BOOLEAN, 2,
5906
5920
                                G_TYPE_POINTER,
5907
5921
                                G_TYPE_POINTER);
5914
5928
                                NULL, NULL,
5915
5929
                                g_cclosure_marshal_VOID__VOID,
5916
5930
                                G_TYPE_NONE, 0);
5917
 
        signals[PREVIEW]
5918
 
                = g_signal_new ("preview",
5919
 
                                G_TYPE_FROM_CLASS (class),
5920
 
                                G_SIGNAL_RUN_LAST,
5921
 
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5922
 
                                                 preview),
5923
 
                                NULL, NULL,
5924
 
                                nautilus_marshal_INT__POINTER_BOOLEAN,
5925
 
                                G_TYPE_INT, 2,
5926
 
                                G_TYPE_POINTER,
5927
 
                                G_TYPE_BOOLEAN);
5928
5931
        signals[BAND_SELECT_STARTED]
5929
5932
                = g_signal_new ("band_select_started",
5930
5933
                                G_TYPE_FROM_CLASS (class),
5972
5975
                                g_cclosure_marshal_VOID__VOID,
5973
5976
                                G_TYPE_NONE, 0);
5974
5977
 
5975
 
        signals[START_INTERACTIVE_SEARCH]
5976
 
                = g_signal_new ("start_interactive_search",
5977
 
                                G_TYPE_FROM_CLASS (class),
5978
 
                                G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION,
5979
 
                                G_STRUCT_OFFSET (NautilusIconContainerClass,
5980
 
                                                 start_interactive_search),
5981
 
                                NULL, NULL,
5982
 
                                nautilus_marshal_BOOLEAN__VOID,
5983
 
                                G_TYPE_BOOLEAN, 0);
5984
 
 
5985
5978
        /* GtkWidget class.  */
5986
5979
 
5987
5980
        widget_class = GTK_WIDGET_CLASS (class);
5988
5981
        widget_class->destroy = destroy;
5989
5982
        widget_class->size_allocate = size_allocate;
 
5983
        widget_class->get_request_mode = get_request_mode;
 
5984
        widget_class->get_preferred_width = get_prefered_width;
 
5985
        widget_class->get_preferred_height = get_prefered_height;
5990
5986
        widget_class->realize = realize;
5991
5987
        widget_class->unrealize = unrealize;
5992
5988
        widget_class->button_press_event = button_press_event;
6001
5997
        canvas_class = EEL_CANVAS_CLASS (class);
6002
5998
        canvas_class->draw_background = draw_canvas_background;
6003
5999
 
6004
 
        class->start_interactive_search = nautilus_icon_container_start_interactive_search;
6005
 
 
6006
 
        gtk_widget_class_install_style_property (widget_class,
6007
 
                                                 g_param_spec_boxed ("selection_box_rgba",
6008
 
                                                                     "Selection Box RGBA",
6009
 
                                                                     "Color of the selection box",
6010
 
                                                                     GDK_TYPE_RGBA,
6011
 
                                                                     G_PARAM_READABLE));
6012
6000
        gtk_widget_class_install_style_property (widget_class,
6013
6001
                                                 g_param_spec_boolean ("activate_prelight_icon_label",
6014
6002
                                                                     "Activate Prelight Icon Label",
6015
6003
                                                                     "Whether icon labels should make use of its prelight color in prelight state",
6016
6004
                                                                     FALSE,
6017
6005
                                                                     G_PARAM_READABLE));
6018
 
                                                                                                                                     
6019
 
 
6020
 
        binding_set = gtk_binding_set_by_class (class);
6021
 
 
6022
 
        gtk_binding_entry_add_signal (binding_set, GDK_KEY_f, GDK_CONTROL_MASK, "start_interactive_search", 0);
6023
 
        gtk_binding_entry_add_signal (binding_set, GDK_KEY_F, GDK_CONTROL_MASK, "start_interactive_search", 0);
6024
6006
}
6025
6007
 
6026
6008
static void
6167
6149
        g_signal_connect (container, "focus-out-event",
6168
6150
                          G_CALLBACK (handle_focus_out_event), NULL);
6169
6151
 
6170
 
        /* read in theme-dependent data */
6171
 
        nautilus_icon_container_theme_changed (container);
6172
 
 
6173
6152
        if (!setup_prefs) {
6174
6153
                g_signal_connect_swapped (nautilus_icon_view_preferences,
6175
6154
                                          "changed::" NAUTILUS_PREFERENCES_ICON_VIEW_TEXT_ELLIPSIS_LIMIT,
6672
6651
}
6673
6652
 
6674
6653
static void
 
6654
preview_selected_items (NautilusIconContainer *container)
 
6655
{
 
6656
        GList *selection;
 
6657
        GArray *locations;
 
6658
        gint idx;
 
6659
 
 
6660
        g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
 
6661
 
 
6662
        selection = nautilus_icon_container_get_selection (container);
 
6663
        locations = nautilus_icon_container_get_selected_icon_locations (container);
 
6664
 
 
6665
        for (idx = 0; idx < locations->len; idx++) {
 
6666
                GdkPoint *point = &(g_array_index (locations, GdkPoint, idx));
 
6667
                gint scroll_x, scroll_y;
 
6668
 
 
6669
                eel_canvas_get_scroll_offsets (EEL_CANVAS (container),
 
6670
                                               &scroll_x, &scroll_y);
 
6671
 
 
6672
                point->x -= scroll_x;
 
6673
                point->y -= scroll_y;
 
6674
        }
 
6675
 
 
6676
        if (selection != NULL) {
 
6677
                g_signal_emit (container,
 
6678
                               signals[ACTIVATE_PREVIEWER], 0,
 
6679
                               selection, locations);
 
6680
        }
 
6681
        g_list_free (selection);        
 
6682
}
 
6683
 
 
6684
static void
6675
6685
activate_selected_items_alternate (NautilusIconContainer *container,
6676
6686
                                   NautilusIcon *icon)
6677
6687
{
8251
8261
                                          end_offset);
8252
8262
        
8253
8263
        g_signal_emit (container,
8254
 
                       signals[RENAMING_ICON], 0,
 
8264
                       signals[ICON_RENAME_STARTED], 0,
8255
8265
                       GTK_EDITABLE (details->rename_widget));
8256
8266
        
8257
8267
        nautilus_icon_container_update_icon (container, icon);
8265
8275
end_renaming_mode (NautilusIconContainer *container, gboolean commit)
8266
8276
{
8267
8277
        NautilusIcon *icon;
8268
 
        const char *changed_text;
 
8278
        const char *changed_text = NULL;
8269
8279
 
8270
8280
        set_pending_icon_to_rename (container, NULL);
8271
8281
 
8289
8299
        if (commit) {
8290
8300
                /* Verify that text has been modified before signalling change. */                      
8291
8301
                changed_text = eel_editable_label_get_text (EEL_EDITABLE_LABEL (container->details->rename_widget));
8292
 
                if (strcmp (container->details->original_text, changed_text) != 0) {                    
8293
 
                        g_signal_emit (container,
8294
 
                                       signals[ICON_TEXT_CHANGED], 0,
8295
 
                                       icon->data,
8296
 
                                       changed_text);
 
8302
                if (strcmp (container->details->original_text, changed_text) == 0) {
 
8303
                        changed_text = NULL;
8297
8304
                }
8298
8305
        }
8299
8306
 
 
8307
        g_signal_emit (container,
 
8308
                       signals[ICON_RENAME_ENDED], 0,
 
8309
                       icon->data,
 
8310
                       changed_text);
 
8311
 
8300
8312
        gtk_widget_hide (container->details->rename_widget);
8301
 
 
8302
8313
        g_free (container->details->original_text);
8303
 
 
8304
 
}
8305
 
 
8306
 
/* emit preview signal, called by the canvas item */
8307
 
gboolean
8308
 
nautilus_icon_container_emit_preview_signal (NautilusIconContainer *icon_container,
8309
 
                                             NautilusIcon *icon,
8310
 
                                             gboolean start_flag)
8311
 
{
8312
 
        gboolean result;
8313
 
        
8314
 
        g_return_val_if_fail (NAUTILUS_IS_ICON_CONTAINER (icon_container), FALSE);
8315
 
        g_return_val_if_fail (icon != NULL, FALSE);
8316
 
        g_return_val_if_fail (start_flag == FALSE || start_flag == TRUE, FALSE);
8317
 
        
8318
 
        result = FALSE;
8319
 
        g_signal_emit (icon_container,
8320
 
                         signals[PREVIEW], 0,
8321
 
                         icon->data,
8322
 
                         start_flag,
8323
 
                         &result);
8324
 
        
8325
 
        return result;
8326
8314
}
8327
8315
 
8328
8316
gboolean
8358
8346
        container->details->single_click_mode = single_click_mode;
8359
8347
}
8360
8348
 
8361
 
 
8362
 
/* update the label color when the background changes */
8363
 
 
8364
 
void
8365
 
nautilus_icon_container_get_label_color (NautilusIconContainer *container,
8366
 
                                         GdkRGBA               *color,
8367
 
                                         gboolean               is_name,
8368
 
                                         gboolean               is_highlight,
8369
 
                                         gboolean               is_prelit)
8370
 
{
8371
 
        int idx;
8372
 
        
8373
 
        if (is_name) {
8374
 
                if (is_highlight) {
8375
 
                        if (gtk_widget_has_focus (GTK_WIDGET (container))) {
8376
 
                                idx = LABEL_COLOR_HIGHLIGHT;
8377
 
                        } else {
8378
 
                                idx = LABEL_COLOR_ACTIVE;
8379
 
                        }
8380
 
                } else {
8381
 
                        if (is_prelit) {
8382
 
                                idx = LABEL_COLOR_PRELIGHT;
8383
 
                        } else {
8384
 
                                idx = LABEL_COLOR;
8385
 
                        }
8386
 
                }
8387
 
        } else {
8388
 
                if (is_highlight) {
8389
 
                        if (gtk_widget_has_focus (GTK_WIDGET (container))) {
8390
 
                                idx = LABEL_INFO_COLOR_HIGHLIGHT;
8391
 
                        } else {
8392
 
                                idx = LABEL_INFO_COLOR_ACTIVE;
8393
 
                        }
8394
 
                } else {
8395
 
                        idx = LABEL_INFO_COLOR;
8396
 
                }
8397
 
        }
8398
 
 
8399
 
        if (color) {
8400
 
                *color = container->details->label_colors[idx];
8401
 
        }
8402
 
}
8403
 
 
8404
 
static void
8405
 
setup_gc_with_fg (NautilusIconContainer *container, int idx, GdkRGBA *color)
8406
 
{
8407
 
        container->details->label_colors[idx] = *color;
8408
 
}
8409
 
 
8410
 
static void
8411
 
setup_label_gcs (NautilusIconContainer *container)
8412
 
{
8413
 
        GtkWidget *widget;
8414
 
        GtkStyleContext *style;
8415
 
        GdkRGBA color;
8416
 
        
8417
 
        if (!gtk_widget_get_realized (GTK_WIDGET (container)))
8418
 
                return;
8419
 
 
8420
 
        widget = GTK_WIDGET (container);
8421
 
 
8422
 
        g_assert (NAUTILUS_IS_ICON_CONTAINER (container));
8423
 
 
8424
 
        /* read the info colors from the current theme; use a reasonable default if undefined */
8425
 
        style = gtk_widget_get_style_context (widget);
8426
 
 
8427
 
        gtk_style_context_get_color (style,
8428
 
                                     GTK_STATE_FLAG_SELECTED,
8429
 
                                     &color);
8430
 
        setup_gc_with_fg (container, LABEL_COLOR_HIGHLIGHT, &color);
8431
 
        setup_gc_with_fg (container, LABEL_INFO_COLOR_HIGHLIGHT, &color);
8432
 
 
8433
 
 
8434
 
        gtk_style_context_get_color (style, GTK_STATE_FLAG_ACTIVE, &color);
8435
 
        setup_gc_with_fg (container, LABEL_COLOR_ACTIVE, &color);
8436
 
        setup_gc_with_fg (container, LABEL_INFO_COLOR_ACTIVE, &color);
8437
 
 
8438
 
        gtk_style_context_get_color (style, GTK_STATE_FLAG_PRELIGHT, &color);
8439
 
        setup_gc_with_fg (container, LABEL_COLOR_PRELIGHT, &color);
8440
 
 
8441
 
        gtk_style_context_get_color (style, GTK_STATE_FLAG_INSENSITIVE, &color);
8442
 
        setup_gc_with_fg (container, LABEL_INFO_COLOR, 
8443
 
                          &color);
8444
 
        
8445
 
        if (!nautilus_icon_container_get_is_desktop (container)) {
8446
 
                gtk_style_context_get_color (style, GTK_STATE_FLAG_NORMAL, &color);
8447
 
                setup_gc_with_fg (container, LABEL_COLOR, &color);
8448
 
        } else {
8449
 
                GdkRGBA tmp;
8450
 
 
8451
 
                gdk_rgba_parse (&tmp, "#EFEFEF");
8452
 
                setup_gc_with_fg (container, LABEL_COLOR, &tmp);
8453
 
        }
8454
 
}
8455
 
 
8456
8349
/* Return if the icon container is a fixed size */
8457
8350
gboolean
8458
8351
nautilus_icon_container_get_is_fixed_size (NautilusIconContainer *container)
8487
8380
        g_return_if_fail (NAUTILUS_IS_ICON_CONTAINER (container));
8488
8381
 
8489
8382
        container->details->is_desktop = is_desktop;
 
8383
 
 
8384
        if (is_desktop) {
 
8385
                GtkStyleContext *context;
 
8386
 
 
8387
                context = gtk_widget_get_style_context (GTK_WIDGET (container));
 
8388
                gtk_style_context_add_class (context, "nautilus-desktop");
 
8389
        }
8490
8390
}
8491
8391
 
8492
8392
void
8522
8422
 
8523
8423
/* handle theme changes */
8524
8424
 
8525
 
static void
8526
 
nautilus_icon_container_theme_changed (gpointer user_data)
8527
 
{
8528
 
        NautilusIconContainer *container;
8529
 
        GtkStyleContext *style;
8530
 
        GdkRGBA color;
8531
 
 
8532
 
        container = NAUTILUS_ICON_CONTAINER (user_data);
8533
 
        style = gtk_widget_get_style_context (GTK_WIDGET (container));
8534
 
 
8535
 
        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_SELECTED, &color);
8536
 
        container->details->highlight_color_rgba = color;
8537
 
 
8538
 
        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_ACTIVE, &color);  
8539
 
        container->details->active_color_rgba = color;
8540
 
 
8541
 
        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_PRELIGHT, &color);
8542
 
        container->details->prelight_color_rgba = color;
8543
 
  
8544
 
        gtk_style_context_get_background_color (style, GTK_STATE_FLAG_NORMAL, &color);
8545
 
        container->details->normal_color_rgba = color;
8546
 
 
8547
 
        setup_label_gcs (container);
8548
 
}
8549
 
 
8550
8425
void
8551
8426
nautilus_icon_container_set_font (NautilusIconContainer *container,
8552
8427
                                  const char *font)