Commit 83d63088 authored by Martin Krohn's avatar Martin Krohn
parents 2acdf5c0 38ac84a9
Pipeline #266 passed with stages
in 1 minute and 6 seconds
......@@ -6,6 +6,7 @@
/depcomp
/install-sh
/libtool
/m4
/missing
/stamp-h1
......
......@@ -8,13 +8,14 @@
# Emanuele Petriglia <transifex@emanuelepetriglia.com>, 2018
# Emanuele Petriglia <transifex@emanuelepetriglia.com>, 2019
# Marco <marco.sting@gmail.com>, 2013
# Vincenzo Reale <vinx.reale@gmail.com>, 2020
msgid ""
msgstr ""
"Project-Id-Version: Xfce4-appfinder\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-06-24 00:30+0200\n"
"PO-Revision-Date: 2019-06-25 05:52+0000\n"
"Last-Translator: Emanuele Petriglia <transifex@emanuelepetriglia.com>\n"
"PO-Revision-Date: 2020-05-21 15:15+0000\n"
"Last-Translator: Vincenzo Reale <vinx.reale@gmail.com>\n"
"Language-Team: Italian (http://www.transifex.com/xfce/xfce4-appfinder/language/it/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
......@@ -77,11 +78,11 @@ msgstr "Eliminare davvero la cronologia dei comandi?"
#: ../src/appfinder-preferences.c:369
msgid "_Delete"
msgstr "Canc_ella"
msgstr "_Elimina"
#: ../src/appfinder-preferences.c:370
msgid "The custom action will be deleted permanently."
msgstr "L'azione personalizzata verrà rimossa definitivamente."
msgstr "L'azione personalizzata sarà eliminata definitivamente."
#: ../src/appfinder-preferences.c:371
#, c-format
......@@ -288,7 +289,7 @@ msgstr "Nascondi la finestra della categoria"
#: ../src/appfinder-preferences.glade.h:23
msgid "Hide category panel and show all applications."
msgstr "Nasconta il pannello della categoria e mostra tutte le applicazioni."
msgstr "Nascondi il pannello della categoria e mostra tutte le applicazioni."
#: ../src/appfinder-preferences.glade.h:24
msgid "Categ_ory icon size:"
......
This diff is collapsed.
......@@ -43,6 +43,8 @@ enum
XFCE_APPFINDER_MODEL_COLUMN_COMMAND,
XFCE_APPFINDER_MODEL_COLUMN_URI,
XFCE_APPFINDER_MODEL_COLUMN_BOOKMARK,
XFCE_APPFINDER_MODEL_COLUMN_FREQUENCY,
XFCE_APPFINDER_MODEL_COLUMN_RECENCY,
XFCE_APPFINDER_MODEL_COLUMN_TOOLTIP,
XFCE_APPFINDER_MODEL_N_COLUMNS,
};
......@@ -67,7 +69,7 @@ XfceAppfinderIconSize;
GType xfce_appfinder_model_get_type (void) G_GNUC_CONST;
XfceAppfinderModel *xfce_appfinder_model_get (void) G_GNUC_MALLOC;
XfceAppfinderModel *xfce_appfinder_model_get (gboolean sort_by_frecency) G_GNUC_MALLOC;
GSList *xfce_appfinder_model_get_categories (XfceAppfinderModel *model);
......@@ -108,6 +110,11 @@ gboolean xfce_appfinder_model_bookmark_toggle (XfceAppfinderM
GarconMenuDirectory *xfce_appfinder_model_get_command_category (void);
GarconMenuDirectory *xfce_appfinder_model_get_bookmarks_category (void);
void xfce_appfinder_model_update_frecency (XfceAppfinderModel *model,
const gchar *desktop_id,
GError **error);
guint xfce_appfinder_model_calculate_frecency (guint frequency,
guint64 recency);
G_END_DECLS
......
......@@ -134,6 +134,10 @@ xfce_appfinder_preferences_init (XfceAppfinderPreferences *preferences)
G_CALLBACK (xfce_appfinder_preferences_single_window_sensitive), object);
xfce_appfinder_preferences_single_window_sensitive (GTK_WIDGET (previous), GTK_WIDGET (object));
object = gtk_builder_get_object (GTK_BUILDER (preferences), "sort-by-frecency");
xfconf_g_property_bind (preferences->channel, "/sort-by-frecency", G_TYPE_BOOLEAN,
G_OBJECT (object), "active");
previous = gtk_builder_get_object (GTK_BUILDER (preferences), "icon-view");
xfconf_g_property_bind (preferences->channel, "/icon-view", G_TYPE_BOOLEAN,
G_OBJECT (previous), "active");
......@@ -259,7 +263,7 @@ xfce_appfinder_preferences_clear_history (XfceAppfinderPreferences *preferences)
_("This will permanently clear the custom command history."),
_("Are you sure you want to clear the command history?")))
{
model = xfce_appfinder_model_get ();
model = xfce_appfinder_model_get (xfconf_channel_get_bool (preferences->channel, "/sort-by-frecency", FALSE));
xfce_appfinder_model_history_clear (model);
g_object_unref (G_OBJECT (model));
}
......
......@@ -224,6 +224,23 @@
<property name="position">3</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="sort-by-frecency">
<property name="label" translatable="yes">Sort recently used items first</property>
<property name="use_action_appearance">False</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
<property name="tooltip_text" translatable="yes">Order items, such that items that are most recently used are always on the top.</property>
<property name="use_underline">True</property>
<property name="draw_indicator">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">4</property>
</packing>
</child>
</object>
</child>
</object>
......
......@@ -117,6 +117,13 @@ static gint xfce_appfinder_window_sort_items (GtkTreeMo
GtkTreeIter *b,
gpointer data);
static gboolean xfce_appfinder_should_sort_icon_view (void);
static void xfce_appfinder_window_update_frecency (XfceAppfinderWindow *window,
GtkTreeModel *model,
const gchar *uri);
static gint xfce_appfinder_window_sort_items_frecency (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer data);
struct _XfceAppfinderWindowClass
{
......@@ -218,7 +225,7 @@ xfce_appfinder_window_init (XfceAppfinderWindow *window)
xfconf_g_property_bind (window->channel, "/category-icon-size", G_TYPE_UINT,
G_OBJECT (window->category_model), "icon-size");
window->model = xfce_appfinder_model_get ();
window->model = xfce_appfinder_model_get (xfconf_channel_get_bool (window->channel, "/sort-by-frecency", FALSE));
xfconf_g_property_bind (window->channel, "/item-icon-size", G_TYPE_UINT,
G_OBJECT (window->model), "icon-size");
......@@ -702,7 +709,10 @@ xfce_appfinder_window_view (XfceAppfinderWindow *window)
gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (window->filter_model), xfce_appfinder_window_item_visible, window, NULL);
window->sort_model = gtk_tree_model_sort_new_with_model (GTK_TREE_MODEL (window->filter_model));
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (window->sort_model), xfce_appfinder_window_sort_items, window->entry, NULL);
if (xfconf_channel_get_bool (window->channel, "/sort-by-frecency", FALSE))
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (window->sort_model), xfce_appfinder_window_sort_items_frecency, window->entry, NULL);
else
gtk_tree_sortable_set_default_sort_func (GTK_TREE_SORTABLE (window->sort_model), xfce_appfinder_window_sort_items, window->entry, NULL);
if (icon_view)
{
......@@ -1817,6 +1827,7 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window,
gboolean regular_command = FALSE;
gboolean save_cmd;
gboolean only_custom_cmd = FALSE;
const gchar *uri;
screen = gtk_window_get_screen (GTK_WINDOW (window));
if (gtk_widget_get_visible (window->paned))
......@@ -1830,6 +1841,7 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window,
if (xfce_appfinder_window_view_get_selected (window, &model, &iter))
{
child_model = model;
gtk_tree_model_get (model, &iter, XFCE_APPFINDER_MODEL_COLUMN_URI, &uri, -1);
if (GTK_IS_TREE_MODEL_SORT (model) || xfce_appfinder_should_sort_icon_view ())
{
......@@ -1841,6 +1853,7 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window,
gtk_tree_model_filter_convert_iter_to_child_iter (GTK_TREE_MODEL_FILTER (child_model), &child_iter, &iter);
result = xfce_appfinder_model_execute (window->model, &child_iter, screen, &regular_command, &error);
xfce_appfinder_window_update_frecency (window, model, uri);
if (!result && regular_command)
{
gtk_tree_model_get (model, &child_iter, XFCE_APPFINDER_MODEL_COLUMN_COMMAND, &cmd, -1);
......@@ -1888,6 +1901,32 @@ xfce_appfinder_window_execute (XfceAppfinderWindow *window,
static void
xfce_appfinder_window_update_frecency (XfceAppfinderWindow *window,
GtkTreeModel *model,
const gchar *uri)
{
GFile *gfile;
gchar *desktop_id;
GError *error = NULL;
if (uri != NULL)
{
gfile = g_file_new_for_uri (uri);
desktop_id = g_file_get_basename (gfile);
g_object_unref (G_OBJECT (gfile));
APPFINDER_DEBUG ("desktop : %s", desktop_id);
model = gtk_tree_model_filter_get_model (GTK_TREE_MODEL_FILTER (window->filter_model));
xfce_appfinder_model_update_frecency (XFCE_APPFINDER_MODEL (model), desktop_id, &error);
g_free (desktop_id);
g_free (error);
}
}
void
xfce_appfinder_window_set_expanded (XfceAppfinderWindow *window,
gboolean expanded)
......@@ -1985,6 +2024,35 @@ xfce_appfinder_window_sort_items (GtkTreeModel *model,
static gint
xfce_appfinder_window_sort_items_frecency (GtkTreeModel *model,
GtkTreeIter *a,
GtkTreeIter *b,
gpointer data)
{
guint a_freq, b_freq;
guint64 a_rec, b_rec;
guint a_res, b_res;
gtk_tree_model_get (model, a, XFCE_APPFINDER_MODEL_COLUMN_FREQUENCY, &a_freq, -1);
gtk_tree_model_get (model, b, XFCE_APPFINDER_MODEL_COLUMN_FREQUENCY, &b_freq, -1);
gtk_tree_model_get (model, a, XFCE_APPFINDER_MODEL_COLUMN_RECENCY, &a_rec, -1);
gtk_tree_model_get (model, b, XFCE_APPFINDER_MODEL_COLUMN_RECENCY, &b_rec, -1);
a_res = xfce_appfinder_model_calculate_frecency (a_freq, a_rec);
b_res = xfce_appfinder_model_calculate_frecency (b_freq, b_rec);
/* Sort according the frecency */
if (b_res - a_res != 0)
return b_res - a_res;
/* If they have the same frecency, fallback to the alphabetical order */
return xfce_appfinder_window_sort_items (model, a, b, data);
}
/*
* Checks for gtk => 3.22.27 during runtime.
* This is necessary because sort model for icon view did not work as expected.
......
......@@ -145,7 +145,8 @@ appfinder_window_destroyed (GtkWidget *window)
if (model_cache == NULL)
{
APPFINDER_DEBUG ("main took reference on the main model");
model_cache = xfce_appfinder_model_get ();
channel = xfconf_channel_get ("xfce4-appfinder");
model_cache = xfce_appfinder_model_get (xfconf_channel_get_bool (channel, "/sort-by-frecency", FALSE));
}
/* remove from internal list */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment