Skip to content

Commit

Permalink
Hide move up and move down buttons in cinnamon menu editor.
Browse files Browse the repository at this point in the history
Remove settings tree from app sys, merge settings menu entries with
the applications menu, remove all cinnamon calls to settings tree.
  • Loading branch information
mtwebster committed Nov 21, 2012
1 parent 0160f8d commit 447b99b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 159 deletions.
24 changes: 23 additions & 1 deletion files/etc/xdg/menus/cinnamon-applications.menu
Expand Up @@ -162,4 +162,26 @@
</Include>
</Menu> <!-- End Wine -->

</Menu> <!-- End Applications -->
<Menu>
<Name>Preferences</Name>
<Directory>cinnamon-settings.directory</Directory>
<Include>
<And>
<Category>Settings</Category>
</And>
</Include>
</Menu>

<!-- System Settings -->
<Menu>
<Name>Administration</Name>
<Directory>cinnamon-settings-system.directory</Directory>
<Include>
<And>
<Category>Settings</Category>
<Category>System</Category>
</And>
</Include>
</Menu> <!-- End System Settings -->

</Menu> <!-- End Applications -->
12 changes: 6 additions & 6 deletions files/usr/lib/cinnamon-menu-editor/Alacarte/MainWindow.py
Expand Up @@ -50,8 +50,8 @@ def __init__(self, datadir, version):
self.setupItemTree()
self.tree.get_object('edit_delete').set_sensitive(False)
self.tree.get_object('edit_properties').set_sensitive(False)
self.tree.get_object('move_up_button').set_sensitive(False)
self.tree.get_object('move_down_button').set_sensitive(False)
# self.tree.get_object('move_up_button').set_sensitive(False)
# self.tree.get_object('move_down_button').set_sensitive(False)

def run(self):
self.loadMenus()
Expand Down Expand Up @@ -322,8 +322,8 @@ def on_menu_tree_cursor_changed(self, treeview):
self.loadItems(self.menu_store[menu_path][2])
self.tree.get_object('edit_delete').set_sensitive(False)
self.tree.get_object('edit_properties').set_sensitive(False)
self.tree.get_object('move_up_button').set_sensitive(False)
self.tree.get_object('move_down_button').set_sensitive(False)
# self.tree.get_object('move_up_button').set_sensitive(False)
# self.tree.get_object('move_down_button').set_sensitive(False)
self.tree.get_object('properties_button').set_sensitive(False)
self.tree.get_object('delete_button').set_sensitive(False)

Expand Down Expand Up @@ -356,8 +356,8 @@ def on_item_tree_cursor_changed(self, treeview):
index = items.get_path(iter).get_indices()[0]
can_go_up = index > 0
can_go_down = index < len(items) - 1
self.tree.get_object('move_up_button').set_sensitive(can_go_up)
self.tree.get_object('move_down_button').set_sensitive(can_go_down)
# self.tree.get_object('move_up_button').set_sensitive(can_go_up)
# self.tree.get_object('move_down_button').set_sensitive(can_go_down)

def on_item_tree_row_activated(self, treeview, path, column):
self.on_edit_properties_activate(None)
Expand Down
6 changes: 4 additions & 2 deletions files/usr/lib/cinnamon-menu-editor/cinnamon-menu-editor.ui
Expand Up @@ -266,6 +266,7 @@
<property name="visible">True</property>
<property name="layout_style">GTK_BUTTONBOX_START</property>
<property name="spacing">6</property>
<!--
<child>
<object class="GtkButton" id="move_up_button">
<property name="label" translatable="yes">Move Up</property>
Expand All @@ -290,21 +291,22 @@
<signal handler="on_move_down_button_clicked" name="clicked"/>
</object>
</child>
-->
<child>
<object class="GtkButton" id="delete_button">
<property name="label" translatable="no">gtk-delete</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="use_stock">True</property>
<signal handler="on_delete_button_clicked" name="clicked"/>
<signal handler="on_delete_button_clicked" name="clicked"/>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</child>
<child>
<object class="GtkButton" id="properties_button">
<property name="label" translatable="no">gtk-properties</property>
Expand Down
5 changes: 1 addition & 4 deletions files/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js
Expand Up @@ -997,7 +997,7 @@ MyApplet.prototype = {
}));
this.categoriesBox.add_actor(this._allAppsCategoryButton.actor);

let trees = [appsys.get_tree(), appsys.get_settings_tree()];
let trees = [appsys.get_tree()];

