[ Pobierz całość w formacie PDF ]
.if (current_page == DISK_PAGE){entry1 = lookup_widget(GTK_WIDGET (button), "diskid_spinbutton");diskid = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON (entry1));clist = GTK_CLIST(lookup_widget(GTK_WIDGET(button),"disk_search_clist"));dvd_gui_show_result("disk_search",dvd_disk_search(diskid, &ids, &count));g_slist_free(disk_search_slist);disk_search_slist = NULL;appbar_text = g_strdup_printf("Found %d Disk(s) for Title ID %d",R-09-07.doc Strona 52z 67 count, diskid );gnome_appbar_set_status(GNOME_APPBAR (lookup_widget(GTK_WIDGET (button), "search_appbar")), appbar_text);while (count--)disk_search_slist = g_slist_append(disk_search_slist,GINT_TO_POINTER(ids[i++]));update_disk_search_clist();}g_free(appbar_text);}on_search_close_clickedvoidon_search_close_clicked (GtkButton *button,gpointer user_data){gtk_widget_hide(search_window);}on_search_clear_clickedFunkcja ta oczyszcza zawartość listy clist na aktualnie otwartej zakładce:voidon_search_close_clicked (GtkButton *button,gpointer user_data){gint current_page;GtkWidget *search_notebook;GtkWidget *clist;search_notebook = lookup_widget (GTK_WIDGET (button), "search_notebook");R-09-07.doc Strona 53z 67 current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(search_notebook));switch (current_page){case TITLE_PAGE:clist = lookup_widget (GTK_WIDGET (button), "title_search_clist");break;case MEMBER_PAGE:clist = lookup_widget (GTK_WIDGET (button), "member_search_clist");break;case DISK_PAGE:clist = lookup_widget (GTK_WIDGET (button), "disk_search_clist");break;default:g_assert_not_reached();}gtk_clist_clear (GTK_CLIST (clist));gnome_appbar_set_status(GNOME_APPBAR (lookup_widget(GTK_WIDGET (button), "search_appbar")), "Cleared");}on_dvd_search_clist_button_press_eventTa funkcja wyświetla odpowiednie menu kontekstowe po naciśnięciu prawego klawisza myszywewnątrz listy clist zawierającej tytuły lub klientów.gbooleanon_dvd_search_clist_button_press_event (GtkWidget *widget,GdkEventButton *event,gpointer user_data){GtkWidget *menu;GtkCList *clist;gint row, column;g_return_val_if_fail(widget != NULL, FALSE);R-09-07.doc Strona 54z 67 menu = create_dvd_popup_menu();if (event->type == GDK_BUTTON_PRESS){GdkEventButton *buttonevent = (GdkEventButton *) event;if ( buttonevent->button == GDK_BUTTON1_MASK ){clist = GTK_CLIST(widget);if (gtk_clist_get_selection_info(clist,buttonevent->x,buttonevent->y,&row,&column)) {gtk_clist_select_rows(clist, row, column);selected_row = row;gtk_menu_popup ( GTK_MENU (menu), NULL, NULL, NULL, NULL,buttonevent->button, 0 );return TRUE;}}}return FALSE;}Pozostałe funkcje są wywołaniami zwrotnymi dla czterech pozycji menu kontekstowego: Rent,Reserve, Edit oraz Delete.on_search_menu_rent_activateFunkcja ta stwierdza, czy otwarta jest zakładka dla tytułów, czy dla klientów; następnie wywołujedo_rent_dvd_dialog, przekazując jako argument identyfikator tytułu lub klienta dla wybranegowiersza:voidon_search_menu_rent_activate (GtkMenuItem *menuitem,gpointer user_data){gint current_page;R-09-07.doc Strona 55z 67 gint id;dvd_store_member member;current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(lookup_widget(search_window, "search_notebook")));if (current_page == TITLE_PAGE){g_return_if_fail (title_search_slist != NULL);id = GPOINTER_TO_INT(G_slist_nth_data(title_search_slist,selected_row));do_rent_dvd_dialog(NULL, id);}if (current_page == MEMBER_PAGE) {g_return_if_fail (member_search_slist != NULL);id = GPOINTER_TO_INT(g_slist_nth_data(member_search_slist,selected_row));dvd_member_get(id, &member);do_rent_dvd_dialog(member.member_no, 0);}}on_search_menu_edit_activatevoidon_search_menu_edit_activate (GtkMenuItem *menuitem,gpointer user_data){gint current_page;gint id;g_return_if_fail (search_window != NULL);current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(lookup_widget(search_window, "search_notebook")));if (current_page == TITLE_PAGE){g_return_if_fail (title_search_slist != NULL);R-09-07.doc Strona 56z 67 id = GPOINTER_TO_INT(g_slist_nth_data(title_search_slist,selected_row));do_dvd_dialog(id);}if (current_page == MEMBER_PAGE){g_return_if_fail (member_search_slist != NULL);id = GPOINTER_TO_INT(g_slist_nth_data(member_search_slist,selected_row));do_member_dialog(id);}}on_search_menu_delete_activateFunkcja delete_activate żąda od użytkownika potwierdzenia zamiaru usunięcia wybranejpozycji z listy tytułów lub klientów, wyświetlając okno dialogowe Gnome:voidon_search_menu_delete_activate (GtkMenuItem *menuitem,gpointer user_data){GtkWidget *dialog;gint id;gint reply;gint current_page;g_return_if_fail (search_window != NULL);current_page = gtk_notebook_get_current_page (GTK_NOTEBOOK(lookup_widget(search_window, "search_notebook")));if (current_page == TITLE_PAGE){g_return_if_fail (title_search_slist != NULL);id = GPOINTER_TO_INT(g_slist_nth_data(title_search_slist,selected_row));dialog = gnome_message_box_new(_("Delete this Title?"),GNOME_MESSAGE_BOX_QUESTION,R-09-07.doc Strona 57z 67 GNOME_STOCK_BUTTON_YES,GNOME_STOCK_BUTTON_NO,NULL);gtk_widget_show(dialog);reply = gnome_dialog_run(GNOME_DIALOG(dialog));if (reply == GNOME_OK) {dvd_title_delete(id);title_search_slist = g_slist_remove (title_search_slist,GINT_TO_POINTER(id));update_title_search_clist();}}if (current_page == MEMBER_PAGE){g_return_if_fail (member_search_slist != NULL);id = GPOINTER_TO_INT(g_slist_nth_data(member_search_slist,selected_row));dialog = gnome_message_box_new(_("Delete this Member?"),GNOME_MESSAGE_BOX_QUESTION,GNOME_STOCK_BUTTON_OK,GNOME_STOCK_BUTTON_CANCEL,NULL);reply = gnome_dialog_run(GNOME_DIALOG(dialog));if (reply == GNOME_OK){dvd_member_delete(id);member_search_slsist = g_slist_remove (member_search_slist,GINT_TO_POINTER(id));update_member_search_clist();}}}on_search_menu_reserve_activateR-09-07
[ Pobierz całość w formacie PDF ]