diff --git a/data/glade/preferences_window.glade b/data/glade/preferences_window.glade
index b8dcd9861..7f8ad20d8 100644
--- a/data/glade/preferences_window.glade
+++ b/data/glade/preferences_window.glade
@@ -3359,6 +3359,26 @@ Custom
False
+
+
+
+ True
+ True
+ Always check to see if Gajim is the _default Jabber client on startup
+ True
+ GTK_RELIEF_NORMAL
+ True
+ False
+ False
+ True
+
+
+
+ 0
+ False
+ False
+
+
diff --git a/src/common/config.py b/src/common/config.py
index d41b0673e..504d1369a 100644
--- a/src/common/config.py
+++ b/src/common/config.py
@@ -188,7 +188,7 @@ class Config:
'notification_avatar_height': [opt_int, 48],
'muc_highlight_words': [opt_str, '', _('A semicolon-separated list of words that will be highlighted in group chats.')],
'quit_on_roster_x_button': [opt_bool, False, _('If True, quits Gajim when X button of Window Manager is clicked. This setting is taken into account only if trayicon is used.')],
- 'set_xmpp://_handler_everytime': [opt_bool, False, _('If True, Gajim registers for xmpp:// on each startup.')],
+ 'check_if_gajim_is_default': [opt_bool, True, _('If True, Gajim will check if it\'s the default jabber client on each startup.')],
'show_unread_tab_icon': [opt_bool, False, _('If True, Gajim will display an icon on each tab containing unread messages. Depending on the theme, this icon may be animated.')],
'show_status_msgs_in_roster': [opt_bool, True, _('If True, Gajim will display the status message, if not empty, for every contact under the contact name in roster window.'), True],
'show_avatars_in_roster': [opt_bool, True, '', True],
diff --git a/src/config.py b/src/config.py
index 9c10cd602..bd61dcd68 100644
--- a/src/config.py
+++ b/src/config.py
@@ -492,6 +492,10 @@ class PreferencesWindow:
st = gajim.config.get('send_os_info')
self.xml.get_widget('send_os_info_checkbutton').set_active(st)
+ # send os info
+ st = gajim.config.get('check_if_gajim_is_default')
+ self.xml.get_widget('check_default_client_checkbutton').set_active(st)
+
# set status msg from currently playing music track
widget = self.xml.get_widget(
'set_status_msg_from_current_music_track_checkbutton')
@@ -997,13 +1001,16 @@ class PreferencesWindow:
def on_send_os_info_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'send_os_info')
-
+
+ def on_check_default_client_checkbutton_toggled(self, widget):
+ self.on_checkbutton_toggled(widget, 'check_if_gajim_is_default')
+
def on_notify_gmail_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email')
def on_notify_gmail_extra_checkbutton_toggled(self, widget):
self.on_checkbutton_toggled(widget, 'notify_on_new_gmail_email_extra')
-
+
def fill_msg_treeview(self):
self.xml.get_widget('delete_msg_button').set_sensitive(False)
model = self.msg_tree.get_model()
diff --git a/src/gajim.py b/src/gajim.py
index 957b86646..77a7ed321 100755
--- a/src/gajim.py
+++ b/src/gajim.py
@@ -2061,6 +2061,11 @@ class Interface:
# Do not set gajim.verbose to False if -v option was given
if gajim.config.get('verbose'):
gajim.verbose = True
+
+ # Is Gajim default app?
+ if os.name != 'nt' and gajim.config.get('check_if_gajim_is_default'):
+ gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
+
#add default status messages if there is not in the config file
if len(gajim.config.get_per('statusmsg')) == 0:
for msg in gajim.config.statusmsg_default:
@@ -2255,8 +2260,6 @@ if __name__ == '__main__':
except TypeError:
cli.set_restart_command(len(argv), argv)
- gtkgui_helpers.possibly_set_gajim_as_xmpp_handler()
-
check_paths.check_and_possibly_create_paths()
Interface()
diff --git a/src/gtkgui_helpers.py b/src/gtkgui_helpers.py
index 3f22841e5..f4edef66c 100644
--- a/src/gtkgui_helpers.py
+++ b/src/gtkgui_helpers.py
@@ -630,14 +630,6 @@ def decode_filechooser_file_paths(file_paths):
def possibly_set_gajim_as_xmpp_handler():
'''registers (by default only the first time) xmmp: to Gajim.'''
- try:
- import gconf
- # in try because daemon may not be there
- client = gconf.client_get_default()
- except:
- return
-
-
path_to_dot_kde = os.path.expanduser('~/.kde')
if os.path.exists(path_to_dot_kde):
path_to_kde_file = os.path.join(path_to_dot_kde,
@@ -646,38 +638,29 @@ def possibly_set_gajim_as_xmpp_handler():
path_to_kde_file = None
else:
path_to_kde_file = None
-
- if gajim.config.get('set_xmpp://_handler_everytime'):
- # it's false by default
- we_set = True
- elif client.get_string('/desktop/gnome/url-handlers/xmpp/command') is None:
- # only the first time (GNOME/GCONF)
- we_set = True
- elif path_to_kde_file is not None and not os.path.exists(path_to_kde_file):
- # only the first time (KDE)
- we_set = True
- else:
- we_set = False
-
- if not we_set:
- return
-
- path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True)
- if path_to_gajim_script:
- if typ == 'svn':
- command = path_to_gajim_script + ' handle_uri %s'
- else: # 'installed'
- command = 'gajim-remote handle_uri %s'
-
- # setting for GNOME/Gconf
- client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True)
- client.set_string('/desktop/gnome/url-handlers/xmpp/command', command)
- client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False)
-
- # setting for KDE
- if path_to_kde_file is not None: # user has run kde at least once
- f = open(path_to_kde_file, 'w')
- f.write('''\
+
+ def set_gajim_as_xmpp_handler(widget = None):
+ if widget:
+ # come from confirmation dialog
+ gajim.config.set('check_if_gajim_is_default',
+ dlg.checkbutton.get_active())
+ dlg.destroy()
+ path_to_gajim_script, typ = get_abspath_for_script('gajim-remote', True)
+ if path_to_gajim_script:
+ if typ == 'svn':
+ command = path_to_gajim_script + ' handle_uri %s'
+ else: # 'installed'
+ command = 'gajim-remote handle_uri %s'
+
+ # setting for GNOME/Gconf
+ client.set_bool('/desktop/gnome/url-handlers/xmpp/enabled', True)
+ client.set_string('/desktop/gnome/url-handlers/xmpp/command', command)
+ client.set_bool('/desktop/gnome/url-handlers/xmpp/needs_terminal', False)
+
+ # setting for KDE
+ if path_to_kde_file is not None: # user has run kde at least once
+ f = open(path_to_kde_file, 'w')
+ f.write('''\
[Protocol]
exec=%s "%%u"
protocol=xmpp
@@ -692,7 +675,41 @@ deleting=false
icon=gajim
Description=xmpp
''' % command)
- f.close()
+ f.close()
+
+ try:
+ import gconf
+ # in try because daemon may not be there
+ client = gconf.client_get_default()
+ except:
+ return
+
+ old_command = client.get_string('/desktop/gnome/url-handlers/xmpp/command')
+ if not old_command or old_command.endswith(' open_chat %s'):
+ # first time (GNOME/GCONF) or old Gajim version
+ we_set = True
+ elif path_to_kde_file is not None and not os.path.exists(path_to_kde_file):
+ # only the first time (KDE)
+ we_set = True
+ else:
+ we_set = False
+
+ if we_set:
+ set_gajim_as_xmpp_handler()
+ elif old_command and not old_command.endswith(' handle_uri %s'):
+ # xmpp:// is currently handled by another program, so ask the user
+ pritext = _('Gajim is not the default Jabber client')
+ sectext = _('Would you like to make Gajim the default Jabber client?')
+ checktext = _('Always check to see if Gajim is the default Jabber client '
+ 'on startup')
+ def on_cancel(widget):
+ gajim.config.set('check_if_gajim_is_default',
+ dlg.checkbutton.get_active())
+ dlg.destroy()
+ dlg = dialogs.ConfirmationDialogCheck(pritext, sectext, checktext,
+ set_gajim_as_xmpp_handler, on_cancel)
+ if gajim.config.get('check_if_gajim_is_default'):
+ dlg.checkbutton.set_active(True)
def escape_underscore(s):
'''Escape underlines to prevent them from being interpreted