1
0
mirror of https://github.com/gryf/pygtktalog.git synced 2025-12-17 11:30:19 +01:00

* Code refactoring.

* Small changes in assumptions.
 * TODO supplement.
 * Moved minor features into future versions.
 * Added extensions configuration editor.
This commit is contained in:
2008-04-07 19:37:06 +00:00
parent c6d2ea795a
commit 344f4be232
8 changed files with 258 additions and 509 deletions

36
README
View File

@@ -56,28 +56,14 @@ For version 1.0 following aims have to be done:
- searching database
- tagging files
- filetypes handling
- movies
- images
- archives
- documents
- user definied group of tags (represented by color in cloud tag)
- file details:
- files properties
x thumbnail
- description
- file information (date, size, etc) (50%)
- exif information
- keywords
- anime/movie
- title
- alt title
- type (anime movie, movie, anime oav, anime tv series, tv series, etc)
- cover/images
- genre
- lang
- sub lang
- release date (from - to)
- anidb link/imdb link
- keywords (tags)
- adding images (60% done)
x generating/saving thumbnails
x moving hardcoded files extensions into config
@@ -90,6 +76,24 @@ For version 2.0:
- internationalization support
- statistics
Removed:
- filetypes handling (movies, images, archives, documents etc). Now it have
common, unified external "plugin" system - simple output from command line
programs.
- anime/movie
- title
- alt title
- type (anime movie, movie, anime oav, anime tv series, tv series, etc)
- cover/images
- genre
- lang
- sub lang
- release date (from - to)
- anidb link/imdb link
Maybe in future versions. Now text file descriptions and tags have to be
enough for good and fast information search.
NOTES
=====

View File

