コード例 #1
0
unsigned int volk_rank_archs(const char *indices[], const int* arch_defs, unsigned int n_archs, const char* name, unsigned int arch) {
  unsigned int i;
  unsigned int best_val = 0;
  static struct volk_arch_pref *volk_arch_prefs;
  static unsigned int n_arch_prefs = 0;
  static int prefs_loaded = 0;
  if(!prefs_loaded) {
      n_arch_prefs = load_preferences(&volk_arch_prefs);
      prefs_loaded = 1;
  }

  //now look for the function name in the prefs list
  for(i=0; i < n_arch_prefs; i++) {
      if(!strncmp(name, volk_arch_prefs[i].name, 128)) { //found it
        return get_index(indices, n_archs, volk_arch_prefs[i].arch);
      }
  }

  for(i=1; i < n_archs; ++i) {
    if((arch_defs[i]&(!arch)) == 0) {
      best_val = (arch_defs[i] > arch_defs[best_val + 1]) ? i-1 : best_val;
    }
  }
  return best_val;
}
コード例 #2
0
ファイル: fe-gnome.c プロジェクト: GNOME/xchat-gnome
void
fe_init (void)
{
    GConfClient *client;

    client = gconf_client_get_default ();
    gconf_client_add_dir (client, "/apps/xchat", GCONF_CLIENT_PRELOAD_NONE, NULL);
    g_object_unref (client);

    u = userlist_new ();
    gui.quit = FALSE;
    palette_init ();
    run_migrations ();
    initialize_gui_1 ();
    if (!preferences_exist ()) {
        run_setup_dialog ();
    } else {
        set_version ();
    }
    servlist_init ();
    initialize_gui_2 ();
    load_preferences ();
    run_main_window (opt_fullscreen);

    /* Force various window-related options to match our interaction model */
    prefs.use_server_tab = TRUE;
    prefs.notices_tabs = FALSE;
    prefs.servernotice = TRUE;
    prefs.slist_skip = FALSE;

    /* If we don't have a specific DCC IP address, force get-from-server */
    if (strlen (prefs.dcc_ip_str) == 0) {
        prefs.ip_from_server = TRUE;
    }

    /* Don't allow the core to autoload plugins. We use our own
     * method for autoloading.
     */
    arg_skip_plugins = 1;

    if (not_autoconnect ()) {
        ConnectDialog *cd;

        cd = connect_dialog_new ();
        gtk_widget_show_all (GTK_WIDGET (cd));
    }

#ifdef USE_PLUGIN
    plugins_initialize ();
#endif
}
コード例 #3
0
ファイル: main.c プロジェクト: adtools/db101
int main(int argc, char *argv[])
{
	init();
	freemem_init();
	init_breakpoints();
	//tracking_init();
	modules_init();
	stabs_init();
	modules_load_list();
	arexx_open_port();
	if (argc < 2 || strcmp("NOGUI", argv[1]) )
		main_open_window();
	load_preferences();
	event_loop();
	cleanup();
	//tracking_cleanup();
	modules_cleanup();
	//remove_hook();
	end();
	return 0;

}
コード例 #4
0
ファイル: main.c プロジェクト: HateBreed/test_framework_visma
/**
* Run a test directly with specified user. Attempts to load preferences
* with specified username and if successful, tries to get a test with
* specified testname and when found, runs the test and quits.
*
* This is run only when program is called with two input parameters
* using switch -u for username and -t for testname.
*
* @param user User whose preferences is to be loaded
* @param testname Name of the user's test to load
*
* @return TRUE if user and testname was found, FALSE if either is missing or not found
*/
gboolean run_user_test(gchar* user, gchar* testname) {
	user_preference* prefs = NULL;
	gboolean rval = FALSE;
	
	if(!user || !testname) return rval;

	// Load preferences for this user
	if((prefs = load_preferences(user))) {
	
		// Get test and when found run it
		testcase* test = preference_get_test(prefs,testname);
		if(test) {
			g_print("Running test \"%s\" to %s (with %d files)\n",
					test->name,test->URL,g_hash_table_size(test->files));
				
			// Init
			tests_initialize(test);
		
			// Run
			if(tests_run_test(prefs->username,test)) 
				g_print("Test %s completed with failures.\n",test->name);
			else g_print("Test %s complete\n",test->name);
		
			// REset
			tests_reset(test);
			rval = TRUE;
		}
		// Test not found
		else {
			rval = FALSE;
			g_print("Test \"%s\" not found\n",testname);
		}
		destroy_preferences();
	}
	else rval = FALSE;
	
	return rval;
}
コード例 #5
0
/*  preferences pointer.. */
bool w_open_preferences_file(
  char *PrefName,
  Typecode Type)
{
  int error = 0;
  bool success= true;

  /* allocate space for our global structure to keep track of the prefs file */
  prefInfo = NULL;
  try {
    prefInfo = new preferences_info;

#if defined(mac)
    prefInfo->PrefsFile.SetParentToPreferences();
    prefInfo->PrefsFile.SetName(PrefName,Type);
    /* check for the preferences folder using FindFolder, creating it if necessary */
#elif defined(SDL)
    prefInfo->PrefsFile.SetToPreferencesDir();
    prefInfo->PrefsFile += PrefName;
#endif

    /* does the preferences file exist? */
    load_preferences();             /* Uses prefInfo.. */

    if(error_pending()) {
      short type;

      error= get_game_error(&type);
      if(type==systemError) {
        if (!prefInfo->PrefsFile.Exists()) {
          prefInfo->PrefsFile.Create(Type);
          prefInfo->wad = create_empty_wad();
          set_game_error(systemError,prefInfo->PrefsFile.GetError());
          w_write_preferences_file();
        }
      }
      else {
        /* Something was invalid.. */
        if (prefInfo->PrefsFile.Delete()) {
          prefInfo->wad= create_empty_wad();
          set_game_error(systemError, error);
          w_write_preferences_file();
        }
        set_game_error(systemError, errNone);
      }
    }
  } catch (...) {
    dprintf("In \"catch\"");
    set_game_error(systemError, memory_error());
  }

  if (error) {
    /* if something is broken, make sure we at least return valid prefs */
    if(prefInfo && !prefInfo->wad) {
      prefInfo->wad= create_empty_wad();
    }
  }

  /* Gotta bail... */
  if(!prefInfo || !prefInfo->wad) {
    success= false;
  }

// dump_wad(prefInfo->wad);

  return success;
}
コード例 #6
0
ファイル: main.c プロジェクト: arievanleyen/xpen
int main(int argc, char *argv[]) {
    GtkBuilder *builder;
    GString *txt = g_string_new_len("", 20);
    char filepad[100];
    unsigned short i, mask=0;
    GdkScreen* screen = NULL;
	int xx, yy, screen_width, screen_height;

	InitAudio();

	pad = get_real_path();					// get the path of the executable

	sprintf(filepad, "%s/.lock", pad);
	setlock(filepad, 10, TRUE);				// disable multiple instances for at least 10 seconds

	g_thread_init (NULL);

    display = XOpenDisplay(0);
    if (display == NULL)
        exit(1);

    gtk_set_locale();

    gtk_init(&argc, &argv);

    builder = gtk_builder_new ();

    sprintf(filepad, "%s/%s.glade", pad, SKIN);

    gtk_builder_add_from_file(builder, filepad, NULL);

    gtk_builder_connect_signals (builder, NULL);

    // set widgets to be handled by the event handlers
    window 			= GW ("window");
    preferences 	= GW ("preferences");
    lookup		 	= GW ("lookup");
    fontbutton 		= GW ("fontbutton1");
    drag 			= GW ("dragbar");
    debug 			= GW ("debug");
	papier 			= GW ("drawingarea1");
    colorbutton1 	= GW ("colorbutton1");
    colorbutton2 	= GW ("colorbutton2");
    checkbutton1	= GW ("checkbutton1");
    entry1 			= GW ("entry1");
    entry2 			= GW ("entry2");
    gtktable1 		= GW ("table1");
    checkbutton8	= GW ("checkbutton8");
    checkbutton9	= GW ("checkbutton9");
    textview1 		= GW ("textview1");
    entry16 		= GW ("entry16");
    combobox1 		= GW ("combobox1");
    scrolled		= GW ("scrolledwindow2");
    opacity 		= GTK_ADJUSTMENT (gtk_builder_get_object (builder, "adjustment1"));
    speed 			= GTK_ADJUSTMENT (gtk_builder_get_object (builder, "adjustment2"));
    textbuffer1		= GTK_TEXT_BUFFER(gtk_builder_get_object (builder, "textbuffer1"));

	for (i=0; i<sizeof(unsigned short); i++) {	// set each bit of mask
		mask <<= 8;
		mask |= 0xFF;
	}

	// fill the struct that keeps the 7 recognize buttons & checkboxes (in preferences)
    for (i=0; i<7; i++) {
    	g_string_sprintf(txt, "checkbutton%d", i+2);
		modebits[i].check = GTK_WIDGET(gtk_builder_get_object (builder, txt->str));
		g_string_sprintf(txt, "button%d", i+3);
		modebits[i].button = GTK_WIDGET(gtk_builder_get_object (builder, txt->str));
		switch (i) {
			case 0: modebits[i].bit = (GB1|GB2);	modebits[i].mask = ((GB1|GB2) ^ mask);	break;
			case 1: modebits[i].bit = BIG5;			modebits[i].mask = (BIG5 ^ mask);		break;
			case 2: modebits[i].bit = DIGITS;		modebits[i].mask = (DIGITS ^ mask);		break;
			case 3: modebits[i].bit = LOWERCASE;	modebits[i].mask = (LOWERCASE ^ mask);	break;
			case 4: modebits[i].bit = UPPERCASE;	modebits[i].mask = (UPPERCASE ^ mask);	break;
			case 5: modebits[i].bit = PUNC;			modebits[i].mask = (PUNC ^ mask);		break;
			case 6: modebits[i].bit = DEFAULT;		modebits[i].mask = (DEFAULT ^ mask);	break;
		}
	}

	// fill the structure that keeps the 13 labels for the keys (preferences)
    for (i=0; i<13; i++) {
    	g_string_sprintf(txt, "button%d", i+10);
		conf.defkey[i].button = GTK_WIDGET(gtk_builder_get_object (builder, txt->str));
    	g_string_sprintf(txt, "entry%d", i+3);
		conf.defkey[i].entry = GTK_WIDGET(gtk_builder_get_object (builder, txt->str));
		conf.defkey[i].key = 0;
    }

    // place a simple combobox for the input selection (preferences)
    combo = gtk_combo_box_new_text();
    gtk_table_attach_defaults(GTK_TABLE(gtktable1), combo, 1, 2, 2, 3);
    gtk_widget_show (combo);

    // get events and labels for the 9 candidates
    for (int i=0; i< 9; i++) {
        g_string_sprintf(txt, "knop%d", i+1);
        knop[i] = GTK_WIDGET (gtk_builder_get_object (builder, txt->str));
        g_string_sprintf(txt, "event%d", i+1);
        event[i] = GTK_WIDGET (gtk_builder_get_object (builder, txt->str));
    }

    // set events for paste and backspace entries (preferences)
    g_signal_connect(entry1, "key_press_event", G_CALLBACK(on_key_press), NULL);
    g_signal_connect(entry1, "key_release_event", G_CALLBACK(on_key_release), NULL);
    g_signal_connect(entry2, "key_press_event", G_CALLBACK(on_key_press), NULL);
    g_signal_connect(entry2, "key_release_event", G_CALLBACK(on_key_release), NULL);

    if (!create_wtpen_window())
        exit(1);

    wtpen_init();

	g_object_unref (G_OBJECT (builder));

    gtk_widget_show_all(GTK_WIDGET(window));

	for (i=0; i<NUMKEYS; i++)	hotkey[i] = 0;	// reset all hotkeys

    // load cedict from file
    sprintf(filepad, "%s/data", pad);
    import_cedict(filepad);

    // load settings from file
    sprintf(filepad, "%s/xpen.cfg", pad);
    load_preferences(filepad);

    // set background and shape
    sprintf(filepad, "%s/%s.png", pad, SKIN);
    set_window_shape(filepad);

	// some styles to be used in the cedict browser (lookup window)一
	gtk_text_buffer_create_tag(textbuffer1, "mark", "background", "yellow", "foreground", "black", NULL);
	gtk_text_buffer_create_tag(textbuffer1, "bold", "weight", PANGO_WEIGHT_BOLD, NULL);
	gtk_text_buffer_create_tag(textbuffer1, "character", "font", conf.font, "scale", 1.3, NULL);
	gtk_text_buffer_create_tag(textbuffer1, "translation", "scale", 0.9, NULL);
	gtk_text_buffer_create_tag(textbuffer1, "pinyin", "scale", 1.1, NULL);

    ready = TRUE;	// let_configure_event() know that it can start its setup

	// start monitoring system-wide keypresses
	g_thread_create (intercept_key_thread, NULL, FALSE, NULL);

	// make sure the window positions and size are legal
	screen = gtk_window_get_screen(GTK_WINDOW(window));		// get screen size
	screen_width = gdk_screen_get_width(screen);
	screen_height = gdk_screen_get_height(screen);

    xx = MAX(MIN(screen_width-width, conf.x), 0);			// set the position of the main window
    yy = MAX(MIN(screen_height-height, conf.y), 0);
	gtk_widget_set_uposition(window, xx, yy);

    xx = MIN(screen_width, conf.dx);						// set the size of the lookup window
    yy = MIN(screen_height, conf.dy);
	gtk_widget_set_usize(lookup, xx, yy);

	xx = MAX(MIN(screen_width-conf.dx, conf.lx), 0);		// set the position of the lookup window
	yy = MAX(MIN(screen_height-conf.dy, conf.ly), 0);
	gtk_widget_set_uposition(lookup, xx, yy);

	g_timeout_add (100, checkfocus, NULL);	// check the inputfocus (each 1/10s)

//////////////////////////////////////////////////////////////
//on_full_screen_button_pressed();	// start the full screen mode
//////////////////////////////////////////////////////////////

    gtk_main();						// start the main loop

	sprintf(filepad, "%s/.lock", pad);		// remove the lock
	setlock(filepad, 0, FALSE);

	// save all settings to file
    sprintf(filepad, "%s/xpen.cfg", pad);
	save_preferences (filepad);

    g_free(pad);
	free_all();

    wtpen_window_done();
    wtlib_done();

    SDL_CloseAudio();
    SDL_Quit();

//on_full_screen_button_pressed();

    return 0;
}
コード例 #7
0
ファイル: main.c プロジェクト: HateBreed/test_framework_visma
/** 
* Test selection part of UI. Lists tests for this user
* and awaits for selection. Runs test if it is found and
* asks whether to rerun test or to quit or to return to main.
*
* @param user username to use for loading preferences
*
* @return TRUE if preferences were found and loaded
*/
gboolean run_test_selection(gchar* user) {

	user_preference* prefs = NULL;
	gchar* temp = (gchar*)g_try_malloc(TEMPLEN);
	gboolean rval = TRUE;

	// Load preferences for this user
	if((prefs = load_preferences(user))) {
		
		g_print("%d test%s loaded for %s:\n",
			g_sequence_get_length(prefs->tests),
			g_sequence_get_length(prefs->tests) > 1 ? "s " : "",
			prefs->username);
	
		gboolean loop = TRUE, rerun = FALSE;
		gchar tnumber = '\0';
	
		// Run main loop for test selection
		while(loop) {
			gint idx = 0;
			GSequenceIter* iter = NULL;
			
			// If rerun of test was not selected print list of tests
			if(!rerun) { 
				g_print("id\tname\tfiles\turl\n");
				g_print("-------------------------------------------------------------------------------\n");
			
				// Go through list of tests
				for(iter = g_sequence_get_begin_iter(prefs->tests); 
					!g_sequence_iter_is_end(iter) ; 
					iter = g_sequence_iter_next(iter))
				{
					testcase* t = (testcase*)g_sequence_get(iter);
					
					// Is a test, print details
					if(t) {
						g_print(" %d\t%s\t%d\t%s\n",idx+1,t->name,g_hash_table_size(t->files),t->URL);
						idx++;
					}
				}
	
				g_print("\nSelect test id to run, q to quit, u to return to user selection: ");
				
				// get a char
				tnumber = getc(stdin);
		
				// Consume newline markers
				if(tnumber != '\n') temp = fgets(temp,TEMPLEN,stdin);
			}
			
			// Test rerun was selected
			else {
				g_print("Starting rerun of test %d\n",g_ascii_digit_value(tnumber));
				rerun = FALSE;
			}

			// If input is a digit between [1...amount of tests]
			if(g_ascii_isdigit(tnumber) && 
				g_ascii_digit_value(tnumber) <= g_sequence_get_length(prefs->tests) &&
				g_ascii_digit_value(tnumber) > 0) {
			
				// Set default parser
				set_parser(prefs->parser);
			
				// Get iterator to at position in testlist
				GSequenceIter* testpos = g_sequence_get_iter_at_pos(prefs->tests,
					g_ascii_digit_value(tnumber)-1);
				
				// Get test
				testcase* test = (testcase*)g_sequence_get(testpos);
			
				g_print("Running test %c:\"%s\" to %s (with %d files)\n",
					tnumber,test->name,test->URL,g_hash_table_size(test->files));
				
				// Initialize
				tests_initialize(test);
			
				// Run
				if(tests_run_test(prefs->username,test)) 
					g_print("Test %s completed with failures.\n",test->name);
				else g_print("Test %s complete\n",test->name);
			
				// Clear and reset test
				tests_reset(test);
				
				g_print("Redo test (r) or quit (q) or go to main (m) or return to user selection (u): ");
				
				// Get char 
				gchar response = getc(stdin);
			
				switch (response) {
					case 'r':
						rerun = TRUE;
						break;
					case 'q':
						loop = FALSE;
						break;
					case 'm':
						g_print("\n\n");
						break;
					case 'u':
						loop = FALSE;
						rval = FALSE;
						break;
					default:
						g_print("Invalid selection. Return to main.\n");
						rerun = FALSE;
						break;
				} // switch
				// Consume newline markers
				if(response != '\n') temp = fgets(temp,TEMPLEN,stdin);
			} // if
			else if(tnumber == 'q') loop = FALSE;
			else if(tnumber == 'u') {
				loop = FALSE;
				rval = FALSE;
			}
			else g_print("Invalid test id (%d)\n",g_ascii_digit_value(tnumber));
			iter = NULL;
		} // while
		destroy_preferences();
	} // if
	else {
		g_print("Preferences for user \"%s\" were not found\n",user);
		rval = FALSE;
	}
	
	g_free(temp);
	
	return rval;
}
コード例 #8
0
ファイル: decoder.c プロジェクト: dpbriggs/mocp
void decoder_init (int debug_info)
{
    load_plugins (debug_info);
    load_preferences ();
}
コード例 #9
0
ファイル: app.c プロジェクト: jeansch/yank-component
 GtkWidget * yank_app_new(EYank *yank) 
{
    yank_preferences      *prefs;


    static GtkTargetEntry drop_types[] =
    {
        { "text/uri-list", 0, 1 },
    };
    static gint n_drop_types = sizeof (drop_types)/sizeof (drop_types [0]);
    gchar     *treetitle[] =
    {
        _("NoteTree"),
        NULL
    };
    gchar     *todotitles[] =
    {
        _("Deadline"),
        _("Priority"),
        _("Complete"),
        _("Title"),
        NULL
    };
     GtkWidget   *app; 
    GtkWidget   *scrolledwindow1;
    GtkWidget   *scrolledwindow2;
    GtkWidget   *scrolledwindow3;
    GtkWidget   *hbox;
    GtkWidget   *hbox3;
    GtkWidget   *vbox;
    GtkWidget   *label;
    GdkFont     *font;
    GtkObject   *prio_adjust;
/*     gint        got_crash; */
    GtkWidget   *b_toggle_ext_flags;
    GtkWidget   *hbox_ext_flags;
		GtkWidget		*hpaned;
    
		hpaned = app = yank->priv->hpaned; 
    yank_main_app(app);  


	 sp->edit_tree = NULL;

	 sp->title_entry =NULL;
	 sp->todo_check =NULL;
	 sp->prio_entry =NULL;
	 sp->de_deadline =NULL;
	 sp->ad_complete =NULL;
	 sp->tlabel_created =NULL;
	 sp->tlabel_changed =NULL;
	 sp->label_changes =NULL;
	 sp->tlabel_expire =NULL;
	 sp->note_id_entry =NULL;
	 sp->text_entry =NULL;
	 sp->note_tree =NULL;
	 sp->b_ok =NULL;
	 sp->b_apply =NULL;
	 sp->b_cancel =NULL;
	 sp->todolist =NULL; 
	 sp->notebook =NULL;
	 sp->status =NULL;  
	 sp->prio_date_box =NULL; 
	 sp->edit_tree=NULL;

   
    yank_root_win(GTK_WINDOW(app)); 
   


    /*
     * main tree
     */
    
    scrolledwindow1 = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow1),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    /* gtk_widget_show will be called later */
