<table><tr><td style="">rilian added a comment.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D10461" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>If you need help, I will provide it for you, because for me there is 2 features which should be in KDE for me:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Global Menu (for all protocols)</li>
<li class="remarkup-list-item">QGtkStyle (with GTK3 themes)</li>
</ol>



<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>Okay. Problem is that for example LibreOffice doesn't have a menu right away, so I can't realy tell "no menu because it's still loading" or "no menu because it doesn't have one" and then fallback to app menu. I could perhaps check if the app has an appmenu at all before trying to fallback but not really fond of adding even more complexity to it.</p></blockquote>

<p>I too because MenuModel can be empty on start, and I cannot differ than user turned menu off or just application do not have a menu?<br />
About searching of appmenu and fallback to it - LibreOffice have both appmenu and menubar, so, we will lose LibreOffice menu.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>What kind of different actions? So far I have only had redundancy in the app menu, I'll try to look into this, merging two separate menus into one somehow, also getting the app name for the app menu..</p></blockquote>

<p>It can be actions (GActions, I mean) than exists only in appmenu, but not in menubar. User may want this.</p>

<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>How am I supposed to know which action belongs where?</p></blockquote>

<p>But all menuitems have "action" attribute)<br />
Or if you about a QAction (which, I think, should called QMenuItem), this is several ways to do this:</p>

<ol class="remarkup-list">
<li class="remarkup-list-item">Look for each section, name it by some action-name regex (as you did with icons) and then show it as menubar.</li>
<li class="remarkup-list-item">Or just do it with each menuitem, but it is way more complicated. I suggest a section-way.</li>
</ol>



<blockquote style="border-left: 3px solid #a7b5bf; color: #464c5c; font-style: italic; margin: 4px 0 12px 0; padding: 4px 12px; background-color: #f8f9fc;"><p>That was just for the icon mapping, I can probably remove this, since the actions in unity are just their localized labels plus unity. prefix, there's nothing I can map them to (like I would be able to window.open to document-open icon)</p></blockquote>

<p>I think you do not need mapping, because we have a bunch of this code:</p>

<div class="remarkup-code-block" style="margin: 12px 0;" data-code-lang="text" data-sigil="remarkup-code-block"><pre class="remarkup-code" style="font: 11px/15px "Menlo", "Consolas", "Monaco", monospace; padding: 12px; margin: 0; background: rgba(71, 87, 120, 0.08);">C
static GtkImage *gtk_menu_item_get_nth_image(GtkMenuItem *menu_item, guint index)
{
        UnityGtkSearch search;

        g_return_val_if_fail(GTK_IS_MENU_ITEM(menu_item), NULL);

        search.type   = GTK_TYPE_IMAGE;
        search.index  = index;
        search.object = NULL;

        g_object_get_nth_object(G_OBJECT(menu_item), &search);

        return search.object != NULL ? GTK_IMAGE(search.object) : NULL;
}

