/*- * Copyright (c) 1999-2000 Robin Ericsson * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $Id: gsfv.c,v 1.5 2000/03/25 10:36:06 lobbin Exp $ */ #include "config.h" #include #include "gsfv.h" #include "callback.h" #include "dirtree.h" static GtkItemFactoryEntry menu_items[] = { { "/_File", NULL, NULL, 0, "" }, { "/File/Quit", "Q", gtk_main_quit, 0, NULL }, { "/_Help", NULL, NULL, 0, "" }, { "/Help/About", NULL, menu_about_cb, 0, NULL }, }; GtkWidget *tree; void get_main_menu (GtkWidget *window, GtkWidget **menubar) { GtkItemFactory *item_factory; GtkAccelGroup *accel_group; gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]); accel_group = gtk_accel_group_new (); item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "
", accel_group); gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL); gtk_accel_group_attach (accel_group, GTK_OBJECT (window)); if (menubar) *menubar = gtk_item_factory_get_widget (item_factory, "
"); } void init_window () { GtkWidget *window; GtkWidget *frame; GtkWidget *rbutton; GtkWidget *box, *box1; GtkWidget *button; GtkWidget *treewin; GtkWidget *menubar, *main_vbox, *sec_main_vbox; GSList *group; gchar *wd; window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_window_set_title (GTK_WINDOW (window), "GTK Simple File Verification v" VERSION ""); gtk_window_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER); gtk_signal_connect (GTK_OBJECT (window), "destroy", GTK_SIGNAL_FUNC (destroy_cb), NULL); main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1); gtk_container_add (GTK_CONTAINER (window), main_vbox); gtk_widget_show (main_vbox); get_main_menu (window, &menubar); gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0); gtk_widget_show (menubar); sec_main_vbox = gtk_vbox_new (FALSE, 1); gtk_container_set_border_width (GTK_CONTAINER (sec_main_vbox), 10); gtk_box_pack_start (GTK_BOX (main_vbox), sec_main_vbox, FALSE, TRUE, 0); gtk_widget_show (sec_main_vbox); frame = gtk_frame_new (" Choose your weapon: "); gtk_box_pack_start (GTK_BOX (sec_main_vbox), frame, FALSE, TRUE, 0); box = gtk_vbox_new (FALSE, 0); gtk_container_add (GTK_CONTAINER (frame), box); gtk_container_set_border_width (GTK_CONTAINER (box), 10); gtk_widget_show (box); gtk_widget_realize (window); wd = g_get_current_dir (); tree = dirtree_new_by_dir (window, "/\0", wd); treewin = gtk_scrolled_window_new (NULL, NULL); gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (treewin), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_widget_set_usize (treewin, 300, 170); gtk_scrolled_window_add_with_viewport (GTK_SCROLLED_WINDOW (treewin), tree); gtk_box_pack_start (GTK_BOX (box), treewin, TRUE, TRUE, 5); gtk_widget_show (tree); gtk_widget_show (treewin); g_free (wd); box1 = gtk_hbox_new (FALSE, 10); gtk_box_pack_start (GTK_BOX (box), box1, TRUE, TRUE, 5); gtk_widget_show (box1); rbutton = gtk_radio_button_new_with_label (NULL, "Verify Files"); gtk_box_pack_start (GTK_BOX (box1), rbutton, FALSE, FALSE, 0); group = gtk_radio_button_group (GTK_RADIO_BUTTON (rbutton)); gtk_widget_show (rbutton); rbutton = gtk_radio_button_new_with_label (group, "Create SFV-File"); gtk_box_pack_start (GTK_BOX (box1), rbutton, FALSE, FALSE, 0); gtk_widget_show (rbutton); button = gtk_button_new_with_label ("Next >>"); gtk_signal_connect (GTK_OBJECT (button), "clicked", GTK_SIGNAL_FUNC (main_next_button_cb), (gpointer) rbutton); gtk_box_pack_start (GTK_BOX (box), button, TRUE, TRUE, 0); gtk_widget_show (button); gtk_widget_show (frame); gtk_widget_show (window); } int main (int argc, char *argv[]) { gtk_init (&argc, &argv); gdk_init (&argc, &argv); init_crc32 (); init_window (); gtk_main ( ); gdk_exit (0); return 0; }