/*     gtk_container_add(GTK_CONTAINER(hpaned), scrolledwindow1); */
		e_paned_add1(E_PANED(hpaned), scrolledwindow1);

    sp->note_tree = gtk_ctree_new_with_titles(1, 0, treetitle);
    gtk_widget_show(sp->note_tree);
    gtk_container_add(GTK_CONTAINER(scrolledwindow1), sp->note_tree);
    gtk_clist_set_column_width(GTK_CLIST(sp->note_tree), 0, 80);
    gtk_clist_set_column_auto_resize(GTK_CLIST(sp->note_tree), 0, TRUE);
    gtk_clist_set_row_height(GTK_CLIST(sp->note_tree), 19);
    gtk_clist_set_selection_mode(GTK_CLIST(sp->note_tree), GTK_SELECTION_EXTENDED);
    gtk_clist_set_reorderable(GTK_CLIST(sp->note_tree), TRUE);
    gtk_clist_set_use_drag_icons(GTK_CLIST(sp->note_tree), TRUE);
    gtk_clist_column_titles_show(GTK_CLIST(sp->note_tree));
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "tree_select_row",
                       GTK_SIGNAL_FUNC (note_tree_row_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "tree_unselect_row",
                       GTK_SIGNAL_FUNC (note_tree_row_unselected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "click_column",
                       GTK_SIGNAL_FUNC (cb_note_tree_col_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->note_tree), "drag_data_received",
		       GTK_SIGNAL_FUNC(cb_note_tree_reordered), NULL);
    /*
     * FIXME:
     * dnd on the note-tree disables reordering of notes by dnd
     */
/*     gtk_signal_connect(GTK_OBJECT(sp->note_tree), "drag_data_received", */
/*                        GTK_SIGNAL_FUNC(cb_note_tree_drop), NULL); */
/*     gtk_drag_dest_set(sp->note_tree, GTK_DEST_DEFAULT_MOTION | */
/*                       GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP, */
/*                       drop_types, n_drop_types, GDK_ACTION_COPY); */

    sp->notebook = gtk_notebook_new();
    gtk_notebook_set_show_tabs(GTK_NOTEBOOK(sp->notebook), FALSE);
    gtk_notebook_set_show_border(GTK_NOTEBOOK(sp->notebook), FALSE);
    gtk_widget_show(sp->notebook);
/*     gtk_container_add(GTK_CONTAINER(hpaned), sp->notebook); */
		e_paned_add2(E_PANED(hpaned), sp->notebook);

    /*
     * todo-list
     */
    
    scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow2),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_widget_show(scrolledwindow2);
    gtk_container_add(GTK_CONTAINER(sp->notebook), scrolledwindow2);
    
    sp->todolist = gtk_clist_new_with_titles(4, todotitles);
    gtk_signal_connect(GTK_OBJECT(sp->todolist), "select_row",
                       GTK_SIGNAL_FUNC (cb_todo_row_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->todolist), "click_column",
                       GTK_SIGNAL_FUNC (cb_todo_col_selected), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->todolist), "drag_data_received",
                       GTK_SIGNAL_FUNC(cb_todo_list_drop), NULL);
    gtk_drag_dest_set(sp->todolist, GTK_DEST_DEFAULT_MOTION |
                      GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
                      drop_types, n_drop_types, GDK_ACTION_COPY);    
    gtk_widget_show(sp->todolist);
    gtk_container_add(GTK_CONTAINER(scrolledwindow2), sp->todolist);
    gtk_clist_column_titles_show(GTK_CLIST(sp->todolist));
    gtk_clist_set_column_auto_resize(GTK_CLIST(sp->todolist), 0 , TRUE);
    gtk_clist_set_column_auto_resize(GTK_CLIST(sp->todolist), 3 , TRUE);
    gtk_clist_set_column_justification(GTK_CLIST(sp->todolist), 1,
                                       GTK_JUSTIFY_RIGHT);
    gtk_clist_set_column_justification(GTK_CLIST(sp->todolist), 2,
                                       GTK_JUSTIFY_RIGHT);
    

    /*
     * text/ data
     */
    
    vbox = gtk_vbox_new(FALSE, 3);
    gtk_widget_show(vbox);
    gtk_container_add(GTK_CONTAINER (sp->notebook), vbox);
    
    hbox = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox);
    gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 3);

    sp->prio_date_box = gtk_vbox_new(FALSE, 3);
    gtk_widget_show(sp->prio_date_box);
    gtk_box_pack_start(GTK_BOX(vbox), sp->prio_date_box, FALSE, FALSE, 0);
    
    hbox_ext_flags = gui_ext_flags();
    gtk_box_pack_start(GTK_BOX(vbox), hbox_ext_flags, FALSE, FALSE, 3);

    label = gtk_label_new(_("Title:"));
    font = gtk_widget_get_style(label)->font;
    gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
    gtk_widget_show(label);
    gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5);

    sp->title_entry = gtk_entry_new();
    gtk_widget_set_usize(sp->title_entry, -1, gdk_string_height(font, "W") + 10);
    gtk_widget_show(sp->title_entry);
    gtk_box_pack_start(GTK_BOX(hbox), sp->title_entry, TRUE, TRUE, 5);

    sp->todo_check = gtk_check_button_new_with_label(_("Done"));
    gtk_widget_set_usize(sp->todo_check, -1, gdk_string_height(font, "W") + 10);
    gtk_widget_show(sp->todo_check);
    gtk_box_pack_start(GTK_BOX(hbox), sp->todo_check, FALSE, FALSE, 5);

    /*
     * button for extra flags& data
     */
    
    b_toggle_ext_flags = gtk_button_new();
    {
        GtkWidget *p_up;
        GtkWidget *p_down;
        GtkWidget *box;
        
        box = gtk_hbox_new(FALSE, 0);
        gtk_container_add(GTK_CONTAINER(b_toggle_ext_flags), box);
        gtk_widget_show(box);
        p_up = gnome_stock_pixmap_widget_at_size(
            GTK_WIDGET(yank_root_win(NULL)), GNOME_STOCK_BUTTON_UP, 12, 14);
        p_down = gnome_stock_pixmap_widget_at_size(
            GTK_WIDGET(yank_root_win(NULL)), GNOME_STOCK_BUTTON_DOWN, 12, 14);
        gtk_widget_hide(p_up);
        gtk_widget_show(p_down);
        gtk_container_add(GTK_CONTAINER(box), p_up);
        gtk_container_add(GTK_CONTAINER(box), p_down);
        gtk_object_set_data(GTK_OBJECT(b_toggle_ext_flags), "up", p_up);
        gtk_object_set_data(GTK_OBJECT(b_toggle_ext_flags), "down", p_down);
    }
    gtk_widget_show(b_toggle_ext_flags);
    gtk_box_pack_start(GTK_BOX(hbox), b_toggle_ext_flags, FALSE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(b_toggle_ext_flags), "clicked",
                       GTK_SIGNAL_FUNC(cb_toggle_ext_flags), hbox_ext_flags);
    
    /*
     * deadline/ prio/ complete
     */
    
    {
        GtkWidget *prio_hbox1;
        GtkWidget *prio_hbox2;
        GtkWidget *sc_complete;
        
        prio_hbox1 = gtk_hbox_new(FALSE, 0);
        gtk_widget_show(prio_hbox1);
        gtk_box_pack_start(GTK_BOX(sp->prio_date_box), prio_hbox1, FALSE, FALSE,
                           0);
        prio_hbox2 = gtk_hbox_new(FALSE, 0);
        gtk_widget_show(prio_hbox2);
        gtk_box_pack_start(GTK_BOX(sp->prio_date_box), prio_hbox2, FALSE, FALSE,
                           0);
        
        label = gtk_label_new(_("Deadline:"));
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), label, FALSE, FALSE, 5);
        sp->de_deadline = gnome_date_edit_new(0, 1, 1);
        gnome_date_edit_set_popup_range(GNOME_DATE_EDIT(sp->de_deadline), 0, 23);
        gtk_widget_set_sensitive(GNOME_DATE_EDIT(sp->de_deadline)->date_entry,
                                 FALSE);
        gtk_widget_set_sensitive(GNOME_DATE_EDIT(sp->de_deadline)->time_entry,
                                 FALSE);
        gtk_widget_show(sp->de_deadline);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), sp->de_deadline, FALSE, FALSE, 0);
        
        label = gtk_label_new(_("Priority:"));
        gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), label, FALSE, FALSE, 5);
        
        prio_adjust = gtk_adjustment_new(0, 0, 9999, 1, 10, 10);
        sp->prio_entry = gtk_spin_button_new(GTK_ADJUSTMENT(prio_adjust), 1, 0);
        /* NOTE: this is note 100% ok */
        gtk_widget_set_usize(GTK_WIDGET(sp->prio_entry),
                             gdk_string_width(font, "999999") + 10,
                             gdk_string_height(font, "W") + 10);
        gtk_widget_show(sp->prio_entry);
        gtk_box_pack_start(GTK_BOX(prio_hbox1), sp->prio_entry, FALSE, FALSE, 0);
        
        label = gtk_label_new(_("Complete:"));
        gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox2), label, FALSE, FALSE, 5);
        
        sp->ad_complete = gtk_adjustment_new(0, 0, 101, 1, 1, 1);
        sc_complete = gtk_hscale_new(GTK_ADJUSTMENT(sp->ad_complete));
        gtk_scale_set_digits(GTK_SCALE(sc_complete), 0);
        gtk_scale_set_value_pos(GTK_SCALE(sc_complete), GTK_POS_LEFT);
        gtk_widget_show(sc_complete);
        gtk_box_pack_start(GTK_BOX(prio_hbox2), sc_complete, TRUE, TRUE, 5);

        label = gtk_label_new(_("%"));
        gtk_widget_set_usize(label, -1, gdk_string_height(font, "W") + 10);
        gtk_widget_show(label);
        gtk_box_pack_start(GTK_BOX(prio_hbox2), label, FALSE, FALSE, 5);
        
    }
    
    /*
     * additional note data
     */

    sp->note_id_entry = gtk_entry_new();
