Public feed #529302

Live Segment

public text v1 · immutable
Raw Edit
·published 2007-06-01 21:30 UTC
rendered paste body
deferred class LIVE_SEGMENT_TREE

insert
    COMMONS
    GTK_TARGET_FLAGS

feature -- Widgets

	pix_col_n: INTEGER is 2
	text_col_n: INTEGER is 3

	live_segment_model: GTK_LIST_STORE is
			-- live segment icon model with thumbnails
		once
			create Result.make (<<g_type_int, g_type_int,
			                      gdk_type_pixbuf, g_type_string,
			                      gdk_type_pixbuf, g_type_string,
			                      gdk_type_pixbuf, g_type_string>>)
		ensure
			Result /= Void
		end -- live_segment_model

	live_segment_view: GTK_ICON_VIEW is
			-- live_segment_icon view
		once
			create Result.with_model (live_segment_model)
			Result.set_pixbuf_column (pix_col_n)
			Result.set_text_column (text_col_n)
			Result.set_item_width (40)
		ensure
			Result /= Void
		end

    segment_area: GTK_VBOX is
            -- the live thumbnail view
        once
            Result := glade_xml.get_vbox ("segment_area_vbox")
        ensure
            Result /= Void
        end -- segment_area

    live_current_slide_image: GTK_IMAGE is
            -- an large image of what is being displayed
        once
            Result := glade_xml.get_image ("live_current_slide_image")
        ensure
            Result /= Void
        end -- live_current_slide_image

feature -- Callbacks

    on_live_segment_model_row_inserted (a_path: GTK_TREE_PATH; an_iter: GTK_TREE_ITER; a_model: GTK_TREE_MODEL) is
		do
			debug print ("live_segment_tree: row_inserted%N") end
		end

	on_live_segment_model_row_deleted (a_path: GTK_TREE_PATH; a_model: GTK_TREE_MODEL) is
		do
			debug print ("live_segment_tree: row_deleted%N") end
		end

feature -- Workaround

	live_segment_delete_filename: STRING is
		once
			Result := (path_to_images / "bin_delete.png").to_string
		ensure
			Result /= Void
		end

	is_live_segment_dragged: BOOLEAN

--feature

--    create_segment_view (new_position: INTEGER) is
--        local
--            expander: GTK_EXPANDER
--            iconview: GTK_ICON_VIEW
--        do
            -- This should just transfer the slide positions from Service Builder
            -- to the thumbnail view instead of creating new segments and slides.
            -- Once in Live the user can then select just about any slide with 
            -- very little effort.
--            debug print ("insert_segment_thumbnails%N") end
--            create expander.make ("expander_label")
--            create iconview.make
--            expander.add (iconview)
--            segment_area.pack_start (expander, False, False, 0)
--            segment_area.reorder_child (expander, new_position)
--        end -- insert_segment_thumbnails

--    on_any_thumbnail_clicked is
--        local
--            segment: SEGMENT
--        do
            -- check to see if spicerack is in Fullscreen mode
            -- if so then when a thumbnail is clicked it will act as "Next"
            -- if not then the large image will change to the selected slide
--            if on_live_golive_clicked then on_live_next_clicked
--            else live_current_slide_image:= segment.default_thumbnail end
--        end

feature {} -- Update

    live_segment_update is
            -- Fills live segment model with service builder slides
        local
            live_iter: GTK_TREE_ITER
            slides: ITERATOR [VAULT_ITEM]
            thumbnail: MEDIA_IMAGE
			pixbuf: GDK_PIXBUF
			curr: VAULT_ITEM
			title: STRING
		do
			live_segment_model.clear
			create live_iter.from_model (live_segment_model)
			if global_service.service /= Void and then global_service.service.bin /= Void then
				debug print ("live_segment_tree: live_segment_update: antes de True: " + live_segment_view.is_sensitive.out + "%N") end
				live_segment_view.set_sensitive (True)
				debug print ("live_segment_tree: live_segment_update: despues de True: " + live_segment_view.is_sensitive.out + "%N") end
				from
					slides := global_service.service.bin.new_iterator_on_items
				until
					slides.is_off
				loop
					curr := slides.item
					live_segment_model.append (live_iter)
					thumbnail := curr.thumbnail
					title := curr.title
					create pixbuf.from_file_at_size (thumbnail.path.to_string, 32, 32)
						check pixbuf.is_valid end
					live_segment_model.set_pixbuf_and_string (live_iter, pixbuf, title)
					slides.next
				end
				
				live_segment_model.append (live_iter)
				create pixbuf.from_file_at_size (live_segment_delete_filename, 32, 32)
					check pixbuf.is_valid end
				live_segment_model.set_pixbuf_and_string (live_iter, pixbuf, once "delete")
			else
				debug print ("live_segment_tree: bin_update: antes de False: " + live_segment_view.is_sensitive.out + "%N") end
				live_segment_view.set_sensitive (False)
				debug print ("live_segment_tree: bin_update: despues de False: " + live_segment_view.is_sensitive.out + "%N") end
			end
		end

feature {} -- Initialization

	live_segment_tree_init is
		require
			live_segment_model /= Void
			live_segment_view /= Void
			segment_area /= Void
			live_current_slide_image /= Void
		local
			target_entry: GTK_TARGET_ENTRY
			live_iter: GTK_TREE_ITER
			pixbuf: GDK_PIXBUF
		once
			debug print ("live_segment_tree: antes de empezar bin_view.is_sensitive: " + live_segment_view.is_sensitive.out + "%N") end
			--live_segment_view.set_sensitive (True)
			debug print ("live_segment_tree: bin_init: bin_view a True:" + live_segment_view.is_sensitive.out + "%N") end
			live_segment_view.set_reorderable (True)
			live_segment_model.connect_agent_to_row_inserted_signal (agent on_live_segment_model_row_inserted)
			live_segment_model.connect_agent_to_row_deleted_signal (agent on_live_segment_model_row_deleted)

			create target_entry.make
			target_entry.set_target ("my_vault_items")
			target_entry.set_flags (gtk_target_same_app)
			target_entry.set_info (0)

			create live_iter.from_model (live_segment_model)
			live_segment_model.append (live_iter)
			create pixbuf.from_file_at_size (live_segment_delete_filename, 32, 32)
				check pixbuf.is_valid end
			live_segment_model.set_pixbuf_and_string (live_iter, pixbuf, once "delete")
			
			live_segment_view.set_sensitive (False)
		end

end -- LIVE_SEGMENT_TREE