@@ -89,16 +89,57 @@
<property name="column_spacing">3</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label5">
<widget class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Eject program:</property>
<property name="mnemonic_widget">ejt_entry</property>
<property name="label" translatable="yes">Mount point:</property>
<property name="mnemonic_widget">mnt_entry</property>
</widget>
<packing>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="mnt_entry">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_mnt">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Browse...</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_button_mnt_clicked"/>
<signal name="activate" handler="on_button_mnt_activate"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="ejt_entry">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
@@ -122,56 +163,15 @@
</packing>
</child>
<child>
<widget class="GtkEntry" id="ejt_entry">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button_mnt">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label" translatable="yes">Browse...</property>
<property name="use_underline">True</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_button_mnt_clicked"/>
<signal name="activate" handler="on_button_mnt_activate"/>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="mnt_entry">
<property name="width_request">100</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="y_options"></property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label4">
<widget class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Mount point:</property>
<property name="mnemonic_widget">mnt_entry</property>
<property name="label" translatable="yes">Eject program:</property>
<property name="mnemonic_widget">ejt_entry</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options"></property>
<property name="y_options"></property>
</packing>
@@ -532,25 +532,11 @@
<widget class="GtkVBox" id="ext_ed">
<property name="visible">True</property>
<property name="border_width">5</property>
<child>
<widget class="GtkComboBox" id="ext_choose">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="items" translatable="yes">Images extensions
Movies extesions</property>
<signal name="changed" handler="on_ext_choose_changed"/>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">3</property>
</packing>
</child>
<child>
<widget class="GtkTable" id="table3">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">1</property>
<property name="n_rows">2</property>
<property name="n_columns">2</property>
<property name="row_spacing">3</property>
<child>
@@ -576,10 +562,33 @@ Movies extesions</property>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Command:</property>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="com_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -594,7 +603,7 @@ Movies extesions</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add</property>
<property name="label" translatable="yes">Add/Change</property>
<property name="response_id">0</property>
<signal name="clicked" handler="on_ext_add_clicked"/>
</widget>
@@ -616,7 +625,7 @@ Movies extesions</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child>
@@ -633,11 +642,12 @@ Movies extesions</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="rules_hint">True</property>
<signal name="cursor_changed" handler="on_extension_tree_cursor_changed"/>
</widget>
</child>
</widget>
<packing>
<property name="position">3</property>
<property name="position">2</property>
</packing>
</child>
</widget>
@@ -661,300 +671,6 @@ Movies extesions</property>
<property name="position">3</property>
</packing>
</child>
<child>
<widget class="GtkVBox" id="commands_group">
<property name="border_width">1</property>
<child>
<widget class="GtkFrame" id="frame9">
<property name="visible">True</property>
<property name="border_width">5</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment9">
<property name="visible">True</property>
<property name="has_focus">True</property>
<property name="border_width">5</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkVBox" id="ext_ed3">
<property name="visible">True</property>
<property name="border_width">5</property>
<child>
<widget class="GtkTable" id="table6">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">1</property>
<property name="n_columns">2</property>
<property name="row_spacing">3</property>
<child>
<widget class="GtkLabel" id="label14">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Command:</property>
<property name="justify">GTK_JUSTIFY_RIGHT</property>
<property name="mnemonic_widget">ext_entry</property>
</widget>
<packing>
<property name="x_options">GTK_FILL</property>
</packing>
</child>
<child>
<widget class="GtkEntry" id="ext_entry4">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
</packing>
</child>
<child>
<widget class="GtkHButtonBox" id="hbuttonbox4">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">3</property>
<property name="layout_style">GTK_BUTTONBOX_END</property>
<child>
<widget class="GtkButton" id="ext_add3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add</property>
<property name="response_id">0</property>
</widget>
</child>
<child>
<widget class="GtkButton" id="ext_del3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Delete</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="expand">False</property>
<property name="position">1</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow6">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="extension_tree3">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="rules_hint">True</property>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkFrame" id="frame10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="border_width">3</property>
<property name="label_xalign">0</property>
<child>
<widget class="GtkAlignment" id="alignment10">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="left_padding">12</property>
<child>
<widget class="GtkTable" id="table7">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="n_rows">2</property>
<property name="n_columns">3</property>
<property name="column_spacing">2</property>
<property name="row_spacing">2</property>
<child>
<placeholder/>
</child>
<child>
<widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkButton" id="button1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-go-forward</property>
<property name="use_stock">True</property>
<property name="image_position">GTK_POS_TOP</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
</packing>
</child>
<child>
<widget class="GtkButton" id="button2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">gtk-go-back</property>
<property name="use_stock">True</property>
<property name="response_id">0</property>
</widget>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="left_attach">1</property>
<property name="right_attach">2</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
<property name="x_options">GTK_SHRINK</property>
<property name="y_options">GTK_SHRINK</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Command extensions</property>
</widget>
<packing>
<property name="x_options">GTK_SHRINK</property>
<property name="y_options">GTK_SHRINK</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="label16">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Available extensions</property>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="x_options">GTK_SHRINK</property>
<property name="y_options">GTK_SHRINK</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow7">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="treeview1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_clickable">True</property>
</widget>
</child>
</widget>
<packing>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="scrolledwindow8">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<child>
<widget class="GtkTreeView" id="treeview2">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="headers_clickable">True</property>
</widget>
</child>
</widget>
<packing>
<property name="left_attach">2</property>
<property name="right_attach">3</property>
<property name="top_attach">1</property>
<property name="bottom_attach">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">&lt;b&gt;Extension assignment&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
<packing>
<property name="position">1</property>
</packing>
</child>
</widget>
<packing>
<property name="position">2</property>
</packing>
</child>
</widget>
</child>
</widget>
</child>
<child>
<widget class="GtkLabel" id="label15">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Comands&lt;/b&gt;</property>
<property name="use_markup">True</property>
</widget>
<packing>
<property name="type">label_item</property>
</packing>
</child>
</widget>
</child>
</widget>
<packing>
<property name="position">4</property>
</packing>
</child>
</widget>
</child>
</widget>

View File

@@ -652,6 +652,8 @@
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="editable">False</property>
<property name="wrap_mode">GTK_WRAP_WORD</property>
<property name="left_margin">2</property>
<property name="right_margin">2</property>
<property name="cursor_visible">False</property>
</widget>
</child>
@@ -866,4 +868,24 @@
</widget>
</child>
</widget>
<widget class="GtkMenu" id="files_popup">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<child>
<widget class="GtkMenuItem" id="add_tag1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">_Add tag</property>
<property name="use_underline">True</property>
</widget>
</child>
<child>
<widget class="GtkMenuItem" id="add_thumbnail1">
<property name="visible">True</property>
<property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
<property name="label" translatable="yes">Add _thumbnail</property>
<property name="use_underline">True</property>
</widget>
</child>
</widget>
</glade-interface>

