Skip to content

Commit

Permalink
The following brings back compatibility with GTK+2 to Remmina 1.1.x (…
Browse files Browse the repository at this point in the history
…HEAD of master branch), while to keeping compatibility with GTK+3, by using GtkGrid on GTK+3 and the old GtkTable in GTK+2. Close #386
  • Loading branch information
antenore committed Dec 7, 2014
2 parents a2aee21 + f0b1e1b commit 716b569
Show file tree
Hide file tree
Showing 25 changed files with 759 additions and 194 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,5 @@ remmina/src/remmina
remmina/desktop/remmina.desktop
remmina-plugins/libvncserver/rfb/rfbconfig.h
remmina-plugins/telepathy/org.freedesktop.Telepathy.Client.Remmina.service

build
67 changes: 67 additions & 0 deletions cmake/FindLibintl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# Try to find Libintl functionality
# Once done this will define
#
# LIBINTL_FOUND - system has Libintl
# LIBINTL_INCLUDE_DIR - Libintl include directory
# LIBINTL_LIBRARIES - Libraries needed to use Libintl
#
# TODO: This will enable translations only if Gettext functionality is
# present in libc. Must have more robust system for release, where Gettext
# functionality can also reside in standalone Gettext library, or the one
# embedded within kdelibs (cf. gettext.m4 from Gettext source).

# Copyright (c) 2006, Chusslove Illich, <caslav.ilic@gmx.net>
# Copyright (c) 2007, Alexander Neundorf, <neundorf@kde.org>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

if(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)
set(Libintl_FIND_QUIETLY TRUE)
endif(LIBINTL_INCLUDE_DIR AND LIBINTL_LIB_FOUND)

find_path(LIBINTL_INCLUDE_DIR libintl.h)

set(LIBINTL_LIB_FOUND FALSE)

if(LIBINTL_INCLUDE_DIR)
include(CheckFunctionExists)
check_function_exists(dgettext LIBINTL_LIBC_HAS_DGETTEXT)

if (LIBINTL_LIBC_HAS_DGETTEXT)
set(LIBINTL_LIBRARIES)
set(LIBINTL_LIB_FOUND TRUE)
else (LIBINTL_LIBC_HAS_DGETTEXT)
find_library(LIBINTL_LIBRARIES NAMES intl libintl )
if(LIBINTL_LIBRARIES)
set(LIBINTL_LIB_FOUND TRUE)
endif(LIBINTL_LIBRARIES)
endif (LIBINTL_LIBC_HAS_DGETTEXT)

endif(LIBINTL_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libintl DEFAULT_MSG LIBINTL_LIBRARIES LIBINTL_LIB_FOUND)

mark_as_advanced(LIBINTL_INCLUDE_DIR LIBINTL_LIBRARIES LIBINTL_LIBC_HAS_DGETTEXT LIBINTL_LIB_FOUND)

3 changes: 3 additions & 0 deletions cmake/GETTEXT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
# Boston, MA 02111-1307, USA.

find_suggested_package(Gettext)
if (GETTEXT_FOUND)
find_package(Libintl)
endif()

function(gettext po_dir package_name)
set(mo_files)
Expand Down
4 changes: 2 additions & 2 deletions remmina-plugins/rdp/rdp_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ static RemminaFile* remmina_rdp_file_import_channel(GIOChannel* channel)
else
{
enc = "UTF-8";
if (g_io_channel_seek(channel, 0, G_SEEK_SET) != G_IO_ERROR_NONE)
if (g_io_channel_seek_position(channel, 0, G_SEEK_SET, &error) != G_IO_STATUS_NORMAL)
{
g_print("g_io_channel_seek: failed\n");
return NULL;
Expand Down Expand Up @@ -233,7 +233,7 @@ RemminaFile* remmina_rdp_file_import(const gchar* from_file)
}

remminafile = remmina_rdp_file_import_channel(channel);
g_io_channel_close(channel);
g_io_channel_shutdown(channel, FALSE, &error);

return remminafile;
}
Expand Down
4 changes: 0 additions & 4 deletions remmina-plugins/rdp/rdp_plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -863,14 +863,10 @@ static gboolean remmina_rdp_main(RemminaProtocolWidget* gp)
if (!rfi->user_cancelled)
{
remmina_plugin_service->protocol_plugin_set_error(gp, _("Unable to connect to RDP server %s"), rfi->settings->ServerHostname);

}

return FALSE;
}



remmina_rdp_main_loop(gp);

return TRUE;
Expand Down
65 changes: 48 additions & 17 deletions remmina-plugins/rdp/rdp_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ guint remmina_rdp_settings_get_keyboard_layout(void)

typedef struct _RemminaPluginRdpsetGrid
{
#if GTK_VERSION == 3
GtkGrid grid;
#else
GtkTable grid;
#endif

GtkWidget* keyboard_layout_label;
GtkWidget* keyboard_layout_combo;
Expand All @@ -95,12 +99,20 @@ typedef struct _RemminaPluginRdpsetGrid

typedef struct _RemminaPluginRdpsetGridClass
{
#if GTK_VERSION == 3
GtkGridClass parent_class;
#else
GtkTableClass parent_class;
#endif
} RemminaPluginRdpsetGridClass;

GType remmina_rdp_settings_grid_get_type(void) G_GNUC_CONST;

#if GTK_VERSION == 3
G_DEFINE_TYPE(RemminaPluginRdpsetGrid, remmina_rdp_settings_grid, GTK_TYPE_GRID)
#else
G_DEFINE_TYPE(RemminaPluginRdpsetGrid, remmina_rdp_settings_grid, GTK_TYPE_TABLE)
#endif

static void remmina_rdp_settings_grid_class_init(RemminaPluginRdpsetGridClass* klass)
{
Expand Down Expand Up @@ -261,6 +273,19 @@ static void remmina_rdp_settings_quality_option_on_toggled(GtkToggleButton* togg
}
}

static inline void remmina_rdp_settings_grid_attach(RemminaPluginRdpsetGrid *grid, GtkWidget *child,
gint left, gint top, gint width, gint height)
{
#if GTK_VERSION == 3
//gtk_grid_attach (GtkGrid *grid, GtkWidget *child, gint left, gint top, gint width, gint height);
gtk_grid_attach(GTK_GRID(grid), child, left, top, width, height);
#else
//gtk_table_attach_defaults (GtkTable *table, GtkWidget *widget,
// guint left_attach, guint right_attach, guint top_attach, guint bottom_attach);
gtk_table_attach_defaults(GTK_TABLE(grid), child, left, left + width - 1, top, top + height - 1);
#endif
}

static void remmina_rdp_settings_grid_init(RemminaPluginRdpsetGrid *grid)
{
gchar* s;
Expand All @@ -269,23 +294,30 @@ static void remmina_rdp_settings_grid_init(RemminaPluginRdpsetGrid *grid)

/* Create the grid */
g_signal_connect(G_OBJECT(grid), "destroy", G_CALLBACK(remmina_rdp_settings_grid_destroy), NULL);
#if GTK_VERSION == 3
gtk_grid_set_row_homogeneous(GTK_GRID(grid), FALSE);
gtk_grid_set_column_homogeneous(GTK_GRID(grid), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(grid), 8);
gtk_grid_set_row_spacing(GTK_GRID(grid), 4);
gtk_grid_set_column_spacing(GTK_GRID(grid), 4);

//gtk_grid_attach (GtkGrid *grid, GtkWidget *child, gint left, gint top, gint width, gint height);
#else
gtk_table_resize(GTK_TABLE(grid), 8, 3);
gtk_table_set_homogeneous(GTK_TABLE(grid), FALSE);
gtk_container_set_border_width(GTK_CONTAINER(grid), 8);
gtk_table_set_row_spacings(GTK_TABLE(grid), 4);
gtk_table_set_col_spacings(GTK_TABLE(grid), 4);
#endif

/* Create the content */
widget = gtk_label_new(_("Keyboard layout"));
gtk_widget_show(widget);
gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
gtk_grid_attach(GTK_GRID(grid), widget, 0, 0, 1, 1);
remmina_rdp_settings_grid_attach(grid, widget, 0, 0, 1, 1);

grid->keyboard_layout_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(grid->keyboard_layout_store));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 0, 4, 1);
remmina_rdp_settings_grid_attach(grid, widget, 1, 0, 4, 1);

renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
Expand All @@ -295,14 +327,14 @@ static void remmina_rdp_settings_grid_init(RemminaPluginRdpsetGrid *grid)
widget = gtk_label_new("-");
gtk_widget_show(widget);
gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 1, 4, 2);
remmina_rdp_settings_grid_attach(grid, widget, 1, 1, 4, 2);
grid->keyboard_layout_label = widget;

remmina_rdp_settings_grid_load_layout(grid);

widget = gtk_check_button_new_with_label(_("Use client keyboard mapping"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 3, 3, 3);
remmina_rdp_settings_grid_attach(grid, widget, 1, 3, 3, 3);
grid->use_client_keymap_check = widget;

s = remmina_plugin_service->pref_get_value("rdp_use_client_keymap");
Expand All @@ -313,12 +345,12 @@ static void remmina_rdp_settings_grid_init(RemminaPluginRdpsetGrid *grid)
widget = gtk_label_new(_("Quality option"));
gtk_widget_show(widget);
gtk_misc_set_alignment(GTK_MISC(widget), 0.0, 0.5);
gtk_grid_attach(GTK_GRID(grid), widget, 0, 6, 1, 4);
remmina_rdp_settings_grid_attach(grid, widget, 0, 6, 1, 4);

grid->quality_store = gtk_list_store_new(2, G_TYPE_UINT, G_TYPE_STRING);
widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(grid->quality_store));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 6, 4, 4);
remmina_rdp_settings_grid_attach(grid, widget, 1, 6, 4, 4);

renderer = gtk_cell_renderer_text_new();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(widget), renderer, TRUE);
Expand All @@ -331,56 +363,56 @@ static void remmina_rdp_settings_grid_init(RemminaPluginRdpsetGrid *grid)

widget = gtk_check_button_new_with_label(_("Wallpaper"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 10, 2, 5);
remmina_rdp_settings_grid_attach(grid, widget, 1, 10, 2, 5);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->wallpaper_check = widget;

widget = gtk_check_button_new_with_label(_("Window drag"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 3, 10, 3, 5);
remmina_rdp_settings_grid_attach(grid, widget, 3, 10, 3, 5);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->windowdrag_check = widget;

widget = gtk_check_button_new_with_label(_("Menu animation"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 13, 2, 6);
remmina_rdp_settings_grid_attach(grid, widget, 1, 13, 2, 6);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->menuanimation_check = widget;

widget = gtk_check_button_new_with_label(_("Theme"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 3, 13, 3, 6);
remmina_rdp_settings_grid_attach(grid, widget, 3, 13, 3, 6);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->theme_check = widget;

widget = gtk_check_button_new_with_label(_("Cursor shadow"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 16, 2, 7);
remmina_rdp_settings_grid_attach(grid, widget, 1, 16, 2, 7);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->cursorshadow_check = widget;

widget = gtk_check_button_new_with_label(_("Cursor blinking"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 3, 16, 3, 7);
remmina_rdp_settings_grid_attach(grid, widget, 3, 16, 3, 7);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->cursorblinking_check = widget;

widget = gtk_check_button_new_with_label(_("Font smoothing"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 1, 19, 2, 8);
remmina_rdp_settings_grid_attach(grid, widget, 1, 19, 2, 8);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->fontsmoothing_check = widget;

widget = gtk_check_button_new_with_label(_("Composition"));
gtk_widget_show(widget);
gtk_grid_attach(GTK_GRID(grid), widget, 3, 19, 3, 8);
remmina_rdp_settings_grid_attach(grid, widget, 3, 19, 3, 8);
g_signal_connect(G_OBJECT(widget), "toggled",
G_CALLBACK(remmina_rdp_settings_quality_option_on_toggled), grid);
grid->composition_check = widget;
Expand All @@ -397,4 +429,3 @@ GtkWidget* remmina_rdp_settings_new(void)

return widget;
}

5 changes: 4 additions & 1 deletion remmina/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ add_executable(remmina ${REMMINA_SRCS})

include_directories(${GTK_INCLUDE_DIRS})
target_link_libraries(remmina ${GTK_LIBRARIES})
if(NOT LIBINTL_LIBC_HAS_DGETTEXT)
target_link_libraries(remmina -lintl)
endif()

find_package(X11)
include_directories(${X11_INCLUDE_DIR})
Expand Down Expand Up @@ -149,7 +152,7 @@ if(GTK3_FOUND AND WITH_VTE)
message(STATUS "VTE ${__VTE_VERSION} not found")
endforeach(__VTE_VERSION)
elseif(WITH_VTE)
set(_VTE_VERSION_NUM)
set(_VTE_VERSION_NUM 2.90)
find_package(VTE)
endif()

Expand Down
2 changes: 2 additions & 0 deletions remmina/src/remmina.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ int main(int argc, char* argv[])
textdomain(GETTEXT_PACKAGE);

#ifdef HAVE_PTHREAD
#if !GLIB_CHECK_VERSION(2,36,0)
g_type_init ();
#endif
gdk_threads_init ();
#endif

Expand Down
9 changes: 9 additions & 0 deletions remmina/src/remmina_applet_menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*
*/

#include "config.h"
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <string.h>
Expand Down Expand Up @@ -88,14 +89,22 @@ remmina_applet_menu_add_group(GtkWidget *menu, const gchar *group, gint position
GtkWidget *image;
GtkWidget *submenu;

#if GTK_VERSION == 3
widget = gtk_menu_item_new_with_label(group);
#else
widget = gtk_image_menu_item_new_with_label(group);
#endif
gtk_widget_show(widget);

image =
gtk_image_new_from_icon_name(
(menuitem->item_type == REMMINA_APPLET_MENU_ITEM_DISCOVERED ?
"folder-remote" : "folder"), GTK_ICON_SIZE_MENU);
gtk_widget_show(image);
#if GTK_VERSION == 2
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(widget), image);
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(widget), TRUE);
#endif

g_object_set_data_full(G_OBJECT(widget), "group", g_strdup(group), g_free);
g_object_set_data(G_OBJECT(widget), "count", GINT_TO_POINTER(0));
Expand Down
12 changes: 12 additions & 0 deletions remmina/src/remmina_applet_menu_item.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*
*/

#include "config.h"
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <string.h>
Expand Down Expand Up @@ -154,10 +155,21 @@ GtkWidget* remmina_applet_menu_item_new(RemminaAppletMenuItemType item_type, ...
}
else
{
#if GTK_VERSION == 3
widget = gtk_image_new_from_icon_name("go-jump", GTK_ICON_SIZE_MENU);
#else
// This is weird I must use the deprecated function call for the jump to
// icon keep it working with MATE, Tango and GNOME themes
// Everywhere else can use the forward compatible function
widget = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, GTK_ICON_SIZE_MENU);
#endif
}

gtk_widget_show(widget);
#if GTK_VERSION == 2
gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), widget);
gtk_image_menu_item_set_always_show_image(GTK_IMAGE_MENU_ITEM(item), TRUE);
#endif

if (item->server)
{
Expand Down

0 comments on commit 716b569

Please sign in to comment.