Skip to content

Commit

Permalink
Remove dependencies on libunique, libgnomeui and libglade2
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Pyhalov committed Dec 12, 2017
1 parent 41af213 commit e60844d
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 5,809 deletions.
2 changes: 0 additions & 2 deletions capplet/Makefile.am
Expand Up @@ -27,7 +27,6 @@ AM_CPPFLAGS = \
$(NWAM_MANAGER_CFLAGS) \
-DNWAM_MANAGER_DATADIR=\""$(pkgdatadir)"\" \
-DNWAM_MANAGER_LOCALEDIR=\""$(prefix)/$(DATADIRNAME)/locale"\" \
-DGLADEDIR=\""$(pkgdatadir)"\" \
-DSYSCONFDIR=\"$(sysconfdir)\" \
-DPRINTER_HELPER_PATH=\"$(libexecdir)\" \
$(NULL)
Expand Down Expand Up @@ -114,7 +113,6 @@ EXTRA_DIST = \
nwam_vpn_pref_dialog.h \
nwam_wireless_chooser.h \
nwam_wireless_dialog.h \
$(glade_DATA) \
$(NULL)

DISTCLEANFILES = \
Expand Down
86 changes: 19 additions & 67 deletions capplet/main.c
Expand Up @@ -28,9 +28,6 @@
#include <stdlib.h>
#include <gtk/gtk.h>
#include <glib/gi18n.h>
#include <libgnomeui/libgnomeui.h>
#include <glade/glade-xml.h>
#include <unique/unique.h>

#include <libnwamui.h>
#include "nwam_tree_view.h"
Expand Down Expand Up @@ -77,61 +74,26 @@ GOptionEntry application_options[] = {
{ NULL }
};

static GtkWidget*
customwidgethandler(GladeXML *xml,
gchar *func_name,
gchar *name,
gchar *string1,
gchar *string2,
gint int1,
gint int2,
gpointer user_data)
{
if (g_ascii_strcasecmp(name, "address_table") == 0 ||
g_ascii_strcasecmp(name, "connection_status_table") == 0 ||
g_ascii_strcasecmp(name, "location_tree") == 0 ||
g_ascii_strcasecmp(name, "vpn_apps_list") == 0 ||
g_ascii_strcasecmp(name, "network_profile_table") == 0) {
g_debug("CUSTOMIZED WIDGET %s", name);
return nwam_tree_view_new();
}

return NULL;
}
static UniqueResponse
nwamui_unique_message_handler( UniqueApp *app,
gint command,
UniqueMessageData *message_data,
guint time_,
gpointer user_data)
static void
activate (GApplication *app, gpointer user_data)
{
NwamPrefIFace *dialog_iface = NULL;

if ( user_data != NULL ) {
dialog_iface = NWAM_PREF_IFACE(user_data);
}

switch ( command ) {
case UNIQUE_ACTIVATE:
nwamui_debug("Got Unique ACTIVATE command (%d)", command );
if ( dialog_iface != NULL ) {
capplet_dialog_raise( dialog_iface );
return( UNIQUE_RESPONSE_OK );
}
break;
default:
nwamui_debug("Got unexpected Unique command %d, ignoring...", command );
break;
g_debug("Got activate signal");
if ( dialog_iface != NULL ) {
capplet_dialog_raise( dialog_iface );
}

return( UNIQUE_RESPONSE_PASSTHROUGH );
}

static void
add_unique_message_handler( UniqueApp *app, NwamPrefIFace *capplet_dialog )
add_unique_message_handler(GApplication *app, NwamPrefIFace *capplet_dialog )
{
if ( app != NULL ) {
g_signal_connect(app, "message-received", (GCallback)nwamui_unique_message_handler, (gpointer)capplet_dialog);
g_signal_connect(app, "activate", G_CALLBACK (activate), (gpointer)capplet_dialog);
}
}

Expand All @@ -141,8 +103,7 @@ add_unique_message_handler( UniqueApp *app, NwamPrefIFace *capplet_dialog )
int
main(int argc, char** argv)
{
UniqueApp *app = NULL;
GnomeProgram* program = NULL;
GApplication *app = NULL;
GOptionContext* option_context = NULL;
GError* err = NULL;
NwamPrefIFace *capplet_dialog = NULL;
Expand All @@ -154,18 +115,9 @@ main(int argc, char** argv)
textdomain (GETTEXT_PACKAGE);
g_option_context_add_main_entries(option_context, application_options, GETTEXT_PACKAGE);

/* Initialise Thread Support */
g_thread_init( NULL );

/* Setup log handler to trap debug messages */
nwamui_util_default_log_handler_init();

program = gnome_program_init (PACKAGE, VERSION, LIBGNOMEUI_MODULE,
argc, argv,
GNOME_PARAM_GOPTION_CONTEXT, option_context,
GNOME_PARAM_APP_DATADIR, NWAM_MANAGER_DATADIR,
GNOME_PARAM_NONE);

nwamui_util_set_debug_mode( debug );

if (!nwamui_prof_check_ui_auth(nwamui_prof_get_instance_noref(), UI_AUTH_ALL)) {
Expand All @@ -180,11 +132,19 @@ main(int argc, char** argv)
prof = nwamui_prof_get_instance_noref();
}

app = unique_app_new("com.sun.nwam-manager-properties", NULL);
app = g_application_new("com.sun.nwam-manager-properties", 0);
if ( !nwamui_util_is_debug_mode() ) {
if (unique_app_is_running(app)) {
GError *error = NULL;

g_application_register (G_APPLICATION (app), NULL, &error);
if (error != NULL) {
g_warning ("Unable to register GApplication: %s", error->message);
g_error_free (error);
error = NULL;
}
if (g_application_get_is_remote (G_APPLICATION (app))) {
/* Send request to other app to show itself */
unique_app_send_message(app, UNIQUE_ACTIVATE, NULL);
g_application_activate(G_APPLICATION (app));
/*
nwamui_util_show_message( NULL, GTK_MESSAGE_INFO, _("NWAM Manager Properties"),
_("\nAnother instance is running.\nThis instance will exit now."), TRUE );
Expand All @@ -200,11 +160,6 @@ main(int argc, char** argv)
gtk_icon_theme_append_search_path (gtk_icon_theme_get_default (),
NWAM_MANAGER_DATADIR G_DIR_SEPARATOR_S "icons");

#if 0
/*
* We probably don't need this any more if we are using
* gnome_program_init.
*/
if (gtk_init_with_args(&argc, &argv, _("NWAM Configuration Capplet"), application_options, NULL, &err) == FALSE ) {
if ( err != NULL && err->message != NULL ) {
g_printerr(err->message);
Expand All @@ -215,9 +170,6 @@ main(int argc, char** argv)
}
exit(1);
}
#endif

glade_set_custom_handler(customwidgethandler, NULL);

if( vpn_pref_dialog ) {
capplet_dialog = NWAM_PREF_IFACE(nwam_vpn_pref_dialog_new());
Expand Down

0 comments on commit e60844d

Please sign in to comment.