[gtkmm-documentation] Adapt to latest versions of gtk+ and gtkmm (Clipboard, DnD)
- From: Kjell Ahlstedt <kjellahl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtkmm-documentation] Adapt to latest versions of gtk+ and gtkmm (Clipboard, DnD)
- Date: Wed, 27 Dec 2017 09:11:31 +0000 (UTC)
commit 15bb1b717c28334b28e7f7393021524717a16ef0
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date: Wed Dec 27 10:09:20 2017 +0100
Adapt to latest versions of gtk+ and gtkmm (Clipboard, DnD)
Many changes in clipboard and drag-and-drop.
Gtk::FontButton::set/get/property_font_name() are gone.
Use Gtk::FontChooser::set/get/property_font() instead.
Gtk::HeaderBar::set/get/property_show_close_button() have been renamed to
set/get/property_show_title_buttons().
Added some #undef GTKMM_DISABLE_DEPRECATED until we know what to use
instead of deprecated event signals.
examples/book/buildapp/step5/exampleappprefs.cc | 2 +-
examples/book/buildapp/step9/window.ui | 2 +-
examples/book/clipboard/ideal/examplewindow.cc | 144 +++++++-------------
examples/book/clipboard/ideal/examplewindow.h | 10 +-
examples/book/clipboard/simple/examplewindow.cc | 32 +++--
examples/book/clipboard/simple/examplewindow.h | 5 +-
.../dialogs/fontchooserdialog/examplewindow.cc | 6 +-
examples/book/drag_and_drop/dndwindow.cc | 19 ++--
examples/book/drag_and_drop/dndwindow.h | 4 +-
examples/book/headerbar/examplewindow.cc | 10 +-
examples/book/headerbar/examplewindow.h | 2 +-
examples/book/menus/popup/examplewindow.cc | 3 +
.../book/printing/advanced/printformoperation.cc | 4 +-
examples/book/toolpalette/canvas.cc | 14 +-
examples/book/toolpalette/canvas.h | 3 +-
examples/book/toolpalette/examplewindow.cc | 11 +-
examples/others/calendar/calendar.cc | 2 +-
.../others/cellrenderercustom/cellrendererlist.cc | 3 +
.../others/cellrenderercustom/cellrendererpopup.cc | 3 +
examples/others/dnd/dndwindow.cc | 19 ++-
examples/others/dnd/dndwindow.h | 4 +-
21 files changed, 138 insertions(+), 164 deletions(-)
---
diff --git a/examples/book/buildapp/step5/exampleappprefs.cc b/examples/book/buildapp/step5/exampleappprefs.cc
index 056f44d..97c7aa3 100644
--- a/examples/book/buildapp/step5/exampleappprefs.cc
+++ b/examples/book/buildapp/step5/exampleappprefs.cc
@@ -34,7 +34,7 @@ ExampleAppPrefs::ExampleAppPrefs(BaseObjectType* cobject,
throw std::runtime_error("No \"transition\" object in prefs.ui");
m_settings = Gio::Settings::create("org.gtkmm.exampleapp");
- m_settings->bind("font", m_font->property_font_name());
+ m_settings->bind("font", m_font->property_font());
m_settings->bind("transition", m_transition->property_active_id());
}
diff --git a/examples/book/buildapp/step9/window.ui b/examples/book/buildapp/step9/window.ui
index 0261a3c..c0389f7 100644
--- a/examples/book/buildapp/step9/window.ui
+++ b/examples/book/buildapp/step9/window.ui
@@ -8,7 +8,7 @@
<object class="GtkHeaderBar" id="header">
<property name="title" translatable="yes">Example Application</property>
<property name="visible">True</property>
- <property name="show-close-button">True</property>
+ <property name="show-title-buttons">True</property>
<property name="decoration-layout">menu:close</property>
<child>
<object class="GtkLabel" id="lines_label">
diff --git a/examples/book/clipboard/ideal/examplewindow.cc b/examples/book/clipboard/ideal/examplewindow.cc
index 716bd48..25bf3f3 100644
--- a/examples/book/clipboard/ideal/examplewindow.cc
+++ b/examples/book/clipboard/ideal/examplewindow.cc
@@ -15,14 +15,13 @@
*/
#include "examplewindow.h"
-#include <algorithm>
+#include <iostream>
+#include <string>
namespace
{
-//These should usually be MIME types.
const char example_format_custom[] = "gtkmmclipboardexample";
-const char example_format_text[] = "UTF8_STRING";
} // anonymous namespace
@@ -46,10 +45,10 @@ ExampleWindow::ExampleWindow()
m_VBox.pack_start(m_Grid, Gtk::PackOptions::EXPAND_WIDGET);
m_Grid.set_row_homogeneous(true);
m_Grid.set_column_homogeneous(true);
- m_Grid.attach(m_ButtonA1, 0, 0, 1, 1);
- m_Grid.attach(m_ButtonA2, 1, 0, 1, 1);
- m_Grid.attach(m_ButtonB1, 0, 1, 1, 1);
- m_Grid.attach(m_ButtonB2, 1, 1, 1, 1);
+ m_Grid.attach(m_ButtonA1, 0, 0);
+ m_Grid.attach(m_ButtonA2, 1, 0);
+ m_Grid.attach(m_ButtonB1, 0, 1);
+ m_Grid.attach(m_ButtonB2, 1, 1);
//Add ButtonBox to bottom:
m_VBox.pack_start(m_ButtonBox, Gtk::PackOptions::SHRINK);
@@ -66,8 +65,8 @@ ExampleWindow::ExampleWindow()
//Connect a signal handler that will be called when the contents of
//the clipboard change.
- Gtk::Clipboard::get()->signal_owner_change().connect(sigc::mem_fun(*this,
- &ExampleWindow::on_clipboard_owner_change) );
+ get_clipboard()->property_content().signal_changed().connect(sigc::mem_fun(*this,
+ &ExampleWindow::on_clipboard_content_changed));
update_paste_status();
}
@@ -80,122 +79,77 @@ void ExampleWindow::on_button_copy()
{
//Build a string representation of the stuff to be copied:
//Ideally you would use XML, with an XML parser here:
- Glib::ustring strData;
- strData += m_ButtonA1.get_active() ? "1" : "0";
- strData += m_ButtonA2.get_active() ? "1" : "0";
- strData += m_ButtonB1.get_active() ? "1" : "0";
- strData += m_ButtonB2.get_active() ? "1" : "0";
+ Glib::ustring strData(example_format_custom);
+ strData += m_ButtonA1.get_active() ? " A1" : "";
+ strData += m_ButtonA2.get_active() ? " A2" : "";
+ strData += m_ButtonB1.get_active() ? " B1" : "";
+ strData += m_ButtonB2.get_active() ? " B2" : "";
- auto refClipboard = Gtk::Clipboard::get();
-
- // Formats:
- std::vector<Glib::ustring> formats;
-
- formats.push_back(example_format_custom);
- formats.push_back(example_format_text);
-
- refClipboard->set(Gdk::ContentFormats::create(formats),
- sigc::mem_fun(*this, &ExampleWindow::on_clipboard_get),
- sigc::mem_fun(*this, &ExampleWindow::on_clipboard_clear) );
-
- //Store the copied data until it is pasted:
- //(Must be done after the call to refClipboard->set(), because that call
- //may trigger a call to on_clipboard_clear.)
- m_ClipboardStore = strData;
-
- update_paste_status();
+ get_clipboard()->set_text(strData);
}
void ExampleWindow::on_button_paste()
{
//Tell the clipboard to call our method when it is ready:
- auto refClipboard = Gtk::Clipboard::get();
-
- refClipboard->request_contents(example_format_custom,
- sigc::mem_fun(*this, &ExampleWindow::on_clipboard_received) );
-
- update_paste_status();
+ get_clipboard()->read_text_async(sigc::mem_fun(*this,
+ &ExampleWindow::on_clipboard_received));
}
-void ExampleWindow::on_clipboard_owner_change(const Gdk::EventOwnerChange&)
+void ExampleWindow::on_clipboard_content_changed()
{
update_paste_status();
}
-void ExampleWindow::on_clipboard_get(Gtk::SelectionData& selection_data)
+void ExampleWindow::on_clipboard_received(Glib::RefPtr<Gio::AsyncResult>& result)
{
- const auto target = selection_data.get_target();
-
- if(target == example_format_custom)
+ Glib::ustring text;
+ try
{
- // This set() override uses an 8-bit text format for the data.
- selection_data.set(example_format_custom, m_ClipboardStore);
+ text = get_clipboard()->read_text_finish(result);
}
- else if(target == example_format_text)
+ catch (const Glib::Error& err)
{
- //Build some arbitrary text representation of the data,
- //so that people see something when they paste into a text editor:
- Glib::ustring text_representation;
-
- text_representation += m_ButtonA1.get_active() ? "A1, " : "";
- text_representation += m_ButtonA2.get_active() ? "A2, " : "";
- text_representation += m_ButtonB1.get_active() ? "B1, " : "";
- text_representation += m_ButtonB2.get_active() ? "B2, " : "";
+ // Print an error about why pasting failed.
+ // Usually you probably want to ignore such failures,
+ // but for demonstration purposes, we show the error.
+ std::cout << "Pasting failed: " << err.what() << std::endl;
+ }
- selection_data.set_text(text_representation);
+ if (text.find(example_format_custom) == 0)
+ {
+ // It's the expected format.
+ m_ButtonA1.set_active(text.find("A1") != std::string::npos);
+ m_ButtonA2.set_active(text.find("A2") != std::string::npos);
+ m_ButtonB1.set_active(text.find("B1") != std::string::npos);
+ m_ButtonB2.set_active(text.find("B2") != std::string::npos);
}
else
{
- g_warning("ExampleWindow::on_clipboard_get(): "
- "Unexpected clipboard target format.");
+ // Unexpected format. Disable the Paste button.
+ std::cout << "Unexpected pasted text: \"" << text << "\"" << std::endl;
+ m_Button_Paste.set_sensitive(false);
}
}
-void ExampleWindow::on_clipboard_clear()
+void ExampleWindow::update_paste_status()
{
- //This isn't really necessary. I guess it might save memory.
- m_ClipboardStore.clear();
+ // Disable the paste button if there is nothing to paste.
+ get_clipboard()->read_text_async(sigc::mem_fun(*this,
+ &ExampleWindow::on_clipboard_received_targets));
}
-void ExampleWindow::on_clipboard_received(
- const Gtk::SelectionData& selection_data)
+void ExampleWindow::on_clipboard_received_targets(Glib::RefPtr<Gio::AsyncResult>& result)
{
- const auto target = selection_data.get_target();
-
- //It should always be this, because that's what we asked for when calling
- //request_contents().
- if(target == example_format_custom)
+ Glib::ustring text;
+ try
+ {
+ text = get_clipboard()->read_text_finish(result);
+ }
+ catch (const Glib::Error&)
{
- auto clipboard_data = selection_data.get_data_as_string();
-
- //See comment in on_button_copy() about this silly clipboard format.
- if(clipboard_data.size() >= 4)
- {
- m_ButtonA1.set_active( clipboard_data[0] == '1' );
- m_ButtonA2.set_active( clipboard_data[1] == '1' );
- m_ButtonB1.set_active( clipboard_data[2] == '1' );
- m_ButtonB2.set_active( clipboard_data[3] == '1' );
- }
}
-}
-
-void ExampleWindow::update_paste_status()
-{
- //Disable the paste button if there is nothing to paste.
-
- auto refClipboard = Gtk::Clipboard::get();
-
- //Discover what targets are available:
- refClipboard->request_targets(sigc::mem_fun(*this,
- &ExampleWindow::on_clipboard_received_targets) );
-}
-void ExampleWindow::on_clipboard_received_targets(
- const std::vector<Glib::ustring>& targets)
-{
- const bool bPasteIsPossible =
- std::find(targets.begin(), targets.end(),
- example_format_custom) != targets.end();
+ const bool bPasteIsPossible = text.find(example_format_custom) == 0;
// Enable/Disable the Paste button appropriately:
m_Button_Paste.set_sensitive(bPasteIsPossible);
diff --git a/examples/book/clipboard/ideal/examplewindow.h b/examples/book/clipboard/ideal/examplewindow.h
index 71b8198..b047181 100644
--- a/examples/book/clipboard/ideal/examplewindow.h
+++ b/examples/book/clipboard/ideal/examplewindow.h
@@ -30,12 +30,10 @@ protected:
void on_button_copy();
void on_button_paste();
- void on_clipboard_owner_change(const Gdk::EventOwnerChange& event);
- void on_clipboard_get(Gtk::SelectionData& selection_data);
- void on_clipboard_clear();
+ void on_clipboard_content_changed();
- void on_clipboard_received(const Gtk::SelectionData& selection_data);
- void on_clipboard_received_targets(const std::vector<Glib::ustring>& targets);
+ void on_clipboard_received(Glib::RefPtr<Gio::AsyncResult>& result);
+ void on_clipboard_received_targets(Glib::RefPtr<Gio::AsyncResult>& result);
void update_paste_status(); //Disable the paste button if there is nothing to paste.
@@ -49,8 +47,6 @@ protected:
Gtk::ButtonBox m_ButtonBox;
Gtk::Button m_Button_Copy, m_Button_Paste;
-
- Glib::ustring m_ClipboardStore; //Keep copied stuff here, until it is pasted. This could be a big complex
data structure.
};
#endif //GTKMM_EXAMPLEWINDOW_H
diff --git a/examples/book/clipboard/simple/examplewindow.cc b/examples/book/clipboard/simple/examplewindow.cc
index 36a1cac..6405034 100644
--- a/examples/book/clipboard/simple/examplewindow.cc
+++ b/examples/book/clipboard/simple/examplewindow.cc
@@ -15,6 +15,7 @@
*/
#include "examplewindow.h"
+#include <iostream>
ExampleWindow::ExampleWindow()
: m_VBox(Gtk::Orientation::VERTICAL),
@@ -34,10 +35,10 @@ ExampleWindow::ExampleWindow()
m_VBox.pack_start(m_Grid, Gtk::PackOptions::EXPAND_WIDGET);
m_Grid.set_row_homogeneous(true);
m_Grid.set_column_homogeneous(true);
- m_Grid.attach(m_ButtonA1, 0, 0, 1, 1);
- m_Grid.attach(m_ButtonA2, 1, 0, 1, 1);
- m_Grid.attach(m_ButtonB1, 0, 1, 1, 1);
- m_Grid.attach(m_ButtonB2, 1, 1, 1, 1);
+ m_Grid.attach(m_ButtonA1, 0, 0);
+ m_Grid.attach(m_ButtonA2, 1, 0);
+ m_Grid.attach(m_ButtonB1, 0, 1);
+ m_Grid.attach(m_ButtonB2, 1, 1);
//Add ButtonBox to bottom:
m_VBox.pack_start(m_ButtonBox, Gtk::PackOptions::SHRINK);
@@ -67,20 +68,31 @@ void ExampleWindow::on_button_copy()
strData += m_ButtonB1.get_active() ? "1" : "0";
strData += m_ButtonB2.get_active() ? "1" : "0";
- auto refClipboard = Gtk::Clipboard::get();
- refClipboard->set_text(strData);
+ get_clipboard()->set_text(strData);
}
void ExampleWindow::on_button_paste()
{
//Tell the clipboard to call our method when it is ready:
- auto refClipboard = Gtk::Clipboard::get();
- refClipboard->request_text(sigc::mem_fun(*this,
- &ExampleWindow::on_clipboard_text_received) );
+ get_clipboard()->read_text_async(sigc::mem_fun(*this,
+ &ExampleWindow::on_clipboard_text_received));
}
-void ExampleWindow::on_clipboard_text_received(const Glib::ustring& text)
+void ExampleWindow::on_clipboard_text_received(Glib::RefPtr<Gio::AsyncResult>& result)
{
+ Glib::ustring text;
+ try
+ {
+ text = get_clipboard()->read_text_finish(result);
+ }
+ catch (const Glib::Error& err)
+ {
+ // Print an error about why pasting failed.
+ // Usually you probably want to ignore such failures,
+ // but for demonstration purposes, we show the error.
+ std::cout << "Pasting failed: " << err.what() << std::endl;
+ }
+
//See comment in on_button_copy() about this silly clipboard format.
if(text.size() >= 4)
{
diff --git a/examples/book/clipboard/simple/examplewindow.h b/examples/book/clipboard/simple/examplewindow.h
index 047a561..44bae10 100644
--- a/examples/book/clipboard/simple/examplewindow.h
+++ b/examples/book/clipboard/simple/examplewindow.h
@@ -1,5 +1,3 @@
-//$Id: examplewindow.h 705 2006-07-19 02:55:32Z jjongsma $ -*- c++ -*-
-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
@@ -31,7 +29,8 @@ protected:
//Signal handlers:
void on_button_copy();
void on_button_paste();
- void on_clipboard_text_received(const Glib::ustring& text);
+
+ void on_clipboard_text_received(Glib::RefPtr<Gio::AsyncResult>& result);
//Child widgets:
Gtk::Box m_VBox;
diff --git a/examples/book/dialogs/fontchooserdialog/examplewindow.cc
b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
index 1c071e5..be917ad 100644
--- a/examples/book/dialogs/fontchooserdialog/examplewindow.cc
+++ b/examples/book/dialogs/fontchooserdialog/examplewindow.cc
@@ -43,7 +43,7 @@ ExampleWindow::~ExampleWindow()
void ExampleWindow::on_font_button_font_set()
{
- auto font_name = m_FontButton.get_font_name();
+ auto font_name = m_FontButton.get_font();
std::cout << "Font chosen: " << font_name << std::endl;
}
@@ -52,7 +52,7 @@ void ExampleWindow::on_button_dialog_clicked()
Gtk::FontChooserDialog dialog("Please choose a font", *this);
//Get the previously selected font name from the FontButton:
- dialog.set_font(m_FontButton.get_font_name());
+ dialog.set_font(m_FontButton.get_font());
int result = dialog.run();
@@ -63,7 +63,7 @@ void ExampleWindow::on_button_dialog_clicked()
{
auto font_name = dialog.get_font();
std::cout << "Font chosen: " << font_name << std::endl;
- m_FontButton.set_font_name(font_name);
+ m_FontButton.set_font(font_name);
break;
}
case Gtk::ResponseType::CANCEL:
diff --git a/examples/book/drag_and_drop/dndwindow.cc b/examples/book/drag_and_drop/dndwindow.cc
index 88e743b..099e2c3 100644
--- a/examples/book/drag_and_drop/dndwindow.cc
+++ b/examples/book/drag_and_drop/dndwindow.cc
@@ -25,16 +25,11 @@ DnDWindow::DnDWindow()
add(m_HBox);
- //Targets:
- std::vector<Glib::ustring> listFormats;
- listFormats.push_back("STRING");
- listFormats.push_back("text/plain");
- auto targetList = Gdk::ContentFormats::create(listFormats);
-
//Drag site:
//Make m_Button_Drag a DnD drag source:
- m_Button_Drag.drag_source_set(targetList);
+ m_Button_Drag.drag_source_set(Glib::RefPtr<Gdk::ContentFormats>());
+ m_Button_Drag.drag_source_add_text_targets();
//Connect signals:
m_Button_Drag.signal_drag_data_get().connect(sigc::mem_fun(*this,
@@ -45,7 +40,11 @@ DnDWindow::DnDWindow()
//Drop site:
//Make m_Label_Drop a DnD drop destination:
- m_Label_Drop.drag_dest_set(targetList);
+ // Don't do this: m_Label_Drop.drag_dest_set({}).
+ // It would call the wrong overload of drag_dest_set() with the wrong
+ // default values of flags and actions (wrong in this simple example).
+ m_Label_Drop.drag_dest_set(Glib::RefPtr<Gdk::ContentFormats>());
+ m_Label_Drop.drag_dest_add_text_targets();
//Connect signals:
m_Label_Drop.signal_drag_data_received().connect(sigc::mem_fun(*this,
@@ -68,7 +67,7 @@ void DnDWindow::on_button_drag_data_get(
}
void DnDWindow::on_label_drop_drag_data_received(
- const Glib::RefPtr<Gdk::DragContext>& context, int, int,
+ const Glib::RefPtr<Gdk::DragContext>& context,
const Gtk::SelectionData& selection_data, guint time)
{
const int length = selection_data.get_length();
@@ -78,5 +77,5 @@ void DnDWindow::on_label_drop_drag_data_received(
<< "\" in label " << std::endl;
}
- context->drag_finish(false, false, time);
+ context->drag_finish(false, time);
}
diff --git a/examples/book/drag_and_drop/dndwindow.h b/examples/book/drag_and_drop/dndwindow.h
index 0cbfee2..1cccc8a 100644
--- a/examples/book/drag_and_drop/dndwindow.h
+++ b/examples/book/drag_and_drop/dndwindow.h
@@ -1,5 +1,3 @@
-//$Id: dndwindow.h 839 2007-05-10 04:11:54Z jjongsma $ -*- c++ -*-
-
/* gtkmm example Copyright (C) 2002 gtkmm development team
*
* This program is free software; you can redistribute it and/or modify
@@ -37,7 +35,7 @@ protected:
const Glib::RefPtr<Gdk::DragContext>& context,
Gtk::SelectionData& selection_data, guint time);
void on_label_drop_drag_data_received(
- const Glib::RefPtr<Gdk::DragContext>& context, int x, int y,
+ const Glib::RefPtr<Gdk::DragContext>& context,
const Gtk::SelectionData& selection_data, guint time);
//Member widgets:
diff --git a/examples/book/headerbar/examplewindow.cc b/examples/book/headerbar/examplewindow.cc
index 7c4dee9..7ff158b 100644
--- a/examples/book/headerbar/examplewindow.cc
+++ b/examples/book/headerbar/examplewindow.cc
@@ -17,7 +17,7 @@
#include "examplewindow.h"
ExampleWindow::ExampleWindow()
- : m_close_button_label("Show close button:", Gtk::Align::END, Gtk::Align::CENTER),
+ : m_title_buttons_label("Show title buttons:", Gtk::Align::END, Gtk::Align::CENTER),
m_title_label("Title:", Gtk::Align::END, Gtk::Align::CENTER),
m_subtitle_label("Subtitle:", Gtk::Align::END, Gtk::Align::CENTER)
{
@@ -37,7 +37,7 @@ ExampleWindow::ExampleWindow()
// Header bar
on_title_entry_activate();
on_subtitle_entry_activate();
- m_header_bar.set_show_close_button();
+ m_header_bar.set_show_title_buttons();
m_header_bar.pack_start(m_button);
// Set headerbar as titlebar
@@ -50,7 +50,7 @@ ExampleWindow::ExampleWindow()
// Layout
m_grid.set_column_spacing(6);
m_grid.set_row_spacing(6);
- m_grid.attach(m_close_button_label, 0, 0);
+ m_grid.attach(m_title_buttons_label, 0, 0);
m_grid.attach(m_switch, 1, 0);
m_grid.attach(m_title_label, 0, 1);
m_grid.attach(m_title_entry, 1, 1);
@@ -66,8 +66,8 @@ ExampleWindow::~ExampleWindow()
void ExampleWindow::on_switch_active_changed()
{
- bool show_close_button = m_switch.get_active();
- m_header_bar.set_show_close_button(show_close_button);
+ bool show_title_buttons = m_switch.get_active();
+ m_header_bar.set_show_title_buttons(show_title_buttons);
}
void ExampleWindow::on_title_entry_activate()
diff --git a/examples/book/headerbar/examplewindow.h b/examples/book/headerbar/examplewindow.h
index 39fa679..ecbcc0b 100644
--- a/examples/book/headerbar/examplewindow.h
+++ b/examples/book/headerbar/examplewindow.h
@@ -38,7 +38,7 @@ protected:
// Widgets
Gtk::HeaderBar m_header_bar;
Gtk::Button m_button;
- Gtk::Label m_close_button_label;
+ Gtk::Label m_title_buttons_label;
Gtk::Switch m_switch;
Gtk::Label m_title_label;
Gtk::Entry m_title_entry;
diff --git a/examples/book/menus/popup/examplewindow.cc b/examples/book/menus/popup/examplewindow.cc
index 4334709..bf1e11b 100644
--- a/examples/book/menus/popup/examplewindow.cc
+++ b/examples/book/menus/popup/examplewindow.cc
@@ -14,6 +14,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//TODO: Remove this undef when we know what to use instead of signal_button_press_event().
+#undef GTKMM_DISABLE_DEPRECATED
+
#include "examplewindow.h"
#include <iostream>
diff --git a/examples/book/printing/advanced/printformoperation.cc
b/examples/book/printing/advanced/printformoperation.cc
index f56a220..88b3e71 100644
--- a/examples/book/printing/advanced/printformoperation.cc
+++ b/examples/book/printing/advanced/printformoperation.cc
@@ -164,7 +164,7 @@ Gtk::Widget* PrintFormOperation::on_create_custom_widget()
auto label = Gtk::manage(new Gtk::Label("Choose a font: "));
hbox->pack_start(*label, Gtk::PackOptions::SHRINK);
- m_FontButton.set_font_name(m_Font);
+ m_FontButton.set_font(m_Font);
hbox->pack_start(m_FontButton, Gtk::PackOptions::SHRINK);
return vbox;
@@ -176,7 +176,7 @@ void PrintFormOperation::on_custom_widget_apply(Gtk::Widget*)
// on_create_custom_widget(). We don't need to use it, because we can use the
// child FontButton directly:
- auto selected_font = m_FontButton.get_font_name();
+ auto selected_font = m_FontButton.get_font();
m_Font = selected_font;
}
diff --git a/examples/book/toolpalette/canvas.cc b/examples/book/toolpalette/canvas.cc
index efa05eb..6986624 100644
--- a/examples/book/toolpalette/canvas.cc
+++ b/examples/book/toolpalette/canvas.cc
@@ -19,7 +19,8 @@
Canvas::Canvas()
: m_drag_data_requested_for_drop(false),
- m_drop_item(nullptr)
+ m_drop_item(nullptr),
+ m_drop_pos(0, 0)
{
set_draw_func(sigc::mem_fun(*this, &Canvas::on_draw));
}
@@ -107,7 +108,7 @@ bool Canvas::on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context,
void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
- int x, int y, const Gtk::SelectionData& selection_data, guint time)
+ const Gtk::SelectionData& selection_data, guint time)
{
// Find the tool button which is the source of this DnD operation.
auto widget = drag_get_source_widget(context);
@@ -133,14 +134,14 @@ void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context
try
{
- auto item = new CanvasItem(this, button, x, y);
+ auto item = new CanvasItem(this, button, m_drop_pos.get_x(), m_drop_pos.get_y());
if(m_drag_data_requested_for_drop)
{
m_canvas_items.push_back(item);
// Signal that the item was accepted and then redraw.
- context->drag_finish(true /* success */, false /* del */, time);
+ context->drag_finish(true /* success */, time);
}
else
{
@@ -160,11 +161,11 @@ void Canvas::on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context
std::cerr << "IconThemeError: " << ex.what() << std::endl;
}
- Gtk::DrawingArea::on_drag_data_received(context, x, y, selection_data, time);
+ Gtk::DrawingArea::on_drag_data_received(context, selection_data, time);
}
-bool Canvas::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int /* x */, int /* y */, guint
time)
+bool Canvas::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time)
{
// Request DnD data for creating a dopped item.
// This will cause on_drag_data_received() to be called.
@@ -175,6 +176,7 @@ bool Canvas::on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int /*
m_drag_data_requested_for_drop = true;
drag_get_data(context, target, time);
+ m_drop_pos = Gdk::Point(x, y);
return true;
}
diff --git a/examples/book/toolpalette/canvas.h b/examples/book/toolpalette/canvas.h
index 2491b6e..6f065ae 100644
--- a/examples/book/toolpalette/canvas.h
+++ b/examples/book/toolpalette/canvas.h
@@ -55,13 +55,14 @@ private:
void on_draw(const Cairo::RefPtr<Cairo::Context>& cr, int width, int height);
void on_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context,
- int x, int y, const Gtk::SelectionData& selection_data, guint time) override;
+ const Gtk::SelectionData& selection_data, guint time) override;
bool on_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) override;
bool on_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time) override;
void on_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time) override;
bool m_drag_data_requested_for_drop; //So we know what to do in on_drag_data_received().
CanvasItem* m_drop_item;
+ Gdk::Point m_drop_pos;
typedef std::vector<CanvasItem*> type_vec_items;
type_vec_items m_canvas_items;
diff --git a/examples/book/toolpalette/examplewindow.cc b/examples/book/toolpalette/examplewindow.cc
index de2f164..b88e302 100644
--- a/examples/book/toolpalette/examplewindow.cc
+++ b/examples/book/toolpalette/examplewindow.cc
@@ -16,7 +16,6 @@
#include "examplewindow.h"
-
void ExampleWindow::load_icon_items()
{
auto icon_theme = Gtk::IconTheme::get_for_display(get_display());
@@ -192,8 +191,7 @@ ExampleWindow::ExampleWindow()
//The Orientation ComboBox:
m_refTreeModelOrientation = Gtk::ListStore::create(m_ColumnsOrientation);
- auto iter = m_refTreeModelOrientation->append();
- auto row = *iter;
+ auto row = *(m_refTreeModelOrientation->append());
row[m_ColumnsOrientation.m_col_value] = Gtk::Orientation::HORIZONTAL;
row[m_ColumnsOrientation.m_col_name] = "Horizontal";\
row = *(m_refTreeModelOrientation->append());
@@ -204,12 +202,11 @@ ExampleWindow::ExampleWindow()
m_ComboOrientation.pack_start(m_ColumnsOrientation.m_col_name);
m_ComboOrientation.signal_changed().connect(
sigc::mem_fun(*this, &ExampleWindow::on_combo_orientation_changed) );
- m_ComboOrientation.set_active(iter);
+ m_ComboOrientation.set_active(row.get_iter());
//The Style ComboBox:
m_refTreeModelStyle = Gtk::ListStore::create(m_ColumnsStyle);
- iter = m_refTreeModelStyle->append();
- row = *iter;
+ row = *(m_refTreeModelStyle->append());
row[m_ColumnsStyle.m_col_value] = static_cast<int>(Gtk::ToolbarStyle::TEXT);
row[m_ColumnsStyle.m_col_name] = "Text";\
row = *(m_refTreeModelStyle->append());
@@ -229,7 +226,7 @@ ExampleWindow::ExampleWindow()
m_ComboStyle.pack_start(m_ColumnsStyle.m_col_name);
m_ComboStyle.signal_changed().connect(
sigc::mem_fun(*this, &ExampleWindow::on_combo_style_changed) );
- m_ComboStyle.set_active(iter);
+ m_ComboStyle.set_active(row.get_iter());
//Add and fill the ToolPalette:
load_icon_items();
diff --git a/examples/others/calendar/calendar.cc b/examples/others/calendar/calendar.cc
index 1cc4b49..be322cf 100644
--- a/examples/others/calendar/calendar.cc
+++ b/examples/others/calendar/calendar.cc
@@ -118,7 +118,7 @@ void CalendarExample::toggle_flag(Gtk::CheckButton *toggle)
void CalendarExample::on_font_button_font_set()
{
- const auto font_name = font_button_->get_font_name();
+ const auto font_name = font_button_->get_font();
const Pango::FontDescription font_desc(font_name);
const auto font_family = font_desc.get_family();
const auto font_size = font_desc.get_size();
diff --git a/examples/others/cellrenderercustom/cellrendererlist.cc
b/examples/others/cellrenderercustom/cellrendererlist.cc
index 80b0c53..3e5ae00 100644
--- a/examples/others/cellrenderercustom/cellrendererlist.cc
+++ b/examples/others/cellrenderercustom/cellrendererlist.cc
@@ -14,6 +14,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//TODO: Remove this undef when we know what to use instead of signal_button_release_event().
+#undef GTKMM_DISABLE_DEPRECATED
+
#include <gtkmm.h>
#include "cellrendererlist.h"
#include "popupentry.h"
diff --git a/examples/others/cellrenderercustom/cellrendererpopup.cc
b/examples/others/cellrenderercustom/cellrendererpopup.cc
index ec5023c..bfe7236 100644
--- a/examples/others/cellrenderercustom/cellrendererpopup.cc
+++ b/examples/others/cellrenderercustom/cellrendererpopup.cc
@@ -14,6 +14,9 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+//TODO: Remove this undef when we know what to use instead of signal_button_press_event().
+#undef GTKMM_DISABLE_DEPRECATED
+
#include <gtkmm.h>
#include "cellrendererpopup.h"
#include "popupentry.h"
diff --git a/examples/others/dnd/dndwindow.cc b/examples/others/dnd/dndwindow.cc
index f96db1a..14db382 100644
--- a/examples/others/dnd/dndwindow.cc
+++ b/examples/others/dnd/dndwindow.cc
@@ -37,6 +37,13 @@ DnDWindow::DnDWindow()
//Targets:
m_listTargets.push_back("STRING");
m_listTargets.push_back("text/plain");
+ m_listTargets.push_back("text/plain;charset=utf-8");
+ if (!Glib::get_charset())
+ {
+ std::string charset;
+ Glib::get_charset(charset);
+ m_listTargets.push_back("text/plain;charset=" + charset);
+ }
m_listTargets.push_back("application/x-rootwin-drop");
//Targets without rootwin:
@@ -76,7 +83,7 @@ DnDWindow::DnDWindow()
m_Button.drag_source_set(Gdk::ContentFormats::create(m_listTargets), Gdk::ModifierType::BUTTON1_MASK |
Gdk::ModifierType::BUTTON3_MASK,
Gdk::DragAction::COPY | Gdk::DragAction::MOVE);
- m_Button.drag_source_set_icon(m_drag_icon);
+ m_Button.drag_source_set_icon(Gdk::Cairo::create_surface_from_pixbuf(m_drag_icon, 1));
m_Grid.attach(m_Button, 0, 1);
m_Button.set_hexpand(true);
@@ -93,7 +100,7 @@ DnDWindow::~DnDWindow()
}
-void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int,
const Gtk::SelectionData& selection_data, guint time)
+void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, const
Gtk::SelectionData& selection_data, guint time)
{
const int length = selection_data.get_length();
const guchar* data = selection_data.get_data();
@@ -103,7 +110,7 @@ void DnDWindow::on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragCon
g_print ("Received \"%s\" in label\n", (gchar *)data);
}
- context->drag_finish(false, false, time);
+ context->drag_finish(false, time);
}
bool DnDWindow::on_label_popup_drag_motion(const Glib::RefPtr<Gdk::DragContext>&, int, int, guint)
@@ -127,7 +134,7 @@ void DnDWindow::on_label_popup_drag_leave(const Glib::RefPtr<Gdk::DragContext>&,
}
}
-void DnDWindow::on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int, int, const
Gtk::SelectionData& selection_data, guint time)
+void DnDWindow::on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, const
Gtk::SelectionData& selection_data, guint time)
{
const int length = selection_data.get_length();
const guchar* data = selection_data.get_data();
@@ -137,7 +144,7 @@ void DnDWindow::on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>
g_print ("Received \"%s\" in trashcan\n", (gchar*)data);
}
- context->drag_finish(false, false, time);
+ context->drag_finish(false, time);
}
bool DnDWindow::on_image_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int, int, guint time)
@@ -179,7 +186,7 @@ bool DnDWindow::on_image_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context
const auto targets = context->get_formats()->get_mime_types();
if(!targets.empty())
{
- drag_get_data( context, targets[0], time );
+ m_Image.drag_get_data(context, targets[0], time);
}
return true;
diff --git a/examples/others/dnd/dndwindow.h b/examples/others/dnd/dndwindow.h
index 9b09334..4d98a5f 100644
--- a/examples/others/dnd/dndwindow.h
+++ b/examples/others/dnd/dndwindow.h
@@ -31,11 +31,11 @@ protected:
void create_popup();
//Signal handlers:
- void on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const
Gtk::SelectionData& selection_data, guint time);
+ void on_label_drop_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, const
Gtk::SelectionData& selection_data, guint time);
bool on_label_popup_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
void on_label_popup_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time);
- void on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, const
Gtk::SelectionData& selection_data, guint time);
+ void on_image_drag_data_received(const Glib::RefPtr<Gdk::DragContext>& context, const Gtk::SelectionData&
selection_data, guint time);
bool on_image_drag_motion(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
void on_image_drag_leave(const Glib::RefPtr<Gdk::DragContext>& context, guint time);
bool on_image_drag_drop(const Glib::RefPtr<Gdk::DragContext>& context, int x, int y, guint time);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]