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.
Related
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.
I have a Motif client (running it on Linux). The client displays an array of buttons to the user in a tabular fashion. Obvious choice is the RowColumn widget. I want scrollbars around the array of buttons so I created a ScrolledWidget and place the RowColumn widget inside. I also place a Frame widget around the Row column widget to make it stand out.
Now, the problem. I want to put a button OUTSIDE the array of widgets for Quit. Problem is it not displaying the button. Is this doable?
Any sample code to do this is appreciated.
XmForm contains:
XmPushButton (exit)
XmScrolledWindow contains:
XmFrame contains
XmRowColumn contains:
array of XmPushButtons
Set up the connections for the XmForm to place the exit button and scrolled window appropriately.
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 have code where I populate combo box models by text but first time I see strange behavior.
I use Blade GUI editir to create *.ui file where i generate single empty combobox.
After, I fetch combo from methods and modify/fill my combo.
This is my snippets of code:
GtkWidget *combo_screen_share;
GtkTreeModel *model;
// here I get empty combobox
combo_screen_share=myprog_gtk_get_widget(call_view,"window_screen_stream");
GtkCellRenderer *renderer=gtk_cell_renderer_text_new();
model=GTK_TREE_MODEL((store=gtk_list_store_new(1,G_TYPE_STRING)));
int i;
for(i=0; i<200; i++){
gtk_list_store_append(store,&iter);
gtk_list_store_set(store,&iter,0,"Full Screen",-1);
}
gtk_combo_box_set_model(GTK_COMBO_BOX(combo_screen_share),model);
g_object_unref(G_OBJECT(model));
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(combo_screen_share),renderer,FALSE);
gtk_cell_layout_set_attributes(GTK_CELL_LAYOUT(combo_screen_share),renderer,"text",0,NULL);
gtk_combo_box_set_active(GTK_COMBO_BOX(combo_screen_share),0);
// bind 'onChange' with other method as callback
g_signal_connect(G_OBJECT(combo_screen_share),"changed",(GCallback)gtk_combo_box_new_with_model,NULL);
It should create 200 rows of "Full Screen" string.
However when I click on combobox, I get empty half screen as gap/space and only after all my 200 items.
If I run the loop for 100, space is going to be smaller.
Did someone meet the same thing and know how to fix it?
Thank you,
What you're seeing isn't a "bug" exactly, it's just the way Gtk does combo boxes and you'll have to live with it.
Try another app if you don't believe me --
Open a Gtk app (I used The Gimp)
Find a combo box with several options
Drag the window so that the combo box is near the bottom of the screen
Click on it
When the combo box appears it will have a big empty space at the top, just like yours.
I don't believe there's a fix without patching Gtk itself. For more discussion/rants on this issue see this Launchpad bug and this Gnome Buzilla bug.
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)