Ejemplo n.º 1
0
static void panel_addto_make_application_model(PanelAddtoDialog* dialog)
{
	GtkTreeStore* store;
	MateMenuTree* tree;
	MateMenuTreeDirectory* root;

	if (dialog->filter_application_model != NULL)
		return;

	store = gtk_tree_store_new(NUMBER_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_STRING);

	tree = matemenu_tree_lookup("mate-applications.menu", MATEMENU_TREE_FLAGS_NONE);
	matemenu_tree_set_sort_key(tree, MATEMENU_TREE_SORT_DISPLAY_NAME);

	if ((root = matemenu_tree_get_root_directory (tree)))
	{
		panel_addto_make_application_list(&dialog->application_list, root, "mate-applications.menu");
		panel_addto_populate_application_model(store, NULL, dialog->application_list);

		matemenu_tree_item_unref(root);
	}

	matemenu_tree_unref(tree);

	tree = matemenu_tree_lookup("mate-settings.menu", MATEMENU_TREE_FLAGS_NONE);
	matemenu_tree_set_sort_key(tree, MATEMENU_TREE_SORT_DISPLAY_NAME);

	if ((root = matemenu_tree_get_root_directory(tree)))
	{
		GtkTreeIter iter;

		gtk_tree_store_append(store, &iter, NULL);
		gtk_tree_store_set(store, &iter, COLUMN_ICON, NULL, COLUMN_TEXT, NULL, COLUMN_DATA, NULL, COLUMN_SEARCH, NULL, -1);

		panel_addto_make_application_list(&dialog->settings_list, root, "mate-settings.menu");
		panel_addto_populate_application_model(store, NULL, dialog->settings_list);

		matemenu_tree_item_unref(root);
	}

	matemenu_tree_unref(tree);

	dialog->application_model = GTK_TREE_MODEL(store);
	dialog->filter_application_model = gtk_tree_model_filter_new(GTK_TREE_MODEL(dialog->application_model), NULL);
	gtk_tree_model_filter_set_visible_func(GTK_TREE_MODEL_FILTER(dialog->filter_application_model), panel_addto_filter_func, dialog, NULL);
}
Ejemplo n.º 2
0
GtkWidget *
create_applications_menu (const char *menu_file,
			  const char *menu_path,
			  gboolean    always_show_image)
{
	MateMenuTree *tree;
	GtkWidget *menu;
	guint      idle_id;

	menu = create_empty_menu ();

	if (always_show_image)
		g_object_set_data (G_OBJECT (menu),
				   "panel-menu-force-icon-for-categories",
				   GINT_TO_POINTER (TRUE));

	tree = matemenu_tree_lookup (menu_file, MATEMENU_TREE_FLAGS_NONE);
	matemenu_tree_set_sort_key (tree, MATEMENU_TREE_SORT_DISPLAY_NAME);

	g_object_set_data_full (G_OBJECT (menu),
				"panel-menu-tree",
				matemenu_tree_ref (tree),
				(GDestroyNotify) matemenu_tree_unref);

	g_object_set_data_full (G_OBJECT (menu),
				"panel-menu-tree-path",
				g_strdup (menu_path ? menu_path : "/"),
				(GDestroyNotify) g_free);

	g_object_set_data (G_OBJECT (menu),
			   "panel-menu-needs-loading",
			   GUINT_TO_POINTER (TRUE));

	g_signal_connect (menu, "show",
			  G_CALLBACK (submenu_to_display), NULL);

	idle_id = g_idle_add_full (G_PRIORITY_LOW,
				   submenu_to_display_in_idle,
				   menu,
				   NULL);
	g_object_set_data_full (G_OBJECT (menu),
				"panel-menu-idle-id",
				GUINT_TO_POINTER (idle_id),
				remove_submenu_to_display_idle);

	g_signal_connect (menu, "button_press_event",
			  G_CALLBACK (menu_dummy_button_press_event), NULL);

	matemenu_tree_add_monitor (tree,
			       (MateMenuTreeChangedFunc) handle_matemenu_tree_changed,
			       menu);
	g_signal_connect (menu, "destroy",
			  G_CALLBACK (remove_matemenu_tree_monitor), tree);

	matemenu_tree_unref (tree);

	return menu;
}
Ejemplo n.º 3
0
static GSList* get_all_applications(void)
{
	MateMenuTree* tree;
	MateMenuTreeDirectory* root;
	GSList* retval;

	tree = matemenu_tree_lookup("mate-applications.menu", MATEMENU_TREE_FLAGS_NONE);
	matemenu_tree_set_sort_key(tree, MATEMENU_TREE_SORT_DISPLAY_NAME);

	root = matemenu_tree_get_root_directory(tree);

	retval = get_all_applications_from_dir(root, NULL);

	matemenu_tree_item_unref(root);
	matemenu_tree_unref(tree);

	retval = g_slist_sort(retval, (GCompareFunc) compare_applications);

	return retval;
}
Ejemplo n.º 4
0
GtkWidget *
create_applications_menu (const char *menu_file,
			  const char *menu_path,
			  gboolean    always_show_image)
{
	MateMenuTree *tree;
	GtkWidget *menu;
	guint      idle_id;

	menu = create_empty_menu ();

	if (always_show_image)
		g_object_set_data (G_OBJECT (menu),
				   "panel-menu-force-icon-for-categories",
				   GINT_TO_POINTER (TRUE));

	tree = matemenu_tree_lookup (menu_file, MATEMENU_TREE_FLAGS_NONE);
	matemenu_tree_set_sort_key (tree, MATEMENU_TREE_SORT_DISPLAY_NAME);

	g_object_set_data_full (G_OBJECT (menu),
				"panel-menu-tree",
				matemenu_tree_ref (tree),
				(GDestroyNotify) matemenu_tree_unref);

	g_object_set_data_full (G_OBJECT (menu),
				"panel-menu-tree-path",
				g_strdup (menu_path ? menu_path : "/"),
				(GDestroyNotify) g_free);

	g_object_set_data (G_OBJECT (menu),
			   "panel-menu-needs-loading",
			   GUINT_TO_POINTER (TRUE));

	g_signal_connect (menu, "show",
			  G_CALLBACK (submenu_to_display), NULL);

	idle_id = g_idle_add_full (G_PRIORITY_LOW,
				   submenu_to_display_in_idle,
				   menu,
				   NULL);
	g_object_set_data_full (G_OBJECT (menu),
				"panel-menu-idle-id",
				GUINT_TO_POINTER (idle_id),
				remove_submenu_to_display_idle);

	g_signal_connect (menu, "button_press_event",
			  G_CALLBACK (menu_dummy_button_press_event), NULL);

	matemenu_tree_add_monitor (tree,
			       (MateMenuTreeChangedFunc) handle_matemenu_tree_changed,
			       menu);
	g_signal_connect (menu, "destroy",
			  G_CALLBACK (remove_matemenu_tree_monitor), tree);

	matemenu_tree_unref (tree);
	
/*HACK Fix any failures of compiz/other wm's to communicate with gtk for transparency */
#if GTK_CHECK_VERSION (3, 0, 0) 
	GtkWidget *toplevel = gtk_widget_get_toplevel (menu);
	GdkScreen *screen = gtk_widget_get_screen(GTK_WIDGET(toplevel));
	GdkVisual *visual = gdk_screen_get_rgba_visual(screen);
	gtk_widget_set_visual(GTK_WIDGET(toplevel), visual); 
#endif
	return menu;
}