for (var i in trees) {
let tree = trees[i];
Expand Down Expand Up @@ -1188,7 +1188,6 @@ MyApplet.prototype = {
let j = 0;
for ( let i = 0; i < launchers.length; ++i ) {
let app = appSys.lookup_app(launchers[i]);
if (!app) app = appSys.lookup_settings_app(launchers[i]);
if (app) {
let button = new FavoritesButton(this, app, launchers.length + 3); // + 3 because we're adding 3 system buttons at the bottom
this._favoritesButtons[app] = button;
Expand Down Expand Up @@ -1274,8 +1273,6 @@ MyApplet.prototype = {
var entry = iter.get_entry();
if (!entry.get_app_info().get_nodisplay()) {
var app = appsys.lookup_app_by_tree_entry(entry);
if (!app)
app = appsys.lookup_settings_app_by_tree_entry(entry);
dupe = this.find_dupe(app);
if (!dupe) {
let applicationButton = new ApplicationButton(this, app);
Expand Down
Expand Up @@ -317,7 +317,6 @@ MyApplet.prototype = {
let apps = new Array();
for (var i in desktopFiles){
let app = appSys.lookup_app(desktopFiles[i]);
if (!app) app = appSys.lookup_settings_app(desktopFiles[i]);
let appinfo;
if (!app) appinfo = Gio.DesktopAppInfo.new_from_filename(CUSTOM_LAUNCHERS_PATH+"/"+desktopFiles[i]);
if (app || appinfo) apps.push([app, appinfo]);
Expand Down
1 change: 0 additions & 1 deletion js/ui/appFavorites.js
Expand Up @@ -27,7 +27,6 @@ AppFavorites.prototype = {
let appSys = Cinnamon.AppSystem.get_default();
let apps = ids.map(function (id) {
let app = appSys.lookup_app(id);
if (!app) app = appSys.lookup_settings_app(id);
return app;
}).filter(function (app) {
return app != null;
Expand Down
132 changes: 0 additions & 132 deletions src/cinnamon-app-system.c
Expand Up @@ -49,13 +49,11 @@ struct _CinnamonAppSystemPrivate {

GSList *known_vendor_prefixes;

GMenuTree *settings_tree;
GHashTable *setting_id_to_app;
};

static void cinnamon_app_system_finalize (GObject *object);
static void on_apps_tree_changed_cb (GMenuTree *tree, gpointer user_data);
static void on_settings_tree_changed_cb (GMenuTree *tree, gpointer user_data);

G_DEFINE_TYPE(CinnamonAppSystem, cinnamon_app_system, G_TYPE_OBJECT);

Expand Down Expand Up @@ -98,22 +96,14 @@ cinnamon_app_system_init (CinnamonAppSystem *self)
priv->id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL,
(GDestroyNotify)g_object_unref);
priv->setting_id_to_app = g_hash_table_new_full (g_str_hash, g_str_equal,
NULL,
(GDestroyNotify)g_object_unref);

/* For now, we want to pick up Evince, Nemo, etc. We'll
* handle NODISPLAY semantics at a higher level or investigate them
* case by case.
*/
priv->apps_tree = gmenu_tree_new ("cinnamon-applications.menu", GMENU_TREE_FLAGS_INCLUDE_NODISPLAY);
g_signal_connect (priv->apps_tree, "changed", G_CALLBACK (on_apps_tree_changed_cb), self);

priv->settings_tree = gmenu_tree_new ("cinnamon-settings.menu", GMENU_TREE_FLAGS_INCLUDE_NODISPLAY);
g_signal_connect (priv->settings_tree, "changed", G_CALLBACK (on_settings_tree_changed_cb), self);

on_apps_tree_changed_cb (priv->apps_tree, self);
on_settings_tree_changed_cb (priv->settings_tree, self);
}

static void
Expand All @@ -123,11 +113,9 @@ cinnamon_app_system_finalize (GObject *object)
CinnamonAppSystemPrivate *priv = self->priv;

g_object_unref (priv->apps_tree);
g_object_unref (priv->settings_tree);

g_hash_table_destroy (priv->running_apps);
g_hash_table_destroy (priv->id_to_app);
g_hash_table_destroy (priv->setting_id_to_app);

g_slist_foreach (priv->known_vendor_prefixes, (GFunc)g_free, NULL);
g_slist_free (priv->known_vendor_prefixes);
Expand Down Expand Up @@ -397,40 +385,6 @@ on_apps_tree_changed_cb (GMenuTree *tree,
g_signal_emit (self, signals[INSTALLED_CHANGED], 0);
}

static void
on_settings_tree_changed_cb (GMenuTree *tree,
gpointer user_data)
{
CinnamonAppSystem *self = CINNAMON_APP_SYSTEM (user_data);
GError *error = NULL;
GHashTable *new_settings;
GHashTableIter iter;
gpointer key, value;

g_assert (tree == self->priv->settings_tree);

g_hash_table_remove_all (self->priv->setting_id_to_app);
if (!gmenu_tree_load_sync (self->priv->settings_tree, &error))
{
g_warning ("Failed to load settings: %s", error->message);
return;
}

new_settings = get_flattened_entries_from_tree (tree);

g_hash_table_iter_init (&iter, new_settings);
while (g_hash_table_iter_next (&iter, &key, &value))
{
const char *id = key;
GMenuTreeEntry *entry = value;
CinnamonApp *app;

app = _cinnamon_app_new (entry);
g_hash_table_replace (self->priv->setting_id_to_app, (char*)id, app);
}
g_hash_table_destroy (new_settings);
}

/**
* cinnamon_app_system_get_tree:
*
Expand All @@ -442,38 +396,6 @@ cinnamon_app_system_get_tree (CinnamonAppSystem *self)
return self->priv->apps_tree;
}

/**
* cinnamon_app_system_get_settings_tree:
*
* Return Value: (transfer none): The #GMenuTree for apps
*/
GMenuTree *
cinnamon_app_system_get_settings_tree (CinnamonAppSystem *self)
{
return self->priv->settings_tree;
}

/**
* cinnamon_app_system_lookup_setting:
* @system:
* @id: desktop file id
*
* Returns: (transfer none): Application in gnomecc.menu, or %NULL if none
*/
CinnamonApp *
cinnamon_app_system_lookup_setting (CinnamonAppSystem *self,
const char *id)
{
CinnamonApp *app;

/* Actually defer to the main app set if there's overlap */
app = cinnamon_app_system_lookup_app (self, id);
if (app != NULL)
return app;

return g_hash_table_lookup (self->priv->setting_id_to_app, id);
}

/**
* cinnamon_app_system_get_default:
*
Expand Down Expand Up @@ -524,26 +446,6 @@ cinnamon_app_system_lookup_app (CinnamonAppSystem *self,
return result;
}

/**
* cinnamon_app_system_lookup_settings_app:
*
* Find a #CinnamonApp corresponding to an id.
*
* Return value: (transfer none): The #CinnamonApp for id, or %NULL if none
*/
CinnamonApp *
cinnamon_app_system_lookup_settings_app (CinnamonAppSystem *self,
const char *id)
{
CinnamonApp *result;

result = g_hash_table_lookup (self->priv->setting_id_to_app, id);
if (result == NULL) {
result = g_hash_table_find (self->priv->setting_id_to_app, (GHRFunc) case_insensitive_search, id);
}
return result;
}

/**
* cinnamon_app_system_lookup_app_by_tree_entry:
* @system: a #CinnamonAppSystem
Expand All @@ -563,25 +465,6 @@ cinnamon_app_system_lookup_app_by_tree_entry (CinnamonAppSystem *self,
return cinnamon_app_system_lookup_app (self, gmenu_tree_entry_get_desktop_file_id (entry));
}

/**
* cinnamon_app_system_lookup_settings_app_by_tree_entry:
* @system: a #CinnamonAppSystem
* @entry: a #GMenuTreeEntry
*
* Find a #CinnamonApp corresponding to a #GMenuTreeEntry.
*
* Return value: (transfer none): The #CinnamonApp for @entry, or %NULL if none
*/
CinnamonApp *
cinnamon_app_system_lookup_settings_app_by_tree_entry (CinnamonAppSystem *self,
GMenuTreeEntry *entry)
{
/* If we looked up directly in ->entry_to_app, we'd lose the
* override of running apps. Thus, indirect through the id.
*/
return cinnamon_app_system_lookup_settings_app (self, gmenu_tree_entry_get_desktop_file_id (entry));
}

/**
* cinnamon_app_system_lookup_app_for_path:
* @system: a #CinnamonAppSystem
Expand Down Expand Up @@ -865,18 +748,3 @@ cinnamon_app_system_subsearch (CinnamonAppSystem *system,
return sort_and_concat_results (system, prefix_results, substring_results);
}

/**
* cinnamon_app_system_search_settings:
* @system: A #CinnamonAppSystem
* @terms: (element-type utf8): List of terms, logical AND
*
* Search through settings for the given search terms.
*
* Returns: (transfer container) (element-type CinnamonApp): List of setting applications
*/
GSList *
cinnamon_app_system_search_settings (CinnamonAppSystem *self,
GSList *terms)
{
return search_tree (self, terms, self->priv->setting_id_to_app);
}
12 changes: 0 additions & 12 deletions src/cinnamon-app-system.h
Expand Up @@ -43,12 +43,8 @@ GMenuTree *cinnamon_app_system_get_tree (CinnamonAppSys

CinnamonApp *cinnamon_app_system_lookup_app (CinnamonAppSystem *system,
const char *id);
CinnamonApp *cinnamon_app_system_lookup_settings_app (CinnamonAppSystem *system,
const char *id);
CinnamonApp *cinnamon_app_system_lookup_app_by_tree_entry (CinnamonAppSystem *system,
GMenuTreeEntry *entry);
CinnamonApp *cinnamon_app_system_lookup_settings_app_by_tree_entry (CinnamonAppSystem *system,
GMenuTreeEntry *entry);
CinnamonApp *cinnamon_app_system_lookup_app_for_path (CinnamonAppSystem *system,
const char *desktop_path);
CinnamonApp *cinnamon_app_system_lookup_heuristic_basename (CinnamonAppSystem *system,
Expand All @@ -65,13 +61,5 @@ GSList *cinnamon_app_system_subsearch (CinnamonAppSystem
GSList *previous_results,
GSList *terms);

GMenuTree *cinnamon_app_system_get_settings_tree (CinnamonAppSystem *system);

GSList *cinnamon_app_system_search_settings (CinnamonAppSystem *system,
GSList *terms);

CinnamonApp *cinnamon_app_system_lookup_setting (CinnamonAppSystem *system,
const char *id);


#endif /* __CINNAMON_APP_SYSTEM_H__ */

0 comments on commit 447b99b

Please sign in to comment.