[med-svn] [SCM] aghermann branch, master, updated. 4f7a3b774136ffffbaf9b05d90bd568347bc5461

Andrei Zavada johnhommer at gmail.com
Fri Nov 16 00:50:00 UTC 2012


The following commit has been merged in the master branch:
commit 8cf0e863e8ad0a7359b625418f9a69eb93f91cf6
Author: Andrei Zavada <johnhommer at gmail.com>
Date:   Wed Oct 3 11:00:41 2012 +0300

    try to take care of unique issues
    
    this is our problem:
    set_unique_app_window( unique_app, wSessionChooser);

diff --git a/data/session-chooser.glade b/data/session-chooser.glade
index 507f792..9359e93 100644
--- a/data/session-chooser.glade
+++ b/data/session-chooser.glade
@@ -7,11 +7,9 @@
     <property name="can_focus">False</property>
     <property name="border_width">10</property>
     <property name="title" translatable="yes">Select Experiment</property>
-    <property name="modal">True</property>
     <property name="window_position">center</property>
-    <property name="destroy_with_parent">True</property>
     <property name="icon">aghermann.png</property>
-    <property name="type_hint">dialog</property>
+    <property name="type_hint">normal</property>
     <child internal-child="vbox">
       <object class="GtkBox" id="dialog-vbox13">
         <property name="visible">True</property>
@@ -25,11 +23,9 @@
             <child>
               <object class="GtkButton" id="bSessionChooserQuit">
                 <property name="label">gtk-quit</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
                 <property name="use_stock">True</property>
               </object>
@@ -44,11 +40,9 @@
             <child>
               <object class="GtkButton" id="bSessionChooserRemove">
                 <property name="label">gtk-remove</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="relief">half</property>
                 <property name="use_underline">True</property>
                 <property name="use_stock">True</property>
@@ -63,11 +57,9 @@
             <child>
               <object class="GtkButton" id="bSessionChooserCreateNew">
                 <property name="label">gtk-new</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="relief">half</property>
                 <property name="use_underline">True</property>
                 <property name="use_stock">True</property>
@@ -82,13 +74,11 @@
             <child>
               <object class="GtkButton" id="bSessionChooserOpen">
                 <property name="label">gtk-open</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_underline">True</property>
                 <property name="use_stock">True</property>
               </object>
@@ -101,11 +91,9 @@
             <child>
               <object class="GtkButton" id="bSessionChooserClose">
                 <property name="label">gtk-close</property>
-                <property name="use_action_appearance">False</property>
                 <property name="can_focus">True</property>
                 <property name="receives_default">True</property>
                 <property name="no_show_all">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
diff --git a/src/main.cc b/src/main.cc
index a855839..6ded1ce 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -16,7 +16,6 @@
 #include <gtk/gtk.h>
 #include <unique/unique.h>
 
-
 #include "common/globals.hh"
 #include "ui/globals.hh"
 #include "ui/ui.hh"
@@ -24,8 +23,6 @@
 
 
 
