diff options
| -rw-r--r-- | configure.ac | 2 | ||||
| -rw-r--r-- | gui/viewtorrents.glade | 506 | ||||
| -rw-r--r-- | src/customcellrendererleft.c | 40 | ||||
| -rw-r--r-- | src/customcellrendererleft.h | 4 | ||||
| -rw-r--r-- | src/customcellrendererprogress.c | 47 | ||||
| -rw-r--r-- | src/customcellrendererprogress.h | 5 | ||||
| -rw-r--r-- | src/customcellrendererrate.c | 36 | ||||
| -rw-r--r-- | src/customcellrendererrate.h | 4 | ||||
| -rw-r--r-- | src/customcellrendererstate.c | 38 | ||||
| -rw-r--r-- | src/customcellrendererstate.h | 4 |
10 files changed, 378 insertions, 308 deletions
diff --git a/configure.ac b/configure.ac index aa41f75..fc01dcf 100644 --- a/configure.ac +++ b/configure.ac @@ -30,7 +30,7 @@ AC_SEARCH_LIBS([fabs], [m],, AC_MSG_ERROR([No fabs found])) # GTK -PKG_CHECK_MODULES([GTK], [gtk+-2.0 >= 2.18 glib-2.0 >= 2.28]) +PKG_CHECK_MODULES([GTK], [gtk+-3.0 >= 3.0 glib-2.0 >= 2.28]) # xmlrpc-c diff --git a/gui/viewtorrents.glade b/gui/viewtorrents.glade index 5f95115..9efaccf 100644 --- a/gui/viewtorrents.glade +++ b/gui/viewtorrents.glade @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.18.3 --> <interface> - <requires lib="gtk+" version="2.18"/> - <!-- interface-naming-policy project-wide --> + <requires lib="gtk+" version="3.0"/> <object class="GtkAccelGroup" id="accelgroup1"/> <object class="GtkActionGroup" id="actiongroup"> <child> @@ -43,215 +43,43 @@ </object> </child> </object> - <object class="GtkAboutDialog" id="aboutdialog"> + <object class="GtkMenu" id="torrentmenu"> + <property name="visible">True</property> <property name="can_focus">False</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">About</property> - <property name="window_position">center-on-parent</property> - <property name="destroy_with_parent">True</property> - <property name="type_hint">dialog</property> - <property name="transient_for">main</property> - <property name="program_name">Viewtorrents</property> - <property name="version">0.1</property> - <property name="copyright" translatable="yes">Copyright Joel Klinghed 2011</property> - <property name="authors">Joel Klinghed</property> - <property name="logo_icon_name">viewtorrents</property> - <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox4"> + <property name="accel_group">accelgroup1</property> + <child> + <object class="GtkImageMenuItem" id="menuitem5"> + <property name="use_action_appearance">True</property> + <property name="related_action">startaction</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">2</property> - <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - <child> - <placeholder/> - </child> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + <property name="accel_group">accelgroup1</property> </object> </child> - </object> - <object class="GtkDialog" id="connectdlg"> - <property name="can_focus">False</property> - <property name="border_width">5</property> - <property name="title" translatable="yes">Connect</property> - <property name="modal">True</property> - <property name="window_position">center-on-parent</property> - <property name="destroy_with_parent">True</property> - <property name="type_hint">dialog</property> - <property name="transient_for">main</property> - <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox2"> + <child> + <object class="GtkImageMenuItem" id="menuitem6"> + <property name="use_action_appearance">True</property> + <property name="related_action">stopaction</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="spacing">2</property> - <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="layout_style">end</property> - <child> - <object class="GtkButton" id="button4"> - <property name="label">gtk-cancel</property> - <property name="use_action_appearance">False</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkButton" id="button3"> - <property name="label">gtk-connect</property> - <property name="use_action_appearance">False</property> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="can_default">True</property> - <property name="receives_default">True</property> - <property name="use_stock">True</property> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">False</property> - <property name="position">1</property> - </packing> - </child> - </object> - <packing> - <property name="expand">False</property> - <property name="fill">True</property> - <property name="pack_type">end</property> - <property name="position">0</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label4"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Enter the URL for the rTorrent RPC instance to connect to. -If authentication is needed, enter username and password as well.</property> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">1</property> - </packing> - </child> - <child> - <object class="GtkTable" id="table1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="n_rows">3</property> - <property name="n_columns">2</property> - <child> - <object class="GtkLabel" id="label1"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">URL:</property> - </object> - </child> - <child> - <object class="GtkLabel" id="label2"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Username:</property> - </object> - <packing> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - <child> - <object class="GtkLabel" id="label3"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="label" translatable="yes">Password:</property> - </object> - <packing> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="connectdlg_url"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> - <property name="primary_icon_sensitive">True</property> - <property name="secondary_icon_sensitive">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="connectdlg_user"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="invisible_char">●</property> - <property name="activates_default">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> - <property name="primary_icon_sensitive">True</property> - <property name="secondary_icon_sensitive">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">1</property> - <property name="bottom_attach">2</property> - </packing> - </child> - <child> - <object class="GtkEntry" id="connectdlg_pwd"> - <property name="visible">True</property> - <property name="can_focus">True</property> - <property name="visibility">False</property> - <property name="invisible_char">●</property> - <property name="activates_default">True</property> - <property name="primary_icon_activatable">False</property> - <property name="secondary_icon_activatable">False</property> - <property name="primary_icon_sensitive">True</property> - <property name="secondary_icon_sensitive">True</property> - </object> - <packing> - <property name="left_attach">1</property> - <property name="right_attach">2</property> - <property name="top_attach">2</property> - <property name="bottom_attach">3</property> - </packing> - </child> - </object> - <packing> - <property name="expand">True</property> - <property name="fill">True</property> - <property name="position">2</property> - </packing> - </child> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + <property name="accel_group">accelgroup1</property> + </object> + </child> + <child> + <object class="GtkImageMenuItem" id="menuitem7"> + <property name="use_action_appearance">True</property> + <property name="related_action">rehashaction</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_underline">True</property> + <property name="use_stock">True</property> + <property name="accel_group">accelgroup1</property> </object> </child> - <action-widgets> - <action-widget response="-6">button4</action-widget> - <action-widget response="-5">button3</action-widget> - </action-widgets> </object> <object class="GtkListStore" id="liststore"> <columns> @@ -286,9 +114,10 @@ If authentication is needed, enter username and password as well.</property> <group name="accelgroup1"/> </accel-groups> <child> - <object class="GtkVBox" id="vbox1"> + <object class="GtkBox" id="box1"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="orientation">vertical</property> <child> <object class="GtkMenuBar" id="menubar"> <property name="visible">True</property> @@ -306,6 +135,7 @@ If authentication is needed, enter username and password as well.</property> <property name="can_focus">False</property> <child> <object class="GtkImageMenuItem" id="connectmenuitem"> + <property name="use_action_appearance">True</property> <property name="related_action">connectaction</property> <property name="visible">True</property> <property name="can_focus">False</property> @@ -316,6 +146,7 @@ If authentication is needed, enter username and password as well.</property> </child> <child> <object class="GtkImageMenuItem" id="disconnectmenuitem"> + <property name="use_action_appearance">True</property> <property name="related_action">disconnectaction</property> <property name="visible">True</property> <property name="can_focus">False</property> @@ -334,7 +165,6 @@ If authentication is needed, enter username and password as well.</property> <child> <object class="GtkImageMenuItem" id="quitmenuitem"> <property name="label">gtk-quit</property> - <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="use_underline">True</property> @@ -359,6 +189,7 @@ If authentication is needed, enter username and password as well.</property> <property name="can_focus">False</property> <child> <object class="GtkImageMenuItem" id="startmenuitem"> + <property name="use_action_appearance">True</property> <property name="related_action">startaction</property> <property name="visible">True</property> <property name="can_focus">False</property> @@ -369,6 +200,7 @@ If authentication is needed, enter username and password as well.</property> </child> <child> <object class="GtkImageMenuItem" id="stopmenuitem"> + <property name="use_action_appearance">True</property> <property name="related_action">stopaction</property> <property name="visible">True</property> <property name="can_focus">False</property> @@ -379,6 +211,7 @@ If authentication is needed, enter username and password as well.</property> </child> <child> <object class="GtkImageMenuItem" id="rehashmenuitem"> + <property name="use_action_appearance">True</property> <property name="related_action">rehashaction</property> <property name="visible">True</property> <property name="can_focus">False</property> @@ -407,8 +240,6 @@ If authentication is needed, enter username and password as well.</property> <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">False</property> - <property name="label" translatable="yes">Toolbar</property> - <property name="use_underline">True</property> <property name="active">True</property> </object> </child> @@ -459,7 +290,9 @@ If authentication is needed, enter username and password as well.</property> <property name="related_action">connectaction</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Connect</property> <property name="use_underline">True</property> + <property name="stock_id">gtk-connect</property> </object> <packing> <property name="expand">False</property> @@ -471,7 +304,9 @@ If authentication is needed, enter username and password as well.</property> <property name="related_action">disconnectaction</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Disconnect</property> <property name="use_underline">True</property> + <property name="stock_id">gtk-disconnect</property> </object> <packing> <property name="expand">False</property> @@ -494,7 +329,9 @@ If authentication is needed, enter username and password as well.</property> <property name="related_action">startaction</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Start</property> <property name="use_underline">True</property> + <property name="stock_id">gtk-media-play</property> </object> <packing> <property name="expand">False</property> @@ -506,7 +343,9 @@ If authentication is needed, enter username and password as well.</property> <property name="related_action">stopaction</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Stop</property> <property name="use_underline">True</property> + <property name="stock_id">gtk-media-stop</property> </object> <packing> <property name="expand">False</property> @@ -518,7 +357,9 @@ If authentication is needed, enter username and password as well.</property> <property name="related_action">rehashaction</property> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="label" translatable="yes">Rehash</property> <property name="use_underline">True</property> + <property name="stock_id">gtk-refresh</property> </object> <packing> <property name="expand">False</property> @@ -536,7 +377,6 @@ If authentication is needed, enter username and password as well.</property> <object class="GtkScrolledWindow" id="scrolledwindow"> <property name="visible">True</property> <property name="can_focus">True</property> - <property name="hscrollbar_policy">automatic</property> <child> <object class="GtkTreeView" id="treeview"> <property name="visible">True</property> @@ -547,6 +387,9 @@ If authentication is needed, enter username and password as well.</property> <property name="search_column">1</property> <property name="fixed_height_mode">True</property> <property name="tooltip_column">1</property> + <child internal-child="selection"> + <object class="GtkTreeSelection" id="treeview-selection"/> + </child> <child> <object class="GtkTreeViewColumn" id="statecolumn"> <property name="sizing">fixed</property> @@ -587,7 +430,7 @@ If authentication is needed, enter username and password as well.</property> <child> <object class="GtkTreeViewColumn" id="upcolumn"> <property name="sizing">fixed</property> - <property name="fixed_width">70</property> + <property name="fixed_width">85</property> <property name="title" translatable="yes">Up</property> <property name="clickable">True</property> <property name="sort_indicator">True</property> @@ -598,7 +441,7 @@ If authentication is needed, enter username and password as well.</property> <child> <object class="GtkTreeViewColumn" id="downcolumn"> <property name="sizing">fixed</property> - <property name="fixed_width">70</property> + <property name="fixed_width">85</property> <property name="title" translatable="yes">Down</property> <property name="clickable">True</property> <property name="sort_indicator">True</property> @@ -639,6 +482,210 @@ If authentication is needed, enter username and password as well.</property> </object> </child> </object> + <object class="GtkAboutDialog" id="aboutdialog"> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="title" translatable="yes">About</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">dialog</property> + <property name="transient_for">main</property> + <property name="program_name">Viewtorrents</property> + <property name="version">0.1</property> + <property name="copyright" translatable="yes">Copyright Joel Klinghed 2011</property> + <property name="authors">Joel Klinghed</property> + <property name="logo_icon_name">viewtorrents</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + </object> + <object class="GtkDialog" id="connectdlg"> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="title" translatable="yes">Connect</property> + <property name="modal">True</property> + <property name="window_position">center-on-parent</property> + <property name="destroy_with_parent">True</property> + <property name="type_hint">dialog</property> + <property name="transient_for">main</property> + <child internal-child="vbox"> + <object class="GtkBox" id="dialog-vbox2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkButtonBox" id="dialog-action_area2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button4"> + <property name="label">gtk-cancel</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button3"> + <property name="label">gtk-connect</property> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="can_default">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Enter the URL for the rTorrent RPC instance to connect to. +If authentication is needed, enter username and password as well.</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkGrid" id="grid1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="column_spacing">5</property> + <property name="row_homogeneous">True</property> + <child> + <object class="GtkLabel" id="label1"> + <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> + </packing> + </child> + <child> + <object class="GtkEntry" id="connectdlg_url"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">True</property> + <property name="primary_icon_activatable">False</property> + <property name="secondary_icon_activatable">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">0</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Username:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="connectdlg_user"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="invisible_char">●</property> + <property name="activates_default">True</property> + <property name="primary_icon_activatable">False</property> + <property name="secondary_icon_activatable">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Password:</property> + </object> + <packing> + <property name="left_attach">0</property> + <property name="top_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="connectdlg_pwd"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="visibility">False</property> + <property name="invisible_char">●</property> + <property name="activates_default">True</property> + <property name="primary_icon_activatable">False</property> + <property name="secondary_icon_activatable">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="top_attach">2</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">3</property> + </packing> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-6">button4</action-widget> + <action-widget response="-5">button3</action-widget> + </action-widgets> + </object> <object class="GtkDialog" id="pwddlg"> <property name="can_focus">False</property> <property name="border_width">5</property> @@ -649,12 +696,12 @@ If authentication is needed, enter username and password as well.</property> <property name="type_hint">dialog</property> <property name="transient_for">main</property> <child internal-child="vbox"> - <object class="GtkVBox" id="dialog-vbox1"> + <object class="GtkBox" id="dialog-vbox1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="spacing">2</property> <child internal-child="action_area"> - <object class="GtkHButtonBox" id="dialog-action_area1"> + <object class="GtkButtonBox" id="dialog-action_area1"> <property name="visible">True</property> <property name="can_focus">False</property> <property name="layout_style">end</property> @@ -718,8 +765,6 @@ If authentication is needed, enter username and password as well.</property> <property name="activates_default">True</property> <property name="primary_icon_activatable">False</property> <property name="secondary_icon_activatable">False</property> - <property name="primary_icon_sensitive">True</property> - <property name="secondary_icon_sensitive">True</property> </object> <packing> <property name="expand">True</property> @@ -734,39 +779,4 @@ If authentication is needed, enter username and password as well.</property> <action-widget response="-5">button1</action-widget> </action-widgets> </object> - <object class="GtkMenu" id="torrentmenu"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="accel_group">accelgroup1</property> - <child> - <object class="GtkImageMenuItem" id="menuitem5"> - <property name="related_action">startaction</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="use_underline">True</property> - <property name="use_stock">True</property> - <property name="accel_group">accelgroup1</property> - </object> - </child> - <child> - <object class="GtkImageMenuItem" id="menuitem6"> - <property name="related_action">stopaction</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="use_underline">True</property> - <property name="use_stock">True</property> - <property name="accel_group">accelgroup1</property> - </object> - </child> - <child> - <object class="GtkImageMenuItem" id="menuitem7"> - <property name="related_action">rehashaction</property> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="use_underline">True</property> - <property name="use_stock">True</property> - <property name="accel_group">accelgroup1</property> - </object> - </child> - </object> </interface> diff --git a/src/customcellrendererleft.c b/src/customcellrendererleft.c index 89184e5..2dc3ae9 100644 --- a/src/customcellrendererleft.c +++ b/src/customcellrendererleft.c @@ -2,6 +2,20 @@ #include "customcellrendererleft.h" +/* Private class member */ +#define PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CUSTOM_TYPE_CELL_RENDERER_LEFT, \ + CustomCellRendererLeftPrivate)) + +typedef struct _CustomCellRendererLeftPrivate CustomCellRendererLeftPrivate; + +struct _CustomCellRendererLeftPrivate +{ + gint64 left; + gchar buffer[20]; +}; + static void custom_cell_renderer_left_get_property(GObject* object, guint param_id, GValue* value, @@ -14,17 +28,18 @@ static void custom_cell_renderer_left_set_property(GObject* object, static void convert_left_to_string(gchar* str, guint size, gint64 left); enum { - PROP_0, - PROP_LEFT, + PROP_0, + PROP_LEFT, }; G_DEFINE_TYPE(CustomCellRendererLeft, custom_cell_renderer_left, GTK_TYPE_CELL_RENDERER_TEXT) static void custom_cell_renderer_left_init(CustomCellRendererLeft* cell_left) { - convert_left_to_string(cell_left->buffer, sizeof(cell_left->buffer), - cell_left->left); - g_object_set(cell_left, "text", cell_left->buffer, NULL); + convert_left_to_string(PRIVATE(cell_left)->buffer, + sizeof(PRIVATE(cell_left)->buffer), + PRIVATE(cell_left)->left); + g_object_set(cell_left, "text", PRIVATE(cell_left)->buffer, NULL); } static void custom_cell_renderer_left_class_init(CustomCellRendererLeftClass *cell_left_class) @@ -35,6 +50,9 @@ static void custom_cell_renderer_left_class_init(CustomCellRendererLeftClass *ce object_class = G_OBJECT_CLASS(cell_left_class); /* cell_renderer_class = GTK_CELL_RENDERER_CLASS(cell_left_class); */ + g_type_class_add_private(object_class, + sizeof(CustomCellRendererLeftPrivate)); + object_class->set_property = custom_cell_renderer_left_set_property; object_class->get_property = custom_cell_renderer_left_get_property; @@ -64,7 +82,7 @@ void custom_cell_renderer_left_get_property(GObject* object, switch (param_id) { case PROP_LEFT: - g_value_set_int64(value, left->left); + g_value_set_int64(value, PRIVATE(left)->left); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); @@ -85,9 +103,9 @@ void custom_cell_renderer_left_set_property(GObject* object, { gint64 left_value = g_value_get_int64(value); - if (left->left != left_value) + if (PRIVATE(left)->left != left_value) { - left->left = left_value; + PRIVATE(left)->left = left_value; changed = TRUE; } break; @@ -98,8 +116,10 @@ void custom_cell_renderer_left_set_property(GObject* object, if (changed) { - convert_left_to_string(left->buffer, sizeof(left->buffer), left->left); - g_object_set(left, "text", left->buffer, NULL); + convert_left_to_string(PRIVATE(left)->buffer, + sizeof(PRIVATE(left)->buffer), + PRIVATE(left)->left); + g_object_set(left, "text", PRIVATE(left)->buffer, NULL); } } diff --git a/src/customcellrendererleft.h b/src/customcellrendererleft.h index 6e18ebd..717ea17 100644 --- a/src/customcellrendererleft.h +++ b/src/customcellrendererleft.h @@ -27,10 +27,6 @@ typedef struct _CustomCellRendererLeftClass CustomCellRendererLeftClass; struct _CustomCellRendererLeft { GtkCellRendererText parent; - - /*< private >*/ - gint64 GSEAL (left); - gchar GSEAL (buffer[20]); }; struct _CustomCellRendererLeftClass diff --git a/src/customcellrendererprogress.c b/src/customcellrendererprogress.c index 04912e7..f8c3eb8 100644 --- a/src/customcellrendererprogress.c +++ b/src/customcellrendererprogress.c @@ -2,6 +2,21 @@ #include "customcellrendererprogress.h" +/* Private class member */ +#define PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CUSTOM_TYPE_CELL_RENDERER_PROGRESS, \ + CustomCellRendererProgressPrivate)) + +typedef struct _CustomCellRendererProgressPrivate CustomCellRendererProgressPrivate; + +struct _CustomCellRendererProgressPrivate +{ + gfloat downloaded; + gfloat seeded; + gchar buffer[10]; +}; + static void custom_cell_renderer_progress_get_property(GObject* object, guint param_id, GValue* value, @@ -15,9 +30,9 @@ static void update_progress(CustomCellRendererProgress* cell_progress, gfloat downloaded, gfloat seeded); enum { - PROP_0, - PROP_DOWNLOADED, - PROP_SEEDED, + PROP_0, + PROP_DOWNLOADED, + PROP_SEEDED, }; G_DEFINE_TYPE(CustomCellRendererProgress, custom_cell_renderer_progress, GTK_TYPE_CELL_RENDERER_PROGRESS) @@ -25,7 +40,8 @@ G_DEFINE_TYPE(CustomCellRendererProgress, custom_cell_renderer_progress, GTK_TYP static void custom_cell_renderer_progress_init(CustomCellRendererProgress* cell_progress) { update_progress(cell_progress, - cell_progress->downloaded, cell_progress->seeded); + PRIVATE(cell_progress)->downloaded, + PRIVATE(cell_progress)->seeded); } static void custom_cell_renderer_progress_class_init(CustomCellRendererProgressClass *cell_progress_class) @@ -36,6 +52,9 @@ static void custom_cell_renderer_progress_class_init(CustomCellRendererProgressC object_class = G_OBJECT_CLASS(cell_progress_class); /* cell_renderer_class = GTK_CELL_RENDERER_CLASS(cell_progress_class); */ + g_type_class_add_private(object_class, + sizeof(CustomCellRendererProgressPrivate)); + object_class->set_property = custom_cell_renderer_progress_set_property; object_class->get_property = custom_cell_renderer_progress_get_property; @@ -75,10 +94,10 @@ void custom_cell_renderer_progress_get_property(GObject* object, switch (param_id) { case PROP_DOWNLOADED: - g_value_set_float(value, progress->downloaded); + g_value_set_float(value, PRIVATE(progress)->downloaded); break; case PROP_SEEDED: - g_value_set_float(value, progress->seeded); + g_value_set_float(value, PRIVATE(progress)->seeded); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); @@ -99,9 +118,9 @@ void custom_cell_renderer_progress_set_property(GObject* object, { gfloat downloaded = g_value_get_float(value); - if (progress->downloaded != downloaded) + if (PRIVATE(progress)->downloaded != downloaded) { - progress->downloaded = downloaded; + PRIVATE(progress)->downloaded = downloaded; changed = TRUE; } break; @@ -110,9 +129,9 @@ void custom_cell_renderer_progress_set_property(GObject* object, { gfloat seeded = g_value_get_float(value); - if (progress->seeded != seeded) + if (PRIVATE(progress)->seeded != seeded) { - progress->seeded = seeded; + PRIVATE(progress)->seeded = seeded; changed = TRUE; } break; @@ -123,17 +142,19 @@ void custom_cell_renderer_progress_set_property(GObject* object, if (changed) { - update_progress(progress, progress->downloaded, progress->seeded); + update_progress(progress, PRIVATE(progress)->downloaded, + PRIVATE(progress)->seeded); } } void update_progress(CustomCellRendererProgress* cell_progress, gfloat downloaded, gfloat seeded) { - g_snprintf(cell_progress->buffer, sizeof(cell_progress->buffer), + g_snprintf(PRIVATE(cell_progress)->buffer, + sizeof(PRIVATE(cell_progress)->buffer), "%2.2f", seeded); g_object_set(cell_progress, "value", (gint)downloaded, - "text", cell_progress->buffer, + "text", PRIVATE(cell_progress)->buffer, NULL); } diff --git a/src/customcellrendererprogress.h b/src/customcellrendererprogress.h index 7e3a7ba..f139b9b 100644 --- a/src/customcellrendererprogress.h +++ b/src/customcellrendererprogress.h @@ -27,11 +27,6 @@ typedef struct _CustomCellRendererProgressClass CustomCellRendererProgressClass; struct _CustomCellRendererProgress { GtkCellRendererProgress parent; - - /*< private >*/ - gfloat GSEAL (downloaded); - gfloat GSEAL (seeded); - gchar GSEAL (buffer[10]); }; struct _CustomCellRendererProgressClass diff --git a/src/customcellrendererrate.c b/src/customcellrendererrate.c index f86c76d..7d39886 100644 --- a/src/customcellrendererrate.c +++ b/src/customcellrendererrate.c @@ -2,6 +2,20 @@ #include "customcellrendererrate.h" +/* Private class member */ +#define PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CUSTOM_TYPE_CELL_RENDERER_RATE, \ + CustomCellRendererRatePrivate)) + +typedef struct _CustomCellRendererRatePrivate CustomCellRendererRatePrivate; + +struct _CustomCellRendererRatePrivate +{ + gfloat rate; + gchar buffer[10]; +}; + static void custom_cell_renderer_rate_get_property(GObject* object, guint param_id, GValue* value, @@ -23,9 +37,10 @@ G_DEFINE_TYPE(CustomCellRendererRate, custom_cell_renderer_rate, GTK_TYPE_CELL_R static void custom_cell_renderer_rate_init(CustomCellRendererRate* cell_rate) { g_object_set(cell_rate, "xalign", 1.0f, NULL); - convert_rate_to_string(cell_rate->buffer, sizeof(cell_rate->buffer), - cell_rate->rate); - g_object_set(cell_rate, "text", cell_rate->buffer, NULL); + convert_rate_to_string(PRIVATE(cell_rate)->buffer, + sizeof(PRIVATE(cell_rate)->buffer), + PRIVATE(cell_rate)->rate); + g_object_set(cell_rate, "text", PRIVATE(cell_rate)->buffer, NULL); } static void custom_cell_renderer_rate_class_init(CustomCellRendererRateClass *cell_rate_class) @@ -36,6 +51,9 @@ static void custom_cell_renderer_rate_class_init(CustomCellRendererRateClass *ce object_class = G_OBJECT_CLASS(cell_rate_class); /* cell_renderer_class = GTK_CELL_RENDERER_CLASS(cell_rate_class); */ + g_type_class_add_private(object_class, + sizeof(CustomCellRendererRatePrivate)); + object_class->set_property = custom_cell_renderer_rate_set_property; object_class->get_property = custom_cell_renderer_rate_get_property; @@ -65,7 +83,7 @@ void custom_cell_renderer_rate_get_property(GObject* object, switch (param_id) { case PROP_RATE: - g_value_set_float(value, rate->rate); + g_value_set_float(value, PRIVATE(rate)->rate); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); @@ -86,9 +104,9 @@ void custom_cell_renderer_rate_set_property(GObject* object, { gfloat rate_value = g_value_get_float(value); - if (rate->rate != rate_value) + if (PRIVATE(rate)->rate != rate_value) { - rate->rate = rate_value; + PRIVATE(rate)->rate = rate_value; changed = TRUE; } break; @@ -99,8 +117,10 @@ void custom_cell_renderer_rate_set_property(GObject* object, if (changed) { - convert_rate_to_string(rate->buffer, sizeof(rate->buffer), rate->rate); - g_object_set(rate, "text", rate->buffer, NULL); + convert_rate_to_string(PRIVATE(rate)->buffer, + sizeof(PRIVATE(rate)->buffer), + PRIVATE(rate)->rate); + g_object_set(rate, "text", PRIVATE(rate)->buffer, NULL); } } diff --git a/src/customcellrendererrate.h b/src/customcellrendererrate.h index 48105d3..a227ea1 100644 --- a/src/customcellrendererrate.h +++ b/src/customcellrendererrate.h @@ -27,10 +27,6 @@ typedef struct _CustomCellRendererRateClass CustomCellRendererRateClass; struct _CustomCellRendererRate { GtkCellRendererText parent; - - /*< private >*/ - gfloat GSEAL (rate); - gchar GSEAL (buffer[10]); }; struct _CustomCellRendererRateClass diff --git a/src/customcellrendererstate.c b/src/customcellrendererstate.c index 8c02358..52fcade 100644 --- a/src/customcellrendererstate.c +++ b/src/customcellrendererstate.c @@ -2,6 +2,19 @@ #include "customcellrendererstate.h" +/* Private class member */ +#define PRIVATE(obj) \ + (G_TYPE_INSTANCE_GET_PRIVATE((obj), \ + CUSTOM_TYPE_CELL_RENDERER_STATE, \ + CustomCellRendererStatePrivate)) + +typedef struct _CustomCellRendererStatePrivate CustomCellRendererStatePrivate; + +struct _CustomCellRendererStatePrivate +{ + gint state; +}; + static void custom_cell_renderer_state_get_property(GObject* object, guint param_id, GValue* value, @@ -14,15 +27,15 @@ static void custom_cell_renderer_state_set_property(GObject* object, static void update_state(CustomCellRendererState* cell_state, gint state); enum { - PROP_0, - PROP_STATE, + PROP_0, + PROP_STATE, }; G_DEFINE_TYPE(CustomCellRendererState, custom_cell_renderer_state, GTK_TYPE_CELL_RENDERER_PIXBUF) static void custom_cell_renderer_state_init(CustomCellRendererState* cell_state) { - update_state(cell_state, cell_state->state); + update_state(cell_state, PRIVATE(cell_state)->state); } static void custom_cell_renderer_state_class_init(CustomCellRendererStateClass *cell_state_class) @@ -33,6 +46,9 @@ static void custom_cell_renderer_state_class_init(CustomCellRendererStateClass * object_class = G_OBJECT_CLASS(cell_state_class); /* cell_renderer_class = GTK_CELL_RENDERER_CLASS(cell_state_class); */ + g_type_class_add_private(object_class, + sizeof(CustomCellRendererStatePrivate)); + object_class->set_property = custom_cell_renderer_state_set_property; object_class->get_property = custom_cell_renderer_state_get_property; @@ -62,7 +78,7 @@ void custom_cell_renderer_state_get_property(GObject* object, switch (param_id) { case PROP_STATE: - g_value_set_int(value, state->state); + g_value_set_int(value, PRIVATE(state)->state); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, param_id, pspec); @@ -83,9 +99,9 @@ void custom_cell_renderer_state_set_property(GObject* object, { gint state_value = g_value_get_int(value); - if (state->state != state_value) + if (PRIVATE(state)->state != state_value) { - state->state = state_value; + PRIVATE(state)->state = state_value; changed = TRUE; } break; @@ -96,7 +112,7 @@ void custom_cell_renderer_state_set_property(GObject* object, if (changed) { - update_state(state, state->state); + update_state(state, PRIVATE(state)->state); } } @@ -105,16 +121,16 @@ void update_state(CustomCellRendererState* cell_state, gint state) switch ((state_t)state) { case STATE_DEAD: - g_object_set(cell_state, "stock-id", GTK_STOCK_CLOSE, NULL); + g_object_set(cell_state, "icon-name", "media-playback-stop", NULL); break; case STATE_ACTIVE: - g_object_set(cell_state, "stock-id", GTK_STOCK_YES, NULL); + g_object_set(cell_state, "icon-name", "media-playback-start", NULL); break; case STATE_REHASH: - g_object_set(cell_state, "stock-id", GTK_STOCK_REFRESH, NULL); + g_object_set(cell_state, "icon-name", "view-refresh", NULL); break; case STATE_HASHFAILED: - g_object_set(cell_state, "stock-id", GTK_STOCK_NO, NULL); + g_object_set(cell_state, "stock-id", "dialog-warning", NULL); break; default: g_assert(FALSE); diff --git a/src/customcellrendererstate.h b/src/customcellrendererstate.h index 2d163f3..495185d 100644 --- a/src/customcellrendererstate.h +++ b/src/customcellrendererstate.h @@ -35,10 +35,6 @@ typedef struct _CustomCellRendererStateClass CustomCellRendererStateClass; struct _CustomCellRendererState { GtkCellRendererPixbuf parent; - - /*< private >*/ - gint GSEAL (state); - GdkPixbuf* GSEAL (buffer[3]); }; struct _CustomCellRendererStateClass |
