Commit 8f7872f0 authored by Jaromír Mikeš's avatar Jaromír Mikeš

Imported Upstream version 0.1.3

parent c4a22e12
File all bug reports in the bug tracker at https://sourceforge.net/tracker/?group_id=404816
The github tracker is now the preffered bug tracker for issues relating to
the git version of Petri-Foo.
For petri-foo-0.1.3 (as downloaded from sourceforge.net) please use the
sourceforge.net bug tracker at:
http://sourceforge.net/tracker/?group_id=404816&atid=1677234
Thanks.
tar -xjf petri-foo-0.1.3.tar.bz2
cd petri-foo-0.1.3
cmake .
make
to run:
gui/petri-foo
......@@ -6,7 +6,7 @@ endif (COMMAND CMAKE_POLICY)
project(Petri-Foo)
set(Petri-Foo_VERSION_MAJOR 0)
set(Petri-Foo_VERSION_MAJOR 1)
set(Petri-Foo_VERSION_MINOR 3)
set(BINDIR "bin" CACHE STRING "Where to install binaries")
set(DATADIR "share/petri-foo" CACHE STRING "Where to install data files")
......@@ -15,12 +15,15 @@ set(PIXMAPS_DIR "share/pixmaps" CACHE STRING "Where to install icons")
set(MIME_DIR "share/mime" CACHE STRING "Where MIME definitions are located")
set(UpdateMime "ON" CACHE BOOL "Update Mime Database")
set(PROJECT_VERSION "0.2.3")
set(ARCHIVE_NAME petri-foo-0.${Petri-Foo_VERSION_MAJOR}.${Petri-Foo_VERSION_MINOR})
mark_as_advanced(EXECUTABLE_OUTPUT_PATH)
mark_as_advanced(LIBRARY_OUTPUT_PATH)
mark_as_advanced(CMAKE_BUILD_TYPE)
mark_as_advanced(CMAKE_INSTALL_PREFIX)
option (BuildForDebug "Include gdb debugging support" ON)
option (BuildForDebug "Include gdb debugging support" OFF)
# DEBUG
set (BuildOptionsDebug "-O0 -ggdb" CACHE STRING "Debug build flags")
......@@ -156,4 +159,8 @@ if (UpdateMime)
)
endif (UpdateMime)
add_custom_target(dist
COMMAND git archive --prefix=${ARCHIVE_NAME}/ HEAD
| bzip2 > ${CMAKE_BINARY_DIR}/${ARCHIVE_NAME}.tar.bz2
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
2012-06-15 James Morris <james@jwm-art.net>
* gui/mod_section.c: prevent change of env mod source
in amp tab from causing gtk critical console messages.
* gui/global_settings.c: free new sample_file_filter str.
2012-06-11 James Morris <james@jwm-art.net>
Preparatory Work for 0.1.3 Release
==================================
* added dist target
* removed obsolete source files
* changed default build to release
* fixed some warnings caused by not-#defined debug
* fixed some warnings about unused variables/parameters
(grep why is this still here)
2012-06-09 James Morris <james@jwm-art.net>
* libpetrifoo/patch_private/patch_data.c, patch_copy:
add call to lfo_update_params for GLFOs (VLFOs are
updated on voice trigger).
2012-06-08 James Morris <james@jwm-art.net>
* libpetrifoo/patch_set_and_get.c: fix assertion
range check for envelope key tracking.
* libpetriui/dish_file.c: fix saving of LFO sync
setting.
* libpetrifoo/pf_error.c: add missing enum cases
to switch, modify handling of unacknowledged
errors to be more informative.
* gui/lfotab.c: only sensitize relevant widgets when
changing LFO between tempo-synced frequency and
non-synced frequency.
* gui/lfotab.c: finish dynamically sensitizing LFO
amount sliders (this time for when switching between
different LFOs).
* gui/idselector.c: change debug statement to output
BEFORE signal emmission.
2012-06-07 James Morris <james@jwm-art.net>
* gui/sampletab.c, fix for play mode assertion failure.
Fixed logic for handling play modes where the to-end
checkbox should sometimes be ignored.
* fixed "program returns random data in a function".
(oops added an unneeded return statement).
* dynamically set LFO amount sliders sensitivity to reflect
state of appropriate modulation source.
* remove ***IS*** textview message
2012-06-06 James Morris <james@jwm-art.net>
* sample-selector auto-preview fixes
2011-08-06 Brendan Jones <brendan.jones.it@gmail.com>
* gui/global_settings.[ch]
......
If you want to contribute to Petri-Foo please take a moment to read these
loose guidelines.
General Guidelines
------------------
* Do join the petri-foo-devel mailing list
* Do not be afraid to pester me into action
* Use of the word awesome is banned (whether applicable or not)
Patches
-------
* You may email me patches as attachments
* Very simple patches may be emailed inline to me or the list
* Try to avoid making whitespace changes in patches
Code Contributions via Git
--------------------------
* Try not to group unrelated bug fixes into a single commit
* Try not to group unrelated commits into a single pull request
Rough Coding Style
------------------
* Line width <= 76 characters
* Do not use tab characters
* Do not leave trailing spaces
* Indents four spaces
* Braces always go on newline
* Space after comma (unless the line becomes 77 characters)
* Keywords such as if, for, have space before open bracket
* Function calls do not have space before open bracket
* Function declarations in headers should be aligned and parameters should
only be named when clarity demands
See the Changelog and/or mailing list.
After some time a new release of Petri-Foo is now available...
Petri-Foo-0.1.3
* Moved build configuration system to cmake
* Removed external dependency on PHAT and replaced with a custom
version called Phin included with Petri-Foo
* Mousewheel waveform zooming
* Auto-preview (with optional resampling) in sample selector dialog
* Numerous bugs squashed unsquashed and squashed again
* Minor GUI updates/fixes
* Removed obsolete source files
......@@ -39,3 +39,9 @@ Differences, additions and improvements over Specimen
Further information about Petri-Foo can always be found at:
http://petri-foo.sourceforge.net
Coding/Contributions
--------------------
See the HACKING file.
......@@ -28,7 +28,6 @@
#include <string.h>
#include "dish_file.h"
#include "log_display.h"
#include "patch.h"
#include "patch_util.h"
#include "petri-foo.h"
......@@ -226,7 +225,6 @@ int bank_ops_open(GtkWidget* parent_window)
if (msg_log_get_notification_state())
{
msg_log(MSG_WARNING, "Bank %s read with errors\n", name);
log_display_show();
}
else
msg_log(MSG_MESSAGE, "Succesfully read bank %s\n", name);
......@@ -291,7 +289,6 @@ int bank_ops_open_recent(GtkWidget* parent_window, char* filename)
if (msg_log_get_notification_state())
{
msg_log(MSG_WARNING, "Bank %s read with errors\n", filename);
log_display_show();
}
else
msg_log(MSG_MESSAGE, "Succesfully read bank %s\n", filename);
......
......@@ -47,6 +47,10 @@ void settings_init()
gbl_settings->last_sample_dir = strdup(getenv("HOME"));
gbl_settings->last_bank_dir = strdup(getenv("HOME"));
gbl_settings->sample_file_filter = strdup("All Audio files");
gbl_settings->sample_auto_preview = true;
gbl_settings->sample_preview_length = 10.0f;
gbl_settings->filename = (char*) g_build_filename(
g_get_user_config_dir(),
g_get_prgname(),
......@@ -153,7 +157,36 @@ int settings_read(const char* path)
xmlChar* vprop = xmlGetProp(node2, BAD_CAST "value");
if (sscanf((const char*)vprop, "%d", &n) == 1)
gbl_settings->log_lines = n;
{ /* arbitrary value alert */
if (n > 0 && n < 65536)
gbl_settings->log_lines = n;
}
}
if (xmlStrcmp(prop, BAD_CAST "sample-file-filter") == 0)
{
free(gbl_settings->sample_file_filter);
gbl_settings->sample_file_filter =
(char*) xmlGetProp(node2, BAD_CAST "value");
}
if (xmlStrcmp(prop, BAD_CAST "sample-auto-preview") == 0)
{
gbl_settings->sample_auto_preview =
xmlstr_to_gboolean(xmlGetProp(node2,
BAD_CAST "value"));
}
if (xmlStrcmp(prop, BAD_CAST "sample-preview-length") == 0)
{
float f;
xmlChar* vprop = xmlGetProp(node2, BAD_CAST "value");
if (sscanf((const char*)vprop, "%f", &f) == 1)
{
if (f > 0.0f && f < 60.0f)
gbl_settings->sample_preview_length = f;
}
}
}
}
......@@ -247,9 +280,29 @@ int settings_write()
node2 = xmlNewTextChild(node1, NULL, BAD_CAST "property", NULL);
xmlNewProp(node2, BAD_CAST "name", BAD_CAST "log-lines");
xmlNewProp(node2, BAD_CAST "type", BAD_CAST "int");
snprintf(buf, CHARBUFSIZE, "%d", gbl_settings->log_lines);
xmlNewProp(node2, BAD_CAST "value", BAD_CAST buf);
node2 = xmlNewTextChild(node1, NULL, BAD_CAST "property", NULL);
xmlNewProp(node2, BAD_CAST "name", BAD_CAST "sample-file-filter");
xmlNewProp(node2, BAD_CAST "type", BAD_CAST "string");
xmlNewProp(node2, BAD_CAST "value",
BAD_CAST gbl_settings->sample_file_filter);
node2 = xmlNewTextChild(node1, NULL, BAD_CAST "property", NULL);
xmlNewProp(node2, BAD_CAST "name", BAD_CAST "sample-auto-preview");
xmlNewProp(node2, BAD_CAST "type", BAD_CAST "boolean");
xmlNewProp(node2, BAD_CAST "value",
BAD_CAST (gbl_settings->sample_auto_preview
? "true"
: "false"));
node2 = xmlNewTextChild(node1, NULL, BAD_CAST "property", NULL);
xmlNewProp(node2, BAD_CAST "name", BAD_CAST "sample-preview-length");
xmlNewProp(node2, BAD_CAST "type", BAD_CAST "float");
snprintf(buf, CHARBUFSIZE, "%0.3f",
gbl_settings->sample_preview_length);
xmlNewProp(node2, BAD_CAST "value", BAD_CAST buf);
debug("attempting to write file:%s\n",gbl_settings->filename);
......@@ -281,6 +334,9 @@ void settings_free(void)
if (gbl_settings->last_bank_dir)
free(gbl_settings->last_bank_dir);
if (gbl_settings->sample_file_filter)
free(gbl_settings->sample_file_filter);
free(gbl_settings);
return;
......
......@@ -22,6 +22,8 @@
#define SETTINGS_H
#include <stdbool.h>
/* global settings
*/
......@@ -41,6 +43,11 @@ typedef struct global_settings_def
int abs_max_sample_size;
int max_sample_size;
*/
char* sample_file_filter;
bool sample_auto_preview;
float sample_preview_length;
} global_settings;
......
......@@ -38,8 +38,8 @@
#include "channelsection.h"
#include "config.h"
#include "driver.h"
#include "global_settings.h"
#include "gui.h"
#include "log_display.h"
#include "mastersection.h"
#include "midisection.h"
#include "mixer.h"
......@@ -69,15 +69,12 @@ static GtkWidget* menu_file = 0;
static GtkWidget* menu_settings = 0;
static GtkWidget* menu_patch = 0;
static GtkWidget* menu_help = 0;
static GtkWidget* menu_view = 0;
static GtkWidget* menuitem_file_recent = 0;
/* view menu */
static GtkWidget* menu_view_log_display = 0;
/* settings */
static GtkWidget* menu_settings_fans = 0;
static GtkWidget* menu_settings_auto_preview = 0;
/* current patch, makes passing patch id to sample editor easier */
static int cur_patch = -1;
......@@ -417,7 +414,6 @@ void cb_menu_patch_remove(GtkWidget* menu_item, gpointer data)
{
(void)menu_item;(void)data;
int val;
int cp;
int index;
......@@ -439,25 +435,6 @@ void cb_menu_patch_remove(GtkWidget* menu_item, gpointer data)
}
void cb_menu_view_log_display_showing(gboolean active)
{
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(menu_view_log_display), active);
}
static void cb_menu_view_log_display(GtkWidget* widget, gpointer data)
{
if (gtk_check_menu_item_get_active(
GTK_CHECK_MENU_ITEM(menu_view_log_display)))
{
log_display_show();
}
else
log_display_hide();
}
static void cb_menu_file_new_bank (GtkWidget * widget, gpointer data)
{
(void)widget;(void)data;
......@@ -510,6 +487,14 @@ static void cb_menu_settings_fans(GtkWidget* widget, gpointer data)
}
static void cb_menu_settings_auto_preview(GtkWidget* widget, gpointer data)
{
(void)widget;(void)data;
global_settings* settings = settings_get();
settings->sample_auto_preview = gtk_check_menu_item_get_active(
GTK_CHECK_MENU_ITEM(menu_settings_auto_preview));
}
static void cb_menu_help_stfu (GtkWidget* widget, gpointer data)
{
(void)widget;(void)data;
......@@ -535,7 +520,7 @@ static void cb_menu_help_about (GtkWidget* widget, gpointer data)
"version", VERSION,
"copyright", "(C) 2004-2005 Pete Bessman\n"
"(C) 2006-2007 others\n"
"(C) 2011 James Morris\n",
"(C) 2011-2012 James Morris\n",
NULL);
}
......@@ -586,6 +571,7 @@ int gui_init(void)
GtkWidget* window_vbox;
GtkWidget* master_hbox;
GtkWidget* vbox;
global_settings* settings = settings_get();
debug ("Initializing GUI\n");
......@@ -637,33 +623,37 @@ int gui_init(void)
gui_menu_add(menu_patch, "Remove",
G_CALLBACK(cb_menu_patch_remove), NULL);
/* view menu */
menu_view = gui_menu_add(menubar, "View", NULL, NULL);
menu_view_log_display =
gui_menu_check_add(menu_view, "Message Log", FALSE,
G_CALLBACK(cb_menu_view_log_display), window);
/* settings menu */
/* use slider fans */
menu_settings = gui_menu_add(menubar, "Settings", NULL, NULL);
gui_menu_add(menu_settings, "Audio...",
G_CALLBACK(cb_menu_settings_audio), NULL);
menu_settings_fans =
gtk_check_menu_item_new_with_label("Use slider fans");
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(menu_settings_fans),
GTK_CHECK_MENU_ITEM(menu_settings_fans),
phin_fan_slider_get_fans_active());
g_signal_connect(GTK_OBJECT(menu_settings_fans), "toggled",
G_CALLBACK(cb_menu_settings_fans), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_settings),
menu_settings_fans);
gtk_widget_show(menu_settings_fans);
/* auto-preview */
menu_settings_auto_preview =
gtk_check_menu_item_new_with_label("Sample auto-preview");
gtk_check_menu_item_set_active(
GTK_CHECK_MENU_ITEM(menu_settings_auto_preview),
settings->sample_auto_preview);
g_signal_connect(GTK_OBJECT(menu_settings_auto_preview), "toggled",
G_CALLBACK(cb_menu_settings_auto_preview), NULL);
gtk_menu_shell_append(GTK_MENU_SHELL(menu_settings),
menu_settings_auto_preview);
gtk_widget_show(menu_settings_auto_preview);
/* help menu */
menu_help = gui_menu_add(menubar, "Help", NULL, NULL);
gui_menu_add(menu_help, "All Sound Off!",
......@@ -727,7 +717,6 @@ int gui_init(void)
/* intialize children */
sample_editor_init(window);
audio_settings_init(window);
log_display_init(window);
/* priming updates */
master_section_update(MASTER_SECTION(master_section));
......@@ -803,7 +792,6 @@ gui_menu_check_add(GtkWidget* menu, const char* label, gboolean active,
gpointer data)
{
GtkWidget* item = 0;
GtkWidget* submenu = 0;
item = gtk_check_menu_item_new_with_label(label);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), active);
......@@ -816,12 +804,12 @@ gui_menu_check_add(GtkWidget* menu, const char* label, gboolean active,
/* recent items menu */
void gui_recent_files_load(void)
{
GtkWidget* menuitem_to_append_to = NULL;
GtkRecentFilter *recent_filter;
GtkWidget *menuitem_file_recent_items;
recent_manager = gtk_recent_manager_get_default();
recent_filter = gtk_recent_filter_new();
gtk_recent_filter_add_mime_type(recent_filter, "application/x-petri-foo");
gtk_recent_filter_add_mime_type(recent_filter,
"application/x-petri-foo");
menuitem_file_recent_items =
gtk_recent_chooser_menu_new_for_manager(recent_manager);
gtk_recent_chooser_add_filter(
......@@ -837,7 +825,8 @@ void gui_recent_files_load(void)
GTK_RECENT_CHOOSER(menuitem_file_recent_items), FALSE);
gtk_recent_chooser_menu_set_show_numbers(
GTK_RECENT_CHOOSER_MENU(menuitem_file_recent_items), TRUE);
g_signal_connect(GTK_OBJECT(menuitem_file_recent_items), "item-activated",
g_signal_connect(GTK_OBJECT(menuitem_file_recent_items),
"item-activated",
G_CALLBACK(cb_recent_chooser_item_activated), window);
gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem_file_recent),
menuitem_file_recent_items);
......
......@@ -126,11 +126,11 @@ press_cb(GtkToggleButton* button, GdkEvent* event, IDSelectorPrivate* p)
p->index = i;
gtk_toggle_button_set_active(
GTK_TOGGLE_BUTTON(p->buttons[p->index]), TRUE);
g_signal_emit_by_name(G_OBJECT(p->self), "changed");
debug("selected index:%d id:%d name:%s\n",
i, p->ids_names[i].id, p->ids_names[i].name);
g_signal_emit_by_name(G_OBJECT(p->self), "changed");
return TRUE;
}
}
......
......@@ -106,7 +106,7 @@ static void lfo_tab_class_init(LfoTabClass* klass)
}
static void set_sensitive(LfoTabPrivate* p, gboolean val)
static void set_lfo_sensitive(LfoTabPrivate* p, gboolean val)
{
gboolean active = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(p->sync_radio));
......@@ -126,13 +126,32 @@ static void set_sensitive(LfoTabPrivate* p, gboolean val)
gtk_widget_set_sensitive(p->fm1_combo, val);
gtk_widget_set_sensitive(p->fm2_combo, val);
gtk_widget_set_sensitive(p->fm1_amount, val);
gtk_widget_set_sensitive(p->fm2_amount, val);
gtk_widget_set_sensitive(p->am1_combo, val);
gtk_widget_set_sensitive(p->am2_combo, val);
gtk_widget_set_sensitive(p->am1_amount, val);
gtk_widget_set_sensitive(p->am2_amount, val);
if (val)
{
gtk_widget_set_sensitive(p->fm1_amount,
mod_src_callback_helper_lfo(p->patch_id, FM1,
GTK_COMBO_BOX(p->fm1_combo), p->lfo_id));
gtk_widget_set_sensitive(p->fm2_amount,
mod_src_callback_helper_lfo(p->patch_id, FM2,
GTK_COMBO_BOX(p->fm2_combo), p->lfo_id));
gtk_widget_set_sensitive(p->am1_amount,
mod_src_callback_helper_lfo(p->patch_id, AM1,
GTK_COMBO_BOX(p->am1_combo), p->lfo_id));
gtk_widget_set_sensitive(p->am2_amount,
mod_src_callback_helper_lfo(p->patch_id, AM2,
GTK_COMBO_BOX(p->am2_combo), p->lfo_id));
}
else
{
gtk_widget_set_sensitive(p->fm1_amount, FALSE);
gtk_widget_set_sensitive(p->fm2_amount, FALSE);
gtk_widget_set_sensitive(p->am1_amount, FALSE);
gtk_widget_set_sensitive(p->am2_amount, FALSE);
}
gtk_widget_set_sensitive(p->freq_fan, !active && val);
gtk_widget_set_sensitive(p->beats_sb, active && val);
......@@ -155,7 +174,7 @@ static void on_cb(GtkToggleButton* button, LfoTabPrivate* p)
static void on_cb2(GtkToggleButton* button, LfoTabPrivate* p)
{
set_sensitive(p, gtk_toggle_button_get_active(button));
set_lfo_sensitive(p, gtk_toggle_button_get_active(button));
}
......@@ -186,9 +205,10 @@ static void sync_cb(GtkToggleButton* button, LfoTabPrivate* p)
static void sync_cb2(GtkToggleButton* button, LfoTabPrivate* p)
{
(void)button;
set_sensitive(p,
gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p->lfo_check)));
gboolean active = gtk_toggle_button_get_active(
GTK_TOGGLE_BUTTON(button));
gtk_widget_set_sensitive(p->freq_fan, !active);
gtk_widget_set_sensitive(p->beats_sb, active);
}
......@@ -228,6 +248,7 @@ static void attack_cb(PhinFanSlider* fan, LfoTabPrivate* p)
static void mod_src_cb(GtkComboBox* combo, LfoTabPrivate* p)
{
int input_id;
bool sens;
if (combo == GTK_COMBO_BOX(p->fm1_combo))
input_id = FM1;
......@@ -243,7 +264,18 @@ static void mod_src_cb(GtkComboBox* combo, LfoTabPrivate* p)
return;
}
mod_src_callback_helper_lfo(p->patch_id, input_id, combo, p->lfo_id);
sens = mod_src_callback_helper_lfo(p->patch_id, input_id,
combo, p->lfo_id);
switch(input_id)
{
case FM1: gtk_widget_set_sensitive(p->fm1_amount, sens); break;
case FM2: gtk_widget_set_sensitive(p->fm2_amount, sens); break;
case AM1: gtk_widget_set_sensitive(p->am1_amount, sens); break;
case AM2: gtk_widget_set_sensitive(p->am2_amount, sens); break;
default:
break;
}
}
static void mod_amount_cb(GtkWidget* w, LfoTabPrivate* p)
......@@ -504,7 +536,7 @@ static void lfo_tab_init(LfoTab* self)
++y;
/* done */
set_sensitive(p, FALSE);
set_lfo_sensitive(p, FALSE);
connect(p);
}
......@@ -513,7 +545,7 @@ static void update_lfo(LfoTabPrivate* p)
{
LFOShape lfoshape;
int shape;
float freq, beats, delay, attack;
float freq, beats, delay = 0, attack = 0;
bool active, sync, positive;
GtkTreeIter iter;
......@@ -533,9 +565,6 @@ static void update_lfo(LfoTabPrivate* p)
? MOD_SRC_GLOBALS
: MOD_SRC_ALL);
debug("setting combo model\n");
block(p);
mod_src_combo_set_model(GTK_COMBO_BOX(p->fm1_combo), mod_srcs);
mod_src_combo_set_model(GTK_COMBO_BOX(p->fm2_combo), mod_srcs);
......@@ -657,6 +686,11 @@ static void update_lfo(LfoTabPrivate* p)
phin_fan_slider_set_value(PHIN_FAN_SLIDER(p->am1_amount), am1amt);
phin_fan_slider_set_value(PHIN_FAN_SLIDER(p->am2_amount), am2amt);
gtk_widget_set_sensitive(p->fm1_amount, fm1src != MOD_SRC_NONE);
gtk_widget_set_sensitive(p->fm2_amount, fm2src != MOD_SRC_NONE);
gtk_widget_set_sensitive(p->am1_amount, am1src != MOD_SRC_NONE);
gtk_widget_set_sensitive(p->am2_amount, am2src != MOD_SRC_NONE);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p->lfo_check), active);
unblock(p);
......
/* Petri-Foo is a fork of the Specimen audio sampler.
Original Specimen author Pete Bessman
Copyright 2005 Pete Bessman
Copyright 2011 James W. Morris
This file is part of Petri-Foo.
Petri-Foo is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 2 as
published by the Free Software Foundation.
Petri-Foo 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 Petri-Foo. If not, see <http://www.gnu.org/licenses/>.
This file is a derivative of a Specimen original, modified 2011
*/
#include <gtk/gtk.h>
#include "log_display.h"
#include "gui.h"
#include "msg_log.h"
#include "petri-foo.h"
#include <string.h>
#include <stdlib.h>
static GtkWidget* window;
static GtkWidget* textview;
static void cb_close (GtkWidget* widget, gpointer data)
{
(void)widget; (void)data;
printf("\n\nclose\n\n");
gtk_widget_hide (window);
cb_menu_view_log_display_showing(false);
}
static void msg_log_callback(const char* msg, int msg_base_type)
{
GtkTextBuffer* buffer;
GtkTextIter iter;
GtkTextMark* mark;
const char* tag = 0;
if (GTK_IS_TEXT_VIEW(textview))
{
printf("%p ***IS*** textview\n", textview);
}
else
{
printf("%p ***IS NOT *** textview\n", textview);
}
switch(msg_base_type)
{
case MSG_TYPE_DEBUG: tag = "debug"; break;
case MSG_TYPE_WARNING: tag = "warning"; break;
case MSG_TYPE_ERROR: tag = "error"; break;
case MSG_TYPE_CRITICAL: tag = "critical"; break;
default: tag = "message"; break;
}
buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
gtk_text_buffer_get_end_iter(buffer, &iter);
gtk_text_buffer_insert_with_tags_by_name(buffer, &iter, msg, -1,
tag, NULL);
mark = gtk_text_buffer_get_mark (buffer, "scroll");
gtk_text_buffer_move_mark (buffer, mark, &iter);
gtk_text_view_scroll_mark_onscreen(GTK_TEXT_VIEW(textview), mark);
}
void log_display_show(void)
{
gtk_widget_show(window);
}
void log_display_hide(void)
{
gtk_widget_hide(window);
}
void log_display_init(GtkWidget* parent)
{
GtkWidget* swindow;