/* * This file is part of Maemo Examples * * Copyright (C) 2005 Nokia Corporation. * * * This software is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public License * as published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this software; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA * 02110-1301 USA * */ /* Includes */ #include #include #include static gint banner_type = 1; GtkWidget *banner = NULL; /* Callback to show information banners */ void show_banner(GtkButton * widget, HildonWindow * window) { switch (banner_type) { case 1: /* Show normal information banner and this automatically goes away */ hildon_banner_show_information(GTK_WIDGET(window), NULL, "Hi there!"); break; case 2: /* Informaton banner with animation icon. This banner does not automatically disapear. */ banner = hildon_banner_show_animation(GTK_WIDGET(window), NULL, "This is animation icon"); break; case 3: /* Remove current information banner */ gtk_widget_destroy(GTK_WIDGET(banner)); break; case 4: /* Information banner with progressbar */ banner = hildon_banner_show_progress(GTK_WIDGET(window), NULL, "Info with progress bar"); /* Set bar to be 20% full */ hildon_banner_set_fraction(HILDON_BANNER(banner), 0.2); break; case 5: /* Set bar to be 80% full */ hildon_banner_set_fraction(HILDON_BANNER(banner), 0.8); break; case 6: /* With sixth click, end the application */ gtk_main_quit(); } /* Increase the counter */ banner_type++; } /* Main application */ int main(int argc, char *argv[]) { /* Create needed variables */ HildonProgram *program; HildonWindow *window; GtkWidget *main_vbox; GtkWidget *button1; /* Initialize the GTK. */ gtk_init(&argc, &argv); /* Create the hildon program and setup the title */ program = HILDON_PROGRAM(hildon_program_get_instance()); g_set_application_name("App Title"); /* Create HildonWindow and set it to HildonProgram */ window = HILDON_WINDOW(hildon_window_new()); hildon_program_add_window(program, window); /* Add vbox to appview */ main_vbox = gtk_vbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(window), main_vbox); /* Add button to vbox */ button1 = gtk_button_new_with_label("Show Info"); gtk_box_pack_start(GTK_BOX(main_vbox), button1, FALSE, TRUE, 0); /* Add signal listener to button */ g_signal_connect(G_OBJECT(button1), "clicked", G_CALLBACK(show_banner), window); /* Connect signal to X in the upper corner */ g_signal_connect(G_OBJECT(window), "delete_event", G_CALLBACK(gtk_main_quit), NULL); /* Begin the main application */ gtk_widget_show_all(GTK_WIDGET(window)); gtk_main(); /* Exit */ return 0; }