コード例 #1
0
ファイル: gtk-run.c プロジェクト: bookwar/lxpanel
static void on_response( GtkDialog* dlg, gint response, gpointer user_data )
{
    GtkEntry* entry = (GtkEntry*)user_data;
    if( G_LIKELY(response == GTK_RESPONSE_OK) )
    {
        GError* err = NULL;
        if( !g_spawn_command_line_async( gtk_entry_get_text(entry), &err ) )
        {
            show_error( (GtkWindow*)dlg, err->message );
            g_error_free( err );
            g_signal_stop_emission_by_name( dlg, "response" );
            return;
        }
    }

    /* cancel running thread if needed */
    if( thread_data ) /* the thread is still running */
        thread_data->cancel = TRUE; /* cancel the thread */

    gtk_widget_destroy( (GtkWidget*)dlg );
    win = NULL;

    /* free app list */
    g_slist_foreach(app_list, (GFunc)menu_cache_item_unref, NULL);
    g_slist_free(app_list);
    app_list = NULL;

    /* free menu cache */
    menu_cache_remove_reload_notify(menu_cache, reload_notify_id);
    reload_notify_id = NULL;
    menu_cache_unref(menu_cache);
    menu_cache = NULL;
}
コード例 #2
0
ファイル: fm-app-menu-view.c プロジェクト: YustasSwamp/libfm
static void destroy_store(gpointer user_data, GObject *obj)
{
    menu_cache_remove_reload_notify(menu_cache, menu_cache_reload_notify);
    menu_cache_reload_notify = NULL;
    menu_cache_unref(menu_cache);
    menu_cache = NULL;
    store = NULL;
}
コード例 #3
0
ファイル: appmenuview.cpp プロジェクト: GinoM/pcmanfm-qt
AppMenuView::~AppMenuView() {
  delete model_;
  if(menu_cache) {
    if(menu_cache_reload_notify)
      menu_cache_remove_reload_notify(menu_cache, menu_cache_reload_notify);
    menu_cache_unref(menu_cache);
  }
}
コード例 #4
0
ファイル: providers.cpp プロジェクト: ThomasVie/lxqt-runner
AppLinkProvider::~AppLinkProvider()
{
#ifdef HAVE_MENU_CACHE
    if(mMenuCache)
    {
        menu_cache_remove_reload_notify(mMenuCache, mMenuCacheNotify);
        menu_cache_unref(mMenuCache);
    }
#else
    delete mXdgMenu;
#endif
}
コード例 #5
0
ファイル: pekwm-menu.c プロジェクト: nfisher1226/pekwm-menu
int
main (int argc, char **argv)
{

	gpointer reload_notify_id = NULL;
	GError *error = NULL;
	gchar  *menu = NULL;
	OB_Menu ob_context = { 0 };

	gboolean  show_gnome = FALSE;
	gboolean  show_kde = FALSE;
	gboolean  show_xfce = FALSE;
	gboolean  show_rox = FALSE;
	gboolean  persistent = FALSE;
	gchar   **app_menu = NULL;
	gchar    *output = NULL;
	gchar    *terminal = "xterm -e";
	gint      ret;
	/*
	 * 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
	 */
	 /* removed startup-notify option and associated code as pekwm doesn't support it
	 * 2013-08-21 NF
	 */
	GOptionEntry entries[] = {
		{ "comment",   'c', 0, G_OPTION_ARG_NONE, &ob_context.comment,
		  "Show generic name instead of application name", NULL },
		{ "terminal",  't', 0, G_OPTION_ARG_STRING, &terminal,
		  "Terminal command (default xterm -e)", "cmd" },
		{ "gnome",     'g', 0, G_OPTION_ARG_NONE, &show_gnome,
		  "Show GNOME entries", NULL },
		{ "kde",       'k', 0, G_OPTION_ARG_NONE, &show_kde,
		  "Show KDE entries", NULL },
		{ "xfce",      'x', 0, G_OPTION_ARG_NONE, &show_xfce,
		  "Show XFCE entries", NULL },
		{ "rox",       'r', 0, G_OPTION_ARG_NONE, &show_rox,
		  "Show ROX entries", NULL },
		{ "persistent",'p', 0, G_OPTION_ARG_NONE, &persistent,
		  "stay active",    NULL },
		{ "output",    'o', 0, G_OPTION_ARG_STRING, &output,
		  "file to write data to", NULL },
		{ "noicons", 'i',   0, G_OPTION_ARG_NONE, &ob_context.no_icons,
		  "Don't display icons in menu", NULL },
		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &app_menu,
		  NULL, "[file.menu]" },
		{NULL}
	};
	GOptionContext *help_context = NULL;

	setlocale (LC_ALL, "");

	help_context = g_option_context_new (" - Pekwm menu generator " VERSION);
	g_option_context_set_help_enabled (help_context, TRUE);
	g_option_context_add_main_entries (help_context, entries, NULL);
	g_option_context_parse (help_context, &argc, &argv, &error);

	if (error)
	{
		g_print ("%s\n", error->message);
		g_error_free (error);
		return 1;
	}

	g_option_context_free (help_context);

#ifdef WITH_ICONS
	gtk_init (&argc, &argv);
	icon_theme = gtk_icon_theme_get_default ();
#endif

	if (output)
		ob_context.output = g_build_filename (g_get_user_cache_dir (), output, NULL);
	else
		ob_context.output =  NULL;

	if (terminal)
		ob_context.terminal_cmd = terminal;

	if (show_gnome) ob_context.show_flag |= SHOW_IN_GNOME;
	if (show_kde)   ob_context.show_flag |= SHOW_IN_KDE;
	if (show_xfce)  ob_context.show_flag |= SHOW_IN_XFCE;
	if (show_rox)   ob_context.show_flag |= SHOW_IN_ROX;


	// wait for the menu to get ready
	MenuCache *menu_cache = menu_cache_lookup_sync (app_menu?*app_menu:"applications.menu");
	if (!menu_cache )
	{
		g_free (menu);
		g_warning ("Cannot connect to menu-cache :/");
		return 1;
	}

	// display the menu anyway
	ret = display_menu(menu_cache, &ob_context);

	if (persistent)
	{
		// menucache used to reload the cache after a call to menu_cache_lookup* ()
		// It's not true anymore with version >= 0.4.0.
		reload_notify_id = menu_cache_add_reload_notify (menu_cache,
		                        (MenuCacheReloadNotify) display_menu,
		                        &ob_context);

		// install signals handler
		signal (SIGTERM, sig_term_handler);
		signal (SIGINT, sig_term_handler);

		// run main loop
		loop = g_main_loop_new (NULL, FALSE);
		g_main_loop_run (loop);
		g_main_loop_unref (loop);

		menu_cache_remove_reload_notify (menu_cache, reload_notify_id);
	}

	menu_cache_unref (menu_cache);
	g_free (menu);
	if (ob_context.output)
		g_free (ob_context.output);

	return ret;
}