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 - 2010 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_struct_t *main_struct);
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_struct_t *main_struct 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_struct_t *main_struct = (heraia_struct_t *) data;
00055     GtkWidget *pref_window = NULL;
00056 
00057     if (main_struct != NULL && main_struct->win_prop != NULL && main_struct->win_prop->main_pref_window != NULL)
00058         {
00059             pref_window = heraia_get_widget(main_struct->xmls->main, "main_preferences_window");
00060             save_preferences(main_struct);
00061             record_and_hide_dialog_box(pref_window, main_struct->win_prop->main_pref_window);
00062         }
00063 
00064     return TRUE;
00065 }
00066 
00067 
00068 /**
00069  * @fn void main_pref_window_connect_signals(heraia_struct_t *main_struct)
00070  *  Connecting the window signals to the right functions
00071  * @param main_struct : main structure
00072  */
00073 static void main_pref_window_connect_signals(heraia_struct_t *main_struct)
00074 {
00075     /* Closing the window */
00076     g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "main_preferences_window")), "delete-event",
00077                      G_CALLBACK(pref_window_delete), main_struct);
00078 
00079     /* Clicking on the file preference button of the toolbar */
00080     g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "mp_tb_fp_bt")), "toggled",
00081                      G_CALLBACK(on_mp_tb_fp_bt_toggled), main_struct);
00082 
00083     /* Clicking on the display button of the toolbar */
00084     g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "mp_tb_display_bt")), "toggled",
00085                      G_CALLBACK(on_mp_tb_display_bt_toggled), main_struct);
00086 
00087     /* Toggling the button to choose to display with separated thousand or not */
00088     g_signal_connect(G_OBJECT(heraia_get_widget(main_struct->xmls->main, "mp_thousand_bt")), "toggled",
00089                      G_CALLBACK(on_mp_thousand_bt_toggled), main_struct);
00090 }
00091 
00092 
00093 /**
00094  * Tool buttons
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_struct_t *main_struct main structure
00102  */
00103 static void on_mp_tb_fp_bt_toggled(GtkToggleToolButton *toolbutton, gpointer data)
00104 {
00105     heraia_struct_t *main_struct = (heraia_struct_t *) data;
00106     GtkWidget *notebook = NULL;  /* Main Preference Window's Notebook */
00107 
00108     if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
00109         {
00110             notebook = heraia_get_widget(main_struct->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_struct_t *main_struct main structure
00121  */
00122 static void on_mp_tb_display_bt_toggled(GtkToggleToolButton *toolbutton, gpointer data)
00123 {
00124     heraia_struct_t *main_struct = (heraia_struct_t *) data;
00125     GtkWidget *notebook = NULL;  /* Main Preference Window's Notebook */
00126 
00127     if (main_struct != NULL && main_struct->xmls != NULL && main_struct->xmls->main != NULL)
00128         {
00129 
00130             notebook = heraia_get_widget(main_struct->xmls->main, "mp_first_notebook");
00131             gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), 1);
00132         }
00133 }
00134 
00135 
00136 /**
00137  * @fn void on_mp_thousand_bt_toggled(GtkToggleButton *togglebutton, gpointer data)
00138  * Refreshes the file labels as an option has been sat
00139  * @param togglebutton : button that was toggled
00140  * @param data : user data : MUST be heraia_struct_t *main_struct main structure
00141  */
00142 static void on_mp_thousand_bt_toggled(GtkToggleButton *togglebutton, gpointer data)
00143 {
00144     heraia_struct_t *main_struct = (heraia_struct_t *) data;
00145 
00146     refresh_file_labels(main_struct);
00147 }
00148 
00149 /******************************** End Signals *********************************/
00150 
00151 
00152 /**
00153  * @fn main_pref_window_init_interface(heraia_struct_t *main_struct)
00154  *  Inits the main preferences window interface
00155  * @param main_struct : main structure
00156  */
00157 void main_pref_window_init_interface(heraia_struct_t *main_struct)
00158 {
00159     main_pref_window_connect_signals(main_struct);
00160 }
Generated on Tue May 11 18:46:08 2010 for Heraia by  doxygen 1.6.3