Пример #1
0
void 
init_ASWallpaper()
{
	memset( &WallpaperState, 0x00, sizeof(ASWallpaperState));
	
	create_main_window(); 
	create_backs_list();
	create_list_preview();
	
	WallpaperState.sel_apply_button = asgtk_add_button_to_box( NULL, GTK_STOCK_APPLY, NULL, G_CALLBACK(on_list_apply_clicked), WallpaperState.backs_list );
	WallpaperState.make_xml_button = asgtk_add_button_to_box( NULL, GTK_STOCK_PROPERTIES, "Make XML", G_CALLBACK(on_make_xml_clicked), WallpaperState.backs_list );
	WallpaperState.edit_xml_button = asgtk_add_button_to_box( NULL, GTK_STOCK_PROPERTIES, "Edit XML", G_CALLBACK(on_edit_xml_clicked), WallpaperState.backs_list );
	WallpaperState.make_mini_button = asgtk_add_button_to_box( NULL, GTK_STOCK_PROPERTIES, "Make mini", G_CALLBACK(on_make_mini_clicked), WallpaperState.backs_list );
	
	WallpaperState.sel_del_button = asgtk_add_button_to_box( NULL, GTK_STOCK_DELETE, NULL, G_CALLBACK(on_list_del_clicked), WallpaperState.backs_list );

	gtk_widget_hide(WallpaperState.edit_xml_button);

	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.sel_apply_button, 0 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.make_mini_button, 5 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.make_xml_button, 5 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.edit_xml_button, 5 );
	asgtk_image_view_add_tool( ASGTK_IMAGE_VIEW(WallpaperState.list_preview), WallpaperState.sel_del_button, 5 );
	
	asgtk_image_dir_set_sel_handler( ASGTK_IMAGE_DIR(WallpaperState.backs_list), backs_list_sel_handler, WallpaperState.list_preview);

	reload_private_backs_list();

	g_signal_connect (G_OBJECT (WallpaperState.main_window), "destroy", G_CALLBACK (on_destroy), NULL);
  	gtk_widget_show (WallpaperState.main_window);
}	 
Пример #2
0
/*  public functions  */
GtkWidget * 
asgtk_gradient_new ()
{
	ASGtkGradient *ge;
    GtkWidget *main_vbox, *main_hbox;
	GtkWidget *scrolled_window ;
	GtkWidget *list_vbox ;
	GtkWidget *frame, *hbox, *vbox, *btn, *table;
	GtkWidget *label ; 

    ge = g_object_new (ASGTK_TYPE_GRADIENT, NULL);
	colorize_gtk_window( GTK_WIDGET(ge) );	
	gtk_container_set_border_width( GTK_CONTAINER (ge), 5 );
	
	main_vbox = GTK_DIALOG(ge)->vbox ; 

	main_hbox = gtk_hbox_new (FALSE, 5);
  	gtk_widget_show (main_hbox);
	gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, TRUE, TRUE, 0);
	
	list_vbox = gtk_vbox_new (FALSE, 0);
	gtk_box_pack_start (GTK_BOX (main_hbox), list_vbox, FALSE, FALSE, 0);

	frame = gtk_frame_new("Gradient direction : ");
	gtk_box_pack_start (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5);
	
	table = gtk_table_new( 2, 2, FALSE );
	gtk_container_add (GTK_CONTAINER (frame), table);
	gtk_container_set_border_width (GTK_CONTAINER (table), 3);

	ge->l2r_radio = gtk_radio_button_new_with_label( NULL, "Left to Right" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->l2r_radio, 0, 1, 0, 1);
	ge->t2b_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->l2r_radio), "Top to Bottom" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->t2b_radio, 0, 1, 1, 2);
	ge->tl2br_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->t2b_radio), "Top-Left to Bottom-Right" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->tl2br_radio, 1, 2, 0, 1);
	ge->bl2tr_radio = gtk_radio_button_new_with_label_from_widget( GTK_RADIO_BUTTON(ge->tl2br_radio), "Bottom-Left to Top-Right" );
	gtk_table_attach_defaults (GTK_TABLE (table), ge->bl2tr_radio, 1, 2, 1, 2);
	gtk_widget_show_all (table);
	gtk_widget_show (table);
	colorize_gtk_widget( frame, get_colorschemed_style_normal() );

	g_signal_connect ((gpointer) ge->l2r_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);
	g_signal_connect ((gpointer) ge->tl2br_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);
	g_signal_connect ((gpointer) ge->t2b_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);
	g_signal_connect ((gpointer) ge->bl2tr_radio, "clicked", G_CALLBACK (on_direction_clicked), ge);


	ge->screen_width_check = gtk_check_button_new_with_label("Use screen width");
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_width_check), TRUE );
	ge->width_entry = gtk_spin_button_new_with_range( 1, 10000, 1 );
	gtk_widget_set_sensitive( ge->width_entry, FALSE );
	ge->screen_height_check = gtk_check_button_new_with_label("Use screen height");
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(ge->screen_height_check), TRUE );
	ge->height_entry = gtk_spin_button_new_with_range( 1, 10000, 1 );
	gtk_widget_set_sensitive( ge->height_entry, FALSE );

   	g_signal_connect ((gpointer) ge->screen_width_check, "clicked", G_CALLBACK (on_size_clicked), ge);
	g_signal_connect ((gpointer) ge->screen_height_check, "clicked", G_CALLBACK (on_size_clicked), ge);


	ge->size_frame = gtk_frame_new("Rendered gradient size : ");
	gtk_box_pack_start (GTK_BOX (list_vbox), ge->size_frame, FALSE, FALSE, 5);
	colorize_gtk_tree_view_window( GTK_WIDGET(ge->size_frame) );

	table = gtk_table_new( 2, 4, FALSE );
	gtk_container_set_border_width( GTK_CONTAINER (table), 3 );
	gtk_container_add( GTK_CONTAINER(ge->size_frame), table );

	gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Width : "), 0, 1, 0, 1);   
	gtk_table_attach_defaults (GTK_TABLE (table), ge->width_entry, 1, 2, 0, 1);   
	gtk_table_attach_defaults (GTK_TABLE (table), gtk_label_new("Height : "), 2, 3, 0, 1);   
	gtk_table_attach_defaults (GTK_TABLE (table), ge->height_entry, 3, 4, 0, 1);  
	gtk_table_attach (GTK_TABLE (table), ge->screen_width_check, 0, 2, 1, 2, GTK_FILL, GTK_FILL, 10, 0);    
	gtk_table_attach (GTK_TABLE (table), ge->screen_height_check, 2, 4, 1, 2, GTK_FILL, GTK_FILL, 10, 0);    
	
	gtk_widget_show_all (table);
	gtk_widget_show (table);
	colorize_gtk_widget( ge->size_frame, get_colorschemed_style_normal() );

	scrolled_window = asgtk_gradient_create_color_list( ge );
	gtk_box_pack_start (GTK_BOX (list_vbox), scrolled_window, FALSE, FALSE, 0);
	
	ge->color_entry = gtk_entry_new_with_max_length(24);
	gtk_entry_set_width_chars( GTK_ENTRY(ge->color_entry), 16 );
