Project

General

Profile

0001-Use-GtkList-for-plugin-list-instead-of-a-GtkTable.patch

Vitaliy Filippov, 10/29/2012 11:38 PM

Download (8.81 KB)

View differences:

src/dtgtk/tristatebutton.c
83 83
    pango_layout_get_pixel_size (layout,&pw,&ph);
84 84

  
85 85
    requisition->width = pw+4;
86
    requisition->height = ph+4;
87 86
  }
88 87
  else
89 88
  {
90
    requisition->width = requisition->height = 24;
89
    requisition->width = 24;
91 90
  }
91
  requisition->height = 24;
92 92
}
93 93

  
94 94
#if 0
......
190 190
    cairo_fill (cr);
191 191
  }
192 192

  
193
  /* draw button image if any */
194
  GtkWidget *image = gtk_button_get_image(GTK_BUTTON(widget));
195
  gint offset = 0;
196
  if(image)
197
  {
198
    GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
199

  
200
    if(pixbuf)
201
    {
202
      /* Draw the pixbuf */
203
      offset = gdk_pixbuf_get_width (pixbuf) + 2;
204
      gint pbh = gdk_pixbuf_get_height (pixbuf);
205
      gdk_cairo_set_source_pixbuf (cr, pixbuf, widget->allocation.x,
206
                                   widget->allocation.y+((widget->allocation.height/2)-(pbh/2)));
207
      cairo_paint (cr);
208
      cairo_destroy (cr);
209
      cr = gdk_cairo_create (widget->window);
210
    }
211
  }
212

  
193 213
  /* create pango text settings if label exists */
194 214
  PangoLayout *layout=NULL;
195 215
  int pw=0,ph=0;
......
207 227
                        style->fg[state].green/65535.0,
208 228
                        style->fg[state].blue/65535.0);
209 229

  
210
  /* draw button image if any */
211
  GtkWidget *image=gtk_button_get_image(GTK_BUTTON(widget));
212
  if(image)
213
  {
214
    GdkPixbuf *pixbuf = gtk_image_get_pixbuf(GTK_IMAGE(image));
215

  
216
    if(pixbuf)
217
    {
218
      /* Draw the pixbuf */
219
      gint pbw = gdk_pixbuf_get_width (pixbuf);
220
      gint pbh = gdk_pixbuf_get_height (pixbuf);
221
      gdk_cairo_set_source_pixbuf (cr, pixbuf, widget->allocation.x+((widget->allocation.width/2)-(pbw/2)),
222
                                   widget->allocation.y+((widget->allocation.height/2)-(pbh/2)));
223
      cairo_paint (cr);
224
    }
225
  }
226

  
227

  
228 230
  /* draw icon */
229 231
  if (DTGTK_TRISTATEBUTTON (widget)->icon)
230 232
  {
......
242 244
  /* draw label */
243 245
  if (text)
244 246
  {
245
    int lx=x+2, ly=y+((height/2.0)-(ph/2.0));
247
    int lx=x+2+offset, ly=y+((height/2.0)-(ph/2.0));
246 248
    cairo_translate(cr, lx, ly);
247 249
    pango_cairo_show_layout (cr,layout);
248 250
  }
src/libs/modulelist.c
33 33

  
34 34
typedef struct dt_lib_modulelist_t
35 35
{
36
  GtkList *list;
36 37
}
37 38
dt_lib_modulelist_t;
38 39

  
......
68 69
  memset(d,0,sizeof(dt_lib_modulelist_t));
69 70
  self->data = (void *)d;
70 71

  
71
  self->widget = gtk_table_new(2, 6, TRUE);
72
  gtk_table_set_row_spacings(GTK_TABLE(self->widget), DT_MODULE_LIST_SPACING);
73
  gtk_table_set_col_spacings(GTK_TABLE(self->widget), DT_MODULE_LIST_SPACING);
72
  self->widget = gtk_scrolled_window_new(NULL, NULL); //GTK_ADJUSTMENT(gtk_adjustment_new(200, 100, 200, 10, 100, 100))
73
  gtk_widget_set_size_request(self->widget, -1, 200);
74
  gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(self->widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
75
  d->list = GTK_LIST(gtk_list_new());
76
  gtk_widget_set_size_request(GTK_WIDGET(d->list), 50, -1);
77
  gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(self->widget), GTK_WIDGET(d->list));
74 78

  
75 79
  /* connect to signal for darktable.develop initialization */
76 80
  dt_control_signal_connect(darktable.signals,DT_SIGNAL_DEVELOP_INITIALIZE,G_CALLBACK(_lib_modulelist_populate_callback),self);
......
133 137
    snprintf(option, 512, _("hide %s"), module->name());
134 138
  }
135 139

  
136
  g_object_set(G_OBJECT(w), "tooltip-text", option, (char *)NULL);
140
  gtk_button_set_label(GTK_BUTTON(w), option);
137 141
  return expand;
138 142
}
139 143

  
......
141 145
{
142 146
  dt_lib_module_t *self = (dt_lib_module_t *)user_data;
143 147

  
144
  /* go thru list of iop modules and add tp table */
148
  /* go thru list of iop modules and add to the list */
145 149
  GList *modules = g_list_last(darktable.develop->iop);
146
  int ti = 0, tj = 0;
150
  GList *buttons = NULL;
147 151
  while(modules)
148 152
  {
149 153
    dt_iop_module_t *module = (dt_iop_module_t *)(modules->data);
150 154
    if(!dt_iop_is_hidden(module) && !(module->flags() & IOP_FLAGS_DEPRECATED))
151 155
    {
152 156
      module->showhide = dtgtk_tristatebutton_new(NULL,0);
157

  
158
      /* set button image */
153 159
      char filename[DT_MAX_PATH_LEN], datadir[DT_MAX_PATH_LEN];
154 160
      dt_loc_get_datadir(datadir, DT_MAX_PATH_LEN);
155 161
      snprintf(filename, DT_MAX_PATH_LEN, "%s/pixmaps/plugins/darkroom/%s.png", datadir, module->op);
......
176 182
      /* connect tristate button callback*/
177 183
      g_signal_connect(G_OBJECT(module->showhide), "tristate-changed",
178 184
                       G_CALLBACK(_lib_modulelist_tristate_changed_callback), module);
179
      gtk_table_attach(GTK_TABLE(self->widget), module->showhide, ti, ti+1, tj, tj+1,
180
                       GTK_FILL | GTK_EXPAND | GTK_SHRINK,
181
                       GTK_SHRINK,
182
                       0, 0);
185

  
186
      buttons = g_list_append(buttons, module->showhide);
183 187
      gtk_widget_show_all(module->showhide);
184
      if(ti < 5) ti++;
185
      else
186
      {
187
        ti = 0;
188
        tj ++;
189
      }
190 188
    }
191 189

  
192 190
    modules = g_list_previous(modules);
193 191
  }
192
  gtk_list_append_items(GTK_LIST(((dt_lib_modulelist_t*)self->data)->list), buttons);
194 193
}
195 194

  
196 195

  
197
-