diff --git a/thunar/Makefile.am b/thunar/Makefile.am index d2eaf67..70c697d 100644 --- a/thunar/Makefile.am +++ b/thunar/Makefile.am @@ -172,8 +172,6 @@ thunar_SOURCES = \ thunar-shortcuts-icon-renderer.h \ thunar-shortcuts-model.c \ thunar-shortcuts-model.h \ - thunar-shortcuts-progress-renderer.c \ - thunar-shortcuts-progress-renderer.h \ thunar-shortcuts-pane.c \ thunar-shortcuts-pane.h \ thunar-shortcuts-view.c \ diff --git a/thunar/thunar-shortcuts-model.c b/thunar/thunar-shortcuts-model.c index 0cee2ab..336ca21 100644 --- a/thunar/thunar-shortcuts-model.c +++ b/thunar/thunar-shortcuts-model.c @@ -217,8 +217,6 @@ struct _ThunarShortcutsModel guint bookmarks_idle_id; guint busy_timeout_id; - - gboolean bookmark_separator_added; }; struct _ThunarShortcut @@ -238,7 +236,6 @@ struct _ThunarShortcut ThunarDevice *device; guint hidden : 1; - guint is_separator : 1; }; @@ -538,12 +535,6 @@ thunar_shortcuts_model_get_column_type (GtkTreeModel *tree_model, case THUNAR_SHORTCUTS_MODEL_COLUMN_HIDDEN: return G_TYPE_BOOLEAN; - - case THUNAR_SHORTCUTS_MODEL_COLUMN_USAGE_PERCENT: - return G_TYPE_INT; - - case THUNAR_SHORTCUTS_MODEL_COLUMN_IS_SEPARATOR: - return G_TYPE_BOOLEAN; } _thunar_assert_not_reached (); @@ -824,45 +815,6 @@ thunar_shortcuts_model_get_value (GtkTreeModel *tree_model, g_value_set_boolean (value, FALSE); break; - case THUNAR_SHORTCUTS_MODEL_COLUMN_IS_SEPARATOR: - g_value_init (value, G_TYPE_BOOLEAN); - g_value_set_boolean (value, shortcut->is_separator); - break; - - case THUNAR_SHORTCUTS_MODEL_COLUMN_USAGE_PERCENT: - g_value_init (value, G_TYPE_INT); - if ((shortcut->group & THUNAR_SHORTCUT_GROUP_DEVICES) != 0 - && (shortcut->group & THUNAR_SHORTCUT_GROUP_HEADER) == 0) - { - guint64 fs_free = 0, fs_total = 0; - - if (shortcut->device != NULL) - file = thunar_device_get_root (shortcut->device); - else if (shortcut->file != NULL) - file = g_object_ref (thunar_file_get_file (shortcut->file)); - else - file = NULL; - - if (file != NULL - && thunar_g_file_get_free_space (file, &fs_free, &fs_total) - && fs_total > 0) - { - g_value_set_int (value, (gint) ((fs_total - fs_free) * 100 / fs_total)); - } - else - { - g_value_set_int (value, -1); - } - - if (file != NULL) - g_object_unref (file); - } - else - { - g_value_set_int (value, -1); - } - break; - default: _thunar_assert_not_reached (); } @@ -1421,18 +1373,6 @@ thunar_shortcuts_model_load_line (GFile *file_path, _thunar_return_if_fail (THUNAR_IS_SHORTCUTS_MODEL (model)); _thunar_return_if_fail (name == NULL || g_utf8_validate (name, -1, NULL)); - /* insert a separator before the first remote bookmark */ - if (!thunar_shortcuts_model_local_file (file_path) - && !model->bookmark_separator_added) - { - ThunarShortcut *sep = g_slice_new0 (ThunarShortcut); - sep->group = THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS; - sep->is_separator = TRUE; - sep->sort_id = row_num; - thunar_shortcuts_model_add_shortcut (model, sep); - model->bookmark_separator_added = TRUE; - } - shortcut = g_slice_new0 (ThunarShortcut); shortcut->group = THUNAR_SHORTCUT_GROUP_PLACES_BOOKMARKS; shortcut->location = g_object_ref (file_path); @@ -1494,9 +1434,6 @@ thunar_shortcuts_model_reload_bookmarks (gpointer data) _thunar_return_val_if_fail (THUNAR_IS_SHORTCUTS_MODEL (model), FALSE); - /* reset separator flag */ - model->bookmark_separator_added = FALSE; - /* Find all user-defined shortcuts (bookmarks) */ for (lp = model->shortcuts; lp != NULL; lp = lp->next) { diff --git a/thunar/thunar-shortcuts-model.h b/thunar/thunar-shortcuts-model.h index ac8390b..df8caef 100644 --- a/thunar/thunar-shortcuts-model.h +++ b/thunar/thunar-shortcuts-model.h @@ -53,8 +53,6 @@ typedef enum THUNAR_SHORTCUTS_MODEL_COLUMN_BUSY, THUNAR_SHORTCUTS_MODEL_COLUMN_BUSY_PULSE, THUNAR_SHORTCUTS_MODEL_COLUMN_HIDDEN, - THUNAR_SHORTCUTS_MODEL_COLUMN_USAGE_PERCENT, - THUNAR_SHORTCUTS_MODEL_COLUMN_IS_SEPARATOR, THUNAR_SHORTCUTS_MODEL_N_COLUMNS, } ThunarShortcutsModelColumn; diff --git a/thunar/thunar-shortcuts-progress-renderer.c b/thunar/thunar-shortcuts-progress-renderer.c deleted file mode 100644 index d12df9f..0000000 --- a/thunar/thunar-shortcuts-progress-renderer.c +++ /dev/null @@ -1,332 +0,0 @@ -/* vi:set et ai sw=2 sts=2 ts=2: */ -/*- - * Copyright (c) 2026 - * - * 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 -#endif - -#include "thunar/thunar-shortcuts-progress-renderer.h" - -/* Height of the usage bar in pixels */ -#define BAR_HEIGHT 4 -/* Gap between the text and the bar */ -#define BAR_TOP_PAD 2 -/* Corner radius */ -#define BAR_RADIUS 2 - - - -enum -{ - PROP_0, - PROP_USAGE_PERCENT, - PROP_IS_SEPARATOR, -}; - - - -struct _ThunarShortcutsProgressRendererClass -{ - GtkCellRendererTextClass __parent__; -}; - -struct _ThunarShortcutsProgressRenderer -{ - GtkCellRendererText __parent__; - - gint usage_percent; /* -1 = no bar, 0..100 = percent used */ - gboolean is_separator; -}; - - - -G_DEFINE_TYPE (ThunarShortcutsProgressRenderer, - thunar_shortcuts_progress_renderer, - GTK_TYPE_CELL_RENDERER_TEXT) - - - -static void -thunar_shortcuts_progress_renderer_get_property (GObject *object, - guint prop_id, - GValue *value, - GParamSpec *pspec) -{ - ThunarShortcutsProgressRenderer *renderer = THUNAR_SHORTCUTS_PROGRESS_RENDERER (object); - - switch (prop_id) - { - case PROP_USAGE_PERCENT: - g_value_set_int (value, renderer->usage_percent); - break; - - case PROP_IS_SEPARATOR: - g_value_set_boolean (value, renderer->is_separator); - break; - - default: - G_OBJECT_CLASS (thunar_shortcuts_progress_renderer_parent_class)->get_property (object, prop_id, value, pspec); - break; - } -} - - - -static void -thunar_shortcuts_progress_renderer_set_property (GObject *object, - guint prop_id, - const GValue *value, - GParamSpec *pspec) -{ - ThunarShortcutsProgressRenderer *renderer = THUNAR_SHORTCUTS_PROGRESS_RENDERER (object); - - switch (prop_id) - { - case PROP_USAGE_PERCENT: - renderer->usage_percent = g_value_get_int (value); - break; - - case PROP_IS_SEPARATOR: - renderer->is_separator = g_value_get_boolean (value); - break; - - default: - G_OBJECT_CLASS (thunar_shortcuts_progress_renderer_parent_class)->set_property (object, prop_id, value, pspec); - break; - } -} - - - -static void -thunar_shortcuts_progress_renderer_get_preferred_height (GtkCellRenderer *cell, - GtkWidget *widget, - gint *minimum, - gint *natural) -{ - ThunarShortcutsProgressRenderer *renderer = THUNAR_SHORTCUTS_PROGRESS_RENDERER (cell); - gint min_h = 0, nat_h = 0; - - /* let the parent (GtkCellRendererText) calculate text height */ - GTK_CELL_RENDERER_CLASS (thunar_shortcuts_progress_renderer_parent_class)->get_preferred_height (cell, widget, &min_h, &nat_h); - - /* add space for the bar if usage data is available */ - if (renderer->usage_percent >= 0) - { - min_h += BAR_TOP_PAD + BAR_HEIGHT; - nat_h += BAR_TOP_PAD + BAR_HEIGHT; - } - - if (minimum != NULL) - *minimum = min_h; - if (natural != NULL) - *natural = nat_h; -} - - - -static void -thunar_shortcuts_progress_renderer_render (GtkCellRenderer *cell, - cairo_t *cr, - GtkWidget *widget, - const GdkRectangle *background_area, - const GdkRectangle *cell_area, - GtkCellRendererState flags) -{ - ThunarShortcutsProgressRenderer *renderer = THUNAR_SHORTCUTS_PROGRESS_RENDERER (cell); - GtkStyleContext *context; - GdkRGBA bar_bg; - GdkRGBA bar_fg; - gint text_height; - gint bar_y; - gint bar_width; - gint xpad, ypad; - GdkRectangle text_area; - - gtk_cell_renderer_get_padding (cell, &xpad, &ypad); - - /* draw a horizontal line for separator rows */ - if (renderer->is_separator) - { - GdkRGBA fg_color; - context = gtk_widget_get_style_context (widget); - gtk_style_context_get_color (context, gtk_style_context_get_state (context), &fg_color); - fg_color.alpha = 0.3; - - cairo_save (cr); - gdk_cairo_set_source_rgba (cr, &fg_color); - cairo_set_line_width (cr, 1.0); - cairo_move_to (cr, cell_area->x + xpad, cell_area->y + cell_area->height / 2 + 0.5); - cairo_line_to (cr, cell_area->x + cell_area->width - xpad, cell_area->y + cell_area->height / 2 + 0.5); - cairo_stroke (cr); - cairo_restore (cr); - return; - } - - if (renderer->usage_percent >= 0) - { - /* calculate how much space the bar needs, then shrink cell_area for text */ - text_area = *cell_area; - text_area.height -= (BAR_TOP_PAD + BAR_HEIGHT); - - /* let the parent draw the text in the reduced area */ - GTK_CELL_RENDERER_CLASS (thunar_shortcuts_progress_renderer_parent_class)->render ( - cell, cr, widget, background_area, &text_area, flags); - - /* draw the usage bar below the text */ - text_height = text_area.height; - bar_y = cell_area->y + ypad + text_height + BAR_TOP_PAD; - bar_width = cell_area->width - 2 * xpad; - - if (bar_width <= 0) - return; - - context = gtk_widget_get_style_context (widget); - - /* bar background: semi-transparent grey */ - bar_bg.red = 0.5; - bar_bg.green = 0.5; - bar_bg.blue = 0.5; - bar_bg.alpha = 0.3; - - /* bar foreground color: red for >90%, otherwise theme selection color */ - if (renderer->usage_percent > 90) - { - bar_fg.red = 0.85; - bar_fg.green = 0.2; - bar_fg.blue = 0.2; - bar_fg.alpha = 0.9; - } - else - { - if (!gtk_style_context_lookup_color (context, "theme_selected_bg_color", &bar_fg) - || bar_fg.alpha < 0.01) - { - /* fallback blue */ - bar_fg.red = 0.3; - bar_fg.green = 0.5; - bar_fg.blue = 0.8; - } - bar_fg.alpha = 0.9; - } - - cairo_save (cr); - - /* draw background track (rounded rectangle) */ - { - gdouble x = cell_area->x + xpad; - gdouble y = bar_y; - gdouble w = bar_width; - gdouble h = BAR_HEIGHT; - gdouble r = BAR_RADIUS; - - cairo_new_sub_path (cr); - cairo_arc (cr, x + w - r, y + r, r, -G_PI_2, 0); - cairo_arc (cr, x + w - r, y + h - r, r, 0, G_PI_2); - cairo_arc (cr, x + r, y + h - r, r, G_PI_2, G_PI); - cairo_arc (cr, x + r, y + r, r, G_PI, 3 * G_PI_2); - cairo_close_path (cr); - } - gdk_cairo_set_source_rgba (cr, &bar_bg); - cairo_fill (cr); - - /* draw filled portion (rounded rectangle) */ - if (renderer->usage_percent > 0) - { - gdouble x = cell_area->x + xpad; - gdouble y = bar_y; - gdouble w = bar_width * renderer->usage_percent / 100.0; - gdouble h = BAR_HEIGHT; - gdouble r = BAR_RADIUS; - - if (w < 2 * r) - r = w / 2.0; - if (r < 0.5) - r = 0; - - cairo_new_sub_path (cr); - cairo_arc (cr, x + w - r, y + r, r, -G_PI_2, 0); - cairo_arc (cr, x + w - r, y + h - r, r, 0, G_PI_2); - cairo_arc (cr, x + r, y + h - r, r, G_PI_2, G_PI); - cairo_arc (cr, x + r, y + r, r, G_PI, 3 * G_PI_2); - cairo_close_path (cr); - - gdk_cairo_set_source_rgba (cr, &bar_fg); - cairo_fill (cr); - } - - cairo_restore (cr); - } - else - { - /* no usage data: just draw the text normally */ - GTK_CELL_RENDERER_CLASS (thunar_shortcuts_progress_renderer_parent_class)->render ( - cell, cr, widget, background_area, cell_area, flags); - } -} - - - -static void -thunar_shortcuts_progress_renderer_class_init (ThunarShortcutsProgressRendererClass *klass) -{ - GObjectClass *gobject_class = G_OBJECT_CLASS (klass); - GtkCellRendererClass *cell_class = GTK_CELL_RENDERER_CLASS (klass); - - gobject_class->get_property = thunar_shortcuts_progress_renderer_get_property; - gobject_class->set_property = thunar_shortcuts_progress_renderer_set_property; - - cell_class->get_preferred_height = thunar_shortcuts_progress_renderer_get_preferred_height; - cell_class->render = thunar_shortcuts_progress_renderer_render; - - g_object_class_install_property (gobject_class, - PROP_USAGE_PERCENT, - g_param_spec_int ("usage-percent", - "usage-percent", - "Disk usage percentage (0-100, -1 = hidden)", - -1, 100, -1, - G_PARAM_READWRITE)); - - g_object_class_install_property (gobject_class, - PROP_IS_SEPARATOR, - g_param_spec_boolean ("is-separator", - "is-separator", - "Draw a horizontal line instead of text", - FALSE, - G_PARAM_READWRITE)); -} - - - -static void -thunar_shortcuts_progress_renderer_init (ThunarShortcutsProgressRenderer *renderer) -{ - renderer->usage_percent = -1; - - /* match the original text renderer settings */ - g_object_set (renderer, "ellipsize", PANGO_ELLIPSIZE_END, NULL); -} - - - -GtkCellRenderer * -thunar_shortcuts_progress_renderer_new (void) -{ - return g_object_new (THUNAR_TYPE_SHORTCUTS_PROGRESS_RENDERER, NULL); -} diff --git a/thunar/thunar-shortcuts-progress-renderer.h b/thunar/thunar-shortcuts-progress-renderer.h deleted file mode 100644 index 6683f39..0000000 --- a/thunar/thunar-shortcuts-progress-renderer.h +++ /dev/null @@ -1,38 +0,0 @@ -/* vi:set et ai sw=2 sts=2 ts=2: */ -/*- - * Copyright (c) 2026 - * - * 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_SHORTCUTS_PROGRESS_RENDERER_H__ -#define __THUNAR_SHORTCUTS_PROGRESS_RENDERER_H__ - -#include - -G_BEGIN_DECLS; - -typedef struct _ThunarShortcutsProgressRendererClass ThunarShortcutsProgressRendererClass; -typedef struct _ThunarShortcutsProgressRenderer ThunarShortcutsProgressRenderer; - -#define THUNAR_TYPE_SHORTCUTS_PROGRESS_RENDERER (thunar_shortcuts_progress_renderer_get_type ()) -#define THUNAR_SHORTCUTS_PROGRESS_RENDERER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), THUNAR_TYPE_SHORTCUTS_PROGRESS_RENDERER, ThunarShortcutsProgressRenderer)) - -GType thunar_shortcuts_progress_renderer_get_type (void) G_GNUC_CONST; -GtkCellRenderer *thunar_shortcuts_progress_renderer_new (void); - -G_END_DECLS; - -#endif /* !__THUNAR_SHORTCUTS_PROGRESS_RENDERER_H__ */ diff --git a/thunar/thunar-shortcuts-view.c b/thunar/thunar-shortcuts-view.c index a17e3a1..8e6d2c4 100644 --- a/thunar/thunar-shortcuts-view.c +++ b/thunar/thunar-shortcuts-view.c @@ -44,7 +44,6 @@ #include "thunar/thunar-private.h" #include "thunar/thunar-shortcuts-icon-renderer.h" #include "thunar/thunar-shortcuts-model.h" -#include "thunar/thunar-shortcuts-progress-renderer.h" #include "thunar/thunar-shortcuts-view.h" #include @@ -320,20 +319,6 @@ thunar_shortcuts_view_navigator_init (ThunarNavigatorIface *iface) -static gboolean -thunar_shortcuts_view_row_separator (GtkTreeModel *model, - GtkTreeIter *iter, - gpointer data) -{ - gboolean is_separator = FALSE; - gtk_tree_model_get (model, iter, - THUNAR_SHORTCUTS_MODEL_COLUMN_IS_SEPARATOR, &is_separator, - -1); - return is_separator; -} - - - static void thunar_shortcuts_view_init (ThunarShortcutsView *view) { @@ -346,8 +331,6 @@ thunar_shortcuts_view_init (ThunarShortcutsView *view) gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (view), FALSE); gtk_tree_view_set_tooltip_column (GTK_TREE_VIEW (view), THUNAR_SHORTCUTS_MODEL_COLUMN_TOOLTIP); - /* no row_separator_func — separator is drawn by the progress renderer */ - /* grab a reference on the provider factory */ view->provider_factory = thunarx_provider_factory_get_default (); @@ -412,14 +395,14 @@ thunar_shortcuts_view_init (ThunarShortcutsView *view) g_object_bind_property (G_OBJECT (view->preferences), "misc-symbolic-icons-in-sidepane", G_OBJECT (view->icon_renderer), "use-symbolic-icons", G_BINDING_SYNC_CREATE); g_signal_connect_swapped (G_OBJECT (view->preferences), "notify::misc-symbolic-icons-in-sidepane", G_CALLBACK (gtk_widget_queue_draw), view); - /* allocate the text+progress renderer for device names with usage bars */ - renderer = thunar_shortcuts_progress_renderer_new (); + /* allocate the text renderer (ellipsizing as required, but "File System" must fit) */ + renderer = g_object_new (GTK_TYPE_CELL_RENDERER_TEXT, + "ellipsize", PANGO_ELLIPSIZE_END, + NULL); g_signal_connect (G_OBJECT (renderer), "edited", G_CALLBACK (thunar_shortcuts_view_renamed), view); gtk_tree_view_column_pack_start (column, renderer, TRUE); gtk_tree_view_column_set_attributes (column, renderer, "text", THUNAR_SHORTCUTS_MODEL_COLUMN_NAME, - "usage-percent", THUNAR_SHORTCUTS_MODEL_COLUMN_USAGE_PERCENT, - "is-separator", THUNAR_SHORTCUTS_MODEL_COLUMN_IS_SEPARATOR, "visible", THUNAR_SHORTCUTS_MODEL_COLUMN_IS_ITEM, NULL); diff --git a/thunar/thunar-standard-view.c b/thunar/thunar-standard-view.c index 83b8992..f1fccc4 100644 --- a/thunar/thunar-standard-view.c +++ b/thunar/thunar-standard-view.c @@ -4799,27 +4799,10 @@ thunar_standard_view_cell_layout_data_func (GtkCellLayout *layout, /* since this function is being used for both icon & name renderers; * we need to make sure the right properties are applied to the right renderers */ if (THUNAR_IS_TEXT_RENDERER (cell)) - { - /* set disk usage bar for computer:// items */ - gint usage = -1; - GFile *gfile = thunar_file_get_file (file); - if (gfile != NULL && g_file_has_uri_scheme (gfile, "computer")) - { - GFile *root = thunar_file_get_target_location (file); - if (root == NULL) - root = gfile; - guint64 fs_free = 0, fs_total = 0; - if (thunar_g_file_get_free_space (root, &fs_free, &fs_total) && fs_total > 0) - usage = (gint) ((fs_total - fs_free) * 100 / fs_total); - if (root != gfile) - g_object_unref (root); - } - g_object_set (G_OBJECT (cell), - "foreground-rgba", foreground != NULL ? &foreground_rgba : NULL, - "highlight-color", background, - "usage-percent", usage, - NULL); - } + g_object_set (G_OBJECT (cell), + "foreground-rgba", foreground != NULL ? &foreground_rgba : NULL, + "highlight-color", background, + NULL); else if (THUNAR_IS_ICON_RENDERER (cell)) g_object_set (G_OBJECT (cell), diff --git a/thunar/thunar-text-renderer.c b/thunar/thunar-text-renderer.c index ace217c..3a9d43b 100644 --- a/thunar/thunar-text-renderer.c +++ b/thunar/thunar-text-renderer.c @@ -23,11 +23,6 @@ #include "thunar/thunar-text-renderer.h" #include "thunar/thunar-util.h" -#include - -#define USAGE_BAR_HEIGHT 4 -#define USAGE_BAR_TOP_PAD 2 -#define USAGE_BAR_RADIUS 2 @@ -37,7 +32,6 @@ enum PROP_HIGHLIGHT_COLOR, PROP_ROUNDED_CORNERS, PROP_HIGHLIGHTING_ENABLED, - PROP_USAGE_PERCENT, }; @@ -61,11 +55,6 @@ thunar_text_renderer_render (GtkCellRenderer *renderer, const GdkRectangle *background_area, const GdkRectangle *cell_area, GtkCellRendererState flags); -static void -thunar_text_renderer_get_preferred_height (GtkCellRenderer *cell, - GtkWidget *widget, - gint *minimum, - gint *natural); @@ -88,7 +77,6 @@ struct _ThunarTextRenderer gchar *highlight_color; gboolean rounded_corners; gboolean highlighting_enabled; - gint usage_percent; /* -1 = no bar, 0..100 = percent used */ }; @@ -110,7 +98,6 @@ thunar_text_renderer_class_init (ThunarTextRendererClass *klass) klass->default_render_function = cell_class->render; cell_class->render = thunar_text_renderer_render; - cell_class->get_preferred_height = thunar_text_renderer_get_preferred_height; /** * ThunarTextRenderer:highlight-color: @@ -149,13 +136,6 @@ thunar_text_renderer_class_init (ThunarTextRendererClass *klass) g_param_spec_boolean ("highlighting-enabled", "highlighting-enabled", "highlighting-enabled", FALSE, EXO_PARAM_READWRITE)); - - g_object_class_install_property (object_class, - PROP_USAGE_PERCENT, - g_param_spec_int ("usage-percent", "usage-percent", - "Disk usage percentage (0-100, -1 = hidden)", - -1, 100, -1, - G_PARAM_READWRITE)); } @@ -164,7 +144,6 @@ static void thunar_text_renderer_init (ThunarTextRenderer *text_renderer) { text_renderer->highlight_color = NULL; - text_renderer->usage_percent = -1; } @@ -203,10 +182,6 @@ thunar_text_renderer_get_property (GObject *object, g_value_set_boolean (value, text_renderer->highlighting_enabled); break; - case PROP_USAGE_PERCENT: - g_value_set_int (value, text_renderer->usage_percent); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -238,10 +213,6 @@ thunar_text_renderer_set_property (GObject *object, text_renderer->highlighting_enabled = g_value_get_boolean (value); break; - case PROP_USAGE_PERCENT: - text_renderer->usage_percent = g_value_get_int (value); - break; - default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -268,91 +239,6 @@ thunar_text_renderer_new (void) -static void -thunar_text_renderer_get_preferred_height (GtkCellRenderer *cell, - GtkWidget *widget, - gint *minimum, - gint *natural) -{ - gint min_h = 0, nat_h = 0; - - GTK_CELL_RENDERER_CLASS (thunar_text_renderer_parent_class)->get_preferred_height (cell, widget, &min_h, &nat_h); - - if (minimum != NULL) *minimum = min_h; - if (natural != NULL) *natural = nat_h; -} - - - -static void -thunar_text_renderer_draw_usage_bar (cairo_t *cr, - GtkWidget *widget, - const GdkRectangle *cell_area, - gint usage_percent) -{ - GtkStyleContext *context; - GdkRGBA bar_bg = { 0.5, 0.5, 0.5, 0.3 }; - GdkRGBA bar_fg; - gint xpad = 2; - gdouble x = cell_area->x + xpad; - gdouble y = cell_area->y + cell_area->height - USAGE_BAR_HEIGHT; - gdouble w = cell_area->width - 2 * xpad; - gdouble h = USAGE_BAR_HEIGHT; - gdouble r = USAGE_BAR_RADIUS; - gdouble fw; - - if (w <= 0) - return; - - context = gtk_widget_get_style_context (widget); - - if (usage_percent > 90) - { - bar_fg.red = 0.85; bar_fg.green = 0.2; bar_fg.blue = 0.2; bar_fg.alpha = 0.9; - } - else - { - if (!gtk_style_context_lookup_color (context, "theme_selected_bg_color", &bar_fg) - || bar_fg.alpha < 0.01) - { bar_fg.red = 0.3; bar_fg.green = 0.5; bar_fg.blue = 0.8; } - bar_fg.alpha = 0.9; - } - - cairo_save (cr); - - /* background track */ - cairo_new_sub_path (cr); - cairo_arc (cr, x + w - r, y + r, r, -G_PI_2, 0); - cairo_arc (cr, x + w - r, y + h - r, r, 0, G_PI_2); - cairo_arc (cr, x + r, y + h - r, r, G_PI_2, G_PI); - cairo_arc (cr, x + r, y + r, r, G_PI, 3 * G_PI_2); - cairo_close_path (cr); - gdk_cairo_set_source_rgba (cr, &bar_bg); - cairo_fill (cr); - - /* filled portion */ - if (usage_percent > 0) - { - fw = w * usage_percent / 100.0; - r = USAGE_BAR_RADIUS; - if (fw < 2 * r) r = fw / 2.0; - if (r < 0.5) r = 0; - - cairo_new_sub_path (cr); - cairo_arc (cr, x + fw - r, y + r, r, -G_PI_2, 0); - cairo_arc (cr, x + fw - r, y + h - r, r, 0, G_PI_2); - cairo_arc (cr, x + r, y + h - r, r, G_PI_2, G_PI); - cairo_arc (cr, x + r, y + r, r, G_PI, 3 * G_PI_2); - cairo_close_path (cr); - gdk_cairo_set_source_rgba (cr, &bar_fg); - cairo_fill (cr); - } - - cairo_restore (cr); -} - - - static void thunar_text_renderer_render (GtkCellRenderer *cell, cairo_t *cr, @@ -361,16 +247,11 @@ thunar_text_renderer_render (GtkCellRenderer *cell, const GdkRectangle *cell_area, GtkCellRendererState flags) { - ThunarTextRenderer *text_renderer = THUNAR_TEXT_RENDERER (cell); - - if (text_renderer->highlighting_enabled) + if (THUNAR_TEXT_RENDERER (cell)->highlighting_enabled) thunar_util_clip_view_background (cell, cr, background_area, widget, flags); - /* draw text normally */ - THUNAR_TEXT_RENDERER_GET_CLASS (text_renderer) + /* we only needed to manipulate the background_area, otherwise everything remains the same. + Hence, we are simply running the original render function now */ + THUNAR_TEXT_RENDERER_GET_CLASS (THUNAR_TEXT_RENDERER (cell)) ->default_render_function (cell, cr, widget, background_area, cell_area, flags); - - /* draw usage bar at the very bottom of the cell, overlapping if needed */ - if (text_renderer->usage_percent >= 0) - thunar_text_renderer_draw_usage_bar (cr, widget, cell_area, text_renderer->usage_percent); }