Esempio n. 1
0
int
clip_GTK_ACCELERATORSETDEFAULTMODMASK(ClipMachine * ClipMachineMemory)
{
   GdkModifierType modifiers = _clip_parni(ClipMachineMemory, 1);

   CHECKARG(1, NUMERIC_type_of_ClipVarType);

   gtk_accelerator_set_default_mod_mask(modifiers);
   return 0;
 err:
   return 1;
}
Esempio n. 2
0
int main (int argc, char *argv[])
{
	GtkWidget	*main_window;
	GOptionContext	*context;
	GError		*option_error;
	gchar		*config_file_name, *dir;
	gboolean	show_version = FALSE;

	GOptionEntry options[] =
	{
		{
			"version",
			'v',
			0,
			G_OPTION_ARG_NONE,
			&show_version,
			_("Show version information"),
			NULL
		},
		{NULL}
	};

#ifdef WITH_HILDON
	HildonProgram   *hildon_program;
#endif

#ifdef ENABLE_NLS
	bindtextdomain (PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (PACKAGE, "UTF-8");
	textdomain (PACKAGE);
  
	gtk_set_locale();
#endif

	/* Parse command line options */
	context = g_option_context_new (NULL);
	g_option_context_set_summary(context,
			_("Carry out simple and scientific calculations"));
#ifdef ENABLE_NLS
	g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);
#else
	g_option_context_add_main_entries (context, options, NULL);
#endif
	g_option_context_add_group (context, gtk_get_option_group (TRUE));

	if (!g_option_context_parse (context, &argc, &argv, &option_error))
	{
		if (option_error)
			g_print ("%s\n", option_error->message);

		return EXIT_FAILURE;
	}

	g_option_context_free (context);

	if(show_version == TRUE)
	{
		g_print(_("%s v%s, (c) 2002-2010 Simon Floery\n"),
			PACKAGE, VERSION);
		return EXIT_SUCCESS;
	}


	gtk_init (&argc, &argv);

	/* at first, get config file */
	dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL);
	g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
	config_file_name = g_build_filename (dir, CONFIG_FILE_NAME, NULL);
	g_free(dir);

	prefs = config_file_read (config_file_name);
	
	constant = config_file_get_constants();
	user_function = config_file_get_user_functions();
	g_free (config_file_name);

	current_status.notation = prefs.def_notation;

#ifdef WITH_HILDON
	gtkbuilder_register_widget (HILDON_TYPE_WINDOW, gtkbuilder_hildon_window_new, gtkbuilder_standard_build_children, NULL);
	hildon_program = HILDON_PROGRAM(hildon_program_get_instance());
#endif

	/* at first get the main frame */
	
	/* sth like ui_launch_up_ui for splitting into first time wizard? */
	main_window = ui_main_window_create();
#ifdef WITH_HILDON
	hildon_program_add_window(hildon_program, HILDON_WINDOW(main_window));
	g_set_application_name(PACKAGE_NAME);
	create_hildon_menu(HILDON_WINDOW(main_window));
#endif	

	/* set the window title */
#ifndef WITH_DEFCALC
	gtk_window_set_title ((GtkWindow *)main_window, PACKAGE_NAME);
#else
	gtk_window_set_title ((GtkWindow *)main_window, "Calculator");
#endif

	/* set the window's icon */
#ifndef WITH_DEFCALC
	gtk_window_set_default_icon_name (PACKAGE);
#else
	gtk_window_set_default_icon_name ("utilities-calculator");
#endif

	/* usually, only Shift, CTRL and ALT modifiers are paid attention to by 
	 * accelerator code. add MOD2 (NUMLOCK allover the world?) to the list. 
	 * We have to do this for a working keypad.
	 */

	gtk_accelerator_set_default_mod_mask (gtk_accelerator_get_default_mod_mask () | GDK_MOD2_MASK); 
				  
	/* prepare calc_basic */

	main_alg = alg_init (0);
	rpn_init (prefs.stack_size, 0);
		
	/* apply changes */
	apply_preferences (prefs);

	memory.data = NULL;
	memory.len = 0;

	/* see function key_snooper for details */
	gtk_key_snooper_install (key_snooper, NULL);

	gtk_window_resize ((GtkWindow *)main_window, 1, 1);
	
	/* gtk_widget_show main window as late as possible */
	gtk_widget_show (main_window);

	gtk_main ();

	/* save changes to file */
	dir = g_build_filename (g_get_user_config_dir (), PACKAGE, NULL);
	g_mkdir_with_parents (dir, S_IRUSR | S_IWUSR | S_IXUSR);
	config_file_name = g_build_filename (dir, CONFIG_FILE_NAME, NULL);
	g_free(dir);

	config_file_write (config_file_name, prefs, constant, user_function);
	g_free (config_file_name);

	return EXIT_SUCCESS;
}