/*     gtk_widget_show(sp->note_id_entry); */
    gtk_widget_hide(sp->note_id_entry);
    gtk_box_pack_start(GTK_BOX(hbox), sp->note_id_entry, FALSE, FALSE, 5);

    /*
     * note text
     */
    
    scrolledwindow3 = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolledwindow3),
                                   GTK_POLICY_AUTOMATIC,
                                   GTK_POLICY_AUTOMATIC);
    gtk_widget_show(scrolledwindow3);
    gtk_box_pack_start(GTK_BOX(vbox), scrolledwindow3, TRUE, TRUE, 0);
                       
    sp->text_entry = gtk_text_new(NULL, NULL);
    gtk_text_set_editable(GTK_TEXT(sp->text_entry), TRUE);
    gtk_widget_show(sp->text_entry);
    gtk_container_add(GTK_CONTAINER(scrolledwindow3), sp->text_entry);

    /* text dnd */
    gtk_signal_connect(GTK_OBJECT(sp->text_entry), "drag_data_received",
                       GTK_SIGNAL_FUNC(cb_text_entry_drop), NULL);
    gtk_drag_dest_set(sp->text_entry, GTK_DEST_DEFAULT_MOTION |
                      GTK_DEST_DEFAULT_HIGHLIGHT | GTK_DEST_DEFAULT_DROP,
                      drop_types, n_drop_types, GDK_ACTION_COPY);

    hbox3 = gtk_hbox_new(FALSE, 0);
    gtk_widget_show(hbox3);
    gtk_box_pack_start(GTK_BOX(vbox), hbox3, FALSE, FALSE, 3);

    sp->b_ok = gnome_stock_button(GNOME_STOCK_BUTTON_OK);
    gtk_widget_show(sp->b_ok);
    gtk_box_pack_start(GTK_BOX(hbox3), sp->b_ok, TRUE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(sp->b_ok), "clicked",
                       GTK_SIGNAL_FUNC(cb_b_ok), NULL);

    sp->b_apply = gnome_stock_button(GNOME_STOCK_BUTTON_APPLY);
    gtk_widget_show(sp->b_apply);
    gtk_box_pack_start(GTK_BOX(hbox3), sp->b_apply, TRUE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(sp->b_apply), "clicked",
                       GTK_SIGNAL_FUNC(cb_b_apply), NULL);
        
    sp->b_cancel = gnome_stock_button(GNOME_STOCK_BUTTON_CANCEL);
    gtk_widget_show(sp->b_cancel);
    gtk_box_pack_start(GTK_BOX(hbox3), sp->b_cancel, TRUE, FALSE, 5);
    gtk_signal_connect(GTK_OBJECT(sp->b_cancel), "clicked",
                       GTK_SIGNAL_FUNC(cb_b_cancel), NULL);

    /*
     * a bit suboptimal
     */
    
    gtk_signal_connect(GTK_OBJECT(sp->title_entry), "changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->de_deadline), "date-changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->de_deadline), "time-changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->tlabel_expire), "time_changed",
		       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->prio_entry), "changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->ad_complete), "value_changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->ad_complete), "value_changed",
                       GTK_SIGNAL_FUNC(cb_complete_updates_done), sp->todo_check);
    gtk_signal_connect(GTK_OBJECT(sp->todo_check), "toggled",
                       GTK_SIGNAL_FUNC(note_changed), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->text_entry), "changed",
                       GTK_SIGNAL_FUNC(note_changed), NULL);

    /*
     * keyboard-control
     */
    
    gtk_signal_connect(GTK_OBJECT(sp->title_entry), "activate",
                       GTK_SIGNAL_FUNC(cb_finished_note), NULL);
    gtk_signal_connect(GTK_OBJECT(sp->text_entry), "activate",
                       GTK_SIGNAL_FUNC(cb_finished_note), NULL);

    /*
     * create pixmaps
     */
    
    pix_text_xpm = gnome_pixmap_new_from_xpm_d(text_xpm);
    gtk_widget_show(pix_text_xpm);
    pix_box_xpm = gnome_pixmap_new_from_xpm_d(box_xpm);
    gtk_widget_show(pix_box_xpm);
    pix_box2_xpm = gnome_pixmap_new_from_xpm_d(box2_xpm);
    gtk_widget_show(pix_box2_xpm);
    pix_circle_xpm = gnome_pixmap_new_from_xpm_d(circle_xpm);
    gtk_widget_show(pix_circle_xpm);
    pix_circle2_xpm = gnome_pixmap_new_from_xpm_d(circle2_xpm);
    gtk_widget_show(pix_circle2_xpm);

    /*
     * menus
     */
    
