unarchive 388250
reopen 388250
found 388250 0.63.1
tags 388250 + patch
thanks

Dear synaptic developers,

some five years ago I opened a wishlist bug against synaptic asking for a keyboard shortcut for "Download Changelog" and another menu entry allowing for "Download Copyright". Because the bug report covered two different issues, it has been closed shortly after with my consent. Now I found this report again and created patches for it that I kindly ask you to integrate into synaptic.

(1) In the main menu there is an entry called "Package / Download
Changelog". It would be nice to also have another entry called "Download
Copyright", which will show the copyright file.

This is extremely interesting for new packages in non-free/contrib and
in all cases when you want to know what the heck you are downloading at
all. ;)

This is covered by download-copyright-file.patch. I have introduced another menu entry "Download Copyright File" next to "Download Changelog" and reuse most of the code that is currently used to retrieve the changelog file. This even becomes visible in the actual text view window itself, when the following text is still introduced as the most current changelog, although the copyright file is shown.

But, hey, at least it's a starting point. ;)

While we are at it, I introduced "Y" as an accelerator key for this menu entry.

(2) Could you please introduce a keyboard shortcut for the "Show
Changelog" function? A suggestion would be "F5" or similar. If you
decide to add the "Show Copyright" function, a keyboard shortcut for
this (maybe "F6") would be nice, too.

This issue is covered by changelog-accelerator.patch. It introduces "L" as an accelerator key for the "Download Changelog" function (I have checked that it was not assigned so far). That's all.

I am going to split this bug as soon as I got feedback from you and are able to estimate changes if one or both patches get applied.

Cheers,
Fabian
--- synaptic-0.63.1.orig/gtk/glade/window_main.glade
+++ synaptic-0.63.1/gtk/glade/window_main.glade
@@ -598,6 +598,7 @@
 		      <property name="label" translatable="yes">_Download Changelog</property>
 		      <property name="use_underline">True</property>
 		      <signal name="activate" handler="on_download_changelog_activate" last_modification_time="Wed, 12 May 2004 18:59:45 GMT"/>
+		      <accelerator key="L" modifiers="GDK_CONTROL_MASK" signal="activate"/>
 		    </widget>
 		  </child>
 
--- synaptic-0.63.1.orig/common/rpackage.cc
+++ synaptic-0.63.1/common/rpackage.cc
@@ -936,6 +936,52 @@ string RPackage::getChangelogFile(pkgAcq
    return filename;
 }
 
+string RPackage::getCopyrightFile(pkgAcquire *fetcher)
+{
+   string prefix;
+   string srcpkg = srcPackage();
+   string descr("Copyright file for ");
+   descr+=name();
+
+   string src_section=section();
+   if(src_section.find('/')!=src_section.npos)
+      src_section=string(src_section, 0, src_section.find('/'));
+   else
+      src_section="main";
+
+   prefix+=srcpkg[0];
+   if(srcpkg.size()>3 && srcpkg[0]=='l' && srcpkg[1]=='i' && srcpkg[2]=='b')
+      prefix=std::string("lib")+srcpkg[3];
+
+   string verstr;
+   if(availableVersion() != NULL)
+      verstr = availableVersion();
+
+   if(verstr.find(':')!=verstr.npos)
+      verstr=string(verstr, verstr.find(':')+1);
+   char uri[512];
+   snprintf(uri,512,"http://packages.debian.org/changelogs/pool/%s/%s/%s/%s_%s/copyright";,
+                               src_section.c_str(),
+                               prefix.c_str(),
+                               srcpkg.c_str(),
+                               srcpkg.c_str(),
+                               verstr.c_str());
+
+   //cout << "uri is: " << uri << endl;
+
+   // no need to translate this, the copyright file is in english anyway
+   string filename = RTmpDir()+"/tmp_cl";
+   ofstream out(filename.c_str());
+   out << "Failed to fetch the copyright file for " << name() << endl;
+   out << "URI was: " << uri << endl;
+   out.close();
+   new pkgAcqFileSane(fetcher, uri, descr, name(), filename);
+
+   fetcher->Run();
+
+   return filename;
+}
+
 string RPackage::getCandidateOriginStr()
 {
    pkgCache::VerIterator Ver = (*_depcache)[*_package].CandidateVerIter(*_depcache);
--- synaptic-0.63.1.orig/common/rpackage.h
+++ synaptic-0.63.1/common/rpackage.h
@@ -152,6 +152,8 @@ class RPackage {
 
    // get changelog file from the debian server 
    string getChangelogFile(pkgAcquire *fetcher);
+   // get copyright file from the debian server
+   string getCopyrightFile(pkgAcquire *fetcher);
    // get screenshot file from the debian server 
    string getScreenshotFile(pkgAcquire *fetcher, bool thumb = true);
 
Binary files synaptic-0.63.1.orig/common/rpackage.o and synaptic-0.63.1/common/rpackage.o differ
--- synaptic-0.63.1.orig/gtk/glade/window_main.glade
+++ synaptic-0.63.1/gtk/glade/window_main.glade
@@ -603,6 +603,16 @@
 		  </child>
 
 		  <child>
+		    <widget class="GtkMenuItem" id="menu_download_copyright">
+		      <property name="visible">True</property>
+		      <property name="label" translatable="yes">Download Cop_yright File</property>
+		      <property name="use_underline">True</property>
+		      <signal name="activate" handler="on_download_copyright_activate" last_modification_time="Wed, 12 May 2004 18:59:45 GMT"/>
+		      <accelerator key="Y" modifiers="GDK_CONTROL_MASK" signal="activate"/>
+		    </widget>
+		  </child>
+
+		  <child>
 		    <widget class="GtkSeparatorMenuItem" id="separator_debian">
 		      <property name="visible">True</property>
 		    </widget>
--- synaptic-0.63.1.orig/gtk/rgmainwindow.cc
+++ synaptic-0.63.1/gtk/rgmainwindow.cc
@@ -1430,6 +1430,11 @@ void RGMainWindow::buildInterface()
                                  G_CALLBACK(cbChangelogDialog),
                                  this); 
 
+   glade_xml_signal_connect_data(_gladeXML,
+                                 "on_download_copyright_activate",
+                                 G_CALLBACK(cbCopyrightDialog),
+                                 this);
+
    /* --------------------------------------------------------------- */
 
    // toolbar menu code
@@ -2003,6 +2008,62 @@ void RGMainWindow::cbChangelogDialog(Gtk
    me->setInterfaceLocked(FALSE);
 }
 
+void RGMainWindow::cbCopyrightDialog(GtkWidget *self, void *data)
+{
+   RGMainWindow *me = (RGMainWindow*)data;
+
+   RPackage *pkg = me->selectedPackage();
+   if(pkg == NULL)
+      return;
+
+   me->setInterfaceLocked(TRUE);
+   RGFetchProgress *status = new RGFetchProgress(me);;
+   status->setDescription(_("Downloading Copyright File"),
+			  _("The copyright files contains a verbatim copy"
+             " of the copyright and distribution license of"
+             " the package."));
+   pkgAcquire fetcher(status);
+   string filename = pkg->getCopyrightFile(&fetcher);
+
+   RGGladeUserDialog dia(me,"changelog");
+
+   // set title
+   GtkWidget *win = glade_xml_get_widget(dia.getGladeXML(),
+					   "dialog_changelog");
+   assert(win);
+   // TRANSLATORS: Title of the copyright dialog - %s is the name of the package
+   gchar *str = g_strdup_printf(_("%s Copyright"), pkg->name());
+   gtk_window_set_title(GTK_WINDOW(win), str);
+   g_free(str);
+
+
+   // set copyright data
+   GtkWidget *textview = glade_xml_get_widget(dia.getGladeXML(),
+					      "textview_changelog");
+   assert(textview);
+   GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(textview));
+   GtkTextIter start,end;
+   gtk_text_buffer_get_start_iter (buffer, &start);
+   gtk_text_buffer_get_end_iter(buffer,&end);
+   gtk_text_buffer_delete(buffer,&start,&end);
+
+   ifstream in(filename.c_str());
+   string s;
+   while(getline(in, s)) {
+      // no need to free str later, it is allocated in a static buffer
+      const char *str = utf8(s.c_str());
+      if(str!=NULL)
+	 gtk_text_buffer_insert_at_cursor(buffer, str, -1);
+      gtk_text_buffer_insert_at_cursor(buffer, "\n", -1);
+   }
+
+   dia.run();
+
+   // clean up
+   delete status;
+   unlink(filename.c_str());
+   me->setInterfaceLocked(FALSE);
+}
 
 void RGMainWindow::cbPackageListRowActivated(GtkTreeView *treeview,
                                              GtkTreePath *path,
--- synaptic-0.63.1.orig/gtk/rgmainwindow.h
+++ synaptic-0.63.1/gtk/rgmainwindow.h
@@ -226,6 +226,7 @@ class RGMainWindow : public RGGladeWindo
                                    vector<RPackage *> selected_pkgs);
 
    static void cbChangelogDialog(GtkWidget *self, void *data);
+   static void cbCopyrightDialog(GtkWidget *self, void *data);
 
    static void cbSelectedRow(GtkTreeSelection *selection, gpointer data);
    static void cbPackageListRowActivated(GtkTreeView *treeview,
Binary files synaptic-0.63.1.orig/gtk/rgmainwindow.o and synaptic-0.63.1/gtk/rgmainwindow.o differ

Reply via email to