diff options
author | Denis Fomin <fominde@gmail.com> | 2013-01-19 13:15:36 +0400 |
---|---|---|
committer | Denis Fomin <fominde@gmail.com> | 2013-01-19 13:15:36 +0400 |
commit | 2f2ef7ed141d0f41b3b2d5ac9fbf3b0ef3fe7665 (patch) | |
tree | 622bd7948cdc2c09219b61f7d966bee6e2ad37e7 | |
parent | e8f1bf54f3d078d80f6a823210865cea737f4a81 (diff) |
UrlShortenerPlugin.Add option in plugin config
-rw-r--r-- | url_shortener/config_dialog.ui | 95 | ||||
-rw-r--r-- | url_shortener/manifest.ini | 2 | ||||
-rw-r--r-- | url_shortener/url_shortener.py | 12 |
3 files changed, 82 insertions, 27 deletions
diff --git a/url_shortener/config_dialog.ui b/url_shortener/config_dialog.ui index a700e4d..d1424ec 100644 --- a/url_shortener/config_dialog.ui +++ b/url_shortener/config_dialog.ui @@ -8,40 +8,87 @@ <property name="visible">True</property> <property name="orientation">vertical</property> <child> - <object class="GtkHBox" id="hbox1"> + <object class="GtkFrame" id="frame1"> <property name="visible">True</property> - <property name="extension_events">all</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> <child> - <object class="GtkLabel" id="avatar_size_lebel"> + <object class="GtkTable" id="table1"> <property name="visible">True</property> - <property name="xalign">0.029999999329447746</property> - <property name="label" translatable="yes">The maximum length not be shortened links(chars)</property> - <property name="track_visited_links">False</property> + <property name="n_rows">2</property> + <property name="n_columns">2</property> + <child> + <object class="GtkSpinButton" id="max_chars"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">6</property> + <property name="snap_to_ticks">True</property> + <property name="numeric">True</property> + <signal name="value_changed" handler="avatar_size_value_changed"/> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="y_options"/> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="in_max_chars"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="width_chars">6</property> + <property name="snap_to_ticks">True</property> + <property name="numeric">True</property> + <signal name="value_changed" handler="on_in_max_chars_value_changed"/> + </object> + <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">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="incoming message"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="xpad">13</property> + <property name="label" translatable="yes">incoming message</property> + <property name="track_visited_links">False</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="avatar_size_lebel"> + <property name="visible">True</property> + <property name="xalign">0</property> + <property name="xpad">12</property> + <property name="label" translatable="yes">outgoing message</property> + <property name="track_visited_links">False</property> + </object> + <packing> + <property name="y_options">GTK_EXPAND</property> + </packing> + </child> </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> </child> - <child> - <object class="GtkSpinButton" id="max_chars"> + <child type="label"> + <object class="GtkLabel" id="label1"> <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="width_chars">6</property> - <property name="snap_to_ticks">True</property> - <property name="numeric">True</property> - <signal name="value_changed" handler="avatar_size_value_changed"/> + <property name="label" translatable="yes"><b>The maximum length not be shortened links(chars):</b></property> + <property name="use_markup">True</property> </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> </child> </object> <packing> + <property name="padding">6</property> <property name="position">0</property> </packing> </child> diff --git a/url_shortener/manifest.ini b/url_shortener/manifest.ini index 0963c44..ea17e2c 100644 --- a/url_shortener/manifest.ini +++ b/url_shortener/manifest.ini @@ -1,7 +1,7 @@ [info] name: Url Shortener short_name: url_shortener -version: 0.2 +version: 0.3 description: Plugin that allows users to shorten a long URL in messages. For example, you can turn this link: http://maps.google.com/maps?f=d&saddr=New+York+Penn+Station&daddr=9th+Ave+%26+14th+St,+New+York,+NY&hl=en&geocode=&mra=ls&dirflg=r&date=11%2F12%2F08&time=4:13pm&ttype=dep&noexp=0&noal=0&sort=&sll=40.746175,-73.998395&sspn=0.014468,0.036392&ie=UTF8&z=14 diff --git a/url_shortener/url_shortener.py b/url_shortener/url_shortener.py index c9131e0..27683ae 100644 --- a/url_shortener/url_shortener.py +++ b/url_shortener/url_shortener.py @@ -32,7 +32,8 @@ class UrlShortenerPlugin(GajimPlugin): 'print_special_text': (self.print_special_text, self.print_special_text1),} self.config_default_values = { - 'MAX_CHARS': (50, _('MAX_CHARS(30-...)')), + 'MAX_CHARS': (50, ('MAX_CHARS(30-...)')), + 'IN_MAX_CHARS': (50, ('MAX_CHARS(30-...)')), 'SHORTEN_OUTGOING': (False, ''),} self.events_handlers['message-outgoing'] = (ged.OUT_PRECORE, self.handle_outgoing_msg) @@ -125,7 +126,7 @@ class Base(object): text_is_valid_uri = True if special_text.startswith('www.') or special_text.startswith('ftp.') \ or text_is_valid_uri and not is_xhtml_link: - if len(special_text) < self.plugin.config['MAX_CHARS']: + if len(special_text) < self.plugin.config['IN_MAX_CHARS']: return end_iter = buffer_.get_end_iter() mark = buffer_.create_mark(None, end_iter, True) @@ -202,6 +203,9 @@ class UrlShortenerPluginConfigDialog(GajimPluginConfigDialog): self.max_chars_spinbutton = self.xml.get_object('max_chars') self.max_chars_spinbutton.get_adjustment().set_all(30, 30, 99999, 1, 10, 0) + self.in_max_chars_spinbutton = self.xml.get_object('in_max_chars') + self.in_max_chars_spinbutton.get_adjustment().set_all(30, 30, 99999, 1, + 10, 0) self.shorten_outgoing = self.xml.get_object('shorten_outgoing') hbox = self.xml.get_object('vbox1') self.child.pack_start(hbox) @@ -210,10 +214,14 @@ class UrlShortenerPluginConfigDialog(GajimPluginConfigDialog): def on_run(self): self.max_chars_spinbutton.set_value(self.plugin.config['MAX_CHARS']) + self.in_max_chars_spinbutton.set_value(self.plugin.config['IN_MAX_CHARS']) self.shorten_outgoing.set_active(self.plugin.config['SHORTEN_OUTGOING']) def avatar_size_value_changed(self, spinbutton): self.plugin.config['MAX_CHARS'] = spinbutton.get_value() + def on_in_max_chars_value_changed(self, spinbutton): + self.plugin.config['IN_MAX_CHARS'] = spinbutton.get_value() + def shorten_outgoing_toggled(self, checkbutton): self.plugin.config['SHORTEN_OUTGOING'] = checkbutton.get_active() |