예제 #1
0
void save_default(void)
{
    extern char *rcfile;
    extern gboolean rcfile_saved;
    extern GtkWidget *sitecopy;

    if (rcfile == NULL) {
	gnome_app_error(GNOME_APP(sitecopy), "The current rcfile is set to NULL. Sites will not be saved. Contact the maintainer.");
	return;
    }
    if (rcfile_write(rcfile, all_sites) == 0) {
	gchar *tmp;
	tmp = g_strdup_printf("Site definitions saved to %s.", rcfile);
	gfe_status(tmp);
	g_free(tmp);
    } else {
	gnome_error_dialog("There was an error writing the site definitions.\n They may not have saved correctly.");
    }
    rcfile_saved = true;
}
예제 #2
0
파일: app.c 프로젝트: goedson/old-gnotime
void
app_new(int argc, char *argv[], const char *geometry_string)
{
	GtkWidget *vbox;
	GtkWidget *widget;
	GtkWidget *vpane;
	GtkWidget *separator;
	GtkLabel *filler;
	GtkHBox *labels;
	GtkVBox *status_vbox;
	GtkStatusbar *grip;

	app_window = gnome_app_new(GTT_APP_NAME, GTT_APP_TITLE " " VERSION);
	gtk_window_set_wmclass(GTK_WINDOW(app_window),
	                         GTT_APP_NAME, GTT_APP_PROPER_NAME);

	/* 485 x 272 seems to be a good size to default to */
	gtk_window_set_default_size(GTK_WINDOW(app_window), 485, 272);
	gtk_window_set_resizable (GTK_WINDOW(app_window), TRUE);

	/* build menus */
	menus_create(GNOME_APP(app_window));

	/* build toolbar */
	widget = build_toolbar();
	gtk_widget_show(widget);
	gnome_app_set_toolbar(GNOME_APP(app_window), GTK_TOOLBAR(widget));

	/* container holds status bar, main ctree widget */
	vbox = gtk_vbox_new(FALSE, 0);

	/* build statusbar */

	status_vbox = GTK_VBOX(gtk_vbox_new(FALSE, 0));
	gtk_widget_show(GTK_WIDGET(status_vbox));

	labels = GTK_HBOX(gtk_hbox_new(FALSE, 0));
	gtk_widget_show(GTK_WIDGET(labels));

	status_bar = gtk_hbox_new(FALSE, 0);
	gtk_widget_show(status_bar);
	separator = gtk_hseparator_new();
	gtk_widget_show(separator);
	gtk_box_pack_start(GTK_BOX(status_vbox), separator, FALSE, FALSE, 0);
	gtk_box_pack_start(GTK_BOX(status_vbox), GTK_WIDGET (labels), TRUE, TRUE, 0);
	gtk_box_pack_start(GTK_BOX(status_bar), GTK_WIDGET (status_vbox), TRUE, TRUE, 0);

	grip = GTK_STATUSBAR(gtk_statusbar_new());
	gtk_statusbar_set_has_resize_grip(grip, TRUE);
	gtk_widget_show(GTK_WIDGET(grip));
	gtk_box_pack_start(GTK_BOX(status_bar), GTK_WIDGET(grip), FALSE, FALSE, 0);

	/* put elapsed time into statusbar */
	status_day_time = GTK_LABEL(gtk_label_new(_("00:00")));
	gtk_widget_show(GTK_WIDGET(status_day_time));

	gtk_box_pack_start(GTK_BOX(labels), GTK_WIDGET(status_day_time),
	                     FALSE, TRUE, 0);

	/* put project name into statusbar */
	status_project = GTK_LABEL(gtk_label_new( _("Timer is not running")));
	gtk_widget_show(GTK_WIDGET(status_project));

	gtk_box_pack_start(GTK_BOX(labels), GTK_WIDGET(status_project),
	                     FALSE, TRUE, 10);

	filler = GTK_LABEL(gtk_label_new(""));
	gtk_widget_show(GTK_WIDGET(filler));
	gtk_box_pack_start(GTK_BOX(labels), GTK_WIDGET(filler), TRUE, TRUE, 1);

	/* put timer icon into statusbar */
	status_timer = gtk_image_new_from_stock (GNOME_STOCK_TIMER,
	                                           GTK_ICON_SIZE_MENU);
	gtk_widget_show(status_timer);
	gtk_box_pack_end(GTK_BOX(status_bar), GTK_WIDGET(status_timer),
	                   FALSE, FALSE, 1);

	/* create the main columned tree for showing projects */
	projects_tree = gtt_projects_tree_new ();

	g_signal_connect (projects_tree, "columns-setup-done", G_CALLBACK (projects_tree_columns_setup_done), NULL);

	gtk_tree_view_set_reorderable (GTK_TREE_VIEW (projects_tree), TRUE);

	g_signal_connect (projects_tree, "row-activated", G_CALLBACK (projects_tree_row_activated), NULL);

	/* create the notes area */
	global_na = notes_area_new();
	vpane = notes_area_get_widget (global_na);

	/* Need to reparent, to get rid of glade parent-window hack.
	 * But gtk_widget_reparent (vpane); causes  a "Gtk-CRITICAL"
	 * to occur.  So we need a fancier move.
	 */
	gtk_widget_ref (vpane);
	gtk_container_remove(GTK_CONTAINER(vpane->parent), vpane);
	gtk_box_pack_start(GTK_BOX(vbox), vpane, TRUE, TRUE, 0);
	gtk_widget_unref (vpane);

	gtk_box_pack_end(GTK_BOX(vbox), status_bar, FALSE, FALSE, 2);

	notes_area_add_projects_tree (global_na, projects_tree);

	/* we are done building it, make it visible */
	gtk_widget_show(vbox);
	gnome_app_set_contents(GNOME_APP(app_window), vbox);

	gtt_status_icon_create();
	if (!geometry_string) return;

	if (gtk_window_parse_geometry(GTK_WINDOW(app_window),geometry_string))
	{
		geom_size_override=TRUE;
	}
	else
	{
		gnome_app_error(GNOME_APP(app_window),
			_("Couldn't understand geometry (position and size)\n"
			  " specified on command line"));
	}
}