[pitivi/aleb.sdk: 1/2] Add icons which are not distributed anymore




commit ac64d971fd47f01acedc7076416da74115348aab
Author: Alexandru Băluț <alexandru balut gmail com>
Date:   Wed Apr 6 23:11:29 2022 +0200

    Add icons which are not distributed anymore
    
    Icons originate from
    
https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/57a412280b110f76771dceeb9f423947740b796c/Adwaita/scalable/status
    
    Fixes #2600

 .../scalable/status/dialog-error-symbolic.svg      |  4 ++
 .../status/dialog-information-symbolic.svg         |  7 ++
 .../scalable/status/dialog-question-symbolic.svg   |  4 ++
 .../scalable/status/dialog-warning-symbolic.svg    |  4 ++
 pitivi/dialogs/prefs.py                            |  2 +-
 pitivi/mainwindow.py                               |  1 +
 pitivi/medialibrary.py                             |  4 +-
 pitivi/project.py                                  |  4 +-
 pitivi/render.py                                   |  2 +-
 pitivi/transitions.py                              | 84 ++++++++++------------
 pitivi/utils/widgets.py                            |  4 +-
 11 files changed, 65 insertions(+), 55 deletions(-)
---
diff --git a/data/icons/hicolor/scalable/status/dialog-error-symbolic.svg 
b/data/icons/hicolor/scalable/status/dialog-error-symbolic.svg
new file mode 100644
index 000000000..e590c5277
--- /dev/null
+++ b/data/icons/hicolor/scalable/status/dialog-error-symbolic.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg";>
+    <path d="m 8 1 c -3.871094 0 -7 3.128906 -7 7 s 3.128906 7 7 7 s 7 -3.128906 7 -7 s -3.128906 -7 -7 -7 z 
m -4 6 h 8 v 2 h -8 z m 0 0" fill="#2e3436"/>
+</svg>
\ No newline at end of file
diff --git a/data/icons/hicolor/scalable/status/dialog-information-symbolic.svg 
b/data/icons/hicolor/scalable/status/dialog-information-symbolic.svg
new file mode 100644
index 000000000..070bb6b60
--- /dev/null
+++ b/data/icons/hicolor/scalable/status/dialog-information-symbolic.svg
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg";>
+    <g fill="#2e3436">
+        <path d="m 7.996094 0 c -2.835938 0 -5.292969 2 -5.871094 4.777344 c -0.527344 2.535156 0.6875 
5.035156 2.875 6.328125 v 0.894531 c 0 0.554688 0.449219 1 1 1 h 4 c 0.550781 0 1 -0.445312 1 -1 l 0.003906 
-0.898438 c 2.179688 -1.292968 3.398438 -3.796874 2.867188 -6.332031 c -0.582032 -2.773437 -3.039063 
-4.769531 -5.875 -4.769531 z m 0 2 c 1.898437 0 3.527344 1.320312 3.917968 3.179688 c 0.390626 1.863281 
-0.570312 3.726562 -2.3125 4.488281 c -0.363281 0.15625 -0.597656 0.515625 -0.601562 0.914062 v 0.417969 h -2 
v -0.417969 c -0.003906 -0.398437 -0.238281 -0.753906 -0.601562 -0.914062 c -1.742188 -0.761719 -2.703126 
-2.625 -2.316407 -4.484375 s 2.015625 -3.183594 3.914063 -3.183594 z m -1.996094 12 v 1 c 0 0.554688 0.445312 
1 1 1 h 2 c 0.554688 0 1 -0.445312 1 -1 v -1 z m 0 0"/>
+        <path d="m 6.644531 6.144531 c -0.195312 0.195313 -0.195312 0.515625 0 0.707031 l 1 1 c 0.195313 
0.195313 0.511719 0.195313 0.707031 0 l 1 -1 c 0.195313 -0.191406 0.195313 -0.511718 0 -0.707031 c -0.195312 
-0.191406 -0.511718 -0.191406 -0.707031 0 l -0.648437 0.648438 l -0.644532 -0.648438 c -0.195312 -0.191406 
-0.511718 -0.191406 -0.707031 0 z m 0 0" fill-opacity="0.34902"/>
+    </g>
+</svg>
\ No newline at end of file
diff --git a/data/icons/hicolor/scalable/status/dialog-question-symbolic.svg 
b/data/icons/hicolor/scalable/status/dialog-question-symbolic.svg
new file mode 100644
index 000000000..de2bb6a30
--- /dev/null
+++ b/data/icons/hicolor/scalable/status/dialog-question-symbolic.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg";>
+    <path d="m 8 0.03125 c -0.398438 0 -0.816406 0.160156 -1.125 0.46875 l -6.375 6.375 c -0.621094 0.621094 
-0.621094 1.628906 0 2.25 l 6.375 6.375 c 0.621094 0.621094 1.628906 0.621094 2.25 0 l 6.375 -6.375 c 
0.621094 -0.621094 0.621094 -1.628906 0 -2.25 l -6.375 -6.375 c -0.308594 -0.308594 -0.726562 -0.46875 -1.125 
-0.46875 z m 0.152344 2.976562 c 0.726562 0.035157 1.433594 0.335938 1.96875 0.871094 c 0.855468 0.855469 
1.113281 2.152344 0.652344 3.269532 c -0.332032 0.796874 -0.988282 1.390624 -1.773438 1.671874 v 1.179688 h 
-2 v -2 c 0 -0.550781 0.449219 -1 1 -1 c 0.40625 0 0.769531 -0.242188 0.925781 -0.617188 c 0.152344 -0.375 
0.070313 -0.800781 -0.21875 -1.089843 c -0.289062 -0.289063 -0.714843 -0.371094 -1.089843 -0.21875 c -0.375 
0.15625 -0.617188 0.519531 -0.617188 0.925781 h -2 c 0 -1.210938 0.734375 -2.308594 1.851562 -2.769531 c 
0.417969 -0.175781 0.863282 -0.246094 1.300782 -0.222657 z m -0.152344 7.992188 c 0.550781 0 1 0.449219 1 1 s 
-0.449219 1 -1 1 s -1 -0.449219 
 -1 -1 s 0.449219 -1 1 -1 z m 0 0" fill="#2e3436"/>
