* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
- * License along with the Gnome Library; see the file COPYING.LIB. If not,
- * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
/*
#include "gtkmenutoolbutton.h"
#include "gtkseparatormenuitem.h"
#include "gtkseparatortoolitem.h"
-#include "gtktearoffmenuitem.h"
#include "gtktoolbar.h"
-#include "gtkuimanager.h"
#include "gtkwindow.h"
#include "gtkprivate.h"
+#undef GDK_DEPRECATED
+#undef GDK_DEPRECATED_FOR
+#define GDK_DEPRECATED
+#define GDK_DEPRECATED_FOR(f)
+
+#include "gtkuimanager.h"
+#include "deprecated/gtktearoffmenuitem.h"
/**
* SECTION:gtkuimanager
*
* <example>
* <title>A UI definition</title>
- * <programlisting>
+ * <programlisting><![CDATA[
* <ui>
* <menubar>
* <menu name="FileMenu" action="FileMenuAction">
* </placeholder>
* </toolbar>
* </ui>
- * </programlisting>
+ * ]]></programlisting>
* </example>
*
* The constructed widget hierarchy is very similar to the element tree
GObject *child,
const gchar *tagname,
gpointer *data);
+static void gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
+ gboolean add_tearoffs);
* menus never have tearoff menu items.
*
* Since: 2.4
+ *
+ * Deprecated: 3.4: Tearoff menus are deprecated and should not
+ * be used in newly written code.
*/
g_object_class_install_property (gobject_class,
PROP_ADD_TEAROFFS,
P_("Add tearoffs to menus"),
P_("Whether tearoff menu items should be added to menus"),
FALSE,
- GTK_PARAM_READWRITE));
+ GTK_PARAM_READWRITE | G_PARAM_DEPRECATED));
g_object_class_install_property (gobject_class,
PROP_UI,
g_node_destroy (manager->private_data->root_node);
manager->private_data->root_node = NULL;
- g_list_foreach (manager->private_data->action_groups,
- (GFunc) g_object_unref, NULL);
- g_list_free (manager->private_data->action_groups);
+ g_list_free_full (manager->private_data->action_groups, g_object_unref);
manager->private_data->action_groups = NULL;
g_object_unref (manager->private_data->accel_group);
switch (prop_id)
{
case PROP_ADD_TEAROFFS:
- gtk_ui_manager_set_add_tearoffs (manager, g_value_get_boolean (value));
+ gtk_ui_manager_do_set_add_tearoffs (manager, g_value_get_boolean (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
* Return value: whether tearoff menu items are added
*
* Since: 2.4
+ *
+ * Deprecated: 3.4: Tearoff menus are deprecated and should not
+ * be used in newly written code.
**/
gboolean
gtk_ui_manager_get_add_tearoffs (GtkUIManager *manager)
* menus never have tearoff menu items.
*
* Since: 2.4
+ *
+ * Deprecated: 3.4: Tearoff menus are deprecated and should not
+ * be used in newly written code.
**/
-void
+void
gtk_ui_manager_set_add_tearoffs (GtkUIManager *manager,
- gboolean add_tearoffs)
+ gboolean add_tearoffs)
{
g_return_if_fail (GTK_IS_UI_MANAGER (manager));
+ gtk_ui_manager_do_set_add_tearoffs (manager, add_tearoffs);
+}
+
+static void
+gtk_ui_manager_do_set_add_tearoffs (GtkUIManager *manager,
+ gboolean add_tearoffs)
+{
add_tearoffs = add_tearoffs != FALSE;
if (add_tearoffs != manager->private_data->add_tearoffs)
{
manager->private_data->add_tearoffs = add_tearoffs;
-
+
dirty_all_nodes (manager);
g_object_notify (G_OBJECT (manager), "add-tearoffs");
* with @manager. Actions in earlier groups hide actions with the same
* name in later groups.
*
+ * If @pos is larger than the number of action groups in @manager, or
+ * negative, @action_group will be inserted at the end of the internal
+ * list.
+ *
* Since: 2.4
**/
void
free_node (GNode *node)
{
Node *info = NODE_INFO (node);
-
- g_list_foreach (info->uifiles, (GFunc) node_ui_reference_free, NULL);
- g_list_free (info->uifiles);
- if (info->action)
- g_object_unref (info->action);
- if (info->proxy)
- g_object_unref (info->proxy);
- if (info->extra)
- g_object_unref (info->extra);
- g_free (info->name);
+ g_list_free_full (info->uifiles, node_ui_reference_free);
+ info->uifiles = NULL;
+
+ g_clear_object (&info->action);
+ g_clear_object (&info->proxy);
+ g_clear_object (&info->extra);
+ g_clear_pointer (&info->name, g_free);
g_slice_free (Node, info);
+ node->data = NULL;
return FALSE;
}
return res;
}
+/**
+ * gtk_ui_manager_add_ui_from_resource:
+ * @manager: a #GtkUIManager object
+ * @resource_path: the resource path of the file to parse
+ * @error: return location for an error
+ *
+ * Parses a resource file containing a <link linkend="XML-UI">UI definition</link> and
+ * merges it with the current contents of @manager.
+ *
+ * Return value: The merge id for the merged UI. The merge id can be used
+ * to unmerge the UI with gtk_ui_manager_remove_ui(). If an error occurred,
+ * the return value is 0.
+ *
+ * Since: 3.4
+ **/
+guint
+gtk_ui_manager_add_ui_from_resource (GtkUIManager *manager,
+ const gchar *resource_path,
+ GError **error)
+{
+ GBytes *data;
+ guint res;
+
+ g_return_val_if_fail (GTK_IS_UI_MANAGER (manager), 0);
+
+ data = g_resources_lookup_data (resource_path, 0, error);
+ if (data == NULL)
+ return 0;
+
+ res = add_ui_from_string (manager, g_bytes_get_data (data, NULL), g_bytes_get_size (data), FALSE, error);
+ g_bytes_unref (data);
+
+ return res;
+}
+
/**
* gtk_ui_manager_add_ui:
* @manager: a #GtkUIManager
return TRUE;
}
-/**
- * _gtk_menu_is_empty:
- * @menu: (allow-none): a #GtkMenu or %NULL
- *
- * Determines whether @menu is empty. A menu is considered empty if it
- * the only visible children are tearoff menu items or "filler" menu
- * items which were inserted to mark the menu as empty.
- *
- * This function is used by #GtkAction.
- *
- * Return value: whether @menu is empty.
- **/
-gboolean
-_gtk_menu_is_empty (GtkWidget *menu)
-{
- GList *children, *cur;
- gboolean result = TRUE;
-
- g_return_val_if_fail (menu == NULL || GTK_IS_MENU (menu), TRUE);
-
- if (!menu)
- return FALSE;
-
- children = gtk_container_get_children (GTK_CONTAINER (menu));
-
- cur = children;
- while (cur)
- {
- if (gtk_widget_get_visible (cur->data))
- {
- if (!GTK_IS_TEAROFF_MENU_ITEM (cur->data) &&
- !g_object_get_data (cur->data, "gtk-empty-menu-item"))
- {
- result = FALSE;
- break;
- }
- }
- cur = cur->next;
- }
- g_list_free (children);
-
- return result;
-}
-
enum {
SEPARATOR_MODE_SMART,
SEPARATOR_MODE_VISIBLE,