Commit 81e645d8 authored by Jonas Kümmerlin's avatar Jonas Kümmerlin Committed by Andre Miranda

Make Thunar core compile and not crash with Gtk3

Optional plugins are not ported yet. We use a shitload of
deprecated Gtk APIs now. Not all features work.
It doesn't look great yet. There are bugs.

But, well, it's a first step.
parent 5d25e291
......@@ -140,15 +140,15 @@ XDT_CHECK_LIBX11_REQUIRE()
dnl ***********************************
dnl *** Check for required packages ***
dnl ***********************************
XDT_CHECK_PACKAGE([EXO], [exo-1], [0.10.0])
XDT_CHECK_PACKAGE([EXO], [exo-2], [0.10.0])
XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GIO], [gio-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GMODULE], [gmodule-2.0], [2.30.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.24.0])
XDT_CHECK_PACKAGE([GTK], [gtk+-3.0], [3.14.0])
XDT_CHECK_PACKAGE([GDK_PIXBUF], [gdk-pixbuf-2.0], [2.14.0])
XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.10.0])
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-1], [4.10.0])
XDT_CHECK_PACKAGE([LIBXFCE4UI], [libxfce4ui-2], [4.10.0])
XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [4.10.0])
dnl ********************************************
......
......@@ -268,7 +268,7 @@ tse_progress (const gchar *working_directory,
/* allocate the progress dialog */
dialog = gtk_dialog_new_with_buttons (_("Compressing files..."),
NULL, GTK_DIALOG_NO_SEPARATOR,
NULL, 0,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
NULL);
gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
......
......@@ -76,7 +76,6 @@ thunar/thunar-standard-view.c
thunar/thunar-statusbar.c
thunar/thunar-stock.c
thunar/thunar-templates-action.c
thunar/thunar-text-renderer.c
thunar/thunar-thumbnail-cache.c
thunar/thunar-thumbnailer.c
thunar/thunar-transfer-job.c
......
......@@ -191,8 +191,6 @@ thunar_SOURCES = \
thunar-stock.h \
thunar-templates-action.c \
thunar-templates-action.h \
thunar-text-renderer.c \
thunar-text-renderer.h \
thunar-thumbnail-cache.c \
thunar-thumbnail-cache.h \
thunar-thumbnailer.c \
......
......@@ -46,8 +46,8 @@ thunar_abstract_dialog_class_init (ThunarAbstractDialogClass *klass)
/* connect additional key bindings to the GtkDialog::close action signal */
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set, GDK_w, GDK_CONTROL_MASK, "close", 0);
gtk_binding_entry_add_signal (binding_set, GDK_W, GDK_CONTROL_MASK, "close", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_w, GDK_CONTROL_MASK, "close", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_W, GDK_CONTROL_MASK, "close", 0);
}
......
......@@ -224,7 +224,8 @@ thunar_abstract_icon_view_init (ThunarAbstractIconView *abstract_icon_view)
"file", THUNAR_COLUMN_FILE);
/* add the name renderer */
g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (abstract_icon_view)->name_renderer), "follow-state", TRUE, NULL);
/*FIXME text prelit*/
/*g_object_set (G_OBJECT (THUNAR_STANDARD_VIEW (abstract_icon_view)->name_renderer), "follow-state", TRUE, NULL);*/
gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (view), THUNAR_STANDARD_VIEW (abstract_icon_view)->name_renderer, TRUE);
gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (view), THUNAR_STANDARD_VIEW (abstract_icon_view)->name_renderer,
"text", THUNAR_COLUMN_NAME);
......@@ -695,7 +696,7 @@ thunar_abstract_icon_view_key_press_event (ExoIconView *view,
ThunarAbstractIconView *abstract_icon_view)
{
/* popup context menu if "Menu" or "<Shift>F10" is pressed */
if (event->keyval == GDK_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_F10))
if (event->keyval == GDK_KEY_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_KEY_F10))
{
thunar_standard_view_context_menu (THUNAR_STANDARD_VIEW (abstract_icon_view), 0, event->time);
return TRUE;
......
......@@ -28,7 +28,6 @@
#include <thunar/thunar-details-view-ui.h>
#include <thunar/thunar-gtk-extensions.h>
#include <thunar/thunar-private.h>
#include <thunar/thunar-text-renderer.h>
#include <thunar/thunar-preferences.h>
......@@ -237,11 +236,11 @@ thunar_details_view_init (ThunarDetailsView *details_view)
G_CALLBACK (thunar_details_view_row_changed), details_view);
/* allocate the shared right-aligned text renderer */
right_aligned_renderer = g_object_new (THUNAR_TYPE_TEXT_RENDERER, "xalign", 1.0f, NULL);
right_aligned_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, "xalign", 1.0f, NULL);
g_object_ref_sink (G_OBJECT (right_aligned_renderer));
/* allocate the shared left-aligned text renderer */
left_aligned_renderer = g_object_new (THUNAR_TYPE_TEXT_RENDERER, "xalign", 0.0f, NULL);
left_aligned_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, "xalign", 0.0f, NULL);
g_object_ref_sink (G_OBJECT (left_aligned_renderer));
/* allocate the tree view columns */
......@@ -809,7 +808,7 @@ thunar_details_view_key_press_event (GtkTreeView *tree_view,
ThunarDetailsView *details_view)
{
/* popup context menu if "Menu" or "<Shift>F10" is pressed */
if (event->keyval == GDK_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_F10))
if (event->keyval == GDK_KEY_Menu || ((event->state & GDK_SHIFT_MASK) != 0 && event->keyval == GDK_KEY_F10))
{
thunar_standard_view_context_menu (THUNAR_STANDARD_VIEW (details_view), 0, event->time);
return TRUE;
......
......@@ -94,7 +94,6 @@ thunar_dialogs_show_rename_file (gpointer parent,
dialog = gtk_dialog_new_with_buttons (title,
window,
GTK_DIALOG_MODAL
| GTK_DIALOG_NO_SEPARATOR
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("_Rename"), GTK_RESPONSE_OK,
......@@ -539,7 +538,6 @@ thunar_dialogs_show_job_ask_replace (GtkWindow *parent,
dialog = gtk_dialog_new_with_buttons (_("Confirm to replace files"),
parent,
GTK_DIALOG_MODAL
| GTK_DIALOG_NO_SEPARATOR
| GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
_("S_kip All"), THUNAR_JOB_RESPONSE_NO_ALL,
......
......@@ -135,10 +135,9 @@ thunar_emblem_chooser_init (ThunarEmblemChooser *chooser)
gtk_widget_show (viewport);
/* setup the wrap table */
chooser->table = g_object_new (EXO_TYPE_WRAP_TABLE,
"border-width", 6,
chooser->table = g_object_new (GTK_TYPE_FLOW_BOX,
"homogeneous", TRUE,
"col-spacing", 12,
"column-spacing", 12,
"row-spacing", 12,
NULL);
gtk_container_add (GTK_CONTAINER (viewport), chooser->table);
......@@ -314,6 +313,7 @@ thunar_emblem_chooser_file_changed (ThunarEmblemChooser *chooser)
GList *file_emblems;
GList *children;
GList *lp, *li;
GObject *child;
guint *count;
guint n_files = 0;
......@@ -344,22 +344,26 @@ thunar_emblem_chooser_file_changed (ThunarEmblemChooser *chooser)
children = gtk_container_get_children (GTK_CONTAINER (chooser->table));
for (lp = children; lp != NULL; lp = lp->next)
{
emblem_name = g_object_get_data (G_OBJECT (lp->data), I_("thunar-emblem"));
child = G_OBJECT (lp->data);
if (GTK_IS_FLOW_BOX_CHILD (child))
child = G_OBJECT (gtk_bin_get_child (GTK_BIN (child)));
emblem_name = g_object_get_data (child, I_("thunar-emblem"));
count = g_hash_table_lookup (emblem_names, emblem_name);
g_signal_handlers_block_by_func (lp->data, thunar_emblem_chooser_button_toggled, chooser);
g_signal_handlers_block_by_func (child, thunar_emblem_chooser_button_toggled, chooser);
if (count == NULL || *count == n_files)
{
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (lp->data), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (lp->data), count != NULL);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (child), FALSE);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (child), count != NULL);
}
else
{
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (lp->data), TRUE);
gtk_toggle_button_set_inconsistent (GTK_TOGGLE_BUTTON (child), TRUE);
}
g_signal_handlers_unblock_by_func (lp->data, thunar_emblem_chooser_button_toggled, chooser);
g_signal_handlers_unblock_by_func (child, thunar_emblem_chooser_button_toggled, chooser);
}
g_list_free (children);
......
......@@ -51,6 +51,8 @@ void thunar_gtk_widget_set_tooltip (GtkWidget
GMountOperation *thunar_gtk_mount_operation_new (gpointer parent);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
static inline int
thunar_gtk_widget_get_allocation_x (GtkWidget *widget)
{
......@@ -111,6 +113,8 @@ thunar_gtk_widget_get_requisition_height (GtkWidget *widget)
return requisition.height;
}
G_GNUC_END_IGNORE_DEPRECATIONS
G_END_DECLS;
#endif /* !__THUNAR_GTK_EXTENSIONS_H__ */
......@@ -51,19 +51,19 @@ static void thunar_icon_renderer_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec);
static void thunar_icon_renderer_get_size (GtkCellRenderer *renderer,
static void thunar_icon_renderer_get_preferred_width (GtkCellRenderer *renderer,
GtkWidget *widget,
GdkRectangle *rectangle,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height);
gint *minimum,
gint *natural);
static void thunar_icon_renderer_get_preferred_height (GtkCellRenderer *renderer,
GtkWidget *widget,
gint *minimum,
gint *natural);
static void thunar_icon_renderer_render (GtkCellRenderer *renderer,
GdkWindow *window,
cairo_t *cr,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags);
......@@ -84,7 +84,8 @@ thunar_icon_renderer_class_init (ThunarIconRendererClass *klass)
gobject_class->set_property = thunar_icon_renderer_set_property;
gtkcell_renderer_class = GTK_CELL_RENDERER_CLASS (klass);
gtkcell_renderer_class->get_size = thunar_icon_renderer_get_size;
gtkcell_renderer_class->get_preferred_width = thunar_icon_renderer_get_preferred_width;
gtkcell_renderer_class->get_preferred_height = thunar_icon_renderer_get_preferred_height;
gtkcell_renderer_class->render = thunar_icon_renderer_render;
/**
......@@ -264,56 +265,40 @@ thunar_icon_renderer_set_property (GObject *object,
static void
thunar_icon_renderer_get_size (GtkCellRenderer *renderer,
GtkWidget *widget,
GdkRectangle *rectangle,
gint *x_offset,
gint *y_offset,
gint *width,
gint *height)
thunar_icon_renderer_get_preferred_width (GtkCellRenderer *renderer,
GtkWidget *widget,
gint *minimum,
gint *natural)
{
ThunarIconRenderer *icon_renderer = THUNAR_ICON_RENDERER (renderer);
float xalign;
float yalign;
int xpad;
int ypad;
gtk_cell_renderer_get_alignment (renderer, &xalign, &yalign);
gtk_cell_renderer_get_padding (renderer, &xpad, &ypad);
gtk_cell_renderer_get_padding (renderer, &xpad, NULL);
if (rectangle != NULL)
{
if (x_offset != NULL)
{
*x_offset = ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? 1.0 - xalign : xalign)
* (rectangle->width - icon_renderer->size);
*x_offset = MAX (*x_offset, 0) + xpad;
}
if (G_LIKELY (minimum)) *minimum = (gint) xpad * 2 + icon_renderer->size;
if (G_LIKELY (natural)) *natural = (gint) xpad * 2 + icon_renderer->size;
}
if (y_offset != NULL)
{
*y_offset = yalign * (rectangle->height - icon_renderer->size);
*y_offset = MAX (*y_offset, 0) + ypad;
}
}
else
{
if (x_offset != NULL)
*x_offset = 0;
if (y_offset != NULL)
*y_offset = 0;
}
if (G_LIKELY (width != NULL))
*width = (gint) xpad * 2 + icon_renderer->size;
static void
thunar_icon_renderer_get_preferred_height (GtkCellRenderer *renderer,
GtkWidget *widget,
gint *minimum,
gint *natural)
{
ThunarIconRenderer *icon_renderer = THUNAR_ICON_RENDERER (renderer);
int ypad;
gtk_cell_renderer_get_padding (renderer, NULL, &ypad);
if (G_LIKELY (height != NULL))
*height = (gint) ypad * 2 + icon_renderer->size;
if (G_LIKELY (minimum)) *minimum = (gint) ypad * 2 + icon_renderer->size;
if (G_LIKELY (natural)) *natural = (gint) ypad * 2 + icon_renderer->size;
}
static void
thunar_icon_renderer_color_selected (cairo_t *cr,
GtkWidget *widget)
......@@ -358,11 +343,10 @@ thunar_icon_renderer_color_lighten (cairo_t *cr,
static void
thunar_icon_renderer_render (GtkCellRenderer *renderer,
GdkWindow *window,
cairo_t *cr,
GtkWidget *widget,
GdkRectangle *background_area,
GdkRectangle *cell_area,
GdkRectangle *expose_area,
const GdkRectangle *background_area,
const GdkRectangle *cell_area,
GtkCellRendererState flags)
{
ThunarClipboardManager *clipboard;
......@@ -374,6 +358,7 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
GdkRectangle emblem_area;
GdkRectangle icon_area;
GdkRectangle draw_area;
GdkRectangle clip_area;
GdkPixbuf *emblem;
GdkPixbuf *icon;
GdkPixbuf *temp;
......@@ -381,7 +366,6 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
GList *lp;
gint max_emblems;
gint position;
cairo_t *cr;
gdouble alpha;
gint emblem_size;
gboolean color_selected;
......@@ -391,6 +375,9 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
if (G_UNLIKELY (icon_renderer->file == NULL))
return;
if (G_UNLIKELY (!gdk_cairo_get_clip_rectangle (cr, &clip_area)))
return;
g_object_get (renderer, "is-expanded", &is_expanded, NULL);
/* determine the icon state */
......@@ -438,11 +425,8 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
color_selected = (flags & GTK_CELL_RENDERER_SELECTED) != 0 && icon_renderer->follow_state;
color_lighten = (flags & GTK_CELL_RENDERER_PRELIT) != 0 && icon_renderer->follow_state;
/* create the context */
cr = gdk_cairo_create (window);
/* check whether the icon is affected by the expose event */
if (gdk_rectangle_intersect (expose_area, &icon_area, &draw_area))
if (gdk_rectangle_intersect (&clip_area, &icon_area, &draw_area))
{
/* use a translucent icon to represent cutted and hidden files to the user */
clipboard = thunar_clipboard_manager_get_for_display (gtk_widget_get_display (widget));
......@@ -572,7 +556,7 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
}
/* render the emblem */
if (gdk_rectangle_intersect (expose_area, &emblem_area, &draw_area))
if (gdk_rectangle_intersect (&clip_area, &emblem_area, &draw_area))
{
/* render the invalid parts of the icon */
thunar_gdk_cairo_set_source_pixbuf (cr, emblem, emblem_area.x, emblem_area.y);
......@@ -600,9 +584,6 @@ thunar_icon_renderer_render (GtkCellRenderer *renderer,
}
}
/* destroy the context */
cairo_destroy (cr);
/* release our reference on the icon factory */
g_object_unref (G_OBJECT (icon_factory));
}
......
......@@ -73,8 +73,12 @@ static ThunarFile *thunar_location_buttons_get_current_directory (ThunarN
static void thunar_location_buttons_set_current_directory (ThunarNavigator *navigator,
ThunarFile *current_directory);
static void thunar_location_buttons_unmap (GtkWidget *widget);
static void thunar_location_buttons_size_request (GtkWidget *widget,
GtkRequisition *requisition);
static void thunar_location_buttons_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural);
static void thunar_location_buttons_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural);
static void thunar_location_buttons_size_allocate (GtkWidget *widget,
GtkAllocation *allocation);
static void thunar_location_buttons_state_changed (GtkWidget *widget,
......@@ -204,7 +208,8 @@ thunar_location_buttons_class_init (ThunarLocationButtonsClass *klass)
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->unmap = thunar_location_buttons_unmap;
gtkwidget_class->size_request = thunar_location_buttons_size_request;
gtkwidget_class->get_preferred_width = thunar_location_buttons_get_preferred_width;
gtkwidget_class->get_preferred_height = thunar_location_buttons_get_preferred_height;
gtkwidget_class->size_allocate = thunar_location_buttons_size_allocate;
gtkwidget_class->state_changed = thunar_location_buttons_state_changed;
gtkwidget_class->grab_notify = thunar_location_buttons_grab_notify;
......@@ -541,39 +546,50 @@ thunar_location_buttons_unmap (GtkWidget *widget)
static void
thunar_location_buttons_size_request (GtkWidget *widget,
GtkRequisition *requisition)
thunar_location_buttons_get_preferred_width (GtkWidget *widget,
gint *minimum,
gint *natural)
{
ThunarLocationButtons *buttons = THUNAR_LOCATION_BUTTONS (widget);
GtkRequisition child_requisition;
gint width = 0, height = 0, child_width = 0, child_height = 0;
GList *lp;
gint spacing;
gtk_widget_style_get (GTK_WIDGET (buttons),
"spacing", &spacing,
NULL);
requisition->width = 0;
requisition->height = 0;
/* calculate the size of the biggest button */
for (lp = buttons->list; lp != NULL; lp = lp->next)
{
gtk_widget_size_request (GTK_WIDGET (lp->data), &child_requisition);
requisition->width = MAX (child_requisition.width, requisition->width);
requisition->height = MAX (child_requisition.height, requisition->height);
gtk_widget_get_preferred_width (GTK_WIDGET (lp->data), &child_width, NULL);
gtk_widget_get_preferred_height (GTK_WIDGET (lp->data), &child_height, NULL);
width = MAX (width, child_width);
height = MAX (height, child_height);
}
/* add space for the sliders if we have more than one path */
buttons->slider_width = MIN (requisition->height * 2 / 3 + 5, requisition->height);
buttons->slider_width = MIN (height * 2 / 3 + 5, height);
if (buttons->list != NULL && buttons->list->next != NULL)
requisition->width += (spacing + buttons->slider_width) * 2;
width += (buttons->slider_width) * 2;
*minimum = *natural = width;
}
gtk_widget_size_request (buttons->left_slider, &child_requisition);
gtk_widget_size_request (buttons->right_slider, &child_requisition);
static void
thunar_location_buttons_get_preferred_height (GtkWidget *widget,
gint *minimum,
gint *natural)
{
ThunarLocationButtons *buttons = THUNAR_LOCATION_BUTTONS (widget);
gint height = 0, child_height = 0;
GList *lp;
/* calculate the size of the biggest button */
for (lp = buttons->list; lp != NULL; lp = lp->next)
{
gtk_widget_get_preferred_height (GTK_WIDGET (lp->data), &child_height, NULL);
height = MAX (height, child_height);
}
requisition->width += gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2;
requisition->height += gtk_container_get_border_width (GTK_CONTAINER (widget)) * 2;
*minimum = *natural = height;
}
......
......@@ -143,7 +143,7 @@ thunar_location_entry_class_init (ThunarLocationEntryClass *klass)
/* setup the key bindings for the location entry */
binding_set = gtk_binding_set_by_class (klass);
gtk_binding_entry_add_signal (binding_set, GDK_Escape, 0, "reset", 0);
gtk_binding_entry_add_signal (binding_set, GDK_KEY_Escape, 0, "reset", 0);
}
......
......@@ -60,7 +60,7 @@ enum
static void thunar_path_entry_editable_init (GtkEditableClass *iface);
static void thunar_path_entry_editable_init (GtkEditableInterface *iface);
static void thunar_path_entry_finalize (GObject *object);
static void thunar_path_entry_get_property (GObject *object,
guint prop_id,
......@@ -72,10 +72,14 @@ static void thunar_path_entry_set_property (GObject
GParamSpec *pspec);
static gboolean thunar_path_entry_focus (GtkWidget *widget,
GtkDirectionType direction);
static gboolean thunar_path_entry_button_press_event (GtkWidget *widget,
GdkEventButton *event);
static gboolean thunar_path_entry_button_release_event (GtkWidget *widget,
GdkEventButton *event);
static void thunar_path_entry_icon_press_event (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEventButton *event,
gpointer userdata);
static void thunar_path_entry_icon_release_event (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEventButton *event,
gpointer user_data);
static gboolean thunar_path_entry_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event);
static gboolean thunar_path_entry_key_press_event (GtkWidget *widget,
......@@ -149,7 +153,7 @@ static const GtkTargetEntry drag_targets[] =
static GtkEditableClass *thunar_path_entry_editable_parent_iface;
static GtkEditableInterface *thunar_path_entry_editable_parent_iface;
......@@ -172,8 +176,6 @@ thunar_path_entry_class_init (ThunarPathEntryClass *klass)
gtkwidget_class = GTK_WIDGET_CLASS (klass);
gtkwidget_class->focus = thunar_path_entry_focus;
gtkwidget_class->button_press_event = thunar_path_entry_button_press_event;
gtkwidget_class->button_release_event = thunar_path_entry_button_release_event;
gtkwidget_class->motion_notify_event = thunar_path_entry_motion_notify_event;
gtkwidget_class->drag_data_get = thunar_path_entry_drag_data_get;
......@@ -208,7 +210,7 @@ thunar_path_entry_class_init (ThunarPathEntryClass *klass)
static void
thunar_path_entry_editable_init (GtkEditableClass *iface)
thunar_path_entry_editable_init (GtkEditableInterface *iface)
{
thunar_path_entry_editable_parent_iface = g_type_interface_peek_parent (iface);
......@@ -266,6 +268,10 @@ thunar_path_entry_init (ThunarPathEntry *path_entry)
/* clear the auto completion whenever the cursor is moved manually or the selection is changed manually */
g_signal_connect (G_OBJECT (path_entry), "notify::cursor-position", G_CALLBACK (thunar_path_entry_clear_completion), NULL);
g_signal_connect (G_OBJECT (path_entry), "notify::selection-bound", G_CALLBACK (thunar_path_entry_clear_completion), NULL);
/* connect the icon signals */
g_signal_connect (G_OBJECT (path_entry), "icon-press", G_CALLBACK (thunar_path_entry_icon_press_event), NULL);
g_signal_connect (G_OBJECT (path_entry), "icon-release", G_CALLBACK (thunar_path_entry_icon_release_event), NULL);
}
......@@ -376,42 +382,38 @@ thunar_path_entry_focus (GtkWidget *widget,
static gboolean
thunar_path_entry_button_press_event (GtkWidget *widget,
GdkEventButton *event)
static void
thunar_path_entry_icon_press_event (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEventButton *event,
gpointer userdata)
{
ThunarPathEntry *path_entry = THUNAR_PATH_ENTRY (widget);
ThunarPathEntry *path_entry = THUNAR_PATH_ENTRY (entry);
if (event->button == 1
&& event->window == gtk_entry_get_icon_window (GTK_ENTRY (widget), GTK_ENTRY_ICON_PRIMARY))
if (event->button == 1 && icon_pos == GTK_ENTRY_ICON_PRIMARY)
{
/* consume the event */
path_entry->drag_button = event->button;
path_entry->drag_x = event->x;
path_entry->drag_y = event->y;
return TRUE;
}
return (*GTK_WIDGET_CLASS (thunar_path_entry_parent_class)->button_press_event) (widget, event);
}
static gboolean
thunar_path_entry_button_release_event (GtkWidget *widget,
GdkEventButton *event)
static void
thunar_path_entry_icon_release_event (GtkEntry *entry,
GtkEntryIconPosition icon_pos,
GdkEventButton *event,
gpointer user_data)
{
ThunarPathEntry *path_entry = THUNAR_PATH_ENTRY (widget);
ThunarPathEntry *path_entry = THUNAR_PATH_ENTRY (entry);
if (event->button == path_entry->drag_button
&& event->window == gtk_entry_get_icon_window (GTK_ENTRY (widget), GTK_ENTRY_ICON_PRIMARY))
if (event->button == path_entry->drag_button && icon_pos == GTK_ENTRY_ICON_PRIMARY)
{
/* reset the drag button state */
path_entry->drag_button = 0;
return TRUE;