View File

@@ -32,10 +32,9 @@ class ConfigController(Controller):
'General':'general_group',
'Scan options':'scan_group',
'Files extensions':'ft_group',
'Commands':'commands_group',
}
category_order = ['General', 'Disk options', 'Scan options',
'Files extensions', 'Commands']
'Files extensions',]
def __init__(self, model):
Controller.__init__(self, model)
@@ -67,15 +66,23 @@ class ConfigController(Controller):
self.__setup_category_tree()
# initialize models for files extensions
self.view['ext_choose'].set_model(self.model.ext_list)
self.view['ext_choose'].set_active(0)
self.view['extension_tree'].get_selection().set_mode(gtk.SELECTION_MULTIPLE)
#self.view['extension_tree'].set_model(self.model.ext_tree)
self.__setup_extension_tree()
self.view['config'].show();
return
# Podłącz sygnały:
#################
# connect signals
def on_extension_tree_cursor_changed(self, tree):
model = tree.get_model()
selected = model.get_value(model.get_iter(tree.get_cursor()[0]), 0)
ext = self.model.confd['extensions']
self.view['ext_entry'].set_text(selected)
self.view['com_entry'].set_text(ext[selected])
def on_category_tree_cursor_changed(self, tree):
"""change view to selected row corresponding to group of properties"""
model = tree.get_model()
@@ -127,22 +134,28 @@ class ConfigController(Controller):
self.__toggle_scan_group()
return
def on_ext_choose_changed(self, widget):
self.__setup_extension_tree()
self.view['ext_entry'].set_text('')
return
def on_ext_add_clicked(self, widget):
ext = self.view['ext_entry'].get_text().lower()
com = self.view['com_entry'].get_text()
if len(ext) == 0 and len(com) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error", "Extension and command required")
return
if len(com) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error", "Command is empty")
return
if len(ext) == 0:
Dialogs.Err("Config - pyGTKtalog", "Error", "Extension is empty")
return
if self.view['ext_choose'].get_active() == 0:
if ext not in self.model.confd['img_ext']:
self.model.confd['img_ext'].append(ext)
self.model.refresh_ext('img_ext')
else:
self.model.confd['mov_ext'].append(ext)
if ext in self.model.confd['extensions'].keys():
obj = Dialogs.Qst('Alter extension',
'Alter extension?',
'Extension "%s" will be altered.' % ext)
if not obj.run():
return
self.model.confd['extensions'][ext] = com
self.__setup_extension_tree()
return
@@ -164,13 +177,8 @@ class ConfigController(Controller):
if not obj.run():
return
if self.view['ext_choose'].get_active() == 0:
n = 'img_ext'
else:
n = 'mov_ext'
for i in selection:
self.model.confd[n].remove(model.get_value(model.get_iter(i), 0))
self.model.confd['extensions'].pop(model.get_value(model.get_iter(i), 0))
self.__setup_extension_tree()
return
@@ -178,17 +186,18 @@ class ConfigController(Controller):
############################
# private controller methods
def __setup_extension_tree(self):
if self.view['ext_choose'].get_active() == 0:
self.model.refresh_ext('img_ext')
else:
self.model.refresh_ext('mov_ext')
self.model.refresh_ext()
self.view['extension_tree'].set_model(self.model.ext_tree)
for i in self.view['extension_tree'].get_columns():
self.view['extension_tree'].remove_column(i)
cell = gtk.CellRendererText()
column = gtk.TreeViewColumn("Extensions", cell, text=0)
column = gtk.TreeViewColumn("Extension", cell, text=0)
column.set_resizable(True)
self.view['extension_tree'].append_column(column)
column = gtk.TreeViewColumn("Command", cell, text=1)
column.set_resizable(True)
self.view['extension_tree'].append_column(column)
@@ -196,6 +205,7 @@ class ConfigController(Controller):
for i in ('ch_thumb','ch_exif','ch_gthumb'):
self.view[i].set_sensitive(self.view['ch_retrive'].get_active())
return
def __setup_category_tree(self):
category_tree = self.view['category_tree']
category_tree.set_model(self.model.category_tree)

View File

