[gimp/tito: 18/50] added opacity as a preference



commit 9d673c409f094bc8005a08f27ec10d649fca3cfc
Author: srihari sriraman <techie visishta net>
Date:   Mon May 21 21:32:27 2012 +0530

    added opacity as a preference

 app/dialogs/tito-dialog.c          |   35 +++++++++----
 plug-ins/pygimp/gimpthumb.override |  102 ++++++++++++++++++++++++++++++++++++
 2 files changed, 127 insertions(+), 10 deletions(-)
---
diff --git a/app/dialogs/tito-dialog.c b/app/dialogs/tito-dialog.c
index b6015d1..a874f9e 100644
--- a/app/dialogs/tito-dialog.c
+++ b/app/dialogs/tito-dialog.c
@@ -91,7 +91,7 @@ static void context_menu_handler( GtkMenuItem* menuitem,
                                   gpointer *data);
 GimpUIManager     *manager;
 static GtkWidget  *dialog;
-static GtkWidget  *list;                             //view shown to the user
+static GtkWidget  *list;
 static GtkWidget  *list_view;
 static GtkWidget  *keyword_entry;
 static GtkWidget  *specify_radio;
@@ -103,6 +103,7 @@ static GtkWidget  *pos_x_spin_button;
 static GtkWidget  *pos_y_spin_button;
 static GtkWidget  *no_of_results_spin_button;
 static GtkWidget  *width_spin_button;
+static GtkWidget  *opacity_spin_button;
 static GtkWidget  *autohide_check_button;
 static GtkWidget  *show_insensitive_check_button;
 static GtkWidget  *preferences_button;
@@ -141,6 +142,7 @@ static struct PREFERENCES {
   float WIDTH;
   gboolean AUTO_HIDE;
   gboolean SHOW_INSENSITIVE;
+  gdouble OPACITY;
 }PREF;
 
 GtkWidget *
@@ -202,14 +204,13 @@ search_dialog (void)
 {
   GtkWidget *main_vbox, *main_hbox;
   GtkWidget *preferences_image;
-  gdouble opacity=0.7;
 
   dialog= gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
   gtk_window_set_decorated (GTK_WINDOW(dialog),FALSE);
   gtk_window_set_default_size 
(GTK_WINDOW(dialog),(PREF.WIDTH/100)*gdk_screen_get_width(gdk_screen_get_default()),def_height);
   gtk_window_move (GTK_WINDOW(dialog),PREF.POSITION_X,PREF.POSITION_Y);
-  gtk_window_set_opacity (GTK_WINDOW(dialog),opacity);
+  gtk_window_set_opacity (GTK_WINDOW(dialog),PREF.OPACITY);
   if(!PREF.AUTO_HIDE)
     gtk_window_set_keep_above(GTK_WINDOW(dialog),TRUE);
 
@@ -277,9 +278,11 @@ preferences_dialog(void)
   GtkWidget   *display_frame;
   GtkWidget   *display_vbox;
   GtkWidget   *no_of_results_hbox;
-  GtkWidget   *width_hbox;  
+  GtkWidget   *width_hbox;
+  GtkWidget   *opacity_hbox;    
   GtkWidget   *no_of_results_label;
   GtkWidget   *width_label;
+  GtkWidget   *opacity_label;  
   
   GtkWidget   *bottom_hbox;
   GtkWidget   *clear_history_button;
@@ -340,10 +343,13 @@ preferences_dialog(void)
   
   no_of_results_hbox = gtk_hbox_new(FALSE,2);
   width_hbox = gtk_hbox_new(FALSE,2);
+  opacity_hbox = gtk_hbox_new(FALSE,2);  
   no_of_results_label = gtk_label_new("Results height:");
   no_of_results_spin_button = gtk_spin_button_new_with_range(2,10,1);
   width_label = gtk_label_new("Tito Width:");
   width_spin_button = gtk_spin_button_new_with_range(20,60,1);
+  opacity_label = gtk_label_new("Tito Opacity:");
+  opacity_spin_button = gtk_spin_button_new_with_range(40,100,10);  
   autohide_check_button = gtk_check_button_new_with_label("Autohide");
   show_insensitive_check_button = gtk_check_button_new_with_label("Show inert actions");
   clear_history_button = gtk_button_new_with_label ("Clear history");
@@ -357,6 +363,9 @@ preferences_dialog(void)
       gtk_box_pack_start (GTK_BOX (display_vbox), width_hbox, TRUE, TRUE, 2);          
           gtk_box_pack_start (GTK_BOX (width_hbox), width_label, TRUE, TRUE, 2);          
           gtk_box_pack_start (GTK_BOX (width_hbox), width_spin_button, TRUE, TRUE, 2);
+      gtk_box_pack_start (GTK_BOX (display_vbox), opacity_hbox, TRUE, TRUE, 2);          
+          gtk_box_pack_start (GTK_BOX (opacity_hbox), opacity_label, TRUE, TRUE, 2);          
+          gtk_box_pack_start (GTK_BOX (opacity_hbox), opacity_spin_button, TRUE, TRUE, 2);    
       gtk_box_pack_start (GTK_BOX (display_vbox), autohide_check_button, TRUE, TRUE, 2);
       gtk_box_pack_start (GTK_BOX (display_vbox), show_insensitive_check_button, TRUE, TRUE, 2);
 
@@ -387,10 +396,13 @@ preferences_dialog(void)
   gtk_widget_show (display_vbox);
   gtk_widget_show (no_of_results_hbox);
   gtk_widget_show (width_hbox);
+  gtk_widget_show (opacity_hbox);  
   gtk_widget_show (no_of_results_label);
   gtk_widget_show (width_label);
+  gtk_widget_show (opacity_label);
   gtk_widget_show (no_of_results_spin_button);
   gtk_widget_show (width_spin_button);
+  gtk_widget_show (opacity_spin_button);  
   gtk_widget_show (autohide_check_button);
   gtk_widget_show (show_insensitive_check_button);
 
@@ -426,7 +438,8 @@ set_prefereces_ui_values(void)
   modify_position_spins();
 
   gtk_spin_button_set_value (GTK_SPIN_BUTTON(no_of_results_spin_button), (gdouble)PREF.NO_OF_RESULTS);
-  gtk_spin_button_set_value (GTK_SPIN_BUTTON(width_spin_button), (gdouble)PREF.WIDTH);  
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON(width_spin_button), (gdouble)PREF.WIDTH);
+  gtk_spin_button_set_value (GTK_SPIN_BUTTON(opacity_spin_button), (gdouble)PREF.OPACITY*100);
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(autohide_check_button), PREF.AUTO_HIDE);    
   gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(show_insensitive_check_button), PREF.SHOW_INSENSITIVE);
   
