Gtk menu with icons - gtk

This is critical part of my run-time created menu:
GtkWidget *menu, *menu_item;
menu = gtk_menu_new();
menu_item = gtk_image_menu_item_new_with_label("Uredi...");
//approach1 - icon don't work
//gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU));
//approach2 - icon also don't work
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(menu_item), GTK_WIDGET(gtk_image_new_from_stock(GTK_STOCK_EDIT, GTK_ICON_SIZE_MENU)));
gtk_menu_shell_append(GTK_MENU_SHELL(menu), menu_item);
g_signal_connect(G_OBJECT(menu_item), "button-release-event", G_CALLBACK(menu_RELEASE), (gpointer)"");
gtk_menu_attach_to_widget(GTK_MENU(menu), button, NULL);
gtk_widget_show_all(menu);
Menu works OK but this is only one "imagemenuitem" on which I see label but don't see image.
What can be wrong here?
Gtk2, Ubuntu 11.10

I'm not 100% sure, but I believe icons in menus and buttons are no longer enabled by default. You need to turn them on to make them show up.
gconftool-2 --type bool --set /desktop/gnome/interface/menus_have_icons true
Or using dconf:
dconf write /org/gnome/desktop/interface/menus-have-icons true

Hey pretty old question so probably not much use. But I was having a very similar problem with a menu not showing images (in my case it was popup menu triggered by a button).
The way I solved it was calling the
gtk_image_menu_item_set_always_show_image(menu_item,TRUE);
This solved my problem, now my images always show :D woot :) As passing in 1 (true) means it will always show.
Ref:
http://developer.gnome.org/gtk3/3.0/GtkImageMenuItem.html

Related

Custom Icon for Gnome Shell Extension in Top Panel not visible

I try to use a custom SVG for my GNOME shell extension as status icon in top panel. But the custom icon is never shown, just the widget's label text. And I find no error in log output.
When I try to set a build-in icon like "system-search-symbolic" it works, this icon is shown.
This is my code snippet (the SVG is in an "icons" directory of my extension: /home/myusername/.local/share/gnome-shell/extensions/my-widget#my-widgets/icons/timeclock-16x16.svg):
// ...
let widgetBoxLayout = new St.BoxLayout();
let iconPath = `${Me.path}/icons/timeclock-16x16.svg`;
// just for debug if path is correct
log(`${Me.metadata.name}: Icon path=${iconPath}`);
let gicon = Gio.icon_new_for_string(`${iconPath}`);
let icon = new St.Icon({ gicon: gicon, style_class: 'system-status-icon', icon_size: 16 });
// this works for build-in icon:
//let icon = new St.Icon({ icon_name: 'system-search-symbolic', style_class: 'system-status-icon'});
widgetBoxLayout.add(icon);
widgetBoxLayout.add(this.widgetText);
//...
Maybe it's a problem that there is an "#" char in icon path?
But why no error is logged?
What is the correct code to use a custom icon for status panel?
(I have GNOME Shell 3.30.2)
Oh no! This one of these "fight for weeks alone, finally ask the crowd, suddenly know the solution yourself" cases ...
The icon was actually visible but since I use a dark theme and the icon itself is also dark it was not "visible". I inverted the colors of this icon and now I can see the icon next to my text in top panel.
Now I have to find out which icon to use depending on user's theme, but the original issue is solved.
Maybe this answer helps other developer making same stupid error.
You need to use -symbolic icons to allow automatic theme aware re-colorization of the icons. Just change the file name of the icon to timeclock-symbolic.svg, at least this should be your first step if every other aspect is fine.

Xcode 8.2.1 not showing documentation description on autocomplete

I'm having problems adding documentation to my code in Xcode 8.2.1.
Here's my code:
/// Test documentation method
///
/// - Parameter string: The input string
/// - Returns: The output bool
func testMethod(string:String) -> Bool {
if string == "YES" {
return true
}
return false
}
The documentation shows as expected in the quick help window but the description doesn't show in the code autocomplete window.
Is there a way to get the description to show in the autocomplete box as in the image below:
You are right, the descriptions you added to the top of your methods and properties don't appear in the popover anymore.
As noted, you can only see the descriptions of Apple's own methods and properties.
The reason being that Xcode doesn't parse these from their classes but rather from a separate documentation set (which you can find in Xcode's Help/Documentation and API reference tab).
So unless Apple decides to change this, I'm afraid it won't be possible to see your own in the popover.
You could keep an eye on existing doc set generators (AppleDoc, Jazzy), maybe they'll offer a way to link their documentation to Xcode's popover.
Keep in mind that you do see your own comments when opening the quick help popover with alt + click on a method or property.
For me the best way to resolve this is by cleaning the project Shift+Command+K, and if that is not working, it is a god idea to remove Derived Data folder.
To remove this folder go to Xcode preferences, Locations tab
and click on the small arrow to open a finder, and remove manually the folder.
Restart Xcode, and check if now is working
https://developer.apple.com/library/content/documentation/Xcode/Reference/xcode_markup_formatting_ref/MarkupFunctionality.html#//apple_ref/doc/uid/TP40016497-CH54-SW1
please refer the official documentation

