int wxDialog::ShowModal() { WX_HOOK_MODAL_DIALOG(); wxASSERT_MSG( !IsModal(), "ShowModal() can't be called twice" ); // release the mouse if it's currently captured as the window having it // will be disabled when this dialog is shown -- but will still keep the // capture making it impossible to do anything in the modal dialog itself wxWindow * const win = wxWindow::GetCapture(); if ( win ) win->GTKReleaseMouseAndNotify(); wxWindow * const parent = GetParentForModalDialog(); if ( parent ) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget) ); } #if GTK_CHECK_VERSION(2,10,0) unsigned sigId = 0; gulong hookId = 0; #ifndef __WXGTK3__ // Ubuntu overlay scrollbar uses at least GTK 2.24 if (gtk_check_version(2,24,0) == NULL) #endif { sigId = g_signal_lookup("realize", GTK_TYPE_WIDGET); hookId = g_signal_add_emission_hook(sigId, 0, realize_hook, NULL, NULL); } #endif Show( true ); m_modalShowing = true; wxOpenModalDialogLocker modalLock; // NOTE: gtk_window_set_modal internally calls gtk_grab_add() ! gtk_window_set_modal(GTK_WINDOW(m_widget), TRUE); // Run modal dialog event loop. { wxGUIEventLoopTiedPtr modal(&m_modalLoop, new wxGUIEventLoop()); m_modalLoop->Run(); } #if GTK_CHECK_VERSION(2,10,0) if (sigId) g_signal_remove_emission_hook(sigId, hookId); #endif gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE); return GetReturnCode(); }
static void parent_set_emission_hook_remove (GtkWidget *widget, gpointer data) { emission_hook_count--; if (emission_hook_count > 0) return; g_signal_remove_emission_hook (g_signal_lookup ("parent-set", GTK_TYPE_WIDGET), emission_hook_id); emission_hook_id = 0; }
static void mai_util_remove_global_event_listener(guint remove_listener) { if (remove_listener > 0) { MaiUtilListenerInfo *listener_info; gint tmp_idx = remove_listener; listener_info = (MaiUtilListenerInfo *) g_hash_table_lookup(listener_list, &tmp_idx); if (listener_info != NULL) { if (gail_remove_global_event_listener && listener_info->gail_listenerid) { gail_remove_global_event_listener(listener_info->gail_listenerid); } /* Hook id of 0 and signal id of 0 are invalid */ if (listener_info->hook_id != 0 && listener_info->signal_id != 0) { /* Remove the emission hook */ g_signal_remove_emission_hook(listener_info->signal_id, listener_info->hook_id); /* Remove the element from the hash */ g_hash_table_remove(listener_list, &tmp_idx); } else { g_warning("Invalid listener hook_id %ld or signal_id %d\n", listener_info->hook_id, listener_info->signal_id); } } else { // atk-bridge is initialized with gail (e.g. yelp) // try gail_remove_global_event_listener if (gail_remove_global_event_listener) { return gail_remove_global_event_listener(remove_listener); } g_warning("No listener with the specified listener id %d", remove_listener); } } else { g_warning("Invalid listener_id %d", remove_listener); } }
void _remove_global_event_listener (guint remove_listener) { if (remove_listener > 0) { AtkUtilListenerInfo *listener_info; gint tmp_idx = remove_listener; listener_info = (AtkUtilListenerInfo *) g_hash_table_lookup(listener_list, &tmp_idx); if (listener_info != NULL) { /* Hook id of 0 and signal id of 0 are invalid */ if (listener_info->hook_id != 0 && listener_info->signal_id != 0) { /* Remove the emission hook */ g_signal_remove_emission_hook(listener_info->signal_id, listener_info->hook_id); /* Remove the element from the hash */ g_hash_table_remove(listener_list, &tmp_idx); } else { g_warning("Invalid listener hook_id %ld or signal_id %d\n", listener_info->hook_id, listener_info->signal_id); } } else { g_warning("No listener with the specified listener id %d", remove_listener); } } else { g_warning("Invalid listener_id %d", remove_listener); } }
/* The locationbar entry was destroyed */ static void _interface_tweaks_on_destroyed(InterfaceTweaks *self, gpointer inUserData) { g_return_if_fail(IS_INTERFACE_TWEAKS(self)); g_return_if_fail(GTK_IS_ENTRY(inUserData)); GtkEntry *entry=GTK_ENTRY(inUserData); guint keyPressSignalID; gulong hookID; /* Remove emission handler from entry if it exists and stops further callbacks * to our emission hook for "key-press-event"s */ hookID=GPOINTER_TO_SIZE(g_object_get_data(G_OBJECT(entry), "interface-tweaks-hook-id")); if(hookID>0) { keyPressSignalID=g_signal_lookup("key-press-event", GTK_TYPE_ENTRY); g_signal_remove_emission_hook(keyPressSignalID, hookID); hookID=0L; g_object_set_data(G_OBJECT(entry), "interface-tweaks-hook-id", GSIZE_TO_POINTER(hookID)); } }
//____________________________________________________________________ void Hook::disconnect( void ) { #if DISABLE_SIGNAL_HOOKS return; #endif // disconnect signal if( _signalId > 0 && _hookId > 0 ) { #if OXYGEN_DEBUG --counter; std::cerr << "Oxygen::Hook::disconnect - hook: " << _hookId << " counter: " << counter << std::endl; #endif g_signal_remove_emission_hook( _signalId, _hookId ); } _signalId = 0; _hookId = 0; }
/* Application property has changed */ static void _interface_tweaks_on_application_changed(InterfaceTweaks *self, MidoriApp *inApplication) { g_return_if_fail(IS_INTERFACE_TWEAKS(self)); g_return_if_fail(inApplication==NULL || MIDORI_IS_APP(inApplication)); InterfaceTweaksPrivate *priv=INTERFACE_TWEAKS(self)->priv; GtkNotebook *notebook; MidoriBrowser *browser; GList *browsers, *browsersIter; GList *tabs, *tabsIter; WebKitWebView *webkitView; InterfaceTweaksLocationbarLookup locationbar; /* Release resources on current application object */ if(priv->application) { g_signal_handlers_disconnect_by_data(priv->application, self); browsers=midori_app_get_browsers(priv->application); for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter)) { browser=MIDORI_BROWSER(browsersIter->data); g_signal_handlers_disconnect_by_data(browser, self); tabs=midori_browser_get_tabs(MIDORI_BROWSER(browsersIter->data)); for(tabsIter=tabs; tabsIter; tabsIter=g_list_next(tabsIter)) { g_signal_handlers_disconnect_by_data(tabsIter->data, self); webkitView=WEBKIT_WEB_VIEW(midori_view_get_web_view(MIDORI_VIEW(tabsIter->data))); g_signal_handlers_disconnect_by_data(webkitView, self); } g_list_free(tabs); notebook=NULL; g_object_get(browser, "notebook", ¬ebook, NULL); if(notebook) { g_signal_handlers_disconnect_by_data(notebook, self); g_object_unref(notebook); } _interface_tweaks_find_browser_locationbar(browser, &locationbar); if(locationbar.widget) { GtkEntry *entry=GTK_ENTRY(locationbar.widget); GtkEntryCompletion *completion; gulong hookID; guint keyPressSignalID; g_signal_handlers_disconnect_by_data(entry, self); completion=gtk_entry_get_completion(GTK_ENTRY(entry)); if(completion) { g_signal_handlers_disconnect_by_data(completion, self); gtk_entry_set_completion(entry, NULL); } hookID=GPOINTER_TO_SIZE(g_object_get_data(G_OBJECT(entry), "interface-tweaks-hook-id")); if(hookID!=0) { keyPressSignalID=g_signal_lookup("key-press-event", GTK_TYPE_ENTRY); g_signal_remove_emission_hook(keyPressSignalID, hookID); hookID=0L; g_object_set_data(G_OBJECT(entry), "interface-tweaks-hook-id", GSIZE_TO_POINTER(hookID)); } } } g_list_free(browsers); g_object_unref(priv->application); priv->application=NULL; } /* Set new application object */ if(!inApplication) return; priv->application=g_object_ref(inApplication); /* Set up all current open browser windows */ browsers=midori_app_get_browsers(priv->application); for(browsersIter=browsers; browsersIter; browsersIter=g_list_next(browsersIter)) { _interface_tweaks_on_add_browser(self, MIDORI_BROWSER(browsersIter->data), priv->application); } g_list_free(browsers); /* Listen to new browser windows opened */ g_signal_connect_swapped(priv->application, "add-browser", G_CALLBACK(_interface_tweaks_on_add_browser), self); /* Notify about property change */ g_object_notify_by_pspec(G_OBJECT(self), InterfaceTweaksProperties[PROP_APPLICATION]); }
int main (int argc, char **argv) { gint i; GTest *test1, *test2; GArray *test_threads; const gint n_threads = 1; #ifdef SYMBIAN g_log_set_handler (NULL, G_LOG_FLAG_FATAL| G_LOG_FLAG_RECURSION | G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING | G_LOG_LEVEL_MESSAGE | G_LOG_LEVEL_INFO | G_LOG_LEVEL_DEBUG, &mrtLogHandler, NULL); g_set_print_handler(mrtPrintHandler); #endif /*SYMBIAN*/ g_thread_init (NULL); #ifndef SYMBIAN g_print ("START: %s\n", argv[0]); #else #ifdef VERBOSE g_print ("START: %s\n", argv[0]); #endif #endif /*SYMBIAN*/ g_log_set_always_fatal (G_LOG_LEVEL_WARNING | G_LOG_LEVEL_CRITICAL | g_log_set_always_fatal (G_LOG_FATAL_MASK)); g_type_init (); test1 = g_object_new (G_TYPE_TEST, NULL); test2 = g_object_new (G_TYPE_TEST, NULL); g_signal_connect (test1, "notify::test-prop", G_CALLBACK (notify), NULL); g_signal_connect (test1, "test-signal1", G_CALLBACK (notify), NULL); g_signal_connect (test1, "test-signal2", G_CALLBACK (notify), NULL); #ifndef SYMBIAN test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *)); stopping = FALSE; for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); g_array_append_val (test_threads, thread); thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); g_array_append_val (test_threads, thread); } g_usleep (500000); stopping = TRUE; g_print ("\nstopping\n"); /* join all threads */ for (i = 0; i < 2 * n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i); g_thread_join (thread); } g_print ("stopped:%d\n",TESTNUM); #else #ifdef MULTITHREAD test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *)); stopping = FALSE; TESTNUM=1; notifynum=0; handlernum=0; for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); g_array_append_val (test_threads, thread); thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); g_array_append_val (test_threads, thread); } g_usleep (500000); stopping = TRUE; #ifdef VERBOSE g_print ("\nstopping\n"); #endif /* join all threads */ for (i = 0; i < 2 * n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i); g_thread_join (thread); } g_assert(notifynum != 0); g_assert(handlernum == 0); g_array_free (test_threads, TRUE); #ifdef VERBOSE g_print ("Signals.c: completed for TESTNUM = %d\n",TESTNUM); #endif test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *)); stopping = FALSE; TESTNUM=2; notifynum=0; handlernum=0; for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); g_array_append_val (test_threads, thread); thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); g_array_append_val (test_threads, thread); } g_usleep (500000); stopping = TRUE; #ifdef VERBOSE g_print ("\nstopping\n"); #endif /* join all threads */ for (i = 0; i < 2 * n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i); g_thread_join (thread); } g_assert(notifynum != 0); g_assert(handlernum != 0); g_array_free (test_threads, TRUE); #ifdef VERBOSE g_print ("Signals.c: completed for TESTNUM = %d\n",TESTNUM); #endif test_threads = g_array_new (FALSE, FALSE, sizeof (GThread *)); stopping = FALSE; TESTNUM=3; notifynum=0; handlernum=0; for (i = 0; i < n_threads; i++) { GThread *thread; thread = g_thread_create ((GThreadFunc) run_thread, test1, TRUE, NULL); g_array_append_val (test_threads, thread); thread = g_thread_create ((GThreadFunc) run_thread, test2, TRUE, NULL); g_array_append_val (test_threads, thread); } g_usleep (5000000); stopping = TRUE; #ifdef VERBOSE g_print ("\nstopping\n"); #endif /* join all threads */ for (i = 0; i < 2 * n_threads; i++) { GThread *thread; thread = g_array_index (test_threads, GThread *, i); g_thread_join (thread); } g_assert(notifynum != 0); g_assert(handlernum == 0); g_array_free (test_threads, TRUE); #ifdef VERBOSE g_print ("Signals.c: completed for TESTNUM = %d\n",TESTNUM); #endif #else /* ! MULTITHREAD*/ TESTNUM=1; #ifdef VERBOSE g_print ("\nStarting with TESTNUM=%d\n",TESTNUM); #endif notifynum=0; handlernum=0; run_thread(test1); g_assert(notifynum == LOOP +1); g_assert(handlernum ==0); notifynum=0; handlernum=0; run_thread(test2); g_assert(notifynum == 0); g_assert(handlernum == 0); TESTNUM=2; #ifdef VERBOSE g_print ("\nStarting with TESTNUM=%d\n",TESTNUM); #endif notifynum=0; handlernum=0; run_thread(test1); g_assert(notifynum == LOOP+1); g_assert(handlernum == LOOP+1); notifynum=0; handlernum=0; run_thread(test2); g_assert(notifynum == 0); g_assert(handlernum == LOOP+1); TESTNUM=3; #ifdef VERBOSE g_print ("\nStarting with TESTNUM=%d\n",TESTNUM); #endif notifynum=0; handlernum=0; run_thread(test1); g_assert(notifynum == LOOP +1); g_assert(handlernum ==0); notifynum=0; handlernum=0; run_thread(test2); g_assert(notifynum == 0); g_assert(handlernum == 0); g_assert(g_signal_has_handler_pending(G_OBJECT(test1),g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,TRUE)==TRUE); g_assert(g_signal_has_handler_pending(G_OBJECT(test2),g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,TRUE)==FALSE); g_assert(g_signal_handler_is_connected(G_OBJECT(test1),g_signal_lookup("test-signal1",G_TYPE_TEST))==TRUE); g_assert(g_signal_handler_is_connected(G_OBJECT(test2),g_signal_lookup("test-signal2",G_TYPE_TEST))==FALSE); handlernum=g_signal_lookup("test-signal1",G_TYPE_TEST); #ifdef VERBOSE g_print("Signal id: %d\n",handlernum); #endif g_signal_connect (test2, "test-signal1", G_CALLBACK (notify), NULL); hookid=g_signal_add_emission_hook(handlernum,NULL,(GSignalEmissionHook) hook_function,NULL,NULL); #ifdef VERBOSE g_print("Hookid: %d\n",hookid); #endif /********************/ #ifdef TEST_STOP_EMISSION /* notifynum=0; handlernum=0; g_print("The following call stops signal emission\n"); g_signal_stop_emission(G_OBJECT(test1),g_signal_lookup("test-signal1",G_TYPE_TEST),0); g_print("The following call should abort and it is normal\n"); run_thread(test1); printf("Notifynum: %d and Handlernum: %d\n",notifynum,handlernum); */ notifynum=0; handlernum=0; g_signal_stop_emission_by_name(G_OBJECT(test1),"test-signal1"); //run_thread(test1); g_print("Notifynum: %d and Handlernum: %d\n",notifynum,handlernum); #endif /*TEST_STOP_EMISSION*/ /*******************/ handlernum=0; g_signal_emit(G_OBJECT (test1), g_test_signals[TEST_SIGNAL1], 0, 0); g_signal_emit(G_OBJECT (test2), g_test_signals[TEST_SIGNAL1], 0, 0); g_assert(handlernum==2); g_signal_remove_emission_hook(g_signal_lookup("test-signal1",G_TYPE_TEST),hookid); #ifdef VERBOSE g_print("Emitting signal again after removing emission hook\n"); #endif handlernum=0; g_signal_emit (G_OBJECT (test1), g_test_signals[TEST_SIGNAL1], 0, 0); g_signal_emit (G_OBJECT (test2), g_test_signals[TEST_SIGNAL1], 0, 0); g_assert(handlernum==0); g_assert (strcmp ("test-signal1", g_signal_name (g_signal_lookup("test-signal1",G_TYPE_TEST))) == 0); g_assert (strcmp ("test-signal2", g_signal_name (g_signal_lookup("test-signal2",G_TYPE_TEST))) == 0); memset(&gv,0,sizeof(gv)); g_value_init(&gv,G_TYPE_OBJECT); g_value_set_object(&gv,test1); gi=0; g_signal_list_ids(G_OBJECT_TYPE(test1),&gi); g_assert(g_signal_lookup("test-signal1",G_TYPE_TEST)==gi); notifynum=0; g_signal_emitv (&gv, g_test_signals[TEST_SIGNAL1], 0, &gv); g_assert(notifynum==1); g_signal_query(g_signal_lookup("test-signal1",G_TYPE_TEST),&gq); g_assert(strcmp("test-signal1",gq.signal_name)==0); g_assert(g_signal_lookup("test-signal1",G_TYPE_TEST)==gq.signal_id); g_assert(g_signal_handler_find(G_OBJECT(test1), G_SIGNAL_RUN_LAST,g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,NULL,NULL,NULL)==2); notifynum=g_signal_handlers_block_matched(G_OBJECT(test1),G_SIGNAL_MATCH_FUNC,g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,NULL,(gpointer)G_CALLBACK(notify),NULL); handlernum=g_signal_handlers_unblock_matched(G_OBJECT(test1),G_SIGNAL_MATCH_FUNC,g_signal_lookup("test-signal2",G_TYPE_TEST),NULL,NULL,(gpointer)G_CALLBACK(notify),NULL); g_assert(notifynum==handlernum); #endif /*MULTITHREAD*/ #ifdef VERBOSE g_printf ("\nsignals-multithread.c: Completed all tests\n"); #endif #endif /*SYMBIAN*/ #if SYMBIAN testResultXml("signals-singlethread"); #endif /* EMULATOR */ return 0; }
int wxDialog::ShowModal() { WX_HOOK_MODAL_DIALOG(); wxASSERT_MSG( !IsModal(), "ShowModal() can't be called twice" ); // release the mouse if it's currently captured as the window having it // will be disabled when this dialog is shown -- but will still keep the // capture making it impossible to do anything in the modal dialog itself wxWindow * const win = wxWindow::GetCapture(); if ( win ) win->GTKReleaseMouseAndNotify(); wxWindow * const parent = GetParentForModalDialog(); if ( parent ) { gtk_window_set_transient_for( GTK_WINDOW(m_widget), GTK_WINDOW(parent->m_widget) ); } #if GTK_CHECK_VERSION(2,10,0) unsigned sigId = 0; gulong hookId = 0; #ifndef __WXGTK3__ // Ubuntu overlay scrollbar uses at least GTK 2.24 if (gtk_check_version(2,24,0) == NULL) #endif { sigId = g_signal_lookup("realize", GTK_TYPE_WIDGET); hookId = g_signal_add_emission_hook(sigId, 0, realize_hook, NULL, NULL); } #endif // NOTE: this will cause a gtk_grab_add() during Show() gtk_window_set_modal(GTK_WINDOW(m_widget), true); Show( true ); m_modalShowing = true; wxOpenModalDialogLocker modalLock; // Prevent the widget from being destroyed if the user closes the window. // Needed for derived classes which bypass wxTLW::Create(), and therefore // the wxTLW "delete-event" handler is not connected gulong handler_id = g_signal_connect( m_widget, "delete-event", G_CALLBACK(gtk_true), this); // Run modal dialog event loop. { wxGUIEventLoopTiedPtr modal(&m_modalLoop, new wxGUIEventLoop()); m_modalLoop->Run(); } g_signal_handler_disconnect(m_widget, handler_id); #if GTK_CHECK_VERSION(2,10,0) if (sigId) g_signal_remove_emission_hook(sigId, hookId); #endif gtk_window_set_modal(GTK_WINDOW(m_widget), FALSE); return GetReturnCode(); }