/*     gnome_app_set_contents(GNOME_APP(app), hpaned); */
/*     sp->status = gnome_appbar_new(FALSE, TRUE, GNOME_PREFERENCES_USER); */
/*     gnome_app_set_statusbar(GNOME_APP(app), sp->status); */
/*     yank_install_menus_and_toolbar(app); */
    yank_tree_item_context_menu(sp->note_tree);
    yank_todo_item_context_menu(sp->todolist);
    yank_text_item_context_menu(sp->title_entry);
    yank_text_item_context_menu(sp->text_entry);
    
/*     gtk_signal_connect(GTK_OBJECT(app), "delete_event", */
/*                        GTK_SIGNAL_FUNC(cb_delete_event), NULL); */

    /*
     * initialize preferences
     * also preloads plugins
     */
    
    load_preferences();
    prefs = get_preferences();

    gtk_text_set_word_wrap(GTK_TEXT(sp->text_entry), prefs->wordwrap);
    gtk_text_set_line_wrap(GTK_TEXT(sp->text_entry), prefs->linewrap);
    
    
/*     if (prefs->yank_width * prefs->yank_height) */
/*     { */
/*         gtk_window_set_default_size(GTK_WINDOW(app), prefs->yank_width, */
/*                                     prefs->yank_height); */
/*     } */
/*     else */
/*     { */
/*         gtk_window_set_default_size(GTK_WINDOW(app), 600, 400); */
/*     } */
    
    if (prefs->use_custom_font)
    {
	if (prefs->note_font)
        {
	    set_note_font_str(prefs->note_font);
	}
	if (prefs->note_tree_font)
	{
	    set_note_tree_font_str(prefs->note_tree_font);
        }
        if (prefs->todolist_font)
        {
            set_todolist_font_str(prefs->todolist_font);
        }
    }
    else
    {
        set_default_font();
    }
    
    
    /*
     * parse geometry if given
     */
    
