~ubuntu-branches/ubuntu/quantal/glom/quantal

« back to all changes in this revision

Viewing changes to glom/mode_design/fields/dialog_fieldcalculation.cc

  • Committer: Bazaar Package Importer
  • Author(s): Iain Lane
  • Date: 2009-01-11 17:12:01 UTC
  • mfrom: (1.1.39 upstream)
  • Revision ID: james.westby@ubuntu.com-20090111171201-0ov9zh1fxfueshxc
Tags: 1.8.5-0ubuntu1
* New upstream release (LP: #256701), fixes LP bugs: 
  + Clear the text in property dialogs for text items (LP: #309147)
  + Don't crash when showing and then hiding the grid (LP: #303453)
  + Temporarily remember the sort order so it is the same when navigating 
    away and back (LP: #303422)
  + Use the list's sort order for the top-level records in the report 
    (LP: #303425)
  + Users/Groups: Disable drag-and-drop for the treeview, because it is
    useless and confusing (LP: #299573)
  + Import: Sort the fields list alphabetically (LP: #306593)
  + delete primary key make unusuable the database (LP: #299549)
  + Spanish translate incomplete (LP: #299556)
  + import date format error (LP: #299591)
  + can't delete data from table list view (LP: #299853)
  + Field definition: default value not saved (LP: #299896)
  + reports crashing (LP: #300054)
  + Year error with date fields (LP: #300057)
  + list view: 2 records added instead of 1 (LP: #300819)
* debian/control: Refreshed dependencies for libglom-dev.
* debian/control: Updated build-deps to match configure checks. goocavnasmm
  build-dep bumped to version without .la files.
* debian/rules: Don't delete the directory containing the templates.
* debian/control, debian/rules, debian/glom-doc.*: Split out
  arch-independent manual and examples into separate package glom-doc, which
  is now recommended by glom (glom will still work if they're not available)
* debian/copyright: Rewritten to new machine-readable format. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
24
24
#include "../../frame_glom.h"
25
25
#include "../../python_embed/glom_python.h"
26
26
#include <glom/libglom/data_structure/glomconversions.h>
27
 
#include <gtksourceviewmm/sourcelanguagesmanager.h>
 
27
#include <gtksourceviewmm/sourcelanguagemanager.h>
28
28
 
29
29
//#include <libgnome/gnome-i18n.h>
30
30
#include <glibmm/i18n.h>
46
46
  {
47
47
    m_text_view->set_highlight_current_line(true);
48
48
 
49
 
    //TODO: Shouldn't this be a singleton?
50
 
    Glib::RefPtr<gtksourceview::SourceLanguagesManager> languages_manager = gtksourceview::SourceLanguagesManager::create();
 
49
    Glib::RefPtr<gtksourceview::SourceLanguageManager> languages_manager = gtksourceview::SourceLanguageManager::get_default();
51
50
 
52
 
    Glib::RefPtr<gtksourceview::SourceLanguage> language = languages_manager->get_language_from_mime_type("application/x-python");
 
51
    Glib::RefPtr<gtksourceview::SourceLanguage> language = languages_manager->get_language("python"); //This is the GtkSourceView language ID.
53
52
    if(language)
54
53
    {
55
54
       //Createa a new buffer and set it, instead of getting the default buffer, in case libglade has tried to set it, using the wrong buffer type:
56
55
       Glib::RefPtr<gtksourceview::SourceBuffer> buffer = gtksourceview::SourceBuffer::create(language);
57
 
       buffer->set_highlight();
 
56
       buffer->set_highlight_syntax();
58
57
       m_text_view->set_buffer(buffer);
59
58
    }
60
59
  }
92
91
  return field;
93
92
}
94
93
 
 
94
bool Dialog_FieldCalculation::check_for_return_statement(const Glib::ustring& calculation)
 
95
{
 
96
  if(calculation.find("return") == Glib::ustring::npos)
 
97
  {
 
98
     Frame_Glom::show_ok_dialog(_("Calculation Error"), _("The calculation does not have a return statement."), *this);
 
99
     return false;
 
100
  }
 
101
  
 
102
  return true;
 
103
}
 
104
 
95
105
void Dialog_FieldCalculation::on_button_test()
96
106
{
97
107
  const Glib::ustring calculation = m_text_view->get_buffer()->get_text();
 
108
  if(!check_for_return_statement(calculation))
 
109
    return;
98
110
 
99
111
  type_map_fields field_values;
100
112