diff options
| -rw-r--r-- | gui/viewtorrents.glade | 63 | ||||
| -rw-r--r-- | src/main.c | 48 |
2 files changed, 92 insertions, 19 deletions
diff --git a/gui/viewtorrents.glade b/gui/viewtorrents.glade index 55715d1..98ffaba 100644 --- a/gui/viewtorrents.glade +++ b/gui/viewtorrents.glade @@ -2,22 +2,21 @@ <interface> <requires lib="gtk+" version="2.18"/> <!-- interface-naming-policy project-wide --> + <object class="GtkAccelGroup" id="accelgroup1"/> <object class="GtkActionGroup" id="actiongroup"> <child> - <object class="GtkAction" id="rehashaction"> - <property name="label" translatable="yes">Rehash</property> - <property name="tooltip" translatable="yes">Rehash selected torrent</property> - <property name="stock_id">gtk-refresh</property> + <object class="GtkAction" id="connectaction"> + <property name="label" translatable="yes">Connect</property> + <property name="tooltip" translatable="yes">Connect to rTorrent</property> + <property name="stock_id">gtk-connect</property> </object> - <accelerator key="r" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="stopaction"> - <property name="label" translatable="yes">Stop</property> - <property name="tooltip" translatable="yes">Stop selected torrent</property> - <property name="stock_id">gtk-media-stop</property> + <object class="GtkAction" id="disconnectaction"> + <property name="label" translatable="yes">Disconnect</property> + <property name="tooltip" translatable="yes">Disconnect from rTorrent</property> + <property name="stock_id">gtk-disconnect</property> </object> - <accelerator key="d" modifiers="GDK_CONTROL_MASK"/> </child> <child> <object class="GtkAction" id="startaction"> @@ -28,18 +27,20 @@ <accelerator key="s" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="disconnectaction"> - <property name="label" translatable="yes">Disconnect</property> - <property name="tooltip" translatable="yes">Disconnect from rTorrent</property> - <property name="stock_id">gtk-disconnect</property> + <object class="GtkAction" id="stopaction"> + <property name="label" translatable="yes">Stop</property> + <property name="tooltip" translatable="yes">Stop selected torrent</property> + <property name="stock_id">gtk-media-stop</property> </object> + <accelerator key="d" modifiers="GDK_CONTROL_MASK"/> </child> <child> - <object class="GtkAction" id="connectaction"> - <property name="label" translatable="yes">Connect</property> - <property name="tooltip" translatable="yes">Connect to rTorrent</property> - <property name="stock_id">gtk-connect</property> + <object class="GtkAction" id="rehashaction"> + <property name="label" translatable="yes">Rehash</property> + <property name="tooltip" translatable="yes">Rehash selected torrent</property> + <property name="stock_id">gtk-refresh</property> </object> + <accelerator key="r" modifiers="GDK_CONTROL_MASK"/> </child> </object> <object class="GtkAboutDialog" id="aboutdialog"> @@ -79,7 +80,6 @@ </object> </child> </object> - <object class="GtkAccelGroup" id="accelgroup1"/> <object class="GtkDialog" id="connectdlg"> <property name="can_focus">False</property> <property name="border_width">5</property> @@ -392,6 +392,31 @@ If authentication is needed, enter username and password as well.</property> </object> </child> <child> + <object class="GtkMenuItem" id="menuitem3"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">_View</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckMenuItem" id="viewtoolbaritem"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Toolbar</property> + <property name="use_underline">True</property> + <property name="active">True</property> + </object> + </child> + </object> + </child> + </object> + </child> + <child> <object class="GtkMenuItem" id="menuitem4"> <property name="use_action_appearance">False</property> <property name="visible">True</property> @@ -64,6 +64,9 @@ typedef struct GtkWidget* top; GtkAction* connectaction, * disconnectaction; GtkAction* startaction, * stopaction, * rehashaction; + GtkCheckMenuItem* viewtoolbaritem; + + GtkToolbar* toolbar; GtkWidget* connectdlg; GtkWidget* connectdlg_url; @@ -261,6 +264,8 @@ static void do_start(GtkAction* action, gpointer data); static void do_stop(GtkAction* action, gpointer data); static void do_rehash(GtkAction* action, gpointer data); +static void do_viewtoolbaritem(GtkCheckMenuItem* checkmenuitem, gpointer data); + static void do_about(GtkMenuItem* menuitem, gpointer data); static gpointer worker_main(gpointer data); @@ -379,6 +384,14 @@ int main(int argc, char** argv) gtk_action_set_sensitive(master.stopaction, FALSE); gtk_action_set_sensitive(master.rehashaction, FALSE); + master.toolbar = GTK_TOOLBAR(gtk_builder_get_object(builder, "toolbar")); + + master.viewtoolbaritem = + GTK_CHECK_MENU_ITEM(gtk_builder_get_object(builder, + "viewtoolbaritem")); + g_signal_connect(master.viewtoolbaritem, + "toggled", G_CALLBACK(do_viewtoolbaritem), &master); + pwddlg = GTK_WIDGET(gtk_builder_get_object(builder, "pwddlg")); gtk_dialog_set_default_response(GTK_DIALOG(pwddlg), GTK_RESPONSE_OK); @@ -457,6 +470,22 @@ int main(int argc, char** argv) gtk_widget_show_all(master.top); + { + GError* error = NULL; + gboolean view = + g_key_file_get_boolean(master.config, "view", "toolbar", &error); + if (!view && error) + { + g_clear_error(&error); + view = TRUE; /* default */ + } + gtk_check_menu_item_set_active(master.viewtoolbaritem, view); + if (!view) + { + gtk_widget_hide(GTK_WIDGET(master.toolbar)); + } + } + master.connectdlg = GTK_WIDGET(gtk_builder_get_object(builder, "connectdlg")); gtk_dialog_set_default_response(GTK_DIALOG(master.connectdlg), @@ -2249,6 +2278,25 @@ void listselection_changed(GtkTreeSelection* selection, gtk_action_set_sensitive(master->rehashaction, FALSE); } +void do_viewtoolbaritem(GtkCheckMenuItem* checkmenuitem, gpointer data) +{ + master_t* master = data; + gboolean active = gtk_check_menu_item_get_active(checkmenuitem); + if (active != gtk_widget_get_visible(GTK_WIDGET(master->toolbar))) + { + if (active) + { + gtk_widget_show_all(GTK_WIDGET(master->toolbar)); + } + else + { + gtk_widget_hide(GTK_WIDGET(master->toolbar)); + } + g_key_file_set_boolean(master->config, "view", "toolbar", active); + save_config(master); + } +} + void do_about(GtkMenuItem* G_GNUC_UNUSED menuitem, gpointer data) { master_t* master = data; |