/*     if (geometry != NULL) */
/*     { */
/*         gint x, y, w, h; */
/*         if (gnome_parse_geometry(geometry, &x, &y, &w, &h )) */
/*         { */
/*             if (x != -1) */
/*             { */
/*                 gtk_widget_set_uposition(app, x, y); */
/*             } */
/*              */
/*             if (w != -1) */
/*             { */
/*                 gtk_window_set_default_size(GTK_WINDOW(app), w, h); */
/*             } */
/*         } */
/*         else */
/*         { */
/*             g_error(_("Could not parse geometry string `%s'"), geometry); */
/*         } */
/*     } */
/*      */
/*     if (prefs->note_tree_width) */
/*     { */
/*         gtk_widget_set_usize(scrolledwindow1, prefs->note_tree_width, -1); */
/*     } */
/*     else */
/*     { */
/*         gtk_widget_set_usize(scrolledwindow1, 200, -1); */
/*     } */
/*     gtk_widget_show(scrolledwindow1); */

    /*
     * try to read files from killed sessions
     */

/*     got_crash = get_crash_file(); */
    
    
    /*
     * load file from the command-line
     */
    
/*     if (file != NULL && ! got_crash) */
/*     { */
/*         load_notes_from_cli((gchar *)file, GTK_CTREE(sp->note_tree), NULL); */
/*     } */

    /*
     * read default file
     */
    