+</svg>
\ No newline at end of file
diff --git a/data/icons/hicolor/scalable/status/dialog-warning-symbolic.svg 
b/data/icons/hicolor/scalable/status/dialog-warning-symbolic.svg
new file mode 100644
index 000000000..22ff60398
--- /dev/null
+++ b/data/icons/hicolor/scalable/status/dialog-warning-symbolic.svg
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg height="16px" viewBox="0 0 16 16" width="16px" xmlns="http://www.w3.org/2000/svg";>
+    <path d="m 7.90625 0.09375 c -0.527344 -0.0273438 -1.039062 0.28125 -1.4375 0.96875 l -6.25 11.59375 c 
-0.535156 0.964844 0.046875 2.34375 1.09375 2.34375 h 13.15625 c 0.980469 0 1.902344 -1.160156 1.21875 
-2.34375 l -6.3125 -11.53125 c -0.398438 -0.644531 -0.941406 -1.003906 -1.46875 -1.03125 z m 1.09375 3.90625 
v 5 c 0.007812 0.527344 -0.472656 1 -1 1 s -1.007812 -0.472656 -1 -1 v -5 z m -1 7 c 0.550781 0 1 0.449219 1 
1 s -0.449219 1 -1 1 s -1 -0.449219 -1 -1 s 0.449219 -1 1 -1 z m 0 0" fill="#2e3436"/>
+</svg>
\ No newline at end of file
diff --git a/pitivi/dialogs/prefs.py b/pitivi/dialogs/prefs.py
index defb42f41..de7217656 100644
--- a/pitivi/dialogs/prefs.py
+++ b/pitivi/dialogs/prefs.py
@@ -872,7 +872,7 @@ class PluginsBox(Gtk.ListBox):
         button = Gtk.Button.new()
         button.props.valign = Gtk.Align.CENTER
         button.props.relief = Gtk.ReliefStyle.NONE
-        button.add(Gtk.Image.new_from_icon_name("folder-open-symbolic", 1))
+        button.add(Gtk.Image.new_from_icon_name("folder-open-symbolic", Gtk.IconSize.MENU))
         button.connect("clicked", self.__location_clicked_cb, group.get_dir())
 
         inner_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