@@ -40,6 +40,7 @@ from models.m_config import ConfigModel
import views.v_dialogs as Dialogs
import gtk
import pango
import datetime
@@ -288,24 +289,23 @@ class MainController(Controller):
def on_files_cursor_changed(self,treeview):
"""Show details of selected file"""
model, paths = treeview.get_selection().get_selected_rows()
try:
itera = model.get_iter(paths[0])
if model.get_value(itera,4) == 1:
#directory, do nothin', just turn off view
'''self.view['details'].hide()
buf = self.view['details'].get_buffer()
buf.set_text('')
self.view['details'].set_buffer(buf)'''
else:
#file, show what you got.
#self.details.get_top_widget()
iter = model.get_iter(treeview.get_cursor()[0])
selected_item = self.model.files_list.get_value(iter, 0)
self.__get_item_info(selected_item)
except:
if __debug__:
print "c_main.py: on_files_cursor_changed() insufficient \
iterator"
#try:
itera = model.get_iter(paths[0])
if model.get_value(itera,4) == 1:
#directory, do nothin', just turn off view
'''self.view['details'].hide()
buf = self.view['details'].get_buffer()
buf.set_text('')
self.view['details'].set_buffer(buf)'''
else:
#file, show what you got.
#self.details.get_top_widget()
iter = model.get_iter(treeview.get_cursor()[0])
selected_item = self.model.files_list.get_value(iter, 0)
self.__get_item_info(selected_item)
#except:
# if __debug__:
# print "c_main.py: on_files_cursor_changed() insufficient iterator"
return
def on_files_key_release_event(self, a, event):
@@ -554,8 +554,7 @@ class MainController(Controller):
self.model.config.confd['confirmquit']:
if not Dialogs.Qst('Quit application - pyGTKtalog',
'Do you really want to quit?',
"Current database is not saved, any changes \
will be lost.").run():
"Current database is not saved, any changes will be lost.").run():
return
self.__store_settings()
@@ -571,16 +570,15 @@ class MainController(Controller):
if self.model.unsaved_project:
if not Dialogs.Qst('Unsaved data - pyGTKtalog',
"Current database isn't saved",
'All changes will be lost. \
Do you really want to abandon it?').run():
'All changes will be lost. Do you really want to abandon it?').run():
return
self.model.new()
# clear "details" buffer
'''txt = ""
buf = self.view['details'].get_buffer()
buf.set_text(txt)
self.view['details'].set_buffer(buf)'''
buf = self.view['description'].get_buffer()
buf.set_text("")
self.view['description'].set_buffer(buf)
self.view['thumb'].hide()
self.__activate_ui()
@@ -729,10 +727,16 @@ class MainController(Controller):
def __get_item_info(self, item):
self.view['description'].show()
set = self.model.get_file_info(item)
buf = self.view['description'].get_buffer()
if set.has_key('description'):
buf.set_text(set['description'])
if set.has_key('file_info'):
buf.set_text(set['file_info'])
if set.has_key('description'):
tag = buf.create_tag()
tag.set_property('weight', pango.WEIGHT_BOLD)
buf.insert_with_tags(buf.get_end_iter(), "\nDetails:\n", tag)
buf.insert(buf.get_end_iter(), set['description'])
else:
buf.set_text('')
self.view['description'].set_buffer(buf)

View File

@@ -75,7 +75,7 @@ class ConfigModel(Model):
'mntwarn': True,
'delwarn': True,
'cd': '/cdrom',
'cd': '/mnt/cdrom',
'ejectapp': 'eject -r',
'retrive': False,
@@ -84,8 +84,17 @@ class ConfigModel(Model):
'exif': True,
'gthumb': False,
'mov_ext': ['avi', 'mkv', 'mpg', 'mpeg', 'wmv'],
'img_ext': ['bmp', 'gif', 'jpg', 'jpeg', 'png'],
'extensions': {'bmp':'identify %s',
'gif':'identify "%s"',
'jpg':'identify "%s"',
'jpeg':'identify "%s"',
'png':'identify "%s"',
'avi':'midentify "%s"',
'mkv':'midentify "%s"',
'mpg':'midentify "%s"',
'mpeg':'midentify "%s"',
'wmv':'midentify "%s"',
},
'showtoolbar':True,
'showstatusbar':True,
@@ -147,21 +156,19 @@ class ConfigModel(Model):
def __init__(self):
Model.__init__(self)
self.category_tree = gtk.ListStore(gobject.TYPE_STRING)
self.ext_list = gtk.ListStore(gobject.TYPE_STRING)
for i in self.filetype_list:
myiter = self.ext_list.insert_before(None,None)
self.ext_list.set_value(myiter,0,i)
self.refresh_ext('img_ext')
self.refresh_ext()
return
def refresh_ext(self, key):
self.ext_tree = gtk.ListStore(gobject.TYPE_STRING)
self.confd[key].sort()
for i in self.confd[key]:
def refresh_ext(self):
self.ext_tree = gtk.ListStore(gobject.TYPE_STRING,
gobject.TYPE_STRING)
keys = sorted(self.confd['extensions'].keys())
for i in keys:
myiter = self.ext_tree.insert_before(None,None)
self.ext_tree.set_value(myiter,0,i)
self.ext_tree.set_value(myiter, 0, i)
self.ext_tree.set_value(myiter, 1, self.confd['extensions'][i])
def save(self):
try:
@@ -190,16 +197,10 @@ class ConfigModel(Model):
count+=1
# extensions sections
newIni.add_section("images extensions")
newIni.add_section("extensions")
count = 1
for i in self.confd['img_ext']:
newIni.add_key(count, i)
count+=1
newIni.add_section("movies extensions")
count = 1
for i in self.confd['mov_ext']:
newIni.add_key(count, i)
for i in self.confd['extensions']:
newIni.add_key(i, self.confd['extensions'][i])
count+=1
# write config
@@ -243,21 +244,11 @@ class ConfigModel(Model):
if __debug__:
print "m_config.py: load() failed to parse option:", opt
pass
elif sec == 'images extensions':
self.confd['img_ext'] = []
elif sec == 'extensions':
self.confd['extensions'] = {}
for opt in parser.options(sec):
try:
self.confd['img_ext'].append(parser.get(sec,opt))
except:
if __debug__:
print "m_config.py: load() failed to parse option:", opt
pass
elif sec == 'movies extensions':
self.confd['mov_ext'] = []
for opt in parser.options(sec):
try:
self.confd['mov_ext'].append(parser.get(sec,opt))
self.confd['extensions'][opt] = parser.get(sec, opt)
except:
if __debug__:
print "m_config.py: load() failed to parse option:", opt

View File

