void social_init (void) { gchar *tmp; social_register_bookmark_site ("Blinklist", "http://www.blinklist.com/index.php?Action=Blink/addblink.php&Title=%s&Url=%s", TRUE, TRUE); social_register_bookmark_site ("blogmarks", "http://blogmarks.net/my/new.php?mini=1&title=%s&url=%s", TRUE, TRUE); social_register_bookmark_site ("Buddymarks", "http://buddymarks.com/add_bookmark.php?bookmark_title=%s&bookmark_url=%s", TRUE, TRUE); social_register_bookmark_site ("CiteUlike", "http://www.citeulike.org/posturl?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("digg", "http://digg.com/submit?phase=2&url=%s", FALSE, FALSE); social_register_bookmark_site ("diigo", "http://www.diigo.com/post?url=%s&title=%s&desc=", TRUE, FALSE); social_register_bookmark_site ("Facebook", "http://www.facebook.com/share.php?u=%s", FALSE, FALSE); social_register_bookmark_site ("Google Bookmarks", "https://www.google.com/bookmarks/mark?op=edit&output=&bkmk=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Google Plus", "https://plus.google.com/share?url=%s", FALSE, FALSE); social_register_bookmark_site ("identi.ca" ,"http://identi.ca//index.php?action=bookmarklet&status_textarea=%%E2%%80%%9C%s%%E2%%80%%9D%%20%%E2%%80%%94%%20%s", TRUE, TRUE); social_register_bookmark_site ("Instapaper", "https://www.instapaper.com/edit?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Lilisto", "http://lister.lilisto.com/?t=%s&l=%s", TRUE, TRUE); social_register_bookmark_site ("Linkagogo", "http://www.linkagogo.com/go/AddNoPopup?title=%s&url=%s", TRUE, TRUE); social_register_bookmark_site ("Linkroll", "http://www.linkroll.com/index.php?action=insertLink&url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("netvouz", "http://netvouz.com/action/submitBookmark?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Newsvine", "http://www.newsvine.com/_wine/save?u=%s&h=%s", TRUE, FALSE); social_register_bookmark_site ("reddit", "http://reddit.com/submit?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Slashdot", "http://slashdot.org/slashdot-it.pl?op=basic&url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Squidoo", "http://www.squidoo.com/lensmaster/bookmark?%s", FALSE, FALSE); social_register_bookmark_site ("Twitter", "http://twitter.com/home?status=%s", FALSE, FALSE); social_register_bookmark_site ("Yahoo My Web", "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=%s&t=%s", TRUE, FALSE); conf_get_str_value (SOCIAL_BM_SITE, &tmp); social_set_bookmark_site (tmp); g_free (tmp); if (!bookmarkSite) social_set_bookmark_site ("del.icio.us"); /* set default if necessary */ }
static gchar * webkit_get_font (guint *size) { gchar *font = NULL; *size = 11; /* default fallback */ /* font configuration support */ conf_get_str_value (USER_FONT, &font); if (NULL == font || 0 == strlen (font)) { if (NULL != font) { g_free (font); font = NULL; } conf_get_default_font_from_schema (DEFAULT_FONT, &font); } if (font) { /* The GTK2/GNOME font name format is "<font name> <size>" */ gchar *tmp = strrchr(font, ' '); if (tmp) { *tmp++ = 0; *size = atoi(tmp); } } return font; }
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); }
int plugin_init(conf_t *conf) { DEBUG_LOG("demo plugin init"); moni_dir = conf_get_str_value(conf, "moni_dir", "/usr/local/apache2/htdocs"); DEBUG_LOG("monitor derectory: %s", moni_dir); return FILMOND_DECLINED; }
void social_init (void) { gchar *tmp; social_register_bookmark_site ("Blinklist", "http://www.blinklist.com/index.php?Action=Blink/addblink.php&Title=%s&Url=%s", TRUE, TRUE); social_register_bookmark_site ("blogmarks", "http://blogmarks.net/my/new.php?mini=1&title=%s&url=%s", TRUE, TRUE); social_register_bookmark_site ("Buddymarks", "http://buddymarks.com/add_bookmark.php?bookmark_title=%s&bookmark_url=%s", TRUE, TRUE); social_register_bookmark_site ("CiteUlike", "http://www.citeulike.org/posturl?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("del.icio.us", "http://del.icio.us/post?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("digg", "http://digg.com/submit?phase=2&url=%s", FALSE, FALSE); social_register_bookmark_site ("diigo", "http://www.diigo.com/post?url=%s&title=%s&desc=", TRUE, FALSE); social_register_bookmark_site ("ekstreme", "http://ekstreme.com/socializer/?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Facebook", "http://www.facebook.com/share.php?u=%s", FALSE, FALSE); social_register_bookmark_site ("FeedMarker", "http://www.feedmarker.com/admin.php?do=bookmarklet_mark&url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Feed Me Links!", "http://feedmelinks.com/categorize?from=toolbar&op=submit&name=%s&url=%s&version=0.7", TRUE, TRUE); social_register_bookmark_site ("Give a Link", "http://www.givealink.org/cgi-pub/bookmarklet/bookmarkletLogin.cgi?&uri=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Google Bookmarks", "https://www.google.com/bookmarks/mark?op=edit&output=&bkmk=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Google Plus", "https://plus.google.com/share?url=%s", FALSE, FALSE); social_register_bookmark_site ("Gravee", "http://www.gravee.com/account/bookmarkpop?u=%s&t=%s", TRUE, FALSE); social_register_bookmark_site ("Hyperlinkomatic","http://www.hyperlinkomatic.com/lm2/add.html?LinkTitle=%s&LinkUrl=%s", TRUE, TRUE); social_register_bookmark_site ("identi.ca" ,"http://identi.ca//index.php?action=bookmarklet&status_textarea=%%E2%%80%%9C%s%%E2%%80%%9D%%20%%E2%%80%%94%%20%s", TRUE, TRUE); social_register_bookmark_site ("igooi", "http://www.igooi.com/addnewitem.aspx?self=1&noui=yes&jump=close&url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Instapaper", "https://www.instapaper.com/edit?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Lilisto", "http://lister.lilisto.com/?t=%s&l=%s", TRUE, TRUE); social_register_bookmark_site ("Linkagogo", "http://www.linkagogo.com/go/AddNoPopup?title=%s&url=%s", TRUE, TRUE); social_register_bookmark_site ("Linkroll", "http://www.linkroll.com/index.php?action=insertLink&url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("maple", "http://www.maple.nu/bookmarks/bookmarklet?bookmark[url]=%s&bookmark[name]=%s", TRUE, FALSE); social_register_bookmark_site ("Mister Wong", "http://www.mister-wong.de/index.php?action=addurl&bm_url=%s&bm_description=%s", TRUE, FALSE); social_register_bookmark_site ("netvouz", "http://netvouz.com/action/submitBookmark?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Newsvine", "http://www.newsvine.com/_wine/save?u=%s&h=%s", TRUE, FALSE); social_register_bookmark_site ("reddit", "http://reddit.com/submit?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Segnalo", "http://segnalo.com/post.html.php?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Simpy", "http://simpy.com/simpy/LinkAdd.do?title=%s&href=%s&v=6&src=bookmarklet", TRUE, TRUE); social_register_bookmark_site ("Slashdot", "http://slashdot.org/slashdot-it.pl?op=basic&url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Spurl", "http://www.spurl.net/spurl.php?v=3&title=%s&url=%s", TRUE, TRUE); social_register_bookmark_site ("Squidoo", "http://www.squidoo.com/lensmaster/bookmark?%s", FALSE, FALSE); social_register_bookmark_site ("StumbleUpon", "http://www.stumbleupon.com/submit/?url=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("tagtooga", "http://www.tagtooga.com/tapp/db.exe?c=jsEntryForm&b=fx&title=%s&url=%s", TRUE, TRUE); social_register_bookmark_site ("Technorati", "http://technorati.com/faves/?add=%s", FALSE, FALSE); social_register_bookmark_site ("Twitter", "http://twitter.com/home?status=%s", FALSE, FALSE); social_register_bookmark_site ("wists", "http://www.wists.com/r.php?r=%s&title=%s", TRUE, FALSE); social_register_bookmark_site ("Yahoo My Web", "http://myweb2.search.yahoo.com/myresults/bookmarklet?u=%s&t=%s", TRUE, FALSE); social_register_bookmark_site ("zurpy", "http://tag.zurpy.com/?box=1&url=%s&title=%s", TRUE, FALSE); conf_get_str_value (SOCIAL_BM_SITE, &tmp); social_set_bookmark_site (tmp); g_free (tmp); if (!bookmarkSite) social_set_bookmark_site ("del.icio.us"); /* set default if necessary */ }
gchar * conf_get_toolbar_style(void) { gchar *style; conf_get_str_value (TOOLBAR_STYLE, &style); /* check if we don't override the toolbar style */ if (strcmp(style, "") == 0) { g_free (style); conf_get_str_value_from_schema (desktop_settings,"toolbar-style", &style); } return style; }
/* 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); }
static char *conf_evaluate(conf_t *conf, char *value) { char *buf = NULL; int avail = MAX_LINE - 1; char *scan, *p; int len = 0; char *var, *sub = NULL, *ret; if ((scan = strchr(value, '$')) == NULL) { return value; } if (*(scan + 1) == '\0') { return value; } buf = (char *)calloc(MAX_LINE, sizeof(char)); if (!buf) { return NULL; } if (scan - value > avail) { goto error; } strncpy(buf, value, scan - value); avail -= scan - value; ++scan; if (*scan == '{' || *scan == '(') { ++scan; } p = (char *)scan; while (*scan && *scan != '}' && *scan != ')' && *scan != ' ') { ++scan; ++len; } if (*scan == '}' || *scan == ')') { ++scan; } sub = str_sub(p, 0, len); if (!sub) { goto error; } if ((var = conf_get_str_value(conf, sub, NULL)) == NULL) { var = getenv(sub); } if (var) { if (strlen(var) > avail) { goto error; } strncat(buf, var, avail); avail -= strlen(var); } strncat(buf, scan, avail); free(sub); if ((ret = conf_evaluate(conf, buf)) == NULL) { goto error; } else if (ret == buf) { return ret; } else { free(buf); return ret; } error: if (buf) free(buf); if (sub) free(sub); return NULL; }
void liferea_shell_create (GtkApplication *app, const gchar *overrideWindowState) { GtkUIManager *ui_manager; GtkAccelGroup *accel_group; GError *error = NULL; gboolean toggle; gchar *id; debug_enter ("liferea_shell_create"); g_object_new (LIFEREA_SHELL_TYPE, NULL); shell->priv->window = GTK_WINDOW (liferea_shell_lookup ("mainwindow")); gtk_window_set_application (GTK_WINDOW (shell->priv->window), app); /* 1.) menu creation */ debug0 (DEBUG_GUI, "Setting up menues"); shell->priv->itemlist = itemlist_create (); /* Prepare some toggle button states */ conf_get_bool_value (REDUCED_FEEDLIST, &toggle); liferea_shell_feedlist_toggle_entries[0].is_active = toggle; ui_manager = gtk_ui_manager_new (); shell->priv->generalActions = gtk_action_group_new ("GeneralActions"); gtk_action_group_set_translation_domain (shell->priv->generalActions, PACKAGE); gtk_action_group_add_actions (shell->priv->generalActions, liferea_shell_action_entries, G_N_ELEMENTS (liferea_shell_action_entries), shell->priv); gtk_action_group_add_toggle_actions (shell->priv->generalActions, liferea_shell_action_toggle_entries, G_N_ELEMENTS (liferea_shell_action_toggle_entries), shell->priv); 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); gtk_action_group_add_toggle_actions (shell->priv->generalActions, liferea_shell_feedlist_toggle_entries, G_N_ELEMENTS (liferea_shell_feedlist_toggle_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->generalActions, 0); shell->priv->addActions = gtk_action_group_new ("AddActions"); gtk_action_group_set_translation_domain (shell->priv->addActions, PACKAGE); gtk_action_group_add_actions (shell->priv->addActions, liferea_shell_add_action_entries, G_N_ELEMENTS (liferea_shell_add_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->addActions, 0); shell->priv->feedActions = gtk_action_group_new ("FeedActions"); gtk_action_group_set_translation_domain (shell->priv->feedActions, PACKAGE); gtk_action_group_add_actions (shell->priv->feedActions, liferea_shell_feed_action_entries, G_N_ELEMENTS (liferea_shell_feed_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->feedActions, 0); shell->priv->readWriteActions = gtk_action_group_new("ReadWriteActions"); gtk_action_group_set_translation_domain (shell->priv->readWriteActions, PACKAGE); 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); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->readWriteActions, 0); shell->priv->itemActions = gtk_action_group_new ("ItemActions"); gtk_action_group_set_translation_domain (shell->priv->itemActions, PACKAGE); gtk_action_group_add_actions (shell->priv->itemActions, liferea_shell_item_action_entries, G_N_ELEMENTS (liferea_shell_item_action_entries), shell->priv); gtk_ui_manager_insert_action_group (ui_manager, shell->priv->itemActions, 0); accel_group = gtk_ui_manager_get_accel_group (ui_manager); gtk_window_add_accel_group (GTK_WINDOW (shell->priv->window), accel_group); g_object_unref (accel_group); g_signal_connect (gtk_accel_map_get (), "changed", G_CALLBACK (on_accel_change), NULL); if (!gtk_ui_manager_add_ui_from_string (ui_manager, liferea_shell_ui_desc, -1, &error)) g_error ("building menus failed: %s", error->message); shell->priv->menubar = gtk_ui_manager_get_widget (ui_manager, "/MainwindowMenubar"); shell->priv->toolbar = gtk_ui_manager_get_widget (ui_manager, "/maintoolbar"); /* Ensure GTK3 toolbar shadows... */ gtk_style_context_add_class (gtk_widget_get_style_context (shell->priv->toolbar), "primary-toolbar"); /* what a pain, why is there no markup for this option? */ g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/newFeedButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/nextUnreadButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/MarkAsReadButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/UpdateAllButton")), "is_important", TRUE, NULL); g_object_set (G_OBJECT (gtk_ui_manager_get_widget (ui_manager, "/maintoolbar/SearchButton")), "is_important", TRUE, NULL); /* 2.) setup containers */ debug0 (DEBUG_GUI, "Setting up widget containers"); gtk_box_pack_start (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->toolbar, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->toolbar, 0); gtk_box_pack_start (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->menubar, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (liferea_shell_lookup ("vbox1")), shell->priv->menubar, 0); gtk_widget_show_all(GTK_WIDGET(shell->priv->toolbar)); g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_press_event", G_CALLBACK (on_key_press_event_null_cb), NULL); g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "key_release_event", G_CALLBACK (on_key_press_event_null_cb), NULL); g_signal_connect ((gpointer) liferea_shell_lookup ("itemtabs"), "scroll_event", G_CALLBACK (on_notebook_scroll_event_null_cb), NULL); g_signal_connect (G_OBJECT (shell->priv->window), "delete_event", G_CALLBACK(on_close), shell->priv); g_signal_connect (G_OBJECT (shell->priv->window), "window_state_event", G_CALLBACK(on_window_state_event), shell->priv); g_signal_connect (G_OBJECT (shell->priv->window), "key_press_event", G_CALLBACK(on_key_press_event), shell->priv); /* 3.) setup status bar */ debug0 (DEBUG_GUI, "Setting up status bar"); shell->priv->statusbar = GTK_STATUSBAR (liferea_shell_lookup ("statusbar")); shell->priv->statusbarLocked = FALSE; shell->priv->statusbarLockTimer = 0; shell->priv->statusbar_feedsinfo = gtk_label_new(""); gtk_widget_show(shell->priv->statusbar_feedsinfo); gtk_box_pack_start (GTK_BOX (shell->priv->statusbar), shell->priv->statusbar_feedsinfo, FALSE, FALSE, 5); /* 4.) setup tabs */ debug0 (DEBUG_GUI, "Setting up tabbed browsing"); shell->priv->tabs = browser_tabs_create (GTK_NOTEBOOK (liferea_shell_lookup ("browsertabs"))); /* 5.) setup feed list */ debug0 (DEBUG_GUI, "Setting up feed list"); shell->priv->feedlistView = GTK_TREE_VIEW (liferea_shell_lookup ("feedlist")); feed_list_view_init (shell->priv->feedlistView); /* 6.) setup menu sensivity */ debug0 (DEBUG_GUI, "Initialising menues"); /* On start, no item or feed is selected, so Item menu should be insensitive: */ liferea_shell_update_item_menu (FALSE); /* necessary to prevent selection signals when filling the feed list and setting the 2/3 pane mode view */ gtk_widget_set_sensitive (GTK_WIDGET (shell->priv->feedlistView), FALSE); /* 7.) setup item view */ debug0 (DEBUG_GUI, "Setting up item view"); shell->priv->itemview = itemview_create (GTK_WIDGET (shell->priv->window)); /* 8.) load icons as required */ debug0 (DEBUG_GUI, "Loading icons"); icons_load (); /* 9.) update and restore all menu elements */ liferea_shell_update_toolbar (); liferea_shell_update_history_actions (); liferea_shell_setup_URL_receiver (); liferea_shell_restore_state (overrideWindowState); gtk_widget_set_sensitive (GTK_WIDGET (shell->priv->feedlistView), TRUE); /* 10.) After main window is realized get theme colors and set up feed list and tray icon */ render_init_theme_colors (GTK_WIDGET (shell->priv->window)); shell->priv->feedlist = feedlist_create (); g_signal_connect (shell->priv->feedlist, "new-items", G_CALLBACK (liferea_shell_update_unread_stats), shell->priv->feedlist); /* 11.) Restore latest selection */ // FIXME: Move to feed list code if (conf_get_str_value (LAST_NODE_SELECTED, &id)) { feed_list_view_select (node_from_id (id)); g_free (id); } /* 12. Setup shell plugins */ shell->priv->extensions = peas_extension_set_new (PEAS_ENGINE (liferea_plugins_engine_get_default ()), LIFEREA_TYPE_SHELL_ACTIVATABLE, "shell", shell, NULL); g_signal_connect (shell->priv->extensions, "extension-added", G_CALLBACK (on_extension_added), shell); g_signal_connect (shell->priv->extensions, "extension-removed", G_CALLBACK (on_extension_removed), shell); peas_extension_set_call (shell->priv->extensions, "activate"); /* 14. Rebuild search folders if needed */ if (searchFolderRebuild) vfolder_foreach (vfolder_rebuild); debug_exit ("liferea_shell_create"); }
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); }
int main (int argc, char *argv[]) { UniqueApp *app; UniqueMessageData *msg; GError *error = NULL; GOptionContext *context; GOptionGroup *debug; gulong debug_flags = 0; LifereaDBus *dbus = NULL; const gchar *initial_state = "shown"; gchar *feed = NULL; int initialState; gboolean show_tray_icon, start_in_tray; #ifdef USE_SM gchar *opt_session_arg = NULL; #endif GOptionEntry entries[] = { { "mainwindow-state", 'w', 0, G_OPTION_ARG_STRING, &initial_state, N_("Start Liferea with its main window in STATE. STATE may be `shown', `iconified', or `hidden'"), N_("STATE") }, #ifdef USE_SM { "session", 0, G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_STRING, &opt_session_arg, NULL, NULL }, #endif { "version", 'v', G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, show_version, N_("Show version information and exit"), NULL }, { "add-feed", 'a', 0, G_OPTION_ARG_STRING, &feed, N_("Add a new subscription"), N_("uri") }, { NULL } }; GOptionEntry debug_entries[] = { { "debug-all", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all types"), NULL }, { "debug-cache", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages for the cache handling"), NULL }, { "debug-conf", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages for the configuration handling"), NULL }, { "debug-db", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the database handling"), NULL }, { "debug-gui", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all GUI functions"), NULL }, { "debug-html", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Enables HTML rendering debugging. Each time Liferea renders HTML output it will also dump the generated HTML into ~/.liferea_1.6/output.xhtml"), NULL }, { "debug-net", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all network activity"), NULL }, { "debug-parsing", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of all parsing functions"), NULL }, { "debug-performance", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages when a function takes too long to process"), NULL }, { "debug-trace", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages when entering/leaving functions"), NULL }, { "debug-update", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the feed update processing"), NULL }, { "debug-vfolder", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print debugging messages of the search folder matching"), NULL }, { "debug-verbose", 0, G_OPTION_FLAG_NO_ARG, G_OPTION_ARG_CALLBACK, debug_entries_parse_callback, N_("Print verbose debugging messages"), NULL }, { NULL } }; if (!g_thread_supported ()) g_thread_init (NULL); #ifdef ENABLE_NLS bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); textdomain (GETTEXT_PACKAGE); #endif debug = g_option_group_new ("debug", _("Print debugging messages for the given topic"), _("Print debugging messages for the given topic"), &debug_flags, NULL); g_option_group_set_translation_domain(debug, GETTEXT_PACKAGE); g_option_group_add_entries (debug, debug_entries); context = g_option_context_new (NULL); g_option_context_set_summary (context, N_("Liferea, the Linux Feed Reader")); g_option_context_set_description (context, N_("For more information, please visit http://liferea.sourceforge.net/")); g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE); g_option_context_set_translation_domain(context, GETTEXT_PACKAGE); g_option_context_add_group (context, debug); g_option_context_add_group (context, gtk_get_option_group (FALSE)); g_option_context_parse (context, &argc, &argv, &error); g_option_context_free (context); if (error) { g_print ("Error parsing options: %s\n", error->message); } set_debug_level (debug_flags); /* Configuration necessary for network options, so it has to be initialized before update_init() */ conf_init (); #ifdef USE_DBUS dbus_g_thread_init (); #endif /* We need to do the network initialization here to allow network-manager to be setup before gtk_init() */ update_init (); gtk_init (&argc, &argv); /* Single instance checks */ app = unique_app_new_with_commands ("net.sourceforge.liferea", NULL, "add_feed", COMMAND_ADD_FEED, NULL); if (unique_app_is_running (app)) { g_print ("Liferea is already running\n"); unique_app_send_message (app, UNIQUE_ACTIVATE, NULL); if (feed) { msg = unique_message_data_new (); unique_message_data_set_text (msg, feed, -1); unique_app_send_message (app, COMMAND_ADD_FEED, msg); } return 1; } else { g_signal_connect (app, "message-received", G_CALLBACK (message_received_cb), NULL); } /* GTK theme support */ g_set_application_name (_("Liferea")); gtk_window_set_default_icon_name ("liferea"); debug_start_measurement (DEBUG_DB); /* order is important! */ db_init (); /* initialize sqlite */ xml_init (); /* initialize libxml2 */ #ifdef HAVE_LIBNOTIFY notification_plugin_register (&libnotify_plugin); #endif social_init (); /* initialize social bookmarking */ #ifdef USE_DBUS dbus = liferea_dbus_new (); #else debug0 (DEBUG_GUI, "Compiled without DBUS support."); #endif #ifdef USE_AVAHI if (conf_get_bool_value (SYNC_AVAHI_ENABLED)) { LifereaAvahiPublisher *avahiPublisher = NULL; debug0 (DEBUG_CACHE, "Registering with AVAHI"); avahiPublisher = liferea_avahi_publisher_new (); liferea_avahi_publisher_publish (avahiPublisher, conf_get_str_value (SYNC_AVAHI_SERVICE_NAME), 23632); } else { debug0 (DEBUG_CACHE, "Avahi support available, but disabled by preferences."); } #else debug0 (DEBUG_CACHE, "Compiled without AVAHI support"); #endif /* how to start liferea, command line takes precedence over preferences */ conf_get_bool_value (SHOW_TRAY_ICON, &show_tray_icon); conf_get_bool_value (START_IN_TRAY, &start_in_tray); if (g_str_equal(initial_state, "iconified")) { initialState = MAINWINDOW_ICONIFIED; } else if (g_str_equal(initial_state, "hidden") || (show_tray_icon && start_in_tray)) { initialState = MAINWINDOW_HIDDEN; } else { initialState = MAINWINDOW_SHOWN; } liferea_shell_create (initialState); g_set_prgname ("liferea"); #ifdef USE_SM /* This must be after feedlist reading because some session managers will tell Liferea to exit if Liferea does not respond to SM requests within a minute or two. This starts the main loop soon after opening the SM connection. */ session_init (BIN_DIR G_DIR_SEPARATOR_S "liferea", opt_session_arg); session_set_cmd (NULL, initialState); #endif signal (SIGTERM, signal_handler); signal (SIGINT, signal_handler); signal (SIGHUP, signal_handler); #ifndef G_OS_WIN32 signal (SIGBUS, fatal_signal_handler); signal (SIGSEGV, fatal_signal_handler); #endif /* Note: we explicitely do not use the gdk_thread_* locking in Liferea because it freezes the program when running Flash applets in gtkmozembed */ runState = STATE_STARTING; debug_end_measurement (DEBUG_DB, "startup"); if (feed) feedlist_add_subscription (feed, NULL, NULL, 0); gtk_main (); g_object_unref (G_OBJECT (dbus)); return 0; }
static void ui_choose_file_or_dir(gchar *title, const gchar *buttonName, gboolean saving, gboolean directory, fileChoosenCallback callback, const gchar *currentPath, const gchar *defaultFilename, const char *filterstring, const char *filtername, gpointer user_data) { GtkWidget *dialog; struct file_chooser_tuple *tuple; GtkWidget *button; gchar *path = NULL; g_assert (!(saving & directory)); g_assert (!(defaultFilename && !saving)); if (!currentPath) conf_get_str_value (ENCLOSURE_DOWNLOAD_PATH, &path); else path = g_strdup (currentPath); dialog = gtk_file_chooser_dialog_new (title, GTK_WINDOW (liferea_shell_get_window ()), (directory?GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER: (saving ? GTK_FILE_CHOOSER_ACTION_SAVE : GTK_FILE_CHOOSER_ACTION_OPEN)), GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, NULL); if (saving) gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE); gtk_window_set_modal (GTK_WINDOW (dialog), TRUE); tuple = g_new0 (struct file_chooser_tuple, 1); tuple->dialog = dialog; tuple->func = callback; tuple->user_data = user_data; button = gtk_dialog_add_button (GTK_DIALOG (dialog), buttonName, GTK_RESPONSE_ACCEPT); gtk_widget_set_can_default (button, TRUE); gtk_widget_grab_default (button); g_signal_connect (G_OBJECT (dialog), "response", G_CALLBACK (ui_choose_file_save_cb), tuple); if (path && g_file_test (path, G_FILE_TEST_EXISTS)) { if (directory || defaultFilename) gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), path); else gtk_file_chooser_set_filename (GTK_FILE_CHOOSER (dialog), path); } if (defaultFilename) gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), defaultFilename); if (filterstring && filtername) { GtkFileFilter *filter, *allfiles; filter = gtk_file_filter_new (); gtk_file_filter_add_pattern (filter, filterstring); gtk_file_filter_set_name (filter, filtername); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), filter); allfiles = gtk_file_filter_new (); gtk_file_filter_add_pattern (allfiles, "*"); gtk_file_filter_set_name (allfiles, _("All Files")); gtk_file_chooser_add_filter (GTK_FILE_CHOOSER (dialog), allfiles); } gtk_widget_show_all (dialog); g_free (path); }