@@ -1033,6 +1046,7 @@ set_default_preferences(void)
  PREF.NO_OF_RESULTS = 4;
  PREF.AUTO_HIDE = TRUE;
  PREF.SHOW_INSENSITIVE = TRUE; 
+ PREF.OPACITY = 1;
  write_preferences();
 }
 
@@ -1051,8 +1065,9 @@ update_preferences(void)
       tmp_y = (gfloat) gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(pos_y_spin_button));      
     }
   
-  PREF.NO_OF_RESULTS     = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(no_of_results_spin_button));
+  PREF.NO_OF_RESULTS    = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(no_of_results_spin_button));
   PREF.WIDTH            = (gfloat)gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(width_spin_button));
+  PREF.OPACITY          = (gdouble)gtk_spin_button_get_value_as_int 
(GTK_SPIN_BUTTON(opacity_spin_button))/100;
   PREF.AUTO_HIDE        = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(autohide_check_button));
   PREF.SHOW_INSENSITIVE = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(show_insensitive_check_button));
     
@@ -1082,8 +1097,8 @@ write_preferences(void)
  fp=fopen(preference_file_path,"w");
  if(fp == NULL)
     return;
- fprintf(fp,"%d %f %f %d %f %d %d", PREF.POSITION,PREF.POSITION_X, PREF.POSITION_Y,
-                                   PREF.NO_OF_RESULTS, PREF.WIDTH, PREF.AUTO_HIDE,PREF.SHOW_INSENSITIVE);
+ fprintf(fp,"%d %f %f %d %f %d %d %lf", PREF.POSITION,PREF.POSITION_X, PREF.POSITION_Y,
+                                   PREF.NO_OF_RESULTS, PREF.WIDTH, 
PREF.AUTO_HIDE,PREF.SHOW_INSENSITIVE,PREF.OPACITY);
  fclose(fp);
 }
 