@@ -28,6 +28,7 @@ import base64
import shutil
import tarfile
import tempfile
import string
import gtk
import gobject
@@ -58,17 +59,13 @@ class MainModel(ModelMT):
FIL = 2 # file
LIN = 3 # symbolic link
# filetype kind of
F_UNK = 0 # unknown - default
F_IMG = 1 # images - jpg, gif, tiff itd
F_MOV = 2 # movies and clips - mpg, ogm, mkv, avi, asf, wmv itd
F_MUS = 4 # music - flac, mp3, mpc, ogg itd
F_APP = 5 # applications
F_DOC = 6 # all kind of documents txt/pdf/doc/odf itd
CD = 1 # sorce: cd/dvd
DR = 2 # source: filesystem
# images extensions - only for PIL and EXIF
IMG = ['jpg', 'jpeg', 'gif', 'png', 'tif', 'tiff', 'tga', 'pcx', 'bmp',
'xbm', 'xpm', 'jp2', 'jpx', 'pnm']
def __init__(self):
ModelMT.__init__(self)
self.config = ConfigModel()
@@ -255,9 +252,7 @@ class MainModel(ModelMT):
# all the rest
self.db_cursor.execute("SELECT f.id, f.filename, f.size, f.date, \
f.type, f.filetype, t.filename \
FROM files f \
LEFT JOIN thumbnails t ON f.id = t.file_id \
f.type FROM files f \
WHERE f.parent_id=? AND f.type!=1 \
ORDER BY f.filename", (id,))
data = self.db_cursor.fetchall()
@@ -270,14 +265,11 @@ class MainModel(ModelMT):
self.files_list.set_value(myiter, 4, ch[4])
self.files_list.set_value(myiter, 5, 'kategoria srategoria')
if ch[4] == self.FIL:
if ch[6] != None:
# TODO: change icon to thumbnail
self.files_list.set_value(myiter, 6, gtk.STOCK_FILE)
else:
self.files_list.set_value(myiter, 6, gtk.STOCK_FILE)
self.files_list.set_value(myiter, 6, gtk.STOCK_FILE)
elif ch[4] == self.LIN:
self.files_list.set_value(myiter, 6, gtk.STOCK_INDEX)
return
def get_parent_discs_value(self, child_id):
if child_id:
self.db_cursor.execute("SELECT parent_id FROM files where id=?", (child_id,))
@@ -290,7 +282,7 @@ class MainModel(ModelMT):
"""get file info from database"""
retval = {}
self.db_cursor.execute("SELECT f.filename, f.date, f.size, f.type, \
t.filename \
t.filename, f.description \
FROM files f \
LEFT JOIN thumbnails t ON t.file_id = f.id \
WHERE f.id = ?", (id,))
@@ -298,7 +290,9 @@ class MainModel(ModelMT):
if set:
string = "ID: %d\nFilename: %s\nDate: %s\nSize: %s\ntype: %s" % \
(id, set[0], datetime.fromtimestamp(set[1]), set[2], set[3])
retval['description'] = string
retval['file_info'] = string
if set[5]:
retval['description'] = set[5]
if set[4]:
retval['thumbnail'] = os.path.join(self.internal_dirname, set[4])
@@ -408,22 +402,11 @@ class MainModel(ModelMT):
size_x integer,
size_y integer,
filetype integer,
note TEXT);""")
description TEXT);""")
self.db_cursor.execute("""create table
tags(id INTEGER PRIMARY KEY AUTOINCREMENT,
file_id INTEGER,
tag TEXT);""")
self.db_cursor.execute("""create table
descriptions(id INTEGER PRIMARY KEY AUTOINCREMENT,
file_id INTEGER,
desc TEXT,
image TEXT,
image_x INTEGER,
image_y INTEGER,
thumb TEXT,
thumb_x INTEGER,
thumb_y INTEGER,
thumb_mode TEXT);""")
self.db_cursor.execute("""create table
thumbnails(id INTEGER PRIMARY KEY AUTOINCREMENT,
file_id INTEGER,
@@ -586,15 +569,33 @@ class MainModel(ModelMT):
update = True
sql = """select seq FROM sqlite_sequence WHERE name='files'"""
db_cursor.execute(sql)
fileid=db_cursor.fetchone()[0]
if i.split('.')[-1].lower() in self.config.confd['img_ext']:
sql = """UPDATE files set filetype = ? where id = ?"""
db_cursor.execute(sql, (self.F_IMG, fileid))
if self.config.confd['thumbs']:
path, exif, ret_code = Thumbnail(current_path, base=self.internal_dirname).save(fileid)
if ret_code != -1:
sql = """insert into thumbnails(file_id, filename) values (?, ?)"""
db_cursor.execute(sql, (fileid, path.split(self.internal_dirname)[1][1:]))
fileid = db_cursor.fetchone()[0]
ext = i.split('.')[-1].lower()
# Images - thumbnails and exif data
if self.config.confd['thumbs'] and ext in self.IMG:
path, exif, ret_code = Thumbnail(current_path, base=self.internal_dirname).save(fileid)
if ret_code != -1:
sql = """insert into thumbnails(file_id, filename) values (?, ?)"""
db_cursor.execute(sql, (fileid,
path.split(self.internal_dirname)[1][1:]))
if self.config.confd['exif']:
# TODO: exif implementation
pass
# Extensions - user defined actions
if ext in self.config.confd['extensions'].keys():
cmd = self.config.confd['extensions'][ext]
arg = string.replace(current_path, '"', '\\"')
output = os.popen(cmd % arg).readlines()
desc = ''
for line in output:
desc += line
#desc = string.replace(desc, "\n", "\\n")
sql = """update files set description=? where id=?"""
db_cursor.execute(sql, (desc, fileid))
#if i.split('.').[-1].lower() in mov_ext:
# # video only

View File

@@ -56,6 +56,7 @@ class Thumbnail(object):
if exif.has_key('Image Orientation'):
orientation = exif['Image Orientation'].values[0]
if orientation > 1:
# TODO: replace silly datetime function with tempfile
t = path.join(gettempdir(), "thumb%d.jpg" % datetime.now().microsecond)
im_in = Image.open(filepath)
im_out = None