[Xfce4-commits] [panel-plugins/xfce4-whiskermenu-plugin] 04/41: Compile with Gtk3.
noreply at xfce.org
noreply at xfce.org
Sat Aug 20 18:32:18 CEST 2016
This is an automated email from the git hooks/post-receive script.
gottcode pushed a commit to branch master
in repository panel-plugins/xfce4-whiskermenu-plugin.
commit 1dd3dcab64755cd1066b0980dfc979d8486b2fd4
Author: Graeme Gott <graeme at gottcode.org>
Date: Sun Aug 7 08:56:16 2016 -0400
Compile with Gtk3.
---
panel-plugin/CMakeLists.txt | 18 +++++++-------
panel-plugin/command-edit.cpp | 6 ++---
panel-plugin/configuration-dialog.cpp | 14 +++++------
panel-plugin/plugin.cpp | 2 +-
panel-plugin/resizer-widget.cpp | 44 ++++-------------------------------
panel-plugin/resizer-widget.h | 6 ++---
panel-plugin/search-page.cpp | 2 +-
panel-plugin/whiskermenu.desktop | 1 +
panel-plugin/window.cpp | 18 ++++++--------
panel-plugin/window.h | 2 +-
10 files changed, 37 insertions(+), 76 deletions(-)
diff --git a/panel-plugin/CMakeLists.txt b/panel-plugin/CMakeLists.txt
index cc92a64..542cc2c 100644
--- a/panel-plugin/CMakeLists.txt
+++ b/panel-plugin/CMakeLists.txt
@@ -12,23 +12,24 @@ if(ENABLE_LINKER_OPTIMIZED_HASH_TABLES)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-O1")
endif()
-find_package(GTK2 REQUIRED)
find_package(PkgConfig REQUIRED)
-pkg_check_modules(exo REQUIRED exo-1)
+pkg_check_modules(GTK3 REQUIRED gtk+-3.0)
+pkg_check_modules(exo REQUIRED exo-2>=0.11)
pkg_check_modules(garcon REQUIRED garcon-1)
-pkg_check_modules(libxfce4panel REQUIRED libxfce4panel-1.0>=4.11)
-pkg_check_modules(libxfce4ui REQUIRED libxfce4ui-1>=4.11)
+pkg_check_modules(libxfce4panel REQUIRED libxfce4panel-2.0>=4.11)
+pkg_check_modules(libxfce4ui REQUIRED libxfce4ui-2>=4.11)
pkg_check_modules(libxfce4util REQUIRED libxfce4util-1.0>=4.11)
include_directories(
+ ${GTK3_INCLUDE_DIRS}
${exo_INCLUDE_DIRS}
${garcon_INCLUDE_DIRS}
${libxfce4panel_INCLUDE_DIRS}
${libxfce4ui_INCLUDE_DIRS}
- ${libxfce4util_INCLUDE_DIRS}
- ${GTK2_INCLUDE_DIRS})
+ ${libxfce4util_INCLUDE_DIRS})
link_directories(
+ ${GTK3_LIBRARY_DIRS}
${exo_LIBRARY_DIRS}
${garcon_LIBRARY_DIRS}
${libxfce4panel_LIBRARY_DIRS}
@@ -46,6 +47,7 @@ add_definitions(
-DG_LOG_DOMAIN="whiskermenu"
-DGSEAL_ENABLE
-DGTK_MULTIHEAD_SAFE
+ ${GTK3_CFLAGS_OTHER}
${exo_CFLAGS_OTHER}
${garcon_CFLAGS_OTHER}
${libxfce4panel_CFLAGS_OTHER}
@@ -93,12 +95,12 @@ add_library(whiskermenu MODULE
window.cpp)
target_link_libraries(whiskermenu
+ ${GTK3_LIBRARIES}
${exo_LIBRARIES}
${garcon_LIBRARIES}
${libxfce4panel_LIBRARIES}
${libxfce4ui_LIBRARIES}
- ${libxfce4util_LIBRARIES}
- ${GTK2_LIBRARIES})
+ ${libxfce4util_LIBRARIES})
string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER)
if(CMAKE_BUILD_TYPE_TOLOWER MATCHES "release|minsizerel")
diff --git a/panel-plugin/command-edit.cpp b/panel-plugin/command-edit.cpp
index 0af8b07..fab5e18 100644
--- a/panel-plugin/command-edit.cpp
+++ b/panel-plugin/command-edit.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2016 Graeme Gott <graeme at gottcode.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -64,8 +64,8 @@ void CommandEdit::browse_clicked()
GtkFileChooser* chooser = GTK_FILE_CHOOSER(gtk_file_chooser_dialog_new(_("Select Command"),
GTK_WINDOW(gtk_widget_get_toplevel(m_widget)),
GTK_FILE_CHOOSER_ACTION_OPEN,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_OK"), GTK_RESPONSE_ACCEPT,
NULL));
gtk_file_chooser_set_local_only(chooser, true);
gtk_file_chooser_set_current_folder(chooser, BINDIR);
diff --git a/panel-plugin/configuration-dialog.cpp b/panel-plugin/configuration-dialog.cpp
index aa850bc..27c47ac 100644
--- a/panel-plugin/configuration-dialog.cpp
+++ b/panel-plugin/configuration-dialog.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013, 2015 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2015, 2016 Graeme Gott <graeme at gottcode.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -69,9 +69,9 @@ ConfigurationDialog::ConfigurationDialog(Plugin* plugin) :
}
m_window = xfce_titled_dialog_new_with_buttons(_("Whisker Menu"),
window,
- GTK_DIALOG_NO_SEPARATOR,
- GTK_STOCK_HELP, GTK_RESPONSE_HELP,
- GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
+ GtkDialogFlags(0),
+ _("_Help"), GTK_RESPONSE_HELP,
+ _("_Close"), GTK_RESPONSE_CLOSE,
NULL);
gtk_window_set_icon_name(GTK_WINDOW(m_window), "document-properties");
gtk_window_set_position(GTK_WINDOW(m_window), GTK_WIN_POS_CENTER);
@@ -118,8 +118,8 @@ void ConfigurationDialog::choose_icon()
{
GtkWidget* chooser = exo_icon_chooser_dialog_new(_("Select An Icon"),
GTK_WINDOW(m_window),
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
+ _("_Cancel"), GTK_RESPONSE_CANCEL,
+ _("_OK"), GTK_RESPONSE_ACCEPT,
NULL);
gtk_dialog_set_default_response(GTK_DIALOG(chooser), GTK_RESPONSE_ACCEPT);
@@ -415,7 +415,7 @@ void ConfigurationDialog::remove_action(GtkButton* button)
// Confirm removal
if (!xfce_dialog_confirm(GTK_WINDOW(gtk_widget_get_toplevel(GTK_WIDGET(button))),
- GTK_STOCK_DELETE, NULL,
+ "edit-delete", _("_Delete"),
_("The action will be deleted permanently."),
_("Remove action \"%s\"?"),
action->get_name()))
diff --git a/panel-plugin/plugin.cpp b/panel-plugin/plugin.cpp
index 7800bb7..fa0dd24 100644
--- a/panel-plugin/plugin.cpp
+++ b/panel-plugin/plugin.cpp
@@ -315,7 +315,7 @@ void Plugin::menu_hidden()
void Plugin::configure()
{
ConfigurationDialog* dialog = new ConfigurationDialog(this);
- g_signal_connect_slot<GtkObject*>(dialog->get_widget(), "destroy", &Plugin::save, this);
+ g_signal_connect_slot<GtkWidget*>(dialog->get_widget(), "destroy", &Plugin::save, this);
}
//-----------------------------------------------------------------------------
diff --git a/panel-plugin/resizer-widget.cpp b/panel-plugin/resizer-widget.cpp
index ed0417f..df28a9e 100644
--- a/panel-plugin/resizer-widget.cpp
+++ b/panel-plugin/resizer-widget.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2016 Graeme Gott <graeme at gottcode.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,8 +27,7 @@ using namespace WhiskerMenu;
ResizerWidget::ResizerWidget(GtkWindow* window) :
m_window(window),
m_cursor(NULL),
- m_shape(3),
- m_supports_alpha(false)
+ m_shape(3)
{
m_alignment = GTK_ALIGNMENT(gtk_alignment_new(1,0,0,0));
@@ -40,10 +39,7 @@ ResizerWidget::ResizerWidget(GtkWindow* window) :
g_signal_connect_slot(m_drawing, "button-press-event", &ResizerWidget::on_button_press_event, this);
g_signal_connect_slot(m_drawing, "enter-notify-event", &ResizerWidget::on_enter_notify_event, this);
g_signal_connect_slot(m_drawing, "leave-notify-event", &ResizerWidget::on_leave_notify_event, this);
- g_signal_connect_slot(m_drawing, "expose-event", &ResizerWidget::on_expose_event, this);
- g_signal_connect_slot(m_window, "screen-changed", &ResizerWidget::on_screen_changed_event, this);
- on_screen_changed_event(GTK_WIDGET(m_drawing), NULL);
-
+ g_signal_connect_slot(m_drawing, "draw", &ResizerWidget::on_draw_event, this);
set_corner(TopRight);
}
@@ -140,40 +136,10 @@ gboolean ResizerWidget::on_leave_notify_event(GtkWidget* widget, GdkEvent*)
//-----------------------------------------------------------------------------
-void ResizerWidget::on_screen_changed_event(GtkWidget* widget, GdkScreen*)
+gboolean ResizerWidget::on_draw_event(GtkWidget* widget, cairo_t* cr)
{
- GdkScreen* screen = gtk_widget_get_screen(widget);
- GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
- if (!colormap)
- {
- colormap = gdk_screen_get_system_colormap(screen);
- m_supports_alpha = false;
- }
- else
- {
- m_supports_alpha = true;
- }
- gtk_widget_set_colormap(widget, colormap);
-}
-
-//-----------------------------------------------------------------------------
-
-gboolean ResizerWidget::on_expose_event(GtkWidget* widget, GdkEvent*)
-{
- cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget));
-
GtkStyle* style = gtk_widget_get_style(widget);
- // Draw semi-transparent background to match window
- if (m_supports_alpha)
- {
- const GdkColor& color = style->bg[GTK_STATE_NORMAL];
- cairo_set_source_rgba(cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0, wm_settings->menu_opacity / 100.0);
- cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
- cairo_paint(cr);
- }
-
- // Draw resize triangle
const GdkColor& color = style->text_aa[gtk_widget_get_state(widget)];
cairo_set_source_rgb(cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0);
@@ -184,8 +150,6 @@ gboolean ResizerWidget::on_expose_event(GtkWidget* widget, GdkEvent*)
}
cairo_fill(cr);
- cairo_destroy(cr);
-
return true;
}
diff --git a/panel-plugin/resizer-widget.h b/panel-plugin/resizer-widget.h
index d281aba..509acc4 100644
--- a/panel-plugin/resizer-widget.h
+++ b/panel-plugin/resizer-widget.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2013 Graeme Gott <graeme at gottcode.org>
+ * Copyright (C) 2013, 2016 Graeme Gott <graeme at gottcode.org>
*
* This library is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -49,8 +49,7 @@ private:
gboolean on_button_press_event(GtkWidget*, GdkEvent* event);
gboolean on_enter_notify_event(GtkWidget* widget, GdkEvent*);
gboolean on_leave_notify_event(GtkWidget* widget, GdkEvent*);
- void on_screen_changed_event(GtkWidget* widget, GdkScreen* old_screen);
- gboolean on_expose_event(GtkWidget* widget, GdkEvent*);
+ gboolean on_draw_event(GtkWidget* widget, cairo_t* cr);
private:
GtkWindow* m_window;
@@ -59,7 +58,6 @@ private:
GdkCursor* m_cursor;
GdkWindowEdge m_edge;
std::vector<GdkPoint> m_shape;
- bool m_supports_alpha;
};
}
diff --git a/panel-plugin/search-page.cpp b/panel-plugin/search-page.cpp
index d85f165..7a742aa 100644
--- a/panel-plugin/search-page.cpp
+++ b/panel-plugin/search-page.cpp
@@ -213,7 +213,7 @@ void SearchPage::clear_search(GtkEntry* entry, GtkEntryIconPosition icon_pos, Gd
gboolean SearchPage::cancel_search(GtkWidget* widget, GdkEvent* event)
{
GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event);
- if (key_event->keyval == GDK_Escape)
+ if (key_event->keyval == GDK_KEY_Escape)
{
GtkEntry* entry = GTK_ENTRY(widget);
const gchar* text = gtk_entry_get_text(entry);
diff --git a/panel-plugin/whiskermenu.desktop b/panel-plugin/whiskermenu.desktop
index b96a638..666340f 100644
--- a/panel-plugin/whiskermenu.desktop
+++ b/panel-plugin/whiskermenu.desktop
@@ -98,3 +98,4 @@ Comment[zh_TW]=顯示選單以方便開啟已安裝的應用程式
Icon=xfce4-whiskermenu
X-XFCE-Module=whiskermenu
X-XFCE-Internal=false
+X-XFCE-API=2.0
diff --git a/panel-plugin/window.cpp b/panel-plugin/window.cpp
index 3a6b909..17555e1 100644
--- a/panel-plugin/window.cpp
+++ b/panel-plugin/window.cpp
@@ -212,10 +212,8 @@ WhiskerMenu::Window::Window() :
gtk_window_set_default_size(m_window, m_geometry.width, m_geometry.height);
// Handle transparency
- gtk_widget_set_app_paintable(GTK_WIDGET(m_sidebar_buttons), true);
- g_signal_connect_slot(m_sidebar_buttons, "expose-event", &Window::on_expose_event, this);
gtk_widget_set_app_paintable(GTK_WIDGET(m_window), true);
- g_signal_connect_slot(m_window, "expose-event", &Window::on_expose_event, this);
+ g_signal_connect_slot(m_window, "draw", &Window::on_draw_event, this);
g_signal_connect_slot(m_window, "screen-changed", &Window::on_screen_changed_event, this);
on_screen_changed_event(GTK_WIDGET(m_window), NULL);
@@ -707,7 +705,7 @@ gboolean WhiskerMenu::Window::on_key_press_event(GtkWidget* widget, GdkEvent* ev
GdkEventKey* key_event = reinterpret_cast<GdkEventKey*>(event);
// Hide if escape is pressed and there is no text in search entry
- if ( (key_event->keyval == GDK_Escape) && exo_str_is_empty(gtk_entry_get_text(m_search_entry)) )
+ if ( (key_event->keyval == GDK_KEY_Escape) && exo_str_is_empty(gtk_entry_get_text(m_search_entry)) )
{
hide();
return true;
@@ -817,22 +815,22 @@ gboolean WhiskerMenu::Window::on_configure_event(GtkWidget*, GdkEvent* event)
void WhiskerMenu::Window::on_screen_changed_event(GtkWidget* widget, GdkScreen*)
{
GdkScreen* screen = gtk_widget_get_screen(widget);
- GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen);
- if (!colormap || (wm_settings->menu_opacity == 100))
+ GdkVisual* visual = gdk_screen_get_rgba_visual(screen);
+ if (!visual || (wm_settings->menu_opacity == 100))
{
- colormap = gdk_screen_get_system_colormap(screen);
+ visual = gdk_screen_get_system_visual(screen);
m_supports_alpha = false;
}
else
{
m_supports_alpha = true;
}
- gtk_widget_set_colormap(widget, colormap);
+ gtk_widget_set_visual(widget, visual);
}
//-----------------------------------------------------------------------------
-gboolean WhiskerMenu::Window::on_expose_event(GtkWidget* widget, GdkEventExpose*)
+gboolean WhiskerMenu::Window::on_draw_event(GtkWidget* widget, cairo_t* cr)
{
if (!gtk_widget_get_realized(widget))
{
@@ -846,7 +844,6 @@ gboolean WhiskerMenu::Window::on_expose_event(GtkWidget* widget, GdkEventExpose*
}
GdkColor color = style->bg[GTK_STATE_NORMAL];
- cairo_t* cr = gdk_cairo_create(gtk_widget_get_window(widget));
if (m_supports_alpha)
{
cairo_set_source_rgba(cr, color.red / 65535.0, color.green / 65535.0, color.blue / 65535.0, wm_settings->menu_opacity / 100.0);
@@ -857,7 +854,6 @@ gboolean WhiskerMenu::Window::on_expose_event(GtkWidget* widget, GdkEventExpose*
}
cairo_set_operator(cr, CAIRO_OPERATOR_SOURCE);
cairo_paint(cr);
- cairo_destroy(cr);
return false;
}
diff --git a/panel-plugin/window.h b/panel-plugin/window.h
index fec8e50..d3b6768 100644
--- a/panel-plugin/window.h
+++ b/panel-plugin/window.h
@@ -82,7 +82,7 @@ private:
gboolean on_map_event(GtkWidget*, GdkEvent*);
gboolean on_configure_event(GtkWidget*, GdkEvent* event);
void on_screen_changed_event(GtkWidget* widget, GdkScreen* old_screen);
- gboolean on_expose_event(GtkWidget* widget, GdkEventExpose* event);
+ gboolean on_draw_event(GtkWidget* widget, cairo_t* cr);
void favorites_toggled();
void recent_toggled();
void category_toggled();
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the Xfce4-commits
mailing list