Commit fbf7c39d authored by Murray Cumming's avatar Murray Cumming Committed by Murray Cumming
Browse files

Remove warn_about_images() and don't use it in on_button_add_field() and

2006-10-18  Murray Cumming  <murrayc@murrayc.com>

        * glom/mode_data/dialog_layout_list.cc:
        * glom/mode_data/dialog_layout_list.h: Remove warn_about_images()
        and don't use it in on_button_add_field() and on_button_edit_field().
        * glom/utility_widgets/imageglom.cc:
        * glom/utility_widgets/imageglom.h: Make scale_keeping_ratio() public,
        so we can use it from elsewhere, and check for null pixbufs.
        * glom/utility_widgets/db_adddel/db_adddel.cc: treeviewcolumn_on_cell_data():
        Show pixbufs too, so that Image fields show up in the list view too.
parent 131ca868
2006-10-18 Murray Cumming <murrayc@murrayc.com>
* glom/mode_data/dialog_layout_list.cc:
* glom/mode_data/dialog_layout_list.h: Remove warn_about_images()
and don't use it in on_button_add_field() and on_button_edit_field().
* glom/utility_widgets/imageglom.cc:
* glom/utility_widgets/imageglom.h: Make scale_keeping_ratio() public,
so we can use it from elsewhere, and check for null pixbufs.
* glom/utility_widgets/db_adddel/db_adddel.cc: treeviewcolumn_on_cell_data():
Show pixbufs too, so that Image fields show up in the list view too.
2006-10-18 Murray Cumming <murrayc@murrayc.com>
* glom/mode_design/fields/box_db_table_definition.cc:
......
......@@ -274,20 +274,15 @@ void Dialog_Layout_List::on_treeview_fields_selection_changed()
enable_buttons();
}
void Dialog_Layout_List::warn_about_images()
{
Frame_Glom::show_ok_dialog(_("Images Not Allowed On List View"), _("The list view cannot display image fields."), *this, Gtk::MESSAGE_WARNING); //TODO: Scale them down to thumbnails in a GtkCellRenderPixbuf?
}
void Dialog_Layout_List::on_button_add_field()
{
//Get the chosen field:
sharedptr<LayoutItem_Field> field = offer_field_list(m_table_name, this);
if(field)
{
if(field->get_glom_type() == Field::TYPE_IMAGE)
if(false) //field->get_glom_type() == Field::TYPE_IMAGE)
{
warn_about_images();
//warn_about_images();
}
else
{
......@@ -372,15 +367,8 @@ void Dialog_Layout_List::on_button_edit_field()
{
//Set the field details in the layout treeview:
if(field_chosen->get_glom_type() == Field::TYPE_IMAGE)
{
warn_about_images();
}
else
{
row[m_ColumnsFields.m_col_layout_item] = field_chosen;
m_modified = true;
}
row[m_ColumnsFields.m_col_layout_item] = field_chosen;
m_modified = true;
}
}
}
......
......@@ -57,8 +57,6 @@ protected:
virtual void on_treeview_fields_selection_changed();
virtual void on_cell_data_name(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& iter);
void warn_about_images();
//Tree model columns:
class ModelColumns_Fields : public Gtk::TreeModel::ColumnRecord
{
......
......@@ -29,6 +29,7 @@
#include <glom/libglom/utils.h>
#include "cellrenderer_buttonimage.h"
#include "cellrenderer_buttontext.h"
#include <glom/utility_widgets/imageglom.h> //For ImageGlom::scale_keeping_ratio().
//#include "../cellrendererlist.h"
#include <iostream> //For debug output.
#include <gtk/gtktreeview.h>
......@@ -1856,9 +1857,19 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
}
case(Field::TYPE_IMAGE):
{
//Gtk::CellRendererPixbuf* pDerived = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
//if(pDerived)
// //TODO: Reuse get_binary() and scaling code from ImageGlom.
Gtk::CellRendererPixbuf* pDerived = dynamic_cast<Gtk::CellRendererPixbuf*>(renderer);
if(pDerived)
{
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Conversions::get_pixbuf_for_gda_value(value);
//Scale it down to a sensible size.
if(pixbuf)
pixbuf = ImageGlom::scale_keeping_ratio(pixbuf, get_fixed_cell_height(), pixbuf->get_width());
pDerived->property_pixbuf() = pixbuf;
}
else
g_warning("Field::sql(): glom_type is TYPE_IMAGE but gda type is not VALUE_TYPE_BINARY");
break;
}
......
......@@ -290,6 +290,9 @@ Glib::RefPtr<Gdk::Pixbuf> ImageGlom::scale_keeping_ratio(const Glib::RefPtr<Gdk:
if( (target_height == 0) || (target_width == 0) )
return Glib::RefPtr<Gdk::Pixbuf>(); //This shouldn't happen anyway.
if(!pixbuf)
return pixbuf;
enum enum_scale_mode
{
SCALE_WIDTH,
......
......@@ -53,6 +53,8 @@ public:
void set_read_only(bool read_only = true);
static Glib::RefPtr<Gdk::Pixbuf> scale_keeping_ratio(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int target_height, int target_width);
protected:
void init();
......@@ -74,8 +76,7 @@ protected:
void setup_menu_usermode();
void scale();
static Glib::RefPtr<Gdk::Pixbuf> scale_keeping_ratio(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, int target_height, int target_width);
Gtk::Image m_image;
Gtk::Frame m_frame;
Glib::RefPtr<Gdk::Pixbuf> m_pixbuf_original; //Only stored temporarily, because it could be big.
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment