From: Author: Yavor Doganov <yavor@gnu.org>
Date: Tue, 09 Oct 2018 21:55:28 +0300
Subject: Avoid libgnome(ui) dependency.
 This patch also fixes the window and about dialog icon.

Bug-Debian: https://bugs.debian.org/868427
Forwarded: no
---
 configure.ac    | 10 +---------
 src/Makefile.am |  4 ++--
 src/btnbox.c    | 20 +++++++++-----------
 src/btnbox.h    |  1 +
 src/global.h    |  2 ++
 src/main.c      | 34 +++++++++++++++++++++++++++++-----
 src/main.h      |  2 +-
 src/options.c   | 16 ++++++++++++----
 src/options.h   |  1 -
 src/rdpparse.c  | 13 +++++--------
 src/run.c       |  4 ++--
 src/srvsel.h    |  1 +
 src/sshbox.h    |  2 +-
 13 files changed, 66 insertions(+), 44 deletions(-)

diff --git a/configure.ac b/configure.ac
index 288a2db..bec12c5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,21 +46,13 @@ GETTEXT_PACKAGE=$PACKAGE
 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], ["${GETTEXT_PACKAGE}"], [gettext domain])
 
 dnl Searching for GTK+ 2 includes/libs and export compiler flags
-PKG_CHECK_MODULES(GTK2, gtk+-2.0, HAVE_GTK=yes, HAVE_GTK=no)
+PKG_CHECK_MODULES(GTK2, [gtk+-2.0 gconf-2.0], HAVE_GTK=yes, HAVE_GTK=no)
 if test "$HAVE_GTK" = "no"; then
 	AC_MSG_ERROR([cannot find GTK+ 2.0!])
 fi
 AC_SUBST(GTK2_CFLAGS)
 AC_SUBST(GTK2_LIBS)
 
-dnl Searching for GNOME 2 includes/libs and export compiler flags
-PKG_CHECK_MODULES(GNOME2, libgnomeui-2.0, HAVE_GNOME2=yes, HAVE_GNOME2=no)
-if test "$HAVE_GNOME2" = "no"; then
-	AC_MSG_ERROR([cannot find GNOME2 2.0!])
-fi
-AC_SUBST(GNOME2_CFLAGS)
-AC_SUBST(GNOME2_LIBS)
-
 AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
 if test "$GCONFTOOL" = "no"; then
 	AC_MSG_ERROR([cannot find gconf 2.0!])
diff --git a/src/Makefile.am b/src/Makefile.am
index 0990bd7..05c45dc 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -23,7 +23,7 @@ bin_PROGRAMS = grdesktop
 
 INCLUDES = -I$(top_srcdir) -I$(top_builddir) \
 	-I$(top_srcdir)/intl \
-	$(GTK2_CFLAGS) $(GNOME2_CFLAGS) \
+	$(GTK2_CFLAGS) \
 	-DDATADIR=\""$(datadir)"\" \
 	-DLOCALEDIR=\""$(datadir)/locale"\" \
 	-DKBPATH=\""$(kbpath)"\"
@@ -39,7 +39,7 @@ grdesktop_SOURCES = main.c main.h \
 	sshbox.c sshbox.h \
 	config.h
 
-grdesktop_LDADD = $(GTK2_LIBS) $(GNOME2_LIBS)
+grdesktop_LDADD = $(GTK2_LIBS)
 
 grdesktopdir = $(datadir)/applications
 grdesktop_DATA = grdesktop.desktop
diff --git a/src/btnbox.c b/src/btnbox.c
index cb06887..4d633dd 100644
--- a/src/btnbox.c
+++ b/src/btnbox.c
@@ -69,12 +69,12 @@ GtkWidget *button_box() {
 void sig_connect(GtkWidget *widget, gpointer data) {
 	/* stop, if box is empty */
 	if(SHASH("hostname") == NULL) {
-		gnome_error_dialog(
+		error_dialog(
 			_("Please select or insert a valid hostname/ip-address!"));
 		return;
 	}
 	if(strlen(SHASH("hostname")) <= 0) {
-		gnome_error_dialog(
+		error_dialog(
 			_("Please select or insert a valid hostname/ip-address!"));
 		return;
 	}
@@ -94,16 +94,14 @@ void sig_cancel(GtkWidget *widget, gpointer data) {
 }
 
 void sig_about(GtkWidget *widget, gpointer data) {
-	GtkWidget *about = NULL;
 	gchar *authors[] = { "Thorsten Sauter <tsauter@gmx.net>", NULL };
 
-	about = gnome_about_new(_("Remotedesktop Client"), VERSION,
-		_("(C) 2002-2004 Thorsten Sauter"),
-		_("Gnome frontend for rdesktop"),
-		(const char**)authors, NULL, NULL, NULL);
-	gtk_signal_connect(GTK_OBJECT(about), "destroy",
-		GTK_SIGNAL_FUNC(gtk_widget_destroy), &about);
-	gtk_widget_show(about);
+	gtk_show_about_dialog(GTK_WINDOW(window_main),
+	                      "program-name", _("Remotedesktop Client"),
+	                      "version", VERSION,
+	                      "copyright", _("(C) 2002-2004 Thorsten Sauter"),
+	                      "comments", _("Gnome frontend for rdesktop"),
+	                      "authors", authors, NULL);
 }
 
 void sig_options(GtkWidget *widget, gpointer data) {
@@ -123,7 +121,7 @@ void sig_options(GtkWidget *widget, gpointer data) {
 void sig_help(GtkWidget *widget, gpointer data) {
 	GError *err = NULL;
 
-	gnome_help_display(PACKAGE, NULL, &err);
+	gtk_show_uri(NULL, "ghelp:"PACKAGE, GDK_CURRENT_TIME, &err);
 	if(err != NULL) {
 		GtkWidget *dlg = NULL;
 
diff --git a/src/btnbox.h b/src/btnbox.h
index 0d7bf63..08894ec 100644
--- a/src/btnbox.h
+++ b/src/btnbox.h
@@ -23,6 +23,7 @@
 #ifndef __BTNBOX_H__
 #define __BTNBOX_H__
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include "config.h"
 #include "global.h"
diff --git a/src/global.h b/src/global.h
index 8bae28b..283b84f 100644
--- a/src/global.h
+++ b/src/global.h
@@ -111,5 +111,7 @@ GtkWidget *combo_clientname;
 GtkWidget *check_sshopts;
 GtkWidget *btn_sshopts;
 
+void error_dialog(gchar *msg, ...);
+
 #endif /* __CONFIG_H__ */
 
diff --git a/src/main.c b/src/main.c
index 57fad21..f6630f8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -22,6 +22,25 @@
 
 #include "main.h"
 
+void error_dialog(gchar *msg, ...) {
+	GtkWidget *dlg;
+	gchar *dlg_msg;
+	va_list ap;
+
+	va_start(ap, msg);
+	dlg_msg = g_strdup_vprintf(msg, ap);
+	va_end(ap);
+
+	dlg = gtk_message_dialog_new(GTK_WINDOW(window_main),
+	                             GTK_DIALOG_DESTROY_WITH_PARENT,
+	                             GTK_MESSAGE_ERROR,
+	                             GTK_BUTTONS_CLOSE,
+	                             "%s", dlg_msg);
+	gtk_dialog_run (GTK_DIALOG(dlg));
+	gtk_widget_destroy(dlg);
+	g_free(dlg_msg);
+}
+
 gint delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) {
 	return(FALSE);
 }
@@ -41,7 +60,7 @@ int make_gui(gchar *rdpfile) {
 	GtkWidget *btnBox;
 	GdkPixbufAnimation *animation;
 
-	window_main = gnome_app_new("grdesktop", _("Remotedesktop Client"));
+	window_main = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 	gtk_window_set_wmclass(GTK_WINDOW(window_main),
 		"grdesktop", "grdesktop");
 	gtk_container_set_border_width(GTK_CONTAINER(window_main), 0);
@@ -55,7 +74,7 @@ int make_gui(gchar *rdpfile) {
 			G_CALLBACK(destroy), NULL);
 
 	winBox = gtk_vbox_new(FALSE, 0);
-	gnome_app_set_contents(GNOME_APP(window_main), winBox);
+	gtk_container_add(GTK_CONTAINER(window_main), winBox);
 	gtk_widget_show(winBox);
 
 	/* display the topic image */
@@ -141,6 +160,7 @@ int main(int argc, char *argv[]) {
 	gboolean opt_usage = FALSE;
 	gboolean opt_version = FALSE;
 	gboolean opt_start = FALSE;
+	gchar *dir, *icon;
 
 #ifdef ENABLE_NLS
 	if(setlocale(LC_ALL, "") == NULL)
@@ -150,9 +170,13 @@ int main(int argc, char *argv[]) {
 	textdomain(PACKAGE);
 #endif
 	
-	gnome_program_init("grdesktop", VERSION, LIBGNOMEUI_MODULE,
-		argc, argv, GNOME_PARAM_APP_DATADIR, DATADIR, NULL);
-	gnome_window_icon_set_default_from_file(DATADIR"/grdesktop.png");
+	gtk_init(&argc, &argv);
+	dir = g_build_path(G_DIR_SEPARATOR_S, DATADIR, "pixmaps",
+	                   "grdesktop", NULL);
+	icon = g_build_filename(dir, "icon.png", NULL);
+	gtk_window_set_default_icon_from_file(icon, NULL);
+	g_free(dir);
+	g_free(icon);
 	gconf_init(argc, argv, NULL);
 	gcfg = gconf_client_get_default();
 	
diff --git a/src/main.h b/src/main.h
index c868bb5..f3b2c7b 100644
--- a/src/main.h
+++ b/src/main.h
@@ -24,8 +24,8 @@
 #define __MAIN_H__
 
 #include "config.h"
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <gnome.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <libintl.h>
diff --git a/src/options.c b/src/options.c
index d887bb3..4ed5051 100644
--- a/src/options.c
+++ b/src/options.c
@@ -136,9 +136,16 @@ void loadKeymap(GtkListStore *model) {
 	/* fill the list */
 	kbdir = opendir(KBPATH);
 	if(kbdir == NULL) {
-		gnome_warning_dialog(g_strdup_printf(
-			_("Unable to find keyboard definitions: %s"),
-			KBPATH));
+	        GtkWidget *dlg;
+
+	        dlg = gtk_message_dialog_new(GTK_WINDOW(window_main),
+	                                     GTK_DIALOG_DESTROY_WITH_PARENT,
+	                                     GTK_MESSAGE_WARNING,
+	                                     GTK_BUTTONS_CLOSE,
+	                                     _("Unable to find keyboard "
+	                                       "definitions: %s"), KBPATH);
+	        gtk_dialog_run(GTK_DIALOG(dlg));
+	        gtk_widget_destroy(dlg);
 	}
 
 	if(kbdir != NULL) {
@@ -494,7 +501,7 @@ void fill_dialog() {
 		iSHASH("usessh"));
 	gtk_widget_set_sensitive(btn_sshopts, iSHASH("usessh"));
 
-	licence_path = gnome_util_prepend_user_home(".rdesktop");
+	licence_path = g_build_filename(g_get_home_dir(), ".rdesktop", NULL);
 	licence_dir = opendir(licence_path);
 	if(licence_dir != NULL) {
 		struct dirent *entry = NULL;
@@ -520,6 +527,7 @@ void fill_dialog() {
 			licence_list = g_list_append(licence_list, g_strdup(hostname));
 		}
 		closedir(licence_dir);
+		g_free(licence_path);
 		if(licence_list != NULL) {
 			gtk_combo_set_popdown_strings(GTK_COMBO(combo_clientname),
 				licence_list);
diff --git a/src/options.h b/src/options.h
index f1164e7..9877f51 100644
--- a/src/options.h
+++ b/src/options.h
@@ -25,7 +25,6 @@
 
 #include <gtk/gtk.h>
 #include <gdk/gdk.h>
-#include <gnome.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <unistd.h>
diff --git a/src/rdpparse.c b/src/rdpparse.c
index 82983b2..5561e5a 100644
--- a/src/rdpparse.c
+++ b/src/rdpparse.c
@@ -30,7 +30,7 @@ void sig_file_open(GtkWidget *widget, gpointer data) {
 	filesel = GTK_FILE_SELECTION(data);
 	filename = g_strdup(gtk_file_selection_get_filename(filesel));
 	if(filename[strlen(filename)-1] == '/') {
-		gnome_error_dialog(_("Please select a valid rdp file!"));
+		error_dialog(_("Please select a valid rdp file!"));
 		sig_loadbtn(widget, NULL);
 		return;
 	}
@@ -47,7 +47,7 @@ void sig_file_save(GtkWidget *widget, gpointer data) {
 	filesel = GTK_FILE_SELECTION(data);
 	filename = g_strdup(gtk_file_selection_get_filename(filesel));
 	if(filename[strlen(filename)-1] == '/') {
-		gnome_error_dialog(_("Please select a valid rdp file!"));
+		error_dialog(_("Please select a valid rdp file!"));
 		sig_savebtn(widget, NULL);
 		return;
 	}
@@ -74,8 +74,7 @@ void sig_file_save(GtkWidget *widget, gpointer data) {
 
 	file = fopen(filename, "w");
 	if(file == NULL) {
-		gnome_error_dialog(g_strdup_printf(_("Unable to save rdp-file: %s"),
-			filename));
+		error_dialog(_("Unable to save rdp-file: %s"), filename);
 		return;
 	}
 
@@ -135,15 +134,13 @@ gint parse_file(gchar *filename) {
 	gint i, ch;
 
 	if(!g_file_test(filename, G_FILE_TEST_EXISTS|G_FILE_TEST_IS_REGULAR)) {
-		gnome_error_dialog(g_strdup_printf(_("Unable to open rdp-file: %s"),
-			filename));
+		error_dialog(_("Unable to open rdp-file: %s"), filename);
 		return(1);
 	}
 
 	file = fopen(filename, "r");
 	if(file == NULL) {
-		gnome_error_dialog(g_strdup_printf(_("Unable to open rdp-file: %s"),
-			filename));
+		error_dialog(_("Unable to open rdp-file: %s"), filename);
 		return(1);
 	}
 
diff --git a/src/run.c b/src/run.c
index 080409d..a97b0ad 100644
--- a/src/run.c
+++ b/src/run.c
@@ -98,7 +98,7 @@ void run_rdesktop() {
 #endif
 
 		if(!SHASH("sshhost") || strlen(SHASH("sshhost")) <= 0) {
-			gnome_error_dialog(_("No hostname for ssh tunneling available"));
+			error_dialog(_("No hostname for ssh tunneling available"));
 			return;
 		}
 
@@ -131,7 +131,7 @@ void run_rdesktop() {
 	loadServers();		/* make sure, we reload the available servers */
 
 	if((ret != TRUE) || (estatus != 0)) {
-		gnome_error_dialog(std_err);
+		error_dialog(std_err);
 		return;
 	}
 
diff --git a/src/srvsel.h b/src/srvsel.h
index 9e577a1..5710093 100644
--- a/src/srvsel.h
+++ b/src/srvsel.h
@@ -23,6 +23,7 @@
 #ifndef __SRVSEL_H__
 #define __SRVSEL_H__
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
 #include <stdlib.h>
 #include <stdio.h>
diff --git a/src/sshbox.h b/src/sshbox.h
index f030b5f..05bd94a 100644
--- a/src/sshbox.h
+++ b/src/sshbox.h
@@ -23,8 +23,8 @@
 #ifndef __SSHBOX_H__
 #define __SSHBOX_H__
 
+#include <glib/gi18n.h>
 #include <gtk/gtk.h>
-#include <gnome.h>
 #include "config.h"
 #include "global.h"
 