static GIcon *gtk_image_get_icon(GtkImage *image)
{
        GIcon *icon = NULL;

        g_return_val_if_fail(GTK_IS_IMAGE(image), NULL);

        switch (gtk_image_get_storage_type(image))
        {
        case GTK_IMAGE_GICON:
        {
                gtk_image_get_gicon(image, &icon, NULL);

                if (icon != NULL)
                        g_object_ref(icon);
        }

        break;

        case GTK_IMAGE_ICON_NAME:
        {
                const char *name = NULL;

                gtk_image_get_icon_name(image, &name, NULL);

                if (name != NULL)
                        icon = G_ICON(g_themed_icon_new_with_default_fallbacks(name));
        }

        break;

        case GTK_IMAGE_PIXBUF:
        {
                GdkPixbuf *pixbuf = gtk_image_get_pixbuf(image);

                if (pixbuf != NULL)
                        icon = g_object_ref(pixbuf);
        }

        break;

        case GTK_IMAGE_ANIMATION:
        {
                GdkPixbufAnimation *animation = gtk_image_get_animation(image);

                if (animation != NULL)
                {
                        GdkPixbuf *pixbuf = gdk_pixbuf_animation_get_static_image(animation);

                        if (pixbuf != NULL)
                                icon = g_object_ref(pixbuf);
                }
        }

        break;

        case GTK_IMAGE_STOCK:
#if GTK_MAJOR_VERSION == 2
        {
                char *stock      = NULL;
                GtkIconSize size = GTK_ICON_SIZE_INVALID;

                gtk_image_get_stock(image, &stock, &size);

                if (stock != NULL)
                {
                        GdkPixbuf *pixbuf =
                            gtk_widget_render_icon(GTK_WIDGET(image), stock, size, NULL);

                        if (pixbuf != NULL)
                                icon = G_ICON(pixbuf);
                }
        }
#elif GTK_MAJOR_VERSION == 3
        {
                GtkStyleContext *context = gtk_widget_get_style_context(GTK_WIDGET(image));

                if (context != NULL)
                {
                        char *stock      = NULL;
                        GtkIconSize size = GTK_ICON_SIZE_INVALID;

                        gtk_image_get_stock(image, &stock, &size);

                        if (stock != NULL)
                        {
                                GtkIconSet *set = gtk_style_context_lookup_icon_set(context, stock);

                                if (set != NULL)
                                {
                                        GdkPixbuf *pixbuf =
                                            gtk_icon_set_render_icon_pixbuf(set, context, size);

                                        if (pixbuf != NULL)
                                                icon = G_ICON(pixbuf);
                                }
                        }
                }
        }
#endif

        break;

        case GTK_IMAGE_ICON_SET:
#if GTK_MAJOR_VERSION == 2
        {
                GtkIconSet *set  = NULL;
                GtkIconSize size = GTK_ICON_SIZE_INVALID;

                gtk_image_get_icon_set(image, &set, &size);

                if (set != NULL)
                {
                        GtkStyle *style            = gtk_widget_get_style(GTK_WIDGET(image));
                        GtkTextDirection direction = gtk_widget_get_direction(GTK_WIDGET(image));
                        GtkStateType state         = gtk_widget_get_state(GTK_WIDGET(image));
                        GdkPixbuf *pixbuf          = gtk_icon_set_render_icon(set,
                                                                     style,
                                                                     direction,
                                                                     state,
                                                                     size,
                                                                     GTK_WIDGET(image),
                                                                     NULL);

                        if (pixbuf != NULL)
                                icon = G_ICON(pixbuf);
                }
        }
#elif GTK_MAJOR_VERSION == 3
        {
                GtkStyleContext *context = gtk_widget_get_style_context(GTK_WIDGET(image));

                if (context != NULL)
                {
                        GtkIconSet *set  = NULL;
                        GtkIconSize size = GTK_ICON_SIZE_INVALID;

                        gtk_image_get_icon_set(image, &set, &size);

                        if (set != NULL)
                        {
                                GdkPixbuf *pixbuf =
                                    gtk_icon_set_render_icon_pixbuf(set, context, size);

                                if (pixbuf != NULL)
                                        icon = G_ICON(pixbuf);
                        }
                }
        }
#endif

        break;

#if GTK_MAJOR_VERSION == 2
        case GTK_IMAGE_IMAGE:
        {
                GdkImage *gdk_image = NULL;

                gtk_image_get_image(image, &gdk_image, NULL);

                if (gdk_image != NULL)
                {
                        GdkColormap *colourmap = gtk_widget_get_colormap(GTK_WIDGET(image));
                        GdkPixbuf *pixbuf      = gdk_pixbuf_get_from_image(NULL,
                                                                      gdk_image,
                                                                      colourmap,
                                                                      0,
                                                                      0,
                                                                      0,
                                                                      0,
                                                                      gdk_image->width,
                                                                      gdk_image->height);

                        if (pixbuf != NULL)
                                icon = G_ICON(pixbuf);
                }
        }

        break;

        case GTK_IMAGE_PIXMAP:
        {
                GdkPixmap *pixmap = NULL;

                gtk_image_get_pixmap(image, &pixmap, NULL);

                if (pixmap != NULL)
                {
                        GdkPixbuf *pixbuf;
                        GdkColormap *colourmap;
                        gint width  = 0;
                        gint height = 0;

                        gdk_pixmap_get_size(pixmap, &width, &height);
                        colourmap = gtk_widget_get_colormap(GTK_WIDGET(image));
                        pixbuf    = gdk_pixbuf_get_from_drawable(NULL,
                                                              pixmap,
                                                              colourmap,
                                                              0,
                                                              0,
                                                              0,
                                                              0,
                                                              width,
                                                              height);

                        if (pixbuf != NULL)
                                icon = G_ICON(pixbuf);
                }
        }

        break;
#endif

        default:
                break;
        }

        return icon;
}</pre></div>

<p>If any icon can be found, appmenu-gtk-module will export this.<br />
And I will temporary disable exporting an empty menubar to MenuModel in appmenu-gtk-module.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R120 Plasma Workspace</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D10461" rel="noreferrer">https://phabricator.kde.org/D10461</a></div></div><br /><div><strong>To: </strong>broulik, Plasma<br /><strong>Cc: </strong>rk, rilian, mtallur, ngraham, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart<br /></div>