I'm trying to get the Maiouw Scrolled Window and a GtkTreeView working
in harmony, but the scrolling simply isn't happening. Has anybody
messed with this widget and had it work in this situation? I hacked
together an example (and attached to this email) of what I'd like,
based on the miaouw example, but it simply doesn't do what I expect.
Thoughts?
Should I be sending this to maemo-developers? There was some debate a
year ago about where this type of question goes, but I never read the
outcome of that conversation.
Rich
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <gtk/gtk.h>
#include <libosso.h>
#include <stdlib.h>
#if defined HILDON && HILDON == 0
#include <hildon-widgets/hildon-program.h>
#else
#include <hildon/hildon.h>
#endif
#include <miaouw/miaouw.h>
#define ROWS 30
#define COLS 15
int main(int argc, char** argv) {
osso_context_t* osso_context;
HildonProgram* program;
GtkWidget* window;
GtkWidget* scrolled_window;
GtkWidget* event_box;
GtkWidget* trv_list;
GtkWidget* widget;
GtkCellRenderer* cell;
GtkListStore* liststore;
gint row, col;
gchar* buffer = g_new0( gchar, 128 );
GtkTreeIter* iter = g_new( GtkTreeIter, 1 );
int i;
gtk_init(&argc, &argv);
osso_context = osso_initialize("miaouwscrolling", "0.0.1", TRUE, NULL);
program = HILDON_PROGRAM(hildon_program_get_instance());
g_set_application_name("Miaouw");
/* You can set the window title when creating a MiaouwWindow. */
window = miaouw_window_new_with_title("Scrolling");
hildon_program_add_window(program, HILDON_WINDOW(window));
g_signal_connect(G_OBJECT(window), "destroy", G_CALLBACK(gtk_main_quit), NULL);
/* The MiaouwScrolledWindow acts just like the original Gtk ScrolledWindow. */
scrolled_window = miaouw_scrolled_window_new(NULL, NULL);
gtk_container_add(GTK_CONTAINER(window), scrolled_window);
trv_list = gtk_tree_view_new();
/* With this utility function an GtkEventBox is added between the viewport and a child widget. */
miaouw_scrolled_window_add_with_viewport(MIAOUW_SCROLLED_WINDOW(scrolled_window), trv_list);
/* The easiest way to support D-pad is to attach scroll adjustments to it with the MiaouwWindow. */
miaouw_window_set_vadjustment(MIAOUW_WINDOW(window),
gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window)));
miaouw_window_set_hadjustment(MIAOUW_WINDOW(window),
gtk_scrolled_window_get_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window)));
liststore = gtk_list_store_new( 1, G_TYPE_STRING );
cell = gtk_cell_renderer_text_new();
gtk_tree_view_insert_column_with_attributes( GTK_TREE_VIEW( trv_list ), -1, "Foo", cell,"text", 0, NULL );
for( i = 0; i < 10000; i++ ) {
gtk_list_store_append( GTK_LIST_STORE( liststore ), iter );
snprintf( buffer, 32, "Potato %d", i );
gtk_list_store_set( GTK_LIST_STORE( liststore ), iter, 0, buffer, -1 );
}
gtk_tree_view_set_model( GTK_TREE_VIEW( trv_list ), GTK_TREE_MODEL( liststore ) );
gtk_widget_show_all(window);
gtk_main();
return 0;
}
_______________________________________________
maemo-users mailing list
[email protected]
https://lists.maemo.org/mailman/listinfo/maemo-users