[gtkmm/gtkmm-2-24] Fix the make check build.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm/gtkmm-2-24] Fix the make check build.
- Date: Fri, 14 Jan 2011 16:56:42 +0000 (UTC)
commit 075e078c59ccf45f41f199b387130d7dfef5ca12
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Jan 14 17:56:30 2011 +0100
Fix the make check build.
* gdk/gdkmm/general.h: set_source_pixbuf(): Add default parameter values,
as are already in gtkmm-3.0.
* demos/gtk-demo/demowindow.cc:
* demos/gtk-demo/example_change_display.cc:
* demos/gtk-demo/example_drawingarea.cc:
* demos/gtk-demo/example_menus.cc:
* demos/gtk-demo/example_pixbufs.cc:
* demos/gtk-demo/example_sizegroup.cc:
* demos/gtk-demo/example_textview.cc:
* demos/gtk-demo/example_treeview_treestore.cc:
* demos/pixbuf-demo.cc: Port to the latest undeprecated gtkmm-2.4 API,
based on the gtkmm-3.0 versions of these demos.
ChangeLog | 17 ++++
demos/gtk-demo/demowindow.cc | 23 +++---
demos/gtk-demo/example_change_display.cc | 45 ++++++------
demos/gtk-demo/example_drawingarea.cc | 103 ++++++++++----------------
demos/gtk-demo/example_menus.cc | 73 ++++++++++---------
demos/gtk-demo/example_pixbufs.cc | 18 ++---
demos/gtk-demo/example_sizegroup.cc | 2 +-
demos/gtk-demo/example_textview.cc | 28 ++------
demos/gtk-demo/example_treeview_treestore.cc | 3 -
demos/pixbuf-demo.cc | 24 ++----
gdk/gdkmm/general.h | 4 +-
11 files changed, 148 insertions(+), 192 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b64741d..b200619 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,22 @@
2011-01-14 Murray Cumming <murrayc murrayc com>
+ Fix the make check build.
+
+ * gdk/gdkmm/general.h: set_source_pixbuf(): Add default parameter values,
+ as are already in gtkmm-3.0.
+ * demos/gtk-demo/demowindow.cc:
+ * demos/gtk-demo/example_change_display.cc:
+ * demos/gtk-demo/example_drawingarea.cc:
+ * demos/gtk-demo/example_menus.cc:
+ * demos/gtk-demo/example_pixbufs.cc:
+ * demos/gtk-demo/example_sizegroup.cc:
+ * demos/gtk-demo/example_textview.cc:
+ * demos/gtk-demo/example_treeview_treestore.cc:
+ * demos/pixbuf-demo.cc: Port to the latest undeprecated gtkmm-2.4 API,
+ based on the gtkmm-3.0 versions of these demos.
+
+2011-01-14 Murray Cumming <murrayc murrayc com>
+
ComobBoxText: Add append(), prepend() and insert(), deprecating *_text().
* gtk/gtkmm/comboboxtext.[h|cc]: Add append(), prepend() and insert(),
diff --git a/demos/gtk-demo/demowindow.cc b/demos/gtk-demo/demowindow.cc
index 02e2056..03195c6 100644
--- a/demos/gtk-demo/demowindow.cc
+++ b/demos/gtk-demo/demowindow.cc
@@ -22,9 +22,9 @@
#endif
#include "demowindow.h"
+#include "gtkmm/main.h"
#include "gtkmm/cellrenderertext.h"
#include "gtkmm/treeviewcolumn.h"
-#include "gtkmm/main.h"
#include "textwidget.h"
#include "demos.h"
#include <vector>
@@ -211,9 +211,7 @@ bool DemoWindow::read_line (FILE *stream, GString *str)
#ifdef HAVE_GETC_UNLOCKED
c = getc_unlocked (stream);
-#else
- c = getc(stream);
-#endif //HAVE_GETC_UNLOCKED
+#endif //GLIBMM_PROPERTIES_ENABLED
if (c == EOF)
goto done;
else
@@ -226,14 +224,12 @@ bool DemoWindow::read_line (FILE *stream, GString *str)
{
#ifdef HAVE_GETC_UNLOCKED
int next_c = getc_unlocked (stream);
-#else
- int next_c = getc(stream);
-#endif //HAVE_GETC_UNLOCKED
+#endif //GLIBMM_PROPERTIES_ENABLED
if (!(next_c == EOF ||
(c == '\r' && next_c == '\n') ||
(c == '\n' && next_c == '\r')))
ungetc (next_c, stream);
-
+
goto done;
}
default:
@@ -320,11 +316,11 @@ void DemoWindow::load_file(const std::string& filename)
refBufferInfo->apply_tag_by_name("title", start, end);
start = end;
-
+
state++;
}
break;
-
+
case 1:
/* Reading body of info section */
while (isspace (*p))
@@ -338,14 +334,14 @@ void DemoWindow::load_file(const std::string& filename)
else
{
int len;
-
+
while (*p == '*' || isspace (*p))
p++;
len = strlen (p);
while (isspace (*(p + len - 1)))
len--;
-
+
if (len > 0)
{
if (in_para)
@@ -377,7 +373,7 @@ void DemoWindow::load_file(const std::string& filename)
}
else
break;
-
+
case 3:
/* Reading program body */
start = refBufferSource->insert(start, p);
@@ -404,3 +400,4 @@ void DemoWindow::on_example_window_hide()
}
}
}
+
diff --git a/demos/gtk-demo/example_change_display.cc b/demos/gtk-demo/example_change_display.cc
index 216263e..292928b 100644
--- a/demos/gtk-demo/example_change_display.cc
+++ b/demos/gtk-demo/example_change_display.cc
@@ -55,7 +55,7 @@ protected:
virtual void query_change_display();
virtual Gtk::Widget* find_toplevel_at_pointer(const Glib::RefPtr<Gdk::Display>& display);
virtual Gtk::Window* query_for_toplevel(const Glib::RefPtr<Gdk::Screen>& screen, const Glib::ustring& prompt);
-
+
//signal handlers:
virtual void on_button_display_open();
virtual void on_button_display_close();
@@ -66,7 +66,7 @@ protected:
virtual void on_display_closed(bool is_error, Glib::RefPtr<Gdk::Display> display);
virtual bool on_popup_button_release_event(GdkEventButton* event);
-
+
virtual void on_response(int response_id);
@@ -89,7 +89,7 @@ protected:
ModelColumns_Screen() { add(m_number); add(m_screen); }
};
ModelColumns_Screen m_columns_screen;
-
+
Gtk::VBox m_VBox;
Gtk::Frame m_Frame_Display, m_Frame_Screen;
Gtk::TreeView m_TreeView_Display, m_TreeView_Screen;
@@ -100,13 +100,13 @@ protected:
Glib::RefPtr<Gtk::SizeGroup> m_refSizeGroup_Display, m_refSizeGroup_Screen;
-
+
Glib::RefPtr<Gdk::Display> m_refCurrentDisplay;
Glib::RefPtr<Gdk::Screen> m_refCurrentScreen;
Popup* m_pPopup;
- bool m_popup_clicked;
+ bool m_popup_clicked;
};
@@ -122,13 +122,11 @@ Example_ChangeDisplay::Example_ChangeDisplay()
m_pPopup(0),
m_popup_clicked(false)
{
- set_has_separator(false);
-
add_button(Gtk::Stock::CLOSE, Gtk::RESPONSE_CLOSE);
add_button("Change", Gtk::RESPONSE_OK);
set_default_size(300, 400);
-
+
m_VBox.set_border_width(8);
get_vbox()->pack_start(m_VBox);
@@ -155,7 +153,7 @@ Example_ChangeDisplay::Example_ChangeDisplay()
m_refSizeGroup_Display = Gtk::SizeGroup::create(Gtk::SIZE_GROUP_HORIZONTAL);
m_refSizeGroup_Display->add_widget(m_ButtonBox_Display);
}
-
+
//Screen:
{
setup_frame(m_Frame_Screen, m_TreeView_Screen, m_ButtonBox_Screen);
@@ -221,7 +219,7 @@ void Example_ChangeDisplay::initialize_displays()
for(type_listDisplays::iterator iter = listDisplays.begin(); iter != listDisplays.end(); ++iter)
{
Glib::RefPtr<Gdk::Display> refDisplay = *iter;
-
+
Gtk::TreeRow row = *(m_refListStore_Display->append());
row[m_columns_display.m_name] = refDisplay->get_name();;
row[m_columns_display.m_display] = refDisplay;
@@ -230,7 +228,7 @@ void Example_ChangeDisplay::initialize_displays()
sigc::bind<-1>( sigc::mem_fun(*this, &Example_ChangeDisplay::on_display_closed), refDisplay) );
}
-#endif
+#endif
}
void Example_ChangeDisplay::on_display_closed(bool /* is_error */, Glib::RefPtr<Gdk::Display> display)
@@ -273,7 +271,7 @@ void Example_ChangeDisplay::on_button_display_open()
if (response_id != Gtk::RESPONSE_OK)
break;
- Glib::ustring new_screen_name = entry.get_text();
+ Glib::ustring new_screen_name = entry.get_text();
if( !new_screen_name.empty() )
{
@@ -301,7 +299,7 @@ void Example_ChangeDisplay::on_treeview_display_selection_changed()
else
m_refCurrentDisplay.reset();
- fill_screens();
+ fill_screens();
}
void Example_ChangeDisplay::on_treeview_screen_selection_changed()
@@ -323,11 +321,11 @@ void Example_ChangeDisplay::fill_screens()
if(m_refCurrentScreen)
{
int n_screens = m_refCurrentDisplay->get_n_screens();
-
+
for (int i = 0; i < n_screens; i++)
{
Glib::RefPtr<Gdk::Screen> refScreen = m_refCurrentDisplay->get_screen(i);
-
+
Gtk::TreeModel::Row row = *(m_refListStore_Screen->append());
row[m_columns_screen.m_number] = i;
row[m_columns_screen.m_screen] = refScreen;
@@ -381,7 +379,7 @@ Gtk::Window* Example_ChangeDisplay::query_for_toplevel(const Glib::RefPtr<Gdk::S
delete m_pPopup;
m_pPopup = 0;
}
-
+
m_pPopup = new Popup(screen, prompt);
m_pPopup->show();
@@ -389,13 +387,16 @@ Gtk::Window* Example_ChangeDisplay::query_for_toplevel(const Glib::RefPtr<Gdk::S
Gdk::Cursor cursor(refDisplay, Gdk::CROSSHAIR);
Gtk::Window* toplevel = 0;
-
- if( m_pPopup->get_window()->pointer_grab(false, Gdk::BUTTON_RELEASE_MASK, cursor, GDK_CURRENT_TIME)
- == Gdk::GRAB_SUCCESS )
+
+ //TODO: Find a suitable replacement for this:
+ //const GdkGrabStatus grabbed = m_pPopup->get_window()->grab(false, Gdk::BUTTON_RELEASE_MASK, cursor, GDK_CURRENT_TIME);
+ //Check it when the GTK+ example has been updated and file a bug about the unhelpful deprecation comment.
+ const Gdk::GrabStatus grabbed = Gdk::GRAB_SUCCESS;
+ if(grabbed == Gdk::GRAB_SUCCESS )
{
m_popup_clicked = false;
m_pPopup->signal_button_release_event().connect( sigc::mem_fun(*this, &Example_ChangeDisplay::on_popup_button_release_event) );
-
+
// Process events until clicked is set by button_release_event_cb.
// We pass in may_block=true since we want to wait if there
@@ -466,12 +467,10 @@ Popup::Popup(const Glib::RefPtr<Gdk::Screen> screen, const Glib::ustring& prompt
Popup::~Popup()
{
}
-
+
// called by DemoWindow
Gtk::Window* do_change_display()
{
return new Example_ChangeDisplay();
}
-
-
diff --git a/demos/gtk-demo/example_drawingarea.cc b/demos/gtk-demo/example_drawingarea.cc
index a79707b..602e51f 100644
--- a/demos/gtk-demo/example_drawingarea.cc
+++ b/demos/gtk-demo/example_drawingarea.cc
@@ -37,7 +37,7 @@ protected:
Gtk::Label m_Label_Checkerboard, m_Label_Scribble;
Gtk::DrawingArea m_DrawingArea_Checkerboard, m_DrawingArea_Scribble;
- Glib::RefPtr<Gdk::Pixmap> m_refPixmap_Scribble;
+ Cairo::RefPtr<Cairo::Surface> m_surface;
};
//Called by DemoWindow;
@@ -111,7 +111,7 @@ Example_DrawingArea::~Example_DrawingArea()
{
}
-bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpose*)
+bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpose* event)
{
enum { CHECK_SIZE = 10, SPACING = 2 };
@@ -122,46 +122,33 @@ bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpos
* works.
*/
- /* It would be a bit more efficient to keep these
- * GC's around instead of recreating on each expose, but
- * this is the lazy/slow way.
- */
- Glib::RefPtr<Gdk::GC> refGC1 = Gdk::GC::create(m_DrawingArea_Checkerboard.get_window());
- Gdk::Color color;
- color.set_red(30000);
- color.set_green(0);
- color.set_blue(30000);
- refGC1->set_rgb_fg_color(color);
-
- Glib::RefPtr<Gdk::GC> refGC2 = Gdk::GC::create(m_DrawingArea_Checkerboard.get_window());
- color.set_red(65535);
- color.set_green(65535);
- color.set_blue(65535);
- refGC2->set_rgb_fg_color(color);
-
- gint xcount = 0;
- gint i = SPACING;
- while (i < m_DrawingArea_Checkerboard.get_allocation().get_width())
+ Glib::RefPtr<Gdk::Window> window = get_window();
+ Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+
+ const Gdk::Rectangle rectangle(&(event->area));
+ Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+ cr->clip();
+
+ int xcount = 0;
+ int i = SPACING;
+ const int width = m_DrawingArea_Checkerboard.get_allocation().get_width();
+ while (i < width)
{
- gint j = SPACING;
- gint ycount = xcount % 2; /* start with even/odd depending on row */
+ int j = SPACING;
+ int ycount = xcount % 2; /* start with even/odd depending on row */
while (j < m_DrawingArea_Checkerboard.get_allocation().get_height())
{
- Glib::RefPtr<Gdk::GC> refGC;
-
if (ycount % 2)
- refGC = refGC1;
+ cr->set_source_rgb(0.45777, 0, 0.45777);
else
- refGC = refGC2;
+ cr->set_source_rgb(1, 1, 1);
/* If we're outside event->area, this will do nothing.
* It might be mildly more efficient if we handled
* the clipping ourselves, but again we're feeling lazy.
*/
- m_DrawingArea_Checkerboard.get_window()->draw_rectangle(refGC,
- true,
- i, j,
- CHECK_SIZE, CHECK_SIZE);
+ cr->rectangle(i, j, CHECK_SIZE, CHECK_SIZE);
+ cr->fill();
j += CHECK_SIZE + SPACING;
++ycount;
@@ -179,36 +166,26 @@ bool Example_DrawingArea::on_drawingarea_checkerboard_expose_event(GdkEventExpos
bool Example_DrawingArea::on_drawingarea_scribble_expose_event(GdkEventExpose* event)
{
- /* We use the "foreground GC" for the widget since it already exists,
- * but honestly any GC would work. The only thing to worry about
- * is whether the GC has an inappropriate clip region set.
- */
- m_DrawingArea_Scribble.get_window()->draw_drawable(
- m_DrawingArea_Scribble.get_style()->get_fg_gc(m_DrawingArea_Scribble.get_state()),
- m_refPixmap_Scribble,
- // Only copy the area that was exposed:
- event->area.x, event->area.y,
- event->area.x, event->area.y,
- event->area.width, event->area.height);
+ Glib::RefPtr<Gdk::Window> window = get_window();
+ Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+ cr->set_source(m_surface, 0, 0); //TODO: Add =0 default parameters to cairomm.
+
+ const Gdk::Rectangle rectangle(&(event->area));
+ Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+ cr->clip();
return false;
}
bool Example_DrawingArea::on_drawingarea_scribble_configure_event(GdkEventConfigure*)
{
- m_refPixmap_Scribble = Gdk::Pixmap::create(
- m_DrawingArea_Scribble.get_window(),
- m_DrawingArea_Scribble.get_allocation().get_width(),
- m_DrawingArea_Scribble.get_allocation().get_height(),
- -1);
-
- /* Initialize the pixmap to white */
- m_refPixmap_Scribble->draw_rectangle(
- m_DrawingArea_Scribble.get_style()->get_white_gc(),
- true,
- 0, 0,
- m_DrawingArea_Scribble.get_allocation().get_width(),
- m_DrawingArea_Scribble.get_allocation().get_height());
+ const Gtk::Allocation allocation = m_DrawingArea_Scribble.get_allocation();
+ m_surface =
+ m_DrawingArea_Scribble.get_window()->create_similar_surface(
+ Cairo::CONTENT_COLOR, allocation.get_width(), allocation.get_height());
+ Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(m_surface);
+ cr->set_source_rgb(1, 1, 1);
+ cr->paint();
/* We've handled the configure event, no need for further processing. */
return true;
@@ -216,7 +193,7 @@ bool Example_DrawingArea::on_drawingarea_scribble_configure_event(GdkEventConfig
bool Example_DrawingArea::on_drawingarea_scribble_motion_notify_event(GdkEventMotion* event)
{
- if(!m_refPixmap_Scribble)
+ if(!m_surface)
return false; // paranoia check, in case we haven't gotten a configure event
/* This call is very important; it requests the next motion event. If you
@@ -250,7 +227,7 @@ bool Example_DrawingArea::on_drawingarea_scribble_motion_notify_event(GdkEventMo
bool Example_DrawingArea::on_drawingarea_scribble_button_press_event(GdkEventButton* event)
{
- if(!m_refPixmap_Scribble)
+ if(!m_surface)
return false; // paranoia check, in case we haven't gotten a configure event
if(event->button == 1)
@@ -266,13 +243,9 @@ void Example_DrawingArea::scribble_draw_brush(int x, int y)
{
const Gdk::Rectangle update_rect (x - 3, y - 3, 6, 6);
- // Paint to the pixmap, where we store our state.
- //
- m_refPixmap_Scribble->draw_rectangle(
- m_DrawingArea_Scribble.get_style()->get_black_gc(),
- true,
- update_rect.get_x(), update_rect.get_y(),
- update_rect.get_width(), update_rect.get_height());
+ Cairo::RefPtr<Cairo::Context> cr = Cairo::Context::create(m_surface);
+ Gdk::Cairo::add_rectangle_to_path(cr, update_rect);
+ cr->fill();
// Now invalidate the affected region of the drawing area.
m_DrawingArea_Scribble.get_window()->invalidate_rect(update_rect, false);
diff --git a/demos/gtk-demo/example_menus.cc b/demos/gtk-demo/example_menus.cc
index a286c53..770de86 100644
--- a/demos/gtk-demo/example_menus.cc
+++ b/demos/gtk-demo/example_menus.cc
@@ -67,21 +67,22 @@ Example_Menus::Example_Menus()
m_VBox1.pack_start(m_MenuBar, Gtk::PACK_SHRINK);
{
- using namespace Gtk::Menu_Helpers;
- MenuList items = m_MenuBar.items();
-
- items.push_back(MenuElem("test\nline2"));
- Gtk::MenuItem* pMenuItem = &items.back();
+ //Note:: It's generally easier to use the Gtk::UIManager API.
+ Gtk::MenuItem* pMenuItem = Gtk::manage(new Gtk::MenuItem("test\nline2"));
pMenuItem->set_submenu( *(create_menu(2, true)) );
+ m_MenuBar.append(*pMenuItem);
+ pMenuItem->show();
- items.push_back(MenuElem("foo"));
- pMenuItem = &items.back();
+ pMenuItem = Gtk::manage(new Gtk::MenuItem("foo"));
pMenuItem->set_submenu( *(create_menu(3, true)) );
+ m_MenuBar.append(*pMenuItem);
+ pMenuItem->show();
- items.push_back(MenuElem("bar"));
- pMenuItem = &items.back();
+ pMenuItem = Gtk::manage(new Gtk::MenuItem("bar"));
pMenuItem->set_submenu( *(create_menu(4, true)) );
pMenuItem->set_right_justified();
+ m_MenuBar.append(*pMenuItem);
+ pMenuItem->show();
}
@@ -92,16 +93,24 @@ Example_Menus::Example_Menus()
Gtk::Menu* pMenu = create_menu(1, false);
pMenu->set_accel_group(get_accel_group());
- using namespace Gtk::Menu_Helpers;
- MenuList items = pMenu->items();
+ Gtk::MenuItem* pMenuItem = Gtk::manage(new Gtk::SeparatorMenuItem());
+ pMenu->append(*pMenuItem);
+ pMenuItem->show();
+
+ pMenuItem = Gtk::manage(new Gtk::CheckMenuItem("Accelerate Me"));
+ pMenuItem->add_accelerator("activate", get_accel_group(), GDK_KEY_F1, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE );
+ pMenu->append(*pMenuItem);
+ pMenuItem->show();
- items.push_back(SeparatorElem());
- items.push_back( CheckMenuElem("Accelerate Me", Gtk::AccelKey(GDK_F1, Gdk::ModifierType(0))) );
- items.push_back( CheckMenuElem("Accelerator Locked") );
- items.back().add_accelerator("activate", get_accel_group(), GDK_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED);
- items.push_back( CheckMenuElem("Accelerator Frozen") );
- items.back().add_accelerator("activate", get_accel_group(), GDK_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);
- items.back().add_accelerator("activate", get_accel_group(), GDK_F3, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);
+ pMenuItem = Gtk::manage(new Gtk::CheckMenuItem("Accelerator Locked"));
+ pMenu->append(*pMenuItem);
+ pMenuItem->add_accelerator("activate", get_accel_group(), GDK_KEY_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE | Gtk::ACCEL_LOCKED);
+ pMenuItem->show();
+
+ pMenuItem = Gtk::manage(new Gtk::CheckMenuItem("Accelerator Frozen"));
+ pMenu->append(*pMenuItem);
+ pMenuItem->add_accelerator("activate", get_accel_group(), GDK_KEY_F2, Gdk::ModifierType(0), Gtk::ACCEL_VISIBLE);
+ pMenuItem->show();
}
m_VBox1.pack_start(m_Separator, Gtk::PACK_SHRINK);
@@ -131,13 +140,11 @@ Gtk::Menu* Example_Menus::create_menu(gint depth, bool tearoff)
Gtk::Menu* pMenu = Gtk::manage(new Gtk::Menu());
{
- using namespace Gtk::Menu_Helpers;
-
- MenuList items = pMenu->items();
-
if(tearoff)
{
- items.push_back(TearoffMenuElem());
+ Gtk::MenuItem* menu_item = Gtk::manage(new Gtk::TearoffMenuItem());
+ pMenu->append(*menu_item);
+ menu_item->show();
}
Gtk::RadioMenuItem::Group radiogroup;
@@ -147,18 +154,16 @@ Gtk::Menu* Example_Menus::create_menu(gint depth, bool tearoff)
char buf[32];
sprintf(buf, "item %2d - %d", depth, j);
- items.push_back(RadioMenuElem(radiogroup, buf));
+ Gtk::MenuItem* pMenuItem = Gtk::manage(new Gtk::RadioMenuItem(radiogroup, buf));
+ pMenu->append(*pMenuItem);
+ pMenuItem->show();
- Gtk::MenuItem* pMenuItem = &items.back();
- if(pMenuItem)
- {
- if(i == 3)
- pMenuItem->set_sensitive(false);
+ if(i == 3)
+ pMenuItem->set_sensitive(false);
- Gtk::Menu* pSubMenu = create_menu(depth - 1, true);
- if(pSubMenu)
- pMenuItem->set_submenu(*pSubMenu);
- }
+ Gtk::Menu* pSubMenu = create_menu(depth - 1, true);
+ if(pSubMenu)
+ pMenuItem->set_submenu(*pSubMenu);
}
}
@@ -169,5 +174,3 @@ void Example_Menus::on_button_clicked()
{
hide();
}
-
-
diff --git a/demos/gtk-demo/example_pixbufs.cc b/demos/gtk-demo/example_pixbufs.cc
index d6af32f..7a27442 100644
--- a/demos/gtk-demo/example_pixbufs.cc
+++ b/demos/gtk-demo/example_pixbufs.cc
@@ -126,19 +126,13 @@ void Example_Pixbufs::load_pixbufs()
/* Expose callback for the drawing area */
bool Example_Pixbufs::on_drawingarea_expose(GdkEventExpose *event)
{
- gint rowstride = m_refPixbuf->get_rowstride();
+ Glib::RefPtr<Gdk::Window> window = get_window();
+ Cairo::RefPtr<Cairo::Context> cr = window->create_cairo_context();
+ Gdk::Cairo::set_source_pixbuf(cr, m_refPixbuf_Background);
- const guchar* pixels = m_refPixbuf->get_pixels() + (rowstride * event->area.y) + (event->area.x * 3);
-
- Glib::RefPtr<Gdk::Window> refWindow = m_DrawingArea.get_window();
- Glib::RefPtr<Gdk::GC> refGC = m_DrawingArea.get_style()->get_black_gc();
-
- refWindow->draw_rgb_image_dithalign(refGC,
- event->area.x, event->area.y,
- event->area.width, event->area.height,
- Gdk::RGB_DITHER_NORMAL,
- pixels, rowstride,
- event->area.x, event->area.y);
+ const Gdk::Rectangle rectangle(&(event->area));
+ Gdk::Cairo::add_rectangle_to_path(cr, rectangle);
+ cr->fill();
return true;
}
diff --git a/demos/gtk-demo/example_sizegroup.cc b/demos/gtk-demo/example_sizegroup.cc
index c980a99..89f4e12 100644
--- a/demos/gtk-demo/example_sizegroup.cc
+++ b/demos/gtk-demo/example_sizegroup.cc
@@ -153,7 +153,7 @@ Gtk::ComboBoxText* Example_SizeGroup::create_combobox(const std::list<Glib::ustr
for(type_listStrings::const_iterator iter = strings.begin(); iter != strings.end(); iter++)
{
- pCombo->append_text(*iter);
+ pCombo->append(*iter);
}
return pCombo;
diff --git a/demos/gtk-demo/example_textview.cc b/demos/gtk-demo/example_textview.cc
index 73549a6..5ba9193 100644
--- a/demos/gtk-demo/example_textview.cc
+++ b/demos/gtk-demo/example_textview.cc
@@ -136,14 +136,6 @@ void Example_TextView::create_tags(Glib::RefPtr<Gtk::TextBuffer>& refBuffer)
refBuffer->create_tag("blue_foreground")->property_foreground() = "blue";
refBuffer->create_tag("red_background")->property_background() = "red";
- enum { gray50_width = 2, gray50_height = 2 };
- static const char gray50_bits[] = { 0x02, 0x01 };
-
- Glib::RefPtr<Gdk::Bitmap> refStipple = Gdk::Bitmap::create(gray50_bits, gray50_width, gray50_height);
-
- refBuffer->create_tag("background_stipple")->property_background_stipple() = refStipple;
- refBuffer->create_tag("foreground_stipple")->property_foreground_stipple() = refStipple;
-
refBuffer->create_tag("big_gap_before_line")->property_pixels_above_lines() = 30;
refBuffer->create_tag("big_gap_after_line")->property_pixels_below_lines() = 30;
refBuffer->create_tag("double_spaced_line")->property_pixels_inside_wrap() = 10;
@@ -224,18 +216,10 @@ void Example_TextView::insert_text(Glib::RefPtr<Gtk::TextBuffer>& refBuffer)
iter = refBuffer->insert_with_tag(iter, "a red background", "red_background");
iter = refBuffer->insert(iter, " or even ");
-
typedef const char* type_constpch;
{
- type_constpch tag_names[] = {"red_background", "background_stipple", 0};
- iter = refBuffer->insert_with_tags_by_name(iter, "a stippled red background", tag_names);
- }
-
- iter = refBuffer->insert(iter, " or ");
-
- {
- type_constpch tag_names[] = {"blue_foreground", "red_background", "foreground_stipple", 0};
- iter = refBuffer->insert_with_tags_by_name(iter, "a stippled blue foreground on solid red background", tag_names);
+ type_constpch tag_names[] = {"blue_foreground", "red_background", 0};
+ iter = refBuffer->insert_with_tags_by_name(iter, "a blue foreground on red background", tag_names);
}
iter = refBuffer->insert(iter, " (select that to read it) can be used.\n\n");
@@ -312,7 +296,7 @@ void Example_TextView::insert_text(Glib::RefPtr<Gtk::TextBuffer>& refBuffer)
"wide_margins");
iter = refBuffer->insert_with_tag(iter, "Internationalization. ", "heading");
-
+
iter = refBuffer->insert(iter,
"You can put all sorts of Unicode text in the buffer.\n\nGerman (Deutsch S\xC3\xBC""d) "
"Gr\xC3\xBC\xC3\x9F Gott\nGreek (\xCE\x95\xCE\xBB\xCE\xBB\xCE\xB7\xCE\xBD\xCE\xB9\xCE\xBA"
@@ -397,9 +381,9 @@ void Example_TextView::attach_widgets(Gtk::TextView& text_view)
else if (i == 1)
{
Gtk::ComboBoxText* pCombo = Gtk::manage( new Gtk::ComboBoxText() );
- pCombo->append_text("Option 1");
- pCombo->append_text("Option 2");
- pCombo->append_text("Option 3");
+ pCombo->append("Option 1");
+ pCombo->append("Option 2");
+ pCombo->append("Option 3");
pWidget = pCombo;
}
diff --git a/demos/gtk-demo/example_treeview_treestore.cc b/demos/gtk-demo/example_treeview_treestore.cc
index 4f5a814..4bceeb9 100644
--- a/demos/gtk-demo/example_treeview_treestore.cc
+++ b/demos/gtk-demo/example_treeview_treestore.cc
@@ -173,9 +173,6 @@ Example_TreeView_TreeStore::Example_TreeView_TreeStore()
add_columns();
m_ScrolledWindow.add(m_TreeView);
-#ifndef GLIBMM_DEFAULT_SIGNAL_HANDLERS_ENABLED
- signal_realize().connect(sigc::mem_fun(*this, &Example_TreeView_TreeStore::on_realize), false);
-#endif
show_all();
}
diff --git a/demos/pixbuf-demo.cc b/demos/pixbuf-demo.cc
index 5db9244..8b3e431 100644
--- a/demos/pixbuf-demo.cc
+++ b/demos/pixbuf-demo.cc
@@ -34,8 +34,8 @@
#include <gdkmm/rectangle.h>
#include <gtkmm/drawingarea.h>
#include <gtkmm/main.h>
-#include <gtkmm/style.h>
#include <gtkmm/window.h>
+#include <gdkmm/general.h>
namespace
{
@@ -73,7 +73,7 @@ public:
virtual ~DemoRenderArea();
protected:
- virtual bool on_expose_event(GdkEventExpose* event);
+ virtual bool on_draw(const Cairo::RefPtr<Cairo::Context>& cr);
private:
Glib::RefPtr<const Gdk::Pixbuf> background_;
@@ -122,27 +122,20 @@ DemoRenderArea::~DemoRenderArea()
{}
/*
- * Expose event handler of the widget. Just fill the exposed
+ * Draw handler of the widget. Just fill the exposed
* area with the corresponding pixmap data from current_frame_.
*/
-bool DemoRenderArea::on_expose_event(GdkEventExpose* event)
+bool DemoRenderArea::on_draw(const Cairo::RefPtr<Cairo::Context>& cr)
{
- const int rowstride = current_frame_->get_rowstride();
- const size_t offset = rowstride * event->area.y + 3 * event->area.x;
-
- get_window()->draw_rgb_image_dithalign(
- get_style()->get_black_gc(),
- event->area.x, event->area.y, event->area.width, event->area.height,
- Gdk::RGB_DITHER_NORMAL,
- ¤t_frame_->get_pixels()[offset], rowstride,
- event->area.x, event->area.y);
+ Gdk::Cairo::set_source_pixbuf(cr, current_frame_);
+ cr->paint();
return true; // stop signal emission
}
/*
* Generate the next frame of the animation and store it into current_frame_.
- * The expose_event handler accesses that buffer to do the actual drawing.
+ * The draw handler accesses that buffer to do the actual drawing.
*/
void DemoRenderArea::generate_next_frame()
{
@@ -190,7 +183,7 @@ void DemoRenderArea::generate_next_frame()
frame_num_ = (frame_num_ + 1) % CYCLE_LEN;
// Tell GTK+ the widget should be redrawn soon. This will trigger the
- // expose_event signal if the widget is actually mapped on the screen.
+ // draw signal if the widget is actually mapped on the screen.
queue_draw();
}
@@ -217,4 +210,3 @@ int main(int argc, char** argv)
}
return EXIT_SUCCESS;
}
-
diff --git a/gdk/gdkmm/general.h b/gdk/gdkmm/general.h
index b5959a6..4bb9847 100644
--- a/gdk/gdkmm/general.h
+++ b/gdk/gdkmm/general.h
@@ -70,7 +70,7 @@ void set_source_color(const ::Cairo::RefPtr< ::Cairo::Context >& context, const
*
* @newin{2,10}
*/
-void set_source_pixbuf(::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double pixbuf_x, double pixbuf_y);
+void set_source_pixbuf(::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double pixbuf_x = 0, double pixbuf_y = 0);
#endif
/** Sets the given pixbuf as the source pattern for the Cairo context. The pattern has an extend mode of CAIRO_EXTEND_NONE and is aligned so that the origin of pixbuf is pixbuf_x, pixbuf_y.
@@ -81,7 +81,7 @@ void set_source_pixbuf(::Cairo::RefPtr< ::Cairo::Context >& context, const Glib:
*
* @newin{2,12}
*/
-void set_source_pixbuf(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double pixbuf_x, double pixbuf_y);
+void set_source_pixbuf(const ::Cairo::RefPtr< ::Cairo::Context >& context, const Glib::RefPtr<Gdk::Pixbuf>& pixbuf, double pixbuf_x = 0, double pixbuf_y = 0);
#ifndef GDKMM_DISABLE_DEPRECATED
/** Sets the given pixbuf as the source pattern for the Cairo context. The pattern has an extend mode of CAIRO_EXTEND_NONE and is aligned so that the origin of pixbuf is pixmap_x, pixmap_y.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]