ui/gtk/menu.h

Sun, 22 Dec 2024 11:49:59 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Sun, 22 Dec 2024 11:49:59 +0100
branch
newapi
changeset 420
28a5920bebe0
parent 389
d15eca5fd8b3
permissions
-rw-r--r--

implement menu itemlist (Motif)

/*
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright 2017 Olaf Wintermann. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *   1. Redistributions of source code must retain the above copyright
 *      notice, this list of conditions and the following disclaimer.
 *
 *   2. Redistributions in binary form must reproduce the above copyright
 *      notice, this list of conditions and the following disclaimer in the
 *      documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef MENU_H
#define	MENU_H

#include "../ui/menu.h"
#include "../common/menu.h"
#include <cx/list.h>
#include "toolkit.h"


#ifdef	__cplusplus
extern "C" {
#endif
    
UIMENU ui_create_menu(UiMenuBuilder *builder, UiObject *obj);
void ui_widget_set_contextmenu(GtkWidget *widget, UIMENU menu);
    
#if GTK_MAJOR_VERSION <= 3

typedef struct UiActiveMenuItemList UiActiveMenuItemList;

typedef void(*ui_menu_add_f)(GtkWidget *, int, UiMenuItemI*, UiObject*);

struct UiActiveMenuItemList {
    UiObject         *object;
    GtkMenuShell     *menu;
    int              index;
    int              oldcount;
    UiList           *list;
    ui_getvaluefunc getvalue;
    ui_callback     callback;
    void            *userdata;
};

GtkWidget *ui_create_menubar(UiObject *obj);

void ui_add_menu_items(GtkWidget *parent, int i, UiMenu *menu, UiObject *obj);

void add_menu_widget(GtkWidget *parent, int i, UiMenuItemI *item, UiObject *obj);
void add_menuitem_widget(GtkWidget *parent, int i, UiMenuItemI *item, UiObject *obj);
void add_menuitem_st_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
void add_menuseparator_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
void add_checkitem_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
void add_radioitem_widget(GtkWidget *p, int index, UiMenuItemI *item, UiObject *obj);
void add_checkitemnv_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);
void add_menuitem_list_widget(GtkWidget *p, int i, UiMenuItemI *item, UiObject *obj);

void ui_update_menuitem_list(UiEvent *event, UiActiveMenuItemList *list);
void ui_menu_event_wrapper(GtkMenuItem *item, UiEventData *event);
void ui_menu_event_toggled(GtkCheckMenuItem *ci, UiEventData *event);
int64_t ui_checkitem_get(UiInteger *i);
void ui_checkitem_set(UiInteger *i, int64_t value);

#endif /* GTK_MAJOR_VERSION <= 3 */

#if GTK_MAJOR_VERSION >= 4

typedef void(*ui_gmenu_add_f)(GMenu *, int, UiMenuItemI*, UiObject*);

typedef struct UiActiveGMenuItemList UiActiveGMenuItemList;
struct UiActiveGMenuItemList {
    UiObject         *object;
    GMenu            *menu;
    char             action[32];
    int              index;
    int              oldcount;
    UiVar            *var;
    ui_getvaluefunc  getvalue;
    ui_callback      callback;
    void             *userdata;
};

void ui_gmenu_add_menu_items(GMenu *parent, int i, UiMenu *menu, UiObject *obj);

void ui_gmenu_add_menu(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj);
void ui_gmenu_add_menuitem(GMenu *parent, int index, UiMenuItemI *item, UiObject *obj);
void ui_gmenu_add_menuseparator(GMenu *p, int index, UiMenuItemI *item, UiObject *obj);
void ui_gmenu_add_checkitem(GMenu *p, int index, UiMenuItemI *item, UiObject *obj);
void ui_gmenu_add_radioitem(GMenu *p, int index, UiMenuItemI *item, UiObject *obj);
void ui_gmenu_add_menuitem_list(GMenu *p, int index, UiMenuItemI *item, UiObject *obj);

void ui_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEventData *event);
void ui_menu_list_item_activate_event_wrapper(GSimpleAction* self, GVariant* parameter, UiEventData *event);
void ui_update_gmenu_item_list(UiEvent *event, UiActiveGMenuItemList *list);

#endif


#ifdef	__cplusplus
}
#endif

#endif	/* MENU_H */

mercurial