/*     if (file == NULL && ! got_crash) */
/*     { */
/*         get_def_file(); */
/*     } */
    
    /*
     * register some signal-handlers
     */

/*     if (signal(SIGTERM, handle_sigterm) == SIG_ERR) */
/*     { */
/*         g_warning("Can't handle SIGTERM"); */
/*     } */
/*     if (signal(SIGCHLD, handle_sigchild) == SIG_ERR) */
/*     { */
/*         g_warning("Can't handle SIGCHILD"); */
/*     } */
/*     if (signal(SIGPIPE, handle_sigpipe) == SIG_ERR) */
/*     { */
/*         g_warning("Can't handle SIGPIPE"); */
/*     } */

    /*
     * init autosave
     */
    
/*     if (prefs->auto_save_minutes) */
/*     { */
/*         autosave_notes(NULL); */
/*     } */
    
    return (hpaned);
}
コード例 #10
0
ファイル: gpicview.c プロジェクト: proudzhu/gpicview
int main(int argc, char *argv[])
{
    GError *error = NULL;
    GOptionContext *context;
    MainWin* win;

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

    context = g_option_context_new ("- simple image viewer");
    g_option_context_add_main_entries (context, opt_entries, GETTEXT_PACKAGE);
    g_option_context_add_group (context, gtk_get_option_group (TRUE));
    if ( !g_option_context_parse (context, &argc, &argv, &error) )
    {
        g_print( "option parsing failed: %s\n", error->message);
        return 1;
    }

    if( should_display_version )
    {
        printf( "gpicview %s\n", VERSION );
        return 0;
    }

    gtk_icon_theme_append_search_path(gtk_icon_theme_get_default(), PIXMAP_DIR);

    load_preferences();

    /* Allocate and show the window.
     * We must show the window now in case the file open needs to put up an error dialog. */
    win = (MainWin*)main_win_new();
    gtk_widget_show( GTK_WIDGET(win) );

    if ( pref.open_maximized )
        gtk_window_maximize( (GtkWindow*)win );

    // FIXME: need to process multiple files...
    if( files )
    {
        if( G_UNLIKELY( *files[0] != '/' && strstr( files[0], "://" )) )    // This is an URI
        {
            char* path = g_filename_from_uri( files[0], NULL, NULL );
            main_win_open( win, path, ZOOM_NONE );
            g_free( path );
        }
        else
            main_win_open( win, files[0], ZOOM_NONE );

        if (should_start_slideshow)
            main_win_start_slideshow ( win );
    }
    else
    {
        main_win_open( win, ".", ZOOM_NONE );
    }

    gtk_main();

    save_preferences();

    return 0;
}