/[pspp]/psppire/gtk_sheet/gtkiconlist.c
ViewVC logotype

Diff of /psppire/gtk_sheet/gtkiconlist.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1.1.1 by jmd, Tue Nov 2 11:17:35 2004 UTC revision 1.2 by jmd, Fri Nov 4 01:08:25 2005 UTC
# Line 61  static guint signals[LAST_SIGNAL] = {0}; Line 61  static guint signals[LAST_SIGNAL] = {0};
61  static void gtk_icon_list_class_init            (GtkIconListClass *class);  static void gtk_icon_list_class_init            (GtkIconListClass *class);
62  static void gtk_icon_list_init                  (GtkIconList *icon_list);  static void gtk_icon_list_init                  (GtkIconList *icon_list);
63  static void gtk_icon_list_destroy               (GtkObject *object);  static void gtk_icon_list_destroy               (GtkObject *object);
64    static void gtk_icon_list_finalize              (GObject *object);
65    
66  static void gtk_icon_list_size_allocate         (GtkWidget *widget,  static void gtk_icon_list_size_allocate         (GtkWidget *widget,
67                                                   GtkAllocation *allocation);                                                   GtkAllocation *allocation);
# Line 195  static void Line 196  static void
196  gtk_icon_list_class_init (GtkIconListClass *klass)  gtk_icon_list_class_init (GtkIconListClass *klass)
197  {  {
198    GtkObjectClass *object_class;    GtkObjectClass *object_class;
199      GObjectClass *gobject_class;
200    GtkWidgetClass *widget_class;    GtkWidgetClass *widget_class;
201    
202    parent_class = gtk_type_class (GTK_TYPE_FIXED);    parent_class = gtk_type_class (GTK_TYPE_FIXED);
203    
204    object_class = (GtkObjectClass *) klass;    object_class = (GtkObjectClass *) klass;
205      gobject_class = (GObjectClass *) klass;
206    widget_class = (GtkWidgetClass *) klass;    widget_class = (GtkWidgetClass *) klass;
207    
208    object_class->destroy = gtk_icon_list_destroy;    object_class->destroy = gtk_icon_list_destroy;
209      gobject_class->finalize = gtk_icon_list_finalize;
210    
211    widget_class->realize = gtk_icon_list_realize;    widget_class->realize = gtk_icon_list_realize;
212    
# Line 311  reorder_icons(GtkIconList *iconlist) Line 315  reorder_icons(GtkIconList *iconlist)
315    
316    old_width = widget->allocation.width;    old_width = widget->allocation.width;
317    old_height = widget->allocation.height;    old_height = widget->allocation.height;
318      if(GTK_WIDGET_REALIZED(widget)){
319        if(GTK_IS_VIEWPORT(widget->parent))
320         gdk_window_get_size(GTK_VIEWPORT(widget->parent)->view_window, &old_width, &old_height);
321      }
322    
323    y = iconlist->row_spacing;    y = iconlist->row_spacing;
324    x = iconlist->col_spacing;    x = iconlist->col_spacing;
# Line 329  reorder_icons(GtkIconList *iconlist) Line 337  reorder_icons(GtkIconList *iconlist)
337      switch(iconlist->mode){      switch(iconlist->mode){
338        case GTK_ICON_LIST_TEXT_RIGHT:        case GTK_ICON_LIST_TEXT_RIGHT:
339          y += vspace;          y += vspace;
340          if(y + vspace >= old_height){          if(y + vspace >= old_height - DEFAULT_COL_SPACING){
341                  x += hspace;                  x += hspace;
342                  y = iconlist->row_spacing;                  y = iconlist->row_spacing;
343          }          }
# Line 338  reorder_icons(GtkIconList *iconlist) Line 346  reorder_icons(GtkIconList *iconlist)
346        case GTK_ICON_LIST_ICON:        case GTK_ICON_LIST_ICON:
347        default:        default:
348          x += hspace;          x += hspace;
349          if(x + hspace >= old_width){          if(x + hspace >= old_width - DEFAULT_COL_SPACING){
350                  x = iconlist->col_spacing;                  x = iconlist->col_spacing;
351                  y += vspace;                  y += vspace;
352          }          }
# Line 348  reorder_icons(GtkIconList *iconlist) Line 356  reorder_icons(GtkIconList *iconlist)
356      icons = icons->next;      icons = icons->next;
357    
358     }     }
   
359  /*  /*
360    gdk_threads_leave();    gdk_threads_leave();
361  */  */
# Line 373  gtk_icon_list_move(GtkIconList *iconlist Line 380  gtk_icon_list_move(GtkIconList *iconlist
380    icon->x = x;    icon->x = x;
381    icon->y = y;    icon->y = y;
382    
383      if(x == old_x && y == old_y) return;
384    
385    item_size_request(iconlist, icon, &req);    item_size_request(iconlist, icon, &req);
386    req1 = icon->pixmap->requisition;    req1 = icon->pixmap->requisition;
387    req2 = icon->entry->requisition;    req2 = icon->entry->requisition;
# Line 440  gtk_icon_list_move(GtkIconList *iconlist Line 449  gtk_icon_list_move(GtkIconList *iconlist
449  static void  static void
450  gtk_icon_list_size_allocate(GtkWidget *widget, GtkAllocation *allocation)  gtk_icon_list_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
451  {  {
452    GtkAllocation old = widget->allocation;    GtkAllocation *old = gtk_object_get_data(GTK_OBJECT(widget),"viewport");
453    GTK_WIDGET_CLASS(parent_class)->size_allocate(widget, allocation);    GTK_WIDGET_CLASS(parent_class)->size_allocate(widget, allocation);
454    if(old.width != allocation->width || old.height != allocation->height)    if(GTK_WIDGET_REALIZED(widget) && old){
455      reorder_icons(GTK_ICON_LIST(widget));      gint new_width, new_height;
456        gdk_window_get_size(GTK_VIEWPORT(widget->parent)->view_window, &new_width, &new_height);
457        if(old->width != new_width || old->height != new_height)
458          reorder_icons(GTK_ICON_LIST(widget));
459        old->width = new_width;
460        old->height = new_height;
461      }
462  }  }
463    
464    
# Line 485  gtk_icon_list_realize(GtkWidget *widget) Line 500  gtk_icon_list_realize(GtkWidget *widget)
500      icons = icons->next;      icons = icons->next;
501    }    }
502    
503    /*  
504      if(GTK_IS_VIEWPORT(widget->parent) && GTK_WIDGET_REALIZED(widget->parent)){
505        GtkAllocation *allocation = gtk_object_get_data(GTK_OBJECT(widget),"viewport");
506        gdk_window_get_size(GTK_VIEWPORT(widget->parent)->view_window, &allocation->width, &allocation->height);
507      }
508    reorder_icons(iconlist);    reorder_icons(iconlist);
509    */
510  }  }
511    
512    
# Line 638  deactivate_entry(GtkIconList *iconlist) Line 659  deactivate_entry(GtkIconList *iconlist)
659           break;           break;
660       }       }
661    
   
662       if(GTK_WIDGET_REALIZED(iconlist->active_icon->entry)){       if(GTK_WIDGET_REALIZED(iconlist->active_icon->entry)){
663         gc = gdk_gc_new(GTK_WIDGET(iconlist)->window);         gc = gdk_gc_new(GTK_WIDGET(iconlist)->window);
664         gdk_gc_set_foreground(gc, &iconlist->background);         gdk_gc_set_foreground(gc, &iconlist->background);
# Line 697  select_icon(GtkIconList *iconlist, GtkIc Line 717  select_icon(GtkIconList *iconlist, GtkIc
717            break;            break;
718          case GTK_ICON_LIST_ICON:          case GTK_ICON_LIST_ICON:
719          default:          default:
720            break;            break;
721        }        }
722      }      }
723    }    }
# Line 734  unselect_icon(GtkIconList *iconlist, Gtk Line 754  unselect_icon(GtkIconList *iconlist, Gtk
754    if(iconlist->mode != GTK_ICON_LIST_ICON){    if(iconlist->mode != GTK_ICON_LIST_ICON){
755     if(item->entry && GTK_WIDGET_REALIZED(item->entry)){     if(item->entry && GTK_WIDGET_REALIZED(item->entry)){
756       GtkStyle *style = gtk_style_copy(item->entry->style);       GtkStyle *style = gtk_style_copy(item->entry->style);
757    
758       style->bg[GTK_STATE_ACTIVE] = iconlist->background;       style->bg[GTK_STATE_ACTIVE] = iconlist->background;
759       style->bg[GTK_STATE_NORMAL] = iconlist->background;       style->bg[GTK_STATE_NORMAL] = iconlist->background;
760         style->text[GTK_STATE_ACTIVE] = GTK_WIDGET(iconlist)->style->text[GTK_STATE_ACTIVE];
761         style->text[GTK_STATE_NORMAL] = GTK_WIDGET(iconlist)->style->text[GTK_STATE_NORMAL];
762       gtk_widget_set_style(item->entry, style);       gtk_widget_set_style(item->entry, style);
763       gtk_style_unref(style);       gtk_style_unref(style);
764    
# Line 743  unselect_icon(GtkIconList *iconlist, Gtk Line 766  unselect_icon(GtkIconList *iconlist, Gtk
766       gtk_entry_set_text(GTK_ENTRY(item->entry), item->entry_label);       gtk_entry_set_text(GTK_ENTRY(item->entry), item->entry_label);
767       gtk_entry_set_editable(GTK_ENTRY(item->entry), FALSE);       gtk_entry_set_editable(GTK_ENTRY(item->entry), FALSE);
768       gtk_widget_draw(item->entry, NULL);       gtk_widget_draw(item->entry, NULL);
769    
770     }     }
771    }    }
772    
# Line 764  unselect_all(GtkIconList *iconlist) Line 788  unselect_all(GtkIconList *iconlist)
788    
789    g_list_free(iconlist->selection);    g_list_free(iconlist->selection);
790    iconlist->selection = NULL;    iconlist->selection = NULL;
   iconlist->active_icon = NULL;  
