39
36
#include "feedlist.h"
40
37
#include "htmlview.h"
41
38
#include "itemlist.h"
43
#include "notification/notification.h"
39
#include "net_monitor.h"
44
40
#include "ui/browser_tabs.h"
41
#include "ui/feed_list_view.h"
45
43
#include "ui/itemview.h"
44
#include "ui/item_list_view.h"
46
45
#include "ui/liferea_dialog.h"
46
#include "ui/search_dialog.h"
47
47
#include "ui/ui_common.h"
48
#include "ui/ui_feedlist.h"
49
#include "ui/ui_indicator.h"
50
#include "ui/ui_itemlist.h"
51
48
#include "ui/ui_prefs.h"
52
#include "ui/ui_script.h"
53
#include "ui/ui_search.h"
54
#include "ui/search_dialog.h"
55
49
#include "ui/ui_session.h"
56
50
#include "ui/ui_tray.h"
57
51
#include "ui/ui_update.h"
59
/* all used icons (FIXME: evil) */
60
GdkPixbuf *icons[MAX_ICONS];
62
static void liferea_shell_class_init (LifereaShellClass *klass);
63
static void liferea_shell_init (LifereaShell *ls);
65
53
#define LIFEREA_SHELL_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), LIFEREA_SHELL_TYPE, LifereaShellPrivate))
67
55
struct LifereaShellPrivate {
70
58
GtkWindow *window; /**< Liferea main window */
71
59
GtkWidget *menubar;
91
80
static GObjectClass *parent_class = NULL;
92
81
static LifereaShell *shell = NULL;
95
liferea_shell_get_type (void)
97
static GType type = 0;
99
if (G_UNLIKELY (type == 0))
101
static const GTypeInfo our_info =
103
sizeof (LifereaShellClass),
104
NULL, /* base_init */
105
NULL, /* base_finalize */
106
(GClassInitFunc) liferea_shell_class_init,
108
NULL, /* class_data */
109
sizeof (LifereaShell),
111
(GInstanceInitFunc) liferea_shell_init
114
type = g_type_register_static (G_TYPE_OBJECT,
83
G_DEFINE_TYPE (LifereaShell, liferea_shell, G_TYPE_OBJECT);
123
86
liferea_shell_finalize (GObject *object)
147
110
g_return_val_if_fail (shell != NULL, NULL);
148
111
g_return_val_if_fail (shell->priv != NULL, NULL);
150
return glade_xml_get_widget (shell->priv->xml, name);
113
return GTK_WIDGET (gtk_builder_get_object (shell->priv->xml, name));
154
117
liferea_shell_init (LifereaShell *ls)
119
/* FIXME: we should only need to load mainwindow, but GtkBuilder won't
120
* load the other required objects, so we need to do it manually...
121
* See fixme in liferea_dialog_new()
122
* http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=508585
124
gchar *objs[] = { "adjustment6", "mainwindow", NULL };
156
125
/* globally accessible singleton */
157
126
g_assert (NULL == shell);
160
129
shell->priv = LIFEREA_SHELL_GET_PRIVATE (ls);
161
shell->priv->xml = glade_xml_new (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "liferea.glade", "mainwindow", GETTEXT_PACKAGE);
162
glade_xml_signal_autoconnect (shell->priv->xml);
130
shell->priv->xml = gtk_builder_new ();
131
if (!gtk_builder_add_objects_from_file (shell->priv->xml, PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "liferea.ui", objs, NULL))
132
g_error ("Loading " PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "liferea.ui failed");
134
gtk_builder_connect_signals (shell->priv->xml, NULL);
172
144
/* load window position */
175
x = conf_get_int_value (LAST_WINDOW_X);
176
y = conf_get_int_value (LAST_WINDOW_Y);
178
w = conf_get_int_value (LAST_WINDOW_WIDTH);
179
h = conf_get_int_value (LAST_WINDOW_HEIGHT);
146
gboolean last_window_maximized;
148
conf_get_int_value (LAST_WINDOW_X, &x);
149
conf_get_int_value (LAST_WINDOW_Y, &y);
151
conf_get_int_value (LAST_WINDOW_WIDTH, &w);
152
conf_get_int_value (LAST_WINDOW_HEIGHT, &h);
181
154
debug4 (DEBUG_GUI, "Retrieved saved setting: size %dx%d position %d:%d", w, h, x, y);
265
243
if (!toolbar_style) /* default to icons */
266
244
gtk_toolbar_set_style (GTK_TOOLBAR (shell->priv->toolbar), GTK_TOOLBAR_ICONS);
267
else if (!strcmp (toolbar_style, "text"))
245
else if (g_str_equal (toolbar_style, "text"))
268
246
gtk_toolbar_set_style (GTK_TOOLBAR (shell->priv->toolbar), GTK_TOOLBAR_TEXT);
269
else if (!strcmp (toolbar_style, "both"))
247
else if (g_str_equal (toolbar_style, "both"))
270
248
gtk_toolbar_set_style (GTK_TOOLBAR (shell->priv->toolbar), GTK_TOOLBAR_BOTH);
271
else if (!strcmp (toolbar_style, "both_horiz") || !strcmp (toolbar_style, "both-horiz") )
249
else if (g_str_equal (toolbar_style, "both_horiz") || g_str_equal (toolbar_style, "both-horiz") )
272
250
gtk_toolbar_set_style (GTK_TOOLBAR (shell->priv->toolbar), GTK_TOOLBAR_BOTH_HORIZ);
273
251
else /* default to icons */
274
252
gtk_toolbar_set_style (GTK_TOOLBAR (shell->priv->toolbar), GTK_TOOLBAR_ICONS);
671
liferea_shell_add_html_tab (const gchar *file, const gchar *name)
673
gchar *filepattern = g_strdup_printf (PACKAGE_DATA_DIR "/" PACKAGE "/doc/html/%s", file);
674
gchar *filename = common_get_localized_filename (filepattern);
675
gchar *fileuri = g_strdup_printf ("file://%s", filename);
677
browser_tabs_add_new (fileuri, name, TRUE);
679
g_free (filepattern);
684
685
on_topics_activate (GtkMenuItem *menuitem, gpointer user_data)
686
gchar *filename = g_strdup_printf ("file://" PACKAGE_DATA_DIR "/" PACKAGE "/doc/html/%s", _("topics_en.html"));
687
browser_tabs_add_new (filename, _("Help Topics"), TRUE);
687
liferea_shell_add_html_tab ("topics_%s.html", _("Help Topics"));
692
691
on_quick_reference_activate (GtkMenuItem *menuitem, gpointer user_data)
694
gchar *filename = g_strdup_printf ("file://" PACKAGE_DATA_DIR "/" PACKAGE "/doc/html/%s", _("reference_en.html"));
695
browser_tabs_add_new (filename, _("Quick Reference"), TRUE);
693
liferea_shell_add_html_tab ("reference_%s.html", _("Quick Reference"));
700
697
on_faq_activate (GtkMenuItem *menuitem, gpointer user_data)
702
gchar *filename = g_strdup_printf ("file://" PACKAGE_DATA_DIR "/" PACKAGE "/doc/html/%s", _("faq_en.html"));
703
browser_tabs_add_new (filename, _("FAQ"), TRUE);
699
liferea_shell_add_html_tab ("faq_%s.html", _("FAQ"));
734
729
export_OPML_file ();
737
// FIXME: change to signal callback
739
liferea_shell_online_status_changed (int online)
733
liferea_shell_set_online_icon (gboolean online)
741
735
GtkWidget *widget;
744
return; // FIXME: this check shouldn't be necessary
746
737
widget = liferea_shell_lookup ("onlineimage");
749
740
liferea_shell_set_status_bar (_("Liferea is now online"));
750
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), icons[ICON_ONLINE]);
751
atk_object_set_name (gtk_widget_get_accessible (widget), _("Work Offline"));
741
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), (GdkPixbuf *)icon_get (ICON_ONLINE));
742
atk_object_set_name (gtk_widget_get_accessible (widget), _("Work Offline"));
753
744
liferea_shell_set_status_bar (_("Liferea is now offline"));
754
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), icons[ICON_OFFLINE]);
745
gtk_image_set_from_pixbuf (GTK_IMAGE (widget), (GdkPixbuf *)icon_get (ICON_OFFLINE));
755
746
atk_object_set_name (gtk_widget_get_accessible (widget), _("Work Online"));
757
748
gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (gtk_action_group_get_action (shell->priv->generalActions, "ToggleOfflineMode")), !online);
759
/* Propagate new online status to other interested widgets */
760
// FIXME: bad design, HTML view implementation needs to register for network events itself
761
liferea_htmlview_set_online (online);
752
liferea_shell_online_status_changed (NetworkMonitor *nm, gboolean online, gpointer userdata)
754
liferea_shell_set_online_icon (online);
762
755
ui_tray_update ();
765
758
/* methods to receive URLs which were dropped anywhere in the main window */
767
liferea_shell_URL_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time)
760
liferea_shell_URL_received (GtkWidget *widget, GdkDragContext *context, gint x, gint y, GtkSelectionData *data, guint info, guint time_received)
769
762
gchar *tmp1, *tmp2, *freeme;
770
763
GtkWidget *mainwindow;
779
g_return_if_fail (data->data != NULL);
772
g_return_if_fail (gtk_selection_data_get_data (data) != NULL);
781
mainwindow = GTK_WIDGET (liferea_shell_lookup ("mainwindow"));
782
treeview = GTK_TREE_VIEW (liferea_shell_lookup ("feedlist"));
774
mainwindow = GTK_WIDGET (shell->priv->window);
775
treeview = GTK_TREE_VIEW (shell->priv->feedlistView);
783
776
model = gtk_tree_view_get_model (treeview);
778
/* x and y are relative to the main window, make them relative to the treeview */
779
gtk_widget_translate_coordinates (mainwindow, GTK_WIDGET (treeview), x, y, &tx, &ty);
785
781
/* Allow link drops only over feed list widget. This is to avoid
786
782
the frequent accidental text drops in the HTML view. */
790
786
if((x > alloc.x+alloc.width) || (x < alloc.x) ||
791
787
(y > alloc.y+alloc.height) || (y < alloc.y)) {
792
gtk_drag_finish (context, FALSE, FALSE, time);
788
gtk_drag_finish (context, FALSE, FALSE, time_received);
796
/* x and y are relative to the main window, make them relative to the treeview */
797
g_assert (gtk_widget_translate_coordinates (mainwindow, GTK_WIDGET (treeview), x, y, &tx, &ty));
799
if ((data->length >= 0) && (data->format == 8)) {
800
/* extra handling to accept multiple drops */
801
freeme = tmp1 = g_strdup (data->data);
792
if ((gtk_selection_data_get_length (data) >= 0) && (gtk_selection_data_get_format (data) == 8)) {
793
/* extra handling to accept multiple drops */
794
freeme = tmp1 = g_strdup (gtk_selection_data_get_data (data));
802
795
while ((tmp2 = strsep (&tmp1, "\n\r"))) {
803
796
if (strlen (tmp2)) {
804
797
/* if the drop is over a node, select it so that feedlist_add_subscription()
806
799
if (gtk_tree_view_get_dest_row_at_pos (treeview, tx, ty, &path, NULL)) {
807
800
if (gtk_tree_model_get_iter (model, &iter, path)) {
808
801
gtk_tree_model_get (model, &iter, FS_PTR, &node, -1);
809
/* if node is NULL, ui_feedlist_select() will unselect the tv */
810
ui_feedlist_select (node);
802
/* if node is NULL, feed_list_view_select() will unselect the tv */
803
feed_list_view_select (node);
812
805
gtk_tree_path_free (path);
814
807
feedlist_add_subscription (g_strdup (tmp2), NULL, NULL,
815
FEED_REQ_RESET_TITLE |
816
808
FEED_REQ_PRIORITY_HIGH);
820
gtk_drag_finish (context, TRUE, FALSE, time);
812
gtk_drag_finish (context, TRUE, FALSE, time_received);
822
gtk_drag_finish (context, FALSE, FALSE, time);
814
gtk_drag_finish (context, FALSE, FALSE, time_received);
827
liferea_shell_setup_URL_receiver (GtkWidget *widget)
819
liferea_shell_setup_URL_receiver (void)
821
GtkWidget *mainwindow;
829
822
GtkTargetEntry target_table[] = {
831
{ "text/plain", 0, 0 },
832
{ "text/uri-list", 0, 1 },
833
{ "_NETSCAPE_URL", 0, 1 },
834
{ "application/x-rootwin-drop", 0, 2 }
823
{ "STRING", GTK_TARGET_OTHER_WIDGET, 0 },
824
{ "text/plain", GTK_TARGET_OTHER_WIDGET, 0 },
825
{ "text/uri-list", GTK_TARGET_OTHER_WIDGET, 1 },
826
{ "_NETSCAPE_URL", GTK_TARGET_OTHER_APP, 1 },
827
{ "application/x-rootwin-drop", GTK_TARGET_OTHER_APP, 2 }
830
mainwindow = GTK_WIDGET (shell->priv->window);
837
832
/* doesn't work with GTK_DEST_DEFAULT_DROP... */
838
gtk_drag_dest_set (widget, GTK_DEST_DEFAULT_ALL,
833
gtk_drag_dest_set (mainwindow, GTK_DEST_DEFAULT_ALL,
839
834
target_table, sizeof (target_table)/sizeof (target_table[0]),
840
835
GDK_ACTION_COPY | GDK_ACTION_MOVE | GDK_ACTION_LINK);
842
g_signal_connect (G_OBJECT (widget), "drag_data_received",
837
g_signal_connect (G_OBJECT (mainwindow), "drag_data_received",
843
838
G_CALLBACK (liferea_shell_URL_received), NULL);
846
static const GtkActionEntry ui_mainwindow_action_entries[] = {
841
static const GtkActionEntry liferea_shell_action_entries[] = {
847
842
{"SubscriptionsMenu", NULL, N_("_Subscriptions")},
848
843
{"UpdateAll", "gtk-refresh", N_("Update _All"), "<control>U", N_("Updates all subscriptions."),
849
844
G_CALLBACK(on_menu_update_all)},
858
853
G_CALLBACK(on_remove_items_activate)},
860
855
{"ItemMenu", NULL, N_("_Item")},
861
{"NextUnreadItem", GTK_STOCK_GO_FORWARD, N_("_Next Unread Item"), "<control>N", N_("Jumps to the next unread item. If necessary selects the next feed with unread items."),
856
/* No tooltip here as it really hinders usability to have it flashing
857
when skimming through items using "Next Unread"! */
858
{"NextUnreadItem", GTK_STOCK_GO_FORWARD, N_("_Next Unread Item"), "<control>N", NULL,
862
859
G_CALLBACK(on_next_unread_item_activate)},
864
861
{"ViewMenu", NULL, N_("_View")},
870
867
{"ToolsMenu", NULL, N_("_Tools")},
871
868
{"ShowUpdateMonitor", NULL, N_("_Update Monitor"), NULL, N_("Show a list of all feeds currently in the update queue"),
872
869
G_CALLBACK(on_menu_show_update_monitor)},
873
{"ShowScriptManager", NULL, N_("_Script Manager"), NULL, N_("Allows to configure and edit LUA hook scripts"),
874
G_CALLBACK(on_menu_show_script_manager)},
875
870
{"ShowPreferences", GTK_STOCK_PREFERENCES, N_("_Preferences"), NULL, N_("Edit Preferences."),
876
871
G_CALLBACK(on_prefbtn_clicked)},
878
873
{"SearchMenu", NULL, N_("S_earch")},
879
874
{"SearchFeeds", "gtk-find", N_("Search All Feeds..."), "<control>F", N_("Show the search dialog."), G_CALLBACK(on_searchbtn_clicked)},
880
{"CreateEngineSearch", NULL, N_("Search With ...")},
882
876
{"HelpMenu", NULL, N_("_Help")},
883
877
{"ShowHelpContents", "gtk-help", N_("_Contents"), "F1", N_("View help for this application."), G_CALLBACK(on_topics_activate)},
899
static GtkToggleActionEntry ui_mainwindow_feedlist_toggle_entries[] = {
893
static GtkToggleActionEntry liferea_shell_feedlist_toggle_entries[] = {
900
894
{"ReducedFeedList", NULL, N_("_Reduced Feed List"), NULL, N_("Hide feeds with no unread items."),
901
895
G_CALLBACK(on_feedlist_reduced_activate)}
904
static const GtkActionEntry ui_mainwindow_add_action_entries[] = {
898
static const GtkActionEntry liferea_shell_add_action_entries[] = {
905
899
{"NewSubscription", "gtk-add", N_("_New Subscription..."), NULL, N_("Adds a subscription to the feed list."),
906
900
G_CALLBACK(on_menu_feed_new)},
907
901
{"NewFolder", NULL, N_("New _Folder..."), NULL, N_("Adds a folder to the feed list."), G_CALLBACK(on_menu_folder_new)},
910
904
{"NewNewsBin", NULL, N_("New _News Bin..."), NULL, N_("Adds a new news bin."), G_CALLBACK(on_new_newsbin_activate)}
913
static const GtkActionEntry ui_mainwindow_feed_action_entries[] = {
907
static const GtkActionEntry liferea_shell_feed_action_entries[] = {
914
908
{"MarkFeedAsRead", "gtk-apply", N_("_Mark Items Read"), "<control>R", N_("Marks all items of the selected feed list node / in the item list as read."),
915
909
G_CALLBACK(on_menu_allread)},
916
910
{"UpdateSelected", "gtk-refresh", N_("_Update"), NULL, N_("Updates the selected subscription or all subscriptions of the selected folder."),
917
911
G_CALLBACK(on_menu_update)}
920
static const GtkActionEntry ui_mainwindow_read_write_action_entries[] = {
914
static const GtkActionEntry liferea_shell_read_write_action_entries[] = {
921
915
{"Properties", "gtk-properties", N_("_Properties"), NULL, N_("Opens the property dialog for the selected subscription."), G_CALLBACK(on_menu_properties)},
922
916
{"DeleteSelected", "gtk-delete", N_("_Remove"), NULL, N_("Removes the selected subscription."), G_CALLBACK(on_menu_delete)}
925
static const GtkActionEntry ui_mainwindow_item_action_entries[] = {
919
static const GtkActionEntry liferea_shell_item_action_entries[] = {
926
920
{"ToggleItemReadStatus", "gtk-apply", N_("Toggle _Read Status"), "<control>M", N_("Toggles the read status of the selected item."),
927
921
G_CALLBACK(on_toggle_unread_status)},
928
922
{"ToggleItemFlag", NULL, N_("Toggle Item _Flag"), "<control>T", N_("Toggles the flag status of the selected item."),
1056
1031
debug0 (DEBUG_GUI, "Loading pane proportions");
1058
if (0 != conf_get_int_value (LAST_VPANE_POS))
1059
gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("leftpane")), conf_get_int_value (LAST_VPANE_POS));
1060
if (0 != conf_get_int_value (LAST_HPANE_POS))
1061
gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("normalViewPane")), conf_get_int_value (LAST_HPANE_POS));
1062
if (0 != conf_get_int_value (LAST_WPANE_POS))
1063
gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("wideViewPane")), conf_get_int_value (LAST_WPANE_POS));
1033
conf_get_int_value (LAST_VPANE_POS, &last_vpane_pos);
1035
gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("leftpane")), last_vpane_pos);
1036
conf_get_int_value (LAST_HPANE_POS, &last_hpane_pos);
1038
gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("normalViewPane")), last_hpane_pos);
1039
conf_get_int_value (LAST_WPANE_POS, &last_wpane_pos);
1041
gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("wideViewPane")), last_wpane_pos);
1081
1057
g_object_new (LIFEREA_SHELL_TYPE, NULL);
1083
1059
shell->priv->window = GTK_WINDOW (liferea_shell_lookup ("mainwindow"));
1085
// FIXME: do we use this anywhere?
1086
gtk_widget_set_name (liferea_shell_lookup ("feedlist"), "feedlist");
1088
1061
/* 2.) menu creation */
1090
1063
debug0 (DEBUG_GUI, "Setting up menues");
1065
shell->priv->itemlist = itemlist_create ();
1092
1067
/* Prepare some toggle button states */
1093
ui_mainwindow_feedlist_toggle_entries[0].is_active = conf_get_bool_value (REDUCED_FEEDLIST);
1068
conf_get_bool_value (REDUCED_FEEDLIST, &toggle);
1069
liferea_shell_feedlist_toggle_entries[0].is_active = toggle;
1095
1071
ui_manager = gtk_ui_manager_new ();
1097
1073
shell->priv->generalActions = gtk_action_group_new ("GeneralActions");
1098
1074
gtk_action_group_set_translation_domain (shell->priv->generalActions, PACKAGE);
1099
gtk_action_group_add_actions (shell->priv->generalActions, ui_mainwindow_action_entries, G_N_ELEMENTS (ui_mainwindow_action_entries), shell->priv);
1100
gtk_action_group_add_toggle_actions (shell->priv->generalActions, ui_mainwindow_action_toggle_entries, G_N_ELEMENTS (ui_mainwindow_action_toggle_entries), shell->priv);
1101
gtk_action_group_add_radio_actions (shell->priv->generalActions, ui_mainwindow_view_radio_entries, G_N_ELEMENTS (ui_mainwindow_view_radio_entries), itemlist_get_view_mode (), (GCallback)on_view_activate, (gpointer)TRUE);
1102
gtk_action_group_add_toggle_actions (shell->priv->generalActions, ui_mainwindow_feedlist_toggle_entries, G_N_ELEMENTS (ui_mainwindow_feedlist_toggle_entries), shell->priv);
1075
gtk_action_group_add_actions (shell->priv->generalActions, liferea_shell_action_entries, G_N_ELEMENTS (liferea_shell_action_entries), shell->priv);
1076
gtk_action_group_add_toggle_actions (shell->priv->generalActions, liferea_shell_action_toggle_entries, G_N_ELEMENTS (liferea_shell_action_toggle_entries), shell->priv);
1077
gtk_action_group_add_radio_actions (shell->priv->generalActions, liferea_shell_view_radio_entries, G_N_ELEMENTS (liferea_shell_view_radio_entries), itemlist_get_view_mode (), (GCallback)on_view_activate, (gpointer)TRUE);
1078
gtk_action_group_add_toggle_actions (shell->priv->generalActions, liferea_shell_feedlist_toggle_entries, G_N_ELEMENTS (liferea_shell_feedlist_toggle_entries), shell->priv);
1103
1079
gtk_ui_manager_insert_action_group (ui_manager, shell->priv->generalActions, 0);
1105
1081
shell->priv->addActions = gtk_action_group_new ("AddActions");
1106
1082
gtk_action_group_set_translation_domain (shell->priv->addActions, PACKAGE);
1107
gtk_action_group_add_actions (shell->priv->addActions, ui_mainwindow_add_action_entries, G_N_ELEMENTS (ui_mainwindow_add_action_entries), shell->priv);
1083
gtk_action_group_add_actions (shell->priv->addActions, liferea_shell_add_action_entries, G_N_ELEMENTS (liferea_shell_add_action_entries), shell->priv);
1108
1084
gtk_ui_manager_insert_action_group (ui_manager, shell->priv->addActions, 0);
1110
1086
shell->priv->feedActions = gtk_action_group_new ("FeedActions");
1111
1087
gtk_action_group_set_translation_domain (shell->priv->feedActions, PACKAGE);
1112
gtk_action_group_add_actions (shell->priv->feedActions, ui_mainwindow_feed_action_entries, G_N_ELEMENTS (ui_mainwindow_feed_action_entries), shell->priv);
1088
gtk_action_group_add_actions (shell->priv->feedActions, liferea_shell_feed_action_entries, G_N_ELEMENTS (liferea_shell_feed_action_entries), shell->priv);
1113
1089
gtk_ui_manager_insert_action_group (ui_manager, shell->priv->feedActions, 0);
1115
1091
shell->priv->readWriteActions = gtk_action_group_new("ReadWriteActions");
1116
1092
gtk_action_group_set_translation_domain (shell->priv->readWriteActions, PACKAGE);
1117
gtk_action_group_add_actions (shell->priv->readWriteActions, ui_mainwindow_read_write_action_entries, G_N_ELEMENTS (ui_mainwindow_read_write_action_entries), shell->priv);
1093
gtk_action_group_add_actions (shell->priv->readWriteActions, liferea_shell_read_write_action_entries, G_N_ELEMENTS (liferea_shell_read_write_action_entries), shell->priv);
1118
1094
gtk_ui_manager_insert_action_group (ui_manager, shell->priv->readWriteActions, 0);
1120
1096
shell->priv->itemActions = gtk_action_group_new ("ItemActions");
1121
1097
gtk_action_group_set_translation_domain (shell->priv->itemActions, PACKAGE);
1122
gtk_action_group_add_actions (shell->priv->itemActions, ui_mainwindow_item_action_entries, G_N_ELEMENTS (ui_mainwindow_item_action_entries), shell->priv);
1098
gtk_action_group_add_actions (shell->priv->itemActions, liferea_shell_item_action_entries, G_N_ELEMENTS (liferea_shell_item_action_entries), shell->priv);
1123
1099
gtk_ui_manager_insert_action_group (ui_manager, shell->priv->itemActions, 0);
1125
1101
accel_group = gtk_ui_manager_get_accel_group (ui_manager);
1205
1179
debug0 (DEBUG_GUI, "Setting up item view");
1207
shell->priv->itemview = itemview_create (ui_itemlist_new (GTK_WIDGET (shell->priv->window)));
1181
shell->priv->itemview = itemview_create (GTK_WIDGET (shell->priv->window));
1209
1183
/* 8.) load icons as required */
1211
1185
debug0 (DEBUG_GUI, "Loading icons");
1213
ui_common_add_pixmap_directory (PACKAGE_DATA_DIR G_DIR_SEPARATOR_S PACKAGE G_DIR_SEPARATOR_S "pixmaps");
1215
/* first try to load icons from theme */
1216
static const gchar *iconThemeNames[] = {
1217
NULL, /* ICON_READ */
1218
NULL, /* ICON_UNREAD */
1219
"emblem-important", /* ICON_FLAG */
1220
NULL, /* ICON_AVAILABLE */
1221
NULL, /* ICON_AVAILABLE_OFFLINE */
1222
NULL, /* ICON_UNAVAILABLE */
1223
NULL, /* ICON_DEFAULT */
1224
NULL, /* ICON_FOLDER_EMPTY */
1225
"folder", /* ICON_FOLDER */
1226
"folder-saved-search", /* ICON_VFOLDER */
1227
NULL, /* ICON_NEWSBIN */
1228
NULL, /* ICON_EMPTY */
1229
NULL, /* ICON_EMPTY_OFFLINE */
1230
"gtk-connect", /* ICON_ONLINE */
1231
"gtk-disconnect", /* ICON_OFFLINE */
1232
NULL, /* ICON_UPDATED */
1233
"mail-attachment", /* ICON_ENCLOSURE */
1237
icon_theme = gtk_icon_theme_get_default ();
1238
for (i = 0; i < MAX_ICONS; i++)
1239
if (iconThemeNames[i])
1240
icons[i] = liferea_shell_get_theme_icon (icon_theme, iconThemeNames[i], 16);
1242
/* and then load own default icons */
1243
static const gchar *iconNames[] = {
1244
"read.xpm", /* ICON_READ */
1245
"unread.png", /* ICON_UNREAD */
1246
"flag.png", /* ICON_FLAG */
1247
"available.png", /* ICON_AVAILABLE */
1248
"available_offline.png", /* ICON_AVAILABLE_OFFLINE */
1249
NULL, /* ICON_UNAVAILABLE */
1250
"default.png", /* ICON_DEFAULT */
1251
"folder_empty.png", /* ICON_FOLDER_EMPTY */
1252
"directory.png", /* ICON_FOLDER */
1253
"vfolder.png", /* ICON_VFOLDER */
1254
"newsbin.png", /* ICON_NEWSBIN */
1255
"empty.png", /* ICON_EMPTY */
1256
"empty_offline.png", /* ICON_EMPTY_OFFLINE */
1257
"online.png", /* ICON_ONLINE */
1258
"offline.png", /* ICON_OFFLINE */
1259
"edit.png", /* ICON_UPDATED */
1260
"attachment.png", /* ICON_ENCLOSURE */
1264
for (i = 0; i < MAX_ICONS; i++)
1266
icons[i] = ui_common_create_pixbuf (iconNames[i]);
1268
/* set up icons that are build from stock */
1269
widget = gtk_button_new ();
1270
icons[ICON_UNAVAILABLE] = gtk_widget_render_icon (widget, GTK_STOCK_DIALOG_ERROR, GTK_ICON_SIZE_MENU, "");
1271
gtk_widget_destroy (widget);
1189
/* 9.) update all menu elements */
1273
1191
liferea_shell_update_toolbar ();
1274
liferea_shell_online_status_changed (network_is_online ());
1276
liferea_shell_setup_URL_receiver (GTK_WIDGET (shell->priv->window)); /* setup URL dropping support */
1193
liferea_shell_setup_URL_receiver (); /* setup URL dropping support */
1278
1195
shell->priv->feedlist = feedlist_create ();
1280
ui_tray_enable (conf_get_bool_value (SHOW_TRAY_ICON)); /* init tray icon */
1282
ui_indicator_init ();
1197
conf_get_bool_value (SHOW_TRAY_ICON, &show_tray_icon);
1199
ui_tray_enable (show_tray_icon); /* init tray icon */
1284
1201
liferea_shell_restore_state ();
1325
1242
g_string_append (buffer, "</h3></td></tr><tr><td colspan=\"2\">");
1326
1243
g_string_append (buffer, _("<p>Welcome to <b>Liferea</b>, a desktop news aggregator for online news "
1328
"<p>The left pane contains the list of your subscriptions. To add a "
1329
"subscription select Feeds -> New Subscription. To browse the headlines "
1330
"of a feed select it in the feed list and the headlines will be loaded "
1331
"into the right pane.</p>"));
1245
"<p>You can add new subscriptions "
1247
"<li>From main menu 'Subscription' -> 'New Subscription'</li>"
1248
"<li>By dropping feed links into the subscription list</li>"
1249
"<li>By right clicking links and choosing 'Subscribe' within Liferea</li>"
1332
1252
g_string_append (buffer, "</td></tr></table>");
1334
1254
g_string_append (buffer, "</div>");
1336
1256
htmlview_finish_output (buffer);
1337
1257
itemview_display_info (buffer->str);
1338
1258
g_string_free (buffer, TRUE);
1260
/* 10. Connect network monitoring and set icon*/
1262
g_signal_connect (network_monitor_get (), "online-status-changed",
1263
G_CALLBACK (liferea_shell_online_status_changed), shell);
1265
liferea_shell_set_online_icon (network_monitor_is_online ());
1340
1267
debug_exit ("liferea_shell_create");
1344
1271
liferea_shell_destroy (void)
1346
ui_feedlist_select (NULL);
1273
feed_list_view_select (NULL);
1347
1274
liferea_shell_save_position ();
1348
ui_indicator_destroy ();
1349
1275
ui_tray_enable (FALSE);
1350
notification_enable (FALSE);
1351
1276
g_object_unref (shell->priv->tabs);
1352
1277
g_object_unref (shell->priv->feedlist);
1278
g_object_unref (shell->priv->itemview);
1354
1280
gtk_widget_destroy (GTK_WIDGET (shell->priv->window));
1282
g_object_unref (shell);
1372
1299
GtkWidget *mainwindow = GTK_WIDGET (shell->priv->window);
1374
if(gdk_window_get_state(GTK_WIDGET(mainwindow)->window) & GDK_WINDOW_STATE_ICONIFIED) {
1301
if (gdk_window_get_state (gtk_widget_get_window (mainwindow)) & GDK_WINDOW_STATE_ICONIFIED) {
1375
1302
/* The window is either iconified, or on another workspace */
1376
1303
/* Raise it in one click */
1377
if (GTK_WIDGET_VISIBLE(mainwindow)) {
1304
if (gtk_widget_get_visible (mainwindow)) {
1378
1305
liferea_shell_save_position ();
1379
gtk_widget_hide(mainwindow);
1306
gtk_widget_hide (mainwindow);
1381
liferea_shell_restore_position();
1382
gtk_window_present(GTK_WINDOW(mainwindow));
1308
liferea_shell_restore_position ();
1309
/* Note: Without deiconify() desktop moving doesn't work in
1310
GNOME+metacity. The window would be moved correctly by
1311
present() but not become visible. */
1312
gtk_window_deiconify (GTK_WINDOW (mainwindow));
1313
gtk_window_present (GTK_WINDOW (mainwindow));
1384
else if(!GTK_WIDGET_VISIBLE(mainwindow)) {
1315
else if (!gtk_widget_get_visible (mainwindow)) {
1385
1316
/* The window is neither iconified nor on another workspace, but is not visible */
1386
1317
liferea_shell_restore_position ();
1387
1318
gtk_window_present (shell->priv->window);