Re: need help putting up/down arrows into Small square



=====
Organization: Thought Unlimited.  Public service Unix since 1986.
Of_Interest: With 28 years  of service  to the  Unix  community.

On Sat, Jul 19, 2014 at 07:59:59PM -0400, Chris Moller wrote:
Compiles fine for me under gtk3-3.10.9-1, only complaining about line 67:

   box = gtk_hbox_new (FALSE, 0);

That's deprecated and should be

   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);


It creates a wide, mostly empty, window with a couple of big up/down
buttons at the left.


        tthanks, bbut it isn't what I had in mind.  I want a small SQUARE
        box surrounding the two arrows.  then I will increase the 
        gtk_window_set_default_size() for 840, 100 to {oh}, around 
        850, 1500  (around line 41).  I have an array of strings

        /* pseudo code */
        chat *text[512] = "hi", "hello", "yes", "no", "foobar", "I'm fine,   
            how are you";  

            I want the arrows in a small square box on the upper left, and
            the array of strings on the right-hand side.  when I have 
            figured out [[!!!]] how to make the arrows activate the array
            of strinngs, that's next.  

            right now, since I havent hacked any GTK+ for *years*, iam
            RE-learning how by brute-force.  trial and error and by
            digging in my files from around 2009.


            gary

            ps:  thanks for clueing me in on the deprecation.... 

        REattaching your clean-up :_)




    /* COMPILE WITH:
    gcc -Wall -Wextra -g arrow.c -o arrow `pkg-config --cflags gtk+-3.0`
    `pkg-config --libs gtk+-3.0`       */

    #include <gtk/gtk.h>

    /* Create an Arrow widget with the specified parameters
     * and pack it into a button */
    GtkWidget *create_arrow_button( GtkArrowType  arrow_type,
                                    GtkShadowType shadow_type )
    {
      GtkWidget *button;
      GtkWidget *arrow;

      button = gtk_button_new();
      arrow = gtk_arrow_new (arrow_type, shadow_type);

      gtk_container_add (GTK_CONTAINER (button), arrow);
      
      gtk_widget_show(button);
      gtk_widget_show(arrow);

      return(button);
    }

    int main( int argc, char *argv[])
    {
      /* GtkWidget is the storage type for widgets */
      GtkWidget *window;
      GtkWidget *button;
      GtkWidget *box;
      GtkWidget *hbox, *vbox;

      /* Initialize the toolkit */
      gtk_init (&argc, &argv);

      /* Create a new window */
      window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
      gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER);
      gtk_window_set_default_size(GTK_WINDOW(window), 850, 100);

      /* Sets the border width of the window. */
      gtk_container_set_border_width(GTK_CONTAINER(window), 10);

      /* It's a good idea to do this for all windows.
       Commented out w/3.0
       gtk_signal_connect (GTK_OBJECT (window), "destroy",
                                 GTK_SIGNAL_FUNC (gtk_main_quit), NULL); */

      /* Create a box to hold the arrows/buttons */
      //box = gtk_hbox_new (FALSE, 0);



   box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
      gtk_container_set_border_width (GTK_CONTAINER (box), 2);
      gtk_container_add (GTK_CONTAINER (window), box);

      button = create_arrow_button(GTK_ARROW_UP, GTK_SHADOW_IN);
      gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);

      button = create_arrow_button(GTK_ARROW_DOWN, GTK_SHADOW_OUT);
      gtk_box_pack_start (GTK_BOX (box), button, FALSE, FALSE, 3);

      //hbox = gtk_hbox_new(FALSE, 2);

      gtk_widget_show_all(window);
      
      /* Rest in gtk_main and wait for the fun to begin! */
      gtk_main ();
      
      return(0);
    }
    /* example-end */





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]