Trying to add a tray menu to a GTK+ (2.24) application on Windows 10, in C. Code is exactly as in this example, except the icon. The result is as follows, menu is not visible and there are up and down arrows instead:
In this example (French forum, code works when an image is provided), only down arrow appears and it is possible sometimes (1 over 10) to actually display the menu entry by right-clicking long time on the arrow.
Question is: is this a GTK+ bug, as stated in several forums, or is there a way to create a menu from a tray icon using GTK+ without implementing a custom-drawn one?
Edit: replaced wrong GTK2 tag by GTK.
Related
I have written a C-program and am studying GTK and Glade to build a GUI and now I am stuck for at least two days:
I need a notebook with one tab. In this tab is a button, if clicked a new tab is added.
I found: 'gtk_notebook_append_page(notebook_pointer, tab_content_pointer, label)' but whatever I do it doesn't work. Especially I am not sure what to take as tab_content. I get one out of three error messages: it complains that it is top level and can't get a parent or it has already a parent or the new tab just can't be inserted.
Does anyone know what to take in glade to be used as tab_content? Or knows an example where I could learn that?
Or do I need to dump glade and write everything in C-code? I found examples for that.
Thanks for your help.
Draw a notebook with Glade. If you right - click on the tab you want to change, you can delete its contents. (A tab can contain a single widget, though you can put in a HBox or a Grid to combine several).
Once deleted, you can insert any other widget there. Here is an example:
A window with a notebook. First tab contents deleted
Inserted a Box, but by default it's vertical, so...
I changed the property to horizontal
I inserted an image widget in the first space, and a checkbutton in the second. (Change the computer's theme to make is a little more visible.
If you want to add pages from you C-code you can do that too, just get a reference to the notebook, and then modify the tab contents.
As a note, I'd recommend looking at using Python as manager of your GUI. Managing GUIs in Gtk and C - using Glade or not - is tedious. There are several example on the net about how to do that:
-Using Python GTK GUI front end with C++ backend
-How to use GTK+ 3 in Python to manage your whole application
This code adds a new tab perfectly here:
notebook = GTK_WIDGET (gtk_builder_get_object (builder, "notebook1"));
if (!notebook) {
g_critical ("Widget \"%s\" is missing in file %s.",
TOP_WINDOW, "notebook1");
}
tab_label = gtk_label_new ("New page's tab");
page_contents = gtk_label_new ("New page's contents");
gtk_notebook_append_page(notebook, page_contents, tab_label);
Note that you have to put "notebook1" in the ID field of the notebook's widget in Glade.
So my problem is as follows - I need to create buttons in my GTK/C program that are simple clickable, colored tiles. I found this thread GTK Modifying Background Color of GtkButton and a few other resources that supply a very similar answer, but no matter what I do the set_fg function does nothing and set_bg function either sets a thin frame around the button/widget - which itself stays gray - or also does nothing. Can anyone please help me solve this problem or give me a reasonable alternative to creating a set of colored tiles that can be clicked on and that can dynamically change color?
I am 2 days in experimenting with Codename One and Mobile development in general and tested out some basic navigation and features so far. Now I want to work on the look and feel of the app.
I looked at the 9-border vid which was helpful, but not sure of the best way to add an image for the touchCommand that takes 3 tabs on that bar ( Example: home, profile, settings.. Similar to how instagram's TouchCommand is at the bottom of the app).
If I add the image, it does not line up with my Commands.
What is the best way to approach this to ensure the "TouchCommand" image appears as one, but is broken up to 3 parts for each individual commands when pressed, home, profile and settings? I might be asking this all wrong, forgive me as this is all new to me.
Thanks.
EDIT:
This is what was done.
In Theme -> Constants added commandBehavior= bar . This gives the default bar at the bottom. Created in photoshop a new bar 300x80 and added it to the TouchCommand. (See ScreenShot 1). Took this bar and broke it up in photoshop into 3 different buttons for the tab press etc. In GUI Builder, added Home, Profile, Settings in the commands. Added the image to Press Icon for Home and it didnt line up (screenshot 2). Very Frustrating to design layouts. I am hoping there is a much better technique as I am still experimenting with Codename one?
What is unclear to me, is I cant find any documentation on how to approach this and what the dimensions of each image should be as it seems that codename one has issue aligning them. I am assuming the steps would be to create the background image and add the icons as interactive layers for the user. I really care for the image being pressed and changes color like the instagram example. I dont see a way to do this in codename one GUI builder and themes.
EDIT:
Okay, I have decided to use tabs instead of the bar at the bottom. If I add my image to it, I get the results (screeshot 3). Is this the right method to use to accompolish what I want? If so, I dont see a way yet to alter this to become what I want :( .
Plus adding the background, shows one size in the display and looks different in the simulator. (screeshot4)
Answered Here: How do you get ActionBar from SocialBoo theme to show up in your GUI?
Tabs are customized individually so the border should apply for an individual tab to create the background. The foreground element is the icon which you define in the Tabs component itself thru the icons property which allows you to define 3 icons for the 3 tabs (assuming you use the GUI builder). If you add the tabs via addTab in the code you can specify an icon there.
I am trying to solve a problem on a software. I have two windows created with Motif library.
The first window contains 5 buttons (Font 1, 2, 3, 4, Exit), choosing a font affects the text of the other window ("Unacknowledged Updates").
When the second window text is in font 1, and we click on the font 4 or font 3 button, the result consists in displaying a text label cut on the second window.
I have written a prototype to reproduce the bug using the same way of coding and initializing widgets. However, I can not reproduce the bug yet. The thing is, the way of how callbacks are managed in my prototype is far more simple than in the original code which uses Xevent sent to X server.
You can find two screenshots displaying the problem following the link:
---Screenshots---
You will find the prototype code following this link : ---here---
The line to compile : gcc mmm_window.c -lX11 -lXm -lXt -o mmm_window
Solved by forcing redraw of 3 XmForm.
It seems like the problem would come from the size of my label (width, height) which does not adapt when changing fonts. I have tried to set XmNrecomputeSize to true on the concerned widget but it did not help. I keep on searching...
When you create a menu bar, a funny line appears underneath (for XP and Win7 at least). How can I get rid of this line? I know that some applications, such as Firefox and Thunderbird, have done so.
Here's an illustration:
I am programming in C, using the Windows API. My menu is loaded from a resource file.
I'd say that line is supposed to be there (Run a simple application like calc and see) If you look at an application like Explorer (Or IE4-6) in XP, its menu is actually a toolbar inside of a rebar.
If you look at a function like GetMenuBarInfo() you will see there is no border property you can query or set.
If a 1 pixel line is that important, you probably have to A) Do some owner drawing on the menu to paint over that line or B) Implement a custom menu control (MS even has a tutorial for IE/Explorer style menus)