aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk
diff options
context:
space:
mode:
Diffstat (limited to 'gtk')
-rw-r--r--gtk/PlatGTK.cxx46
-rw-r--r--gtk/ScintillaGTK.cxx51
2 files changed, 51 insertions, 46 deletions
diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx
index 81dd686b3..62afdfb0b 100644
--- a/gtk/PlatGTK.cxx
+++ b/gtk/PlatGTK.cxx
@@ -803,11 +803,11 @@ void SurfaceImpl::Release() {
drawable = 0;
if (createdGC) {
createdGC = false;
- gdk_gc_unref(gc);
+ g_object_unref(gc);
}
gc = 0;
if (ppixmap)
- gdk_pixmap_unref(ppixmap);
+ g_object_unref(ppixmap);
ppixmap = 0;
if (layout)
g_object_unref(layout);
@@ -954,7 +954,7 @@ void SurfaceImpl::FillRectangle(PRectangle rc, Surface &surfacePattern) {
int widthx = (xTile + widthPat > rc.right) ? rc.right - xTile : widthPat;
for (int yTile = rc.top; yTile < rc.bottom; yTile += heightPat) {
int heighty = (yTile + heightPat > rc.bottom) ? rc.bottom - yTile : heightPat;
- gdk_draw_pixmap(drawable,
+ gdk_draw_drawable(drawable,
gc,
static_cast<SurfaceImpl &>(surfacePattern).drawable,
0, 0,
@@ -1080,7 +1080,7 @@ void SurfaceImpl::Ellipse(PRectangle rc, ColourAllocated fore, ColourAllocated b
void SurfaceImpl::Copy(PRectangle rc, Point from, Surface &surfaceSource) {
if (static_cast<SurfaceImpl &>(surfaceSource).drawable) {
- gdk_draw_pixmap(drawable,
+ gdk_draw_drawable(drawable,
gc,
static_cast<SurfaceImpl &>(surfaceSource).drawable,
from.x, from.y,
@@ -1755,7 +1755,7 @@ void Window::SetPositionRelative(PRectangle rc, Window relativeTo) {
gtk_window_move(GTK_WINDOW(PWidget(wid)), ox, oy);
- gtk_widget_set_usize(PWidget(wid), sizex, sizey);
+ gtk_widget_set_size_request(PWidget(wid), sizex, sizey);
}
PRectangle Window::GetClientPosition() {
@@ -1821,7 +1821,7 @@ void Window::SetCursor(Cursor curs) {
if (PWidget(wid)->window)
gdk_window_set_cursor(PWidget(wid)->window, gdkCurs);
- gdk_cursor_destroy(gdkCurs);
+ gdk_cursor_unref(gdkCurs);
}
void Window::SetTitle(const char *s) {
@@ -1864,7 +1864,7 @@ struct ListImage {
static void list_image_free(gpointer, gpointer value, gpointer) {
ListImage *list_image = (ListImage *) value;
if (list_image->pixbuf)
- gdk_pixbuf_unref (list_image->pixbuf);
+ g_object_unref (list_image->pixbuf);
g_free(list_image);
}
@@ -2070,14 +2070,14 @@ PRectangle ListBoxX::GetDesiredRect() {
height = (rows * row_height
+ 2 * (ythickness
+ GTK_CONTAINER(PWidget(list))->border_width + 1));
- gtk_widget_set_usize(GTK_WIDGET(PWidget(list)), -1, height);
+ gtk_widget_set_size_request(GTK_WIDGET(PWidget(list)), -1, height);
// Get the size of the scroller because we set usize on the window
gtk_widget_size_request(GTK_WIDGET(scroller), &req);
rc.right = req.width;
rc.bottom = req.height;
- gtk_widget_set_usize(GTK_WIDGET(list), -1, -1);
+ gtk_widget_set_size_request(GTK_WIDGET(list), -1, -1);
int width = maxItemCharacters;
if (width < 12)
width = 12;
@@ -2117,7 +2117,7 @@ static void init_pixmap(ListImage *list_image) {
// Drop any existing pixmap/bitmap as data may have changed
if (list_image->pixbuf)
- gdk_pixbuf_unref(list_image->pixbuf);
+ g_object_unref(list_image->pixbuf);
list_image->pixbuf =
gdk_pixbuf_new_from_xpm_data((const gchar**)xpm_lineform);
delete []xpm_lineformfromtext;
@@ -2293,7 +2293,7 @@ void ListBoxX::RegisterImage(int type, const char *xpm_data) {
if (list_image) {
// Drop icon already registered
if (list_image->pixbuf)
- gdk_pixbuf_unref(list_image->pixbuf);
+ g_object_unref(list_image->pixbuf);
list_image->pixbuf = NULL;
list_image->xpm_data = xpm_data;
} else {
@@ -2342,7 +2342,13 @@ Menu::Menu() : mid(0) {}
void Menu::CreatePopUp() {
Destroy();
- mid = gtk_item_factory_new(GTK_TYPE_MENU, "<main>", NULL);
+ mid = gtk_menu_new();
+#if GLIB_CHECK_VERSION(2,10,0)
+ g_object_ref_sink(G_OBJECT(mid));
+#else
+ g_object_ref(G_OBJECT(mid));
+ gtk_object_sink(GTK_OBJECT(G_OBJECT(mid)));
+#endif
}
void Menu::Destroy() {
@@ -2351,21 +2357,27 @@ void Menu::Destroy() {
mid = 0;
}
+static void MenuPositionFunc(GtkMenu *, gint *x, gint *y, gboolean *, gpointer userData) {
+ sptr_t intFromPointer = reinterpret_cast<sptr_t>(userData);
+ *x = intFromPointer & 0xffff;
+ *y = intFromPointer >> 16;
+}
+
void Menu::Show(Point pt, Window &) {
int screenHeight = gdk_screen_height();
int screenWidth = gdk_screen_width();
- GtkItemFactory *factory = reinterpret_cast<GtkItemFactory *>(mid);
- GtkWidget *widget = gtk_item_factory_get_widget(factory, "<main>");
- gtk_widget_show_all(widget);
+ GtkMenu *widget = reinterpret_cast<GtkMenu *>(mid);
+ gtk_widget_show_all(GTK_WIDGET(widget));
GtkRequisition requisition;
- gtk_widget_size_request(widget, &requisition);
+ gtk_widget_size_request(GTK_WIDGET(widget), &requisition);
if ((pt.x + requisition.width) > screenWidth) {
pt.x = screenWidth - requisition.width;
}
if ((pt.y + requisition.height) > screenHeight) {
pt.y = screenHeight - requisition.height;
}
- gtk_item_factory_popup(factory, pt.x - 4, pt.y - 4, 3,
+ gtk_menu_popup(widget, NULL, NULL, MenuPositionFunc,
+ reinterpret_cast<void *>((pt.y << 16) | pt.x), 0,
gtk_get_current_event_time());
}
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index f381f3605..d43fcdb33 100644
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -258,7 +258,7 @@ private:
static gboolean IdleCallback(ScintillaGTK *sciThis);
static gboolean StyleIdle(ScintillaGTK *sciThis);
virtual void QueueStyling(int upTo);
- static void PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *widget);
+ static void PopUpCB(GtkMenuItem *menuItem, ScintillaGTK *sciThis);
gint ExposeTextThis(GtkWidget *widget, GdkEventExpose *ose);
static gint ExposeText(GtkWidget *widget, GdkEventExpose *ose, ScintillaGTK *sciThis);
@@ -376,7 +376,7 @@ void ScintillaGTK::RealizeThis(GtkWidget *widget) {
gdk_window_set_user_data(widget->window, widget);
gdk_window_set_background(widget->window, &widget->style->bg[GTK_STATE_NORMAL]);
gdk_window_show(widget->window);
- gdk_cursor_destroy(cursor);
+ gdk_cursor_unref(cursor);
widget->style = gtk_style_attach(widget->style, widget->window);
wPreedit = gtk_window_new(GTK_WINDOW_POPUP);
wPreeditDraw = gtk_drawing_area_new();
@@ -620,8 +620,7 @@ void ScintillaGTK::Initialise() {
gtk_widget_set_events(widtxt, GDK_EXPOSURE_MASK);
// Avoid background drawing flash
gtk_widget_set_double_buffered(widtxt, FALSE);
- gtk_drawing_area_size(GTK_DRAWING_AREA(widtxt),
- 100,100);
+ gtk_widget_set_size_request(widtxt, 100, 100);
adjustmentv = gtk_adjustment_new(0.0, 0.0, 201.0, 1.0, 20.0, 20.0);
scrollbarv = gtk_vscrollbar_new(GTK_ADJUSTMENT(adjustmentv));
GTK_WIDGET_UNSET_FLAGS(PWidget(scrollbarv), GTK_CAN_FOCUS);
@@ -866,9 +865,9 @@ void ScintillaGTK::SetTicking(bool on) {
if (timer.ticking != on) {
timer.ticking = on;
if (timer.ticking) {
- timer.tickerID = reinterpret_cast<TickerID>(gtk_timeout_add(timer.tickSize, (GtkFunction)TimeOut, this));
+ timer.tickerID = reinterpret_cast<TickerID>(g_timeout_add(timer.tickSize, (GtkFunction)TimeOut, this));
} else {
- gtk_timeout_remove(GPOINTER_TO_UINT(timer.tickerID));
+ g_source_remove(GPOINTER_TO_UINT(timer.tickerID));
}
}
timer.ticksToWait = caret.period;
@@ -1281,8 +1280,7 @@ void ScintillaGTK::CreateCallTipWindow(PRectangle rc) {
gtk_widget_set_events(widcdrw,
GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK);
}
- gtk_drawing_area_size(GTK_DRAWING_AREA(PWidget(ct.wDraw)),
- rc.Width(), rc.Height());
+ gtk_widget_set_size_request(PWidget(ct.wDraw), rc.Width(), rc.Height());
ct.wDraw.Show();
if (PWidget(ct.wCallTip)->window) {
gdk_window_resize(PWidget(ct.wCallTip)->window, rc.Width(), rc.Height());
@@ -1290,24 +1288,18 @@ void ScintillaGTK::CreateCallTipWindow(PRectangle rc) {
}
void ScintillaGTK::AddToPopUp(const char *label, int cmd, bool enabled) {
- char fulllabel[200];
- strcpy(fulllabel, "/");
- strcat(fulllabel, label);
- GtkItemFactoryCallback menuSig = GtkItemFactoryCallback(PopUpCB);
- GtkItemFactoryEntry itemEntry = {
- fulllabel, NULL,
- menuSig,
- cmd,
- const_cast<gchar *>(label[0] ? "<Item>" : "<Separator>"),
- NULL
- };
- gtk_item_factory_create_item(GTK_ITEM_FACTORY(popup.GetID()),
- &itemEntry, this, 1);
+ GtkWidget *menuItem;
+ if (label[0])
+ menuItem = gtk_menu_item_new_with_label(label);
+ else
+ menuItem = gtk_separator_menu_item_new();
+ gtk_menu_shell_append(GTK_MENU_SHELL(popup.GetID()), menuItem);
+ g_object_set_data(G_OBJECT(menuItem), "CmdNum", reinterpret_cast<void *>(cmd));
+ g_signal_connect(G_OBJECT(menuItem),"activate", G_CALLBACK(PopUpCB), this);
+
if (cmd) {
- GtkWidget *item = gtk_item_factory_get_widget_by_action(
- reinterpret_cast<GtkItemFactory *>(popup.GetID()), cmd);
- if (item)
- gtk_widget_set_sensitive(item, enabled);
+ if (menuItem)
+ gtk_widget_set_sensitive(menuItem, enabled);
}
}
@@ -1966,8 +1958,8 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose)
GdkColor color[2] = { {0, 0x0000, 0x0000, 0x0000},
{0, 0xffff, 0xffff, 0xffff}
};
- gdk_color_alloc(gdk_colormap_get_system(), color);
- gdk_color_alloc(gdk_colormap_get_system(), color + 1);
+ gdk_colormap_alloc_color(gdk_colormap_get_system(), color, FALSE, TRUE);
+ gdk_colormap_alloc_color(gdk_colormap_get_system(), color + 1, FALSE, TRUE);
gdk_gc_set_foreground(gc, color + 1);
gdk_draw_rectangle(widget->window, gc, TRUE, ose->area.x, ose->area.y,
@@ -1977,7 +1969,7 @@ gboolean ScintillaGTK::ExposePreeditThis(GtkWidget *widget, GdkEventExpose *ose)
gdk_gc_set_background(gc, color + 1);
gdk_draw_layout(widget->window, gc, 0, 0, layout);
- gdk_gc_unref(gc);
+ g_object_unref(gc);
g_free(str);
pango_attr_list_unref(attrs);
g_object_unref(layout);
@@ -2386,7 +2378,8 @@ void ScintillaGTK::QueueStyling(int upTo) {
}
}
-void ScintillaGTK::PopUpCB(ScintillaGTK *sciThis, guint action, GtkWidget *) {
+void ScintillaGTK::PopUpCB(GtkMenuItem *menuItem, ScintillaGTK *sciThis) {
+ guint action = (sptr_t)(g_object_get_data(G_OBJECT(menuItem), "CmdNum"));
if (action) {
sciThis->Command(action);
}