예제 #1
0
static gint idle_toplevel_callback_func(gpointer data)
{
  if (gtk_main_level() > 1) {
    /*
     * We don't run callbacks if we're in the middle of a
     * subsidiary gtk_main. So unschedule this idle function; it
     * will be rescheduled by post_main() when we come back up a
     * level, which is the earliest we might actually do
     * something.
     */
    if (idle_fn_scheduled) { /* double-check, just in case */
      g_source_remove(toplevel_callback_idle_id);
      idle_fn_scheduled = FALSE;
    }
  } else {
    run_toplevel_callbacks();
  }

  /*
   * If we've emptied our toplevel callback queue, unschedule
   * ourself. Otherwise, leave ourselves pending so we'll be called
   * again to deal with more callbacks after another round of the
   * event loop.
   */
  if (!toplevel_callback_pending() && idle_fn_scheduled) {
    g_source_remove(toplevel_callback_idle_id);
    idle_fn_scheduled = FALSE;
  }

  return TRUE;
}
예제 #2
0
파일: xpad-app.c 프로젝트: abhinandh/xpad
static gboolean
xpad_app_first_idle_check (XpadPadGroup *group)
{
	/* We do this check at the first idle rather than immediately during
	   start because we want to give the tray time to become embedded. */
	if (!xpad_tray_is_open () &&
	    xpad_pad_group_num_visible_pads (group) == 0)
	{
		if (pads_loaded_on_start > 0)
			/* So we loaded xpad, there's no tray, and there's only hidden
			   pads...  Probably previously had tray open but we failed
			   this time.  Show all pads as a last resort.  This shouldn't
			   happen in normal operation. */
			xpad_pad_group_show_all (group);
		else
		{
			if (gtk_main_level () > 0)
				gtk_main_quit ();
			else
				exit (0);
		}
	}
	
	return FALSE;
}
예제 #3
0
파일: evtloop.cpp 프로젝트: 3v1n0/wxWidgets
int wxGUIEventLoop::DoRun()
{
    guint loopLevel = gtk_main_level();

    // This is placed inside of a loop to take into account nested
    // event loops.  For example, inside this event loop, we may receive
    // Exit() for a different event loop (which we are currently inside of)
    // That Exit() will cause this gtk_main() to exit so we need to re-enter it.
    while ( !m_shouldExit )
    {
        gtk_main();
    }

    // Force the enclosing event loop to also exit to see if it is done in case
    // that event loop had Exit() called inside of the just ended loop. If it
    // is not time yet for that event loop to exit, it will be executed again
    // due to the while() loop on m_shouldExit().
    //
    // This is unnecessary if we are the top level loop, i.e. loop of level 0.
    if ( loopLevel )
    {
        gtk_main_quit();
    }

    OnExit();

#if wxUSE_EXCEPTIONS
    // Rethrow any exceptions which could have been produced by the handlers
    // ran by the event loop.
    if ( wxTheApp )
        wxTheApp->RethrowStoredException();
#endif // wxUSE_EXCEPTIONS

    return m_exitcode;
}
예제 #4
0
파일: iconify.c 프로젝트: Abazigal/iconify
/* Called when a child is dead */
void cb_child_is_dead(int pid, int status, gpointer data)
{
    ((app_elems *) data)->childisdead = TRUE;
    ((app_elems *) data)->childdeath = status;
    if (gtk_main_level() > 0)
	gtk_main_quit();
}
예제 #5
0
파일: main.c 프로젝트: Tetralet/LilyTerm
void quit_gtk()
{
#ifdef DETAIL
	g_debug("! Launch quit_gtk()");
#endif
	if (gtk_main_level()) gtk_main_quit();
}
예제 #6
0
static gint window_deleted(GtkWidget *widget, GdkEventAny *event, gpointer data)
{
	ack = FALSE;
	if (gtk_main_level() > 1)
		gtk_main_quit();

	return TRUE;
}
예제 #7
0
int
test_quit (int exit_code)
{
	if (gtk_main_level () > 0) {
		gtk_main_quit ();
	}

	return exit_code;
}
예제 #8
0
void pApplication::quit() {
  //if gtk_main() was invoked, call gtk_main_quit()
  if(gtk_main_level()) gtk_main_quit();

  #if defined(DISPLAY_XORG)
  //todo: Keyboard::poll() is being called after Application::quit();
  //so if display is closed; this causes a segfault
  //XCloseDisplay(display);
  //display = nullptr;
  #endif
}
예제 #9
0
static void encoding_dialog(const gchar *path)
{
	static gint warned_user = FALSE;
	GenericDialog *gd;
	GString *string;
	const gchar *lc;
	const gchar *bf;

	/* check that gtk is initialized (loop is level > 0) */
	if (gtk_main_level() == 0)
		{
		/* gtk not initialized */
		gtk_init_add(encoding_dialog_delay, g_strdup(path));
		return;
		}

	if (warned_user) return;
	warned_user = TRUE;

	lc = getenv("LANG");
	bf = getenv("G_BROKEN_FILENAMES");
	warned_user = TRUE;

	string = g_string_new("");
	g_string_append(string, "One or more filenames are not encoded with the preferred locale character set.\n");
	g_string_append_printf(string, "Operations on, and display of these files with %s may not succeed.\n\n", PACKAGE);
	g_string_append(string, "If your filenames are not encoded in utf-8, try setting\n");
	g_string_append(string, "the environment variable G_BROKEN_FILENAMES=1\n");
	g_string_append_printf(string, "It appears G_BROKEN_FILENAMES is %s%s\n\n",
				(bf) ? "set to " : "not set.", (bf) ? bf : "");
	g_string_append_printf(string, "The locale appears to be set to \"%s\"\n(set by the LANG environment variable)\n", (lc) ? lc : "undefined");
	if (lc && (strstr(lc, "UTF-8") || strstr(lc, "utf-8")))
		{
		gchar *name;
		name = g_convert(path, -1, "UTF-8", "ISO-8859-1", NULL, NULL, NULL);
		string = g_string_append(string, "\nPreferred encoding appears to be UTF-8, however the file:\n");
		g_string_append_printf(string, "\"%s\"\n%s encoded in valid UTF-8.\n",
				(name) ? name : "[name not displayable]",
				(g_utf8_validate(path, -1, NULL)) ? "is": "is NOT");
		g_free(name);
		}

	gd = generic_dialog_new("Filename encoding locale mismatch",
				PACKAGE, "locale warning", NULL, TRUE, NULL, NULL);
	generic_dialog_add_button(gd, GTK_STOCK_CLOSE, NULL, NULL, TRUE);

	generic_dialog_add_message(gd, GTK_STOCK_DIALOG_WARNING,
				   "Filename encoding locale mismatch", string->str);

	gtk_widget_show(gd->dialog);

	g_string_free(string, TRUE);
}
예제 #10
0
static void import_ok_cb(GtkWidget *widget, gpointer data)
{
	const gchar *utf8mbox, *destdir;
	FolderItem *dest;
	gchar *mbox;

	utf8mbox = gtk_entry_get_text(GTK_ENTRY(file_entry));
	destdir = gtk_entry_get_text(GTK_ENTRY(dest_entry));

	if (utf8mbox && !*utf8mbox) {
		alertpanel_error(_("Source mbox filename can't be left empty."));
		gtk_widget_grab_focus(file_entry);
		return;
	}
	if (destdir && !*destdir) {
		if (alertpanel(_("Import mbox file"), _("Destination folder is not set.\nImport mbox file to the Inbox folder?"),
						GTK_STOCK_OK, GTK_STOCK_CANCEL, NULL, ALERTFOCUS_FIRST)
			== G_ALERTALTERNATE) {
			gtk_widget_grab_focus(dest_entry);
			return;
		}
	}

	mbox = g_filename_from_utf8(utf8mbox, -1, NULL, NULL, NULL);
	if (!mbox) {
		g_warning("import_ok_cb(): failed to convert character set.");
		mbox = g_strdup(utf8mbox);
	}

	if (!destdir || !*destdir) {
		dest = folder_find_item_from_path(INBOX_DIR);
	} else {
		dest = folder_find_item_from_identifier
			(destdir);
	}

	if (!dest) {
		alertpanel_error(_("Can't find the destination folder."));
		gtk_widget_grab_focus(dest_entry);
		g_free(mbox);
		return;
	} else {
		import_ok = proc_mbox(dest, mbox, FALSE, NULL);
	}

	g_free(mbox);

	if (gtk_main_level() > 1)
		gtk_main_quit();
}
예제 #11
0
void
sighandler(int sig)
{
	switch (sig) {
	case SIGHUP:
		gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
		gaim_connections_disconnect_all();
		break;
	case SIGSEGV:
#ifndef DEBUG
		fprintf(stderr, "Gaim has segfaulted and attempted to dump a core file.\n"
			"This is a bug in the software and has happened through\n"
			"no fault of your own.\n\n"
			"It is possible that this bug is already fixed in CVS.\n"
			"If you can reproduce the crash, please notify the gaim\n"
			"maintainers by reporting a bug at\n"
			GAIM_WEBSITE "bug.php\n\n"
			"Please make sure to specify what you were doing at the time,\n"
			"and post the backtrace from the core file. If you do not know\n"
			"how to get the backtrace, please get instructions at\n"
			GAIM_WEBSITE "gdb.php. If you need further\n"
			"assistance, please IM either SeanEgn or LSchiere and\n"
			"they can help you.\n");
#else
		fprintf(stderr, "Hi, user.  We need to talk.\n"
			"I think something's gone wrong here.  It's probably my fault.\n"
			"No, really, it's not you... it's me... no no no, I think we get along well\n"
			"it's just that.... well, I want to see other people.  I... what?!?  NO!  I haven't\n"
			"been cheating on you!!  How many times do you want me to tell you?!  And for the\n"
			"last time, it's just a rash!\n");
		/*g_on_error_query (g_get_prgname());*/
#endif
		abort();
		break;
	case SIGCHLD:
		clean_pid();
		signal(SIGCHLD, sighandler);    /* restore signal catching on this one! */
		break;
	default:
		gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
		gaim_connections_disconnect_all();

		gaim_plugins_unload_all();

		if (gtk_main_level())
			gtk_main_quit();
		exit(0);
	}
}
예제 #12
0
파일: e-shell.c 프로젝트: UIKit0/evolution
static void
shell_ready_for_quit (EShell *shell,
                      EActivity *activity,
                      gboolean is_last_ref)
{
	GtkApplication *application;
	GList *list;

	if (!is_last_ref)
		return;

	application = GTK_APPLICATION (shell);

	/* Increment the reference count so we can safely emit
	 * a signal without triggering the toggle reference. */
	g_object_ref (activity);

	e_activity_set_state (activity, E_ACTIVITY_COMPLETED);

	g_object_remove_toggle_ref (
		G_OBJECT (activity), (GToggleNotify)
		shell_ready_for_quit, shell);

	/* Finalize the activity. */
	g_object_unref (activity);

	/* XXX Inhibiting session manager actions currently only
	 *     works on GNOME, so check that we obtained a valid
	 *     inhibit cookie before attempting to uninhibit. */
	if (shell->priv->inhibit_cookie > 0) {
		gtk_application_uninhibit (
			application, shell->priv->inhibit_cookie);
		shell->priv->inhibit_cookie = 0;
	}

	/* Destroy all watched windows.  Note, we iterate over a -copy-
	 * of the watched windows list because the act of destroying a
	 * watched window will modify the watched windows list, which
	 * would derail the iteration. */
	list = g_list_copy (gtk_application_get_windows (application));
	g_list_foreach (list, (GFunc) gtk_widget_destroy, NULL);
	g_list_free (list);

	if (gtk_main_level () > 0)
		gtk_main_quit ();
}
예제 #13
0
파일: general.c 프로젝트: amery/clip-itk
/* Registers a function to be called when an instance of the mainloop is left. */
int
clip_GTK_QUITADD(ClipMachine * cm)
{
	guint main_level = INT_OPTION(cm,1,gtk_main_level());
	C_var *c;

	CHECKOPT(1,NUMERIC_t); CHECKARG2(2,PCODE_t,CCODE_t);

	c = NEW(C_var);
	c->cm = cm; //c->cfunc = NEW(ClipVar);
	_clip_mclone(cm,&c->cfunc, _clip_spar(cm,2));
	_clip_retni(cm,gtk_quit_add_full(main_level,(GtkFunction)__func,NULL,c,
		_destroy__func));
	return 0;
err:
	return 1;
}
예제 #14
0
파일: xpad-app.c 프로젝트: abhinandh/xpad
static gboolean
xpad_app_quit_if_no_pads (XpadPadGroup *group)
{
	if (!xpad_tray_is_open ())
	{
		gint num_pads = xpad_pad_group_num_visible_pads (group);
		if (num_pads == 0)
		{
			if (gtk_main_level () > 0)
				gtk_main_quit ();
			else
				exit (0);
		}
	}
	
	return FALSE;
}
예제 #15
0
static int quit_if_in_main_loop (gpointer callback_data)
{
    guint level;

    g_assert (callback_data == NULL);

    level = gtk_main_level ();

    /* We can be called even outside the main loop,
     * so check that we are in a loop before calling quit.
     */
    if (level != 0)
    {
        gtk_main_quit ();
    }

    /* We need to be called again if we quit a nested loop. */
    return level > 1;
}
예제 #16
0
파일: main.c 프로젝트: vastin/iliad-hacking
// signal handlers
static void on_sigterm(int signo)
{
    DL_WARNPRINTF("entry pcshareMgr");

    if (gtk_main_level() > 0)
    {
        // stop main process
        gdk_threads_enter();
        DL_WARNPRINTF("stop GTK main");
        gtk_main_quit();
        gdk_threads_leave();
    }
    else
    {
        // not in gtk_main, probably in initialisation phase
        // just quit
        DL_WARNPRINTF("_exit(1)");
        _exit(1);
    }
}
예제 #17
0
파일: general.c 프로젝트: amery/clip-itk
/* Trigger destruction of object in case the mainloop at level main_level is quit. */
int
clip_GTK_QUITADDDESTROY(ClipMachine * cm)
{
	guint main_level = INT_OPTION(cm,1,gtk_main_level());
	C_widget *cwid = _fetch_cwidget(cm,_clip_spar(cm,2));
	C_object *cobj;

	CHECKOPT(1,NUMERIC_t); CHECKARG2(2,MAP_t,NUMERIC_t);

	if (cwid->objtype == GTK_OBJ_WIDGET)
	{
		CHECKCWID(cwid, GTK_IS_OBJECT);
		gtk_quit_add_destroy(main_level, GTK_OBJECT(cwid->widget));
	}
	if (cwid->objtype == GTK_OBJ_OBJECT)
	{
		cobj = (C_object*)cwid;
		CHECKCOBJ(cobj, GTK_IS_OBJECT(cobj->object));
		gtk_quit_add_destroy(main_level, GTK_OBJECT(cobj->object));
	}
	return 0;
err:
	return 1;
}
예제 #18
0
static void ok_clicked(GtkWidget *widget, gpointer data)
{
	ack = TRUE;
	if (gtk_main_level() > 1)
		gtk_main_quit();
}
예제 #19
0
파일: general.c 프로젝트: amery/clip-itk
/* Ask for the current nesting level of the main loop.
 * This can be useful when calling gtk_quit_add. */