diff --git a/pitivi/mainwindow.py b/pitivi/mainwindow.py
index a18ca504c..f102e9bb6 100644
--- a/pitivi/mainwindow.py
+++ b/pitivi/mainwindow.py
@@ -92,6 +92,7 @@ class MainWindow(Gtk.ApplicationWindow, Loggable):
         os.environ["PULSE_PROP_application.icon_name"] = "pitivi"
 
         Gtk.IconTheme.get_default().append_search_path(get_pixmap_dir())
+        Gtk.IconTheme.get_default().append_search_path(os.path.join(get_pixmap_dir(), "transitions"))
 
         Gtk.ApplicationWindow.__init__(self)
         Loggable.__init__(self)
diff --git a/pitivi/medialibrary.py b/pitivi/medialibrary.py
index 5aac791a0..cc7a44e97 100644
--- a/pitivi/medialibrary.py
+++ b/pitivi/medialibrary.py
@@ -431,7 +431,9 @@ class AssetThumbnail(GObject.Object, Loggable):
         try:
             icon = icon_theme.load_icon(icon_name, size, Gtk.IconLookupFlags.FORCE_SIZE)
         except GLib.Error:
-            icon = icon_theme.load_icon("dialog-question", size, 0)
+            # The resulting black question mark is good for light themes but
+            # not the best for the dark ones.
+            icon = icon_theme.load_icon("dialog-question-symbolic", size, 0)
         return icon
 
     def _set_state(self):
diff --git a/pitivi/project.py b/pitivi/project.py
index 334addfac..bf65dd02f 100644
--- a/pitivi/project.py
+++ b/pitivi/project.py
@@ -214,7 +214,7 @@ class ProjectManager(GObject.Object, Loggable):
         vbox.pack_start(primary, True, True, 0)
 
         # make the [[image] text] hbox
-        image = Gtk.Image.new_from_icon_name("dialog-error", Gtk.IconSize.DIALOG)
+        image = Gtk.Image.new_from_icon_name("dialog-error-symbolic", Gtk.IconSize.DIALOG)
         hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=SPACING * 2)
         hbox.pack_start(image, False, True, 0)
         hbox.pack_start(vbox, True, True, 0)
@@ -310,7 +310,7 @@ class ProjectManager(GObject.Object, Loggable):
 
         # make the [[image] text] hbox
         image = Gtk.Image.new_from_icon_name(
-            "dialog-question", Gtk.IconSize.DIALOG)
+            "dialog-question-symbolic", Gtk.IconSize.DIALOG)
         hbox = Gtk.Box(homogeneous=False, spacing=SPACING * 2)
         hbox.set_orientation(Gtk.Orientation.HORIZONTAL)
         hbox.pack_start(image, False, False, 0)
diff --git a/pitivi/render.py b/pitivi/render.py
index 81931e8db..c9052ebaf 100644
--- a/pitivi/render.py
+++ b/pitivi/render.py
@@ -1143,7 +1143,7 @@ class RenderDialog(Loggable):
                 tooltip_text = None
                 self._is_filename_valid = True
 
-        warning_icon = "dialog-warning" if tooltip_text else None
+        warning_icon = "dialog-warning-symbolic" if tooltip_text else None
         self.fileentry.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, warning_icon)
         self.fileentry.set_icon_tooltip_text(Gtk.EntryIconPosition.SECONDARY, tooltip_text)
         self.__update_render_button_sensitivity()
diff --git a/pitivi/transitions.py b/pitivi/transitions.py
index 1df39afaa..a7510fdff 100644
--- a/pitivi/transitions.py
+++ b/pitivi/transitions.py
@@ -16,6 +16,7 @@
 # License along with this program; if not, see <http://www.gnu.org/licenses/>.
 import os
 from gettext import gettext as _
+from typing import Optional
 
 from gi.repository import GdkPixbuf
 from gi.repository import GES
@@ -31,9 +32,9 @@ from pitivi.utils.ui import SPACING
 
 
 (COL_TRANSITION_ASSET,
- COL_NAME_TEXT,
- COL_DESC_TEXT,
- COL_ICON) = list(range(4))
+ COL_NAME,
+ COL_ICON_NAME,
+ COL_DESCRIPTION) = list(range(4))
 
 BORDER_LOOP_THRESHOLD = 50000
 
