47
47
* handled entirely by NetworkManager's L<nm-connection-editor(1)>
48
48
* program and has nothing to do with this code.
49
49
*
50
- * This file is written in a kind of "pseudo-Gtk" which is backwards compatible
51
- * from Gtk 3.0 through at least Gtk 3.22. This is done using a few macros to
52
- * implement old C<gtk_*> functions or map them to newer functions.
50
+ * This file is written in a kind of "pseudo-Gtk" that currently targets Gtk
51
+ * 3.22 exclusively, but may later be extended to a broader Gtk version range.
52
+ * This is done using a few macros to implement old C<gtk_*> functions or map
53
+ * them to newer functions.
53
54
*/
54
55
55
56
#include <config.h>
92
93
#define MAX_SUPPORTED_VCPUS 160
93
94
#define MAX_SUPPORTED_MEMORY_MB (UINT64_C (4000 * 1024))
94
95
95
- #if GLIB_CHECK_VERSION (2 ,32 ,0 ) && GTK_CHECK_VERSION (3 ,12 ,0 ) /* glib >= 2.32 && gtk >= 3.12 */
96
- #define USE_POPOVERS
97
- #endif
98
-
99
96
static void create_connection_dialog (struct config * );
100
97
static void create_conversion_dialog (struct config * config ,
101
98
const char * const * disks ,
@@ -247,10 +244,8 @@ create_connection_dialog (struct config *config)
247
244
password_entry = gtk_entry_new ();
248
245
gtk_label_set_mnemonic_widget (GTK_LABEL (password_label ), password_entry );
249
246
gtk_entry_set_visibility (GTK_ENTRY (password_entry ), FALSE);
250
- #ifdef GTK_INPUT_PURPOSE_PASSWORD /* guaranteed if gtk >= 3.5.12 */
251
247
gtk_entry_set_input_purpose (GTK_ENTRY (password_entry ),
252
248
GTK_INPUT_PURPOSE_PASSWORD );
253
- #endif
254
249
if (config -> auth .password != NULL )
255
250
gtk_entry_set_text (GTK_ENTRY (password_entry ), config -> auth .password );
256
251
table_attach (table , password_entry ,
@@ -1747,21 +1742,15 @@ static void *start_conversion_thread (void *data);
1747
1742
static gboolean conversion_error (gpointer user_data );
1748
1743
static gboolean conversion_finished (gpointer user_data );
1749
1744
static void cancel_conversion_dialog (GtkWidget * w , gpointer data );
1750
- #ifdef USE_POPOVERS
1751
1745
static void activate_action (GSimpleAction * action , GVariant * parameter , gpointer user_data );
1752
- #else
1753
- static void shutdown_button_clicked (GtkToolButton * w , gpointer data );
1754
- #endif
1755
1746
static void shutdown_clicked (GtkWidget * w , gpointer data );
1756
1747
static void reboot_clicked (GtkWidget * w , gpointer data );
1757
1748
static gboolean close_running_dialog (GtkWidget * w , GdkEvent * event , gpointer data );
1758
1749
1759
- #ifdef USE_POPOVERS
1760
1750
static const GActionEntry shutdown_actions [] = {
1761
1751
{ .name = "shutdown" , .activate = activate_action },
1762
1752
{ .name = "reboot" , .activate = activate_action },
1763
1753
};
1764
- #endif
1765
1754
1766
1755
/**
1767
1756
* Create the running dialog.
@@ -1777,14 +1766,8 @@ create_running_dialog (void)
1777
1766
{ "black" , "maroon" , "green" , "olive" , "navy" , "purple" , "teal" , "silver" ,
1778
1767
"gray" , "red" , "lime" , "yellow" , "blue" , "fuchsia" , "cyan" , "white" };
1779
1768
GtkTextBuffer * buf ;
1780
- #ifdef USE_POPOVERS
1781
1769
GMenu * shutdown_menu ;
1782
1770
GSimpleActionGroup * shutdown_group ;
1783
- #else
1784
- GtkWidget * shutdown_menu ;
1785
- GtkWidget * shutdown_menu_item ;
1786
- GtkWidget * reboot_menu_item ;
1787
- #endif
1788
1771
1789
1772
run_dlg = gtk_dialog_new ();
1790
1773
gtk_window_set_title (GTK_WINDOW (run_dlg ), g_get_prgname ());
@@ -1810,19 +1793,12 @@ create_running_dialog (void)
1810
1793
gtk_text_buffer_create_tag (buf , tag_name , "foreground" , tags [i ], NULL );
1811
1794
}
1812
1795
1813
- #if GTK_CHECK_VERSION (3 ,16 ,0 ) /* gtk >= 3.16 */
1814
1796
/* XXX This only sets the "CSS" style. It's not clear how to set
1815
1797
* the particular font. However (by accident) this does at least
1816
1798
* set the widget to use a monospace font.
1817
1799
*/
1818
1800
GtkStyleContext * context = gtk_widget_get_style_context (v2v_output );
1819
1801
gtk_style_context_add_class (context , "monospace" );
1820
- #else
1821
- PangoFontDescription * font ;
1822
- font = pango_font_description_from_string ("Monospace 11" );
1823
- gtk_widget_override_font (v2v_output , font );
1824
- pango_font_description_free (font );
1825
- #endif
1826
1802
1827
1803
log_label = gtk_label_new (NULL );
1828
1804
set_alignment (log_label , 0. , 0.5 );
@@ -1845,7 +1821,6 @@ create_running_dialog (void)
1845
1821
status_label , TRUE, TRUE, 0 );
1846
1822
1847
1823
/* Shutdown popup menu. */
1848
- #ifdef USE_POPOVERS
1849
1824
shutdown_menu = g_menu_new ();
1850
1825
g_menu_append (shutdown_menu , _ ("_Shutdown" ), "shutdown.shutdown" );
1851
1826
g_menu_append (shutdown_menu , _ ("_Reboot" ), "shutdown.reboot" );
@@ -1854,23 +1829,13 @@ create_running_dialog (void)
1854
1829
g_action_map_add_action_entries (G_ACTION_MAP (shutdown_group ),
1855
1830
shutdown_actions ,
1856
1831
G_N_ELEMENTS (shutdown_actions ), NULL );
1857
- #else
1858
- shutdown_menu = gtk_menu_new ();
1859
- shutdown_menu_item = gtk_menu_item_new_with_mnemonic (_ ("_Shutdown" ));
1860
- gtk_menu_shell_append (GTK_MENU_SHELL (shutdown_menu ), shutdown_menu_item );
1861
- gtk_widget_show (shutdown_menu_item );
1862
- reboot_menu_item = gtk_menu_item_new_with_mnemonic (_ ("_Reboot" ));
1863
- gtk_menu_shell_append (GTK_MENU_SHELL (shutdown_menu ), reboot_menu_item );
1864
- gtk_widget_show (reboot_menu_item );
1865
- #endif
1866
1832
1867
1833
/* Buttons. */
1868
1834
gtk_dialog_add_buttons (GTK_DIALOG (run_dlg ),
1869
1835
_ ("_Cancel conversion ..." ), 1 ,
1870
1836
NULL );
1871
1837
cancel_button = gtk_dialog_get_widget_for_response (GTK_DIALOG (run_dlg ), 1 );
1872
1838
gtk_widget_set_sensitive (cancel_button , FALSE);
1873
- #ifdef USE_POPOVERS
1874
1839
shutdown_button = gtk_menu_button_new ();
1875
1840
gtk_button_set_use_underline (GTK_BUTTON (shutdown_button ), TRUE);
1876
1841
gtk_button_set_label (GTK_BUTTON (shutdown_button ), _ ("_Shutdown ..." ));
@@ -1880,13 +1845,6 @@ create_running_dialog (void)
1880
1845
gtk_menu_button_set_use_popover (GTK_MENU_BUTTON (shutdown_button ), TRUE);
1881
1846
gtk_menu_button_set_menu_model (GTK_MENU_BUTTON (shutdown_button ),
1882
1847
G_MENU_MODEL (shutdown_menu ));
1883
- #else
1884
- shutdown_button = GTK_WIDGET (gtk_menu_tool_button_new (NULL ,
1885
- _ ("_Shutdown ..." )));
1886
- gtk_tool_button_set_use_underline (GTK_TOOL_BUTTON (shutdown_button ), TRUE);
1887
- gtk_menu_tool_button_set_menu (GTK_MENU_TOOL_BUTTON (shutdown_button ),
1888
- shutdown_menu );
1889
- #endif
1890
1848
gtk_widget_set_sensitive (shutdown_button , FALSE);
1891
1849
gtk_dialog_add_action_widget (GTK_DIALOG (run_dlg ), shutdown_button , 2 );
1892
1850
@@ -1897,14 +1855,6 @@ create_running_dialog (void)
1897
1855
G_CALLBACK (gtk_main_quit ), NULL );
1898
1856
g_signal_connect (G_OBJECT (cancel_button ), "clicked" ,
1899
1857
G_CALLBACK (cancel_conversion_dialog ), NULL );
1900
- #ifndef USE_POPOVERS
1901
- g_signal_connect (G_OBJECT (shutdown_button ), "clicked" ,
1902
- G_CALLBACK (shutdown_button_clicked ), shutdown_menu );
1903
- g_signal_connect (G_OBJECT (shutdown_menu_item ), "activate" ,
1904
- G_CALLBACK (shutdown_clicked ), NULL );
1905
- g_signal_connect (G_OBJECT (reboot_menu_item ), "activate" ,
1906
- G_CALLBACK (reboot_clicked ), NULL );
1907
- #endif
1908
1858
}
1909
1859
1910
1860
/**
@@ -2367,7 +2317,6 @@ cancel_conversion_dialog (GtkWidget *w, gpointer data)
2367
2317
gtk_widget_destroy (dlg );
2368
2318
}
2369
2319
2370
- #ifdef USE_POPOVERS
2371
2320
static void
2372
2321
activate_action (GSimpleAction * action , GVariant * parameter , gpointer user_data )
2373
2322
{
@@ -2377,16 +2326,6 @@ activate_action (GSimpleAction *action, GVariant *parameter, gpointer user_data)
2377
2326
else if (STREQ (action_name , "reboot" ))
2378
2327
reboot_clicked (NULL , user_data );
2379
2328
}
2380
- #else
2381
- static void
2382
- shutdown_button_clicked (GtkToolButton * w , gpointer data )
2383
- {
2384
- GtkMenu * menu = data ;
2385
-
2386
- gtk_menu_popup (menu , NULL , NULL , NULL , NULL , 1 ,
2387
- gtk_get_current_event_time ());
2388
- }
2389
- #endif
2390
2329
2391
2330
static void
2392
2331
shutdown_clicked (GtkWidget * w , gpointer data )
0 commit comments