main_pref_window.c

Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: t; c-basic-offset: 4 -*- */
00002 /*
00003  *  main_pref_window.c
00004  *  heraia - an hexadecimal file editor and analyser based on ghex
00005  *
00006  *  (C) Copyright 2008 - 2009 Olivier Delhomme
00007  *  e-mail : heraia@delhomme.org
00008  *  URL    : http://heraia.tuxfamily.org
00009  *
00010  *  This program is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2, or  (at your option)
00013  *  any later version.
00014  *
00015  *  This program is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY;  without even the implied warranty of
00017  *  MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with this program; if not, write to the Free Software
00022  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00023  */
00024 /**
00025  * @file main_pref_window.c
00026  * Handles main preference window 
00027  */
00028 
00029 #include <libheraia.h>
00030 
00031 static gboolean pref_window_delete(GtkWidget *widget, GdkEvent  *event, gpointer data);
00032 static void main_pref_window_connect_signals(heraia_window_t *main_window);
00033 
00034 /* ToolBar buttons */
00035 static void on_mp_tb_fp_bt_toggled(GtkToggleToolButton *toolbutton, gpointer data);
00036 static void on_mp_tb_display_bt_toggled(GtkToggleToolButton *toolbutton, gpointer data);
00037 
00038 /* Toogle Buttons */
00039 static void on_mp_thousand_bt_toggled(GtkToggleButton *togglebutton, gpointer data);
00040 
00041 
00042 /**** The Signals ****/
00043 
00044 /** 
00045  * @fn gboolean pref_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
00046  *  Closing the window 
00047  * @param widget : calling widget (may be NULL as we don't use this here)
00048  * @param event : event associated (may be NULL as we don't use this here)
00049  * @param data : MUST be heraia_window_t *main_window main structure and not NULL
00050  * @return Always returns TRUE in order to propagate the signal 
00051  */
00052 static gboolean pref_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)
00053 {
00054         heraia_window_t *main_window = (heraia_window_t *) data;
00055         GtkWidget *pref_window = NULL;
00056         
00057         if (main_window != NULL && main_window->win_prop != NULL && main_window->win_prop->main_pref_window != NULL)
00058         {
00059                 pref_window = heraia_get_widget(main_window->xmls->main, "main_preferences_window");
00060                 save_main_preferences(main_window);
00061                 record_and_hide_dialog_box(pref_window, main_window->win_prop->main_pref_window);
00062         }
00063         
00064         return TRUE;
00065 }
00066 
00067 /**
00068  * @fn void main_pref_window_connect_signals(heraia_window_t *main_window)
00069  *  Connecting the window signals to the right functions 
00070  * @param main_window : main structure
00071  */
00072 static void main_pref_window_connect_signals(heraia_window_t *main_window)
00073 {
00074         /* Closing the window */
00075         g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "main_preferences_window")), "delete-event",
00076                                          G_CALLBACK(pref_window_delete), main_window);
00077 
00078         /* Clicking on the file preference button of the toolbar */
00079         g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "mp_tb_fp_bt")), "toggled",
00080                                          G_CALLBACK(on_mp_tb_fp_bt_toggled), main_window);
00081         
00082         /* Clicking on the display button of the toolbar */
00083         g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "mp_tb_display_bt")), "toggled",
00084                                          G_CALLBACK(on_mp_tb_display_bt_toggled), main_window);
00085         
00086         /* Toggling the button to choose to display with separated thousand or not */ 
00087         g_signal_connect(G_OBJECT(heraia_get_widget(main_window->xmls->main, "mp_thousand_bt")), "toggled",
00088                                          G_CALLBACK(on_mp_thousand_bt_toggled), main_window);
00089 }
00090 
00091 
00092 /**
00093  * Tool buttons
00094  */
00095 
00096 
00097 /**
00098  * @fn void on_mp_tb_fp_bt_toggled(GtkToolButton *toolbutton, gpointer data)
00099  *  Main Preferences, ToolBar, File Preference Button
00100  * @param toolbutton : button that was clicked
00101  * @param data : user data : MUST be heraia_window_t *main_window main structure
00102  */
00103 static void on_mp_tb_fp_bt_toggled(GtkToggleToolButton *toolbutton, gpointer data)
00104 {
00105         heraia_window_t *main_window = (heraia_window_t *) data;
00106         GtkWidget *notebook = NULL;  /* Main Preference Window's Notebook */
00107         
00108         if (main_window != NULL && main_window->xmls != NULL && main_window->xmls->main != NULL)
00109         {
00110                 notebook = heraia_get_widget(main_window->xmls->main, "mp_first_notebook");
00111                 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 0);
00112         }
00113 }
00114 
00115 
00116 /**
00117  * @fn void on_mp_tb_display_bt_toggled(GtkToolButton *toolbutton, gpointer data)
00118  * Main Preferences, ToolBar, Display Button
00119  * @param toolbutton : button that was clicked
00120  * @param data : user data : MUST be heraia_window_t *main_window main structure
00121  */
00122 static void on_mp_tb_display_bt_toggled(GtkToggleToolButton *toolbutton, gpointer data)
00123 {
00124         heraia_window_t *main_window = (heraia_window_t *) data;
00125         GtkWidget *notebook = NULL;  /* Main Preference Window's Notebook */
00126         
00127         if (main_window != NULL && main_window->xmls != NULL && main_window->xmls->main != NULL)
00128         {
00129         
00130                 notebook = heraia_get_widget(main_window->xmls->main, "mp_first_notebook");
00131                 gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
00132         }
00133 }
00134 
00135 /**
00136  * @fn void on_mp_thousand_bt_toggled(GtkToggleButton *togglebutton, gpointer data)
00137  * Refreshes the file labels as an option has been sat
00138  * @param togglebutton : button that was toggled
00139  * @param data : user data : MUST be heraia_window_t *main_window main structure
00140  */
00141 static void on_mp_thousand_bt_toggled(GtkToggleButton *togglebutton, gpointer data)
00142 {
00143         heraia_window_t *main_window = (heraia_window_t *) data;
00144         
00145         refresh_file_labels(main_window);
00146 }
00147 
00148 /**** End Signals ****/
00149 
00150 
00151 /**
00152  * @fn main_pref_window_init_interface(heraia_window_t *main_window)
00153  *  Inits the main preferences window interface
00154  * @param main_window : main structure
00155  */
00156 void main_pref_window_init_interface(heraia_window_t *main_window)
00157 {
00158         main_pref_window_connect_signals(main_window);
00159 }

Generated on Sat Feb 14 11:44:16 2009 for Heraia by  doxygen 1.5.6