SHA256
1
0
forked from pool/brisk-menu
Alexei Sorokin 2019-03-07 14:26:05 +00:00 committed by Git OBS Bridge
parent c9fdd670f8
commit e0cb1926ed
3 changed files with 207 additions and 11 deletions

View File

@ -0,0 +1,188 @@
--- a/meson.build
+++ b/meson.build
@@ -52,7 +52,7 @@ gnome = import('gnome')
# Required minimum versions
gtk_min_version = '>= 3.18.0'
-mate_min_version = '>= 1.16.0'
+mate_min_version = '>= 1.21.0'
glib_min_version = '>= 2.44.0'
# GTK/UI deps
--- a/src/backend/apps/apps-backend.c
+++ b/src/backend/apps/apps-backend.c
@@ -19,6 +19,8 @@ BRISK_BEGIN_PEDANTIC
#include "apps-section.h"
#include <gio/gio.h>
#include <glib/gi18n.h>
+
+#define MATEMENU_I_KNOW_THIS_IS_UNSTABLE
#include <matemenu-tree.h>
BRISK_END_PEDANTIC
@@ -72,9 +74,11 @@ static void brisk_apps_backend_launch_action(GSimpleAction *action, GVariant *pa
DEF_AUTOFREE(gchar, g_free)
DEF_AUTOFREE(GSList, g_slist_free)
DEF_AUTOFREE(MateMenuTreeDirectory, matemenu_tree_item_unref)
-DEF_AUTOFREE(MateMenuTreeItem, matemenu_tree_item_unref)
-DEF_AUTOFREE(MateMenuTree, matemenu_tree_unref)
+DEF_AUTOFREE(MateMenuTreeEntry, matemenu_tree_item_unref)
+DEF_AUTOFREE(MateMenuTreeIter, matemenu_tree_iter_unref)
+DEF_AUTOFREE(MateMenuTree, g_object_unref)
DEF_AUTOFREE(GDesktopAppInfo, g_object_unref)
+DEF_AUTOFREE(GError, g_error_free)
/**
* Due to a glib weirdness we must fully invalidate the monitor's cache
@@ -352,12 +356,18 @@ static gboolean brisk_apps_backend_build_from_tree(BriskAppsBackend *self, const
{
autofree(MateMenuTree) *tree = NULL;
autofree(MateMenuTreeDirectory) *dir = NULL;
+ autofree(GError) *error = NULL;
- tree = matemenu_tree_lookup(menu_id, MATEMENU_TREE_FLAGS_NONE);
+ tree = matemenu_tree_new(menu_id, MATEMENU_TREE_FLAGS_NONE);
if (!tree) {
return FALSE;
}
+ if (!matemenu_tree_load_sync(tree, &error)) {
+ g_message("Failed to load tree: %s", error->message);
+ return FALSE;
+ }
+
dir = matemenu_tree_get_root_directory(tree);
if (!dir) {
return FALSE;
@@ -392,37 +402,31 @@ static void brisk_apps_backend_recurse_root(BriskAppsBackend *self,
MateMenuTreeDirectory *directory,
MateMenuTreeDirectory *root)
{
- autofree(GSList) *kids = NULL;
- GSList *elem = NULL;
+ autofree(MateMenuTreeIter) *iter = NULL;
+ MateMenuTreeItemType type;
- kids = matemenu_tree_directory_get_contents(directory);
+ iter = matemenu_tree_directory_iter(directory);
/* Iterate the root tree */
- for (elem = kids; elem; elem = elem->next) {
- autofree(MateMenuTreeItem) *item = elem->data;
-
- switch (matemenu_tree_item_get_type(item)) {
+ while ((type = matemenu_tree_iter_next(iter)) != MATEMENU_TREE_ITEM_INVALID) {
+ switch (type) {
case MATEMENU_TREE_ITEM_DIRECTORY: {
- MateMenuTreeDirectory *dir = MATEMENU_TREE_DIRECTORY(item);
+ autofree(MateMenuTreeDirectory) *dir =
+ matemenu_tree_iter_get_directory(iter);
autofree(MateMenuTreeDirectory) *parent = NULL;
+ autofree(MateMenuTreeIter) *children = NULL;
BriskSection *section = NULL;
- GSList *children = NULL;
- guint n_children = 0;
- parent = matemenu_tree_item_get_parent(item);
+ parent = matemenu_tree_directory_get_parent(dir);
/* Nested menus basically only happen in mate-settings.menu */
if (parent != root) {
goto recurse_root;
}
- children = matemenu_tree_directory_get_contents(dir);
- if (children) {
- n_children = g_slist_length(children);
- g_slist_free_full(children, matemenu_tree_item_unref);
- }
+ children = matemenu_tree_directory_iter(dir);
/* Skip empty sections entirely */
- if (n_children < 1) {
+ if (matemenu_tree_iter_next(children) == MATEMENU_TREE_ITEM_INVALID) {
continue;
}
@@ -437,7 +441,7 @@ static void brisk_apps_backend_recurse_root(BriskAppsBackend *self,
brisk_apps_backend_recurse_root(self, dir, root);
} break;
case MATEMENU_TREE_ITEM_ENTRY: {
- MateMenuTreeEntry *entry = MATEMENU_TREE_ENTRY(item);
+ autofree(MateMenuTreeEntry) *entry = matemenu_tree_iter_get_entry(iter);
autofree(GDesktopAppInfo) *info = NULL;
const gchar *desktop_file = NULL;
BriskItem *app_item = NULL;
--- a/src/backend/apps/apps-section.c
+++ b/src/backend/apps/apps-section.c
@@ -54,48 +54,22 @@ static const GIcon *brisk_apps_section_get_icon(BriskSection *item);
static const gchar *brisk_apps_section_get_backend_id(BriskSection *item);
static gboolean brisk_apps_section_can_show_item(BriskSection *section, BriskItem *item);
-/**
- * Create a GIcon for the given path
- */
-static GIcon *brisk_apps_section_create_path_icon(const gchar *path)
-{
- autofree(GFile) *file = NULL;
-
- file = g_file_new_for_path(path);
- if (!file) {
- return NULL;
- }
- return g_file_icon_new(file);
-}
-
static void brisk_apps_section_update_directory(BriskAppsSection *self,
MateMenuTreeDirectory *directory)
{
g_clear_object(&self->icon);
g_clear_pointer(&self->id, g_free);
g_clear_pointer(&self->name, g_free);
- const gchar *icon = NULL;
if (!directory) {
return;
}
- /* Set our ID and name */
+ /* Set our ID, name, and icon */
self->id =
g_strdup_printf("%s.mate-directory", matemenu_tree_directory_get_menu_id(directory));
self->name = g_strdup(matemenu_tree_directory_get_name(directory));
-
- icon = matemenu_tree_directory_get_icon(directory);
- if (!icon) {
- return;
- }
-
- /* Set an appropriate icon based on the string */
- if (icon[0] == '/') {
- self->icon = brisk_apps_section_create_path_icon(icon);
- } else {
- self->icon = g_themed_icon_new_with_default_fallbacks(icon);
- }
+ self->icon = matemenu_tree_directory_get_icon(directory);
}
static void brisk_apps_section_set_property(GObject *object, guint id, const GValue *value,
--- a/src/backend/apps/apps-section.h
+++ b/src/backend/apps/apps-section.h
@@ -13,6 +13,8 @@
#include <gio/gio.h>
#include <glib-object.h>
+
+#define MATEMENU_I_KNOW_THIS_IS_UNSTABLE
#include <matemenu-tree.h>
#include "../section.h"
--- a/src/frontend/desktop-button.h
+++ b/src/frontend/desktop-button.h
@@ -13,7 +13,6 @@
#include <glib-object.h>
#include <gtk/gtk.h>
-#include <matemenu-tree.h>
#include "launcher.h"

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Fri Dec 14 12:54:01 UTC 2018 - sor.alexei@meowr.ru
- Add brisk-menu-mate-menus-1.22.patch:
https://github.com/solus-project/brisk-menu/pull/103
-------------------------------------------------------------------
Fri Nov 3 06:00:03 UTC 2017 - sor.alexei@meowr.ru

View File

@ -1,7 +1,7 @@
#
# spec file for package brisk-menu
#
# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@ -12,7 +12,7 @@
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
@ -20,21 +20,22 @@ Name: brisk-menu
Version: 0.5.0
Release: 0
Summary: Modern, efficient menu for MATE
License: GPL-2.0+ AND CC-BY-SA-4.0
License: GPL-2.0-or-later AND CC-BY-SA-4.0
Group: System/GUI/Other
Url: https://github.com/solus-project/brisk-menu
Source: https://github.com/solus-project/brisk-menu/releases/download/v%{version}/%{name}-v%{version}.tar.xz
Source1: https://github.com/solus-project/brisk-menu/releases/download/v%{version}/%{name}-v%{version}.tar.xz.asc
Source2: %{name}.keyring
# PATCH-FIX-UPSTREAM brisk-menu-mate-menus-1.22.patch -- https://github.com/solus-project/brisk-menu/pull/103
Patch0: brisk-menu-mate-menus-1.22.patch
BuildRequires: hicolor-icon-theme
BuildRequires: meson
BuildRequires: pkgconfig
BuildRequires: pkgconfig(gdk-x11-3.0) >= 3.18.0
BuildRequires: pkgconfig(gio-unix-2.0) >= 2.44.0
BuildRequires: pkgconfig(glib-2.0) >= 2.44.0
BuildRequires: pkgconfig(gtk+-3.0) >= 3.18.0
BuildRequires: pkgconfig(libmate-menu) >= 1.18.0
BuildRequires: pkgconfig(libmatepanelapplet-4.0) >= 1.18.0
BuildRequires: pkgconfig(gio-2.0)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(gtk+-3.0)
BuildRequires: pkgconfig(libmate-menu) >= 1.21
BuildRequires: pkgconfig(libmatepanelapplet-4.0) >= 1.21
BuildRequires: pkgconfig(libnotify)
BuildRequires: pkgconfig(x11)
Recommends: %{name}-lang
@ -45,6 +46,7 @@ Modern, efficient menu for the MATE Desktop Environment.
%prep
%setup -q -n %{name}-v%{version}
%patch0 -p1
%lang_package
@ -56,7 +58,7 @@ Modern, efficient menu for the MATE Desktop Environment.
%meson_install
%find_lang %{name}
%if 0%{?suse_version} <= 1320
%if 0%{?suse_version} < 1500
%post
%icon_theme_cache_post
%glib2_gsettings_schema_post
@ -67,7 +69,7 @@ Modern, efficient menu for the MATE Desktop Environment.
%endif
%files
%doc LICENSE*
%license LICENSE*
%{_libexecdir}/brisk-menu
%dir %{_datadir}/mate-panel/
%dir %{_datadir}/mate-panel/applets/