-static GtkWindow *main_window = NULL;
-
 static UniqueResponse
 message_received_cb( UniqueApp         *,
                      UniqueCommand      command,
@@ -33,7 +30,7 @@ message_received_cb( UniqueApp         *,
                      guint              time_,
                      gpointer           )
 {
-	if ( main_window == NULL )
+	if ( aghui::__main_window__ == NULL )
 		return UNIQUE_RESPONSE_OK;
 
 	UniqueResponse res;
@@ -41,8 +38,8 @@ message_received_cb( UniqueApp         *,
 	switch ( command ) {
 	case UNIQUE_ACTIVATE:
 		/* move the main window to the screen that sent us the command */
-		gtk_window_set_screen( main_window, unique_message_data_get_screen( message));
-		gtk_window_present_with_time( main_window, time_);
+		gtk_window_set_screen( aghui::__main_window__, unique_message_data_get_screen( message));
+		gtk_window_present_with_time( aghui::__main_window__, time_);
 		res = UNIQUE_RESPONSE_OK;
 	    break;
 	default:
@@ -73,27 +70,28 @@ main( int argc, char **argv)
 	gtk_init( &argc, &argv);
 
 	// don't let user get us started twice
-	UniqueApp *app =
+	aghui::__unique_app__ =
 		unique_app_new_with_commands( "com.johnhommer.Aghermann", NULL,
 					      "fafa", 1,
 					      NULL);
+	if ( unique_app_is_running( aghui::__unique_app__) ) {
+		printf( "There is unique app\n");
+		unique_app_send_message( aghui::__unique_app__, UNIQUE_ACTIVATE, NULL);
+	} else {
+		printf( "Unique app not there\n");
+		g_signal_connect( aghui::__unique_app__, "message-received",
+				  (GCallback)message_received_cb,
+				  NULL);
 
-	if ( unique_app_is_running( app) )
-		unique_app_send_message( app, UNIQUE_ACTIVATE, NULL);
-	else {
 		agh::global::init_rng();
 		if ( aghui::prepare_for_expdesign() ) {
 			aghui::pop_ok_message( NULL, "UI failed to initialize. Your install is broken.\n");
 			return 2;
 		}
 
-		aghui::SSessionChooser chooser (argv[optind], &main_window);
+		aghui::SSessionChooser chooser (argv[optind]);
 		// implicit read sessionrc, run
 
-		unique_app_watch_window( app, (GtkWindow*)main_window);
-		g_signal_connect( app, "message-received",
-				  (GCallback)message_received_cb,
-				  NULL);
 		gtk_main();
 	}
 	// g_object_unref (app); // abandon ship anyway
diff --git a/src/ui/globals.hh b/src/ui/globals.hh
index cbceb1d..44197c6 100644
--- a/src/ui/globals.hh
+++ b/src/ui/globals.hh
@@ -1,6 +1,6 @@
 // ;-*-C++-*-
 /*
- *       File name:  ui/globals.h
+ *       File name:  ui/globals.hh
  *         Project:  Aghermann
  *          Author:  Andrei Zavada <johnhommer at gmail.com>
  * Initial version:  2012-09-22
@@ -15,6 +15,7 @@
 #define _AGHUI_GLOBALS_H
 
 #include <gtk/gtk.h>
+#include <unique/unique.h>
 
 #if HAVE_CONFIG_H && !defined(VERSION)
 #  include "config.h"
@@ -25,6 +26,11 @@ using namespace std;
 
 namespace aghui {
 
+extern UniqueApp
+	*__unique_app__;
+
+extern GtkWindow
+	*__main_window__;
 
 // convenience assign-once vars
 extern GdkDevice
@@ -39,6 +45,8 @@ extern GString
 
 int prepare_for_expdesign();
 
+void set_unique_app_window( GtkWindow*);
+
 } // namespace aghui
 
 #endif
diff --git a/src/ui/libcommon.cc b/src/ui/libcommon.cc
index 158e38c..fca0786 100644
--- a/src/ui/libcommon.cc
+++ b/src/ui/libcommon.cc
@@ -25,8 +25,27 @@ GString	*aghui::__ss__;
 GdkDevice
 	*aghui::__client_pointer__;
 
+UniqueApp
+	*aghui::__unique_app__;
+
+GtkWindow
+	*aghui::__main_window__;
+
 #define AGH_UI_GRESOURCE_FILE "aghermann.gresource"
 
+// unique
+
+void
+aghui::
+set_unique_app_window( GtkWindow* w)
+{
+	unique_app_watch_window(
+		aghui::__unique_app__,
+		aghui::__main_window__ = w);
+}
+
+// own init
+
 int
 aghui::
 prepare_for_expdesign()
diff --git a/src/ui/session-chooser.cc b/src/ui/session-chooser.cc
index f18ecc0..7cedc1e 100644
--- a/src/ui/session-chooser.cc
+++ b/src/ui/session-chooser.cc
@@ -45,9 +45,8 @@ get_session_stats()
 
 
 aghui::SSessionChooser::
-SSessionChooser (const char* explicit_session, GtkWindow** single_main_window_)
+SSessionChooser (const char* explicit_session)
       : filename (string (getenv("HOME")) + "/.config/aghermann/sessionrc"),
-	single_main_window (single_main_window_),
 	ed (nullptr)
 {
 	if ( construct_widgets() )
@@ -62,17 +61,17 @@ SSessionChooser (const char* explicit_session, GtkWindow** single_main_window_)
 			char* canonicalized = canonicalize_file_name( explicit_session);
 			ed = new aghui::SExpDesignUI(
 				this, canonicalized);
-			*single_main_window = ed->wMainWindow;
+			set_unique_app_window( ed->wMainWindow);
 			free( canonicalized);
 
 		} else if ( last_dir_no == -1 ) {
 			gtk_widget_show( (GtkWidget*)wSessionChooser);
-			*single_main_window = (GtkWindow*)wSessionChooser;
+			//set_unique_app_window( (GtkWindow*)wSessionChooser);
 
 		} else {
 			ed = new aghui::SExpDesignUI(
 				this, get_dir());
-			*single_main_window = ed->wMainWindow;
+			set_unique_app_window( ed->wMainWindow);
 		}
 	} catch (runtime_error ex) {
 		aghui::pop_ok_message( nullptr, "%s", ex.what());
@@ -91,10 +90,10 @@ SSessionChooser (const char* explicit_session, GtkWindow** single_main_window_)
 aghui::SSessionChooser::
 ~SSessionChooser()
 {
+	destruct_widgets();
 	if ( ed )
 		delete ed;
 	write_sessionrc();
-	destruct_widgets();
 }
 
 
@@ -113,13 +112,13 @@ open_selected_session()
 	try {
 		ed = new aghui::SExpDesignUI(
 			this, selected);
-		*single_main_window = ed->wMainWindow;
+		set_unique_app_window( ed->wMainWindow);
 
 		return 0;
 
 	} catch (invalid_argument ex) {
 		ed = nullptr;
-		*single_main_window = (GtkWindow*)wSessionChooser;
+		//set_unique_app_window( (GtkWindow*)wSessionChooser);
 
 		pop_ok_message( nullptr,
 				"%s\n\n"
@@ -136,7 +135,7 @@ close_current_session()
 	assert (ed);
 	delete ed;
 	ed = nullptr;
-	*single_main_window = (GtkWindow*)wSessionChooser;
+	//set_unique_app_window( unique_app, (GtkWindow*)wSessionChooser);
 }
 
 
diff --git a/src/ui/session-chooser.hh b/src/ui/session-chooser.hh
index 727b72c..2f9983a 100644
--- a/src/ui/session-chooser.hh
+++ b/src/ui/session-chooser.hh
@@ -50,7 +50,7 @@ struct SSession : public string {
 struct SSessionChooser {
 	DELETE_DEFAULT_METHODS (SSessionChooser);
 
-	SSessionChooser (const char*, GtkWindow** single_main_window_);
+	SSessionChooser (const char*);
        ~SSessionChooser ();
 
 	string	title;
@@ -58,8 +58,6 @@ struct SSessionChooser {
 	int	last_dir_no;
 	list<SSession>
 		sessions;
-	GtkWindow
-		**single_main_window; // for use by libunique
 
 	aghui::SExpDesignUI* ed;
 

-- 
Sleep experiment manager



More information about the debian-med-commit mailing list