@@ -53,16 +54,10 @@ class TransitionsListWidget(Gtk.Box, Loggable):
         self.app = app
         self.element = None
         self._pixdir = os.path.join(get_pixmap_dir(), "transitions")
-        icon_theme = Gtk.IconTheme.get_default()
-        self._question_icon = icon_theme.load_icon("dialog-question", 48, 0)
         self.set_orientation(Gtk.Orientation.VERTICAL)
         # Whether a child widget has the focus.
         self.container_focused = False
 
-        # Tooltip handling
-        self._current_transition_name = None
-        self._current_tooltip_icon = None
-
         # Searchbox
         self.searchbar = Gtk.Box()
         self.searchbar.set_orientation(Gtk.Orientation.HORIZONTAL)
@@ -109,19 +104,24 @@ class TransitionsListWidget(Gtk.Box, Loggable):
               "the transition type."))
         self.infobar.get_content_area().add(txtlabel)
 
-        self.storemodel = Gtk.ListStore(GES.Asset, str, str, GdkPixbuf.Pixbuf)
+        self.storemodel = Gtk.ListStore(GES.Asset, str, str, str)
+        # Create the filterModel for searching
+        self.model_filter = self.storemodel.filter_new()
 
         self.iconview_scrollwin = Gtk.ScrolledWindow()
         self.iconview_scrollwin.set_shadow_type(Gtk.ShadowType.ETCHED_IN)
 
-        self.iconview = Gtk.IconView(model=self.storemodel)
-        self.iconview.set_pixbuf_column(COL_ICON)
-        # We don't show text because we have a searchbar and the names are ugly
-        # self.iconview.set_text_column(COL_NAME_TEXT)
-        self.iconview.set_item_width(48 + 10)
-        self.iconview_scrollwin.add(self.iconview)
+        self.iconview = Gtk.IconView(model=self.model_filter)
+        cell_renderer = Gtk.CellRendererPixbuf()
+        cell_renderer.props.stock_size = Gtk.IconSize.DIALOG
+        self.iconview.pack_start(cell_renderer, expand=False)
+        self.iconview.add_attribute(cell_renderer, "icon-name", COL_ICON_NAME)
+
+        self.iconview.set_item_width(48 + SPACING)
         self.iconview.set_property("has_tooltip", True)
 
+        self.iconview_scrollwin.add(self.iconview)
+
         self.search_entry.connect("changed", self._search_entry_changed_cb)
         self.search_entry.connect("icon-press", self._search_entry_icon_press_cb)
         self.iconview.connect("query-tooltip", self._iconview_query_tooltip_cb)
@@ -134,10 +134,6 @@ class TransitionsListWidget(Gtk.Box, Loggable):
         self.pack_start(self.iconview_scrollwin, True, True, 0)
         self.pack_start(self.props_widgets, False, False, 0)
 
-        # Create the filterModel for searching
-        self.model_filter = self.storemodel.filter_new()
-        self.iconview.set_model(self.model_filter)
-
         self.infobar.show_all()
         self.iconview_scrollwin.show_all()
         self.iconview.hide()
@@ -249,18 +245,15 @@ class TransitionsListWidget(Gtk.Box, Loggable):
     def _load_available_transitions_cb(self):
         """Loads the transitions types and icons into the storemodel."""
         for trans_asset in GES.list_assets(GES.TransitionClip):
-            trans_asset.icon = self._get_icon(trans_asset.get_id())
-            self.storemodel.append([trans_asset,
-                                    str(trans_asset.get_id()),
-                                    str(trans_asset.get_meta(
-                                        GES.META_DESCRIPTION)),
-                                    trans_asset.icon])
+            name = trans_asset.get_id()
+            icon_name = name if self._get_icon(name) else "dialog-question-symbolic"
+            description = trans_asset.get_meta(GES.META_DESCRIPTION)
+            self.storemodel.append([trans_asset, name, icon_name, description])
 
         # Now that the UI is fully ready, enable searching
         self.model_filter.set_visible_func(self._set_row_visible_func, data=None)
         # Alphabetical/name sorting instead of based on the ID number
-        self.storemodel.set_sort_column_id(
-            COL_NAME_TEXT, Gtk.SortType.ASCENDING)
+        self.storemodel.set_sort_column_id(COL_NAME, Gtk.SortType.ASCENDING)
 
     def activate(self, element):
         """Hides the infobar and shows the transitions UI."""