791  }  }
792    
793  GtkWidget*  GtkWidget*
794  gtk_icon_list_new (guint icon_width, GtkIconListMode mode)  gtk_icon_list_new (guint icon_width, GtkIconListMode mode)
795  {  {
796    GtkIconList *icon_list;    GtkIconList *icon_list;
797      GtkAllocation *allocation;
798    
799    icon_list = gtk_type_new (gtk_icon_list_get_type ());    icon_list = gtk_type_new (gtk_icon_list_get_type ());
800    
801    gtk_icon_list_construct(icon_list, icon_width, mode);    gtk_icon_list_construct(icon_list, icon_width, mode);
802      allocation = g_new0(GtkAllocation, 1);
803      gtk_object_set_data(GTK_OBJECT(icon_list), "viewport", allocation);
804    
805    return GTK_WIDGET (icon_list);    return GTK_WIDGET (icon_list);
806  }  }
# Line 866  gtk_icon_list_destroy (GtkObject *object Line 892  gtk_icon_list_destroy (GtkObject *object
892      (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);      (*GTK_OBJECT_CLASS (parent_class)->destroy) (object);
893  }  }
894    
895    static void
896    gtk_icon_list_finalize (GObject *object)
897    {
898      GtkIconList *icon_list;
899      GtkAllocation *allocation;
900    
901      icon_list = GTK_ICON_LIST (object);
902    
903      allocation = gtk_object_get_data(GTK_OBJECT(icon_list), "viewport");
904      if(allocation) g_free(allocation);
905      gtk_object_set_data(GTK_OBJECT(icon_list), "viewport", NULL);
906    
907      if (G_OBJECT_CLASS (parent_class)->finalize)
908        (*G_OBJECT_CLASS (parent_class)->finalize) (object);
909    }
910    
911  void  void
912  gtk_icon_list_set_background (GtkIconList *iconlist, GdkColor *color)  gtk_icon_list_set_background (GtkIconList *iconlist, GdkColor *color)
# Line 1104  gtk_icon_list_real_add (GtkIconList *ico Line 1145  gtk_icon_list_real_add (GtkIconList *ico
1145          x += hspace;          x += hspace;
1146          if(x >= width){          if(x >= width){
1147                  x = iconlist->col_spacing;                  x = iconlist->col_spacing;
1148                  y += vspace ;                  y += vspace;
1149          }          }
1150          break;          break;
1151    }      }
1152    } else {    } else {
1153      y = iconlist->row_spacing;      y = iconlist->row_spacing;
1154      x = iconlist->col_spacing;      x = iconlist->col_spacing;
# Line 1164  gtk_icon_list_put (GtkIconList *iconlist Line 1205  gtk_icon_list_put (GtkIconList *iconlist
1205       req1.width = MAX(req1.width, req.width);       req1.width = MAX(req1.width, req.width);
1206    }    }
1207    
   
1208    if(iconlist->mode == GTK_ICON_LIST_ICON)    if(iconlist->mode == GTK_ICON_LIST_ICON)
1209            req2.width = req2.height = 0;            req2.width = req2.height = 0;
1210    else    else
# Line 1441  gtk_icon_list_remove (GtkIconList *iconl Line 1481  gtk_icon_list_remove (GtkIconList *iconl
1481    
1482    if(icons){    if(icons){
1483       if(icon->state == GTK_STATE_SELECTED) unselect_icon(iconlist, icon, NULL);       if(icon->state == GTK_STATE_SELECTED) unselect_icon(iconlist, icon, NULL);
1484         if(icon == iconlist->active_icon) deactivate_entry(iconlist);
1485       pixmap_destroy(GTK_PIXMAP(icon->pixmap));       pixmap_destroy(GTK_PIXMAP(icon->pixmap));
1486       if(icon->entry && iconlist->mode != GTK_ICON_LIST_ICON){       if(icon->entry && iconlist->mode != GTK_ICON_LIST_ICON){
1487         remove_from_fixed(iconlist, icon->entry);         remove_from_fixed(iconlist, icon->entry);

Legend:
Removed from v.1.1.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26