Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ----------------------------------------------------------------------------
- * ginterface.h -- graphic interface
- * Main module header
- * ----------------------------------------------------------------------------
- * copyright (c) 2006 Jérôme BENHAÏM <benhaimjerome@gmail.com>, Mirsal ENNAIME <mirsal.ennaime@gmail.com>
- *
- * ----------------------------------------------------------------------------
- * 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.
- * ----------------------------------------------------------------------------
- * Before attempting to install gtkmm 2.4, you might first need to install these other packages.
- * libsigc++ 2.0
- * GTK+ 2.4
- * cairomm
- *These dependencies have their own dependencies, including the following applications and libraries:
- * pkg-config
- * glib
- * ATK
- * Pango
- * cairo
- */
- using namespace std;
- #ifndef ginterface_H
- #define ginterface_H
- /* sys */
- #include <string>
- /* gnome */
- #include <libglademm.h>
- #include <gtkmm.h>
- /* app */
- #include "debug.h"
- #include "common.h"
- #include "interface.h"
- #include "callback.h"
- using namespace Gtk;
- // Liste des Class
- /* class Gmodules */
- class Gmodule : public Module { /* Gnome Module structure */
- private:
- // widget: Pointer table of Widgets
- /*Widget* widgets;*/
- Glib::RefPtr<Gnome::Glade::Xml> refXml;
- protected:
- public:
- //Modules(){ };
- Gmodule(Glib::ustring name) : Module(name){ LOG_IN ();
- #ifdef GLIBMM_EXCEPTIONS_ENABLED
- try{ refXml = Gnome::Glade::Xml::create(name); }
- catch(const Gnome::Glade::XmlError& ex){
- cerr << ex.what() << endl;
- exit;
- }
- #else
- auto_ptr<Gnome::Glade::XmlError> error;
- refXml = Gnome::Glade::Xml::create(name, "", "", error);
- if(error.get()){
- cerr << error->what() << endl;
- exit;
- }
- #endif
- //Get the Glade-instantiated window_main:
- LOG_OUT ();
- };
- ~Gmodule(){ LOG_IN (); /*delete refXml;*/ LOG_OUT (); };
- Glib::RefPtr<Gnome::Glade::Xml> get_refxml(){ LOG_IN (); return refXml; LOG_OUT (); };
- //void get_win_main(Window* p){ LOG_IN (); LOG_OUT (); };
- };
- /* class */
- class Ginterface : public Interface {
- private:
- Glib::ustring filename;
- Gmodule* modules;
- Window* winmain;
- protected:
- public:
- static void on_oscil_sync_algo1_clicked(Gtk::CheckButton * button, gpointer p) {
- LOG_IN ();
- //button.set_label("ello");
- LOG_OUT ();
- };
- static void on_winmain_quit_event(Window * window, gpointer p) {
- LOG_IN ();
- LOG_OUT ();
- };
- Ginterface(int argc, char *argv[]) : Interface() {
- LOG_IN();
- Main kit(argc, argv);
- int i;
- filename="";
- for ( i = 1; i <= argc; i++){
- if ( (argv[i] != NULL) && (Glib::ustring(argv[i]) == "-f")
- && (argv[i+1] != NULL) && (Glib::ustring(argv[i+1]) != "") ){ // -f and name as argument
- FILE *file = fopen(argv[i+1],"r");
- if ( file == NULL) { // try open fil
- filename="dxbaseinterface.glade";
- cout << "Le fichier "<<argv[i+1]<<" n'existe pas" << endl;
- cout << "Chargement du fichier par defaut : " << filename << endl;
- }else{
- cout << "Chargement du fichier d'interface : "<<argv[i+1]<<" ."<<endl;
- fclose(file);
- filename=Glib::ustring(argv[i+1]);
- }
- }
- }
- if (filename == ""){
- filename="dxbaseinterface.glade";
- cout << "Aucun fichier spécifié." << endl;
- cout << "Chargement du fichier : " << filename << endl;
- FILE *file = fopen("dxbaseinterface.glade","r");
- if ( file == NULL) { // try open fil
- cout << "Le fichier "<<filename<<" n'existe pas" << endl;
- filename="interface.glade";
- cout << "Chargement du fichier par defaut : " << filename << endl;
- FILE *file = fopen("dxbaseinterface.glade","r");
- }else{
- cout << "argv "<<i<<" : "<<argv[i]<<" ."<<endl;
- fclose(file);
- }
- }
- winmain = 0;
- modules = new Gmodule(filename);
- (modules[0].get_refxml())->get_widget("window_main", winmain);
- cout << modules[0].get_name() << endl;
- CheckButton* checkbutton_oscil_sync_algo1;
- (modules[0].get_refxml())->get_widget("checkbutton_oscil_sync_algo1", checkbutton_oscil_sync_algo1);
- // gtk_toggle_button_set_mode(GTK_TOGGLE_BUTTON(togglebutton_mute_op1),TRUE);
- // fprintf ( stderr, "kiki %u\n", togglebutton_mute_op1 );
- //register_click_handler(okbutton, clicked, somedata);
- //g_signal_connect(checkbutton_oscil_sync_algo1, "clicked", G_CALLBACK (on_oscil_sync_algo1_clicked),NULL);
- checkbutton_oscil_sync_algo1->signal_clicked().connect(sigc::ptr_fun(&on_oscil_sync_algo1_clicked));
- //g_signal_connect(togglebutton_mute_op1, "toggled", G_CALLBACK(on_togglebutton_mute_op1_clicked_event), NULL);
- //g_signal_connect(winmain, "clicked", G_CALLBACK(on_winmain_quit_event), NULL);
- if(winmain){
- //Get the Glade-instantiated Button, and connect a signal handler:
- kit.run(*winmain);
- delete winmain;
- //winmain = 0;
- }
- // assign widgets
- //g_assign_widget();
- // assign signals
- //g_assign_signal();
- //Gtk::Window window;
- //Main::run(*(Gtk::Window*)gtk_widget_get_tooltip_window(*modules[0].get_widget(0)));
- LOG_OUT();
- }
- ~Ginterface(){ LOG_IN(); delete modules; LOG_OUT(); };
- };
- //int ginterface(int , char *[]);
- #endif /* ginterface_H */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement