@@ -1930,6 +1930,47 @@ ensure_current_configuration_is_saved (void)
19301930 g_object_unref (rr_screen );
19311931}
19321932
1933+ static void
1934+ monitor_activate_cb (GtkCheckMenuItem * item , gpointer data )
1935+ {
1936+ MsdXrandrManager * manager = MSD_XRANDR_MANAGER (data );
1937+ struct MsdXrandrManagerPrivate * priv = manager -> priv ;
1938+ MateRROutputInfo * output ;
1939+ GError * error ;
1940+
1941+ ensure_current_configuration_is_saved ();
1942+
1943+ output = g_object_get_data (G_OBJECT (item ), "output" );
1944+
1945+ /*This is borrowed from the capplet in mate-control-center
1946+ *And shares the same limitations concerning monitors
1947+ *which have been turned off and back on without being reconfigured
1948+ */
1949+ if (gtk_check_menu_item_get_active (item )){
1950+ int x , y , width , height ;
1951+ mate_rr_output_info_get_geometry (output , & x , & y , NULL , NULL );
1952+ width = mate_rr_output_info_get_preferred_width (output );
1953+ height = mate_rr_output_info_get_preferred_height (output );
1954+ mate_rr_output_info_set_geometry (output , x , y , width , height );
1955+ mate_rr_output_info_set_active (output , TRUE);
1956+
1957+ }
1958+ else {
1959+ mate_rr_output_info_set_active (output , FALSE);
1960+ }
1961+
1962+ error = NULL ;
1963+ if (!mate_rr_config_save (priv -> configuration , & error )) {
1964+ error_message (manager , _ ("Could not save monitor configuration" ), error , NULL );
1965+ if (error )
1966+ g_error_free (error );
1967+
1968+ return ;
1969+ }
1970+
1971+ try_to_apply_intended_configuration (manager , NULL , gtk_get_current_event_time (), NULL );
1972+ }
1973+
19331974static void
19341975output_rotation_item_activate_cb (GtkCheckMenuItem * item , gpointer data )
19351976{
@@ -2048,6 +2089,47 @@ add_rotation_items_for_output (MsdXrandrManager *manager, MateRROutputInfo *outp
20482089 add_items_for_rotations (manager , output , rotations );
20492090}
20502091
2092+ static void
2093+ add_enable_option_for_output (MsdXrandrManager * manager , MateRROutputInfo * output )
2094+ {
2095+ struct MsdXrandrManagerPrivate * priv = manager -> priv ;
2096+ GtkWidget * item ;
2097+ gulong activate_id ;
2098+
2099+ item = gtk_check_menu_item_new ();
2100+
2101+ if (mate_rr_output_info_is_active (output )){
2102+ gtk_menu_item_set_label (GTK_MENU_ITEM (item ), "Using this monitor" );
2103+ gtk_widget_set_tooltip_text (item , "Turn this monitor off" );
2104+ }
2105+ else {
2106+ gtk_menu_item_set_label (GTK_MENU_ITEM (item ), "Not using this monitor" );
2107+ gtk_widget_set_tooltip_text (item ,"Turn this monitor on" );
2108+ }
2109+
2110+ gtk_widget_show_all (item );
2111+ gtk_menu_shell_append (GTK_MENU_SHELL (priv -> popup_menu ), item );
2112+
2113+ g_object_set_data (G_OBJECT (item ), "output" , output );
2114+
2115+ activate_id = g_signal_connect (item , "activate" ,
2116+ G_CALLBACK (monitor_activate_cb ), manager );
2117+
2118+ /* Block the signal temporarily so our callback won't be called;
2119+ * we are just setting up the UI.
2120+ */
2121+ g_signal_handler_block (item , activate_id );
2122+
2123+ if (mate_rr_output_info_is_active (output )){
2124+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item ), TRUE);
2125+ }
2126+ else {
2127+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (item ), FALSE);
2128+ }
2129+
2130+ g_signal_handler_unblock (item , activate_id );
2131+ }
2132+
20512133static void
20522134add_menu_items_for_output (MsdXrandrManager * manager , MateRROutputInfo * output )
20532135{
@@ -2057,6 +2139,7 @@ add_menu_items_for_output (MsdXrandrManager *manager, MateRROutputInfo *output)
20572139 item = make_menu_item_for_output_title (manager , output );
20582140 gtk_menu_shell_append (GTK_MENU_SHELL (priv -> popup_menu ), item );
20592141
2142+ add_enable_option_for_output (manager , output );
20602143 add_rotation_items_for_output (manager , output );
20612144}
20622145
0 commit comments