Permalink
Browse files

[Frontend-GNOME] Implemented configurable auto switch for person and …

…group chats (closes: #385)
  • Loading branch information...
1 parent 10616e5 commit 9d875358b5765520eb3a40add2aee57fdc22e99d @meebey committed May 16, 2012
@@ -1539,6 +1539,33 @@ yy/yyyy = year</property>
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkCheckButton" id="AutoSwitchPersonChatsCheckButton">
+ <property name="label" translatable="yes">Automatically switch to newly opened person chats</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <widget class="GtkCheckButton" id="AutoSwitchGroupChatsCheckButton">
+ <property name="label" translatable="yes">Automatically switch to newly opened group chats</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="_OnChanged"/>
+ </widget>
+ <packing>
+ <property name="expand">False</property>
+ <property name="position">3</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="position">1</property>
@@ -249,7 +249,9 @@ public void Load()
Get(prefix+"EngineBufferLines", 100);
Get(prefix+"StripColors", false);
Get(prefix+"StripFormattings", false);
-
+ Get(prefix+"AutoSwitchPersonChats", false);
+ Get(prefix+"AutoSwitchGroupChats", true);
+
prefix = "Engine/Users/DEFAULT/Interface/Notebook/Tab/";
Get(prefix+"NoActivityColor", "#000000");
Get(prefix+"ActivityColor", "#0080FF");
@@ -459,6 +461,8 @@ public void Load()
LoadUserEntry(user, "Interface/Notebook/EngineBufferLines", null);
LoadUserEntry(user, "Interface/Notebook/StripColors", null);
LoadUserEntry(user, "Interface/Notebook/StripFormattings", null);
+ LoadUserEntry(user, "Interface/Notebook/AutoSwitchPersonChats", null);
+ LoadUserEntry(user, "Interface/Notebook/AutoSwitchGroupChats", null);
LoadUserEntry(user, "Interface/Notebook/Tab/NoActivityColor", null);
LoadUserEntry(user, "Interface/Notebook/Tab/ActivityColor", null);
LoadUserEntry(user, "Interface/Notebook/Tab/EventColor", null);
@@ -43,6 +43,8 @@ public class ChatViewManager : ChatViewManagerBase
private Gtk.TreeView f_TreeView;
private UserConfig f_Config;
ChatViewSyncManager SyncManager { get; set; }
+ bool AutoSwitchPersonChats { get; set; }
+ bool AutoSwitchGroupChats { get; set; }
public event ChatViewManagerChatAddedEventHandler ChatAdded;
public event ChatViewManagerChatRemovedEventHandler ChatRemoved;
@@ -196,7 +198,13 @@ public virtual void ApplyConfig(UserConfig config)
if (config == null) {
throw new ArgumentNullException("config");
}
-
+
+ var prefix = "Interface/Notebook/";
+ AutoSwitchPersonChats =
+ config[prefix + "AutoSwitchPersonChats"] as bool? ?? false;
+ AutoSwitchGroupChats =
+ config[prefix + "AutoSwitchGroupChats"] as bool? ?? true;
+
f_Config = config;
foreach (ChatView chat in f_Chats) {
chat.ApplyConfig(f_Config);
@@ -249,7 +257,11 @@ void OnChatAdded(object sender, ChatViewAddedEventArgs e)
#if GTK_SHARP_2_10
f_Notebook.SetTabReorderable(chatView, true);
#endif
- chatView.ShowAll();
+
+ if ((chatView is PersonChatView && AutoSwitchPersonChats) ||
+ (chatView is GroupChatView && AutoSwitchGroupChats)) {
+ CurrentChatNumber = idx;
+ }
if (ChatAdded != null) {
ChatAdded(this, new ChatViewManagerChatAddedEventArgs(chatView));
@@ -442,7 +442,15 @@ private void _Load()
((Gtk.RadioButton)_Glade["TabPositionRadioButtonNone"]).Active = true;
break;
}
-
+ if (Frontend.UserConfig["Interface/Notebook/AutoSwitchPersonChats"] != null) {
+ ((Gtk.CheckButton) _Glade["AutoSwitchPersonChatsCheckButton"]).Active =
+ (bool) Frontend.UserConfig["Interface/Notebook/AutoSwitchPersonChats"];
+ }
+ if (Frontend.UserConfig["Interface/Notebook/AutoSwitchGroupChats"] != null) {
+ ((Gtk.CheckButton) _Glade["AutoSwitchGroupChatsCheckButton"]).Active =
+ (bool) Frontend.UserConfig["Interface/Notebook/AutoSwitchGroupChats"];
+ }
+
// Interface/Notebook/Channel
switch ((string)Frontend.UserConfig["Interface/Notebook/Channel/UserListPosition"]) {
case "left":
@@ -711,6 +719,7 @@ private void _Save()
Frontend.UserConfig["Interface/ShowAdvancedSettings"] =
((Gtk.CheckButton)_Glade["ShowAdvancedSettingsCheckButton"]).Active;
+ // Interface/Notebook
Frontend.UserConfig["Interface/Notebook/TimestampFormat"] =
((Gtk.Entry)_Glade["TimestampFormatEntry"]).Text;
Frontend.UserConfig["Interface/Notebook/BufferLines"] =
@@ -735,7 +744,13 @@ private void _Save()
tab_position = "none";
}
Frontend.UserConfig["Interface/Notebook/TabPosition"] = tab_position;
-
+
+ Frontend.UserConfig["Interface/Notebook/AutoSwitchPersonChats"] =
+ ((Gtk.CheckButton)_Glade["AutoSwitchPersonChatsCheckButton"]).Active;
+ Frontend.UserConfig["Interface/Notebook/AutoSwitchGroupChats"] =
+ ((Gtk.CheckButton)_Glade["AutoSwitchGroupChatsCheckButton"]).Active;
+
+ // Interface/Notebook/Channel
string userlist_position = null;
if (((Gtk.RadioButton)_Glade["UserListPositionRadioButtonLeft"]).Active) {
userlist_position = "left";
@@ -59,6 +59,7 @@ public PersonChatView(PersonChatModel chat) : base(chat)
PersonChatModel = chat;
Add(OutputScrolledWindow);
+ ShowAll();
}
public override void Sync()
@@ -58,6 +58,7 @@ public SessionChatView(ChatModel chat) : base(chat)
OutputMessageTextView.ShowTimestamps = false;
Add(OutputScrolledWindow);
+ ShowAll();
}
protected override void OnTabButtonPress(object sender, Gtk.ButtonPressEventArgs e)

0 comments on commit 9d87535

Please sign in to comment.