/** * To be called whenever a node was selected and should * replace the current itemlist. */ void itemlist_load (nodePtr node) { itemSetPtr itemSet; gint folder_display_mode; gboolean folder_display_hide_read; debug_enter ("itemlist_load"); g_return_if_fail (NULL != node); debug1 (DEBUG_GUI, "loading item list with node \"%s\"", node_get_title (node)); g_assert (!itemlist->priv->guids); g_assert (!itemlist->priv->filter); /* 1. Filter check. Don't continue if folder is selected and no folder viewing is configured. If folder viewing is enabled set up a "unread items only" rule depending on the prefences. */ /* for folders and other heirarchic nodes do filtering */ if (IS_FOLDER (node) || node->children) { liferea_shell_update_allitems_actions (FALSE, 0 != node->unreadCount); conf_get_int_value (FOLDER_DISPLAY_MODE, &folder_display_mode); if (!folder_display_mode) return; conf_get_bool_value (FOLDER_DISPLAY_HIDE_READ, &folder_display_hide_read); if (folder_display_hide_read) { itemlist->priv->filter = g_new0(struct itemSet, 1); itemlist->priv->filter->anyMatch = TRUE; itemset_add_rule (itemlist->priv->filter, "unread", "", TRUE); } } else {
ItemView * itemview_create (GtkWidget *window) { gint zoom; /* 1. Create widgets, load preferences */ g_object_new (ITEMVIEW_TYPE, NULL); itemview->priv->currentLayoutMode = NODE_VIEW_MODE_INVALID; itemview->priv->itemListView = item_list_view_create (window); itemview->priv->itemListViewContainer = gtk_widget_get_parent (GTK_WIDGET (item_list_view_get_widget (itemview->priv->itemListView))); conf_get_int_value (LAST_ZOOMLEVEL, &zoom); if (zoom == 0) { zoom = 100; conf_set_int_value (LAST_ZOOMLEVEL, zoom); } itemview->priv->zoom = zoom; /* initially we pack the item list in the normal view pane, which is later changed in itemview_set_layout() */ gtk_container_add (GTK_CONTAINER (liferea_shell_lookup ("normalViewItems")), itemview->priv->itemListViewContainer); /* 2. Prepare HTML rendering */ htmlview_init (); return itemview; }
void node_set_view_mode (nodePtr node, nodeViewType viewMode) { gint defaultViewMode; /* To allow users to select a default viewing mode for the layout we need to store only exceptions from this mode, which is why we compare the mode to be set with the default and if it's equal we just set NODE_VIEW_MODE_DEFAULT. This allows to not OPML export the viewMode attribute for nodes the are in default viewing mode, which then allows to follow a switch in the preference to a new default viewing mode. This of course also means that the we use some state on each changing of the view mode preference. */ conf_get_int_value (DEFAULT_VIEW_MODE, &defaultViewMode); if (viewMode != (nodeViewType)defaultViewMode) node->viewMode = viewMode; else node->viewMode = NODE_VIEW_MODE_DEFAULT; }
static void conf_proxy_reset_settings_cb (GSettings *settings, guint cnxn_id, gchar *key, gpointer user_data) { gchar *proxyname, *proxyusername, *proxypassword; gint proxyport; gint proxydetectmode; gboolean proxyuseauth; proxyname = NULL; proxyport = 0; proxyusername = NULL; proxypassword = NULL; conf_get_int_value (PROXY_DETECT_MODE, &proxydetectmode); switch (proxydetectmode) { default: case 0: debug0 (DEBUG_CONF, "proxy auto detect is configured"); /* nothing to do, all done by libproxy inside libsoup */ break; case 1: debug0 (DEBUG_CONF, "proxy is disabled by user"); /* nothing to do */ break; case 2: debug0 (DEBUG_CONF, "manual proxy is configured"); conf_get_str_value (PROXY_HOST, &proxyname); conf_get_int_value (PROXY_PORT, &proxyport); conf_get_bool_value (PROXY_USEAUTH, &proxyuseauth); if (proxyuseauth) { conf_get_str_value (PROXY_USER, &proxyusername); conf_get_str_value (PROXY_PASSWD, &proxypassword); } break; } debug4 (DEBUG_CONF, "Manual proxy settings are now %s:%d %s:%s", proxyname != NULL ? proxyname : "NULL", proxyport, proxyusername != NULL ? proxyusername : "******", proxypassword != NULL ? proxypassword : "******"); network_set_proxy (proxydetectmode, proxyname, proxyport, proxyusername, proxypassword); }
/* * Restore the window position from the values saved into gconf. Note * that this does not display/present/show the mainwindow. */ static void liferea_shell_restore_position (void) { /* load window position */ int x, y, w, h; gboolean last_window_maximized; conf_get_int_value (LAST_WINDOW_X, &x); conf_get_int_value (LAST_WINDOW_Y, &y); conf_get_int_value (LAST_WINDOW_WIDTH, &w); conf_get_int_value (LAST_WINDOW_HEIGHT, &h); debug4 (DEBUG_GUI, "Retrieved saved setting: size %dx%d position %d:%d", w, h, x, y); /* Restore position only if the width and height were saved */ if (w != 0 && h != 0) { if (x >= gdk_screen_width ()) x = gdk_screen_width () - 100; else if (x + w < 0) x = 100; if (y >= gdk_screen_height ()) y = gdk_screen_height () - 100; else if (y + w < 0) y = 100; debug4 (DEBUG_GUI, "Restoring to size %dx%d position %d:%d", w, h, x, y); gtk_window_move (GTK_WINDOW (shell->priv->window), x, y); /* load window size */ gtk_window_resize (GTK_WINDOW (shell->priv->window), w, h); } conf_get_bool_value (LAST_WINDOW_MAXIMIZED, &last_window_maximized); if (last_window_maximized) gtk_window_maximize (GTK_WINDOW (shell->priv->window)); else gtk_window_unmaximize (GTK_WINDOW (shell->priv->window)); }
const gchar * prefs_get_download_command (void) { gint enclosure_download_tool; conf_get_int_value (DOWNLOAD_TOOL, &enclosure_download_tool); /* FIXME: array boundary check */ return enclosure_download_commands[enclosure_download_tool]; }
nodeViewType node_get_view_mode (nodePtr node) { gint defaultViewMode; conf_get_int_value (DEFAULT_VIEW_MODE, &defaultViewMode); if (NODE_VIEW_MODE_DEFAULT == node->viewMode) return defaultViewMode; else return node->viewMode; }
static void feedlist_init (FeedList *fl) { gint startup_feed_action; debug_enter ("feedlist_init"); /* 1. Prepare globally accessible singleton */ g_assert (NULL == feedlist); feedlist = fl; feedlist->priv = FEEDLIST_GET_PRIVATE (fl); feedlist->priv->loading = TRUE; /* 2. Set up a root node and import the feed list source structure. */ debug0 (DEBUG_CACHE, "Setting up root node"); ROOTNODE = node_source_setup_root (); /* 3. Ensure folder expansion and unread count*/ debug0 (DEBUG_CACHE, "Initializing node state"); feedlist_foreach (feedlist_init_node); ui_tray_update (); /* 4. Check if feeds do need updating. */ debug0 (DEBUG_UPDATE, "Performing initial feed update"); conf_get_int_value (STARTUP_FEED_ACTION, &startup_feed_action); if (0 == startup_feed_action) { /* Update all feeds */ if (network_monitor_is_online ()) { debug0 (DEBUG_UPDATE, "initial update: updating all feeds"); node_update_subscription (feedlist_get_root (), GUINT_TO_POINTER (0)); } else { debug0 (DEBUG_UPDATE, "initial update: prevented because we are offline"); } } else { debug0 (DEBUG_UPDATE, "initial update: resetting feed counter"); feedlist_reset_update_counters (NULL); } /* 5. Start automatic updating */ feedlist->priv->autoUpdateTimer = g_timeout_add_seconds (10, feedlist_auto_update, NULL); g_signal_connect (network_monitor_get (), "online-status-changed", G_CALLBACK (on_network_status_changed), NULL); /* 6. Finally save the new feed list state */ feedlist->priv->loading = FALSE; feedlist_schedule_save (); debug_exit ("feedlist_init"); }
/** * To be called whenever an itemset was updated. If it is the * displayed itemset it will be merged against the item list * tree view. */ void itemlist_merge_itemset (itemSetPtr itemSet) { gint folder_display_mode; debug_enter ("itemlist_merge_itemset"); debug_start_measurement (DEBUG_GUI); /* No node check when loading search results directly */ if (!itemlist_priv.isSearchResult) { nodePtr node = node_from_id (itemSet->nodeId); if (!itemlist_priv.currentNode) return; /* Nothing to do if nothing is displayed */ if (!IS_VFOLDER (itemlist_priv.currentNode) && (itemlist_priv.currentNode != node) && !node_is_ancestor (itemlist_priv.currentNode, node)) return; /* Nothing to do if the item set does not belong to this node, or this is a search folder */ conf_get_int_value (FOLDER_DISPLAY_MODE, &folder_display_mode); if (IS_FOLDER (itemlist_priv.currentNode) && !folder_display_mode) return; /* Bail out if it is a folder without the recursive display preference set */ debug1 (DEBUG_GUI, "reloading item list with node \"%s\"", node_get_title (node)); } else { /* If we are loading a search result we must never merge anything besides the search items. In fact if we already have items we just return. */ if (itemlist_priv.searchResultComplete) return; itemlist_priv.searchResultComplete = TRUE; } /* merge items into item view */ itemset_foreach (itemSet, itemlist_merge_item); itemview_update (); debug_end_measurement (DEBUG_GUI, "itemlist merge"); debug_exit ("itemlist_merge_itemset"); }
/* gcc conf.c hash.c -DCONF_TEST_MAIN -I../inc */ int main(int argc, char *argv[]) { conf_t conf = {}; if (argc < 2) { fprintf(stderr, "usage: ./a.out <conf_file>\n"); exit(1); } if (conf_init(&conf, argv[1]) != 0) { fprintf(stderr, "conf_init error\n"); exit(1); } conf_dump(&conf); printf("PORT: %d\n", conf_get_int_value(&conf, "porta", 7777)); printf("LOG_NAME: %s\n", conf_get_str_value(&conf, "log_name", "NULL")); conf_free(&conf); exit(0); }
ItemView * itemview_create (GtkWidget *window) { gint zoom; g_object_new (ITEMVIEW_TYPE, NULL); /* 1. Load preferences */ conf_get_int_value (LAST_ZOOMLEVEL, &zoom); if (zoom == 0) { zoom = 100; conf_set_int_value (LAST_ZOOMLEVEL, zoom); } itemview->priv->zoom = zoom; /* 2. Set initial layout (because no node selected yet) */ itemview_set_layout (NODE_VIEW_MODE_WIDE); return itemview; }
void subscription_auto_update (subscriptionPtr subscription) { gint interval; guint flags = 0; GTimeVal now; if (!subscription) return; interval = subscription_get_update_interval (subscription); if (-1 == interval) conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &interval); if (-2 >= interval || 0 == interval) return; /* don't update this subscription */ g_get_current_time (&now); if (subscription->updateState->lastPoll.tv_sec + interval*60 <= now.tv_sec) subscription_update (subscription, flags); }
/* Helper method checking if the passed item set is relevant for the currently item list content. */ static gboolean itemlist_itemset_is_valid (itemSetPtr itemSet) { gint folder_display_mode; nodePtr node; node = node_from_id (itemSet->nodeId); if (!itemlist->priv->currentNode) return FALSE; /* Nothing to do if nothing is displayed */ if (!IS_VFOLDER (itemlist->priv->currentNode) && (itemlist->priv->currentNode != node) && !node_is_ancestor (itemlist->priv->currentNode, node)) return FALSE; /* Nothing to do if the item set does not belong to this node, or this is a search folder */ conf_get_int_value (FOLDER_DISPLAY_MODE, &folder_display_mode); if (IS_FOLDER (itemlist->priv->currentNode) && !folder_display_mode) return FALSE; /* Bail out if it is a folder without the recursive display preference set */ debug1 (DEBUG_GUI, "reloading item list with node \"%s\"", node_get_title (node)); return TRUE; }
static void subscription_prop_dialog_load (SubscriptionPropDialog *spd, subscriptionPtr subscription) { gint interval; gint default_update_interval; gint defaultInterval, spinSetInterval; gchar *defaultIntervalStr; nodePtr node = subscription->node; feedPtr feed = (feedPtr)node->data; spd->priv->subscription = subscription; /* General */ gtk_entry_set_text(GTK_ENTRY(spd->priv->feedNameEntry), node_get_title(node)); spd->priv->refreshInterval = liferea_dialog_lookup(spd->priv->dialog,"refreshIntervalSpinButton"); interval = subscription_get_update_interval(subscription); defaultInterval = subscription_get_default_update_interval(subscription); conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &default_update_interval); spinSetInterval = defaultInterval > 0 ? defaultInterval : default_update_interval; if (-2 >= interval) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup(spd->priv->dialog, "updateIntervalNever")), TRUE); } else if (-1 == interval) { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup(spd->priv->dialog, "updateIntervalDefault")), TRUE); } else { gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup(spd->priv->dialog, "updateIntervalSpecific")), TRUE); spinSetInterval = interval; } /* Set refresh interval spin button and combo box */ if (spinSetInterval % 1440 == 0) { /* days */ gtk_combo_box_set_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit), 2); spinSetInterval /= 1440; } else if (spinSetInterval % 60 == 0) { /* hours */ gtk_combo_box_set_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit), 1); spinSetInterval /= 60; } else { gtk_combo_box_set_active (GTK_COMBO_BOX (spd->priv->refreshIntervalUnit), 0); } gtk_spin_button_set_value (GTK_SPIN_BUTTON (spd->priv->refreshInterval), spinSetInterval); gtk_widget_set_sensitive (spd->priv->refreshInterval, interval > 0); gtk_widget_set_sensitive (spd->priv->refreshIntervalUnit, interval > 0); /* setup info label about default update interval */ if(-1 != defaultInterval) defaultIntervalStr = g_strdup_printf(ngettext("The provider of this feed suggests an update interval of %d minute.", "The provider of this feed suggests an update interval of %d minutes.", defaultInterval), defaultInterval); else defaultIntervalStr = g_strdup(_("This feed specifies no default update interval.")); gtk_label_set_text(GTK_LABEL(liferea_dialog_lookup(spd->priv->dialog, "feedUpdateInfo")), defaultIntervalStr); g_free(defaultIntervalStr); /* Source (only for feeds) */ if (SUBSCRIPTION_TYPE(subscription) == feed_get_subscription_type ()) { if(subscription_get_source(subscription)[0] == '|') { gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), &(subscription_get_source(subscription)[1])); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spd->priv->cmdRadio), TRUE); ui_subscription_prop_enable_httpauth(spd->priv, FALSE); gtk_widget_set_sensitive(spd->priv->selectFile, TRUE); } else if(strstr(subscription_get_source(subscription), "://") != NULL) { xmlURIPtr uri = xmlParseURI(BAD_CAST subscription_get_source(subscription)); xmlChar *parsedUrl; if(uri) { if(uri->user) { gchar *user = uri->user; gchar *pass = strstr(user, ":"); if(pass) { pass[0] = '\0'; pass++; gtk_entry_set_text(GTK_ENTRY(spd->priv->password), pass); } gtk_entry_set_text(GTK_ENTRY(spd->priv->username), user); xmlFree(uri->user); uri->user = NULL; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spd->priv->authcheckbox), TRUE); } parsedUrl = xmlSaveUri(uri); gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), parsedUrl); xmlFree(parsedUrl); xmlFreeURI(uri); } else { gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), subscription_get_source(subscription)); } ui_subscription_prop_enable_httpauth(spd->priv, TRUE); gtk_widget_set_sensitive(spd->priv->selectFile, FALSE); } else { /* File */ gtk_entry_set_text(GTK_ENTRY(spd->priv->sourceEntry), subscription_get_source(subscription)); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(spd->priv->fileRadio), TRUE); ui_subscription_prop_enable_httpauth(spd->priv, FALSE); gtk_widget_set_sensitive(spd->priv->selectFile, TRUE); } if(subscription_get_filter(subscription)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "filterCheckbox")), TRUE); gtk_entry_set_text(GTK_ENTRY(liferea_dialog_lookup(spd->priv->dialog, "filterEntry")), subscription_get_filter(subscription)); } } /* Archive */ if(feed->cacheLimit == CACHE_DISABLE) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheDisable")), TRUE); } else if(feed->cacheLimit == CACHE_DEFAULT) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheDefault")), TRUE); } else if(feed->cacheLimit == CACHE_UNLIMITED) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheUnlimited")), TRUE); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "feedCacheLimited")), TRUE); gtk_spin_button_set_value(GTK_SPIN_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "cacheItemLimit")), feed->cacheLimit); } gtk_widget_set_sensitive(liferea_dialog_lookup(spd->priv->dialog, "cacheItemLimit"), feed->cacheLimit > 0); on_feed_prop_filtercheck(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "filterCheckbox")), spd->priv); /* Download */ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(liferea_dialog_lookup(spd->priv->dialog, "dontUseProxyCheck")), subscription->updateOptions->dontUseProxy); /* Advanced */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "enclosureDownloadCheck")), feed->encAutoDownload); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "loadItemLinkCheck")), node->loadItemLink); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "ignoreCommentFeeds")), feed->ignoreComments); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "enforcePopupCheck")), feed->enforcePopup); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "preventPopupCheck")), feed->preventPopup); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (spd->priv->dialog, "markAsReadCheck")), feed->markAsRead); /* Remove tabs we do not need... */ if (SUBSCRIPTION_TYPE(subscription) != feed_get_subscription_type ()) { /* Remove "Allgemein", "Source" and "Download" tab */ gtk_notebook_remove_page (GTK_NOTEBOOK (liferea_dialog_lookup (spd->priv->dialog, "subscriptionPropNotebook")), 0); gtk_notebook_remove_page (GTK_NOTEBOOK (liferea_dialog_lookup (spd->priv->dialog, "subscriptionPropNotebook")), 0); gtk_notebook_remove_page (GTK_NOTEBOOK (liferea_dialog_lookup (spd->priv->dialog, "subscriptionPropNotebook")), 1); } }
static gboolean on_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer data) { gboolean modifier_matches = FALSE; guint default_modifiers; const gchar *type; GtkWidget *focusw; gint browse_key_setting; if (event->type == GDK_KEY_PRESS) { default_modifiers = gtk_accelerator_get_default_mod_mask (); /* handle [<modifier>+]<Space> headline skimming hotkey */ switch (event->keyval) { case GDK_KEY_space: conf_get_int_value (BROWSE_KEY_SETTING, &browse_key_setting); switch (browse_key_setting) { default: case 0: modifier_matches = ((event->state & default_modifiers) == 0); /* Hack to make space handled in the module. This is necessary because the HTML widget code must be able to catch spaces for input fields. By ignoring the space here it will be passed to the HTML widget which in turn will pass it back if it is not eaten by any input field currently focussed. */ return FALSE; case 1: modifier_matches = ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK); break; case 2: modifier_matches = ((event->state & GDK_MOD1_MASK) == GDK_MOD1_MASK); break; } if (modifier_matches) { itemview_scroll (); return TRUE; } break; } /* some <Ctrl> hotkeys that overrule the HTML view */ if ((event->state & GDK_CONTROL_MASK) == GDK_CONTROL_MASK) { switch (event->keyval) { case GDK_KEY_KP_Add: case GDK_KEY_equal: case GDK_KEY_plus: liferea_shell_do_zoom (TRUE); return TRUE; break; case GDK_KEY_KP_Subtract: case GDK_KEY_minus: liferea_shell_do_zoom (FALSE); return TRUE; break; } } /* prevent usage of navigation keys in entries */ focusw = gtk_window_get_focus (GTK_WINDOW (widget)); if (!focusw || GTK_IS_ENTRY (focusw)) return FALSE; /* prevent usage of navigation keys in HTML view */ type = g_type_name (G_OBJECT_TYPE (focusw)); if (type && (g_str_equal (type, "WebKitWebView"))) return FALSE; /* check for treeview navigation */ if (0 == (event->state & default_modifiers)) { switch (event->keyval) { case GDK_KEY_KP_Delete: case GDK_KEY_Delete: if (focusw == GTK_WIDGET (shell->priv->feedlistView)) return FALSE; /* to be handled in feed_list_view_key_press_cb() */ on_remove_item_activate (NULL, NULL); return TRUE; break; case GDK_KEY_n: on_next_unread_item_activate (NULL, NULL); return TRUE; break; case GDK_KEY_f: itemview_move_cursor (1); return TRUE; break; case GDK_KEY_b: itemview_move_cursor (-1); return TRUE; break; case GDK_KEY_u: ui_common_treeview_move_cursor (shell->priv->feedlistView, -1); itemview_move_cursor_to_first (); return TRUE; break; case GDK_KEY_d: ui_common_treeview_move_cursor (shell->priv->feedlistView, 1); itemview_move_cursor_to_first (); return TRUE; break; } } } return FALSE; }
static void liferea_shell_restore_state (const gchar *overrideWindowState) { gchar *toolbar_style, *accels_file; gint last_vpane_pos, last_hpane_pos, last_wpane_pos; gint resultState; debug0 (DEBUG_GUI, "Setting toolbar style"); toolbar_style = conf_get_toolbar_style (); liferea_shell_set_toolbar_style (toolbar_style); g_free (toolbar_style); debug0 (DEBUG_GUI, "Loading accelerators"); accels_file = common_create_config_filename ("accels"); gtk_accel_map_load (accels_file); g_free (accels_file); debug0 (DEBUG_GUI, "Restoring window position"); liferea_shell_restore_position (); debug0 (DEBUG_GUI, "Loading pane proportions"); conf_get_int_value (LAST_VPANE_POS, &last_vpane_pos); if (last_vpane_pos) gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("leftpane")), last_vpane_pos); conf_get_int_value (LAST_HPANE_POS, &last_hpane_pos); if (last_hpane_pos) gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("normalViewPane")), last_hpane_pos); conf_get_int_value (LAST_WPANE_POS, &last_wpane_pos); if (last_wpane_pos) gtk_paned_set_position (GTK_PANED (liferea_shell_lookup ("wideViewPane")), last_wpane_pos); /* Apply horrible window state parameter logic: -> overrideWindowState provides optional command line flags passed by user or the session manager (prio 1) -> lastState provides last shutdown preference (prio 2) */ /* Initialize with last saved state */ conf_get_int_value (LAST_WINDOW_STATE, &resultState); /* Override with command line options */ if (!g_strcmp0 (overrideWindowState, "hidden")) resultState = MAINWINDOW_HIDDEN; if (!g_strcmp0 (overrideWindowState, "shown")) resultState = MAINWINDOW_SHOWN; /* And set the window to the resulting state */ switch (resultState) { case MAINWINDOW_HIDDEN: debug0 (DEBUG_GUI, "Restoring window state 'hidden (to tray)'"); /* Realize needed so that the window structure can be accessed... otherwise we get a GTK warning when window is shown by clicking on notification icon or when theme colors are fetched. */ gtk_widget_realize (GTK_WIDGET (shell->priv->window)); gtk_widget_hide (GTK_WIDGET (shell->priv->window)); break; case MAINWINDOW_SHOWN: default: /* Safe default is always to show window */ debug0 (DEBUG_GUI, "Restoring window state 'shown'"); gtk_widget_show (GTK_WIDGET (shell->priv->window)); } }
void preferences_dialog_init (PreferencesDialog *pd) { GtkWidget *widget, *entry; GtkComboBox *combo; GtkListStore *store; GtkTreeIter treeiter; GtkAdjustment *itemCount; GtkTreeStore *treestore; GtkTreeViewColumn *column; GSList *list; gchar *proxyport; gchar *configuredBrowser, *name; gboolean enabled; static int manual; struct browser *iter; gint tmp, i, iSetting, proxy_port; gboolean bSetting, show_tray_icon; gchar *proxy_host, *proxy_user, *proxy_passwd; gchar *browser_command; prefdialog = pd; pd->priv = PREFERENCES_DIALOG_GET_PRIVATE (pd); pd->priv->dialog = liferea_dialog_new ("prefs.ui", "prefdialog"); /* Set up browser selection popup */ store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_INT); for(i = 0, iter = browser_get_all (); iter->id != NULL; iter++, i++) { gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _(iter->display), 1, i, -1); } manual = i; /* This allows the user to choose their own browser by typing in the command. */ gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("Manual"), 1, i, -1); combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "browserpopup")); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); ui_common_setup_combo_text (combo, 0); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(on_browser_changed), pd); /* Create location menu */ store = gtk_list_store_new (1, G_TYPE_STRING); combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "browserlocpopup")); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); ui_common_setup_combo_text (combo, 0); g_signal_connect(G_OBJECT(combo), "changed", G_CALLBACK(on_browser_place_changed), pd); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("Browser default"), -1); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("Existing window"), -1); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("New window"), -1); gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, _("New tab"), -1); /* ================== panel 1 "feeds" ==================== */ /* check box for feed startup update */ conf_get_int_value (STARTUP_FEED_ACTION, &iSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "startupactionbtn")), (iSetting == 0)); /* cache size setting */ widget = liferea_dialog_lookup (pd->priv->dialog, "itemCountBtn"); itemCount = gtk_spin_button_get_adjustment (GTK_SPIN_BUTTON (widget)); conf_get_int_value (DEFAULT_MAX_ITEMS, &iSetting); gtk_adjustment_set_value (itemCount, iSetting); /* set default update interval spin button and unit combo box */ ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "globalRefreshIntervalUnitComboBox"), default_update_interval_unit_options, G_CALLBACK (on_default_update_interval_unit_changed), -1); widget = liferea_dialog_lookup (pd->priv->dialog, "globalRefreshIntervalUnitComboBox"); conf_get_int_value (DEFAULT_UPDATE_INTERVAL, &tmp); if (tmp % 1440 == 0) { /* days */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 2); tmp /= 1440; } else if (tmp % 60 == 0) { /* hours */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 1); tmp /= 60; } else { /* minutes */ gtk_combo_box_set_active (GTK_COMBO_BOX (widget), 0); } widget = liferea_dialog_lookup (pd->priv->dialog,"globalRefreshIntervalSpinButton"); gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), tmp); g_signal_connect (G_OBJECT (widget), "changed", G_CALLBACK (on_default_update_interval_value_changed), pd); /* ================== panel 2 "folders" ==================== */ g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "updateAllFavicons")), "clicked", G_CALLBACK(on_updateallfavicons_clicked), pd); conf_get_int_value (FOLDER_DISPLAY_MODE, &iSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "folderdisplaybtn")), iSetting?TRUE:FALSE); conf_get_bool_value (FOLDER_DISPLAY_HIDE_READ, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "hidereadbtn")), bSetting?TRUE:FALSE); /* ================== panel 3 "headlines" ==================== */ conf_get_int_value (BROWSE_KEY_SETTING, &iSetting); ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "skimKeyCombo"), browser_skim_key_options, G_CALLBACK (on_skim_key_changed), iSetting); conf_get_int_value (DEFAULT_VIEW_MODE, &iSetting); ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "defaultViewModeCombo"), default_view_mode_options, G_CALLBACK (on_default_view_mode_changed), iSetting); /* Setup social bookmarking list */ i = 0; conf_get_str_value (SOCIAL_BM_SITE, &name); store = gtk_list_store_new (1, G_TYPE_STRING); list = bookmarkSites; while (list) { socialSitePtr siter = list->data; if (name && !strcmp (siter->name, name)) tmp = i; gtk_list_store_append (store, &treeiter); gtk_list_store_set (store, &treeiter, 0, siter->name, -1); list = g_slist_next (list); i++; } combo = GTK_COMBO_BOX (liferea_dialog_lookup (pd->priv->dialog, "socialpopup")); g_signal_connect (G_OBJECT (combo), "changed", G_CALLBACK (on_socialsite_changed), pd); gtk_combo_box_set_model (combo, GTK_TREE_MODEL (store)); ui_common_setup_combo_text (combo, 0); gtk_combo_box_set_active (combo, tmp); /* ================== panel 4 "browser" ==================== */ /* set the inside browsing flag */ widget = liferea_dialog_lookup(pd->priv->dialog, "browseinwindow"); conf_get_bool_value(BROWSE_INSIDE_APPLICATION, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting); /* set the javascript-disabled flag */ widget = liferea_dialog_lookup(pd->priv->dialog, "disablejavascript"); conf_get_bool_value(DISABLE_JAVASCRIPT, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting); /* set the enable Plugins flag */ widget = liferea_dialog_lookup(pd->priv->dialog, "enableplugins"); conf_get_bool_value(ENABLE_PLUGINS, &bSetting); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widget), bSetting); tmp = 0; conf_get_str_value(BROWSER_ID, &configuredBrowser); if(!strcmp(configuredBrowser, "manual")) tmp = manual; else for(i=0, iter = browser_get_all (); iter->id != NULL; iter++, i++) if(!strcmp(configuredBrowser, iter->id)) tmp = i; gtk_combo_box_set_active(GTK_COMBO_BOX(liferea_dialog_lookup(pd->priv->dialog, "browserpopup")), tmp); g_free(configuredBrowser); conf_get_int_value (BROWSER_PLACE, &iSetting); gtk_combo_box_set_active(GTK_COMBO_BOX(liferea_dialog_lookup(pd->priv->dialog, "browserlocpopup")), iSetting); conf_get_str_value (BROWSER_COMMAND, &browser_command); entry = liferea_dialog_lookup(pd->priv->dialog, "browsercmd"); gtk_entry_set_text(GTK_ENTRY(entry), browser_command); g_free (browser_command); gtk_widget_set_sensitive (GTK_WIDGET (entry), tmp == manual); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "manuallabel"), tmp == manual); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "urlhintlabel"), tmp == manual); /* ================== panel 4 "GUI" ================ */ widget = liferea_dialog_lookup (pd->priv->dialog, "popupwindowsoptionbtn"); conf_get_bool_value (SHOW_POPUP_WINDOWS, &bSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting); widget = liferea_dialog_lookup (pd->priv->dialog, "trayiconoptionbtn"); conf_get_bool_value (SHOW_TRAY_ICON, &show_tray_icon); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), show_tray_icon); widget = liferea_dialog_lookup (pd->priv->dialog, "newcountintraybtn"); conf_get_bool_value (SHOW_NEW_COUNT_IN_TRAY, &bSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "newcountintraybtn"), show_tray_icon); widget = liferea_dialog_lookup (pd->priv->dialog, "minimizetotraybtn"); conf_get_bool_value (DONT_MINIMIZE_TO_TRAY, &bSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "minimizetotraybtn"), show_tray_icon); widget = liferea_dialog_lookup (pd->priv->dialog, "startintraybtn"); conf_get_bool_value (START_IN_TRAY, &bSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting); gtk_widget_set_sensitive (liferea_dialog_lookup (pd->priv->dialog, "startintraybtn"), show_tray_icon); if (ui_indicator_is_visible ()) { /* If we use the indicator applet: - The "show tray icon" and "minimize to tray icon" settings are interpreted as "show indicator" and "minimize to indicator" - The "new count in tray icon" setting doesn't make sense and is ignored by indicator handling code */ gtk_widget_hide (liferea_dialog_lookup (pd->priv->dialog, "newcountintraybtn")); gtk_button_set_label (GTK_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "trayiconoptionbtn")), _("Integrate with the messaging menu (indicator)")); gtk_button_set_label (GTK_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "minimizetotraybtn")), _("Terminate instead of minimizing to the messaging menu")); gtk_button_set_label (GTK_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "startintraybtn")), _("Start minimized to the messaging menu")); } /* tool bar settings */ widget = liferea_dialog_lookup (pd->priv->dialog, "hidetoolbarbtn"); conf_get_bool_value(DISABLE_TOOLBAR, &bSetting); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), bSetting); /* select currently active toolbar style option */ conf_get_str_value (TOOLBAR_STYLE, &name); for (i = 0; gui_toolbar_style_values[i] != NULL; ++i) { if (strcmp (name, gui_toolbar_style_values[i]) == 0) break; } g_free (name); /* On invalid key value: revert to default */ if (gui_toolbar_style_values[i] == NULL) i = 0; /* create toolbar style menu */ ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "toolbarCombo"), gui_toolbar_style_options, G_CALLBACK (on_gui_toolbar_style_changed), i); /* ================= panel 5 "proxy" ======================== */ conf_get_str_value (PROXY_HOST, &proxy_host); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyhostentry")), proxy_host); g_free (proxy_host); conf_get_int_value (PROXY_PORT, &proxy_port); proxyport = g_strdup_printf ("%d", proxy_port); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyportentry")), proxyport); g_free (proxyport); conf_get_bool_value (PROXY_USEAUTH, &enabled); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "useProxyAuth")), enabled); conf_get_str_value (PROXY_USER, &proxy_user); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxyusernameentry")), proxy_user); g_free (proxy_user); conf_get_str_value (PROXY_PASSWD, &proxy_passwd); gtk_entry_set_text (GTK_ENTRY (liferea_dialog_lookup (pd->priv->dialog, "proxypasswordentry")), proxy_passwd); g_free (proxy_passwd); gtk_widget_set_sensitive (GTK_WIDGET (liferea_dialog_lookup(pd->priv->dialog, "proxyauthtable")), enabled); conf_get_int_value (PROXY_DETECT_MODE, &i); switch (i) { default: case 0: /* proxy auto detect */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "proxyAutoDetectRadio")), TRUE); enabled = FALSE; break; case 1: /* no proxy */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "noProxyRadio")), TRUE); enabled = FALSE; break; case 2: /* manual proxy */ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (liferea_dialog_lookup (pd->priv->dialog, "manualProxyRadio")), TRUE); enabled = TRUE; break; } gtk_widget_set_sensitive (GTK_WIDGET (liferea_dialog_lookup (pd->priv->dialog, "proxybox")), enabled); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyAutoDetectRadio")), "clicked", G_CALLBACK (on_proxyAutoDetect_clicked), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "noProxyRadio")), "clicked", G_CALLBACK (on_noProxy_clicked), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "manualProxyRadio")), "clicked", G_CALLBACK (on_manualProxy_clicked), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyhostentry")), "changed", G_CALLBACK (on_proxyhostentry_changed), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyportentry")), "changed", G_CALLBACK (on_proxyportentry_changed), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxyusernameentry")), "changed", G_CALLBACK (on_proxyusernameentry_changed), pd); g_signal_connect (G_OBJECT (liferea_dialog_lookup (pd->priv->dialog, "proxypasswordentry")), "changed", G_CALLBACK (on_proxypasswordentry_changed), pd); /* ================= panel 6 "Enclosures" ======================== */ /* menu for download tool */ conf_get_int_value (DOWNLOAD_TOOL, &iSetting); ui_common_setup_combo_menu (liferea_dialog_lookup (pd->priv->dialog, "downloadToolCombo"), enclosure_download_tool_options, G_CALLBACK (on_enclosure_download_tool_changed), iSetting); /* set up list of configured enclosure types */ treestore = gtk_tree_store_new (FTS_LEN, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_POINTER); list = (GSList *)enclosure_mime_types_get (); while (list) { GtkTreeIter *newIter = g_new0 (GtkTreeIter, 1); gtk_tree_store_append (treestore, newIter, NULL); gtk_tree_store_set (treestore, newIter, FTS_TYPE, (NULL != ((encTypePtr)(list->data))->mime)?((encTypePtr)(list->data))->mime:((encTypePtr)(list->data))->extension, FTS_CMD, ((encTypePtr)(list->data))->cmd, FTS_PTR, list->data, -1); list = g_slist_next (list); } widget = liferea_dialog_lookup (pd->priv->dialog, "enc_action_view"); gtk_tree_view_set_model (GTK_TREE_VIEW (widget), GTK_TREE_MODEL (treestore)); column = gtk_tree_view_column_new_with_attributes (_("Type"), gtk_cell_renderer_text_new (), "text", FTS_TYPE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (widget), column); gtk_tree_view_column_set_sort_column_id (column, FTS_TYPE); column = gtk_tree_view_column_new_with_attributes (_("Program"), gtk_cell_renderer_text_new (), "text", FTS_CMD, NULL); gtk_tree_view_column_set_sort_column_id (column, FTS_CMD); gtk_tree_view_append_column (GTK_TREE_VIEW(widget), column); gtk_tree_selection_set_mode (gtk_tree_view_get_selection (GTK_TREE_VIEW(widget)), GTK_SELECTION_SINGLE); /* ================= panel 7 "Plugins" ======================== */ pd->priv->plugins_box = liferea_dialog_lookup (pd->priv->dialog, "plugins_box"); g_assert (pd->priv->plugins_box != NULL); GtkWidget *alignment; alignment = gtk_alignment_new (0., 0., 1., 1.); gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 12, 12, 12, 12); widget = peas_gtk_plugin_manager_new (NULL); g_assert (widget != NULL); gtk_container_add (GTK_CONTAINER (alignment), widget); gtk_box_pack_start (GTK_BOX (pd->priv->plugins_box), alignment, TRUE, TRUE, 0); g_signal_connect_object (pd->priv->dialog, "destroy", G_CALLBACK (preferences_dialog_destroy_cb), pd, 0); gtk_widget_show_all (pd->priv->dialog); gtk_window_present (GTK_WINDOW (pd->priv->dialog)); }
static void conf_proxy_reset_settings_cb (GSettings *settings, guint cnxn_id, gchar *key, gpointer user_data) { gchar *proxyname, *proxyusername, *proxypassword, *tmp; gboolean gnomeUseProxy; guint proxyport; gint proxydetectmode; gboolean proxyuseauth; xmlURIPtr uri; proxyname = NULL; proxyport = 0; proxyusername = NULL; proxypassword = NULL; conf_get_int_value (PROXY_DETECT_MODE, &proxydetectmode); switch (proxydetectmode) { default: case 0: debug0 (DEBUG_CONF, "proxy auto detect is configured"); /* first check for a configured GNOME proxy, note: older GNOME versions do use the boolean flag GNOME_USE_PROXY while newer ones use the string key GNOME_PROXY_MODE */ conf_get_str_value_from_schema (proxy_settings, GNOME_PROXY_MODE, &tmp); gnomeUseProxy = g_str_equal (tmp, "manual"); g_free (tmp); /* first check for a configured GNOME proxy */ if (gnomeUseProxy) { conf_get_str_value_from_schema (proxy_settings, GNOME_PROXY_HOST, &proxyname); conf_get_int_value_from_schema (proxy_settings, GNOME_PROXY_PORT, &proxyport); debug2 (DEBUG_CONF, "using GNOME configured proxy: \"%s\" port \"%d\"", proxyname, proxyport); conf_get_bool_value_from_schema (proxy_settings, GNOME_PROXY_USEAUTH, &proxyuseauth); if (proxyuseauth) { conf_get_str_value_from_schema (proxy_settings, GNOME_PROXY_USER, &proxyusername); conf_get_str_value_from_schema (proxy_settings, GNOME_PROXY_PASSWD, &proxypassword); } } else { /* otherwise there could be a proxy specified in the environment the following code was derived from SnowNews' setup.c */ if (g_getenv("http_proxy")) { /* The pointer returned by getenv must not be altered. What about mentioning this in the manpage of getenv? */ debug0 (DEBUG_CONF, "using proxy from environment"); do { uri = xmlParseURI (BAD_CAST g_getenv ("http_proxy")); if (uri == NULL) { debug0 (DEBUG_CONF, "parsing URI in $http_proxy failed!"); break; } if (uri->server == NULL) { debug0 (DEBUG_CONF, "could not determine proxy name from $http_proxy!"); xmlFreeURI (uri); break; } proxyname = g_strdup (uri->server); proxyport = (uri->port == 0) ? 3128 : uri->port; if (uri->user) { tmp = strtok (uri->user, ":"); tmp = strtok (NULL, ":"); if (tmp) { proxyusername = g_strdup (uri->user); proxypassword = g_strdup (tmp); } } xmlFreeURI (uri); } while (FALSE); } } if (!proxyname) debug0 (DEBUG_CONF, "no proxy GNOME of $http_proxy configuration found..."); break; case 1: debug0 (DEBUG_CONF, "proxy is disabled by user"); /* nothing to do */ break; case 2: debug0 (DEBUG_CONF, "manual proxy is configured"); conf_get_str_value (PROXY_HOST, &proxyname); conf_get_int_value (PROXY_PORT, &proxyport); conf_get_bool_value (PROXY_USEAUTH, &proxyuseauth); if (proxyuseauth) { conf_get_str_value (PROXY_USER, &proxyusername); conf_get_str_value (PROXY_PASSWD, &proxypassword); } break; } debug4 (DEBUG_CONF, "Proxy settings are now %s:%d %s:%s", proxyname != NULL ? proxyname : "NULL", proxyport, proxyusername != NULL ? proxyusername : "******", proxypassword != NULL ? proxypassword : "******"); network_set_proxy (proxyname, proxyport, proxyusername, proxypassword); }