diff --git a/configure.ac.in b/configure.ac.in index 836e468ca0e825de4d335f4619ab2ee3ac9ecdf6..740c7f171da6746275f82724f1339f08be42d024 100644 --- a/configure.ac.in +++ b/configure.ac.in @@ -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 ******************************************** diff --git a/plugins/thunar-sendto-email/main.c b/plugins/thunar-sendto-email/main.c index db31890fc3ab749dc44207c06e69bd3aef44f1f3..7c56c3049c3eb47d435c32986d69d955b1c2b293 100644 --- a/plugins/thunar-sendto-email/main.c +++ b/plugins/thunar-sendto-email/main.c @@ -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); diff --git a/po/POTFILES.in b/po/POTFILES.in index 1c487a9e4138bbdc73436eda334123eab98eeb5a..587f917fc9b6e63266f6a1a769f19387ebd17daf 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -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 diff --git a/thunar/Makefile.am b/thunar/Makefile.am index 8e7d624e7622cdf957531692bb2972a109014e8e..ac6511ecd09d77bded0d511ef07569576387d685 100644 --- a/thunar/Makefile.am +++ b/thunar/Makefile.am @@ -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 \ diff --git a/thunar/thunar-abstract-dialog.c b/thunar/thunar-abstract-dialog.c index 48d71fefda8edb594f200107b69875c5d32c28a8..1540e8a9e944ae1a7f4a4c01828706103b03cdc2 100644 --- a/thunar/thunar-abstract-dialog.c +++ b/thunar/thunar-abstract-dialog.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); } diff --git a/thunar/thunar-abstract-icon-view.c b/thunar/thunar-abstract-icon-view.c index 828818b4679b93f607f9bee528fa5f7ada5d3fb7..15c83d692e16c4c97f46a7d05ef7fbf6e581eff4 100644 --- a/thunar/thunar-abstract-icon-view.c +++ b/thunar/thunar-abstract-icon-view.c @@ -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; diff --git a/thunar/thunar-details-view.c b/thunar/thunar-details-view.c index acb9339472ddd5aa0dccda879222b505d5921e32..69f89a1bdc2497f7e6c205d3763c00885c6cfe5c 100644 --- a/thunar/thunar-details-view.c +++ b/thunar/thunar-details-view.c @@ -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; diff --git a/thunar/thunar-dialogs.c b/thunar/thunar-dialogs.c index 62fa06343b44120b9feeae4f116eb038912f43b2..90824605d5eb8f5015f27ece85c64c8c2d08759d 100644 --- a/thunar/thunar-dialogs.c +++ b/thunar/thunar-dialogs.c @@ -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, diff --git a/thunar/thunar-emblem-chooser.c b/thunar/thunar-emblem-chooser.c index 753bfddbc4c8d90a6c2f74ba7645eb2b6940999b..be61f091ec8cdba6bcdc328a7467c4c42171356b 100644 --- a/thunar/thunar-emblem-chooser.c +++ b/thunar/thunar-emblem-chooser.c @@ -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); diff --git a/thunar/thunar-gtk-extensions.h b/thunar/thunar-gtk-extensions.h index c5c160ef420dbe22eeae13c8aca84cb844fde0c3..afc41500ba0d5267f2640373bcbf5270680abe2a 100644 --- a/thunar/thunar-gtk-extensions.h +++ b/thunar/thunar-gtk-extensions.h @@ -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__ */ diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c index 4e1e7c0cc485b0da37d02db3a4b13fdc4faff2e9..fea809e8fa0fedef41c36a7aa4fe88527b13bdda 100644 --- a/thunar/thunar-icon-renderer.c +++ b/thunar/thunar-icon-renderer.c @@ -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)); } diff --git a/thunar/thunar-location-buttons.c b/thunar/thunar-location-buttons.c index d6411c3c68d0b4ce2c917ef56f8987931537cece..7074ccff30aa28db8ddf764c26701494840392ec 100644 --- a/thunar/thunar-location-buttons.c +++ b/thunar/thunar-location-buttons.c @@ -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; } diff --git a/thunar/thunar-location-entry.c b/thunar/thunar-location-entry.c index a6952740e4d24278b3ddc9a414330cc2811b615c..9c101a4d31666a91d2cc9912059eccd4525dcd0b 100644 --- a/thunar/thunar-location-entry.c +++ b/thunar/thunar-location-entry.c @@ -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); } diff --git a/thunar/thunar-path-entry.c b/thunar/thunar-path-entry.c index 54f83172adfa91c2374f3d1772662fd8f989b613..5955dc11805d6827603cccc78b2b249777ef6ba4 100644 --- a/thunar/thunar-path-entry.c +++ b/thunar/thunar-path-entry.c @@ -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; } - - return (*GTK_WIDGET_CLASS (thunar_path_entry_parent_class)->button_release_event) (widget, event); } @@ -428,7 +430,7 @@ thunar_path_entry_motion_notify_event (GtkWidget *widget, if (path_entry->drag_button > 0 && path_entry->current_file != NULL - && event->window == gtk_entry_get_icon_window (GTK_ENTRY (widget), GTK_ENTRY_ICON_PRIMARY) + /*FIXME && event->window == gtk_entry_get_icon_window (GTK_ENTRY (widget), GTK_ENTRY_ICON_PRIMARY)*/ && gtk_drag_check_threshold (widget, path_entry->drag_x, path_entry->drag_y, event->x, event->y)) { /* create the drag context */ @@ -466,7 +468,7 @@ thunar_path_entry_key_press_event (GtkWidget *widget, ThunarPathEntry *path_entry = THUNAR_PATH_ENTRY (widget); /* check if we have a tab key press here and control is not pressed */ - if (G_UNLIKELY (event->keyval == GDK_Tab && (event->state & GDK_CONTROL_MASK) == 0)) + if (G_UNLIKELY (event->keyval == GDK_KEY_Tab && (event->state & GDK_CONTROL_MASK) == 0)) { /* if we don't have a completion and the cursor is at the end of the line, we just insert the common prefix */ if (!path_entry->has_completion && gtk_editable_get_position (GTK_EDITABLE (path_entry)) == gtk_entry_get_text_length (GTK_ENTRY (path_entry))) diff --git a/thunar/thunar-permissions-chooser.c b/thunar/thunar-permissions-chooser.c index 62fd3d1c8f937d180fb35b3f055d77f23e820821..fe2c88e8e17db3e2530bc016f1f52165d550fb31 100644 --- a/thunar/thunar-permissions-chooser.c +++ b/thunar/thunar-permissions-chooser.c @@ -515,7 +515,6 @@ thunar_permissions_chooser_ask_recursive (ThunarPermissionsChooser *chooser) /* allocate the question dialog */ dialog = gtk_dialog_new_with_buttons (_("Question"), GTK_WINDOW (toplevel), GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_NO, GTK_RESPONSE_NO, diff --git a/thunar/thunar-properties-dialog.c b/thunar/thunar-properties-dialog.c index e6a59852a8ecd2c7d234c624976303429396c667..aca67e87311331aa6f00ed700df586ebbc0bb27c 100644 --- a/thunar/thunar-properties-dialog.c +++ b/thunar/thunar-properties-dialog.c @@ -216,8 +216,8 @@ thunar_properties_dialog_class_init (ThunarPropertiesDialogClass *klass) /* setup the key bindings for the properties dialog */ binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_F5, 0, "reload", 0); - gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "reload", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F5, 0, "reload", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_r, GDK_CONTROL_MASK, "reload", 0); } diff --git a/thunar/thunar-renamer-progress.c b/thunar/thunar-renamer-progress.c index 73abd7ec801b5a559ae769cfbbd4a3504147f114..8ea805c127de8b94c5983e804bc8fc8c249f482a 100644 --- a/thunar/thunar-renamer-progress.c +++ b/thunar/thunar-renamer-progress.c @@ -36,7 +36,7 @@ enum static void thunar_renamer_progress_finalize (GObject *object); -static void thunar_renamer_progress_destroy (GtkObject *object); +static void thunar_renamer_progress_destroy (GtkWidget *object); static gboolean thunar_renamer_progress_next_idle (gpointer user_data); static void thunar_renamer_progress_next_idle_destroy (gpointer user_data); @@ -72,14 +72,14 @@ G_DEFINE_TYPE (ThunarRenamerProgress, thunar_renamer_progress, GTK_TYPE_ALIGNMEN static void thunar_renamer_progress_class_init (ThunarRenamerProgressClass *klass) { - GtkObjectClass *gtkobject_class; + GtkWidgetClass *gtkwidget_class; GObjectClass *gobject_class; gobject_class = G_OBJECT_CLASS (klass); gobject_class->finalize = thunar_renamer_progress_finalize; - gtkobject_class = GTK_OBJECT_CLASS (klass); - gtkobject_class->destroy = thunar_renamer_progress_destroy; + gtkwidget_class = GTK_WIDGET_CLASS (klass); + gtkwidget_class->destroy = thunar_renamer_progress_destroy; } @@ -115,14 +115,14 @@ thunar_renamer_progress_finalize (GObject *object) static void -thunar_renamer_progress_destroy (GtkObject *object) +thunar_renamer_progress_destroy (GtkWidget *object) { ThunarRenamerProgress *renamer_progress = THUNAR_RENAMER_PROGRESS (object); /* exit the internal main loop on destroy */ thunar_renamer_progress_cancel (renamer_progress); - (*GTK_OBJECT_CLASS (thunar_renamer_progress_parent_class)->destroy) (object); + (*GTK_WIDGET_CLASS (thunar_renamer_progress_parent_class)->destroy) (object); } diff --git a/thunar/thunar-shortcuts-icon-renderer.c b/thunar/thunar-shortcuts-icon-renderer.c index b52da5f0cc9f371166edaa4b2c91504df9e14eb9..898e79e0720198ba9830c2d4a81af6d9bf1ea27b 100644 --- a/thunar/thunar-shortcuts-icon-renderer.c +++ b/thunar/thunar-shortcuts-icon-renderer.c @@ -53,11 +53,10 @@ static void thunar_shortcuts_icon_renderer_set_property (GObject const GValue *value, GParamSpec *pspec); static void thunar_shortcuts_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); @@ -205,24 +204,26 @@ thunar_shortcuts_icon_renderer_set_property (GObject *object, static void thunar_shortcuts_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) { ThunarShortcutsIconRenderer *shortcuts_icon_renderer = THUNAR_SHORTCUTS_ICON_RENDERER (renderer); GtkIconTheme *icon_theme; GdkRectangle draw_area; GdkRectangle icon_area; + GdkRectangle clip_area; GtkIconInfo *icon_info; GdkPixbuf *icon = NULL; GdkPixbuf *temp; GIcon *gicon; - cairo_t *cr; gdouble alpha; + if (!gdk_cairo_get_clip_rectangle (cr, &clip_area)) + return; + /* check if we have a volume set */ if (G_UNLIKELY (shortcuts_icon_renderer->gicon != NULL || shortcuts_icon_renderer->device != NULL)) @@ -278,14 +279,12 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer *renderer, icon_area.y = cell_area->y + (cell_area->height - icon_area.height) / 2; /* 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)) { /* render the invalid parts of the icon */ - cr = gdk_cairo_create (window); thunar_gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y); gdk_cairo_rectangle (cr, &draw_area); cairo_paint_with_alpha (cr, alpha); - cairo_destroy (cr); } /* cleanup */ @@ -295,8 +294,8 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer *renderer, else { /* fallback to the default icon renderering */ - (*GTK_CELL_RENDERER_CLASS (thunar_shortcuts_icon_renderer_parent_class)->render) (renderer, window, widget, background_area, - cell_area, expose_area, flags); + (*GTK_CELL_RENDERER_CLASS (thunar_shortcuts_icon_renderer_parent_class)->render) (renderer, cr, widget, background_area, + cell_area, flags); } } diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c index b4c857d2eb848a5b74dcbba76814aef23037bb85..4119cae1953513043f629f08eb6301b0f314b465 100644 --- a/thunar/thunar-shortcuts-view.c +++ b/thunar/thunar-shortcuts-view.c @@ -533,10 +533,10 @@ thunar_shortcuts_view_key_release_event (GtkWidget *widget, /* work nicer with keyboard navigation */ switch (event->keyval) { - case GDK_Up: - case GDK_Down: - case GDK_KP_Up: - case GDK_KP_Down: + case GDK_KEY_Up: + case GDK_KEY_Down: + case GDK_KEY_KP_Up: + case GDK_KEY_KP_Down: thunar_shortcuts_view_open (view, OPEN_IN_VIEW); /* keep focus on us */ diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index c2b6b60f9dfec588a04929287c4489d7b17d1664..79e449849af0699f7787feebbf6ff0b75453022d 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -51,7 +51,6 @@ #include <thunar/thunar-standard-view-ui.h> #include <thunar/thunar-templates-action.h> #include <thunar/thunar-history.h> -#include <thunar/thunar-text-renderer.h> #include <thunar/thunar-thumbnailer.h> #if defined(GDK_WINDOWING_X11) @@ -117,8 +116,8 @@ static void thunar_standard_view_set_property (GOb static void thunar_standard_view_realize (GtkWidget *widget); static void thunar_standard_view_unrealize (GtkWidget *widget); static void thunar_standard_view_grab_focus (GtkWidget *widget); -static gboolean thunar_standard_view_expose_event (GtkWidget *widget, - GdkEventExpose *event); +static gboolean thunar_standard_view_draw (GtkWidget *widget, + cairo_t *cr); static GList *thunar_standard_view_get_selected_files (ThunarComponent *component); static void thunar_standard_view_set_selected_files (ThunarComponent *component, GList *selected_files); @@ -468,7 +467,7 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass) gtkwidget_class->realize = thunar_standard_view_realize; gtkwidget_class->unrealize = thunar_standard_view_unrealize; gtkwidget_class->grab_focus = thunar_standard_view_grab_focus; - gtkwidget_class->expose_event = thunar_standard_view_expose_event; + gtkwidget_class->draw = thunar_standard_view_draw; klass->delete_selected_files = thunar_standard_view_delete_selected_files; klass->connect_ui_manager = (gpointer) exo_noop; @@ -586,11 +585,11 @@ thunar_standard_view_class_init (ThunarStandardViewClass *klass) /* setup the key bindings for the standard views */ binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_CONTROL_MASK, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); } @@ -711,9 +710,14 @@ thunar_standard_view_init (ThunarStandardView *standard_view) exo_binding_new (G_OBJECT (standard_view), "zoom-level", G_OBJECT (standard_view->icon_renderer), "size"); /* setup the name renderer */ - standard_view->name_renderer = thunar_text_renderer_new (); + standard_view->name_renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, + "alignment", PANGO_ALIGN_CENTER, + "xalign", 0.5, + FALSE); g_object_ref_sink (G_OBJECT (standard_view->name_renderer)); - exo_binding_new (G_OBJECT (standard_view->preferences), "misc-single-click", G_OBJECT (standard_view->name_renderer), "follow-prelit"); + + /* TODO: prelit underline + exo_binding_new (G_OBJECT (standard_view->preferences), "misc-single-click", G_OBJECT (standard_view->name_renderer), "follow-prelit");*/ /* be sure to update the selection whenever the folder changes */ g_signal_connect_swapped (G_OBJECT (standard_view->model), "notify::folder", G_CALLBACK (thunar_standard_view_selection_changed), standard_view); @@ -1094,33 +1098,32 @@ thunar_standard_view_grab_focus (GtkWidget *widget) static gboolean -thunar_standard_view_expose_event (GtkWidget *widget, - GdkEventExpose *event) +thunar_standard_view_draw (GtkWidget *widget, + cairo_t *cr) { gboolean result = FALSE; - cairo_t *cr; GtkAllocation a; /* let the scrolled window do it's work */ - result = (*GTK_WIDGET_CLASS (thunar_standard_view_parent_class)->expose_event) (widget, event); + cairo_save (cr); + result = (*GTK_WIDGET_CLASS (thunar_standard_view_parent_class)->draw) (widget, cr); + cairo_restore (cr); /* render the folder drop shadow */ if (G_UNLIKELY (THUNAR_STANDARD_VIEW (widget)->priv->drop_highlight)) { gtk_widget_get_allocation (widget, &a); - gtk_paint_shadow (gtk_widget_get_style (widget), gtk_widget_get_window (widget), + gtk_paint_shadow (gtk_widget_get_style (widget), cr, GTK_STATE_NORMAL, GTK_SHADOW_OUT, - NULL, widget, "dnd", + widget, "dnd", a.x, a.y, a.width, a.height); /* the cairo version looks better here, so we use it if possible */ - cr = gdk_cairo_create (gtk_widget_get_window (widget)); cairo_set_source_rgb (cr, 0.0, 0.0, 0.0); cairo_set_line_width (cr, 1.0); cairo_rectangle (cr, a.x + 0.5, a.y + 0.5, a.width - 1, a.height - 1); cairo_stroke (cr); - cairo_destroy (cr); } return result; @@ -2613,7 +2616,6 @@ thunar_standard_view_action_select_by_pattern (GtkAction *action, dialog = gtk_dialog_new_with_buttons (_("Select by Pattern"), GTK_WINDOW (window), GTK_DIALOG_MODAL - | GTK_DIALOG_NO_SEPARATOR | GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, _("_Select"), GTK_RESPONSE_OK, @@ -3121,10 +3123,10 @@ thunar_standard_view_key_press_event (GtkWidget *view, _thunar_return_val_if_fail (THUNAR_IS_STANDARD_VIEW (standard_view), FALSE); /* need to catch "/" and "~" first, as the views would otherwise start interactive search */ - if ((event->keyval == GDK_slash || event->keyval == GDK_asciitilde || event->keyval == GDK_dead_tilde) && !(event->state & (~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask ()))) + if ((event->keyval == GDK_KEY_slash || event->keyval == GDK_KEY_asciitilde || event->keyval == GDK_KEY_dead_tilde) && !(event->state & (~GDK_SHIFT_MASK & gtk_accelerator_get_default_mod_mask ()))) { /* popup the location selector (in whatever way) */ - if (event->keyval == GDK_dead_tilde) + if (event->keyval == GDK_KEY_dead_tilde) g_signal_emit (G_OBJECT (standard_view), standard_view_signals[START_OPEN_LOCATION], 0, "~"); else g_signal_emit (G_OBJECT (standard_view), standard_view_signals[START_OPEN_LOCATION], 0, event->string); @@ -3897,7 +3899,7 @@ thunar_standard_view_drag_scroll_timer (gpointer user_data) { /* determine pointer location and window geometry */ gdk_window_get_pointer (gtk_widget_get_window (gtk_bin_get_child (GTK_BIN (standard_view))), &x, &y, NULL); - gdk_window_get_geometry (gtk_widget_get_window (gtk_bin_get_child (GTK_BIN (standard_view))), NULL, NULL, &w, &h, NULL); + gdk_window_get_geometry (gtk_widget_get_window (gtk_bin_get_child (GTK_BIN (standard_view))), NULL, NULL, &w, &h); /* check if we are near the edge (vertical) */ offset = y - (2 * 20); diff --git a/thunar/thunar-statusbar.c b/thunar/thunar-statusbar.c index 39ea7c66c2afcb5be180f30843285f56ccfd4be4..b4c9021ad6e5ed3813f3564616a672004e7d7593 100644 --- a/thunar/thunar-statusbar.c +++ b/thunar/thunar-statusbar.c @@ -104,7 +104,6 @@ static void thunar_statusbar_init (ThunarStatusbar *statusbar) { statusbar->context_id = gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar), "Main text"); - gtk_statusbar_set_has_resize_grip (GTK_STATUSBAR (statusbar), TRUE); } diff --git a/thunar/thunar-text-renderer.c b/thunar/thunar-text-renderer.c deleted file mode 100644 index 42a0140ce486d1dece21261f2ddb9725872d2394..0000000000000000000000000000000000000000 --- a/thunar/thunar-text-renderer.c +++ /dev/null @@ -1,880 +0,0 @@ -/* vi:set et ai sw=2 sts=2 ts=2: */ -/*- - * Copyright (c) 2005-2006 Benedikt Meurer <benny@xfce.org> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#ifdef HAVE_MEMORY_H -#include <memory.h> -#endif -#ifdef HAVE_STRING_H -#include <string.h> -#endif - -#include <exo/exo.h> - -#include <thunar/thunar-gobject-extensions.h> -#include <thunar/thunar-marshal.h> -#include <thunar/thunar-pango-extensions.h> -#include <thunar/thunar-text-renderer.h> -#include <thunar/thunar-util.h> - - - -enum -{ - PROP_0, - PROP_ALIGNMENT, - PROP_FOLLOW_PRELIT, - PROP_FOLLOW_STATE, - PROP_TEXT, - PROP_WRAP_MODE, - PROP_WRAP_WIDTH, - N_PROPERTIES -}; - -enum -{ - EDITED, - LAST_SIGNAL, -}; - - - -static void thunar_text_renderer_finalize (GObject *object); -static void thunar_text_renderer_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec); -static void thunar_text_renderer_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec); -static void thunar_text_renderer_get_size (GtkCellRenderer *renderer, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height); -static void thunar_text_renderer_render (GtkCellRenderer *renderer, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags); -static GtkCellEditable *thunar_text_renderer_start_editing (GtkCellRenderer *renderer, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags); -static void thunar_text_renderer_invalidate (ThunarTextRenderer *text_renderer); -static void thunar_text_renderer_set_widget (ThunarTextRenderer *text_renderer, - GtkWidget *widget); -static void thunar_text_renderer_editing_done (GtkCellEditable *editable, - ThunarTextRenderer *text_renderer); -static void thunar_text_renderer_grab_focus (GtkWidget *entry, - ThunarTextRenderer *text_renderer); -static gboolean thunar_text_renderer_focus_out_event (GtkWidget *entry, - GdkEventFocus *event, - ThunarTextRenderer *text_renderer); -static void thunar_text_renderer_populate_popup (GtkEntry *entry, - GtkMenu *menu, - ThunarTextRenderer *text_renderer); -static void thunar_text_renderer_popup_unmap (GtkMenu *menu, - ThunarTextRenderer *text_renderer); -static gboolean thunar_text_renderer_entry_menu_popdown_timer (gpointer user_data); -static void thunar_text_renderer_entry_menu_popdown_timer_destroy (gpointer user_data); - - - -struct _ThunarTextRendererClass -{ - GtkCellRendererClass __parent__; - - void (*edited) (ThunarTextRenderer *text_renderer, - const gchar *path, - const gchar *text); -}; - -struct _ThunarTextRenderer -{ - GtkCellRenderer __parent__; - - /* pango renderer properties */ - PangoLayout *layout; - GtkWidget *widget; - guint text_static : 1; - gchar *text; - gint char_width; - gint char_height; - PangoWrapMode wrap_mode; - gint wrap_width; - guint follow_state : 1; - gint focus_width;; - PangoAlignment alignment; - - /* underline prelited rows */ - guint follow_prelit : 1; - - /* cell editing support */ - GtkWidget *entry; - guint entry_menu_active : 1; - guint entry_menu_popdown_timer_id; -}; - - - -static guint text_renderer_signals[LAST_SIGNAL]; -static GParamSpec *text_renderer_props[N_PROPERTIES] = { NULL, }; - - - -G_DEFINE_TYPE (ThunarTextRenderer, thunar_text_renderer, GTK_TYPE_CELL_RENDERER) - - - -static void -thunar_text_renderer_class_init (ThunarTextRendererClass *klass) -{ - GtkCellRendererClass *gtkcell_renderer_class; - GObjectClass *gobject_class; - - gobject_class = G_OBJECT_CLASS (klass); - gobject_class->finalize = thunar_text_renderer_finalize; - gobject_class->get_property = thunar_text_renderer_get_property; - gobject_class->set_property = thunar_text_renderer_set_property; - - gtkcell_renderer_class = GTK_CELL_RENDERER_CLASS (klass); - gtkcell_renderer_class->get_size = thunar_text_renderer_get_size; - gtkcell_renderer_class->render = thunar_text_renderer_render; - gtkcell_renderer_class->start_editing = thunar_text_renderer_start_editing; - - /** - * ThunarTextRenderer:alignment: - * - * Specifies how to align the lines of text with respect to each other. - **/ - text_renderer_props[PROP_ALIGNMENT] = - g_param_spec_enum ("alignment", - "alignment", - "alignment", - PANGO_TYPE_ALIGNMENT, - PANGO_ALIGN_LEFT, - EXO_PARAM_READWRITE); - - /** - * ThunarTextRenderer:follow-prelit: - * - * Whether to underline prelited cells. This is used for the single - * click support in the detailed list view. - **/ - text_renderer_props[PROP_FOLLOW_PRELIT] = - g_param_spec_boolean ("follow-prelit", - "follow-prelit", - "follow-prelit", - FALSE, - EXO_PARAM_READWRITE); - - /** - * ThunarTextRenderer:follow-state: - * - * Specifies whether the text renderer should render text - * based on the selection state of the items. This is necessary - * for #ExoIconView, which doesn't draw any item state indicators - * itself. - **/ - text_renderer_props[PROP_FOLLOW_STATE] = - g_param_spec_boolean ("follow-state", - "follow-state", - "follow-state", - FALSE, - EXO_PARAM_READWRITE); - - /** - * ThunarTextRenderer:text: - * - * The text to render. - **/ - text_renderer_props[PROP_TEXT] = - g_param_spec_string ("text", - "text", - "text", - NULL, - EXO_PARAM_READWRITE); - - /** - * ThunarTextRenderer:wrap-mode: - * - * Specifies how to break the string into multiple lines, if the cell renderer - * does not have enough room to display the entire string. This property has - * no effect unless the wrap-width property is set. - **/ - text_renderer_props[PROP_WRAP_MODE] = - g_param_spec_enum ("wrap-mode", - "wrap-mode", - "wrap-mode", - PANGO_TYPE_WRAP_MODE, - PANGO_WRAP_CHAR, - EXO_PARAM_READWRITE); - - /** - * ThunarTextRenderer:wrap-width: - * - * Specifies the width at which the text is wrapped. The wrap-mode property can - * be used to influence at what character positions the line breaks can be placed. - * Setting wrap-width to -1 turns wrapping off. - **/ - text_renderer_props[PROP_WRAP_WIDTH] = - g_param_spec_int ("wrap-width", - "wrap-width", - "wrap-width", - -1, G_MAXINT, -1, - EXO_PARAM_READWRITE); - - /* install properties */ - g_object_class_install_properties (gobject_class, N_PROPERTIES, text_renderer_props); - - /** - * ThunarTextRenderer::edited: - * @text_renderer : a #ThunarTextRenderer. - * @path : the string representation of the tree path, which was edited. - * @text : the new text for the cell. - * @user_data : user data set when the signal handler was connected. - * - * Emitted whenever the user successfully edits a cell. - **/ - text_renderer_signals[EDITED] = - g_signal_new (I_("edited"), - G_OBJECT_CLASS_TYPE (gobject_class), - G_SIGNAL_RUN_LAST, - G_STRUCT_OFFSET (ThunarTextRendererClass, edited), - NULL, NULL, - _thunar_marshal_VOID__STRING_STRING, - G_TYPE_NONE, 2, G_TYPE_STRING, G_TYPE_STRING); -} - - - -static void -thunar_text_renderer_init (ThunarTextRenderer *text_renderer) -{ - text_renderer->wrap_width = -1; - text_renderer->alignment = PANGO_ALIGN_LEFT; -} - - - -static void -thunar_text_renderer_finalize (GObject *object) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (object); - - /* release text (if not static) */ - if (!text_renderer->text_static) - g_free (text_renderer->text); - - /* drop the cached widget */ - thunar_text_renderer_set_widget (text_renderer, NULL); - - (*G_OBJECT_CLASS (thunar_text_renderer_parent_class)->finalize) (object); -} - - - -static void -thunar_text_renderer_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (object); - - switch (prop_id) - { - case PROP_ALIGNMENT: - g_value_set_enum (value, text_renderer->alignment); - break; - - case PROP_FOLLOW_PRELIT: - g_value_set_boolean (value, text_renderer->follow_prelit); - break; - - case PROP_FOLLOW_STATE: - g_value_set_boolean (value, text_renderer->follow_state); - break; - - case PROP_TEXT: - g_value_set_string (value, text_renderer->text); - break; - - case PROP_WRAP_MODE: - g_value_set_enum (value, text_renderer->wrap_mode); - break; - - case PROP_WRAP_WIDTH: - g_value_set_int (value, text_renderer->wrap_width); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - - -static void -thunar_text_renderer_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (object); - const gchar *sval; - - switch (prop_id) - { - case PROP_ALIGNMENT: - text_renderer->alignment = g_value_get_enum (value); - break; - - case PROP_FOLLOW_PRELIT: - text_renderer->follow_prelit = g_value_get_boolean (value); - break; - - case PROP_FOLLOW_STATE: - text_renderer->follow_state = g_value_get_boolean (value); - break; - - case PROP_TEXT: - /* release the previous text (if not static) */ - if (!text_renderer->text_static) - g_free (text_renderer->text); - sval = g_value_get_string (value); - text_renderer->text_static = (value->data[1].v_uint & G_VALUE_NOCOPY_CONTENTS); - text_renderer->text = (sval == NULL) ? "" : (gchar *)sval; - if (!text_renderer->text_static) - text_renderer->text = g_strdup (text_renderer->text); - break; - - case PROP_WRAP_MODE: - text_renderer->wrap_mode = g_value_get_enum (value); - break; - - case PROP_WRAP_WIDTH: - /* be sure to reset fixed height if wrapping is requested */ - text_renderer->wrap_width = g_value_get_int (value); - if (G_LIKELY (text_renderer->wrap_width >= 0)) - gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, -1); - break; - - default: - G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); - break; - } -} - - - -static void -thunar_text_renderer_get_size (GtkCellRenderer *renderer, - GtkWidget *widget, - GdkRectangle *cell_area, - gint *x_offset, - gint *y_offset, - gint *width, - gint *height) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (renderer); - gint text_length; - gint text_width; - gint text_height; - gint renderer_xpad; - gint renderer_ypad; - gfloat renderer_xalign; - gfloat renderer_yalign; - - /* setup the new widget */ - thunar_text_renderer_set_widget (text_renderer, widget); - - /* we can guess the dimensions if we don't wrap */ - if (text_renderer->wrap_width < 0) - { - /* determine the text_length in characters */ - text_length = g_utf8_strlen (text_renderer->text, -1); - - /* the approximation is usually 1-2 chars wrong, so wth */ - text_length += 2; - - /* calculate the appromixate text width/height */ - text_width = text_renderer->char_width * text_length; - text_height = text_renderer->char_height; - } - else - { - /* calculate the real text dimension */ - pango_layout_set_width (text_renderer->layout, text_renderer->wrap_width * PANGO_SCALE); - pango_layout_set_wrap (text_renderer->layout, text_renderer->wrap_mode); - pango_layout_set_text (text_renderer->layout, text_renderer->text, -1); - pango_layout_get_pixel_size (text_renderer->layout, &text_width, &text_height); - } - - /* if we have to follow the state manually, we'll need - * to reserve some space to render the indicator to. - */ - if (text_renderer->follow_state) - { - text_width += 2 * text_renderer->focus_width; - text_height += 2 * text_renderer->focus_width; - } - - /* update width/height */ - gtk_cell_renderer_get_padding (renderer, &renderer_xpad, &renderer_ypad); - gtk_cell_renderer_get_alignment (renderer, &renderer_xalign, &renderer_yalign); - - if (G_LIKELY (width != NULL)) - *width = text_width + 2 * renderer_xpad; - if (G_LIKELY (height != NULL)) - *height = text_height + 2 * renderer_ypad; - - /* update the x/y offsets */ - if (G_LIKELY (cell_area != NULL)) - { - if (G_LIKELY (x_offset != NULL)) - { - *x_offset = ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? (1.0 - renderer_xalign) : renderer_xalign) - * (cell_area->width - text_width - (2 * renderer_xpad)); - *x_offset = MAX (*x_offset, 0); - } - - if (G_LIKELY (y_offset != NULL)) - { - *y_offset = renderer_yalign * (cell_area->height - text_height - (2 * renderer_ypad)); - *y_offset = MAX (*y_offset, 0); - } - } -} - - - -static void -thunar_text_renderer_render (GtkCellRenderer *renderer, - GdkWindow *window, - GtkWidget *widget, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GdkRectangle *expose_area, - GtkCellRendererState flags) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (renderer); - GtkStateType state; - cairo_t *cr; - gint x0, x1, y0, y1; - gint x_offset; - gint y_offset; - PangoRectangle rect; - gint renderer_xpad; - gint renderer_ypad; - gfloat renderer_xalign; - gfloat renderer_yalign; - - gtk_cell_renderer_get_padding (renderer, &renderer_xpad, &renderer_ypad); - gtk_cell_renderer_get_alignment (renderer, &renderer_xalign, &renderer_yalign); - - /* setup the new widget */ - thunar_text_renderer_set_widget (text_renderer, widget); - - if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED) - { - if (gtk_widget_has_focus (widget)) - state = GTK_STATE_SELECTED; - else - state = GTK_STATE_ACTIVE; - } - else if ((flags & GTK_CELL_RENDERER_PRELIT) == GTK_CELL_RENDERER_PRELIT - && gtk_widget_get_state (widget) == GTK_STATE_PRELIGHT) - { - state = GTK_STATE_PRELIGHT; - } - else - { - if (gtk_widget_get_state (widget) == GTK_STATE_INSENSITIVE) - state = GTK_STATE_INSENSITIVE; - else - state = GTK_STATE_NORMAL; - } - - /* check if we should follow the prelit state (used for single click support) */ - if (text_renderer->follow_prelit && (flags & GTK_CELL_RENDERER_PRELIT) != 0) - pango_layout_set_attributes (text_renderer->layout, thunar_pango_attr_list_underline_single ()); - else - pango_layout_set_attributes (text_renderer->layout, NULL); - - /* setup the wrapping */ - if (text_renderer->wrap_width < 0) - { - pango_layout_set_width (text_renderer->layout, -1); - pango_layout_set_wrap (text_renderer->layout, PANGO_WRAP_CHAR); - } - else - { - pango_layout_set_width (text_renderer->layout, text_renderer->wrap_width * PANGO_SCALE); - pango_layout_set_wrap (text_renderer->layout, text_renderer->wrap_mode); - } - - pango_layout_set_text (text_renderer->layout, text_renderer->text, -1); - pango_layout_set_alignment (text_renderer->layout, text_renderer->alignment); - - /* calculate the real text dimension */ - pango_layout_get_pixel_extents (text_renderer->layout, NULL, &rect); - - /* take into account the state indicator (required for calculation) */ - if (text_renderer->follow_state) - { - rect.width += 2 * text_renderer->focus_width; - rect.height += 2 * text_renderer->focus_width; - } - - /* calculate the real x-offset */ - x_offset = ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL) ? (1.0 - renderer_xalign) : renderer_xalign) - * (cell_area->width - rect.width - (2 * renderer_xpad)); - x_offset = MAX (x_offset, 0); - - /* calculate the real y-offset */ - y_offset = renderer_yalign * (cell_area->height - rect.height - (2 * renderer_ypad)); - y_offset = MAX (y_offset, 0); - - /* render the state indicator */ - if ((flags & GTK_CELL_RENDERER_SELECTED) == GTK_CELL_RENDERER_SELECTED && text_renderer->follow_state) - { - /* calculate the text bounding box (including the focus padding/width) */ - x0 = cell_area->x + x_offset; - y0 = cell_area->y + y_offset; - x1 = x0 + rect.width; - y1 = y0 + rect.height; - - /* Cairo produces nicer results than using a polygon - * and so we use it directly if possible. - */ - cr = gdk_cairo_create (window); - cairo_move_to (cr, x0 + 5, y0); - cairo_line_to (cr, x1 - 5, y0); - cairo_curve_to (cr, x1 - 5, y0, x1, y0, x1, y0 + 5); - cairo_line_to (cr, x1, y1 - 5); - cairo_curve_to (cr, x1, y1 - 5, x1, y1, x1 - 5, y1); - cairo_line_to (cr, x0 + 5, y1); - cairo_curve_to (cr, x0 + 5, y1, x0, y1, x0, y1 - 5); - cairo_line_to (cr, x0, y0 + 5); - cairo_curve_to (cr, x0, y0 + 5, x0, y0, x0 + 5, y0); - gdk_cairo_set_source_color (cr, >k_widget_get_style (widget)->base[state]); - cairo_fill (cr); - cairo_destroy (cr); - } - - /* draw the focus indicator */ - if (text_renderer->follow_state && (flags & GTK_CELL_RENDERER_FOCUSED) != 0) - { - gtk_paint_focus (gtk_widget_get_style (widget), window, gtk_widget_get_state (widget), NULL, widget, "icon_view", - cell_area->x + x_offset, cell_area->y + y_offset, rect.width, rect.height); - } - - /* get proper sizing for the layout drawing */ - if (text_renderer->follow_state) - { - rect.width -= 2 * text_renderer->focus_width; - rect.height -= 2 * text_renderer->focus_width; - x_offset += text_renderer->focus_width; - y_offset += text_renderer->focus_width; - } - - /* draw the text */ - gtk_paint_layout (gtk_widget_get_style (widget), window, state, TRUE, - expose_area, widget, "cellrenderertext", - cell_area->x + x_offset + renderer_xpad - rect.x, - cell_area->y + y_offset + renderer_ypad - rect.y, - text_renderer->layout); -} - - - -static GtkCellEditable* -thunar_text_renderer_start_editing (GtkCellRenderer *renderer, - GdkEvent *event, - GtkWidget *widget, - const gchar *path, - GdkRectangle *background_area, - GdkRectangle *cell_area, - GtkCellRendererState flags) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (renderer); - GtkCellRendererMode renderer_mode; - gfloat renderer_xalign; - - g_object_get (G_OBJECT (renderer), - "mode", &renderer_mode, - "xalign", &renderer_xalign, - NULL); - - /* verify that we are editable */ - if (renderer_mode != GTK_CELL_RENDERER_MODE_EDITABLE) - return NULL; - - /* allocate a new text entry widget to be used for editing */ - text_renderer->entry = g_object_new (GTK_TYPE_ENTRY, - "has-frame", FALSE, - "text", text_renderer->text, - "visible", TRUE, - "xalign", renderer_xalign, - NULL); - - /* select the whole text */ - gtk_editable_select_region (GTK_EDITABLE (text_renderer->entry), 0, -1); - - /* remember the tree path that we're editing */ - g_object_set_data_full (G_OBJECT (text_renderer->entry), I_("thunar-text-renderer-path"), g_strdup (path), g_free); - - /* connect required signals */ - g_signal_connect (G_OBJECT (text_renderer->entry), "editing-done", G_CALLBACK (thunar_text_renderer_editing_done), text_renderer); - g_signal_connect_after (G_OBJECT (text_renderer->entry), "grab-focus", G_CALLBACK (thunar_text_renderer_grab_focus), text_renderer); - g_signal_connect (G_OBJECT (text_renderer->entry), "focus-out-event", G_CALLBACK (thunar_text_renderer_focus_out_event), text_renderer); - g_signal_connect (G_OBJECT (text_renderer->entry), "populate-popup", G_CALLBACK (thunar_text_renderer_populate_popup), text_renderer); - - return GTK_CELL_EDITABLE (text_renderer->entry); -} - - - -static void -thunar_text_renderer_invalidate (ThunarTextRenderer *text_renderer) -{ - thunar_text_renderer_set_widget (text_renderer, NULL); -} - - - -static void -thunar_text_renderer_set_widget (ThunarTextRenderer *text_renderer, - GtkWidget *widget) -{ - PangoFontMetrics *metrics; - PangoContext *context; - gint focus_padding; - gint focus_line_width; - - if (G_LIKELY (widget == text_renderer->widget)) - return; - - /* disconnect from the previously set widget */ - if (G_UNLIKELY (text_renderer->widget != NULL)) - { - g_signal_handlers_disconnect_by_func (G_OBJECT (text_renderer->widget), thunar_text_renderer_invalidate, text_renderer); - g_object_unref (G_OBJECT (text_renderer->layout)); - g_object_unref (G_OBJECT (text_renderer->widget)); - } - - /* activate the new widget */ - text_renderer->widget = widget; - - /* connect to the new widget */ - if (G_LIKELY (widget != NULL)) - { - /* take a reference on the widget */ - g_object_ref (G_OBJECT (widget)); - - /* we need to recalculate the metrics when a new style (and thereby a new font) is set */ - g_signal_connect_swapped (G_OBJECT (text_renderer->widget), "destroy", G_CALLBACK (thunar_text_renderer_invalidate), text_renderer); - g_signal_connect_swapped (G_OBJECT (text_renderer->widget), "style-set", G_CALLBACK (thunar_text_renderer_invalidate), text_renderer); - - /* allocate a new pango layout for this widget */ - context = gtk_widget_get_pango_context (widget); - text_renderer->layout = pango_layout_new (context); - - /* disable automatic text direction, but use the direction specified by Gtk+ */ - pango_layout_set_auto_dir (text_renderer->layout, FALSE); - - /* we don't want to interpret line separators in file names */ - pango_layout_set_single_paragraph_mode (text_renderer->layout, TRUE); - - /* calculate the average character dimensions */ - metrics = pango_context_get_metrics (context, gtk_widget_get_style (widget)->font_desc, pango_context_get_language (context)); - text_renderer->char_width = PANGO_PIXELS (pango_font_metrics_get_approximate_char_width (metrics)); - text_renderer->char_height = PANGO_PIXELS (pango_font_metrics_get_ascent (metrics) + pango_font_metrics_get_descent (metrics)); - pango_font_metrics_unref (metrics); - - /* tell the cell renderer about the fixed height if we're not wrapping text */ - if (G_LIKELY (text_renderer->wrap_width < 0)) - gtk_cell_renderer_set_fixed_size (GTK_CELL_RENDERER (text_renderer), -1, text_renderer->char_height); - - /* determine the focus-padding and focus-line-width style properties from the widget */ - gtk_widget_style_get (widget, "focus-padding", &focus_padding, "focus-line-width", &focus_line_width, NULL); - text_renderer->focus_width = focus_padding + focus_line_width; - } - else - { - text_renderer->layout = NULL; - text_renderer->char_width = 0; - text_renderer->char_height = 0; - } -} - - - -static void -thunar_text_renderer_editing_done (GtkCellEditable *editable, - ThunarTextRenderer *text_renderer) -{ - const gchar *path; - const gchar *text; - gboolean editing_canceled; - - g_object_get (G_OBJECT (editable), "editing-canceled", &editing_canceled, NULL); - - /* disconnect our signals from the cell editable */ - g_signal_handlers_disconnect_by_func (G_OBJECT (editable), thunar_text_renderer_editing_done, text_renderer); - g_signal_handlers_disconnect_by_func (G_OBJECT (editable), thunar_text_renderer_focus_out_event, text_renderer); - g_signal_handlers_disconnect_by_func (G_OBJECT (editable), thunar_text_renderer_populate_popup, text_renderer); - - /* let the GtkCellRenderer class do it's part of the job */ - gtk_cell_renderer_stop_editing (GTK_CELL_RENDERER (text_renderer), editing_canceled); - - /* inform whoever is interested that we have new text (if not cancelled) */ - if (G_LIKELY (!editing_canceled)) - { - text = gtk_entry_get_text (GTK_ENTRY (editable)); - path = g_object_get_data (G_OBJECT (editable), "thunar-text-renderer-path"); - g_signal_emit (G_OBJECT (text_renderer), text_renderer_signals[EDITED], 0, path, text); - } -} - - - -static void -thunar_text_renderer_grab_focus (GtkWidget *entry, - ThunarTextRenderer *text_renderer) -{ - const gchar *text; - const gchar *dot; - glong offset; - - /* determine the text from the entry widget */ - text = gtk_entry_get_text (GTK_ENTRY (entry)); - - /* lookup the last dot in the text */ - dot = thunar_util_str_get_extension (text); - if (G_LIKELY (dot != NULL)) - { - /* determine the UTF-8 char offset */ - offset = g_utf8_pointer_to_offset (text, dot); - - /* select the text prior to the dot */ - if (G_LIKELY (offset > 0)) - gtk_editable_select_region (GTK_EDITABLE (entry), 0, offset); - } - - /* disconnect the grab-focus handler, so we change the selection only once */ - g_signal_handlers_disconnect_by_func (G_OBJECT (entry), thunar_text_renderer_grab_focus, text_renderer); -} - - - -static gboolean -thunar_text_renderer_focus_out_event (GtkWidget *entry, - GdkEventFocus *event, - ThunarTextRenderer *text_renderer) -{ - /* cancel editing if we haven't popped up the menu */ - if (G_LIKELY (!text_renderer->entry_menu_active)) - thunar_text_renderer_editing_done (GTK_CELL_EDITABLE (entry), text_renderer); - - /* we need to pass the event to the entry */ - return FALSE; -} - - - -static void -thunar_text_renderer_populate_popup (GtkEntry *entry, - GtkMenu *menu, - ThunarTextRenderer *text_renderer) -{ - if (G_UNLIKELY (text_renderer->entry_menu_popdown_timer_id != 0)) - g_source_remove (text_renderer->entry_menu_popdown_timer_id); - - text_renderer->entry_menu_active = TRUE; - - g_signal_connect (G_OBJECT (menu), "unmap", G_CALLBACK (thunar_text_renderer_popup_unmap), text_renderer); -} - - - -static void -thunar_text_renderer_popup_unmap (GtkMenu *menu, - ThunarTextRenderer *text_renderer) -{ - text_renderer->entry_menu_active = FALSE; - - if (G_LIKELY (text_renderer->entry_menu_popdown_timer_id == 0)) - { - text_renderer->entry_menu_popdown_timer_id = g_timeout_add_full (G_PRIORITY_LOW, 500u, thunar_text_renderer_entry_menu_popdown_timer, - text_renderer, thunar_text_renderer_entry_menu_popdown_timer_destroy); - } -} - - - -static gboolean -thunar_text_renderer_entry_menu_popdown_timer (gpointer user_data) -{ - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (user_data); - - GDK_THREADS_ENTER (); - - /* check if we still have the keyboard focus */ - if (G_UNLIKELY (!gtk_widget_has_focus (text_renderer->entry))) - thunar_text_renderer_editing_done (GTK_CELL_EDITABLE (text_renderer->entry), text_renderer); - - GDK_THREADS_LEAVE (); - - return FALSE; -} - - - -static void -thunar_text_renderer_entry_menu_popdown_timer_destroy (gpointer user_data) -{ - THUNAR_TEXT_RENDERER (user_data)->entry_menu_popdown_timer_id = 0; -} - - - -/** - * thunar_text_renderer_new: - **/ -GtkCellRenderer* -thunar_text_renderer_new (void) -{ - return g_object_new (THUNAR_TYPE_TEXT_RENDERER, NULL); -} - diff --git a/thunar/thunar-text-renderer.h b/thunar/thunar-text-renderer.h deleted file mode 100644 index 2be4438530c8b9d0b4060d0460fc4c44604af2d0..0000000000000000000000000000000000000000 --- a/thunar/thunar-text-renderer.h +++ /dev/null @@ -1,43 +0,0 @@ -/* vi:set et ai sw=2 sts=2 ts=2: */ -/*- - * Copyright (c) 2005 Benedikt Meurer <benny@xfce.org> - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License as published by the Free - * Software Foundation; either version 2 of the License, or (at your option) - * any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple - * Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef __THUNAR_TEXT_RENDERER_H__ -#define __THUNAR_TEXT_RENDERER_H__ - -#include <gtk/gtk.h> - -G_BEGIN_DECLS; - -typedef struct _ThunarTextRendererClass ThunarTextRendererClass; -typedef struct _ThunarTextRenderer ThunarTextRenderer; - -#define THUNAR_TYPE_TEXT_RENDERER (thunar_text_renderer_get_type ()) -#define THUNAR_TEXT_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_TEXT_RENDERER, ThunarTextRenderer)) -#define THUNAR_TEXT_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), THUNAR_TYPE_TEXT_RENDERER, ThunarTextRendererClass)) -#define THUNAR_IS_TEXT_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), THUNAR_TYPE_TEXT_RENDERER)) -#define THUNAR_IS_TEXT_RENDERER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), THUNAR_TYPE_TEXT_RENDERER)) -#define THUNAR_TEXT_RENDERER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), THUNAR_TYPE_TEXT_RENDERER, ThunarTextRendererClass)) - -GType thunar_text_renderer_get_type (void) G_GNUC_CONST; - -GtkCellRenderer *thunar_text_renderer_new (void) G_GNUC_MALLOC; - -G_END_DECLS; - -#endif /* !__THUNAR_TEXT_RENDERER_H__ */ diff --git a/thunar/thunar-tree-view.c b/thunar/thunar-tree-view.c index a7dda59af0197d1bec5b18b6dd871570fe4c208f..3b46b8526909927a27fdd021db80344ecb42d8d1 100644 --- a/thunar/thunar-tree-view.c +++ b/thunar/thunar-tree-view.c @@ -358,11 +358,11 @@ thunar_tree_view_class_init (ThunarTreeViewClass *klass) /* setup the key bindings for the tree view */ binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, GDK_CONTROL_MASK, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, 0, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, 0, "delete-selected-files", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, GDK_CONTROL_MASK, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, 0, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, 0, "delete-selected-files", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Delete, GDK_SHIFT_MASK, "delete-selected-files", 0); } @@ -855,9 +855,9 @@ thunar_tree_view_key_press_event(GtkWidget *widget, switch (event->keyval) { case GDK_KEY_Up: - case GDK_KP_Up: + case GDK_KEY_KP_Up: case GDK_KEY_Down: - case GDK_KP_Down: + case GDK_KEY_KP_Down: /* the default actions works good, but we want to update the right pane */ GTK_WIDGET_CLASS (thunar_tree_view_parent_class)->key_press_event (widget, event); @@ -870,7 +870,7 @@ thunar_tree_view_key_press_event(GtkWidget *widget, break; case GDK_KEY_Left: - case GDK_KP_Left: + case GDK_KEY_KP_Left: /* if branch is expanded then collapse it */ if (gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path)) gtk_tree_view_collapse_row (GTK_TREE_VIEW (view), path); @@ -903,7 +903,7 @@ thunar_tree_view_key_press_event(GtkWidget *widget, break; case GDK_KEY_Right: - case GDK_KP_Right: + case GDK_KEY_KP_Right: /* if branch is not expanded then expand it */ if (!gtk_tree_view_row_expanded (GTK_TREE_VIEW (view), path)) gtk_tree_view_expand_row (GTK_TREE_VIEW (view), path, FALSE); @@ -917,9 +917,9 @@ thunar_tree_view_key_press_event(GtkWidget *widget, stopPropagation = TRUE; break; - case GDK_space: - case GDK_Return: - case GDK_KP_Enter: + case GDK_KEY_space: + case GDK_KEY_Return: + case GDK_KEY_KP_Enter: thunar_tree_view_open_selection (view); stopPropagation = TRUE; break; @@ -2653,7 +2653,7 @@ thunar_tree_view_drag_scroll_timer (gpointer user_data) { /* determine pointer location and window geometry */ gdk_window_get_pointer (gtk_widget_get_window (GTK_WIDGET (view)), NULL, &y, NULL); - gdk_window_get_geometry (gtk_widget_get_window (GTK_WIDGET (view)), NULL, NULL, NULL, &h, NULL); + gdk_window_get_geometry (gtk_widget_get_window (GTK_WIDGET (view)), NULL, NULL, NULL, &h); /* check if we are near the edge */ offset = y - (2 * 20); diff --git a/thunar/thunar-window.c b/thunar/thunar-window.c index ee55a0bf8c8d245b67aba563f2eae149c6a21ec9..80e6a48dd81c31bc4a6ec86dd887e09fc8187a72 100644 --- a/thunar/thunar-window.c +++ b/thunar/thunar-window.c @@ -622,19 +622,19 @@ thunar_window_class_init (ThunarWindowClass *klass) /* setup the key bindings for the windows */ binding_set = gtk_binding_set_by_class (klass); - gtk_binding_entry_add_signal (binding_set, GDK_BackSpace, 0, "back", 0); - gtk_binding_entry_add_signal (binding_set, GDK_F5, 0, "reload", 1, G_TYPE_BOOLEAN, TRUE); - gtk_binding_entry_add_signal (binding_set, GDK_F9, 0, "toggle-sidepane", 0); - gtk_binding_entry_add_signal (binding_set, GDK_F10, 0, "toggle-menubar", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Add, GDK_CONTROL_MASK, "zoom-in", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Subtract, GDK_CONTROL_MASK, "zoom-out", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_0, GDK_CONTROL_MASK, "zoom-reset", 0); - gtk_binding_entry_add_signal (binding_set, GDK_KP_Insert, GDK_CONTROL_MASK, "zoom-reset", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_BackSpace, 0, "back", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F5, 0, "reload", 1, G_TYPE_BOOLEAN, TRUE); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F9, 0, "toggle-sidepane", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_F10, 0, "toggle-menubar", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Add, GDK_CONTROL_MASK, "zoom-in", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Subtract, GDK_CONTROL_MASK, "zoom-out", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_0, GDK_CONTROL_MASK, "zoom-reset", 0); + gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Insert, GDK_CONTROL_MASK, "zoom-reset", 0); /* setup the key bindings for Alt+N */ for (i = 0; i < 10; i++) { - gtk_binding_entry_add_signal (binding_set, GDK_0 + i, GDK_MOD1_MASK, + gtk_binding_entry_add_signal (binding_set, GDK_KEY_0 + i, GDK_MOD1_MASK, "tab-change", 1, G_TYPE_UINT, i - 1); } } @@ -3022,8 +3022,7 @@ thunar_window_action_open_templates (GtkAction *action, { /* display the "About Templates" dialog */ dialog = gtk_dialog_new_with_buttons (_("About Templates"), GTK_WINDOW (window), - GTK_DIALOG_DESTROY_WITH_PARENT - | GTK_DIALOG_NO_SEPARATOR, + GTK_DIALOG_DESTROY_WITH_PARENT, GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); diff --git a/thunarx/thunarx-property-page.c b/thunarx/thunarx-property-page.c index 1a6a0f2bd4b8ffb7230aafceadd0be3d4339c2f7..aec8e6a47e9a78f5c1b4e24dca6b62d3b16455e2 100644 --- a/thunarx/thunarx-property-page.c +++ b/thunarx/thunarx-property-page.c @@ -51,11 +51,7 @@ static void thunarx_property_page_set_property (GObject *objec guint prop_id, const GValue *value, GParamSpec *pspec); -static void thunarx_property_page_destroy (GtkObject *object); -static void thunarx_property_page_size_request (GtkWidget *widget, - GtkRequisition *requisition); -static void thunarx_property_page_size_allocate (GtkWidget *widget, - GtkAllocation *allocation); +static void thunarx_property_page_destroy (GtkWidget *object); @@ -73,7 +69,6 @@ G_DEFINE_TYPE (ThunarxPropertyPage, thunarx_property_page, GTK_TYPE_BIN) static void thunarx_property_page_class_init (ThunarxPropertyPageClass *klass) { - GtkObjectClass *gtkobject_class; GtkWidgetClass *gtkwidget_class; GObjectClass *gobject_class; @@ -84,12 +79,8 @@ thunarx_property_page_class_init (ThunarxPropertyPageClass *klass) gobject_class->get_property = thunarx_property_page_get_property; gobject_class->set_property = thunarx_property_page_set_property; - gtkobject_class = GTK_OBJECT_CLASS (klass); - gtkobject_class->destroy = thunarx_property_page_destroy; - gtkwidget_class = GTK_WIDGET_CLASS (klass); - gtkwidget_class->size_request = thunarx_property_page_size_request; - gtkwidget_class->size_allocate = thunarx_property_page_size_allocate; + gtkwidget_class->destroy = thunarx_property_page_destroy; /** * ThunarxPropertyPage::label: @@ -181,69 +172,19 @@ thunarx_property_page_set_property (GObject *object, static void -thunarx_property_page_destroy (GtkObject *object) +thunarx_property_page_destroy (GtkWidget *object) { ThunarxPropertyPage *property_page = THUNARX_PROPERTY_PAGE (object); /* destroy the label widget (if any) */ if (G_LIKELY (property_page->priv->label_widget != NULL)) { - gtk_object_destroy (GTK_OBJECT (property_page->priv->label_widget)); + gtk_widget_destroy (GTK_WIDGET (property_page->priv->label_widget)); g_object_unref (G_OBJECT (property_page->priv->label_widget)); property_page->priv->label_widget = NULL; } - (*GTK_OBJECT_CLASS (thunarx_property_page_parent_class)->destroy) (object); -} - - - -static void -thunarx_property_page_size_request (GtkWidget *widget, - GtkRequisition *requisition) -{ - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child = gtk_bin_get_child (bin); - - if (G_LIKELY (child != NULL && gtk_widget_get_visible (child))) - { - gtk_widget_size_request (child, requisition); - } - else - { - requisition->width = 0; - requisition->height = 0; - } - - requisition->width += 2 * (gtk_container_get_border_width (GTK_CONTAINER (bin)) + gtk_widget_get_style (widget)->xthickness); - requisition->height += 2 * (gtk_container_get_border_width (GTK_CONTAINER (bin)) + gtk_widget_get_style (widget)->ythickness); -} - - - -static void -thunarx_property_page_size_allocate (GtkWidget *widget, - GtkAllocation *allocation) -{ - GtkAllocation child_allocation; - GtkBin *bin = GTK_BIN (widget); - GtkWidget *child = gtk_bin_get_child (bin); - - /* apply the allocation to the property page */ - gtk_widget_set_allocation (widget, allocation); - - /* apply the child allocation if we have a child */ - if (G_LIKELY (child != NULL && gtk_widget_get_visible (child))) - { - /* calculate the allocation for the child widget */ - child_allocation.x = allocation->x + gtk_container_get_border_width (GTK_CONTAINER (bin)) + gtk_widget_get_style (widget)->xthickness; - child_allocation.y = allocation->y + gtk_container_get_border_width (GTK_CONTAINER (bin)) + gtk_widget_get_style (widget)->ythickness; - child_allocation.width = allocation->width - 2 * (gtk_container_get_border_width (GTK_CONTAINER (bin)) + gtk_widget_get_style (widget)->xthickness); - child_allocation.height = allocation->height - 2 * (gtk_container_get_border_width (GTK_CONTAINER (bin)) + gtk_widget_get_style (widget)->ythickness); - - /* apply the child allocation */ - gtk_widget_size_allocate (child, &child_allocation); - } + (*GTK_WIDGET_CLASS (thunarx_property_page_parent_class)->destroy) (object); }