#if 0
	ge->color_preview = gtk_color_button_new();
	g_signal_connect ((gpointer) ge->color_preview, "clicked", G_CALLBACK (on_color_preview_clicked), ge);
#else
	ge->color_preview = gtk_image_new();
	update_color_preview( ge, DEFAULT_COLOR_STR );
#endif

	ge->offset_entry = gtk_spin_button_new_with_range( 0., 1., 0.05 );


	frame = gtk_frame_new("Change point attributes : ");
	gtk_box_pack_end (GTK_BOX (list_vbox), frame, FALSE, FALSE, 5);
	colorize_gtk_tree_view_window( GTK_WIDGET(frame) );

	vbox = gtk_vbox_new( FALSE, 5 );			   
	gtk_container_add( GTK_CONTAINER(frame), vbox );
	
	table = gtk_table_new( 4, 2, FALSE );
	gtk_container_set_border_width( GTK_CONTAINER (table), 3 );


//	hbox = gtk_hbox_new( FALSE, 5 );			   
//	gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 );
	gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
	label = gtk_label_new("Color : ");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
    gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 1, 0, 1);   	
	label = gtk_label_new("Offset : ");
	gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT);
	gtk_table_attach_defaults (GTK_TABLE (table), label, 2, 3, 0, 1);   	   
	gtk_table_attach (GTK_TABLE (table), ge->color_entry, 1, 2, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2);   	   
	gtk_table_attach (GTK_TABLE (table), ge->offset_entry, 3, 4, 0, 1, GTK_SHRINK, GTK_SHRINK, 2, 2);

	frame = gtk_frame_new(NULL);
	colorize_gtk_tree_view_window( GTK_WIDGET(frame) );
	gtk_widget_set_size_request( frame, COLOR_PREVIEW_WIDTH, COLOR_PREVIEW_HEIGHT );
	gtk_container_set_border_width( GTK_CONTAINER (table), 0 );
	gtk_container_add( GTK_CONTAINER(frame), ge->color_preview );
	gtk_widget_show( ge->color_preview );
	
	btn = gtk_button_new();
	gtk_container_set_border_width( GTK_CONTAINER (btn), 0 );
	//btn = gtk_button_new_with_label(" Color selector ");
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_container_add (GTK_CONTAINER (btn), frame);
	gtk_widget_show (frame);
	g_signal_connect ((gpointer) frame, "size-allocate",
                       G_CALLBACK (color_preview_size_alloc), ge);

	gtk_table_attach (GTK_TABLE (table), btn, 0, 2, 1, 2, GTK_FILL, GTK_SHRINK, 2, 2);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_color_clicked), ge);	
	
	gtk_widget_show_all (table);
	gtk_widget_show (table);

	hbox = gtk_hbox_new( FALSE, 5 );			   
	gtk_container_set_border_width( GTK_CONTAINER (hbox), 3 );
	gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
	
	ge->delete_btn = btn = gtk_button_new_from_stock(GTK_STOCK_DELETE);
	gtk_widget_set_sensitive( ge->delete_btn, FALSE );
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_delete_point_clicked), ge);	   
	
	btn = gtk_button_new_from_stock(GTK_STOCK_ADD);
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_add_point_clicked), ge);	   
	
	ge->apply_btn = btn = gtk_button_new_from_stock(GTK_STOCK_APPLY);
	gtk_widget_set_sensitive( ge->apply_btn, FALSE );
	colorize_gtk_widget( GTK_WIDGET(btn), get_colorschemed_style_button());
	gtk_box_pack_end (GTK_BOX (hbox), btn, FALSE, FALSE, 0);
	g_signal_connect ((gpointer) btn, "clicked", G_CALLBACK (on_apply_point_clicked), ge);	   

	gtk_widget_show_all (hbox);
	gtk_widget_show (hbox);

	/* The preview : */
	ge->image_view = ASGTK_IMAGE_VIEW(asgtk_image_view_new());
	gtk_widget_set_size_request (GTK_WIDGET(ge->image_view), PREVIEW_WIDTH, PREVIEW_HEIGHT);
	gtk_box_pack_end (GTK_BOX (main_hbox), GTK_WIDGET(ge->image_view), TRUE, TRUE, 0);
	asgtk_image_view_set_aspect ( ge->image_view,
							   	  get_screen_width(NULL), get_screen_height(NULL) );
	asgtk_image_view_set_resize ( ge->image_view, 
								  ASGTK_IMAGE_VIEW_SCALE_TO_VIEW|
							 	  ASGTK_IMAGE_VIEW_TILE_TO_ASPECT, 
								  ASGTK_IMAGE_VIEW_RESIZE_ALL );



  	gtk_widget_show_all (list_vbox);
  	gtk_widget_show_all (main_hbox);
	gtk_widget_hide(ge->image_view->details_label);
	
	btn = gtk_check_button_new_with_label( "Use screen aspect ratio" );
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE );
	gtk_widget_show (btn);
	colorize_gtk_widget( btn, get_colorschemed_style_normal() );  
	g_signal_connect (G_OBJECT (btn), "toggled",
	              	  G_CALLBACK (asgtk_image_view_screen_aspect_toggle), (gpointer) ge->image_view);
	gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5);
	asgtk_image_view_add_detail( ge->image_view, btn, 0 );

	btn = gtk_check_button_new_with_label( "Scale to fit this view" );
	gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON(btn), TRUE );
	gtk_widget_show (btn);
	colorize_gtk_widget( btn, get_colorschemed_style_normal() );  
	g_signal_connect (G_OBJECT (btn), "toggled",
	              	  G_CALLBACK (asgtk_image_view_scale_to_view_toggle), (gpointer) ge->image_view);
	gtk_button_set_alignment( GTK_BUTTON(btn), 1.0, 0.5);
	asgtk_image_view_add_detail( ge->image_view, btn, 0 );

	btn = asgtk_add_button_to_box( NULL, GTK_STOCK_REFRESH, NULL, G_CALLBACK(on_refresh_clicked), ge );
	asgtk_image_view_add_tool( ge->image_view, btn, 3 );


	LOCAL_DEBUG_OUT( "created image ASGtkGradient object %p", ge );	
	return GTK_WIDGET (ge);
}