diff --git a/.hg_archival.txt b/.hg_archival.txt new file mode 100644 index 0000000..840a938 --- /dev/null +++ b/.hg_archival.txt @@ -0,0 +1,6 @@ +repo: 236107f09e6cbb1efcfcbcfca7fe3d01d6756c53 +node: eae8c7854dab0437d283ae286b6b08dfb4af67d0 +branch: default +latesttag: v0.8.0 +latesttagdistance: 1 +changessincelatesttag: 1 diff --git a/.hgignore b/.hgignore new file mode 100644 index 0000000..2bbd31b --- /dev/null +++ b/.hgignore @@ -0,0 +1,6 @@ +syntax: glob +*.orig +*.rej +*~ +*.o +*.so diff --git a/.hgtags b/.hgtags new file mode 100644 index 0000000..553da62 --- /dev/null +++ b/.hgtags @@ -0,0 +1,21 @@ +607cb011a046afb469c8c6a32cb25fe82e1a9c99 v0.3.6 +85b6eda07d65fcb7dabde2cafba53d99597087ce v0.3.6.1 +ce182c3b44d00d85ba2175c6276173ddd9f3dccd v0.3.6.3 +a68d53a9e5a38c90cea912d0aa814d49c4275b41 v0.3.6.5 +2cc5c76a25810677086acecabc0ba6d7665f4633 v0.3.6.4 +989c9da7fd1d1a8ecce1f2e9ed00cf73d86219ae v0.3.6.6 +8aec06a014523304f4c85735af3d114cb8bd870d v0.3.6.7 +64441862ddf4be3f15207b7904b036b033b01805 v0.3.6.8 +aec5f6b3bb4bb61fa1ff10bc7362c52e775b0ceb v0.4.99 +c32044967c4d99dfc67b38ba7b29e57c344da4f3 v0.5.0 +c32044967c4d99dfc67b38ba7b29e57c344da4f3 v0.5.0 +0000000000000000000000000000000000000000 v0.5.0 +0000000000000000000000000000000000000000 v0.5.0 +4974c50d687eae19ec284fb7911471a1eed9c4c2 v0.5.0 +ffbe369c5cbd80c372cbff08d01e12c3c93bfa17 v0.5.1 +ffbe369c5cbd80c372cbff08d01e12c3c93bfa17 v0.5.1 +0000000000000000000000000000000000000000 v0.5.1 +0000000000000000000000000000000000000000 v0.5.1 +d03ae08b671008d672170356d201227360fbd37c v0.5.1 +3c78153fc3cb9115e83db95b6f4f0ca5a698f762 v0.7.0 +a7f8a5815fd2443b43d3428901cee078bbfaf7c6 v0.8.0 diff --git a/ChangeLog b/ChangeLog index d827e0b..9147e08 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,13 +1,203 @@ +2014-10-27 Fabrice THIROUX + + * .hgtags: + Added tag v0.7.0 for changeset 3c78153fc3cb + [3daf21c3b626] [tip] + + * openbox-menu.h: + Change version to 0.7.0 as it targets menu-cache 0.7.0 + [3c78153fc3cb] [v0.7.0] + + * menu.c: + Warn if XDG_MENU_PREFIX is set. This cause trouble with menu-cache + 0.7 + [b42fd73621d6] + + * utils.c: + Won't crash if menu entry doesn't have exec key (thanks LStranger) + [6a67e27a21a6] + +2014-05-30 Fabrice THIROUX + + * utils.c: + Fix quote XML entity name, it is obviously named " + [414186d93f26] + +2013-11-30 Fabrice THIROUX + + * .hgtags: + Added tag v0.5.1 for changeset d03ae08b6710 + [d8857e942f8c] + + * .hgtags: + Removed tag v0.5.1 + [d03ae08b6710] [v0.5.1] + + * ob_display.c: + Fix missing double quote (issue #3) + [2c8ef0cbc8f4] + +2013-11-24 Fabrice THIROUX + + * .hgtags: + Added tag v0.5.1 for changeset ffbe369c5cbd + [728467bbe0e6] + + * openbox-menu.h: + Bump to 0.5.1 + [ffbe369c5cbd] + + * README.md: + Documentation updated + [abc31487545b] + +2013-11-17 Fabrice THIROUX + + * ob_display.c: + small change in XML template. + [a3176b559389] + + * menu.c, ob_display.c, openbox-menu.h: + Header and footer flags were removed. A XML template can be used + instead (-T flags). + [f2e2f8aa7463] + +2013-11-11 Fabrice THIROUX + + * README.md: + Documentation correction + [bb1d0bc4df6c] + + * ob_display.c: + XML definition header added + [51972bddb66a] + +2013-11-09 Fabrice THIROUX + + * README.md: + line feeds removed in documentation + [9329bcdd2b23] + + * README.md: + Add custom header and footer section in documentation + [e5f33a1cc4b3] + +2013-11-04 Fabrice THIROUX + + * TODO: + TODO updated + [cf2a78005b52] + +2013-11-03 Fabrice THIROUX + + * ob_display.c: + Drop menu_cache_get_root_dir as it is marked as deprecated since + 0.3.4 + [50f75e1603d5] + + * menu.c, ob_display.c, openbox-menu.h, utils.c: + Header and footer of the pipe-menu may be customize by user with -H + and -F parameters. Minor changes in doc + [2b97a171fdff] + + * menu.c, ob_display.c, openbox-menu.h: + Error code retreived from callback + [62e9c9e90c59] + + * menu.c, ob_display.c, openbox-menu.h, utils.c: + Cold and rainy day: big changes in code + [7ff8f172d1f3] + + * menu.c, openbox-menu.h: + Use of a context to configure the program + [0a9c0f5aac1b] + +2013-10-26 Fabrice THIROUX + + * README.md: + Markdown syntax modification + [fb3d86453f1b] + + * README.md: + Example added in documentation + [ead077817a39] + +2013-10-25 Fabrice THIROUX + + * README.md: + README update + [21d95458fade] + + * openbox-menu.h: + A sort of version check added in order to inform user of older + version of menu-cache during compilation + [40f2d7b6d415] + + * menu.c: + Changes in check_application_menu documentation + [04e8f25ac257] + + * menu.c: + Openbox can use user custom menus. + + XDG_CONFIG_DIRS is used to set ordered base directories for + configuration as defined in XDG base directory specification. + [e113bcf53407] + +2013-10-24 Fabrice THIROUX + + * menu.c, openbox-menu.h: + date updated + [4d3588e67180] + + * menu.c: + menu_cache_lookup is called when openbox-menu is ran in persistent + mode. + [6c35466488e3] + + * menu.c: + get_application_menu 2: the return. + [3a02f28aff65] + +2013-10-17 Fabrice THIROUX + + * menu.c: + free output variable only if it is allocated + [86e1c4b18cdd] + + * menu.c: + Fix bad propagated error return + [409a1bb496e4] + +2013-10-16 Fabrice THIROUX + + * menu.c: + Remove tests on xdg menu files asLibmenu-cache seems to take care of + non-existent files and XDG_PREFIX value. + [82f72f650e44] + 2013-08-20 Fabrice THIROUX * .hgtags: + Added tag v0.5.0 for changeset 4974c50d687e + [0e52ecf29860] + + * ChangeLog, openbox-menu.h: + Definitively the 0.5.0 version. + [4974c50d687e] [v0.5.0] + + * .hgtags: + Removed tag v0.5.0 + [3705bd7152a7] + + * .hgtags: Added tag v0.5.0 for changeset c32044967c4d - [b11386081931] [tip] + [b11386081931] * menu.c: No need to free reload_notify_id, this is done by menu_cache_remove_reload_notify. - [c32044967c4d] [v0.5.0] + [c32044967c4d] 2013-08-18 Fabrice THIROUX diff --git a/archlinux/PKGBUILD b/archlinux/PKGBUILD new file mode 100644 index 0000000..21eecc0 --- /dev/null +++ b/archlinux/PKGBUILD @@ -0,0 +1,33 @@ +# Contributors: Calimero +# Maintainer: mimas + +_pkgname=openbox-menu +pkgname=$_pkgname-hg +pkgver=66.35d948d8b998 +pkgrel=1 +pkgdesc="Dynamic XDG menu for openbox" +arch=('i686' 'x86_64') +provides=("openbox-menu") +conflicts=("openbox-menu") +url="http://mimasgpc.free.fr/openbox-menu.html" +license=('GPL3') +depends=('gtk2' 'menu-cache') +makedepends=("mercurial") +optdepends=('lxmenu-data: LXDE menus' 'gnome-menus: GNOME menus') +source=("hg+https://bitbucket.org/fabriceT/openbox-menu") +md5sums=('SKIP') + +pkgver() { + cd $_pkgname + echo $(hg identify -n).$(hg identify -i) +} + +build() { + cd $_pkgname + make +} + +package() { + cd $_pkgname + make install DESTDIR="${pkgdir}/usr/" +} diff --git a/menu.c b/menu.c index 7bb706d..c7be3be 100644 --- a/menu.c +++ b/menu.c @@ -1,5 +1,5 @@ // openbox-menu - a dynamic menu for openbox -// Copyright (C) 2010-13 mimas +// Copyright (C) 2010-15 Fabrice THIROUX // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -39,8 +39,7 @@ g_main_loop_quit (loop); } - -/****f* openbox-menu/get_application_menu +/****f* openbox-menu/get_default_application_menu * FUNCTION * Try to determine which menu file to use if none defined by user. * XDG_MENU_PREFIX variable exists, it is used to prefix menu name. @@ -49,14 +48,13 @@ * a char that need to be freed by caller. ****/ gchar * -get_application_menu (void) +get_default_application_menu (void) { gchar menu[APPMENU_SIZE]; gchar *xdg_prefix = getenv("XDG_MENU_PREFIX"); if (xdg_prefix) { - g_warning ("XDG_MENU_PREFIX environment variable set, this could prevent the menu from loading. Unset it if an error happens"); g_snprintf (menu, APPMENU_SIZE, "%sapplications.menu", xdg_prefix); } else @@ -64,7 +62,6 @@ return strdup (menu); } - /****f* openbox-menu/check_application_menu * FUNCTION @@ -113,27 +110,13 @@ gboolean show_kde = FALSE; gboolean show_xfce = FALSE; gboolean show_rox = FALSE; + gboolean show_unknown = FALSE; gboolean no_icons = FALSE; gchar *template = NULL; gboolean sn = FALSE; gchar *output = NULL; gchar **app_menu = NULL; - /* - * TODO: Registered OnlyShowIn Environments - * Ref: http://standards.freedesktop.org/menu-spec/latest/apb.html - * - * GNOME GNOME Desktop - * KDE KDE Desktop - * LXDE LXDE Desktop - * MATE MATÉ Desktop - * Razor Razor-qt Desktop - * ROX ROX Desktop - * TDE Trinity Desktop - * Unity Unity Shell - * XFCE XFCE Desktop - * Old Legacy menu systems - */ GOptionEntry entries[] = { { "comment", 'c', 0, G_OPTION_ARG_NONE, &comment, "Show generic name instead of application name", NULL }, @@ -147,6 +130,8 @@ "Show XFCE entries", NULL }, { "rox", 'r', 0, G_OPTION_ARG_NONE, &show_rox, "Show ROX entries", NULL }, + { "unknown", 'u', 0, G_OPTION_ARG_NONE, &show_unknown, + "Show Unknown deskstop entries", NULL }, { "persistent",'p', 0, G_OPTION_ARG_NONE, &persistent, "stay active", NULL }, { "sn", 's', 0, G_OPTION_ARG_NONE, &sn, @@ -182,10 +167,14 @@ else context->output = NULL; - if (show_gnome) context->show_flag |= SHOW_IN_GNOME; - if (show_kde) context->show_flag |= SHOW_IN_KDE; - if (show_xfce) context->show_flag |= SHOW_IN_XFCE; - if (show_rox) context->show_flag |= SHOW_IN_ROX; + // We add extra desktop entries to display. + // Our current desktop is set when menu_cache has loaded its own cache. + // (likely in menu_display function). + if (show_gnome) context->show_flag |= SHOW_IN_GNOME; + if (show_kde) context->show_flag |= SHOW_IN_KDE; + if (show_xfce) context->show_flag |= SHOW_IN_XFCE; + if (show_rox) context->show_flag |= SHOW_IN_ROX; + if (show_unknown) context->show_flag |= 1 << N_KNOWN_DESKTOPS; if (terminal_cmd) context->terminal_cmd = terminal_cmd; @@ -205,7 +194,7 @@ context->persistent = TRUE; if (!app_menu) - context->menu_file = get_application_menu (); + context->menu_file = get_default_application_menu(); else context->menu_file = strdup (*app_menu); @@ -222,6 +211,8 @@ { gpointer reload_notify_id = NULL; MenuCache *menu_cache = NULL; + + g_unsetenv("XDG_MENU_PREFIX"); // For unknow reason, it doesn't work when it is set. if (context->persistent) /* persistent mode */ { diff --git a/ob_display.c b/ob_display.c index 423fcc8..7d64a3f 100644 --- a/ob_display.c +++ b/ob_display.c @@ -1,5 +1,5 @@ // ob_display.c - this file is part of openbox-menu -// Copyright (C) 2010-13 mimas +// Copyright (C) 2010-15 Fabrice THIROUX // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -140,7 +140,7 @@ break; case MENU_CACHE_TYPE_APP: - if (app_is_visible (MENU_CACHE_APP(l->data), 0)) + if (app_is_visible (MENU_CACHE_APP(l->data), context->show_flag)) menu_application (l->data, context); } } @@ -207,6 +207,11 @@ context->code = MENU_DIR_ERROR; return; } + + // Desktops are dynamically detected by menu_cache when reloading + // its cache. It is now time to add our desktop to the show_flag in + // the application context. + add_current_desktop_to_context (menu, context); GSList *l = menu_cache_dir_get_children (dir); diff --git a/openbox-menu.h b/openbox-menu.h index ece598b..11ee66e 100644 --- a/openbox-menu.h +++ b/openbox-menu.h @@ -1,6 +1,6 @@ /* * openbox-menu.h - this file is part of openbox-menu - * Copyright (C) 2010-13 mimas + * Copyright (C) 2010-15 Fabrice THIROUX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published @@ -21,7 +21,7 @@ #define __OPENBOXMENU_APP__ #include -#define VERSION "0.7.0" +#define VERSION "0.8.0" #define APPMENU_SIZE 30 #define TERMINAL_CMD "xterm -e" @@ -58,6 +58,8 @@ gchar *clean_exec (MenuCacheApp *); gchar *safe_name (const char *); gchar *item_icon_path (MenuCacheItem*); +guint32 get_current_desktop_flag (); +void add_current_desktop_to_context (MenuCache *, OB_Menu *); void menu_display (MenuCache *, OB_Menu *); diff --git a/utils.c b/utils.c index b02cb8c..065ddfd 100644 --- a/utils.c +++ b/utils.c @@ -1,5 +1,5 @@ // utils.c - this file is part of openbox-menu -// Copyright (C) 2010-13 mimas +// Copyright (C) 2010-15 Fabrice THIROUX // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -83,7 +83,7 @@ const char *exec = menu_cache_app_get_exec (MENU_CACHE_APP(app)); g_return_val_if_fail(exec,""); - + GString *cmd = g_string_sized_new (64); for (;*exec; ++exec) @@ -205,3 +205,25 @@ else return menu_cache_app_get_is_visible(MENU_CACHE_APP(app), de_flag); } + +const char* get_desktop_name() { + const gchar *desktop = g_getenv ("XDG_CURRENT_DESKTOP"); + if (desktop) + return desktop; + + desktop = g_getenv ("DESKTOP_SESSION"); + if (desktop) + return desktop; + + // We return nothing. + return NULL; +} + +void +add_current_desktop_to_context (MenuCache *menu, OB_Menu *context) { + const char* desktop = get_desktop_name (); + if (desktop) { + context->show_flag |= menu_cache_get_desktop_env_flag(menu, desktop); + } +} +