Rewrite currently active functionality in plan C
This commit is contained in:
parent
605531c2f1
commit
3fc93d970c
|
@ -44,4 +44,9 @@
|
|||
|
||||
enum ModuleType { Input, Output, InputOutput };
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
extern GtkBuilder * g_builder;
|
||||
|
||||
#include "../common/debug.h"
|
||||
|
||||
#endif /* #ifndef COMMON_H__15E63B7A_8350_4ABD_B04C_592158354949__INCLUDED */
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains the glade (gtk_builder) helpers
|
||||
**************************************************************************
|
||||
*
|
||||
* LADI Session Handler 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.
|
||||
*
|
||||
* LADI Session Handler 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 LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
|
||||
* or write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "glade.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
#include <glade/glade.h>
|
||||
|
||||
GladeXML * g_glade;
|
||||
|
||||
bool init_glade(void)
|
||||
{
|
||||
const char * path;
|
||||
struct stat st;
|
||||
|
||||
path = "./gui/gui.glade";
|
||||
if (stat(path, &st) == 0)
|
||||
{
|
||||
goto found;
|
||||
}
|
||||
|
||||
path = DATA_DIR "/gui.glade";
|
||||
if (stat(path, &st) == 0)
|
||||
{
|
||||
goto found;
|
||||
}
|
||||
|
||||
lash_error("Unable to find the gui.glade file");
|
||||
uninit_glade();
|
||||
return false;
|
||||
|
||||
found:
|
||||
lash_info("Loading glade from %s", path);
|
||||
g_glade = glade_xml_new(path, NULL, NULL);
|
||||
return true;
|
||||
}
|
||||
|
||||
void uninit_glade(void)
|
||||
{
|
||||
}
|
||||
|
||||
GtkWidget * get_glade_widget(const char * name)
|
||||
{
|
||||
GtkWidget * ptr;
|
||||
|
||||
ptr = GTK_WIDGET(glade_xml_get_widget(g_glade, name));
|
||||
|
||||
assert(ptr != NULL);
|
||||
|
||||
return ptr;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: C ; c-basic-offset: 2 -*- */
|
||||
/*
|
||||
* LADI Session Handler (ladish)
|
||||
*
|
||||
* Copyright (C) 2009 Nedko Arnaudov <nedko@arnaudov.name>
|
||||
*
|
||||
**************************************************************************
|
||||
* This file contains the interface to the glade (gtk_builder) helpers
|
||||
**************************************************************************
|
||||
*
|
||||
* LADI Session Handler 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.
|
||||
*
|
||||
* LADI Session Handler 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 LADI Session Handler. If not, see <http://www.gnu.org/licenses/>
|
||||
* or write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef GLADE_H__E2BF7CFC_1B04_4160_9165_A1B433C6B3C2__INCLUDED
|
||||
#define GLADE_H__E2BF7CFC_1B04_4160_9165_A1B433C6B3C2__INCLUDED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#if 0
|
||||
} /* Adjust editor indent */
|
||||
#endif
|
||||
|
||||
bool init_glade(void);
|
||||
void uninit_glade(void);
|
||||
GtkWidget * get_glade_widget(const char * name);
|
||||
|
||||
#if 0
|
||||
{ /* Adjust editor indent */
|
||||
#endif
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
#endif
|
||||
|
||||
#endif /* #ifndef GLADE_H__E2BF7CFC_1B04_4160_9165_A1B433C6B3C2__INCLUDED */
|
109
gui/main.cpp
109
gui/main.cpp
|
@ -26,13 +26,13 @@
|
|||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include <libglademm/xml.h>
|
||||
#include <glibmm/exception.h>
|
||||
#include <gtkmm.h>
|
||||
#include "Widget.hpp"
|
||||
|
||||
#include "../common/debug.h"
|
||||
#include "glade.h"
|
||||
#include "canvas.h"
|
||||
#include "graph_canvas.h"
|
||||
#include "../jack_proxy.h"
|
||||
#include "dbus_helpers.h"
|
||||
|
||||
#if 0
|
||||
class Patchage {
|
||||
public:
|
||||
Patchage();
|
||||
|
@ -146,7 +146,6 @@ protected:
|
|||
#include "project_list.hpp"
|
||||
#include "session.hpp"
|
||||
#include "globals.hpp"
|
||||
#include "dbus_helpers.h"
|
||||
//#include "load_projects_dialog.hpp"
|
||||
#include "graph_canvas.h"
|
||||
#include "../jack_proxy.h"
|
||||
|
@ -156,9 +155,6 @@ Patchage * g_app;
|
|||
#define LOG_TO_STD
|
||||
//#define LOG_TO_STATUS
|
||||
|
||||
graph_canvas_handle g_jack_graph_canvas;
|
||||
graph_handle g_jack_graph;
|
||||
|
||||
/* Gtk helpers (resize combo boxes) */
|
||||
|
||||
static void
|
||||
|
@ -194,6 +190,7 @@ gtkmm_set_width_for_given_text (Gtk::Widget &w, const gchar *text,
|
|||
|
||||
Patchage::Patchage()
|
||||
: _max_dsp_load(0.0)
|
||||
#if 0
|
||||
, INIT_WIDGET(_about_win)
|
||||
, INIT_WIDGET(_buffer_size_combo)
|
||||
, INIT_WIDGET(_clear_load_but)
|
||||
|
@ -220,6 +217,7 @@ Patchage::Patchage()
|
|||
, INIT_WIDGET(_toolbar)
|
||||
, INIT_WIDGET(_zoom_full_but)
|
||||
, INIT_WIDGET(_zoom_normal_but)
|
||||
#endif
|
||||
{
|
||||
g_app = this;
|
||||
|
||||
|
@ -851,66 +849,61 @@ Patchage::is_canvas_empty()
|
|||
return _canvas->items().empty();
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Glib::RefPtr<Gnome::Glade::Xml> g_xml;
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
static
|
||||
Glib::RefPtr<Gnome::Glade::Xml>
|
||||
glade_open()
|
||||
{
|
||||
// Check for the .glade file in ./src/
|
||||
std::string glade_filename = std::string("./gui/gui.glade");
|
||||
std::ifstream fs(glade_filename.c_str());
|
||||
if (fs.fail())
|
||||
{ // didn't find it, check DATA_PATH
|
||||
fs.clear();
|
||||
|
||||
glade_filename = DATA_DIR "/gui.glade";
|
||||
|
||||
fs.open(glade_filename.c_str());
|
||||
if (fs.fail())
|
||||
{
|
||||
std::ostringstream ss;
|
||||
ss << "Unable to find gui.glade file" << std::endl;
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
fs.close();
|
||||
}
|
||||
|
||||
return Gnome::Glade::Xml::create(glade_filename);
|
||||
}
|
||||
graph_canvas_handle g_jack_graph_canvas;
|
||||
graph_handle g_jack_graph;
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
GtkWidget * main_win;
|
||||
GtkScrolledWindow * main_scrolledwin;
|
||||
GtkWidget * canvas_widget;
|
||||
|
||||
gtk_init(&argc, &argv);
|
||||
|
||||
if (!canvas_init())
|
||||
{
|
||||
lash_error("Canvas initialization failed.");
|
||||
return 1;
|
||||
}
|
||||
|
||||
try
|
||||
if (!init_glade())
|
||||
{
|
||||
Gtk::Main app(argc, argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
g_xml = glade_open();
|
||||
|
||||
Patchage patchage;
|
||||
app.run(*patchage.window());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
lash_error("Caught exception, aborting. Error message was: %s\n", e.what());
|
||||
return 1;
|
||||
|
||||
}
|
||||
catch (Glib::Exception& e)
|
||||
{
|
||||
lash_error("Caught exception, aborting. Error message was: %s\n", e.what().c_str());
|
||||
return 1;
|
||||
}
|
||||
/* Obtain widgets that we need */
|
||||
main_win = get_glade_widget("main_win");
|
||||
main_scrolledwin = GTK_SCROLLED_WINDOW(get_glade_widget("main_scrolledwin"));
|
||||
|
||||
patchage_dbus_init();
|
||||
|
||||
graph_create(JACKDBUS_SERVICE, JACKDBUS_OBJECT, &g_jack_graph);
|
||||
graph_canvas_create(1600 * 2, 1200 * 2, &g_jack_graph_canvas);
|
||||
graph_canvas_attach(g_jack_graph_canvas, g_jack_graph);
|
||||
graph_activate(g_jack_graph);
|
||||
|
||||
canvas_widget = canvas_get_widget(graph_canvas_get_canvas(g_jack_graph_canvas));
|
||||
|
||||
gtk_widget_show(canvas_widget);
|
||||
|
||||
//gtkmm_set_width_for_given_text(*_buffer_size_combo, "4096 frames", 40);
|
||||
|
||||
gtk_container_add(GTK_CONTAINER(main_scrolledwin), canvas_widget);
|
||||
|
||||
// _canvas->scroll_to(static_cast<int>(_canvas->width()/2 - 320), static_cast<int>(_canvas->height()/2 - 240)); // FIXME: hardcoded
|
||||
|
||||
//_main_scrolledwin->property_hadjustment().get_value()->set_step_increment(10);
|
||||
//_main_scrolledwin->property_vadjustment().get_value()->set_step_increment(10);
|
||||
|
||||
gtk_widget_show(main_win);
|
||||
|
||||
//_about_win->set_transient_for(*_main_win);
|
||||
|
||||
gtk_main();
|
||||
|
||||
uninit_glade();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue