(no commit message)
authorJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 28 Apr 2013 08:25:56 +0000 (08:25 +0000)
committerJean-Philippe Orsini <jeanfi@gmail.com>
Sun, 28 Apr 2013 08:25:56 +0000 (08:25 +0000)
src/glade/prss.glade
src/main.c
src/ttrss_ws.c

index 4298b56..6bbbd31 100644 (file)
@@ -5,7 +5,7 @@
     <property name="label" translatable="yes">Refresh</property>
     <property name="stock_id">gtk-refresh</property>
   </object>
     <property name="label" translatable="yes">Refresh</property>
     <property name="stock_id">gtk-refresh</property>
   </object>
-  <object class="GtkListStore" id="feed_store">
+  <object class="GtkListStore" id="headline_store">
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
@@ -13,7 +13,7 @@
       <column type="gint"/>
     </columns>
   </object>
       <column type="gint"/>
     </columns>
   </object>
-  <object class="GtkListStore" id="headline_store">
+  <object class="GtkListStore" id="feed_store">
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
     <columns>
       <!-- column-name gchararray1 -->
       <column type="gchararray"/>
       <column type="gint"/>
     </columns>
   </object>
       <column type="gint"/>
     </columns>
   </object>
+  <object class="GtkListStore" id="liststore1">
+    <columns>
+      <!-- column-name gchararray1 -->
+      <column type="gchararray"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">horizontal</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">vertical</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkDialog" id="settings_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
   <object class="GtkDialog" id="settings_dialog">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
           </packing>
         </child>
         <child>
           </packing>
         </child>
         <child>
-          <object class="GtkGrid" id="grid1">
+          <object class="GtkNotebook" id="notebook1">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="row_homogeneous">True</property>
             <child>
             <child>
-              <object class="GtkLabel" id="label1">
+              <object class="GtkGrid" id="grid1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">URL:</property>
+                <property name="row_homogeneous">True</property>
+                <child>
+                  <object class="GtkLabel" id="label4">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">URL:</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label5">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Login:</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label6">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xpad">1</property>
+                    <property name="label" translatable="yes">Password:</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="url_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">•</property>
+                    <property name="invisible_char_set">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="login_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">•</property>
+                    <property name="invisible_char_set">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="password_entry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="visibility">False</property>
+                    <property name="invisible_char">•</property>
+                    <property name="invisible_char_set">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">2</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
               </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
             </child>
             </child>
-            <child>
-              <object class="GtkLabel" id="label2">
+            <child type="tab">
+              <object class="GtkLabel" id="label1">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="label" translatable="yes">Login:</property>
+                <property name="label" translatable="yes">Account</property>
               </object>
               <packing>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
               </packing>
             </child>
             <child>
-              <object class="GtkLabel" id="label3">
+              <object class="GtkGrid" id="grid2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="xpad">1</property>
-                <property name="label" translatable="yes">Password:</property>
+                <child>
+                  <object class="GtkLabel" id="label7">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Layout:</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkComboBox" id="layout">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="model">liststore1</property>
+                    <property name="active">0</property>
+                    <child>
+                      <object class="GtkCellRendererText" id="cellrenderertext2"/>
+                      <attributes>
+                        <attribute name="text">0</attribute>
+                      </attributes>
+                    </child>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
               </object>
               <packing>
               </object>
               <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="position">1</property>
               </packing>
             </child>
               </packing>
             </child>
-            <child>
-              <object class="GtkEntry" id="url_entry">
+            <child type="tab">
+              <object class="GtkLabel" id="label2">
                 <property name="visible">True</property>
                 <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">•</property>
+                <property name="can_focus">False</property>
+                <property name="label" translatable="yes">Interface</property>
               </object>
               <packing>
               </object>
               <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">0</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
+                <property name="position">1</property>
+                <property name="tab_fill">False</property>
               </packing>
             </child>
             <child>
               </packing>
             </child>
             <child>
-              <object class="GtkEntry" id="login_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="invisible_char">•</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">1</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
+              <placeholder/>
             </child>
             </child>
-            <child>
-              <object class="GtkEntry" id="password_entry">
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="visibility">False</property>
-                <property name="invisible_char">•</property>
-              </object>
-              <packing>
-                <property name="left_attach">1</property>
-                <property name="top_attach">2</property>
-                <property name="width">1</property>
-                <property name="height">1</property>
-              </packing>
+            <child type="tab">
+              <placeholder/>
             </child>
           </object>
           <packing>
             </child>
           </object>
           <packing>
index 3957c8d..b0d6852 100644 (file)
@@ -38,6 +38,8 @@
 static const char *program_name;
 static GSettings *settings;
 
 static const char *program_name;
 static GSettings *settings;
 
+static GtkPaned *w_panel;
+
 static int model_state;
 
 enum {
 static int model_state;
 
 enum {
@@ -122,8 +124,8 @@ void update()
 
                gtk_list_store_set(GTK_LIST_STORE(model),
                                   &iter,
 
                gtk_list_store_set(GTK_LIST_STORE(model),
                                   &iter,
-                                  0, title,
-                                  1, (*feeds)->id,
+                                  COL_FEED_TITLE, title,
+                                  COL_FEED_ID, (*feeds)->id,
                                   -1);
                free(title);
                feeds++;
                                   -1);
                free(title);
                feeds++;
@@ -133,6 +135,24 @@ void update()
        log_debug("update() done");
 }
 
        log_debug("update() done");
 }
 
+void update_layout()
+{
+       int layout;
+
+       layout = g_settings_get_int(settings, "layout");
+
+       switch (layout) {
+       case 1:
+               gtk_orientable_set_orientation(GTK_ORIENTABLE(w_panel),
+                                              GTK_ORIENTATION_HORIZONTAL);
+               break;
+       case 0:
+       default:
+               gtk_orientable_set_orientation(GTK_ORIENTABLE(w_panel),
+                                              GTK_ORIENTATION_VERTICAL);
+       }
+}
+
 void refresh_clicked_cbk(GtkWidget *btn, gpointer data)
 {
        log_debug("refresh_clicked_cbk()");
 void refresh_clicked_cbk(GtkWidget *btn, gpointer data)
 {
        log_debug("refresh_clicked_cbk()");
@@ -145,6 +165,7 @@ void settings_activate_cbk(GtkWidget *menu_item, gpointer data)
        GtkDialog *diag;
        GtkBuilder *builder;
        GtkEntry *login, *url, *pwd;
        GtkDialog *diag;
        GtkBuilder *builder;
        GtkEntry *login, *url, *pwd;
+       GtkComboBox *layout;
 
        log_debug("settings_activate_cbk()");
 
 
        log_debug("settings_activate_cbk()");
 
@@ -166,7 +187,17 @@ void settings_activate_cbk(GtkWidget *menu_item, gpointer data)
        pwd = GTK_ENTRY(gtk_builder_get_object(builder, "password_entry"));
        gtk_entry_set_text(pwd, g_settings_get_string(settings, "password"));
 
        pwd = GTK_ENTRY(gtk_builder_get_object(builder, "password_entry"));
        gtk_entry_set_text(pwd, g_settings_get_string(settings, "password"));
 
+       layout = GTK_COMBO_BOX(gtk_builder_get_object(builder,
+                                                     "layout"));
+
+       gtk_combo_box_set_active(layout, g_settings_get_int(settings,
+                                                           "layout"));
+
        if (gtk_dialog_run(diag)) {
        if (gtk_dialog_run(diag)) {
+               g_settings_set_int(settings,
+                                  "layout",
+                                  gtk_combo_box_get_active(layout));
+
                g_settings_set_string(settings,
                                      "password",
                                      gtk_entry_get_text(pwd));
                g_settings_set_string(settings,
                                      "password",
                                      gtk_entry_get_text(pwd));
@@ -182,6 +213,7 @@ void settings_activate_cbk(GtkWidget *menu_item, gpointer data)
                                 g_settings_get_string(settings, "password"));
                ws_open_session();
 
                                 g_settings_get_string(settings, "password"));
                ws_open_session();
 
+               update_layout();
                update();
        }
 
                update();
        }
 
@@ -271,8 +303,10 @@ int feed_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
 
                                gtk_list_store_set(headline_store,
                                                   &iter,
 
                                gtk_list_store_set(headline_store,
                                                   &iter,
-                                                  0, title,
-                                                  1, (*headlines)->id,
+                                                  COL_HEADLINE_TITLE,
+                                                  title,
+                                                  COL_HEADLINE_ID,
+                                                  (*headlines)->id,
                                                   -1);
 
                                free(title);
                                                   -1);
 
                                free(title);
@@ -292,7 +326,7 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
        GtkTreeIter iter;
        GtkTreeModel *model;
        struct headline *headline;
        GtkTreeIter iter;
        GtkTreeModel *model;
        struct headline *headline;
-       char *str;
+       char *str, *tmp;
 
        log_debug("headline_cursor_changed_cbk()");
 
 
        log_debug("headline_cursor_changed_cbk()");
 
@@ -302,15 +336,22 @@ int headline_cursor_changed_cbk(GtkTreeView *treeview, gpointer data)
        headline = get_selected_headline(&iter);
 
        if (headline) {
        headline = get_selected_headline(&iter);
 
        if (headline) {
-               str = ttrss_get_headline_content(headline);
-
-               if (str)
+               tmp = ttrss_get_headline_content(headline);
+
+               if (tmp) {
+                       str = g_strdup_printf("<h1><a href='%s'>%s</a></h1>%s",
+                                             headline->url,
+                                             headline->title,
+                                             tmp);
+                       free(tmp);
+                       
                        web_load(str);
                        web_load(str);
-               else
+                       free(str);
+               } else {
                        web_load("");
                        web_load("");
+               }
 
 
-               free(str);
-
+               
                if (headline->unread) {
                        ttrss_set_article_unread(headline->id, 0);
                        headline->unread = 0;
                if (headline->unread) {
                        ttrss_set_article_unread(headline->id, 0);
                        headline->unread = 0;
@@ -486,6 +527,8 @@ int main(int argc, char **argv)
        w_headlinetree = GTK_TREE_VIEW(gtk_builder_get_object(builder,
                                                              "headline_tree"));
 
        w_headlinetree = GTK_TREE_VIEW(gtk_builder_get_object(builder,
                                                              "headline_tree"));
 
+       w_panel = GTK_PANED(gtk_builder_get_object(builder, "paned2"));
+
        gtk_builder_connect_signals(builder, NULL);
 
        panh = GTK_WIDGET(gtk_builder_get_object(builder, "webkit_window"));
        gtk_builder_connect_signals(builder, NULL);
 
        panh = GTK_WIDGET(gtk_builder_get_object(builder, "webkit_window"));
@@ -495,6 +538,7 @@ int main(int argc, char **argv)
        g_object_unref(G_OBJECT(builder));
 
        gtk_widget_show_all(window);
        g_object_unref(G_OBJECT(builder));
 
        gtk_widget_show_all(window);
+       update_layout();
 
        gtk_main();
 
 
        gtk_main();
 
index 92bd60c..d2c673f 100644 (file)
@@ -208,7 +208,7 @@ char *ws_login()
 
 int ws_open_session()
 {
 
 int ws_open_session()
 {
-       int /*version, */result;
+       int version, result;
 
        log_debug("ws_open_session()");
 
 
        log_debug("ws_open_session()");
 
@@ -219,16 +219,16 @@ int ws_open_session()
        session_id = ws_login();
 
        if (session_id) {
        session_id = ws_login();
 
        if (session_id) {
-               /*version = ws_get_api_version();
+               version = ws_get_api_version();
                log_debug("API version= %d", version);
                log_debug("API version= %d", version);
-
+               
                if (version > 0) {
                        result = 1;
                } else {
                        free(session_id);
                        session_id = NULL;
                        result = 0;
                if (version > 0) {
                        result = 1;
                } else {
                        free(session_id);
                        session_id = NULL;
                        result = 0;
-                       }*/
+               }
                result = 1;
        } else {
                result =  0;
                result = 1;
        } else {
                result =  0;