"Fossies" - the Fresh Open Source Software Archive

Member "darktable-2.6.3/src/libs/tools/module_toolbox.c" (20 Oct 2019, 3579 Bytes) of package /linux/misc/darktable-2.6.3.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "module_toolbox.c" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.6.3_vs_3.0.0.rc0.

    1 /*
    2     This file is part of darktable,
    3     copyright (c) 2011 Henrik Andersson.
    4 
    5     darktable is free software: you can redistribute it and/or modify
    6     it under the terms of the GNU General Public License as published by
    7     the Free Software Foundation, either version 3 of the License, or
    8     (at your option) any later version.
    9 
   10     darktable is distributed in the hope that it will be useful,
   11     but WITHOUT ANY WARRANTY; without even the implied warranty of
   12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   13     GNU General Public License for more details.
   14 
   15     You should have received a copy of the GNU General Public License
   16     along with darktable.  If not, see <http://www.gnu.org/licenses/>.
   17 */
   18 
   19 #include "control/signal.h"
   20 #include "dtgtk/button.h"
   21 #include "gui/gtk.h"
   22 #include "libs/lib.h"
   23 #include "libs/lib_api.h"
   24 
   25 DT_MODULE(1)
   26 
   27 /* proxy function, to add a widget to toolbox */
   28 static void _lib_module_toolbox_add(dt_lib_module_t *self, GtkWidget *widget, dt_view_type_flags_t views);
   29 
   30 
   31 typedef struct child_data_t
   32 {
   33   GtkWidget * child;
   34   dt_view_type_flags_t views;
   35 
   36 } child_data_t;
   37 
   38 typedef struct dt_lib_module_toolbox_t
   39 {
   40   GtkWidget *container;
   41   GList * child_views;
   42 } dt_lib_module_toolbox_t;
   43 
   44 const char *name(dt_lib_module_t *self)
   45 {
   46   return _("module toolbox");
   47 }
   48 
   49 const char **views(dt_lib_module_t *self)
   50 {
   51   static const char *v[] = {"darkroom", "lighttable", "tethering", NULL};
   52   return v;
   53 }
   54 
   55 uint32_t container(dt_lib_module_t *self)
   56 {
   57   return DT_UI_CONTAINER_PANEL_CENTER_BOTTOM_RIGHT;
   58 }
   59 
   60 int expandable(dt_lib_module_t *self)
   61 {
   62   return 0;
   63 }
   64 
   65 int position()
   66 {
   67   return 100;
   68 }
   69 
   70 
   71 void gui_init(dt_lib_module_t *self)
   72 {
   73   /* initialize ui widgets */
   74   dt_lib_module_toolbox_t *d = (dt_lib_module_toolbox_t *)g_malloc0(sizeof(dt_lib_module_toolbox_t));
   75   self->data = (void *)d;
   76 
   77   /* the toolbar container */
   78   d->container = self->widget = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 10);
   79 
   80   /* setup proxy */
   81   darktable.view_manager->proxy.module_toolbox.module = self;
   82   darktable.view_manager->proxy.module_toolbox.add = _lib_module_toolbox_add;
   83 }
   84 
   85 void gui_cleanup(dt_lib_module_t *self)
   86 {
   87   dt_lib_module_toolbox_t *d = (dt_lib_module_toolbox_t *)self->data;
   88   g_list_free_full(d->child_views,free);
   89   g_free(self->data);
   90   self->data = NULL;
   91 }
   92 
   93 void view_enter(struct dt_lib_module_t *self,struct dt_view_t *old_view,struct dt_view_t *new_view)
   94 {
   95   dt_lib_module_toolbox_t *d = (dt_lib_module_toolbox_t *)self->data;
   96   GList *child_elt = d->child_views;
   97   dt_view_type_flags_t nv= new_view->view(new_view);
   98   while(child_elt)
   99   {
  100     child_data_t* child_data = (child_data_t*)child_elt->data;
  101     if(child_data->views & nv) 
  102     {
  103       gtk_widget_show_all(child_data->child);
  104     }
  105     else
  106     {
  107       gtk_widget_hide(child_data->child);
  108     }
  109     child_elt = g_list_next(child_elt);
  110   }
  111 }
  112 
  113 static void _lib_module_toolbox_add(dt_lib_module_t *self, GtkWidget *widget, dt_view_type_flags_t views)
  114 {
  115   dt_lib_module_toolbox_t *d = (dt_lib_module_toolbox_t *)self->data;
  116   gtk_box_pack_start(GTK_BOX(d->container), widget, TRUE, FALSE, 0);
  117   gtk_widget_show_all(widget);
  118 
  119   child_data_t *child_data = malloc(sizeof(child_data_t));
  120   child_data->child = widget;
  121   child_data->views = views;
  122   d->child_views = g_list_prepend(d->child_views,child_data);
  123 
  124 }
  125 // modelines: These editor modelines have been set for all relevant files by tools/update_modelines.sh
  126 // vim: shiftwidth=2 expandtab tabstop=2 cindent
  127 // kate: tab-indents: off; indent-width 2; replace-tabs on; indent-mode cstyle; remove-trailing-spaces modified;