/[svn]/gigedit/trunk/src/gigedit/paramedit.cpp
ViewVC logotype

Diff of /gigedit/trunk/src/gigedit/paramedit.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2844 by persson, Sun Sep 20 08:49:40 2015 UTC revision 3364 by schoenebeck, Tue Nov 14 18:07:25 2017 UTC
# Line 1  Line 1 
1  /*  /*
2   * Copyright (C) 2006-2015 Andreas Persson   * Copyright (C) 2006-2017 Andreas Persson
3   *   *
4   * This program is free software; you can redistribute it and/or   * This program is free software; you can redistribute it and/or
5   * modify it under the terms of the GNU General Public License as   * modify it under the terms of the GNU General Public License as
# Line 17  Line 17 
17   * 02110-1301 USA.   * 02110-1301 USA.
18   */   */
19    
20  #include <cstring>  #include "global.h"
   
 #include <glibmmconfig.h>  
 // threads.h must be included first to be able to build with  
 // G_DISABLE_DEPRECATED  
 #if (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION == 31 && GLIBMM_MICRO_VERSION >= 2) || \  
     (GLIBMM_MAJOR_VERSION == 2 && GLIBMM_MINOR_VERSION > 31) || GLIBMM_MAJOR_VERSION > 2  
 #include <glibmm/threads.h>  
 #endif  
   
21  #include "paramedit.h"  #include "paramedit.h"
22    
 #include "global.h"  
23  #include "compat.h"  #include "compat.h"
24  #include "Settings.h"  #include "Settings.h"
25    
26  #include <gtkmm/messagedialog.h>  #include <gtkmm/messagedialog.h>
27    
 std::string gig_encoding("CP1252");  
   
 Glib::ustring gig_to_utf8(const gig::String& gig_string) {  
     return Glib::convert_with_fallback(gig_string, "UTF-8", gig_encoding, "?");  
 }  
   
 gig::String gig_from_utf8(const Glib::ustring& utf8_string) {  
     return Glib::convert_with_fallback(utf8_string, gig_encoding, "UTF-8", "?");  
 }  
   
   