@@ -1097,8 +1112,8 @@ read_preferences(void)
      set_default_preferences();
      return;
    }
- if(fscanf(fp,"%d %f %f %d %f %d %d", &PREF.POSITION, &PREF.POSITION_X, &PREF.POSITION_Y,
-                                  &PREF.NO_OF_RESULTS, &PREF.WIDTH, &PREF.AUTO_HIDE, &PREF.SHOW_INSENSITIVE) 
== 0)
+ if(fscanf(fp,"%d %f %f %d %f %d %d %lf", &PREF.POSITION, &PREF.POSITION_X, &PREF.POSITION_Y,
+                                  &PREF.NO_OF_RESULTS, &PREF.WIDTH, &PREF.AUTO_HIDE, &PREF.SHOW_INSENSITIVE, 
&PREF.OPACITY) == 0)
           set_default_preferences();
  fclose(fp);
 }
diff --git a/plug-ins/pygimp/gimpthumb.override b/plug-ins/pygimp/gimpthumb.override
new file mode 100644
index 0000000..c43e539
--- /dev/null
+++ b/plug-ins/pygimp/gimpthumb.override
@@ -0,0 +1,102 @@
+%%
+headers
+#include <Python.h>
+
+#define NO_IMPORT_PYGOBJECT
+#include <pygobject.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <libgimpthumb/gimpthumb.h>
+
+/* TODO: Add a header for these */
+void gimpthumb_register_classes(PyObject *d);
+void gimpthumb_add_constants(PyObject *module, const gchar *strip_prefix);
+%%
+modulename gimpthumb
+%%
+import gobject.GObject as PyGObject_Type
+import gtk.gdk.Pixbuf as PyGdkPixbuf_Type
+%%
+ignore-glob
+  *_get_type
+%%
+override gimp_thumb_init kwargs
+static PyObject *
+_wrap_gimp_thumb_init(PyObject *self, PyObject *args, PyObject *kwargs)
+{
+    char *creator, *thumb_basedir = NULL;
+
+    static char *kwlist[] = { "creator", "thumb_basedir", NULL };
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs,
+                                     "s|z:init", kwlist,
+                                     &creator, &thumb_basedir))
+        return NULL;
+
+    return PyBool_FromLong(gimp_thumb_init(creator, thumb_basedir));
+}
+%%
+override gimp_thumb_find_thumb kwargs
+static PyObject *
+_wrap_gimp_thumb_find_thumb(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    gchar *uri, *ret;
+    PyObject *py_size, *py_ret;
+    GimpThumbSize size;
+
+    static char *kwlist[] = { "uri", NULL };
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sO:find_thumb", kwlist,
+                                     &uri, &py_size))
+        return NULL;
+
+    if (pyg_enum_get_value(GIMP_TYPE_THUMB_SIZE, py_size, (gint *)&size))
+        return NULL;
+
+    ret = gimp_thumb_find_thumb(uri, &size);
+
+    if (ret == NULL) {
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+
+    py_ret = Py_BuildValue("sN", ret,
+                           pyg_enum_from_gtype(GIMP_TYPE_THUMB_SIZE, size));
+    g_free(ret);
+    return py_ret;
+}
+%%
+override gimp_thumb_file_test kwargs
+static PyObject *
+_wrap_gimp_thumb_file_test(PyGObject *self, PyObject *args, PyObject *kwargs)
+{
+    gchar *filename;
+    GimpThumbFileType ret;
+    gint64 mtime, size;
+    gint err_no;
+
+    static char *kwlist[] = { "filename", NULL };
+
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s:file_test", kwlist,
+                                     &filename))
+        return NULL;
+
+    ret = gimp_thumb_file_test(filename, &mtime, &size, &err_no);
+
+    if (ret == GIMP_THUMB_FILE_TYPE_NONE) {
+        PyObject *v = Py_BuildValue("iss",
+                                    err_no, g_strerror(err_no), filename); 
+        if (v != NULL) {
+            PyErr_SetObject(PyExc_IOError, v);
+            Py_DECREF(v);
+        }
+
+        return NULL;
+    }
+
+    return Py_BuildValue("NNN", 
+                         pyg_enum_from_gtype(GIMP_TYPE_THUMB_FILE_TYPE, ret),
+                         PyLong_FromLongLong(mtime),
+                         PyLong_FromLongLong(size));
+}


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