static void add_menu(EomDetailWindow *window) { HildonAppMenu *appmenu; GtkWidget *button; appmenu = HILDON_APP_MENU(hildon_app_menu_new()); button = hildon_gtk_button_new(HILDON_SIZE_AUTO); gtk_button_set_label(GTK_BUTTON(button), "Edit..."); g_signal_connect_after(button, "clicked", G_CALLBACK(on_edit), window); hildon_app_menu_append(appmenu, GTK_BUTTON(button)); button = hildon_gtk_button_new(HILDON_SIZE_AUTO); gtk_button_set_label(GTK_BUTTON(button), "Delete..."); g_signal_connect_after(button, "clicked", G_CALLBACK(on_delete), (gpointer)window); hildon_app_menu_append(appmenu, GTK_BUTTON(button)); gtk_widget_show_all(GTK_WIDGET(appmenu)); hildon_stackable_window_set_main_menu( HILDON_STACKABLE_WINDOW(window), appmenu ); }
static HildonAppMenu * create_menu (GtkWidget *label, GtkAccelGroup *accel) { GtkWidget *button; HildonSizeType buttonsize = HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH; HildonAppMenu *menu = HILDON_APP_MENU (hildon_app_menu_new ()); /* Options */ button = hildon_gtk_button_new (buttonsize); gtk_button_set_label (GTK_BUTTON (button), "Menu command one"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_append (menu, GTK_BUTTON (button)); gtk_widget_add_accelerator (button, "activate", accel, GDK_r, GDK_CONTROL_MASK, GTK_ACCEL_VISIBLE); button = hildon_gtk_button_new (buttonsize); gtk_button_set_label (GTK_BUTTON (button), "Menu command two"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_append (menu, GTK_BUTTON (button)); button = hildon_gtk_button_new (buttonsize); gtk_button_set_label (GTK_BUTTON (button), "Menu command three"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_append (menu, GTK_BUTTON (button)); button = hildon_gtk_button_new (buttonsize); gtk_button_set_label (GTK_BUTTON (button), "Menu command four"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_append (menu, GTK_BUTTON (button)); button = hildon_gtk_button_new (buttonsize); gtk_button_set_label (GTK_BUTTON (button), "Menu command five"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_append (menu, GTK_BUTTON (button)); /* Filters */ button = hildon_gtk_radio_button_new (buttonsize, NULL); gtk_button_set_label (GTK_BUTTON (button), "filter one"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_add_filter (menu, GTK_BUTTON (button)); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); button = hildon_gtk_radio_button_new_from_widget (buttonsize, GTK_RADIO_BUTTON (button)); gtk_button_set_label (GTK_BUTTON (button), "filter two"); g_signal_connect_after (button, "clicked", G_CALLBACK (menu_button_clicked), label); hildon_app_menu_add_filter (menu, GTK_BUTTON (button)); gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (button), FALSE); gtk_widget_show_all (GTK_WIDGET (menu)); return menu; }
static GtkWidget * append_menu_button (GtkWidget *menu, const gchar *label) { GtkWidget *btn; btn = hildon_gtk_button_new (HILDON_SIZE_AUTO); gtk_button_set_label (GTK_BUTTON (btn), label); hildon_app_menu_append (HILDON_APP_MENU (menu), GTK_BUTTON (btn)); return btn; }
int main (int argc, char **argv) { GtkWidget *win; GtkWidget *showprogressbutton, *hideprogressbutton; GtkBox *vbox; hildon_gtk_init (&argc, &argv); /* Window and vbox to pack everything */ win = hildon_stackable_window_new (); vbox = GTK_BOX (gtk_vbox_new (FALSE, 10)); /* Buttons */ showprogressbutton = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); gtk_button_set_label (GTK_BUTTON (showprogressbutton), "Show progress indicator"); hideprogressbutton = hildon_gtk_button_new (HILDON_SIZE_FINGER_HEIGHT | HILDON_SIZE_AUTO_WIDTH); gtk_button_set_label (GTK_BUTTON (hideprogressbutton), "Hide progress indicator"); /* Pack all widgets */ gtk_box_pack_start (GTK_BOX (vbox), showprogressbutton, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), hideprogressbutton, TRUE, TRUE, 0); gtk_container_set_border_width (GTK_CONTAINER (win), 20); gtk_container_add (GTK_CONTAINER (win), GTK_WIDGET (vbox)); /* Connect signals */ g_signal_connect (win, "destroy", G_CALLBACK (gtk_main_quit), NULL); g_signal_connect (showprogressbutton, "clicked", G_CALLBACK (show_progress_button_clicked), win); g_signal_connect (hideprogressbutton, "clicked", G_CALLBACK (hide_progress_button_clicked), win); /* Run example */ gtk_widget_show_all (win); gtk_main (); return 0; }