int
clip_GTK_MAINLEVEL(ClipMachine * cm)
{
	_clip_retni(cm,gtk_main_level());
	return 0;
}
예제 #20
0
static void cancel_clicked(GtkWidget *widget, gpointer data)
{
	ack = FALSE;
	if (gtk_main_level() > 1)
		gtk_main_quit();
}
예제 #21
0
static void import_cancel_cb(GtkWidget *widget, gpointer data)
{
	if (gtk_main_level() > 1)
		gtk_main_quit();
}
예제 #22
0
void pApplication::quit() {
  //if gtk_main() was invoked, call gtk_main_quit()
  if(gtk_main_level()) gtk_main_quit();
}
예제 #23
0
파일: main.c 프로젝트: Tetralet/LilyTerm
int main( int   argc,
	  char *argv[])
#endif
{
#if defined(USE_GTK2_GEOMETRY_METHOD) && defined (GEOMETRY)
	g_debug("GEOMETRY_NONE  = 0x%X", GEOMETRY_NONE );
	g_debug("GEOMETRY_UPDATE_PAGE_NAME = 0x%X", GEOMETRY_UPDATE_PAGE_NAME);
	g_debug("GEOMETRY_UPDATE_PAGE_NAME_MASK = 0x%X", GEOMETRY_UPDATE_PAGE_NAME_MASK);
	g_debug("GEOMETRY_CHANGING_THEME = 0x%X", GEOMETRY_CHANGING_THEME);
	g_debug("GEOMETRY_SHOW_HIDE_SCROLL_BAR = 0x%X", GEOMETRY_SHOW_HIDE_SCROLL_BAR);
	g_debug("GEOMETRY_SHOW_HIDE_TAB_BAR = 0x%X", GEOMETRY_SHOW_HIDE_TAB_BAR);
	g_debug("GEOMETRY_CHANGING_FONT = 0x%X", GEOMETRY_CHANGING_FONT);

	g_debug("GEOMETRY_NEEDS_RUN_SIZE_REQUEST_MASK = 0x%X", GEOMETRY_NEEDS_RUN_SIZE_REQUEST_MASK);
	g_debug("GEOMETRY_NEEDS_RUN_SIZE_REQUEST_AGAIN_MASK = 0x%X", GEOMETRY_NEEDS_RUN_SIZE_REQUEST_AGAIN_MASK);
	g_debug("GEOMETRY_HAD_BEEN_RESIZED_ONCE_MASK = 0x%X", GEOMETRY_HAD_BEEN_RESIZED_ONCE_MASK);
#endif
	// command_line_path = argv[0];

	// g_debug ("argc = %d", argc);
	// print_array ("argv", argv);
	// i18n support. We need to support i18n under console, too.
	setlocale(LC_ALL, "");
	bindtextdomain(BINARY, LOCALEDIR);
	bind_textdomain_codeset(BINARY, "UTF-8");
	textdomain(BINARY);

#if ! defined(SAFEMODE) && defined(DEVELOP)
	g_message("Running %s without SAFE MODE!", PACKAGE);
#endif

#ifdef OUT_OF_MEMORY
#  undef g_strdup_printf
#endif
#ifdef ENABLE_PROFILE
	const gchar *user_config_dir = g_get_user_config_dir();
	if (user_config_dir) profile_dir = g_strdup_printf("%s/%s", user_config_dir, BINARY);
#endif
#ifdef OUT_OF_MEMORY
	#define g_strdup_printf(...) NULL
#endif
	// in BSD system, /proc may not exist.
	proc_exist = check_if_default_proc_dir_exist(NULL);
	// g_debug ("Get proc_exist = %d, proc_file_system_path = %s", proc_exist, proc_file_system_path);

	shell = g_getenv("SHELL");
	if (shell==NULL) shell = "";

	gboolean pwd_need_be_free = FALSE;
	pwd = (gchar *)g_getenv("PWD");
	if (pwd==NULL)
	{
		pwd_need_be_free = TRUE;
		pwd = g_get_current_dir();
	}
	if (pwd==NULL)
	{
		pwd_need_be_free = FALSE;
		pwd = "";
	}
	// g_debug("Got $PWD = %s", pwd);

	home = g_getenv("HOME");
	if (home==NULL) home = "";
	// g_debug("Get $HOME = %s", home);

	// deal the command line options
	command_option(argc, argv);
	if (wmclass_name==NULL) wmclass_name = g_getenv("RESOURCE_NAME");
	if (wmclass_name==NULL) wmclass_name = "";
	if (wmclass_class==NULL) wmclass_class = "";
	// g_debug("Got wmclass_name = %s, wmclass_class = %s", wmclass_name, wmclass_class);

	// init the gtk+2 engine

	// GTK3: get gtk_test_widget_click() working...
	// gdk_disable_multidevice();

#ifndef UNIT_TEST
	gtk_init(&argc, &argv);
#endif
	// FIXME: we should get the single_process from profile. Current is command-line option only.
	if (single_process)
	{
		gchar *socket_str = convert_socket_data_to_string(argv);
		if (init_gtk_socket(SOCKET_FILE, socket_str, (GSourceFunc)convert_string_to_socket_data) == UNIX_SOCKET_DATA_SENT)
		{
			g_free(profile_dir);
			exit (0);
		}
		g_free(socket_str);
	}

	// start LilyTerm

	// empty_environ = g_strsplit("", " ", -1);
	extern gchar **environ;
	// print_array("main(): environ", environ);
	gchar *environ_str = convert_array_to_string(environ, '\t');
	// if (window_list) g_error("CHECK: window_list = %p !!", window_list);
	// g_debug("Got environ_str (in main.c) = %s", environ_str);
	selection_clipboard = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
	selection_primary = gtk_clipboard_get(GDK_SELECTION_PRIMARY);
	system_locale_list = get_locale_list();
	// g_debug("Got system_locale_list = %s", system_locale_list);
	init_LC_CTYPE = g_strdup(get_default_lc_data(LC_CTYPE));
	// g_debug("Got init_LC_CTYPE = %s", init_LC_CTYPE);
	init_LANGUAGE = g_strdup(get_default_lc_data(LANGUAGE));
	// g_debug("Got init_LANGUAGE = %s", init_LANGUAGE);
	init_LC_MESSAGES = g_strdup(get_default_lc_data(LC_MESSAGES));
	// g_debug("init_LC_MESSAGES = %s", init_LC_MESSAGES);
	init_encoding = (gchar *)get_encoding_from_locale(NULL);
	if (! compare_strings(init_encoding, "ANSI_X3.4-1968", TRUE))
	{
		g_free(init_encoding);
		init_encoding = g_strdup("UTF-8");
	}
	// g_debug("init_encoding = %s", init_encoding);
	SYSTEM_VTE_CJK_WIDTH_STR = g_getenv("VTE_CJK_WIDTH");
	// g_debug ("Got SYSTEM_VTE_CJK_WIDTH_STR = %s", SYSTEM_VTE_CJK_WIDTH_STR);
	// FIXME: signal(SIGCHLD, SIG_IGN);
	// The first window of LilyTerm

	// Convert the GdkColor to GdkRGBA
	convert_system_color_to_rgba();

	// g_debug("Got original encoding = %s", get_encoding_from_locale(NULL));
	//GtkNotebook *new_window(int argc,
	//			char *argv[],
	//			gchar *shell,
	//			gchar *environment,
	//			gchar *locale_list,
	//			gchar *PWD,
	//			gchar *HOME,
	//			gchar *VTE_CJK_WIDTH_STR,
	//			gboolean VTE_CJK_WIDTH_STR_overwrite_profile,
	//			gchar *wmclass_name,
	//			gchar *wmclass_class,
	//			gchar *user_environ,
	//			gchar *encoding,
	//			gboolean encoding_overwrite_profile,
	//			gchar *lc_messages,
	//			struct Window *win_data_orig,
	//			struct Page *page_data_orig)

	// g_debug("main(1): gtk_main_level = %d, g_list_length(window_list) = %d", gtk_main_level(), g_list_length(window_list));
	if ((new_window(argc,
			argv,
			(gchar *) shell,
			environ_str,
			system_locale_list,
			(gchar *) pwd,
			(gchar *) home,
			SYSTEM_VTE_CJK_WIDTH_STR,
			FALSE,
			wmclass_name,
			wmclass_class,
			NULL,
			init_encoding,
			FALSE,
			init_LC_MESSAGES,
			NULL,
			NULL)) ||
	     g_list_length(window_list))
	{
		// The argv of "main" LilyTerm can't be free.
		// Set it to NULL here to avoid double_free().
		argv=NULL;
#ifdef ENABLE_X_STARTUP_NOTIFICATION_ID
		gdk_notify_startup_complete_with_id(PACKAGE);
#endif
		// g_debug("main(2): gtk_main_level = %d, g_list_length(window_list) = %d", gtk_main_level(), g_list_length(window_list));
		if (! gtk_main_level())
			gtk_main();
	}
#ifdef DETAIL
	else
	{
//		g_debug("Got window_list = %p", window_list);
//		GList *win_list = window_list;
//		gint i=0;
//
//		while (win_list)
//		{
//			g_debug("Got %d win_data = %p", ++i, win_list->data);
//			win_list = win_list->next;
//		}
		g_debug("??? The creation of first window is FAIL!!!");
	}
#endif
	extern struct KeyValue system_keys[KEYS];
	gint i;
	// g_debug("Clear function key data!!");
	for (i=KEY_SWITCH_TO_TAB_1; i<=KEY_SWITCH_TO_TAB_12; i++)
	{
		g_free(system_keys[i].name);
		g_free(system_keys[i].topic);
		g_free(system_keys[i].comment);
		g_free(system_keys[i].translation);
#ifdef UNIT_TEST
		system_keys[i].name = NULL;
		system_keys[i].topic = NULL;
		system_keys[i].comment = NULL;
		system_keys[i].translation = NULL;
#endif
	}

	// g_free(pwd);
	// g_strfreev(empty_environ);
	g_free(environ_str);
	g_free(init_encoding);
	g_free(system_locale_list);
	g_free(profile_dir);
	if (pwd_need_be_free) g_free(pwd);
	g_free(restricted_locale_message);
	g_list_free(window_list);
	g_free(init_LC_CTYPE);
	g_free(init_LC_MESSAGES);
#ifdef UNIT_TEST
	// empty_environ = NULL;
	environ_str = NULL;
	init_encoding = NULL;
	system_locale_list = NULL;
	profile_dir = NULL;
	restricted_locale_message = NULL;
	window_list = NULL;
	init_LC_CTYPE = NULL;
	init_LC_MESSAGES = NULL;
#endif
	return 0;
}
예제 #24
0
void cb_quit(void)
{
    do {
	gtk_main_quit();
    } while (gtk_main_level() > 1);
}
예제 #25
0
파일: gtktestutils.c 프로젝트: jdapena/gtk
static void
try_main_quit (void)
{
    if (gtk_main_level())
        gtk_main_quit();
}
예제 #26
0
static gboolean
configure_event (GtkWidget         *widget,
                 GdkEventConfigure *event,
                 gpointer           data)
{
  GdkGLDrawable *gldrawable;
  static gboolean is_initialized = FALSE;

  /*
   * Create an OpenGL off-screen rendering area.
   */

  if (pixmap != NULL)
    g_object_unref (G_OBJECT (pixmap));

  pixmap = gdk_pixmap_new (widget->window,
			   widget->allocation.width,
			   widget->allocation.height,
                           -1);

  /*
   * Set OpenGL-capability to the pixmap
   */

  gldrawable = GDK_GL_DRAWABLE (gdk_pixmap_set_gl_capability (pixmap,
                                                              glconfig,
                                                              NULL));

  /*
   * Create OpenGL rendering context (not direct).
   */

  if (glcontext == NULL)
    {
      glcontext = gdk_gl_context_new (gldrawable,
                                      NULL,
                                      FALSE,
                                      GDK_GL_RGBA_TYPE);
      if (glcontext == NULL)
        {
          g_print ("Connot create the OpenGL rendering context\n");
          if (gtk_main_level () != 0)
            gtk_main_quit ();
          return TRUE;
        }

      g_print ("The OpenGL rendering context is created\n");
    }

  /*** OpenGL BEGIN ***/
  if (!gdk_gl_drawable_gl_begin (gldrawable, glcontext))
    goto NO_GL;

  if (!is_initialized)
    {
      init ();
      is_initialized = TRUE;
    }

  glViewport (0, 0,
              widget->allocation.width, widget->allocation.height);

  glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

  /* Sync. */
  gdk_gl_drawable_wait_gl (gldrawable);

  /* GDK rendering. */
  gdk_draw_rectangle (GDK_DRAWABLE (gldrawable),
		      widget->style->black_gc,
		      TRUE,
		      widget->allocation.width/10,
		      widget->allocation.height/10,
		      widget->allocation.width*8/10,
		      widget->allocation.height*8/10);

  /* Sync. */
  gdk_gl_drawable_wait_gdk (gldrawable);

  glCallList (1);

  glFlush ();

  gdk_gl_drawable_gl_end (gldrawable);
  /*** OpenGL END ***/

 NO_GL:

  return TRUE;
}
예제 #27
0
/*
 * Replacement code for the gtk_quit_add() function, which GTK2 - in
 * their unbounded wisdom - deprecated without providing any usable
 * replacement, and which we were using to ensure that our idle
 * function for toplevel callbacks was only run from the outermost
 * gtk_main().
 *
 * We must make sure that all our subsidiary calls to gtk_main() are
 * followed by a call to post_main(), so that the idle function can be
 * re-established when we end up back at the top level.
 */
