diff --git a/debian/control b/debian/control
index 5402b16..5cb0084 100644
--- a/debian/control
+++ b/debian/control
@@ -12,7 +12,7 @@ Build-Depends: debhelper (>= 9),
libgtk-3-dev,
libgtksourceview-4-dev,
libpeas-dev,
- libxapp-dev,
+ libxapp-dev (>= 1.9),
libsm-dev,
libx11-dev,
libxml2-dev,
@@ -32,7 +32,7 @@ Depends: iso-codes,
${shlibs:Depends},
python3,
python3-gi,
- xapps-common,
+ xapps-common (>= 1.9.0),
zenity
XB-Python-Version: ${python:Versions}
Description: Text editor
diff --git a/xed/resources/ui/xed-ui.xml b/xed/resources/ui/xed-ui.xml
index 4285d41..042739b 100644
--- a/xed/resources/ui/xed-ui.xml
+++ b/xed/resources/ui/xed-ui.xml
@@ -16,9 +16,15 @@
-
-
-
+
+
+
diff --git a/xed/xed-ui.h b/xed/xed-ui.h
index 6cd75ce..d0920c6 100644
--- a/xed/xed-ui.h
+++ b/xed/xed-ui.h
@@ -48,6 +48,8 @@ static const GtkActionEntry xed_always_sensitive_menu_entries[] =
{ "Tools", NULL, N_("_Tools") },
{ "Documents", NULL, N_("_Documents") },
{ "Help", NULL, N_("_Help") },
+ { "XAppFavoritesMenu", NULL, N_("Favorites")},
+ { "FileRecentsMenu", NULL, N_("Recents")},
/* File menu */
{ "FileNew", "document-new-symbolic", N_("_New"), "N",
diff --git a/xed/xed-window-private.h b/xed/xed-window-private.h
index 5d9cb6c..78054f1 100644
--- a/xed/xed-window-private.h
+++ b/xed/xed-window-private.h
@@ -32,6 +32,7 @@
#define __XED_WINDOW_PRIVATE_H__
#include
+#include
#include "xed/xed-window.h"
#include "xed-message-bus.h"
@@ -101,6 +102,10 @@ struct _XedWindowPrivate
guint recents_menu_ui_id;
gulong recents_handler_id;
+ GtkActionGroup *favorites_action_group;
+ guint favorites_menu_ui_id;
+ gulong favorites_handler_id;
+
XedTab *active_tab;
gint num_tabs;
diff --git a/xed/xed-window.c b/xed/xed-window.c
index 799a7e7..42ec4c5 100644
--- a/xed/xed-window.c
+++ b/xed/xed-window.c
@@ -209,6 +209,14 @@ xed_window_dispose (GObject *object)
window->priv->recents_handler_id = 0;
}
+ if (window->priv->favorites_handler_id != 0)
+ {
+ XAppFavorites *favorites;
+ favorites = xapp_favorites_get_default ();
+ g_signal_handler_disconnect (favorites, window->priv->favorites_handler_id);
+ window->priv->favorites_handler_id = 0;
+ }
+
g_clear_object (&window->priv->manager);
g_clear_object (&window->priv->message_bus);
g_clear_object (&window->priv->window_group);
@@ -878,7 +886,7 @@ update_recent_files_menu (XedWindow *window)
gtk_action_group_add_action (p->recents_action_group, action);
g_object_unref (action);
- gtk_ui_manager_add_ui (p->manager, p->recents_menu_ui_id, "/MenuBar/FileMenu/FileRecentsPlaceholder",
+ gtk_ui_manager_add_ui (p->manager, p->recents_menu_ui_id, "/MenuBar/FileMenu/FileRecentsMenu/FileRecentsPlaceholder",
action_name, action_name, GTK_UI_MANAGER_MENUITEM, FALSE);
g_free (action_name);
@@ -911,6 +919,71 @@ toolbar_visibility_changed (GtkWidget *toolbar,
}
}
+static void
+favorite_activated (GtkAction *action,
+ gpointer user_data)
+{
+ GFile *location;
+
+ location = g_file_new_for_uri (gtk_action_get_name (action));
+ xed_commands_load_location (XED_WINDOW (user_data), location, NULL, 0);
+
+ g_object_unref (location);
+}
+
+static void
+update_favorites_menu (XedWindow *window)
+{
+ XedWindowPrivate *p = window->priv;
+ XAppFavorites *favorites;
+ GList *actions, *l;
+ GList *items = NULL;
+ guint i;
+
+ xed_debug (DEBUG_WINDOW);
+
+ g_return_if_fail (p->favorites_action_group != NULL);
+
+ if (p->favorites_menu_ui_id != 0)
+ {
+ gtk_ui_manager_remove_ui (p->manager, p->favorites_menu_ui_id);
+ }
+
+ actions = gtk_action_group_list_actions (p->favorites_action_group);
+ for (l = actions; l != NULL; l = l->next)
+ {
+ g_signal_handlers_disconnect_by_func(GTK_ACTION (l->data), G_CALLBACK (favorite_activated), window);
+ gtk_action_group_remove_action (p->favorites_action_group, GTK_ACTION(l->data));
+ }
+ g_list_free (actions);
+
+ p->favorites_menu_ui_id = gtk_ui_manager_new_merge_id (p->manager);
+
+ favorites = xapp_favorites_get_default ();
+
+ const gchar *supported_mimetypes[2] = {
+ "text/plain",
+ NULL
+ };
+
+ items = xapp_favorites_create_actions (favorites, supported_mimetypes);
+
+ for (l = items; l != NULL; l = l->next)
+ {
+ GtkAction *action = GTK_ACTION (l->data);
+ const gchar *name = gtk_action_get_name (action);
+
+ g_signal_connect (action, "activate", G_CALLBACK (favorite_activated), window);
+
+ gtk_action_group_add_action (p->favorites_action_group, action);
+
+ gtk_ui_manager_add_ui (p->manager, p->favorites_menu_ui_id, "/MenuBar/FileMenu/XAppFavoritesMenu/XAppFavorites",
+ name, name, GTK_UI_MANAGER_MENUITEM, FALSE);
+ }
+
+ g_list_free_full (items, g_object_unref);
+}
+
static GtkWidget *
create_toolbar_button (GtkAction *action)
{
@@ -943,6 +1016,7 @@ create_menu_bar_and_toolbar (XedWindow *window,
GtkWidget *box;
GtkWidget *separator;
GtkWidget *button;
+ XAppFavorites *favorites;
xed_debug (DEBUG_WINDOW);
@@ -1017,6 +1091,19 @@ create_menu_bar_and_toolbar (XedWindow *window,
window);
update_recent_files_menu (window);
+ action_group = gtk_action_group_new ("FavoriteFilesActions");
+ gtk_action_group_set_translation_domain (action_group, NULL);
+ window->priv->favorites_action_group = action_group;
+ gtk_ui_manager_insert_action_group (manager, action_group, 0);
+ g_object_unref (action_group);
+
+ favorites = xapp_favorites_get_default ();
+ window->priv->favorites_handler_id = g_signal_connect_swapped (favorites,
+ "changed", G_CALLBACK (update_favorites_menu),
+ window);
+
+ update_favorites_menu (window);
+
/* list of open documents menu */
action_group = gtk_action_group_new ("DocumentsListActions");
gtk_action_group_set_translation_domain (action_group, NULL);