Today I tried to work with the GtkMenuButton and I understand it 95%, execept the function:
gtk_menu_button_set_align_widget()
The documentations say:
Sets the [GtkWidget](https://developer.gnome.org/gtk3/stable/GtkWidget.html) to use to line the menu with when popped up. Note that the *`align_widget`* must contain the [GtkMenuButton](https://developer.gnome.org/gtk3/stable/GtkMenuButton.html) itself.
After I read closely I noticed that I am not sure what is the purpose of this Function.
Here is the Code tested:
#include <gtk/gtk.h>
int main ( void )
{
GtkWidget *window;
GtkWidget *box;
GtkWidget *menu_button;
gtk_init ( NULL, NULL );
/* Create the Window*/
window = gtk_window_new ( GTK_WINDOW_TOPLEVEL );
gtk_window_set_default_size ( GTK_WINDOW ( window ), 300, 300 );
g_signal_connect ( window, "delete-event", gtk_main_quit, NULL );
g_signal_connect ( window, "destroy", gtk_main_quit, NULL );
/* Create the Box which holds the Menu Button*/
box = gtk_box_new ( GTK_ORIENTATION_HORIZONTAL, 5 );
gtk_container_add ( GTK_CONTAINER ( window ), box );
/* Create the Menu Button*/
menu_button = gtk_menu_button_new();
gtk_widget_set_sensitive( menu_button, TRUE );
gtk_widget_set_valign ( menu_button, GTK_ALIGN_START );
gtk_box_set_center_widget ( GTK_BOX ( box ), menu_button );
/* BOX holds the Menu Button*/
/* Set the Box as align widget for Menu Button*/
gtk_menu_button_set_align_widget ( GTK_MENU_BUTTON ( menu_button ), box );
/* Set the Button Menu Direction*/
gtk_menu_button_set_direction ( GTK_MENU_BUTTON ( menu_button ), GTK_ARROW_LEFT );
/* Create the Image for Menu Button*/
GtkWidget *img = gtk_image_new_from_icon_name ( "emblem-system-symbolic", GTK_ICON_SIZE_BUTTON );
gtk_container_add ( GTK_CONTAINER ( menu_button ), img );
/// ***
gtk_widget_show_all ( window );
gtk_main ();
}
At this point the Menu Button behaves just like its a GtktoggleButton.