D10461: GMenu-DBusMenu-Proxy
Konstantin
noreply at phabricator.kde.org
Wed Feb 14 15:23:19 UTC 2018
rilian added a comment.
If you need help, I will provide it for you, because for me there is 2 features which should be in KDE for me:
1. Global Menu (for all protocols)
2. QGtkStyle (with GTK3 themes)
> 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.
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?
About searching of appmenu and fallback to it - LibreOffice have both appmenu and menubar, so, we will lose LibreOffice menu.
> 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..
It can be actions (GActions, I mean) than exists only in appmenu, but not in menubar. User may want this.
> How am I supposed to know which action belongs where?
But all menuitems have "action" attribute)
Or if you about a QAction (which, I think, should called QMenuItem), this is several ways to do this:
1. Look for each section, name it by some action-name regex (as you did with icons) and then show it as menubar.
2. Or just do it with each menuitem, but it is way more complicated. I suggest a section-way.
> 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)
I think you do not need mapping, because we have a bunch of this code:
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;
}
If any icon can be found, appmenu-gtk-module will export this.
And I will temporary disable exporting an empty menubar to MenuModel in appmenu-gtk-module.
REPOSITORY
R120 Plasma Workspace
REVISION DETAIL
https://phabricator.kde.org/D10461
To: broulik, #plasma
Cc: rk, rilian, mtallur, ngraham, plasma-devel, ZrenBot, progwolff, lesliezhai, ali-mohamed, jensreuterberg, abetts, sebas, apol, mart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20180214/b422ab3c/attachment.html>
More information about the Plasma-devel
mailing list