28  namespace {  namespace {
29      struct CCText {      struct CCText {
30          const char* const txt;          const char* const txt;
# Line 160  LabelWidget::LabelWidget(const char* lab Line 139  LabelWidget::LabelWidget(const char* lab
139      label(Glib::ustring(labelText) + ":"),      label(Glib::ustring(labelText) + ":"),
140      widget(widget)      widget(widget)
141  {  {
142    #if HAS_GTKMM_ALIGNMENT
143      label.set_alignment(Gtk::ALIGN_START);      label.set_alignment(Gtk::ALIGN_START);
144    #else
145        label.set_halign(Gtk::Align::START);
146    #endif
147  }  }
148    
149  void LabelWidget::set_sensitive(bool sensitive)  void LabelWidget::set_sensitive(bool sensitive)
# Line 172  void LabelWidget::set_sensitive(bool sen Line 155  void LabelWidget::set_sensitive(bool sen
155  ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText)  ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText)
156      : LabelWidget(leftHandText, text)      : LabelWidget(leftHandText, text)
157  {  {
158    #if HAS_GTKMM_ALIGNMENT
159      text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);      text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);
160    #else
161        label.set_halign(Gtk::Align::START);
162        label.set_valign(Gtk::Align::START);
163    #endif
164  }  }
165    
166  ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText)  ReadOnlyLabelWidget::ReadOnlyLabelWidget(const char* leftHandText, const char* rightHandText)
167     : LabelWidget(leftHandText, text)     : LabelWidget(leftHandText, text)
168  {  {
169    #if HAS_GTKMM_ALIGNMENT
170      text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);      text.set_alignment(Gtk::ALIGN_START, Gtk::ALIGN_START);
171    #else
172        text.set_halign(Gtk::Align::START);
173        text.set_valign(Gtk::Align::START);
174    #endif
175      text.set_text(rightHandText);      text.set_text(rightHandText);
176  }  }
177    
# Line 329  namespace { Line 322  namespace {
322                  return true;                  return true;
323              }              }
324          }          }
325    
326    #if HAS_GTKMM_CPP11_ENUMS
327            return Gtk::SpinButton::INPUT_ERROR;
328    #else
329          return Gtk::INPUT_ERROR;          return Gtk::INPUT_ERROR;
330    #endif
331      }      }
332  }  }
333    
# Line 349  Glib::ustring note_str(int note) Line 347  Glib::ustring note_str(int note)
347    
348  namespace {  namespace {
349      // Convert the Entry text to a number      // Convert the Entry text to a number
350    #if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && (GTKMM_MINOR_VERSION > 91 || (GTKMM_MINOR_VERSION == 91 && GTKMM_MICRO_VERSION >= 2))) // GTKMM >= 3.91.2
351        int on_input(double& new_value, Gtk::SpinButton* spinbutton) {
352            return note_value(spinbutton->get_text(), &new_value);
353        }
354    #else
355      int on_input(double* new_value, Gtk::SpinButton* spinbutton) {      int on_input(double* new_value, Gtk::SpinButton* spinbutton) {
356          return note_value(spinbutton->get_text(), new_value);          return note_value(spinbutton->get_text(), new_value);
357      }      }
358    #endif
359    
360      // Convert the Adjustment position to text      // Convert the Adjustment position to text
361      bool on_output(Gtk::SpinButton* spinbutton) {      bool on_output(Gtk::SpinButton* spinbutton) {
# Line 373  void spin_button_show_notes(Gtk::SpinBut Line 377  void spin_button_show_notes(Gtk::SpinBut
377  }  }
378    
379  ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) :  ChoiceEntryLeverageCtrl::ChoiceEntryLeverageCtrl(const char* labelText) :
380    #if HAS_GTKMM_ALIGNMENT
381      LabelWidget(labelText, align),      LabelWidget(labelText, align),
382      align(0, 0, 0, 0)      align(0, 0, 0, 0)
383    #else
384        LabelWidget(labelText, combobox)
385    #endif
386  {  {
387      for (int i = 0 ; i < controlChangeTextsSize ; i++) {      for (int i = 0 ; i < controlChangeTextsSize ; i++) {
388          if (controlChangeTexts[i].txt) {          if (controlChangeTexts[i].txt) {
# Line 391  ChoiceEntryLeverageCtrl::ChoiceEntryLeve Line 399  ChoiceEntryLeverageCtrl::ChoiceEntryLeve
399      }      }
400      combobox.signal_changed().connect(      combobox.signal_changed().connect(
401          sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed));          sigc::mem_fun(*this, &ChoiceEntryLeverageCtrl::value_changed));
402    #if HAS_GTKMM_ALIGNMENT
403      align.add(combobox);      align.add(combobox);
404    #else
405        combobox.set_halign(Gtk::Align::FILL);
406        combobox.set_valign(Gtk::Align::FILL);
407    #endif
408      value.type = gig::leverage_ctrl_t::type_none;      value.type = gig::leverage_ctrl_t::type_none;
409      value.controller_number = 0;      value.controller_number = 0;
410  }  }
# Line 524  void StringEntryMultiLine::set_value(con Line 537  void StringEntryMultiLine::set_value(con
537  }  }
538    
539    
540  Table::Table(int x, int y) : Gtk::Table(x, y), rowno(0) {  }  Table::Table(int x, int y) :
541    #if USE_GTKMM_GRID
542        Gtk::Grid(),
543        cols(x),
544    #else
545        Gtk::Table(x, y),
546    #endif
547        rowno(0)
548    {
549    }
550    
551  void Table::add(BoolEntry& boolentry)  void Table::add(BoolEntry& boolentry)
552  {  {
553    #if USE_GTKMM_GRID
554        attach(boolentry.widget, 0, rowno, 2);
555    #else
556      attach(boolentry.widget, 0, 2, rowno, rowno + 1,      attach(boolentry.widget, 0, 2, rowno, rowno + 1,
557             Gtk::FILL, Gtk::SHRINK);             Gtk::FILL, Gtk::SHRINK);
558    #endif
559      rowno++;      rowno++;
560  }  }
561    
562  void Table::add(BoolEntryPlus6& boolentry)  void Table::add(BoolEntryPlus6& boolentry)
563  {  {
564    #if USE_GTKMM_GRID
565        attach(boolentry.widget, 0, rowno, 2);
566    #else
567      attach(boolentry.widget, 0, 2, rowno, rowno + 1,      attach(boolentry.widget, 0, 2, rowno, rowno + 1,
568             Gtk::FILL, Gtk::SHRINK);             Gtk::FILL, Gtk::SHRINK);
569    #endif
570      rowno++;      rowno++;
571  }  }
572    
573  void Table::add(LabelWidget& prop)  void Table::add(LabelWidget& prop)
574  {  {
575    #if USE_GTKMM_GRID
576        attach(prop.label, 1, rowno);
577        attach(prop.widget, 2, rowno);
578    #else
579      attach(prop.label, 1, 2, rowno, rowno + 1,      attach(prop.label, 1, 2, rowno, rowno + 1,
580             Gtk::FILL, Gtk::SHRINK);             Gtk::FILL, Gtk::SHRINK);
581      attach(prop.widget, 2, 3, rowno, rowno + 1,      attach(prop.widget, 2, 3, rowno, rowno + 1,
582             Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);             Gtk::EXPAND | Gtk::FILL, Gtk::SHRINK);
583    #endif
584      rowno++;      rowno++;
585  }  }

Legend:
Removed from v.2844  
changed lines
  Added in v.3364

  ViewVC Help
Powered by ViewVC