mirror of
https://github.com/Oxbian/PackageSaver.git
synced 2025-06-02 16:58:09 +02:00
Success!! Finishing adding the packageSaver GUI
Just check the TODO for next
This commit is contained in:
parent
a7b6b29a5d
commit
c00685e72f
BIN
PackageSaver
BIN
PackageSaver
Binary file not shown.
@ -12,6 +12,7 @@ struct _treeViewer
|
|||||||
|
|
||||||
void init_packages(treeViewer *tv);
|
void init_packages(treeViewer *tv);
|
||||||
void on_ct2_toggled (GtkCellRendererToggle *cell, gchar *path_string, gpointer user_data);
|
void on_ct2_toggled (GtkCellRendererToggle *cell, gchar *path_string, gpointer user_data);
|
||||||
|
void on_saveFile_clicked (GtkButton *btn, gpointer user_data);
|
||||||
void on_destroy();
|
void on_destroy();
|
||||||
|
|
||||||
#endif
|
#endif
|
3
pkgToSave.txt
Normal file
3
pkgToSave.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
a52dec
|
||||||
|
aalib
|
||||||
|
acl
|
@ -84,6 +84,52 @@ void on_ct2_toggled (GtkCellRendererToggle *cell, gchar *path_string, gpointer u
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Function to save packageName into a file
|
||||||
|
*
|
||||||
|
* @param btn button clicked
|
||||||
|
* @param user_data treeView in which data is
|
||||||
|
*/
|
||||||
|
void on_saveFile_clicked (GtkButton *btn, gpointer user_data)
|
||||||
|
{
|
||||||
|
treeViewer *tv = (treeViewer*) user_data;
|
||||||
|
GtkTreeModel *model = gtk_tree_view_get_model(tv->treeView);
|
||||||
|
GtkTreeIter iter;
|
||||||
|
gtk_tree_model_get_iter_first(model, &iter);
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
fp = fopen("pkgToSave.txt", "w");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "Error opening the file, please open an issue on github!");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
int row = 0;
|
||||||
|
|
||||||
|
while (1)
|
||||||
|
{
|
||||||
|
gchar *pkgName;
|
||||||
|
gboolean isKept = FALSE;
|
||||||
|
|
||||||
|
gtk_tree_model_get(model, &iter, 1, &isKept, -1); //Getting the bool of the row
|
||||||
|
//fprintf(stderr, "row %d\n",row);
|
||||||
|
/* Checking if the user asked to keep the row or not */
|
||||||
|
if (isKept == TRUE)
|
||||||
|
{
|
||||||
|
gtk_tree_model_get(model, &iter, 0, &pkgName, -1); // Getting the packageName
|
||||||
|
fputs(pkgName, fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gtk_tree_model_iter_next (model, &iter) == FALSE)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
row++;
|
||||||
|
}
|
||||||
|
fclose(fp);
|
||||||
|
//fprintf(stderr, "File closed");
|
||||||
|
}
|
||||||
|
|
||||||
void on_destroy()
|
void on_destroy()
|
||||||
{
|
{
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
|
@ -21,6 +21,8 @@ int main(int argc, char *argv[])
|
|||||||
GtkCellRenderer *ct1 = GTK_CELL_RENDERER(gtk_builder_get_object(builder, "ct1"));
|
GtkCellRenderer *ct1 = GTK_CELL_RENDERER(gtk_builder_get_object(builder, "ct1"));
|
||||||
GtkCellRenderer *ct2 = GTK_CELL_RENDERER(gtk_builder_get_object(builder, "ct2"));
|
GtkCellRenderer *ct2 = GTK_CELL_RENDERER(gtk_builder_get_object(builder, "ct2"));
|
||||||
GtkTreeSelection *select = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "select"));
|
GtkTreeSelection *select = GTK_TREE_SELECTION(gtk_builder_get_object(builder, "select"));
|
||||||
|
GtkButton *saveFileButton = GTK_BUTTON(gtk_builder_get_object(builder, "SaveInFile"));
|
||||||
|
|
||||||
|
|
||||||
gtk_tree_view_column_add_attribute(cx1, ct1, "text", 0); // attach renderer to column
|
gtk_tree_view_column_add_attribute(cx1, ct1, "text", 0); // attach renderer to column
|
||||||
gtk_tree_view_column_add_attribute(cx2, ct2, "active", 1); // attach renderer to column
|
gtk_tree_view_column_add_attribute(cx2, ct2, "active", 1); // attach renderer to column
|
||||||
@ -32,6 +34,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/*Connection all the signal*/
|
/*Connection all the signal*/
|
||||||
g_signal_connect (ct2, "toggled", G_CALLBACK (on_ct2_toggled), &tv);
|
g_signal_connect (ct2, "toggled", G_CALLBACK (on_ct2_toggled), &tv);
|
||||||
|
g_signal_connect (saveFileButton, "clicked", G_CALLBACK (on_saveFile_clicked), &tv);
|
||||||
|
|
||||||
gtk_widget_show_all(window);
|
gtk_widget_show_all(window);
|
||||||
|
|
||||||
@ -40,5 +43,5 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: free all when exiting
|
// TODO: free all when exiting
|
||||||
// saving the actions into a file ou clipboard
|
|
||||||
// adding a research by name feature
|
// adding a research by name feature
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkButton" id="SaveInFile">
|
<object class="GtkButton" id="SaveInFile">
|
||||||
<property name="label" translatable="yes">Save in a file</property>
|
<property name="label" translatable="yes">Save in a file</property>
|
||||||
<property name="width-request">250</property>
|
<property name="width-request">500</property>
|
||||||
<property name="height-request">25</property>
|
<property name="height-request">25</property>
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
@ -80,22 +80,6 @@
|
|||||||
<property name="y">200</property>
|
<property name="y">200</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
|
||||||
<object class="GtkButton" id="SaveInClip">
|
|
||||||
<property name="label" translatable="yes">Save in clip board</property>
|
|
||||||
<property name="width-request">250</property>
|
|
||||||
<property name="height-request">25</property>
|
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="can-focus">True</property>
|
|
||||||
<property name="receives-default">True</property>
|
|
||||||
<property name="image-position">top</property>
|
|
||||||
<signal name="clicked" handler="on_SaveInClip_clicked" swapped="no"/>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="x">250</property>
|
|
||||||
<property name="y">200</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
@ -56,6 +56,9 @@
|
|||||||
<property name="title" translatable="yes" context="Label of column keeping the program ?">Keeping ?</property>
|
<property name="title" translatable="yes" context="Label of column keeping the program ?">Keeping ?</property>
|
||||||
<property name="expand">True</property>
|
<property name="expand">True</property>
|
||||||
<property name="alignment">0.5</property>
|
<property name="alignment">0.5</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererToggle" id="ct2"/>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
@ -86,7 +89,6 @@
|
|||||||
<property name="can-focus">True</property>
|
<property name="can-focus">True</property>
|
||||||
<property name="receives-default">True</property>
|
<property name="receives-default">True</property>
|
||||||
<property name="image-position">top</property>
|
<property name="image-position">top</property>
|
||||||
<signal name="clicked" handler="on_SaveInClip_clicked" swapped="no"/>
|
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="x">250</property>
|
<property name="x">250</property>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user