|
|
edd3054 |
From 15ff08fd2e1fa8f16f63768c61252518f77a60d4 Mon Sep 17 00:00:00 2001
|
|
|
edd3054 |
From: Fabio Valentini <decathorpe@gmail.com>
|
|
|
edd3054 |
Date: Wed, 4 Mar 2020 00:21:24 +0100
|
|
|
edd3054 |
Subject: [PATCH 4/4] drop ugly TitledSeparatorMenuItem
|
|
|
edd3054 |
|
|
|
edd3054 |
---
|
|
|
edd3054 |
docklets/Trash/TrashDockItem.vala | 5 +-
|
|
|
edd3054 |
lib/Widgets/DockWindow.vala | 6 +-
|
|
|
edd3054 |
lib/Widgets/TitledSeparatorMenuItem.vala | 109 -----------------------
|
|
|
edd3054 |
3 files changed, 3 insertions(+), 117 deletions(-)
|
|
|
edd3054 |
delete mode 100644 lib/Widgets/TitledSeparatorMenuItem.vala
|
|
|
edd3054 |
|
|
|
edd3054 |
diff --git a/docklets/Trash/TrashDockItem.vala b/docklets/Trash/TrashDockItem.vala
|
|
|
edd3054 |
index 40507d4..2c21527 100644
|
|
|
edd3054 |
--- a/docklets/Trash/TrashDockItem.vala
|
|
|
edd3054 |
+++ b/docklets/Trash/TrashDockItem.vala
|
|
|
edd3054 |
@@ -176,10 +176,7 @@ namespace Docky
|
|
|
edd3054 |
|
|
|
edd3054 |
enumerator.close (null);
|
|
|
edd3054 |
}
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- if (files.size > 0)
|
|
|
edd3054 |
- items.add (new TitledSeparatorMenuItem.no_line (_("Restore Files")));
|
|
|
edd3054 |
-
|
|
|
edd3054 |
+
|
|
|
edd3054 |
files.sort ((CompareDataFunc) compare_files);
|
|
|
edd3054 |
|
|
|
edd3054 |
var count = 0;
|
|
|
edd3054 |
diff --git a/lib/Widgets/DockWindow.vala b/lib/Widgets/DockWindow.vala
|
|
|
edd3054 |
index f0a1dcf..47090cc 100644
|
|
|
edd3054 |
--- a/lib/Widgets/DockWindow.vala
|
|
|
edd3054 |
+++ b/lib/Widgets/DockWindow.vala
|
|
|
edd3054 |
@@ -656,8 +656,7 @@ namespace Plank
|
|
|
edd3054 |
var debug_items = new Gee.ArrayList<Gtk.MenuItem> ();
|
|
|
edd3054 |
|
|
|
edd3054 |
debug_items.add (new Gtk.SeparatorMenuItem ());
|
|
|
edd3054 |
- debug_items.add (new TitledSeparatorMenuItem.no_line ("debug this dock"));
|
|
|
edd3054 |
-
|
|
|
edd3054 |
+
|
|
|
edd3054 |
Gtk.MenuItem menu_item;
|
|
|
edd3054 |
|
|
|
edd3054 |
menu_item = new Gtk.MenuItem.with_mnemonic ("Open config folder");
|
|
|
edd3054 |
@@ -680,8 +679,7 @@ namespace Plank
|
|
|
edd3054 |
var debug_items = new Gee.ArrayList<Gtk.MenuItem> ();
|
|
|
edd3054 |
|
|
|
edd3054 |
debug_items.add (new Gtk.SeparatorMenuItem ());
|
|
|
edd3054 |
- debug_items.add (new TitledSeparatorMenuItem.no_line ("debug this item"));
|
|
|
edd3054 |
-
|
|
|
edd3054 |
+
|
|
|
edd3054 |
Gtk.MenuItem menu_item;
|
|
|
edd3054 |
|
|
|
edd3054 |
var dock_item_file = item.Prefs.get_backing_file ();
|
|
|
edd3054 |
diff --git a/lib/Widgets/TitledSeparatorMenuItem.vala b/lib/Widgets/TitledSeparatorMenuItem.vala
|
|
|
edd3054 |
deleted file mode 100644
|
|
|
edd3054 |
index dc5b039..0000000
|
|
|
edd3054 |
--- a/lib/Widgets/TitledSeparatorMenuItem.vala
|
|
|
edd3054 |
+++ /dev/null
|
|
|
edd3054 |
@@ -1,109 +0,0 @@
|
|
|
edd3054 |
-//
|
|
|
edd3054 |
-// Copyright (C) 2010 Michal Hruby <michal.mhr@gmail.com>
|
|
|
edd3054 |
-// Copyright (C) 2011-2012 Robert Dyer, Rico Tzschichholz
|
|
|
edd3054 |
-// Copyright (C) 2013 Rico Tzschichholz
|
|
|
edd3054 |
-//
|
|
|
edd3054 |
-// This library is free software; you can redistribute it and/or
|
|
|
edd3054 |
-// modify it under the terms of the GNU Lesser General Public
|
|
|
edd3054 |
-// License as published by the Free Software Foundation; either
|
|
|
edd3054 |
-// version 2.1 of the License, or (at your option) any later version.
|
|
|
edd3054 |
-//
|
|
|
edd3054 |
-// This library is distributed in the hope that it will be useful,
|
|
|
edd3054 |
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
edd3054 |
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
edd3054 |
-// Lesser General Public License for more details.
|
|
|
edd3054 |
-//
|
|
|
edd3054 |
-// You should have received a copy of the GNU Lesser General Public License
|
|
|
edd3054 |
-// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
edd3054 |
-//
|
|
|
edd3054 |
-// Authored by Michal Hruby <michal.mhr@gmail.com>
|
|
|
edd3054 |
-// Modified by Robert Dyer, Rico Tzschichholz
|
|
|
edd3054 |
-//
|
|
|
edd3054 |
-
|
|
|
edd3054 |
-namespace Plank
|
|
|
edd3054 |
-{
|
|
|
edd3054 |
- /**
|
|
|
edd3054 |
- * A {@link Gtk.SeparatorMenuItem} with a title on it.
|
|
|
edd3054 |
- * The separator can be drawn with or without a line.
|
|
|
edd3054 |
- */
|
|
|
edd3054 |
- public class TitledSeparatorMenuItem : Gtk.SeparatorMenuItem
|
|
|
edd3054 |
- {
|
|
|
edd3054 |
- static construct
|
|
|
edd3054 |
- {
|
|
|
edd3054 |
- set_accessible_role (Atk.Role.SEPARATOR);
|
|
|
edd3054 |
- PlankCompat.gtk_widget_class_set_css_name ((GLib.ObjectClass) typeof (TitledSeparatorMenuItem).class_ref (), "menuitem");
|
|
|
edd3054 |
- }
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- bool draw_line = true;
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- string text;
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- public TitledSeparatorMenuItem (string text)
|
|
|
edd3054 |
- {
|
|
|
edd3054 |
- this.text = text;
|
|
|
edd3054 |
- }
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- public TitledSeparatorMenuItem.no_line (string text)
|
|
|
edd3054 |
- {
|
|
|
edd3054 |
- this (text);
|
|
|
edd3054 |
- draw_line = false;
|
|
|
edd3054 |
- }
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- protected override bool draw (Cairo.Context cr)
|
|
|
edd3054 |
- {
|
|
|
edd3054 |
- unowned Gtk.StyleContext context = get_style_context ();
|
|
|
edd3054 |
- var state = context.get_state ();
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- int x, y, w, h;
|
|
|
edd3054 |
- int border_width = (int) get_border_width ();
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- x = border_width;
|
|
|
edd3054 |
- y = border_width;
|
|
|
edd3054 |
- w = get_allocated_width () - 2 * border_width;
|
|
|
edd3054 |
- h = get_allocated_height () - 2 * border_width;
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- var padding = context.get_padding (state);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- context.render_background (cr, x, y, w, h);
|
|
|
edd3054 |
- context.render_frame (cr, x, y, w, h);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- if (draw_line) {
|
|
|
edd3054 |
- bool wide_separators;
|
|
|
edd3054 |
- int separator_height;
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- style_get ("wide-separators", out wide_separators,
|
|
|
edd3054 |
- "separator-height", out separator_height);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- if (wide_separators)
|
|
|
edd3054 |
- context.render_frame (cr, x + padding.left, y + padding.top,
|
|
|
edd3054 |
- w - padding.left - padding.right, separator_height);
|
|
|
edd3054 |
- else
|
|
|
edd3054 |
- context.render_line (cr, x + padding.left, y + padding.top,
|
|
|
edd3054 |
- x + w - padding.right - 1, y + padding.top);
|
|
|
edd3054 |
- }
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- unowned Pango.FontDescription font_desc = style.font_desc;
|
|
|
edd3054 |
- font_desc.set_absolute_size ((int) (h * Pango.SCALE * Pango.Scale.LARGE));
|
|
|
edd3054 |
- font_desc.set_weight (Pango.Weight.BOLD);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- var layout = new Pango.Layout (Gdk.pango_context_get ());
|
|
|
edd3054 |
- layout.set_font_description (font_desc);
|
|
|
edd3054 |
- layout.set_width ((int) ((w - padding.left - padding.right) * Pango.SCALE));
|
|
|
edd3054 |
- layout.set_text (text, -1);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- Pango.Rectangle logical_rect;
|
|
|
edd3054 |
- layout.get_pixel_extents (null, out logical_rect);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- context.render_background (cr, 0, y, x + logical_rect.width + padding.left + padding.right, h);
|
|
|
edd3054 |
- context.render_frame (cr, 0, y, x + logical_rect.width + padding.left + padding.right, h);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- var color = context.get_color (state);
|
|
|
edd3054 |
- cr.set_source_rgba (color.red, color.green, color.blue, color.alpha);
|
|
|
edd3054 |
- cr.move_to (x + padding.left, y + (h - logical_rect.height) / 2);
|
|
|
edd3054 |
- Pango.cairo_show_layout (cr, layout);
|
|
|
edd3054 |
-
|
|
|
edd3054 |
- return Gdk.EVENT_STOP;
|
|
|
edd3054 |
- }
|
|
|
edd3054 |
- }
|
|
|
edd3054 |
-}
|
|
|
edd3054 |
-
|
|
|
edd3054 |
--
|
|
|
edd3054 |
2.24.1
|
|
|
edd3054 |
|