How to make Own Decorated window



Hi
i have able to write a new decorated window .. its only minimize till now
... but one problem is that how to make it move by sticking it to Cursor  ..
its not happening in this case :(

#include<gtk/gtk.h>
GtkWidget *
make_window (void)
{
  GtkWidget *window;
  GdkColor color;
  gdk_color_parse ("#a1c0f5", &color);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  gtk_window_set_title (GTK_WINDOW (window), "Chat Window");
  gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_MOUSE);
  g_signal_connect (G_OBJECT (window), "destroy", gtk_main_quit, NULL);
  gtk_widget_modify_bg (window, GTK_STATE_NORMAL, &color);
  gtk_widget_set_size_request (window, 320, 220);
  gtk_container_set_border_width (GTK_CONTAINER (window), 0);
  return window;
}

void
minimize_window (GtkWidget * widget, gpointer data)
{

  gtk_window_iconify (data);
}

gint
main (gint argc, gchar ** argv)
{
  GtkWidget *window, *event_box, *hbox, *vbox;
  GdkColor color;
  gdk_color_parse ("#f3f3f3", &color);
  gtk_init (&argc, &argv);
  window = make_window ();


  //Hbox
  hbox = gtk_hbox_new (FALSE, 0);
  vbox = gtk_vbox_new (FALSE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_box_pack_start (GTK_BOX (vbox), hbox, 0, 0, 0);
  event_box = gtk_event_box_new ();

  gtk_widget_set_size_request (hbox, 10, 20);

  gtk_container_add (GTK_CONTAINER (hbox), event_box);


  gtk_widget_modify_bg (event_box, GTK_STATE_NORMAL, &color);

  GtkWidget *button = gtk_button_new ();
  GtkWidget *image = gtk_image_new_from_file
("/home/ami/Desktop/pirate.xpm");
  gtk_container_add (GTK_CONTAINER (button), image);




  g_signal_connect (G_OBJECT (button), "clicked",
            G_CALLBACK (minimize_window), (gpointer) window);

  gtk_box_pack_end (GTK_BOX (hbox), button, 0, 0, 1);

  gtk_widget_show (image);
  gtk_widget_show (button);



  gtk_widget_realize (window);
  gdk_window_set_decorations (window->window, 0);
  gdk_window_set_functions (window->window,
                (GDK_FUNC_MOVE | GDK_FUNC_MINIMIZE |
                 GDK_FUNC_CLOSE));

  gtk_widget_show (event_box);
  gtk_widget_show (hbox);
  gtk_widget_show (vbox);



  gtk_widget_show (window);


  gtk_main ();

  return 0;
}

Any suggestions ?

Thanks
Amitesh


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