void post_main(void)
{
  if (gtk_main_level() == 1)
    notify_toplevel_callback(NULL);
}
예제 #28
0
static VALUE
rg_s_main_level(G_GNUC_UNUSED VALUE self)
{
    return INT2FIX(gtk_main_level());
}
예제 #29
0
파일: xpad-app.c 프로젝트: abhinandh/xpad
static gboolean
process_remote_args (gint *argc, gchar **argv[], gboolean have_gtk)
{
	GError *error = NULL;
	GOptionContext *context;
	
	option_new = FALSE;
	option_files = NULL;
	option_quit = FALSE;
	option_smid = NULL;
	option_hide = FALSE;
	option_show = FALSE;
	option_toggle = FALSE;
	
	context = g_option_context_new (NULL);
	g_option_context_set_ignore_unknown_options (context, TRUE);
	g_option_context_set_help_enabled (context, FALSE);
	g_option_context_add_main_entries (context, remote_options, GETTEXT_PACKAGE);
	if (g_option_context_parse (context, argc, argv, &error))
	{
		if (have_gtk && option_smid)
			xpad_session_manager_set_id (option_smid);
		
		if (have_gtk && option_new)
		{
			GtkWidget *pad = xpad_pad_new (pad_group);
			gtk_widget_show (pad);
		}

		if (have_gtk && option_show)
		  xpad_pad_group_show_all (pad_group);
		
		if (have_gtk && option_hide)
		  xpad_pad_group_close_all (pad_group);
		
		if (have_gtk && option_toggle)
		  xpad_pad_group_toggle_hide (pad_group);

		if (have_gtk && option_files)
		{
			int i;
			for (i = 0; option_files[i]; i++)
			{
				GtkWidget *pad = xpad_pad_new_from_file (pad_group, option_files[i]);
				if (pad)
					gtk_widget_show (pad);
			}
		}
		
		if (option_quit)
		{
			if (have_gtk && gtk_main_level () > 0)
				gtk_main_quit ();
			else
				exit (0);
		}
	}
	else
	{
		fprintf (output, "%s\n", error->message);
		/* Don't quit.  Bad options passed to the main xpad program by other
		   iterations shouldn't close the main one. */
	}
	
	g_option_context_free (context);
	
	return(option_new || option_quit || option_smid || option_files ||
	       option_hide || option_show || option_toggle);
}
예제 #30
0
static void
destroy_window (void)
{
    if (gtk_main_level () > 0)
        gtk_main_quit ();
}