WatchKit Extension[4608:145616] Unable to find image named "hello" on Watch

Problem:
Trying to set the WKInterfaceLabel text using xCode 6.2 but it returns this error:
WatchKit Extension[4608:145616] Unable to find image named "hello" on Watch
Code:
#IBOutlet var lblPassword: WKInterfaceLabel!
lblPassword.setText("hello")
Cleaning the project doesn't seem to fix the issue for me. But if you click on the image file, you'll see "Target Membership" options on the right pane. Select all of them, Clean the build and try again.
I got the same error although I am pretty sure these image files exist.
I just terminated Xcode, relaunched it, cleaned the project (command + K) and built it. It started to work again.
I do this routine whenever I face a new problem. It solves most of the problems as you might know. Sorry if you have done it already.
I supposed that you adding image to asset catalog in WatchKit Extension. This is wrong.You should add that image to asset catalog in WatchKit App. Sorry i can't add image here.
Try as I might, my images were not loaded up to the watch until I did it directly by 'caching' as follows in my InterfaceController in the WatchKit Extension:
[[WKInterfaceDevice currentDevice] addCachedImage:[UIImage imageNamed:#"carrota.png"] name:#"carrot"];
[self.portfiolioImage setImageNamed:#"carrot"];
For me, it looks like you have added "hello" as an image name somewhere in the storyboard.
Use XCode's Find dialog to look for "hello". It will show use as an image name, too.
Screen Shot 1
Ok So the keything to note here is that "you do not want to drag and drop the images into the AssetCatalog"......the only way this worked for me was to manually right click on the catalog (as shown in screen shot 1 and "Add Files"....look for the image you want to add on your local/external drive (Making Sure that only the "WatchKit App" Checkmark is selected in the Add to Targets Section" as shown in Screen Shot 2) and add the images!!
Screen Shot 2
i've had the exact same problem. solution: i've exedently connected the group parenting the WKInterfaceLabel. Try setting YOURSUPPOSEDLABLE.setTextColor(.brown), if the Background of it changes, you have connected the group.
So in my case I had copied and pasted a prior row and assigned a diff class.
That duplicated row's group still had an IBOutlet connection to the prior class that I did not catch.
Once I removed that connection this stupid issue resolved itself and I was able to successfully call .setText()

Resize by default TinyMCE

I'm using TinyMCE for the first time, and I love it, but is a bit closed.
I'd like to get images resized by default, this is, when adding an image, put it by default on 300px width, for example (then the user can make it bigger or smaller dragging).
I don't know where to touch! Is there a command within the lists of images (the js you can attach to make TinyMCE show a list of images)? Or I have to hack css? Or I have to dive into TinyMCE code?
Thank you in advance
Marc
If you are OK with changing code files then proceed as follows
Open tiny_mce/plugins/advimage/js/image.js
Locate insertAndClose : function()
Insert after
var ed = tinyMCEPopup.editor, ......;
if(f.width.value == ""){
f.width.value = 300;
}
Hope it helps!
There are several options. I would go the css way. Check out the tinycme init configuration setting content_css. Using an additioanl own css file enables you to setthe width of images to 300px easily.

SWT: How to “render” a Widget in the background / into an offscreenbuffer

I would very much appreciate your advice and help:
How can I render a SWT Widget/Component in the BACKGROUND (offscreenbuffer?) and get the “painted” pixels that were drawn by the Widget/Component to save them on the harddisk:
What I currently have is:
Display display = new Display();
Shell shell = new Shell(display);
// ...
MyWidgetComponent mwc = new MyWidgetComponent(shell, SWT.BORDER);
shell.open();
Image screenshot = new Image(shell.getDisplay(), shell.getBounds());
GC.copyArea(screenshot, 0, 0);
//...
Problem:
Taking the screenshot itself of the shell/widget works, but it will open a new Window in the Taskbar. That is something I do NOT want.
What I want to achieve is:
I want to run this application completely in the background as a “server application” (for example embed and call this into a servlet). So the MyWidgetComponent should be rendered pixel by pixel completely in the offscreenbuffer and I later I retrieve the pixels and save them to the harddisk or directly return the rendered widget as an image as the result of the servlet-request. (I do not want to popup any windows in a server environment, in case this might be a windows server...).
How can I achieve this. I searched a lot but havent found anything useful.
Thank you very much!!
Jan
I can't answer your question directly, but I have run into a similar problem that I struggled with: taking a screenshot of a Shell or Widget while it is obstructed from view.
Consider, for instance, window A that overlaps window B. A screenshot is made of B using your code:
Image screenshot = new Image(shellB.getDisplay(), shellB.getBounds());
GC.copyArea(screenshot, 0, 0);
My findings revealed that this could be done under Windows Vista, Windows 7 and Mac OS X (although I'm unsure about the latter). However, under Windows XP, Linux with GNOME and Linux with KDE, the screenshot contains a white area where the overlapping window obstructs the view.
I haven't found a solution for this, and I suspect that not only is this behavior platform dependent, but also fairly buggy in SWT.
I'd love to hear that I'm off the mark, though!