From: Andy M. <asm...@us...> - 2003-04-30 21:57:00
|
Update of /cvsroot/ayttm/ayttm/src/gtk In directory sc8-pr-cvs1:/tmp/cvs-serv32433/src/gtk Modified Files: Makefile.am prefs_window.C Added Files: file_selection_dlg.C Log Message: Move file selection into gtk dir --- NEW FILE: file_selection_dlg.C --- /* * Ayttm * * Copyright (C) 2003, the Ayttm team * * Ayttm is derivative of Everybuddy * Copyright (C) 1999-2002, Torrey Searle <ts...@uc...> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <assert.h> #include <gtk/gtk.h> #include "ui_file_selection_dlg.h" class ay_file_selection_dlg { public: ay_file_selection_dlg( const char *inSelectedFile, const char *inWindowTitle, t_file_selection_callback *inCallback, void *inData ); private: // Gtk callbacks static void s_ok_callback( GtkButton *button, gpointer data ); static void s_cancel_callback( GtkButton *button, gpointer data ); private: GtkWidget *m_dialog; t_file_selection_callback *m_callback; void *m_data; }; #ifdef __cplusplus extern "C" { #endif /// Entry point to this file - construct and display the file selection dialog void ay_ui_do_file_selection( const char *inDefaultFile, const char *inWindowTitle, t_file_selection_callback *inCallback, void *inData ) { new ay_file_selection_dlg( inDefaultFile, inWindowTitle, inCallback, inData ); } #ifdef __cplusplus } #endif //////////////// //// ay_file_selection_dlg implementation ay_file_selection_dlg::ay_file_selection_dlg( const char *inSelectedFile, const char *inWindowTitle, t_file_selection_callback *inCallback, void *inData ) : m_callback( inCallback ), m_data( inData ) { assert( m_callback ); m_dialog = gtk_file_selection_new( inWindowTitle ); gtk_container_set_border_width( GTK_CONTAINER(m_dialog), 10 ); gtk_window_set_modal( GTK_WINDOW(m_dialog), TRUE ); GtkWidget *ok_button = GTK_FILE_SELECTION(m_dialog)->ok_button; gtk_widget_show( ok_button ); GTK_WIDGET_SET_FLAGS( ok_button, GTK_CAN_DEFAULT ); GtkWidget *cancel_button = GTK_FILE_SELECTION(m_dialog)->cancel_button; gtk_widget_show( cancel_button ); GTK_WIDGET_SET_FLAGS( cancel_button, GTK_CAN_DEFAULT ); gtk_signal_connect( GTK_OBJECT(ok_button), "clicked", GTK_SIGNAL_FUNC (s_ok_callback), this ); gtk_signal_connect( GTK_OBJECT(cancel_button), "clicked", GTK_SIGNAL_FUNC(s_cancel_callback), this ); if ( inSelectedFile != NULL ) gtk_file_selection_set_filename( GTK_FILE_SELECTION(m_dialog), inSelectedFile ); gtk_widget_show( m_dialog ); } //// // ay_file_selection_dlg callbacks // s_ok_callback void ay_file_selection_dlg::s_ok_callback( GtkButton *button, void *data ) { ay_file_selection_dlg *the_dlg = reinterpret_cast<ay_file_selection_dlg *>(data); assert( the_dlg != NULL ); const char *selected_file = gtk_file_selection_get_filename( GTK_FILE_SELECTION( the_dlg->m_dialog ) ); (the_dlg->m_callback)( selected_file, the_dlg->m_data ); gtk_widget_destroy( GTK_WIDGET( the_dlg->m_dialog ) ); delete the_dlg; } // s_cancel_callback void ay_file_selection_dlg::s_cancel_callback( GtkButton *button, void *data ) { ay_file_selection_dlg *the_dlg = reinterpret_cast<ay_file_selection_dlg *>(data); assert( the_dlg != NULL ); (the_dlg->m_callback)( NULL, the_dlg->m_data ); gtk_widget_destroy( GTK_WIDGET( the_dlg->m_dialog ) ); delete the_dlg; } Index: Makefile.am =================================================================== RCS file: /cvsroot/ayttm/ayttm/src/gtk/Makefile.am,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- Makefile.am 27 Apr 2003 12:30:42 -0000 1.3 +++ Makefile.am 30 Apr 2003 21:56:46 -0000 1.4 @@ -1,7 +1,7 @@ noinst_LTLIBRARIES = libayttmgtk.la libayttmgtk_la_SOURCES = about_window.c extgtktext.c gtk_eb_html.c gtkspell.c \ - gtkutils.c message_windows.c prefs_window.C + gtkutils.c message_windows.c prefs_window.C file_selection_dlg.C noinst_HEADERS = extgtktext.h gtk_eb_html.h gtkspell.h \ gtkutils.h Index: prefs_window.C =================================================================== RCS file: /cvsroot/ayttm/ayttm/src/gtk/prefs_window.C,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- prefs_window.C 29 Apr 2003 22:47:25 -0000 1.17 +++ prefs_window.C 30 Apr 2003 21:56:46 -0000 1.18 @@ -170,7 +170,7 @@ private: // Gtk callbacks static void s_toggle_checkbox( GtkWidget *widget, int *data ); - static void s_set_browser_path( char *selected_filename, void *data ); + static void s_set_browser_path( const char *selected_filename, void *data ); static void s_get_alt_browser_path( GtkWidget *t_browser_browse_button, int *data ); private: @@ -218,7 +218,7 @@ virtual void Apply( void ); private: // Gtk callbacks - static void s_setsoundfilename( char *selected_filename, void *data ); + static void s_setsoundfilename( const char *selected_filename, void *data ); static void s_getsoundfile( GtkWidget *widget, void *data ); static void s_testsoundfile( GtkWidget *widget, void *data ); static void s_soundvolume_changed( GtkAdjustment *adjust, void *data ); @@ -1056,7 +1056,7 @@ } // s_set_browser_path -void ay_general_panel::s_set_browser_path( char *selected_filename, void *data ) +void ay_general_panel::s_set_browser_path( const char *selected_filename, void *data ) { if ( selected_filename == NULL ) return; @@ -1075,9 +1075,9 @@ ay_general_panel *the_panel = reinterpret_cast<ay_general_panel *>( data ); assert( the_panel != NULL ); - char *alt_browser_text = gtk_entry_get_text( GTK_ENTRY(the_panel->m_alternate_browser_entry) ); - eb_do_file_selector( alt_browser_text, _("Select your browser"), - ay_general_panel::s_set_browser_path, the_panel ); + const char *alt_browser_text = gtk_entry_get_text( GTK_ENTRY(the_panel->m_alternate_browser_entry) ); + + ay_do_file_selection( alt_browser_text, _("Select your browser"), s_set_browser_path, the_panel ); } @@ -1251,7 +1251,7 @@ // ay_sound_files_panel callbacks // s_setsoundfilename -void ay_sound_files_panel::s_setsoundfilename( char *selected_filename, void *data ) +void ay_sound_files_panel::s_setsoundfilename( const char *selected_filename, void *data ) { if ( selected_filename == NULL ) return; @@ -1309,7 +1309,43 @@ t_cb_data *cb_data = reinterpret_cast<t_cb_data *>(data); assert( cb_data != NULL ); - eb_do_file_selector( NULL, _("Select a file to use"), s_setsoundfilename, cb_data ); + const ay_sound_files_panel *the_panel = cb_data->m_panel; + GtkEntry *sound_entry = NULL; + + switch( cb_data->m_sound_id ) + { + case SOUND_BUDDY_ARRIVE: + sound_entry = GTK_ENTRY(the_panel->m_arrivesound_entry); + break; + + case SOUND_BUDDY_LEAVE: + sound_entry = GTK_ENTRY(the_panel->m_leavesound_entry); + break; + + case SOUND_SEND: + sound_entry = GTK_ENTRY(the_panel->m_sendsound_entry); + break; + + case SOUND_RECEIVE: + sound_entry = GTK_ENTRY(the_panel->m_receivesound_entry); + break; + + case SOUND_BUDDY_AWAY: + sound_entry = GTK_ENTRY(the_panel->m_awaysound_entry); + break; + + case SOUND_FIRSTMSG: + sound_entry = GTK_ENTRY(the_panel->m_firstmsgsound_entry); + break; + + default: + assert( false ); + break; + } + + const char *current_sound = gtk_entry_get_text( sound_entry ); + + ay_do_file_selection( current_sound, _("Select a file to use"), s_setsoundfilename, cb_data ); } // s_testsoundfile |