/** *Example for statusbar and progressbar usage **/ int main(void) { // Status bar statusbar *status = statusbar_new("Indeterminate"); for (int i=0; i<30; i++) { usleep(SLEEP_MS); statusbar_inc(status); } statusbar_finish(status); status = statusbar_new("Status bar with a really long label"); for (int i=0; i<10; i++) { usleep(SLEEP_MS); statusbar_inc(status); } statusbar_finish(status); status = statusbar_new_with_format("Custom","(|)|"); for (int i=0; i<30; i++) { usleep(SLEEP_MS); statusbar_inc(status); } statusbar_finish(status); // Progress bar int max = 240; progressbar *progress = progressbar_new("Smooth",max); for(int i=0;i<max;i++) { usleep(SLEEP_MS); progressbar_inc(progress); } progressbar_finish(progress); progress = progressbar_new("Three Second Task with a long label",3); for(int i=0;i<3;i++) { progressbar_inc(progress); sleep(1); } progressbar_finish(progress); progress = progressbar_new("Fast",100); for(int i=0;i<100;i++) { usleep(SLEEP_MS); progressbar_inc(progress); } progressbar_finish(progress); }
static void construct_widgets (GpaCardManager *cardman) { GtkWidget *vbox; GtkWidget *hbox, *hbox1, *hbox2; GtkWidget *label; GtkWidget *icon; gchar *markup; GtkWidget *menubar; GtkWidget *toolbar; GtkWidget *statusbar; /* Set a default size for the main window. */ gtk_window_set_default_size (GTK_WINDOW (cardman), 680, 480); /* Realize the window so that we can create pixmaps without warnings. */ gtk_widget_realize (GTK_WIDGET (cardman)); /* Use a vbox to show the menu, toolbar and the file container. */ vbox = gtk_vbox_new (FALSE, 0); /* Get the menu and the toolbar. */ cardman_action_new (cardman, &menubar, &toolbar); gtk_box_pack_start (GTK_BOX (vbox), menubar, FALSE, TRUE, 0); gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, TRUE, 0); /* Add a fancy label that tells us: This is the card manager. */ hbox1 = gtk_hbox_new (FALSE, 0); icon = gtk_image_new_from_stock (GPA_STOCK_CARDMAN, GTK_ICON_SIZE_DND); gtk_box_pack_start (GTK_BOX (hbox1), icon, FALSE, TRUE, 0); label = gtk_label_new (NULL); markup = g_strdup_printf ("<span font_desc=\"16\">%s</span>", _("Card Manager")); gtk_label_set_markup (GTK_LABEL (label), markup); g_free (markup); gtk_box_pack_start (GTK_BOX (hbox1), label, TRUE, TRUE, 10); gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); /* Add a application selection box. */ hbox2 = gtk_hbox_new (FALSE, 0); label = gtk_label_new (_("Application selection:")); gtk_box_pack_start (GTK_BOX (hbox2), label, FALSE, TRUE, 5); cardman->app_selector = gtk_combo_box_new_text (); gtk_combo_box_append_text (GTK_COMBO_BOX (cardman->app_selector), _("Auto")); gtk_combo_box_set_active (GTK_COMBO_BOX (cardman->app_selector), 0); gtk_box_pack_start (GTK_BOX (hbox2), cardman->app_selector, FALSE, TRUE, 0); /* Put Card Manager label and application selector into the same line. */ hbox = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox), hbox1, FALSE, FALSE, 0); gtk_box_pack_end (GTK_BOX (hbox), hbox2, FALSE, FALSE, 0); gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, TRUE, 5); /* Create a container (a scolled window) which will take the actual card widget. This container is required so that we can easily change to a differet card widget. */ cardman->card_container = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (cardman->card_container), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start (GTK_BOX (vbox), cardman->card_container, TRUE, TRUE, 0); /* Update the container using the current card application. */ update_card_widget (cardman, NULL); statusbar = statusbar_new (cardman); gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0); gtk_container_add (GTK_CONTAINER (cardman), vbox); }