@@ -311,15 +304,13 @@ class TransitionsListWidget(Gtk.Box, Loggable):
         self.searchbar.hide()
         self.infobar.show()
 
-    def _get_icon(self, transition_nick):
+    def _get_icon(self, transition_nick: str) -> Optional[GdkPixbuf.Pixbuf]:
         """Gets an icon pixbuf for the specified transition nickname."""
-        name = transition_nick + ".png"
         try:
-            icon = GdkPixbuf.Pixbuf.new_from_file(
-                os.path.join(self._pixdir, name))
+            return GdkPixbuf.Pixbuf.new_from_file(
+                os.path.join(self._pixdir, transition_nick + ".png"))
         except GLib.Error:
-            icon = self._question_icon
-        return icon
+            return None
 
     def _iconview_query_tooltip_cb(self, view, x, y, keyboard_mode, tooltip):
         is_row, x, y, model, path, iter_ = view.get_tooltip_context(
@@ -329,27 +320,24 @@ class TransitionsListWidget(Gtk.Box, Loggable):
 
         view.set_tooltip_item(tooltip, path)
 
-        name = model.get_value(iter_, COL_TRANSITION_ASSET).get_id()
-        if self._current_transition_name != name:
-            self._current_transition_name = name
-            icon = model.get_value(iter_, COL_ICON)
-            self._current_tooltip_icon = icon
-
-        longname = model.get_value(iter_, COL_NAME_TEXT).strip()
-        description = model.get_value(iter_, COL_DESC_TEXT)
-        txt = "<b>%s:</b>\n%s" % (GLib.markup_escape_text(longname),
-                                  GLib.markup_escape_text(description),)
-        tooltip.set_markup(txt)
+        icon_name = model.get_value(iter_, COL_ICON_NAME)
+        tooltip.set_icon_from_icon_name(icon_name, Gtk.IconSize.DIALOG)
+
+        longname = model.get_value(iter_, COL_NAME)
+        description = model.get_value(iter_, COL_DESCRIPTION)
+        markup = "<b>{}:</b>\n{}".format(GLib.markup_escape_text(longname),
+                                         GLib.markup_escape_text(description))
+        tooltip.set_markup(markup)
         return True
 
     def get_selected_item(self):
         path = self.iconview.get_selected_items()
-        if path == []:
+        if not path:
             return None
         return self.model_filter[path[0]][COL_TRANSITION_ASSET]
 
     def _set_row_visible_func(self, model, model_iter, data):
         """Filters the icon view to show only the search results."""
         text = self.search_entry.get_text().lower()
-        return text in model.get_value(model_iter, COL_DESC_TEXT).lower() or\
-            text in model.get_value(model_iter, COL_NAME_TEXT).lower()
+        return text in model.get_value(model_iter, COL_DESCRIPTION).lower() or \
+            text in model.get_value(model_iter, COL_NAME).lower()
diff --git a/pitivi/utils/widgets.py b/pitivi/utils/widgets.py
index a1a279511..6c02e294b 100644
--- a/pitivi/utils/widgets.py
+++ b/pitivi/utils/widgets.py
@@ -177,7 +177,7 @@ class TextWidget(Gtk.Box, DynamicWidget):
                 self.valid = True
             else:
                 if self.valid:
-                    self.text.set_icon_from_icon_name(1, "dialog-warning")
+                    self.text.set_icon_from_icon_name(Gtk.EntryIconPosition.SECONDARY, 
"dialog-warning-symbolic")
                 self.valid = False
         elif self.send_signal:
             self.emit("value-changed")
@@ -594,7 +594,7 @@ class InputValidationWidget(Gtk.Box, DynamicWidget):
         DynamicWidget.__init__(self, widget.default)
         self._widget = widget
         self._validation_function = validation_function
-        self._warning_sign = Gtk.Image.new_from_icon_name("dialog-warning", 3)
+        self._warning_sign = Gtk.Image.new_from_icon_name("dialog-warning-symbolic", 
Gtk.IconSize.LARGE_TOOLBAR)
 
         self.set_orientation(Gtk.Orientation.HORIZONTAL)
         self.pack_start(self._widget, expand=False, fill=False, padding=0)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]