GTK+ Forums Forum Index GTK+ Forums
Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TextView and scroll

 
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming
Author Message
Ossi
GTK+ Geek


Joined: 09 Sep 2008
Posts: 67
Location: Denmark

PostPosted: Wed Oct 01, 2008 1:47 pm    Post subject: TextView and scroll Reply with quote

Hello all.

I have made a textview placed in a scrolled window, but i am having troubles replacing the two scroll bars with buttons (up-down, right-left).

I have used the function call:

Code: (Plaintext)
1
2
   gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_win),
                                   GTK_POLICY_NEVER, GTK_POLICY_NEVER);


This allows me to implement buttons instead of scroll bars...

The callback function for f.x the down button I implemented as:
Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
void FulldownClicked(GtkWidget *widget, gpointer data)
{
    GtkAdjustment *adj;
    gint value;
   
    adj = gtk_scrolled_window_get_vadjustment(GTK_SCROLLED_WINDOW(
                                                  fullstruct.scrolled_win));

    value = gtk_adjustment_get_value(adj);
    gtk_adjustment_set_value(adj, value-22);
    gtk_adjustment_value_changed( adj );
}


but it dosent work, how do I replace the scrol bars with buttons?

\Ossi
Back to top
dreblen
Never Seen the Sunlight


Joined: 14 Jun 2007
Posts: 920
Location: Falun, WI USA

PostPosted: Wed Oct 01, 2008 2:51 pm    Post subject: Reply with quote

using a viewport instead of a scrolled window might work
http://library.gnome.org/devel/gtk/stable/GtkViewport.html
Back to top
Ossi
GTK+ Geek


Joined: 09 Sep 2008
Posts: 67
Location: Denmark

PostPosted: Thu Oct 02, 2008 9:39 am    Post subject: Reply with quote

Thanks for the advice dreblen.

I ended up with:

Code: (Plaintext)
1
2
3
4
5
6
7
8
9
10
11
12
    scrolled_win = gtk_scrolled_window_new(NULL, NULL);
    gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled_win),
                                 GTK_POLICY_NEVER, GTK_POLICY_NEVER);

    horizontal = gtk_scrolled_window_get_hadjustment(
        GTK_SCROLLED_WINDOW(scrolled_win));
    vertical = gtk_scrolled_window_get_vadjustment(
        GTK_SCROLLED_WINDOW(scrolled_win));

    viewport = gtk_viewport_new(horizontal, vertical);
    gtk_container_add(GTK_CONTAINER(scrolled_win), viewport);
    gtk_container_add(GTK_CONTAINER(viewport), textview);


This allows me to make adjustments to the GtkAdjustment widget in my button callback function.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    GTK+ Forums Forum Index -> GTK+ Programming All times are GMT
Page 1 of 1

 


Powered by phpBB © 2001, 2005 phpBB Group
CodeBB 1.0 Beta 2
Protected by Anti-Spam ACP