Changeset 390 for trunk/gtk


Ignore:
Timestamp:
Jun 18, 2006, 7:41:36 AM (15 years ago)
Author:
joshe
Message:

Fix column and initial window sizing.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gtk/main.c

    r328 r390  
    8787makewind_toolbar(struct cbdata *data);
    8888GtkWidget *
    89 makewind_list(struct cbdata *data);
     89makewind_list(struct cbdata *data, GObject **sizehack);
    9090gboolean
    9191winclose(GtkWidget *widget, GdkEvent *event, gpointer gdata);
     
    304304  GtkWidget *list;
    305305  GtkRequisition req;
    306   gint height;
     306  gint width, height;
     307  GObject *sizehack;
     308  GdkScreen *screen;
    307309
    308310  g_object_ref(G_OBJECT(back));
     
    324326  gtk_box_pack_start(GTK_BOX(vbox), makewind_toolbar(data), FALSE, FALSE, 0);
    325327
    326   list = makewind_list(data);
     328  sizehack = NULL;
     329  list = makewind_list(data, &sizehack);
    327330  gtk_container_add(GTK_CONTAINER(scroll), list);
    328331  gtk_box_pack_start(GTK_BOX(vbox), scroll, TRUE, TRUE, 0);
     
    343346  updatemodel(data);
    344347
     348  /* some evil magic to try to get a nice initial window size */
    345349  gtk_widget_show_all(vbox);
    346350  gtk_widget_realize(wind);
    347 
    348351  gtk_widget_size_request(list, &req);
    349352  height = req.height;
     
    352355  gtk_widget_size_request(wind, &req);
    353356  height += req.height;
    354   gtk_window_set_default_size(GTK_WINDOW(wind), -1, (height > req.width ?
    355      MIN(height, req.width * 8 / 5) : MAX(height, req.width * 5 / 8)));
    356 
    357   gtk_widget_show(wind);
    358 
     357  screen = gtk_widget_get_screen(wind);
     358  width = MIN(req.width, gdk_screen_get_width(screen) / 2);
     359  height = MIN(height, gdk_screen_get_height(screen) / 5 * 4);
     360  if(height > req.width)
     361    height = MIN(height, width * 8 / 5);
     362  else
     363    height = MAX(height, width * 5 / 8);
     364  height = (height > req.width ?
     365            MIN(height, width * 8 / 5) : MAX(height, width * 5 / 8));
     366  g_object_set(sizehack, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
     367  gtk_widget_show_now(wind);
     368  gtk_window_resize(GTK_WINDOW(wind), width, height);
     369
     370  /* set up the ipc socket now that we're ready to get torrents from it */
    359371  ipc_socket_setup(GTK_WINDOW(wind), addtorrents, data);
    360372}
     
    410422
    411423GtkWidget *
    412 makewind_list(struct cbdata *data) {
     424makewind_list(struct cbdata *data, GObject **sizehack) {
    413425  GType types[] = {
    414426    /* info->name, info->totalSize, status,     error,      trackerError, */
     
    437449
    438450  namerend = gtk_cell_renderer_text_new();
     451  *sizehack = G_OBJECT(namerend);
     452  /* note that this renderer is set to ellipsize, just not here */
    439453  col = gtk_tree_view_column_new_with_attributes(_("Name"), namerend, NULL);
    440   g_object_set(namerend, "ellipsize", PANGO_ELLIPSIZE_END, NULL);
    441454  gtk_tree_view_column_set_cell_data_func(col, namerend, dfname, NULL, NULL);
    442455  gtk_tree_view_column_set_expand(col, TRUE);
    443   gtk_tree_view_column_set_resizable(col, TRUE);
     456  gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
    444457  gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
    445458
     
    451464  col = gtk_tree_view_column_new_with_attributes(_("Progress"), progrend, NULL);
    452465  gtk_tree_view_column_set_cell_data_func(col, progrend, dfprog, NULL, NULL);
    453   gtk_tree_view_column_set_resizable(col, TRUE);
     466  gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE);
    454467  gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
    455468
Note: See TracChangeset for help on using the changeset viewer.